1
1
Fork 0
mirror of https://github.com/QB64-Phoenix-Edition/QB64pe.git synced 2024-07-09 09:35:13 +00:00
Commit graph

595 commits

Author SHA1 Message Date
Samuel Gomes 2957c41061 Workaround for _SNDCOPY for _SNDNEW sounds. Another one to follow for _SNDOPEN(buffer, "memory") 2023-01-08 00:14:59 +05:30
Samuel Gomes 5a893b8ffc Update comments and some beautification 2023-01-06 20:32:03 +05:30
Samuel Gomes eacee1f609 Add PushMonoSampleFrames 2023-01-06 12:21:17 +05:30
Samuel Gomes f7690aea17 Update comments 2023-01-02 16:24:08 +05:30
Samuel Gomes ecfe4fb1be Format code 2023-01-01 23:17:56 +05:30
Samuel Gomes 6c72deafc1 Improve _SNDOPEN test and supress printfs in Hively replayer code 2023-01-01 23:14:05 +05:30
Samuel Gomes e4273c0a68 Add Amiga AHX & HVL decoder 2023-01-01 22:56:02 +05:30
Samuel Gomes 061bf6af3d Rename _NEWSOUND to _SNDNEW to align with _SND* APIs 2022-12-31 12:00:38 +05:30
Samuel Gomes da9d9e871c Fix for template argument deduction/substitution failed 2022-12-31 05:18:22 +05:30
Samuel Gomes 4c80f6bcea Implement feature request #28 2022-12-31 01:49:23 +05:30
Samuel Gomes eebb56afd5 Implement load sound from memory #232 2022-12-22 20:42:27 +05:30
Samuel Gomes a72f80258f Address #186 2022-12-22 15:11:20 +05:30
Samuel Gomes bc65076feb Reduce mutex locks by using 2 vectors for _SNDRAW 2022-12-21 11:47:41 +05:30
Samuel Gomes 1357f53041 Add NO_PITCH, NO_SPATIALIZATION flags for raw ma_sound 2022-12-16 12:28:22 +05:30
Samuel Gomes bcc7105641 Avoid getting queue size inside loop 2022-12-16 03:50:32 +05:30
Samuel Gomes bd82b24ac7 Improve SOUND timing - #167 2022-12-15 10:47:27 +05:30
Samuel Gomes df9b739e23 Address #166 - _SNDRAW using miniaudio data source 2022-12-15 09:16:42 +05:30
Samuel Gomes cf16cb0c00 Replace custom queue code with C++ STL queue 2022-12-13 09:12:52 +05:30
Samuel Gomes 7f2ab7e83a
Merge branch 'QB64-Phoenix-Edition:main' into miniaudio-fixes 2022-12-04 01:32:39 +05:30
Matthew Kilgore 7ac2eefcb8 Fix slowdown of _ScreenX and _ScreenY
The commands _ScreenX and _ScreenY got significantly slower due to the
need to wait for the GLUT thread to wake up and execute the glutGet()
command for them. We've already seen a few programs (including the IDE)
where this behavior completely grinds the program to a halt, so we
definitely can't keep it.

The simple solution here is to not call glutGet() on every _ScreenX/Y
command. Instead every time the idle/timer function runs we get the
current values for the relevant glutGet() variables and store them.
libqb_glut_get() then checks if the value being read is one of the ones
we read in the idle/timer functionand if so just returns the last read
value. By doing it this way the commands no longer has to wait on the
GLUT thread for the result.
2022-11-30 17:33:17 -05:00
Matthew Kilgore f7fabda198 Fix random seg faults on exit
Fairly straightfowrad, programs were randomly seg faulting on exit. This
was happening due to GLUT registering a cleanup function via atexit(),
which then gets called when exit() is called.

The issue happens when exit() is called on a thread other than the GLUT
thread, which leads to the exit() call then attempting to cleanup GLUT
while the other thread is still using it, which randomly leads to seg
faults.

Fixing this is slightly annoying. We cannot stop the GLUT thread, as
the basic GLUT API (which is used on Mac OS) simply does not offer a way
to exit the glutMainLoop() call. Thus the simplest solution is to simply
make sure we call exit() on the GLUT thread, which we can fairly easily
due via the message queue.

That being the case, a new libqb_exit() API was added, which simply
regsiters the GLUT exit message and then waits for the program to end.
The atexit() handler then runs on the GLUT thread and everything works
out fine.

In the future we probably should redo the exit logic a bit so that all
the threads are actually stopped/joined to ensure the exit process is
consistent, however this is good enough for now. Also, there's plenty of
error states which call exit() which I did not address.
2022-11-29 20:04:54 -05:00
Matthew Kilgore 6c288ecb6f Don't compile libqb.cpp as Objective-C on Mac OS
With the recent changes to libqb.cpp to pull out some of the GLUT logic,
the only actual Objective-C in libqb.cpp was pulled out. That being the
case, it's no longer necessary to have libqb.mm for compiling libqb.cpp,
so we're removing it to simplify the compliation logic a bit.
2022-11-29 20:04:54 -05:00
Matthew Kilgore 72193e34e5 Add GLUT command queue, processed on GLUT thread
This fixes all the code so that all the calls to glut functions
happen on the same thread that is running GLUT.

We achieve this by creating a queue of GLUT commands to execute.
Commands can be added to the queue anywhere in the code, and then the
queue is processed on the GLUT thread via it's idle func or timer func.
The command is run and if necessary the result is provided in the
message queue object. Each object contains a completion which can be
waited on to block until the GLUT thread has processed the command.

Fixes: #66
2022-11-29 20:04:54 -05:00
Matthew Kilgore d678be717c Move GLUT initialization logic into separate .cpp file 2022-11-29 20:04:53 -05:00
Samuel Gomes 93bf793c19
Merge branch 'QB64-Phoenix-Edition:main' into miniaudio-fixes 2022-11-27 10:58:57 +05:30
Matt Kilgore 8185234792
Merge branch 'main' into fix-glut-init-logic 2022-11-26 22:42:46 -05:00
Roland Heyder ec6e648007 Simplify #include
Solving #119
2022-11-27 00:11:04 +01:00
Matthew Kilgore d2aa572a94 Fix GLUT initialization logic
The current GLUT initialization logic is flawed because it allows the
QB64 code portion of the program to start on a separate thread at the
same time that the GLUT code is starting. This results in a race where
some commands won't work for a brief period at the beginning of the
program (with "won't work" being very inconsistent, some return invalid
values, some have a chance at seg faulting).

