1
1
Fork 0
mirror of https://github.com/QB64-Phoenix-Edition/QB64pe.git synced 2024-08-05 17:00:26 +00:00
Commit graph

85 commits

Author SHA1 Message Date
Matthew Kilgore
d64221afda Use correct math functions from std::
With the removal of `using namespace std;` we inadvertently started
using some of the global math.h versions of these functions, which take
different types and resulting in computation errors.

The fix is to prefix all these functions with std:: so that we go back
to using the std:: versions.
2023-10-07 02:05:13 -04:00
Samuel Gomes
3f16e3c9d1 Add volume, panning & waveform support for SOUND 2023-06-10 02:24:05 +05:30
Samuel Gomes
e4b36ca8ad Add font load-from-memory support 2023-04-20 09:23:13 +05:30
Samuel Gomes
d974c0b9a8 Tidy up font code 2023-04-04 17:51:17 +05:30
Samuel Gomes
6dd651f7cd Replace MinGW intrinsic zlib with miniz 2023-03-19 02:28:05 +05:30
Samuel Gomes
e79537e624
Merge branch 'main' into image-load-from-memory-support 2023-02-13 16:24:36 +05:30
Matthew Kilgore
d4ed371681 Stopped timers don't trigger on TIMER ON
If a timer expires while stopped, it should trigger when TIMER ON is
run. Instead, on QB64 it triggers randomly after the TIMER ON happens.

The basic issue is that `qbevent` needs to be set to trigger the timer,
but TIMER ON doesn't do that. The regular timer logic that does that
already set it when the timer expired while sleeping, so it won't set it
again. The simplest solution is to just alway set qbevent = 1 when TIMER
ON is done. It's slightly less efficent but doesn't hurt to set it even
when there are no timers that expired.

Fixes: #293
2023-02-12 21:27:25 -05:00
Matthew Kilgore
924472f5d6 Fix timers not firing at the start of the program
Timer's were not firing at the right time if they were started shortly
after the program started, instead they would fire at twice the interval
time (and then work correctly after that).

The issue was a mistaken assumption about `time_now`, with the idea that
if `last_time == 0` then `time_now` will be large enough such that the
interval check will pass. This is wrong because in most cases `time_now`
starts at zero at program start, so when `last_time == 0` it will take
one full interval of the timer before `time_now` is large enough for the
interval check to pass (at which point the timer is initialized and runs
normally).

This simply refactors the timer logic so that `last_time == 0` is
checked first, rather than if the interval has expired. This doesn't
change how the normal logic works, but ensures that the value of
`time_now` does not matter for initializing a timer.

Fixes: #273
2023-02-12 21:27:25 -05:00
Samuel Gomes
f0f0a9a420 Overload _LOADIMAGE to allow strings as the 2nd parameter 2023-01-11 16:18:43 +05:30
Matthew Kilgore
f21ce09e2d Replace time() with std::chrono, fix startup delay
Currently main() includes logic that is intended to sync time() with
GetTicks() for the purpose of using GetTicks() to get millisecond
accuracy with time(), which only has second accuracy. Unfortunately, the
'syncing' up of these time sources results in an average of a half
second delay in starting a QB64-PE program.

This logic is easly replaced with std::chrono, which provides a real
time clock which is also millisecond accurate. That removes the need to
use time() and GetTicks() together to get millisecond accuracy, and
means the delay syncing them is no longer necessary.

I also separated most of the "delay" and "time" related functions into
datetime.cpp, and included the new std::chrono code into that file.

Since I needed to call some of the rounding functions in datetime.cpp I
also moved that stuff out into its own .cpp and header files to clean
things up a bit.

