Commit graph

2554 commits

Author SHA1 Message Date
刘皓
eb8794874e
Don't reallocate memory in wasm_rt_replace_memory unless the memory capacity has changed 2025-07-06 13:38:20 -04:00
刘皓
fd822ea498
Don't seed the Ruby PRNG with the system time in libretro builds
This allows libretro save states to actually behave the same every time
you load them with respect to when randomly generated events occur and
the random movements that NPCs make.
2025-07-06 12:27:46 -04:00
刘皓
42d49f7296
Remove caching of libretro stage 1 from the autobuild
It doesn't take nearly as long for stage 1 of the libretro build process
to build as it did when I first started working on libretro builds. At
this point, I find it unnecessary to keep caching the stage 1 build
artifacts.
2025-07-06 12:06:00 -04:00
刘皓
f98d868336
Implement Kernel.save_data in libretro builds 2025-07-06 11:48:11 -04:00
刘皓
5dc71864bb
Implement optional second argument for Kernel.load_data in libretro builds 2025-07-06 11:43:24 -04:00
刘皓
32802c0721
Don't call assumeRubyGC(false) in Bitmap::sandbox_deserialize_begin 2025-07-06 11:20:45 -04:00
刘皓
1a275a1866
Properly set assumingRubyGC when deserializing bitmaps from libretro save states 2025-07-06 11:08:44 -04:00
刘皓
e587768f9c
Fix WASI file descriptor leak during libretro save state deserialization 2025-07-06 10:53:02 -04:00
刘皓
d1cdd55566
Avoid pointer arithmetic overflow in sandbox_ptr_unaligned in big-endian libretro builds 2025-07-05 19:33:18 -04:00
刘皓
db0934e308
Fix a mistake in the previous commit 2025-07-04 15:08:02 -04:00
刘皓
a72f695f1c
Serialize viewport origins in libretro save states 2025-07-04 15:01:40 -04:00
刘皓
3561b3171e
Serialize audio fading and ME watch states in libretro save states 2025-07-04 10:20:06 -04:00
刘皓
ca5cfcbca9
Fix some more bugs in sandbox memory manipulation functions 2025-07-03 22:20:56 -04:00
刘皓
5048efe1b4
Merge branch 'dev' into libretro 2025-07-03 22:09:46 -04:00
刘皓
e22b2c6d5a
Fix some bugs and safety issues in sandbox memory manipulation functions 2025-07-03 22:04:29 -04:00
Splendide Imaginarius
6833b5b4b9
Merge pull request #257 from Splendide-Imaginarius/mkxp-z-occurred
Some checks failed
Automatic Build / Windows (push) Has been cancelled
Automatic Build / Ubuntu 22.04 x86_64 (push) Has been cancelled
Automatic Build / Ubuntu 22.04 arm64 (push) Has been cancelled
Automatic Build / Ubuntu 22.04 armv6 (push) Has been cancelled
Automatic Build / Ubuntu 22.04 armv7 (push) Has been cancelled
Automatic Build / Ubuntu 22.04 armv7-neon (push) Has been cancelled
Automatic Build / Ubuntu 22.04 power8le (push) Has been cancelled
Automatic Build / Ubuntu 22.04 power9le (push) Has been cancelled
Automatic Build / Ubuntu 22.04 riscv64 (push) Has been cancelled
Automatic Build / Ubuntu 22.04 s390x (push) Has been cancelled
Automatic Build / Debian Trixie x86_64 (push) Has been cancelled
Automatic Build / Debian Trixie arm64 (push) Has been cancelled
Automatic Build / Debian Trixie armv6 (push) Has been cancelled
Automatic Build / Debian Trixie armv7 (push) Has been cancelled
Automatic Build / Debian Trixie armv7-neon (push) Has been cancelled
Automatic Build / Debian Trixie s390x (push) Has been cancelled
Automatic Build / macOS (push) Has been cancelled
Automatic Build / Debian Trixie power8le (push) Has been cancelled
Automatic Build / Debian Trixie power9le (push) Has been cancelled
Automatic Build / Debian Trixie riscv64 (push) Has been cancelled
Fix misspelling of "occurred"
2025-07-03 23:16:57 +00:00
Splendide Imaginarius
75f9caadbb Fix misspelling of "occurred" 2025-07-03 22:31:40 +00:00
刘皓
cfaba64211
Fix a typo in retro_unserialize 2025-07-03 13:23:07 -04:00
刘皓
1824a0fc06
Change type of sb()->fiber_list elements from std::pair<key_t, struct fiber> to struct fiber 2025-07-03 13:21:29 -04:00
刘皓
6806c56a07
Fix a mistake in the previous commit 2025-07-03 13:18:21 -04:00
刘皓
7fa8b8ef16
Fix libretro save states created in the same frame one was loaded being corrupted 2025-07-03 12:39:29 -04:00
刘皓
d1a6d53892
Enforce deterministic iteration order for sandbox fibers
I've changed the sandbox fibers in libretro builds to be stored in a
linked list, with an unordered map mapping fiber keys to linked list
nodes for efficient lookup. The original implementation was just having
all the fibers in an unordered map.