The same issue also leads to us adding many `while (!window_exists)`
checks in an attempt to solve this race for some of the commands.
Unfortunately this solution is very inconsistently applied leading to
some deadlock situations, and really it's a silly solution when this
race is entirely our creation anyway.

To fix this, the logic was changed such that we perform all of the GLUT
initialization besides calling `glutMainLoop()` before we ever start the
thread that runs the actual QB64 code. By doing it this way we ensure
that the GLUT initialization has already taken place before the code
runs and thus the race is gone.

Things get a bit more interesting with $SCREENHIDE, because that simply
delays the execution of the GLUT initialization indefinitely until
_ScreenShow is done. This was previously very buggy since some commands
rely on FreeGLUT being up and will simply hang the entire program if
run. Other commands have logic to catch this and simply return zero.

The above issue is solved with the `NEEDS_GLUT()` and `OPTIONAL_GLUT()`
macros. Both of them simply check if the GLUT initialization has taken
place and exit the current function if it has not. The difference
between the two is that `NEEDS_GLUT()` throws an 'illegal function call'
error while `OPTIONAL_GLUT()` simply exits with no error. The choice of
behavior of each function was based upon its previous behavior - if it
checked `screen_hide` and exited with no error previously, then
`OPTIONAL_GLUT()` was used. If it deadlocked or similar then
`NEEDS_GLUT()` was used (so instead of deadlocking, it now produces an
error). In this way, programs can now never get stuck due to the use of
`$SCREENHIDE` and all the commands have consistent behavior that can be
relied upon.

Fixes: #234
2022-11-26 01:33:32 -05:00
Samuel Gomes b29eaed459
Merge branch 'QB64-Phoenix-Edition:main' into miniaudio-fixes 2022-11-26 07:59:30 +05:30
SteveMcNeill ca7d6ee289 fix comment
Whoops!  Not enough coffee, I guess.  ;)
2022-11-25 00:52:29 -05:00
SteveMcNeill 0d76a7bbed Simplify multi-line logic to single line. 2022-11-24 15:00:54 -05:00
SteveMcNeill 6d055e5df1 Bugfix to _FONT
Fonts 9, 15, and 17 can *only* be used in SCREEN 0.  Attempting to use them in graphic screens results in a seg fault and an instant program crash on Windows.  This is definitely the most undesirable of behaviors for a program, and can easily be caught and dealt with just by tossing a simple "Illegal Function Call" error for the issue.
2022-11-24 08:34:31 -05:00
Samuel Gomes 50c1430456
Merge branch 'QB64-Phoenix-Edition:main' into miniaudio-fixes 2022-11-24 07:17:04 +05:30
Matthew Kilgore c84220055f Add FreeGLUT warning function
Registering a warning function keeps FreeGLUT from writing warnings to
the console (which is not desirable since it conflicts with our own
console output).
2022-11-22 23:53:04 -05:00
Matthew Kilgore 11a5b8be8e _OpenClient() should return zero on connection failure, not error 2022-11-20 18:44:24 -05:00
Matthew Kilgore 445408d95b _StatusCode() should give the correct error on invalid handle type
Passing a handle of the invalid type (Ex. TCP) to _StatusCode should
give error 52, but it gies error 9.
2022-11-20 04:38:03 -05:00
Matthew Kilgore 12c9c35db5 Add _StatusCode command for HTTP handles
The _StatusCode command returns the status code on the HTTP response
when given a HTTP handle from _OpenClient().
2022-11-20 04:04:02 -05:00
Matthew Kilgore ffdf9db390 Add libqb.cpp stream support for HTTP
Modifies libqb.cpp to add support for opening HTTP connections via
_OPENCLIENT(). This makes use of the libqb_http API in ./libqb, which is
backed by libcurl.

This also includes a bit of refactoring for some of the code that
required additions. I replaced a few of the integer values with enums,
and added a new entry for Http and then implemented it in all the
necessary locations. In addition to `_OPENCLIENT()`, there is also
support for using HTTP connections with `EOF()`, `LOF()`, `GET #`
(variable and fixed length), and `CLOSE`.

I additionally fixed an issue of parsing the colon parts of the
`_OPENCLIENT()` parameter, where having too many colons would cause the
program to crash. Since we only allow so many parts to begin with it I
simply limited the max number of parts it will split to 10.

Fixes: #98
Fixes: #46
2022-11-19 15:13:26 -05:00
Matthew Kilgore 45d52271da Add libqb_http API for HTTP connections
This adds the libqb_http API, which is designed to support HTTP and
HTTPS usage from QB64-PE source.

The design consists of a single thread which services all the HTTP(s)
connections. There are then various libqb_http APIs exposed that allow
interacting with this thread to create a new connection, query
connection status, read data, or close the connection.

Internally the thread makes use of the curl_multi interface to allow a
single thread to service multiple HTTP(s) connections in parallel. This
means you can _OPENCLIENT() multiple HTTP connection in a row and all of
them will be serviced at the same time in whatever order data is
available.