Fixes: #282
2023-01-08 20:24:25 -05:00
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
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
Samuel Gomes
93e58baa1d Common dialogs support 2022-10-23 12:57:02 +05:30
Samuel Gomes
f49f8bdf06 Implement _SNDPLAYCOPY enhancement #185 2022-10-05 02:33:44 +05:30
Samuel Gomes
f99eb27717 Remove all _SHR & _SHL changes 2022-09-01 16:15:42 +05:30
Samuel Gomes
2ed17f6198 Add _ROR & _ROL support. Fix issues with _SHR & _SHL 2022-09-01 06:51:06 +05:30
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
Matthew Kilgore
1aa8d7a42f Run clang-format on ./internal/c/*cpp files 2022-05-06 13:20:30 -04: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
FellippeHeitor
8d9cd83f6a Prevent errors when doing internal lbound/ubound checks 2021-09-30 22:40:57 -03: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
FellippeHeitor
7ba11565a5 Adds GetBytes so it's easier to add data to the packet ($DEBUG). 2021-09-03 00:03:28 -03:00
FellippeHeitor
9aa166e4de Checks for array's lbound and ubound before fetching data. 2021-08-19 19:10:51 -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
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
Fellippe Heitor
ee4b611056 Adds _EnvironCount 2021-07-17 12:15:00 -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
Luke Ceddia
bf32a6a0fc
Explicitly set x87 fpu to extended precision mode 2021-06-17 23:51:08 +10:00
Luke Ceddia
c62568008d
Add _ERRORMESSAGE$ 2021-01-17 23:54:15 +11:00
FellippeHeitor
bd54eb0f39 Attempts at implementing _MEMSOUND 2020-12-31 01:40:54 -03:00
FellippeHeitor
ac268c740b Simplifies usage of zlib across platforms. 2020-01-18 18:48:10 -03:00
FellippeHeitor
51710ddcd3 Renames zlib's folder so it can be updated without the hassle later on. 2020-01-02 23:00:51 -03:00
FellippeHeitor
7c9eafbadb Replaces _TOGGLE_(KEY)LOCK with _(KEY)LOCK ON/OFF/_TOGGLE. Also:
- Changes CFont to sub__consolefont and func_CInp to func_cinp, in alignment with the rest of libqb/qbx.
- Adds stubs to all new console functionality, so we can still ship for other OSes with no bigger issues.
- Adds new keywords to syntax highlighter.
2020-01-02 19:55:58 -03:00
FellippeHeitor
114bd7b5a8 Adds stubs for _INFLATE$ and DEFLATE$ for OSes other than Windows.
These will return the unchanged text$ passed for now.
2020-01-02 17:35:02 -03:00
FellippeHeitor
49f265f1c2 Adds $ASSERTS, $ASSERTS:CONSOLE and _ASSERT condition[, message$] 2020-01-01 18:20:30 -03:00
QB64Cobalt
539a71ef25
Update qbx.cpp 2019-12-05 07:08:31 -08:00
SteveMcNeill
58b82dff13 Minor change to bit routines, added ability to ignore warnings in IDE 2019-12-04 12:30:02 -05:00
QB64Cobalt
d0935e041e
Update qbx.cpp 2019-11-16 16:20:22 -08:00
SteveMcNeill
eba05938bb Pushed changes to enhance the Windows Console Experience
Window's CONSOLE support has been extended so that:

CSRLIN support added.
POS(0) support added.
LOCATE support added. (Works with optional parameters.)
COLOR support added.
SCREEN support added to get both character and color information of any point on the console.
tab() glitch fixed. (Which could cause an endless loop when printing with comma spaced text/numbers.)
_WIDTH support added.
_HEIGHT support added.
WIDTH support added, with 2 new parameters added so we can set the buffer width and buffer height also.
CLS support semi-added.  (Doesn't accept colored backgrounds; it clears the screen black.  I'm getting tired of working up console stuff which I probably won't ever use myself...)
SLEEP support added.
END support added so we now end with any keypress and not just enter.

_CONSOLEINPUT added, so we can tell the difference in mouse and keyboard input.
_CINP(toggle) support added, which allows us to get single character keystrokes from the console.
_CONSOLEFONT FontName, FontSize support added, which allows us to change the font and font size we use for the console.
_CONSOLECURSOR _SHOW|_HIDE, cursorsize support added, which allows us to show or hide the cursor in the console, and to change its size (from 0 to 100), as desired.

New keyboard commands added:

_CAPSLOCK -- returns 1 if caps lock is on, 0 if it isn't.
_NUMLOCK -- as above, but for num lock
_SCROLLOCK -- as above, but for scroll lock

_TOGGLE_CAPSLOCK -- toggles the caps lock state for us.
_TOGGLE_NUMLOCK -- same, but for num lock
_TOGGLE_SCROLLOCK -- same, but for scroll lock
2019-08-27 19:52:02 -04:00