Commit graph

139 commits

Author SHA1 Message Date
刘皓
41557aba6e
Add a log message when loading libretro save state made with incompatible mkxp-z version 2025-06-04 11:32:32 -04:00
刘皓
0bbc859848
Change .mkxp file extension to not be recognized as an archive in libretro builds
I'm planning on allowing the user to put an empty file with the
extension .mkxp in the game directory and load that as the game so that
they can control the file name RetroArch uses for save states, since
RetroArch uses the name of the game file as the name of the save states.

The file extension .mkxpz is still recognized as an archive.
2025-06-04 00:04:33 -04:00
刘皓
e19ee7f60a
Implement libretro save state serialization/deserialization for audio state 2025-06-03 17:41:51 -04:00
刘皓
f97fbe7e0e
Implement frame duping properly for Graphics.play_movie in libretro builds 2025-06-03 14:18:28 -04:00
刘皓
afb0748ffa
Use a priority deque to allocate object keys/WASI file descriptors 2025-06-03 10:59:30 -04:00
刘皓
f84ad5b781
Implement libretro save state serialization/deserialization for graphics state 2025-06-02 22:14:34 -04:00
刘皓
175a210532
Implement deserializing libretro save states of the opposite endianness 2025-06-02 17:39:30 -04:00
刘皓
9db5a2e1da
Fix crash in libretro builds when the game throws an error or exits 2025-05-31 21:06:18 -04:00
刘皓
3c244cc7ea
Refactor libretro save state serialization to not require extra objects 2025-05-31 19:06:57 -04:00
刘皓
83eeb18b3b
Fix disposed objects in libretro save states sometimes being undisposed after deserialization 2025-05-31 18:09:51 -04:00
刘皓
bb4dd64d8d
Add some safety checks to libretro save state deserialization 2025-05-31 16:34:15 -04:00
刘皓
ef07a974ec
Free shared state when sandbox is destroyed in libretro builds 2025-05-31 16:06:07 -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
刘皓
79e732d032
Fix dispose watches sometimes not being disconnected when deserializing libretro save states 2025-05-28 17:37:00 -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
刘皓
002b66d167
Fix serialization of Tilemap::Autotiles and TilemapVX::BitmapArray in libretro builds 2025-05-27 17:22:31 -04:00
刘皓
8ca753d85d
Continue implementing save state deserialization in libretro builds 2025-05-27 16:59:41 -04:00
刘皓
d383889d4e
Start implementing save state deserialization in libretro builds 2025-05-25 16:07:40 -04:00
刘皓
85b3340ea0
Actually remember to serialize the memory size in libretro builds 2025-05-25 10:19:13 -04:00
刘皓
bc0bd7fe65
Make some small improvements to save state serialization in libretro builds 2025-05-24 19:19:57 -04:00
刘皓
0b27c24bd5
Implement save state serialization for stack pointer and Asyncify state/data in libretro builds 2025-05-24 13:25:40 -04:00
刘皓
e957af931c
Implement save state serialization for WASI file descriptors in libretro builds 2025-05-23 23:59:29 -04:00
刘皓
e137548de4
Implement save state serialization for Graphics.play_movie in libretro builds 2025-05-22 22:08:55 -04:00
刘皓
68d327d265
Implement save state serialization for sandbox state in libretro builds 2025-05-22 21:44:00 -04:00
刘皓
2896ec5abd
Implement save state serialization for C++ objects owned by the bindings in libretro builds 2025-05-22 12:49:01 -04:00
刘皓
39567dd0ea
Add fiber stack indices into libretro save state 2025-05-20 18:34:55 -04:00
刘皓
80b3833fff
Start implementing save state serialization in libretro builds 2025-05-20 17:42:35 -04:00
刘皓
5199c48de7
Remove exceptions from mkxp-z src/ directory 2025-05-16 15:54:32 -04:00
刘皓
215e880aa6
Make RTP paths in mkxp.json consistent with other paths in libretro builds 2025-05-14 10:10:46 -04:00
刘皓
28fb36af98
Capitalize /Dist, /Game, /Save and /System in libretro builds for consistency 2025-05-13 17:53:59 -04:00
刘皓
36075a5add
Load RTPs from mkxp.json as well in libretro builds 2025-05-13 17:26:30 -04:00
刘皓
714c583b9f
Allow RTPs to be loaded from archives as well in libretro builds 2025-05-13 16:17:04 -04:00
刘皓
75b953d4c8
Implement loading RTPs from the libretro system directory 2025-05-13 12:28:17 -04:00
刘皓
f57568e051
Allow some libretro core options to be changed during execution 2025-05-11 18:54:56 -04:00
刘皓
3fda80275d
Implement core options in libretro builds 2025-05-11 17:04:33 -04:00
刘皓
b8d785b7e1
Implement growing VM memory in libretro builds
The binding coroutines in libretro builds are constructed on the VM
stack, so reallocating the VM memory would corrupt the memory of any
currently existing coroutines.