HTTP is optional and selected via a Makefile setting. A stub is swapped
in if HTTP support is not used, which avoids need to add another build
flag to libqb.cpp.
2022-11-19 15:13:26 -05:00
Samuel Gomes 4c5072e0aa Enable PulseAudio on Linux 2022-11-18 10:46:58 +05:30
Matthew Kilgore 34a7df535e Add libcurl to the repository
This copy is used for building on Windows. For Linux and OS X we used
the system-provided copy.
2022-11-17 22:03:41 -05:00
Samuel Gomes 96e2c92bd6
Merge branch 'QB64-Phoenix-Edition:main' into miniaudio-fixes 2022-11-16 08:13:26 +05:30
Matthew Kilgore a28342be99 Fix password handling in _InputBox$ on Windows
We were incorrectly treating the empty string and NULL the same and
using a password dialog for both. It now has the correct behavior of
displaying the password when provided the empty string, but just
displaying a blank input box when provided NULL.
2022-11-14 20:23:41 -05:00
Samuel Gomes 5cefba8609 Merge branch 'miniaudio-fixes' of https://github.com/a740g/QB64pe into miniaudio-fixes 2022-11-14 23:46:22 +05:30
Samuel Gomes ea80bddd51
Merge branch 'QB64-Phoenix-Edition:main' into miniaudio-fixes 2022-11-14 23:33:25 +05:30
Matthew Kilgore e6964dfc69 Include stdint.h on Windows, change integer defines to use them
It seems we weren't including stdint.h on Windows by mistake. Likely we
were getting it anywy from some other header, but it sounds like that
got changed in newer versions of MinGW and either way we shouldn't rely
on that.

Being that we include stdint.h on all platforms, I also changed os.h to
always use these types when defining the `int32` and friends sized
types. Ideally we get rid of those defines in the future but we can at
least use the stdint.h types going forward (as we already have).
2022-11-12 19:48:26 -05:00
Matthew Kilgore 1509f85719 Improve _InputBox$ support on Windows
This applies various dialog settings so that the dialog is always on
top, and also so that Tab works as expected to move between the
controls. The Edit control is moved first so that it's focused when the
window appears.
2022-11-12 19:48:17 -05:00
Matthew Kilgore 3f709ba65b Add logic to correctly discover our process's Window
Currently we have two different ways of determining what Window handle
to tie our dialogs too - we either use GetForegroundWindow(), or create
a completely new and hidden handle. The associated window determines
what process names shows up on notifications, and also which window
can't be interacted with while a dialog is open.

Both of those approaches aren't really good. In the case of
GetForegroundWindow(), it just returns whatever window the user has in
focus, which might be a completely different process. With the hidden
window, it means the dialog and notification aren't really tied to the
QB64-PE program, so you can still interact with the window even when a
dialog is open, and the notification doesn't show an exectuable name.

To solve this we're now using EnumWindows() to enumerate over all the
Windows on the system and find one associated with our ProcessId. We
then check if it's the top-level window and return it if it is.

If that process fails to find a window (such as if this is a
console-only program, or $SCREENHIDE is used) then we check if
GetConsoleWindow() gives us a handle and use that.

If neither approach works, then we fall back to creating a hidden window
so that the dialogs can still work.
2022-11-12 19:16:43 -05:00
Samuel Gomes 7c2f709b7e Change blockSampleFrames for reduced latency 2022-11-11 18:50:59 +05:30
Samuel Gomes 2a5e2e8add Add O2 by default due to resampling code in audio 2022-11-10 18:48:41 +05:30
Samuel Gomes ae35e596b4
Merge branch 'QB64-Phoenix-Edition:main' into miniaudio-fixes 2022-11-10 07:27:37 +05:30
Matt Kilgore a85f10e35c
Merge branch 'main' into paint-fill-fix 2022-11-08 21:55:53 -05:00
Samuel Gomes 28bdc23ce3
Merge branch 'QB64-Phoenix-Edition:main' into miniaudio-fixes 2022-11-08 23:54:25 +05:30
Matthew Kilgore ac8aac39b7 Use signed type for xdelta and ydelta arrays
I accidentally declared these as uint32_t even though I store -1 in
them. It was working anyway due to the implicit conversion that happens
when adding it to an int32_t, but it should be fixed regardless.
2022-11-08 01:32:05 -05:00
Matthew Kilgore 4f5af8888e Fix PAINT when border color is not supplied
The border color parameter to PAINT is optional, but sub_paint was not
handling that case. What it should do in that situation is keep painting
until it finds pixels that are not the same color as the original
starting pixel was. Instead it would simply assume border color was
valid and paint until it finds color zero (the default parameter value
when it's not provided).

This was originally reported in QB64Official/qb64#2, and Walt
(@TheJoyfulProgrammer) fixed it in QB64Official/qb64#38. Functionally
this is the same change, however I'm checking `passed & 4` to see
whether a border color was provided rather than `bordercol == NULL`.
The later has problems if the provided bordercolor is zero, which is
allowed since zero is a valid color. The `passed` argument indicates
which of the function arguments were actually provided in the QB64
source that called PAINT.

Additionally, along with the `while (true)` loop that Walt changed I
went ahead and removed the duplication of the sections for each
direction. We now just use a couple of arrays to determine which
direction we're checking and loop over all 4.
2022-11-08 00:59:12 -05:00
Matthew Kilgore 90b3bd2662 Address build warnings on tinyfiledialogs.c
A function was made unnecessary but wasn't removed, triggering a
warning. Additionally gcc likes parenthesis around `=` assignments used
for conditions.
2022-11-08 00:49:13 -05:00
Matthew Kilgore 5b238467a9 Use hidden input if defaultText is blank
Fairly simple, this sets the ES_PASSWORD flag when the default text is
blank.

Additionally I fixed the dialog callback to correctly call EndDialog()
rather than DestroyWindow().
2022-11-08 00:49:13 -05:00
Matthew Kilgore 7bf68383d5 Fix warnings, remove unused code in tinyfiledialogs.c 2022-11-08 00:49:13 -05:00
Matthew Kilgore ee9f8e4404 Remove quote checks on Windows
These are the last of the quote checks, these don't require any
associated changes as the underlying Win32 functions already allow
quotes. They were simply added to keep parity with the functionality on
other platforms, that that has since been fixed.
2022-11-08 00:49:13 -05:00
Matthew Kilgore ec0ec10652 Add missing static to char array in tinyfd_openFileDialog
Fairly simple, lBuff is used to return the resulting filename and has to
be static so that it's still valid when the function exits.
2022-11-08 00:49:13 -05:00
Matthew Kilgore 0115029e5e Implement InputBox using DialogBoxIndirect
This removes the VBS based InputBox for Windows and replaces it with a
version that uses DialogBoxIndirect to create the dialog. While it is a
bit more complicated in some respects, it removes any concerns about the
contents of the strings as they're no longer being inserted into the
generated script.

It also has the advantage that it doesn't spawn another process (which
then shows up in the task bar in some situations).

