Commit graph

18 commits

Author SHA1 Message Date
刘皓
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
刘皓
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
刘皓
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
刘皓
7a2702bf95
Complete more of the font bindings for libretro builds 2025-04-04 12:20:33 -04:00
刘皓
206e8508b6
Replace WABT's WebAssembly runtime with a custom implementation 2025-02-11 20:40:55 -05:00
刘皓
a75cf4ae22
Implement plane bindings for binding-sandbox 2025-02-06 19:44:34 -05:00
刘皓
74ebe267ee
Implement tilemap bindings for binding-sandbox 2025-02-06 15:01:05 -05:00
刘皓
6aa52c926c
Implement viewport bindings for binding-sandbox 2025-02-06 13:01:46 -05:00
刘皓
b1206d9dc5
Implement enough stub bindings for binding-sandbox to begin testing KNight-Blade 2025-01-23 14:23:34 -05:00
刘皓
7d753e2655
Implement even more of binding-sandbox
I've made it so that `Graphics.update` pauses the Ruby VM and returns to
the libretro frontend. Once the libretro frontend calls `retro_run()`
again, the Ruby VM resumes. This allows the libretro frontend to control
the rendering loop.
2025-01-22 21:52:55 -05:00
刘皓
4c9e68e066
Convert VALUEs to little-endian before passing to function pointers 2025-01-21 20:14:53 -05:00
刘皓
019812f71e
Start writing class/method stubs for binding-sandbox
I know I've got a long road ahead of me. I'm committing my work so far
for future reference and so that I can check for CI failures.
2025-01-21 12:56:17 -05:00
刘皓
379c22833f
Store coroutine variables in the Ruby stack in libretro builds
To stop Ruby's garbage collector from freeing Ruby `VALUE`s while we're
in the middle of using them in libretro builds, we need to make sure all
the `VALUE`s we use are on the sandbox's stack.

Also, to allow Ruby to recognize `VALUE`s on the sandbox's stack on
big-endian targets, I've changed the serialization of `VALUE`s. Before,
any `VALUE`s returned by a sandbox function were always converted to the
target's endian, and any `VALUE`s passed to sandbox functions as
argument were then converted back to WebAssembly's endianness,
little-endian. Now, `VALUE`s are always little-endian; they are no
longer converted to the target's endianness. That should be fine since
`VALUE`s are supposed to be opaque values.
2025-01-19 19:08:03 -05:00
刘皓
d7d460d6b0
Small fixes to the sandbox bindings 2025-01-19 11:30:55 -05:00
刘皓
fe5a94aea7
Implement loading scripts from Scripts.rxdata for libretro 2025-01-18 18:51:29 -05:00