I've changed it so that the coroutines are no longer constructed on the
VM stack so that they're unaffected by VM memory reallocations, and
added a "slot" mechanism for storing variables on the VM stack. (Any
Ruby `VALUE`s used by a coroutine have to be stored on the VM stack so
that the Ruby garbage collector doesn't free them while they're being
used, which is why the slot mechanism is necessary.)
2025-05-09 22:49:13 -04:00
刘皓
66256e9156
Put saves in ./mkxp-z/Saves/ in libretro save directory
Since the libretro save directory isn't guaranteed to be private for
each core, or even private for just saves, we'd better create a
directory structure in the libretro save directory for our saves.
2025-05-07 18:35:25 -04:00
刘皓
c85e9554ec
Implement writing to filesystem (i.e. game saving) in libretro builds
Files are written to the libretro save directory, which is mounted at
/save in PhysFS. All filesystem calls made from Ruby in libretro builds
are routed through PhysFS, so the game can just use any ordinary
filesystem function provided by Ruby to interact with /save.

It's also union mounted on top of the game directory (located at /game
in PhysFS) so that games that write their save files to the current
working directory will have their save files saved to the libretro save
directory instead of the game directory.

For security and portability reasons, nothing outside of the libretro
save directory can be written to, and nothing outside of the libretro
save directory, the libretro game directory and the various embedded
files used by the runtime can be read from.
2025-05-07 16:01:41 -04:00
刘皓
3e3df818aa
Use C getcwd() instead of Ruby Dir.pwd() to get CWD in libretro builds 2025-05-06 18:02:03 -04:00
刘皓
13c0657691
Handle current working directory properly in libretro builds
Any relative paths that the game tries to access in libretro builds will
now be relative to whatever is the current working directory in the Ruby
sandbox, which will also now be initialized to the game directory during
initialization. Before, all of the bindings that took paths were
hardcoded to prepend the path with the game directory.
2025-05-06 16:55:28 -04:00
刘皓
1c10158f2d
Add single-threaded Graphics.play_movie for platforms without multithreading 2025-05-05 11:00:27 -04:00
刘皓
82c3d7985c
Fix some Graphics.play_movie audio/video synchronization issues in libretro builds 2025-05-03 23:01:11 -04:00
刘皓
df1dbccf5a
Implement bindings for keyboard and controller button input in libretro builds 2025-05-02 14:53:21 -04:00
刘皓
5b94ce4e80
Refactor binding-sandbox header files into .cpp files 2025-04-30 22:31:13 -04:00
刘皓
09bcb1532c
Refactor out the SANDBOX_COROUTINE() macro
Removing this macro allows the correct line numbers to show up in GDB
stack traces.
2025-04-30 19:00:48 -04:00
刘皓
2373a22a70
Complete the graphics bindings in libretro builds 2025-04-29 14:51:19 -04:00