With this changes quote characters are allowed in all of the parameters.
2022-11-08 00:49:13 -05:00
Samuel Gomes 839e1479a0
Merge branch 'QB64-Phoenix-Edition:main' into miniaudio-fixes 2022-11-08 07:56:40 +05:30
Matthew Kilgore f73a1da97d Fix osascript escaping on Mac OS
Escaping the osascript commands requires two layers of escaping: One for the
script itself, and one for the sh arguments.

For the script itself, we simply have to escape the " character with \". When
then take the result of that and escape it sutably for sh arguments in single
quotes. We already have a function for that so we simply call that to do the
job.
2022-11-07 02:43:29 -05:00
Samuel Gomes e9905d6cd0
Merge branch 'QB64-Phoenix-Edition:main' into miniaudio-fixes 2022-11-07 00:16:25 +05:30
Matthew Kilgore b20aade638 Swap NotifyPopup to use Shell_NotifyIcon
Fairly straight forward, the Powershell code was fundimentally just
calling Shell_NotifyIcon under the covers which we can easily do
ourself. The notification has to be tied to a window, so I simply create
a hidden one to use.

A nice improvement here is that instead of having to use the Powershell
icon we can make use of the EXE icon if one was provided. If one is not
provided then we use the default 'application' icon.
2022-11-06 01:08:36 -04:00
Samuel Gomes 8f405ecde7
Merge branch 'QB64-Phoenix-Edition:main' into miniaudio-fixes 2022-11-05 22:45:41 +05:30
Matthew Kilgore c945214cb8 Fix quoting of arguments to dialog functions on Linux
tinyfiledialogs had lots of issue surounding the quoting of the
arguments to the dialog functions. The arguments are effectively placed
verbadim into shell commands, and without any proper treatment they
would get accidentally evaluated by the shell, which is a big problem.
Additionally, any arguments containing quotes would just not work since
they would screw up the underlying shell command.

This change fixes all that for Linux. Every argument to the dialog
functions is now surrounded in single quotes, which prevents any
evaluation of the string by the shell. Additionally, because this is
standard the only chracters that need special treatment are the single
quote characters, and proper escaping for them has been added. The
result is that the dialog functions can now accept arguments that hvae
single and double quotes in them (on Linux).
2022-11-05 00:36:48 -04:00
Samuel Gomes d2cd85825f Update miniaudio to v0.11.11 2022-11-04 22:43:27 +05:30
Samuel Gomes 9a509cab61 Update miniaudio to v0.11.10 2022-11-03 18:11:20 +05:30
Matthew Kilgore 980d646317 Add back internal MessageBox function
Unfortunately InForm code calls this function directly via
`DECLARE LIBRARY`. For the moment we're adding it back in to keep those
programs functioning, in the future it may be removed.
2022-10-31 00:14:20 -04:00
Samuel Gomes 2f84616168 Fix _OPENFILEDIALOG$ to accept -1 for allowMultipleSelects& 2022-10-30 04:35:46 +05:30
Samuel Gomes 5c9766ce97 Update tinyfiledialogs to v3.8.9 2022-10-29 17:18:50 +05:30
Samuel Gomes 7e533a2473 Update test license files 2022-10-25 07:28:35 +05:30
Samuel Gomes d14d688181 Fix IMAGE_GET_BGRA_... macros 2022-10-25 04:47:27 +05:30
Samuel Gomes a122331d6d Include stdarg.h in gui.h 2022-10-25 04:34:41 +05:30
Samuel Gomes 56c7936fb4 Address issues mentioned in #216 2022-10-25 04:24:01 +05:30
Samuel Gomes 6b60048d9e Simplify gui_tokenize() 2022-10-24 02:59:51 +05:30
Samuel Gomes fb00990bab Replace strtok with strtok_r 2022-10-24 02:09:55 +05:30
Samuel Gomes 6a74b3f487 Replace libqb alert, MessageBox & MessageBox2 with tiny file dialogs 2022-10-24 01:24:57 +05:30
Samuel Gomes 98e40c173d Fix common dialogs build.mk bug 2022-10-23 22:44:39 +05:30
Samuel Gomes 327d753206 Move qbs_new_txt_len() declaration to libqb.h 2022-10-23 18:23:35 +05:30
Samuel Gomes 93e58baa1d Common dialogs support 2022-10-23 12:57:02 +05:30
Samuel Gomes a2e77d7557 Only change _SNDBAL stereo panning if x is passed. Mimic old OpenAL behavior. 2022-10-05 15:28:04 +05:30
Samuel Gomes 7e63a68407 Simplify sub__sndplaycopy 2022-10-05 06:31:46 +05:30
Samuel Gomes f49f8bdf06 Implement _SNDPLAYCOPY enhancement #185 2022-10-05 02:33:44 +05:30
Samuel Gomes c0e3f3608c Add O2 to build.mk 2022-09-18 23:46:54 +05:30
Samuel Gomes fa0ba3e5d8
Merge branch 'main' into main 2022-09-18 14:49:58 +05:30
Samuel Gomes 9681aa1d30 Update code to use C++ unordered_map 2022-09-18 00:03:08 +05:30
Matthew Kilgore aea4a6058e Fix linking audio when using $CONSOLE:ONLY
A quick fix, but providing `DEPENDENCY_CONSOLE_ONLY` when compiling
audio.cpp tells `common.h` to avoid pulling in `freeglut.h`, which fixes
the linking issue.

Fixes: #172
2022-09-17 03:06:24 -04:00
Samuel Gomes bb8bd56689 Merge branch 'main' of https://github.com/a740g/QB64PE 2022-09-17 08:53:38 +05:30
Samuel Gomes a100a434e4 Fix #175 2022-09-17 08:53:32 +05:30
Matthew Kilgore 84f1165776 Fix _MOUSEMOVE when window is resized
`sub__mousemove` is trying to use `x_scale`, `y_scale`, `x_offset`, and
`y_offset` to calculate where the mouse should be in the event the
window coordinates are different from the screen coordinates.