The new implementation has the benefit that fibers are always iterated
in the same order on every platform, which allows save state creation to
be more deterministic.
2025-07-03 09:16:55 -04:00
刘皓
a2244c25cd
Make sure p->deserYChanged is initialized in Sprite::sandbox_deserialize_begin() 2025-07-02 21:03:04 -04:00
刘皓
81cb43ef37
Prevent unaligned memory accesses in libretro builds
These are undefined behaviour. All memory accesses need to be aligned.
For unaligned memory accesses, we have to use memcpy.
2025-07-02 20:46:54 -04:00
刘皓
e3146c5e1d
Authenticate to the GitHub API in the autobuild to reduce flakiness 2025-07-02 19:24:09 -04:00
刘皓
7f0d5b3960
Serialize which Ruby fiber is currently active in libretro save states 2025-07-02 18:24:02 -04:00
刘皓
fd529af870
Don't allow using libretro save states while shared state is uninitialized 2025-07-02 15:20:41 -04:00
刘皓
29c0621771
Call Font::initDefaultDynAttribs() before initializing shared state in libretro builds 2025-07-02 14:38:09 -04:00
刘皓
00c688309b
Fix edge case in pointer unswizzling algorithm for libretro save state serialization
If there are two Ruby objects, A and B, that are both no longer used
(i.e. they're able to be freed by the Ruby garbage collector), and A
references B, then it's possible for the Ruby garbage collector to free
B but not also free A in the same garbage collection cycle.

The pointer unswizzling algorithm currently crashes when the garbage
collector does this because the object A will still be in
`sb()->objects` but B will not be, and so save state serialization will
still try to serialize A. When the pointer unswizzling algorithm tries
to serialize all the other objects A references and cannot find the
referenced object B, the program crashes.
2025-07-02 13:32:06 -04:00
刘皓
2aa09e8529
Prevent std::memcpy from being called on null pointer in binding-sandbox/binding-base.h 2025-07-02 10:35:38 -04:00
刘皓
3b0d8e7458
Fix more undefined behaviour found by UBSan 2025-07-02 10:30:52 -04:00
刘皓
80b57e8601
Merge branch 'misc-fixes' into libretro 2025-07-02 10:20:23 -04:00
刘皓
3158e0c26f
Fix undefined behaviour found by UBSan 2025-07-02 10:17:02 -04:00
刘皓
880fdeca43
Fix bug in PCG implementation in wasi.cpp 2025-07-02 09:10:19 -04:00
刘皓
0d18b9e422
Handle initialize being called multiple times in binding-sandbox/font-binding.cpp 2025-07-01 15:14:41 -04:00
刘皓
529c0cd905
Fix bug in initialize_copy in binding-sandbox/font-binding.cpp 2025-07-01 11:24:16 -04:00
刘皓
fa8a5242ea
Fix crash in libretro builds when starting a game with rewind enabled in RetroArch 2025-07-01 10:10:03 -04:00
刘皓
54fedb980c
Detach OpenAL buffers when stopping sound emitters when deserializing libretro save states 2025-06-30 21:55:41 -04:00
刘皓
d9a6c68d6b
Fix another potential crash in soundemitter.cpp 2025-06-30 20:55:32 -04:00
刘皓
97f862662b
Fix a rare crash in soundemitter.cpp when loading a save state in libretro builds with C++ exceptions disabled 2025-06-30 19:43:34 -04:00
刘皓
84d5851aec
Serialize WASI file descriptor positions in libretro save states 2025-06-28 11:43:18 -04:00
刘皓
96f39f3913
Request libretro frontend shutdown when the game exits 2025-06-26 22:41:54 -04:00
刘皓
2f5850bfc1
Fix some bugs in bitmap deserialization for libretro save states 2025-06-24 18:14:08 -04:00
刘皓
c96c571241
Replace exception.type == Exception::Ok with exception.is_ok() 2025-06-24 15:49:07 -04:00
刘皓
b65525e609
Replace exception.type != Exception::Ok with exception.is_error() 2025-06-24 15:44:32 -04:00
刘皓
e9450952f6
Fix bug in libretro save state serialization/deserialization of frozen pixels 2025-06-23 20:57:44 -04:00
刘皓
077b461480
Improve code for refreshing OpenGL state in libretro builds
Instead of resetting all the OpenGL state to the default values on
refresh, the code now reapplies the state currently stored in `glState`
on refresh.
2025-06-23 20:10:08 -04:00
刘皓
c97b4b8b6e
Don't vertically flip the screen in libretro builds
Libretro provides the option to make the libretro frontend vertically
flip the video output when using OpenGL, so let's just allow the
frontend to do that instead of doing it manually. It might be more
efficient.
2025-06-23 18:34:35 -04:00
刘皓
08ad3e9f8f
Patch boost_assert to use stb_sprintf on platforms with no snprintf implementation 2025-06-23 18:15:11 -04:00
刘皓
3d044087e0
Disable threading in Emscripten build in the libretro buildbot 2025-06-23 14:14:40 -04:00