Commit graph

93 commits

Author SHA1 Message Date
刘皓
ced3e697bd
Fix Graphics.fadeout/.fadein causing screen flashing in libretro builds 2025-04-18 11:54:23 -04:00
刘皓
dafcb15ea5
Add enough bindings in libretro builds to play Crysalis 2025-04-17 14:17:17 -04:00
刘皓
e1c0e62aed
Fix Font.default_size binding in libretro builds 2025-04-17 11:34:42 -04:00
刘皓
35ffaff26e
Add bindings for snap_to_bitmap in libretro builds 2025-04-17 00:00:03 -04:00
刘皓
726b7f77f8
Fix bugs in VX/VXA input and window bindings in libretro builds 2025-04-16 23:42:52 -04:00
刘皓
b3976bf61e
Fix several bugs and missing bindings in libretro builds 2025-04-16 21:57:13 -04:00
刘皓
5a5fcd26c5
Delete copy constructor for stack_frame_guard and stack_frame
The copy constructors are causing problems when the `fiber.stack` vector
gets reallocated when its capacity is full, since when vectors are
reallocated, the elements are moved (or copied if there's no usable move
constructor) to the reallocated memory and then the original elements
are destroyed.

This premature calling of destructors leads to double-free and
use-after-free errors.

I fixed it by deleting the copy constructors and explicitly defining
move constructors.
2025-04-16 21:39:04 -04:00
刘皓
8e9e7700f0
Fix stack pointer corruption in binding-base.h 2025-04-16 19:21:48 -04:00
刘皓
c7f35c96c9
Make sandbox-bindgen allocate varargs buffers on the stack
Not sure why, but this fixes crashes when calling variadic functions in
the Ruby API in libretro builds when Ruby is built without `-DNDEBUG`.
Maybe the previous way of calling varargs functions was undefined
behaviour somehow.
2025-04-14 21:04:14 -04:00
刘皓
dae17511aa
Rescue all Ruby errors in libretro builds instead of only StandardErrors
`rb_rescue` only catches `StandardError`s, which doesn't include things
like Ruby syntax errors that we'd like to catch. We need to explicitly
use `rb_rescue2` to catch `Exception` in order to catch everything.
2025-04-13 22:18:41 -04:00
刘皓
06819fb9a9
Start implementing VX/VX Ace bindings in libretro builds 2025-04-13 17:30:50 -04:00
刘皓
8c16bc0092
Implement config loading in libretro builds 2025-04-11 23:12:05 -04:00
刘皓
299650159f
Implement changing the frame rate in libretro builds 2025-04-10 16:51:25 -04:00
刘皓
ae19c0e42e
Reconcile the standalone and libretro build systems 2025-04-09 23:52:12 -04:00
刘皓
8fa20c660a
Implement audio fading in libretro builds 2025-04-07 14:33:50 -04:00
刘皓
9f3329e1cb
Implement more of the audio bindings for libretro builds 2025-04-06 22:38:10 -04:00
刘皓
b1f1fb7571
Make Graphics.transition a no-op in libretro builds when not frozen 2025-04-05 21:37:27 -04:00
刘皓
6b59b60fe7
Fix incorrect initialize_copy bindings in libretro builds 2025-04-05 21:10:31 -04:00
刘皓
77c5ee65fd
Use rb_num2int instead of rb_num2uint in libretro graphics bindings 2025-04-05 21:07:37 -04:00
刘皓
d60b23781b
Implement Graphics.transition binding and related bindings in libretro builds 2025-04-05 14:35:43 -04:00
刘皓
7a2702bf95
Complete more of the font bindings for libretro builds 2025-04-04 12:20:33 -04:00
刘皓
981a7a2bd0
Remove unnecessary coroutines from libretro color= binding implementations 2025-04-02 13:22:31 -04:00
刘皓
8457ac1598
Rename mkxp-threads to mkxp-polyfill 2025-04-02 13:06:17 -04:00
刘皓
23781a645b
Implement bindings for changing font size and color in libretro builds 2025-03-31 18:48:14 -04:00
刘皓
dcd29f44a9
Remove dependency on libzip in libretro builds 2025-03-31 13:26:54 -04:00
刘皓
de5216c3ce
Implement loading from encrypted game archives in libretro builds 2025-03-30 23:37:19 -04:00
刘皓
d9f32b97a7
Fix libretro compilation error when using devkitARM 2025-03-29 13:40:13 -04:00
刘皓
6f6d0044ff
Decrease size of Ruby in libretro builds
This decreases the size of the libretro core by around 10% without
having a discernable effect on game compatibility.
2025-03-27 22:00:00 -04:00
刘皓
fac72be163
Fix a second Ruby memory leak
Okay, I think that fixes all the memory leaks. Finally! I'll submit a
pull request to Ruby to fix both of the memory leaks.
2025-03-27 00:28:37 -04:00
刘皓
c6dd227d54
Improve the stack frame guard implementation in libretro builds 2025-03-25 00:30:54 -04:00
刘皓
06f3c064b7
Make sure WebAssembly stack pointer is aligned in libretro builds 2025-03-22 19:33:16 -04:00
刘皓
207a5263e5
Fix typo in libretro flashable bindings 2025-03-22 11:52:44 -04:00
刘皓
322d61b604
Allow adjusting Ruby GC parameters in libretro builds
There seems to be a memory leak somewhere. I'm tweaking the GC
parameters to be more conservative to help track down the leak.
2025-03-21 11:56:45 -04:00
刘皓
85025c5f33
Fix Bitmap.blt and Bitmap.stretch_blt in libretro builds
Whoops, I accidentally switched these two functions!
2025-03-20 22:54:31 -04:00
刘皓
7d557354da
Implement flashable and viewport element bindings for libretro builds 2025-03-20 22:38:05 -04:00
刘皓
eb9a5a467e
Add Graphics.frame_count bindings in libretro builds 2025-03-20 21:29:22 -04:00
刘皓
8539a97f86
Fix clone method of Color, Tone and Rect in libretro builds 2025-03-20 19:38:38 -04:00
刘皓
28cc1255f4
Complete the table bindings for binding-sandbox 2025-03-18 18:49:34 -04:00
刘皓
d58a652f12
Fix tilemap rendering in libretro builds 2025-03-18 18:26:20 -04:00
刘皓
eeef9ff943
Don't make sandbox_malloc into a coroutine
Okay, the coroutine implementation of `sandbox_malloc` is clearly
broken. It would be working if Asyncify instrumented the `memory.grow`
WebAssembly instruction, but it doesn't instrument it.