Unfortunately, all four of those variables are actually never set in the
program. The real scale values and offsets (in the event of
letterboxing) are stored in `environment_2d__` values. This change
switches `sub__mousemove` to simply use the correct values when
calculating the mouse position.

Because `x_scale` and `y_scale` are not used anywhere else I just
removed them completely. I wanted to remove `x_offset` and `y_offset` as
well but there are a few spots that make use of it. It must be a bug,
since they are never assigned values other than zero, but I'm not sure
if the correct fix for the other locations is to use the
`environment_2d__` value or do nothing, so I'm leaving them for now and
we can address them later.
2022-09-10 15:31:22 -04:00
Samuel Gomes 8425f117a7 Fix #169 & #170 2022-09-10 04:08:31 +05:30
Matthew Kilgore cd5e312f5a Revert changes to miniaudio.h, move changes elsewhere
Changing midiaudio.h will make it harder to incorporate new versions
into QB64-PE as they come out. To fix that I have reverted all the
changes to midiaudio.h and moved the few private parts we were using
into a separate 'filepath' API that's part of libqb.
2022-09-08 23:59:19 -04:00
Matthew Kilgore 3e4477521a fix audio midi vtable linking 2022-09-04 23:35:14 -04:00
Matthew Kilgore 2b3403745c Add initial MIDI language support
This adds MIDI support to the language as a new unstable feature. There
are two new metacommands that come with this:

$Unstable: Midi
$MidiSoundFont: [Default|"filename"]

The $Unstable command is required to be able to use any of the other
commands, and just signifies that this is not a full part of the
language yet and may change in breaking ways before the API is
finalized.

The $MidiSoundFont command enables MIDI support in the compiled program,
and also specifies what sound font to use to play MIDI files. "Default"
will make use of the soundfont placed at
'./internal/support/default_soundfont.sf2', and otherwise a filename can
be specified to use any soundfont wanted.

In either case, the selected sound font is compiled into the executable
and then loaded at runtime.

Fixes: #115
2022-09-04 23:35:14 -04:00
Samuel Gomes d3854630cf Fix usage of mem_block type in _MEMSOUND 2022-09-04 05:16:41 +05:30
Matthew Kilgore f03b55808b Remove DPI Awareness on Windows
DPI Awareness allows a program to tell Windows that it will handle
properly scaling itself for the screen's DPI. Thus when a program is DPI
Aware, it will always see the actual screen size. When a program is not
DPI Aware, then Windows will scale the program according to the
selection by the user, and the reported screen size will match the
scaled size rather than the actual screen size.

Commit 189cdb8e added logic to enable DPI Awareness on Windows, but it
was hidden behind a `WINVER` check. This meant it was not actually in
use because at the time QB64 did not set a `WINVER` high enough to
actually enable that code. As such all Windows versions of QB64
including v2.0.2 were not DPI Aware.

Much later-on, Commit 869e361e declared a `_WIN32_WINNT` of `0x0600`,
which seems to have also declared `WINVER` as the same and thus enabled
the DPI Awareness logic. As a consequence, QB64-PE programs no longer
get scaled even though they don't have a way to acquire the current DPI
to do proper scaling themselves.

Since the behavior change was unintentional and proper language support
is not there, we're considering the addition of DPI Awareness a bug. It
will be added back some time later with more language support to allow
it to be properly used.
2022-09-02 23:50:23 -04:00
Samuel Gomes f99eb27717 Remove all _SHR & _SHL changes 2022-09-01 16:15:42 +05:30
Samuel Gomes 5812433b9d Added limits.h to common.h 2022-09-01 07:25:01 +05:30
Samuel Gomes 2ed17f6198 Add _ROR & _ROL support. Fix issues with _SHR & _SHL 2022-09-01 06:51:06 +05:30
Matthew Kilgore 30c0634d20 Fix High-DPI awareness on Windows
We started defining `_WIN32_WINNT` a little while ago to express that we
require Windows Vista or above for support. This enables us to access
some Windows Vista-only APIs. The fact that `WINVER` also needs to be
defined was missed, and it seems that defining one means the other no
longer gets defined automatically as it did before. Thus we're simplying
now also defining `WINVER` the same as `_WIN32_WINNT`.

