1
1
Fork 0
mirror of https://github.com/QB64-Phoenix-Edition/QB64pe.git synced 2024-08-04 16:30:25 +00:00
Commit graph

272 commits

Author SHA1 Message Date
RainRat
f65a74c22a fix typos 2024-01-28 10:37:47 -08:00
Samuel Gomes
e1001a0dd9 Remove dead code (time64.*) 2024-01-19 12:54:23 +05:30
Samuel Gomes
3caa2924f0 Changes per suggestions in #428 2024-01-05 01:40:11 +05:30
Samuel Gomes
7d1cc89780 Fix OPEN COM from locking up inside gfs_open_com_syntax() 2024-01-05 00:31:19 +05:30
Samuel Gomes
d4437d1b32 Update func__loadfont() to use filepath_fix_directory() 2023-12-29 03:01:24 +05:30
Samuel Gomes
a11a66fb63 Rename startDir to g_startDir 2023-12-10 11:25:01 +05:30
Samuel Gomes
48539861f3 Repace fixdir() with filepath_fix_directory() 2023-12-10 11:15:41 +05:30
Samuel Gomes
0e251eb8e8 Consolidate all filesystem related functions to it's own translation unit 2023-12-10 01:16:29 +05:30
SteveMcNeill
01163fb9e9 Create math.h
Move the extended math functions out of libqb and qbx, and place them inside math.h.

Correct the formula for _ARCSEC and _ARCCSC.
2023-10-31 08:34:19 -04:00
SteveMcNeill
3cf12d4222 Patch _ARCSEC and _ARCCSC
As per the forum posts here: https://qb64phoenix.com/forum/showthread.php?tid=2125
2023-10-31 00:21:30 -04:00
SteveMcNeill
5a063f4ef8 check for which optional param is passed to CLS 2023-10-18 09:11:40 -04:00
SteveMcNeill
7345839b75 missing call to sub__dest?? 2023-10-18 08:49:42 -04:00
SteveMcNeill
9854955d99 Add Support for optional paramter for an image handle to CLS 2023-10-18 08:01:12 -04:00
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
c82dd88ee2
Merge branch 'main' into game-controller-fixes-and-enhancements 2023-10-04 18:47:20 +05:30
Samuel Gomes
2b92380460 Simplify func__os() 2023-10-01 09:47:31 +05:30
Samuel Gomes
49aeccc486 Initial WoA64 and MingW-LLVM support 2023-10-01 08:08:58 +05:30
Samuel Gomes
79c531f2bb Reorg. game controller and update libstem_gamepad 2023-09-26 02:01:35 +05:30
Samuel Gomes
8822967d45 Replace string with std::string 2023-09-25 05:32:00 +05:30
Samuel Gomes
2bfbf5b67c Remove using namespace std from libqb 2023-09-25 05:20:21 +05:30
Samuel Gomes
efbd16b19c Remove legacy openal headers from libqb.cpp 2023-09-22 08:41:45 +05:30
Samuel Gomes
b40edfbd9b Avoid rendering filled background color boxes when _KEEPBACKGROUND is set 2023-09-21 07:52:07 +05:30
Samuel Gomes
586371dc77 Implement _SAVEIMAGE 2023-09-17 11:52:54 +05:30
RainRat
3914037c0f fix typos 2023-04-30 15:20:42 -07:00
Samuel Gomes
9870510b04
Merge branch 'QB64-Phoenix-Edition:main' into font-FreeTypeAmalgam 2023-04-28 20:57:28 +05:30
Samuel Gomes
7b6b0b0d42 Implement UPint functions 2023-04-26 13:09:25 +05:30
Matthew Kilgore
8e1e7bc540 Fix keyboard _Device on Windows
Currently the Keyboard _Devices entry on Windows does not report all the
key presses and releases. This is due to missing some messages in the
form of WM_SYSKEYDOWN and WM_SYSKEYUP. Additionally Windows is weird
about report the state of the individual shift keys, so we add some
logic using GetAsyncKeyState() to fix that up.

Fixes: #333
2023-04-25 19:12:01 -04:00
Samuel Gomes
e4b36ca8ad Add font load-from-memory support 2023-04-20 09:23:13 +05:30
Samuel Gomes
618e5117cd Add FontPrintWidthUTF32() and optimize chrwidth() 2023-04-19 09:30:38 +05:30
Samuel Gomes
492c8d0cf5 Remove unused out_x_pre_increment, out_x_post_increment 2023-04-19 08:39:56 +05:30
Samuel Gomes
ec723ed46b New FreeType cached font renderer 2023-04-19 07:49:02 +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
4dcefd103e Satisfy -Wc++11-narrowing 2023-03-04 07:50:46 +05:30
Matthew Kilgore
f995f38e38 Using Sleep with Console programs does not trigger timers
The command Sleep is supposed to allow timers to trigger while the
program is sleeping on the delay. This is achieved in QB64 by having
commands that do delays manually call evnt() to trigger events if they
come up (of which timers are one).

Sleep has a custom implementation for console programs on Windows which
doesn't do this, so I redid the logic so that it calls evnt() at regular
intervals while waiting for input. Additionally, due to now calling
evnt() we also need to check if we should exit sleep early due to an
evnt() firing.

Fixes: #294
2023-02-12 21:27:25 -05:00
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
Matthew Kilgore
a3cea42e0d Move icon image creation to sub__icon
The icon image creation is actually fairly expensive because the first
time you create a 32-bit image init_blend() is called, which is fairly
slow. Since only sub__icon makes use of these images (non-Windows
platforms and $Console:Only programs can't even use them) it's easy
enough to move the creation into sub__icon so the creation cost is
avoided on startup.
2023-01-08 20:24:25 -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
Matt Kilgore
8185234792
Merge branch 'main' into fix-glut-init-logic 2022-11-26 22:42:46 -05: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
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
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