This commit reverts commit 42c4ff9497 and
also increases the default VM memory allocation from 64 MiB to 96 MiB to
account for the lack of ability to increase the memory allocation at run
time. I'll find some new way to implement increasing the memory
allocation later.
2025-03-18 13:49:41 -04:00
刘皓
7ce7fdb3e0
Never free TilemapAutotiles in binding-sandbox 2025-03-17 15:52:00 -04:00
刘皓
67de008ed2
Add angle and mirror functions to libretro sprite bindings
Finally, it can get past the title screen of KNight-Blade.
2025-03-17 14:01:19 -04:00
刘皓
f3419a9c16
Merge branch 'libretro-compat' into libretro 2025-03-03 12:08:13 -05:00
刘皓
eac2b76f64
Don't use preferred path separator in wasi.cpp 2025-03-03 11:21:47 -05:00
刘皓
bffd6a280e
Merge branch 'libretro-compat' into libretro 2025-03-02 14:13:57 -05:00
刘皓
b68dae451d
Zero out memory allocated by wasm-rt
In release 1.0 of the WebAssembly Specification, it says that all the
bytes in WebAssembly memory need to be initialized to 0 on creation of
the memory, and when memory is grown, the new bytes also need to be
initialized to 0.

It seems this zeroing behaviour is indeed required for the sandbox to
operate correctly. Not zeroing leads to undefined behaviour. This
manifested as a crash that occurred when restarting the libretro core,
but for some reason, only on Emscripten. Not sure why this didn't happen
on other platforms. Even sanitizers weren't able to detect the bug!

(cherry picked from commit edf061e323b8f0ab0c6a72c76ae7ccc07a1649c0)
2025-03-02 14:05:49 -05:00
刘皓
db0758f634
Rename wasm-rt symbols to reduce probability of symbol conflicts with libretro frontend 2025-03-02 13:49:19 -05:00
刘皓
66152bf5c5
Merge branch 'libretro-compat' into libretro 2025-02-27 23:34:08 -05:00
刘皓
20f806abef
Remove dependency on xxd 2025-02-27 23:32:30 -05:00
刘皓
f4e7e8dac7
Add windowskin methods to binding-sandbox window binding 2025-02-27 14:58:50 -05:00