This fixes High-DPI awareness and a few other things that were gated
behind WINVER checks.
2022-08-28 21:44:07 -04:00
Samuel Gomes 26391445ee Updated comments 2022-08-28 02:16:56 -04:00
Samuel Gomes 124251f8f8 Fixed Linux compile issue - extra space in #include. Doh! 2022-08-28 02:16:56 -04:00
Samuel Gomes 9ed193346a Update QB64-PE image library to convert images to 8bpp 2022-08-28 02:16:56 -04:00
Samuel Gomes d3da6da2fa Simplified image library. Added PCX support using dr_pcx 2022-08-28 02:16:56 -04:00
Matthew Kilgore c989be69f6 Disable MIDI support
This will be added back soon with with functionality to be able to
optionally enable it.
2022-08-27 14:27:55 -04:00
Matthew Kilgore 48208e2eda Change miniaudio build logic to always clean all files 2022-08-27 14:27:55 -04:00
Matthew Kilgore 41cc1e6569 Integrate the miniaudio backend into the build
This integrates the miniaudio backend, using a new `DEP_AUDIO_MINIAUDIO`
flag to enable it. This will allow consumers to choose which backend to
use.
2022-08-27 14:27:55 -04:00
Matthew Kilgore 481906977e Add a740g's miniaudio backend
This is a single commit adding all of a740g's audio backend. Later
commits will connect it together with QB64PE itself.
2022-08-27 14:27:55 -04:00
Roland Heyder 2ec897b75d Step 10: Update remaining stuff
- checks all remaining occurrences of the term 'qb64', some remain untouched, some are renamed according to context
- also added new logo for README.md
- this step does finalize the 'Phoenix Edition' re-branding
2022-08-12 02:54:12 +02:00
Roland Heyder e68582b6f2 Step 7: Rename qb64.exe to qb64pe.exe
- Includes related LNX/OSX files
- Excludes mentions in the help (*.txt) files
2022-08-11 18:07:57 +02:00
Roland Heyder 96fc1eb3a9 Step 5: Update embedded images in libqb.cpp
- replaced default icon image data, which is used, if _ICON is used w/o parameter, but no $EXEICON is specified either (see also Step 1)
- this step completes icon related changes
2022-08-10 20:02:00 +02:00
Matthew Kilgore 94c2b56b69 Use mutex guard in completion implementation 2022-06-14 23:58:04 -04:00
Matthew Kilgore 298331e490 posix mutex shouldn't allow NULL
We shouldn't allow mutex lock/unlock to silently do nothing if NULL is
passed, as that is very likely a bug. Beyond that the Windows version
doesn't do this, so it's inconsistent as well.
2022-06-14 23:56:17 -04:00
Matthew Kilgore 869e361ee4 Move QB64 compiler settings to libqb-common.h
This moves a lot of the preprocessor flags for what compiler/platform
we're using into a libqb-common.h header inside the libqb/include
folder. This gets included at the top of every libqb .cpp file, and is
intended to be fairly small, providing only necessary things like
_WIN32_WINNT (which needs to be defined before including <windows.h> or
friends).
2022-06-12 00:28:16 -04:00
Matthew Kilgore cde7afef30 Use libqb_mutex in libqb.cpp
libqb_mutex can replace the existing Mutex handling we do in libqb.cpp
2022-06-11 22:47:06 -04:00
Matthew Kilgore 4052b8cc19 Add append-only buffer API
The Buffer API implements an append-only buffer, where you can write to
the end or read from the beginning. Data that is read is discarded from
the buffer, and you can query the buffer to get the current amount of
data inside.

Internally the buffer API is implemented as a chain of separate buffers.
This is done to avoid having to resize the existing buffer, which is
expensive. We keep track of where the reading currently is, and discard
the internal buffers after all the data in them is read.
2022-06-11 22:47:06 -04:00
Matthew Kilgore ecfc71ef95 Add completion API
Completions are basically a oneshot flag, which provide a `wait()` call
that blocks until 'finish()' has been called on the completion.

The nice aspect of completions is that because it is a oneshot the order
does not matter - if 'finish()' is called before 'wait()' then 'wait()'
returns immediately. It makes the logic for waiting until a thread is
done finishing up some work easy to implement.
2022-06-11 22:47:06 -04:00
Matthew Kilgore 7ef15653fd Add generic thread, mutex, and condvar API
This adds generic APIs to libqb for handling thread's, mutex's, and
condition variables. On Linux and OSX these are implemented via the ones
provided by pthreads. On Windows they're implemented via the ones
provided by the Win32 API.

For compiling, the code itself is not conditional, but the Makefile
includes logic to decide which implementation to pick.

Note that it would have been nice to simply use std::thread and friends
from C++11, however using them on MinGW appears to be a bit messy. Since
using the Windows ones directly isn't that hard this was an easy compromise.
2022-06-11 22:47:06 -04:00
Matthew Kilgore eb815c4220 Prepare for separate libqb, define C++ standard
This sets up a few different flags we'll need for the conditional
compiling, and also sets the C++ standard to gnu++11, which effectively
just matches what we were implicitly using before.
2022-06-11 22:47:05 -04:00
Matthew Kilgore 76c437288a Remove leftover build file 2022-06-11 20:42:23 -04:00
Matthew Kilgore f99407f251 Revert existing libqb split 2022-06-11 20:42:23 -04:00
Matthew Kilgore 62ec4ebdbd Fix compilation with DEP_DEVICEINPUT
The Makefile changes broke compiling with device input support. This got
missed because no test case for DEP_DEVICEINPUT got added.

Fixes: #100
2022-06-09 21:30:37 -04:00
Matthew Kilgore 437cfc3ab7 Remove old build system
Mostly old build scripts and helper files that are now covered by the
Makefile.

A notable deletion is the glew dll and lib files. These are unnecessary
because we compile `glew.c` directly rather than link against the dll or
lib copies we have.
2022-05-19 09:17:13 -04:00
Matthew Kilgore e0ef818522 Change purge scripts to use make clean 2022-05-19 09:17:13 -04:00
SteveMcNeill ecfa18a109 change numerics to more descriptive constants 2022-05-17 05:04:41 -04:00
SteveMcNeill 8574c1f921 Change to _screenwidth and _screenheight
Having windows call GetSystemMetrics without relying on glutGet, gets rid of the seg fault that can occur at program start up.  screenicon was restored to it's previous state so that larger issues with it can be addressed at a future date.
2022-05-16 11:37:58 -04:00
SteveMcNeill acbeca81b9 Fix to _desktopwidth, _desktopheight, _screenicon
Fixes the issue as brought up on the forums here: https://qb64phoenix.com/forum/showthread.php?tid=408

Also added a small set of logic so we don't end up inside an endless loop if the screen is hidden (via _SCREENHIDE), or if it doesn't exist for whatever reason.
2022-05-16 07:55:08 -04:00
Matthew Kilgore 7a5ca0c49c Cleanup unused Makefile stuff 2022-05-14 12:13:00 -04:00
Matthew Kilgore 5c4dcdc8aa Use dlfcn.h on OSX 2022-05-12 00:21:02 -04:00
Matthew Kilgore c1639b3979 Add basic make build system 2022-05-12 00:21:02 -04:00
Matthew Kilgore fcec53e55b Fix text wrapping on last column with variable width fonts
Currently there is a bug where if a variable width font is in use and
text printed would exactly fit to the end of the row, it is instead
wrapped and printed on the next line.

Ex. You're printing a character that is 10 pixels wide, starting
from position 90 on an image that is 100 pixels wide. This should fix,
but instead your character will be printed on the next line.

