Commit graph

2744 commits

Author SHA1 Message Date
02d59bb062 Add included default Config.dat file 2025-04-26 16:16:19 +02:00
192443b664 Revert "Turn on FPS display"
This reverts commit e14d3f59f2.

The framerate is now stable and correct enough that the FPS display is
no longer needed.
2025-04-26 16:12:36 +02:00
843facfdb6 Typo fix "testing" -> "tested" 2025-04-26 16:02:59 +02:00
d5f4123cf3 Update README.md to include setup and build instructions 2025-04-26 16:02:11 +02:00
c7e02b4fd0 Add Makefile for building on Solaris
Previously Makefiles were made on the spot and just sorta thrown onto
the target via FTP. A real canonical Makefile will make building from
scratch not a nightmare.
2025-04-26 15:47:49 +02:00
d43a683018 Increase audio bit depth to 16
We were already outputting 16-bit audio, one byte was just being
ignored. Might as well bump it up since the computer can handle it.
2025-04-26 15:23:12 +02:00
82e7864903 Add double-buffering to avoid screen flashes with XShm
When using the X shared memory extension, the X server may start
reading the buffer at a time when the client is writing to it. This
can result in the next unfinished frame flashing onto the screen. The
canonical way to solve this is to wait for an event to come in
signaling that it's safe to continue, but that would add considerable
latency to rendering. Instead, we bet on the fact that it won't take
all that long, and so we double-buffer. We have two buffers shared
with the X server and swap them at the end of each frame. We only draw
to the one not being displayed. That way the X server should always
have time to read out a full finished frame.
2025-04-26 14:44:58 +02:00
719937c06f Fix color of rendered text for Solaris 2025-04-26 14:17:03 +02:00
a4479f9c07 Reimplement Backend_Delay to fix threads freezing
So our workaround for making usleep thread-safe mostly worked in that
it fixed one of the things making it thread-unsafe, but it seems that
sigsuspend, which usleep uses, is also not thread-safe, since
sometimes one of our two threads would freeze, stuck inside
sigsuspend. So instead of usleep, we're using a trick that Stacken
member map suggested: using select. Calling select with no file
descriptors to work on will have it block on the kernel level until
its timeout is hit. This acts as a sleep. As it turns out, this seems
to completely solve our sleep-related problems, and massively reduces
the amount of audio buffer underruns as a nice bonus!
2025-04-26 13:54:12 +02:00
108b0282bb Update README.md for the Solaris fork 2025-04-25 12:09:05 +02:00
9efce111c9 Implement audio backend mutexes
This is apparently necessary, and I thought it was leading to the main
game thread freezing, but after implementing and testing, that does
not appear to be the case. Still, implementing these is correct, so
it's best to have it done anyway.
2025-04-24 22:24:11 +02:00
c841d343a3 Correct audio buffer underrun error message 2025-04-24 22:03:38 +02:00
15f4d74698 Fix misnamed variable in audio code
Unfinished renaming
2025-04-24 21:09:24 +02:00
6c04e37864 Working and tested audio backend for Solaris
Uses the audio device's "EOF counter" to tell how many audio buffers
we've played, then ensures that production is three buffers ahead of
playback. This has been tested and works. Either game or audio thread
may still freeze, this can likely be fixed by implementing the locks.
2025-04-24 21:00:44 +02:00
a56c9c57a2 Add workaround for usleep throwing SIGALRM signals
On Solaris, usleep is not thread-safe and will introduce a race
condition when used in a multithreaded environment. This manifests as
SIGALRM signals escaping from its internal call to sigsuspend. If a
signal is missing a handler, the process dies upon receiving it,
crashing.

The Solaris libc code does something rougly equivalent to this:

    PreserveSignalHandlers(...);
    /* Effectively NOPs out SIGALRM */
    DisableSIGALRM(...);
    SetTimer(...);

    /* Suspends the thread until it receives a SIGALRM signal. When it
       receives this signal, it both wakes up *and* receives the
       signal. In this case we don't want to do anything but wake up,
       so the SIGALRM handler is a NOP.
    */

    sigsuspend(...);

    RestoreSignalHandlers(...);

    return;

The consequences of this code in a multithreaded context is that if
two sleeps are in progress at the same time, one will necessarily
finish before the other, *restore the non-existant handlers*, and go
on doing its thing. When the other sleep finishes, it won't have a NOP
handler to call when waking up, a handler is searched for, none is
found, and thus we crash.
2025-04-24 20:32:22 +02:00
a86f5df428 Revert "Rewrite some code for ease of reading"
sorry, it got less readable now

