刘皓
8fed0ee847
Properly handle RETRO_ENVIRONMENT_GET_USERNAME
returning null in libretro builds
2025-07-14 22:32:00 -04:00
刘皓
accb5948ea
Update libretro-common and add Irish language in binding-sandbox.cpp
2025-07-13 20:59:33 -04:00
刘皓
eb8794874e
Don't reallocate memory in wasm_rt_replace_memory
unless the memory capacity has changed
2025-07-06 13:38:20 -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
刘皓
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
刘皓
ca5cfcbca9
Fix some more bugs in sandbox memory manipulation functions
2025-07-03 22:20:56 -04:00
刘皓
e22b2c6d5a
Fix some bugs and safety issues in sandbox memory manipulation functions
2025-07-03 22:04:29 -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
刘皓
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
刘皓
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
刘皓
7f0d5b3960
Serialize which Ruby fiber is currently active in libretro save states
2025-07-02 18:24:02 -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
刘皓
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
刘皓
84d5851aec
Serialize WASI file descriptor positions in libretro save states
2025-06-28 11:43:18 -04:00
刘皓
8858f9dd90
Remove unnecessary slot from libretro Graphics.update
binding
2025-06-12 17:57:13 -04:00
刘皓
e6404179ea
Fix a small bug in the previous commit
2025-06-11 16:07:48 -04:00
刘皓
ee31cccb81
Serialize PRNG state in libretro save states
...
Save states in libretro builds now also contain the state of the
pseudorandom number generator used to implement the WASI `random_get`
function for better save state determinism.
I've also changed the PRNG from MT19937 to PCG.
2025-06-11 15:54:21 -04:00
刘皓
ef64eaa4e5
Implement reinitializing OpenGL objects in libretro builds
...
Libretro provides a way to detect when the OpenGL context is destroyed,
like on Android and possibly also iOS when switching between apps. This
commit implements reinitializing all OpenGL objects when this happens so
that the graphics continue to function in this case.
2025-06-10 16:30:44 -04:00
刘皓
41557aba6e
Add a log message when loading libretro save state made with incompatible mkxp-z version
2025-06-04 11:32:32 -04:00
刘皓
0ca9e7ef3d
Don't include .UTF-8 at the ends of locale names in libretro builds
...
This is for consistency with standalone builds, which report locale
names without the encoding and with an underscore between the language
and region, e.g. "en_US".
2025-06-04 09:29:38 -04:00
刘皓
c61ef1cb60
Fix typo in sandbox bindings: "default_font_family" should be "default_font_family="
2025-06-03 23:14:49 -04:00
刘皓
6092f4a6fc
Change exception_raise
in sandbox bindings to take const Exception &
instead of Exception &
as argument
2025-06-03 23:11:06 -04:00
刘皓
b7b5e23e18
Implement system bindings in libretro builds
2025-06-03 23:06:05 -04:00
刘皓
784e62d1c5
Cast struct sandbox_str_guard
to const char *
before passing to variadic functions
2025-06-03 14:26:48 -04:00
刘皓
a71746bca0
Revert "Remove WASI_DEBUG
macro"
...
This reverts commit d62d6aef3e
.
Now that `sandbox_str()` is safe to use, I should put this macro back
in.
2025-06-03 13:30:22 -04:00
刘皓
6bddd82618
Change sandbox_str()
to return a guard object instead of a pointer to a static string in big-endian libretro builds
2025-06-03 13:14:51 -04:00
刘皓
addf927922
Merge branch 'misc-fixes' into libretro
2025-06-03 11:36:20 -04:00
刘皓
afb0748ffa
Use a priority deque to allocate object keys/WASI file descriptors
2025-06-03 10:59:30 -04:00
刘皓
175a210532
Implement deserializing libretro save states of the opposite endianness
2025-06-02 17:39:30 -04:00
刘皓
3c244cc7ea
Refactor libretro save state serialization to not require extra objects
2025-05-31 19:06:57 -04:00
刘皓
bb4dd64d8d
Add some safety checks to libretro save state deserialization
2025-05-31 16:34:15 -04:00
刘皓
6f6efb4ef0
Fix fonts and autotiles/bitmap arrays being leaked when serializing libretro save states
2025-05-31 12:26:26 -04:00
刘皓
2ee1b61670
Fix some more bugs in libretro save state serialization/deserialization
2025-05-31 10:47:47 -04:00
刘皓
a84d85cf1f
Update some more dirty flags when deserializing save states in libretro builds
2025-05-30 14:57:24 -04:00
刘皓
6ddc8c6ce4
Update plane/window dirty flags when deserializing save states in libretro builds
2025-05-29 21:54:11 -04:00
刘皓
56c711f1c1
Move some serialization-related code from binding-util to sandbox-serial-util
2025-05-29 21:06:29 -04:00
刘皓
7980cd440a
Handle change watches when deserializing save states in libretro builds
2025-05-29 10:41:19 -04:00
刘皓
c802e24f1b
Fix WASI file descriptor deserialization bugs in libretro builds
2025-05-28 17:07:22 -04:00
刘皓
b664b3c8c7
Disconnect dispose watches before deserializing save states in libretro builds
2025-05-28 16:01:32 -04:00
刘皓
6f472fb732
Handle disposal when deserializing save states in libretro builds
2025-05-28 15:32:43 -04:00
刘皓
1f5d90822c
Remove designated initializers
...
Apparently these are not valid until C++20.
2025-05-27 21:28:29 -04:00
刘皓
ede42dbb1b
Fix serialization of Tilemap::Autotiles
and TilemapVX::BitmapArray
in libretro builds, for real this time
2025-05-27 19:11:58 -04:00