The reason this happens is an off by one error, cursor_x (effectively
the X value passed to LOCATE) is one based even when using a variable
width font where cursor_x represents a pixel location. The location that
check if the next character can fit on the screen never handles the base
one, so it ends up treating the ending Y coordinate as one past where it
will actually end, which makes the code thing the print will go past the
edge of the screen.

To fix we simply subtract one before doing the comparison to give us the
actual ending pixel column.
2022-05-06 17:50:07 -04:00
Matthew Kilgore 55da5f4ce3 Format other various source files 2022-05-06 13:20:30 -04:00
Matthew Kilgore 1aa8d7a42f Run clang-format on ./internal/c/*cpp files 2022-05-06 13:20:30 -04:00
SteveMcNeill 50eb90f885 Update LodePNG library
from 2012 version to 2022 version, which has been quite improved and sped up.
2022-05-03 02:33:45 -04:00
Matthew Kilgore 77aced1b1c Rewrite distribution logic, download mingw*.exe 2022-04-28 17:21:56 -04:00
Matthew Kilgore 9315646e76 setup_win.bat: create internal/c/c_compiler
internal/c/c_compiler no longer contains anything, so git will not
create it. This change makes setup_win.bat create the directory if it's
not already there.
2022-04-28 17:15:35 -04:00
Matthew Kilgore 97240a0b46 Add standalone mingw32 and mingw64 installers 2022-04-28 13:43:09 -04:00
Matthew Kilgore fbc580c9c5 Delete Mingw32 and Mingw64 2022-04-28 13:42:59 -04:00
phillvancejr 8f0c08e2ec Added global scope operator :: to the socket bind call to prevent clashes with <functional> std::bind in some builds 2021-11-01 10:21:16 -04:00
Roland Heyder c48bf6776e Fixed LOC function for files
Will correctly return zero (0) now for just opened but yet untouched files.
2021-10-22 23:51:48 +02:00
Fellippe Heitor 0fac593dd6 Update libqb.cpp to allow manual compilation in WinXP
Oh, well... there's still life for XP.
2021-10-17 03:56:54 -03:00
FellippeHeitor 56aa5e7e53 Try harder to return window_handle 2021-10-16 23:08:13 -03:00
Roland Heyder ce3c459dad Implements the _Bin$ function
Usage is analog to the legacy OCT$ and HEX$ functions.
2021-10-14 00:17:35 +02:00
Fellippe Heitor ab1f20eb3b Allow PRINT to show content in console even without a new line
Closes #74
2021-10-04 00:17:21 -03:00
FellippeHeitor 8d9cd83f6a Prevent errors when doing internal lbound/ubound checks 2021-09-30 22:40:57 -03:00
FellippeHeitor 1a3f3f5ad1 Add binary name to error message dialog; closes #157 2021-09-29 23:25:47 -03:00
Fellippe Heitor 4995175a16
Exits if without dev or ctx. 2021-09-25 23:15:12 -03:00
KindOne 4e91e559dd
Don't exit if missing speakers when using SOUND/BEEP. 2021-09-23 00:57:49 -04:00
FellippeHeitor 5cab1880b5 Uses GetLogicalDrives() in Windows (file dialogs). Closes #183 2021-09-21 02:54:41 -03:00
FellippeHeitor 3e498df414 Fixes watching/sending values for _BIT arrays. 2021-09-20 22:04:24 -03:00
Ashish Kushwaha 8e69e8cf3b allow 'move' to treated as 'cycle' for _mouseshow 2021-09-14 19:37:08 +05:30
Ashish Kushwaha 0f1dbed8e3
Merge branch 'QB64Team:development' into development 2021-09-12 19:21:01 +05:30
FellippeHeitor a02243455b Merge branch 'development' into watch-arrays 2021-09-04 23:57:22 -03:00
FellippeHeitor 7ba11565a5 Adds GetBytes so it's easier to add data to the packet ($DEBUG). 2021-09-03 00:03:28 -03:00
chlorophyll-zz fcb714133b
Update libqb.h
this fixes PR #185
2021-09-02 14:45:10 +02:00
chlorophyll-zz 6c403db7f2
Fix: Ambigous 'data' in global scope
Fixes #184
Probably breaks another thing.
Ambigous 'data' in global scope
https://root-forum.cern.ch/t/ambiguous-data-in-global-scope/41490
2021-09-02 13:52:36 +02:00
FellippeHeitor 9aa166e4de Checks for array's lbound and ubound before fetching data. 2021-08-19 19:10:51 -03:00
FellippeHeitor 3e4d1fc430 Merge branch 'development' into var-export 2021-08-18 21:28:50 -03:00
Luke Ceddia 27e4ee4770
Detect non-x86 based architectures 2021-08-18 22:07:40 +10:00
FellippeHeitor e791ca2001 Ensures _ConsoleTitle has time to do its thing. 2021-08-18 00:26:06 -03:00
FellippeHeitor c2eb3c00bc Merge branch 'development' into var-export 2021-08-18 00:22:55 -03:00
FellippeHeitor 744bd19107 Fixes race condition between vWatch and _CONSOLETITLE
It was a love triangle with _WindowHandle in the end, it's complicated.
2021-08-18 00:21:03 -03:00
Luke Ceddia 30d67825bf
Detect aarch64 as 64 bit 2021-08-18 00:04:24 +10:00
FellippeHeitor 2af2f4e2a1 Improves handling/signaling of INPUT/LINE INPUT in $DEBUG mode. 2021-08-14 21:28:21 -03:00
FellippeHeitor 8dddefd002 Brings debuggee window to foreground when using INPUT. 2021-08-14 17:04:25 -03:00
FellippeHeitor c41af6961f Prevents checking _WINDOWHANDLE from halting a $CONSOLE app.
Would happen when in conjunction with $SCREENHIDE.
2021-08-13 00:51:32 -03:00
FellippeHeitor cca1593f79 Switches focus to IDE automatically when breakpoint is reached.
Windows-only.
2021-08-12 23:00:43 -03:00
FellippeHeitor 0bbc60e73e Allows reading program_stop without using _Exit. 2021-08-04 21:12:33 -03:00
FellippeHeitor 01a3c56685 Allows setting any length string variables from the IDE. 2021-08-03 00:36:21 -03:00
Ashish Kushwaha 7e3a60c50b added 'cycle' style in _mouseshow 2021-07-31 11:22:10 +05:30
Luke Ceddia 1e76f237de
Supress SIGPIPE on tcp send 2021-07-31 00:06:09 +10:00
Fellippe Heitor 7e5710a364 Allows _MK$/_CV to deal with _OFFSET
_UNSIGNED _OFFSET too.
2021-07-28 14:26:32 -03:00
FellippeHeitor 231e28c79b Adds method to allow closing the connection with the IDE.
In order to allow $DEBUG to work with programs that call CLEAR, the connection handle used to connect to the IDE is locked by default and cannot be CLOSEd. With this change, the debuggee itself can now unlock the handle and close the link.
2021-07-22 00:18:34 -03:00
FellippeHeitor 30348dd2db Allows a debuggee to call CLEAR while keeping connected to the IDE. 2021-07-21 23:54:30 -03:00
FellippeHeitor 1fa3781a12 Attempt at fixing ENVIRON for Windows.
'Works on my machine'.
2021-07-17 13:27:35 -03:00
Fellippe Heitor ee4b611056 Adds _EnvironCount 2021-07-17 12:15:00 -03:00
Luke Ceddia a866fec7f0
Rewrite ENVIRON 2021-07-17 17:56:42 +10:00
Fellippe Heitor 90461eb226 Fixes ENVIRON$() in *nix systems when passing a string. 2021-07-17 01:04:27 -03:00
Fellippe Heitor ae887507c2 On error, report back to the IDE. ($DEBUG) 2021-07-16 23:18:46 -03:00
FellippeHeitor af454940e4 Adds TIMER ON control over the debuggee. 2021-07-15 01:13:50 -03:00
Luke Ceddia 0f3909d955
Revert "Prevent zombie processes with Shell _Dontwait"
This reverts commit a94b738407.
It turns out that change stops the SHELL function returning the
child exit code, which is worse than having zombie processes.
2021-07-13 16:20:32 +10:00
Luke Ceddia a94b738407
Prevent zombie processes with Shell _Dontwait 2021-07-13 13:08:27 +10:00
Fellippe Heitor 7b853bf9f2 First attempt at implementing Step. 2021-07-11 12:55:49 -03:00
Fellippe Heitor b59aa4d7af Begins prototyping a $DEBUG metacommand. 2021-07-09 08:08:49 -03:00
what c622ae9592
Remove 255 char limit for INPUT
Also affects `LINE INPUT`
2021-07-05 19:39:24 -04:00
Zachary Spriggs f90a45a2cf Allow $CONSOLE:ONLY programs to return _WINDOWHANDLE
We previously only allowed GUI QB64 programs to return a value in _WINDOWHANDLE. Following Microsoft's recommendation for obtaining a console program's handle, we can now return the handle in a $CONSOLE:ONLY program https://docs.microsoft.com/en-us/troubleshoot/windows-server/performance/obtain-console-window-handle
2021-07-02 11:17:32 -04:00
Zachary Spriggs e799e79012 Add %TEMP% to _DIR$() folder specifications
Adds the %TEMP% directory to `_DIR$()` folder specifications.
2021-06-21 20:25:21 -04:00
Zachary Spriggs 4a66dabf08 Add Program Files & Program Files (x86) to _DIR$()
This change adds the Program Files and Program Files (x86) folder specifications to the `_DIR$()` function.

`Print _Dir$("program files")
Print _Dir$("program files x86")`
2021-06-21 17:01:23 -04:00
Luke Ceddia bf32a6a0fc
Explicitly set x87 fpu to extended precision mode 2021-06-17 23:51:08 +10:00
Fellippe Heitor 5e05664896 Removes Sleep(0) from qbs_inkey
Addresses #166
2021-05-24 16:19:55 -03:00
Fellippe Heitor ec747a53c2
Merge pull request #156 from lstricklan/development
Fix writing to SCRN when opened as a file
2021-03-30 13:49:26 -03:00
Lynn Stricklan 445f11fd4c Update libqb.cpp 2021-03-26 11:51:21 -06:00
Zachary Spriggs 46e24587aa
FreeLibrary in func__newimage
Freeing the runtime linked library in `func__newimage` after the call
2021-03-26 08:34:55 -04:00
Zachary Spriggs 20a61cc474
Fix new bug with _Width and _Height
Where the previous bug would only return the console's image size when an image was passed, the new bug made it only ever return 80 for `_Width` and 25 for `_Height` when it should be returning the console's image size if there is no value passed and it is the `_Source`, which it is if we are in a `$Console:Only`.

Here is a code block that demonstrates the bug being fixed:
```Option _Explicit
$Console
Screen _NewImage(640, 480, 32)
_Dest _Console
Width 120, 5
_Dest 0

Print "Hello world"

Print _DesktopWidth, _DesktopHeight
Dim As Long i: i = _NewImage(1280, 720, 32)
Print _Width, _Height
Print _Width(0), _Height(0)
Print _Width(_Console), _Height(_Console)```
2021-03-24 09:38:44 -04:00
Fellippe Heitor 2a476e19e9
Merge pull request #153 from lstricklan/development
Fixes to libqb.cpp for random file record length and to msbin.c for MBF encoding
2021-03-24 01:28:31 -03:00
Zachary Spriggs ad3afb56b8
Changed #if blocks to be greater than or equal to Vista version 2021-03-24 00:14:19 -04:00
Zachary Spriggs c727abd667
Check for XP using WINVER in func__newimage and sub__consolefont
This can re-enable `_ConsoleFont` by checking if the version of Windows is greater than XP. Also, for the DPI awareness.
2021-03-24 00:09:33 -04:00
Lynn Stricklan 87c01d0bed Update libqb.cpp
When opening a file for random access, if the LEN is not supplied, it defaults the length correctly, but does not allocate the buffer correctly. The code should reference the record_length in the file struct.
2021-03-23 13:41:59 -06:00