This reverts commit 5448068426.
2025-04-24 15:50:34 +02:00
hugova
5448068426 Rewrite some code for ease of reading 2025-04-24 15:34:44 +02:00
b1d3549723 Untested maybe improved audio code (no more pre-computed sleeps) 2025-04-18 21:40:02 +02:00
3b0418a25f some clean up and violent thrashing 2025-04-08 22:00:54 +02:00
2dd6b4479f Mostly working audio but gets out of sync and dies 2025-04-08 21:03:29 +02:00
2d46a14a37 Working but very choppy audio 2025-04-08 20:23:30 +02:00
ffdd2d5d7f Add barely working sound for Solaris (screams like hell) 2025-04-08 19:07:17 +02:00
b0f8744c4a Replace nice struct init syntax with elder-friendly 2025-04-17 18:42:53 +02:00
abdfcf2e00 Fix wrong usage of audio_info_t and audio_prinfo_t 2025-04-17 18:32:02 +02:00
62898c85f8 Add system that renders "cheap" "tiles" without color keying
The game appears to render level tiles as 16x16 pixel tiles, and many
of these do not require any transparency. So we now compute which
tiles are completely opaque and store those in a set, so that when we
draw them we can skip color keying.
2025-04-17 11:34:31 +02:00
2928b8a362 Remove "register" declaration from little endian path
Declaring a "register variable" isn't allowed in modern C++ so I ditch
that in the path that my dev machine compiles.

I *should* remove them from both and update GCC on the Sun to as new
as possible, but I'm not going to do that because that sound painful,
so this is what it is.
2025-04-17 11:34:07 +02:00
638918b4df Big endian changes 2025-04-12 17:44:22 +02:00
962bb9d477 Big endian define garbage 2025-04-12 17:38:29 +02:00
21323b964c Add big endian define (hack for Sun) 2025-04-12 17:27:55 +02:00
82566dabd2 Fix bugs on Sun (hopefully) 2025-04-12 17:22:49 +02:00
df2e2ce792 Remove maybe pointless maybe bad thing in shmget call 2025-04-10 22:52:17 +02:00
d19f37cfed Make manual-build-maker.lisp generate Makefile instead of shell script 2025-04-10 22:51:45 +02:00
4003931ed9 Check that the framebuffer image matches expectations 2025-04-09 15:11:18 +02:00
d562f588cf Add hint about turning on SHM on Sun 2025-04-09 15:00:53 +02:00
2c93c071d1 Add use of XShm for faster transfer speeds between game and X server 2025-04-09 14:57:32 +02:00
e14d3f59f2 Turn on FPS display 2025-04-08 11:18:08 +02:00
022144d727 Fix RenderBackend_ColourFill for 4-byte pixel format 2025-04-07 00:16:03 +02:00
8d840d89ea Make a constant for the park signal in case we want to change it 2025-04-06 23:48:40 +02:00
e3ce9ae828 Park the main thread while getting audio frames from the game
The main justification for this is that normal behaviour from a
backend is to have the main thread be interrupted by the audio system
and to then stay within the audio system while getting audio
frames. Parking the main thread simulates this by ensuring nothing
else happens in the game's logical flow at the same time.
2025-04-06 23:44:27 +02:00
faa808e238 Remove a little more 3DS gunk 2025-04-06 22:57:11 +02:00
c7dd1520c6 Skip copying unnecessary byte during blitting 2025-04-06 22:56:12 +02:00
6ab4984350 Adjust rendering code to 4-byte pixel format with unused byte 2025-04-06 22:48:08 +02:00
33b59f8219 Remove some 3DS stuff 2025-04-06 22:41:13 +02:00
d9cfb85346 Add build script generator 2025-04-06 21:19:19 +02:00
01e0787473 Use the correct header file for Solaris audio 2025-04-06 21:18:39 +02:00
b99fe37522 Don't use thread locals in stb_image (doesn't work on Solaris) 2025-04-06 21:18:13 +02:00
31d16e714f Add untested preliminary audio backend for Solaris 2025-04-06 12:25:30 +02:00
98b2b4c64d Make compatible with the Sun's pixel format 2025-04-05 19:51:34 +02:00
a1c39be7b3 Add Emacs backup files to .gitignore 2025-04-04 22:08:13 +02:00
e01863b80c Add initial code for raw X11 backend 2025-04-04 22:03:22 +02:00