Commit graph

68 commits

Author SHA1 Message Date
刘皓
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
刘皓
25f21b9ab6
Implement more of the bitmap bindings for binding-sandbox 2025-02-27 14:41:13 -05:00
刘皓
4a810730f1
Merge branch 'libretro-compat' into libretro 2025-02-22 23:16:58 -05:00
刘皓
9ed11ecffa
Use libretro's PlayStation 3 Docker image instead of ScummVM's 2025-02-22 16:04:51 -05:00
刘皓
8a8860912a
Merge branch 'libretro-compat' into libretro 2025-02-21 23:56:52 -05:00
刘皓
71fa2453e8
Fix libretro compilation error when using GCC < 8.1.0 2025-02-21 17:56:32 -05:00
刘皓
7c5ae9a8e5
Start integrating libretro OpenGL graphics 2025-02-18 14:05:14 -05:00
刘皓
42c4ff9497
Make sandbox_malloc into a coroutine
According to AddressSanitizer, when `sandbox_malloc` causes the
WebAssembly memory to grow in size, every single coroutine on the
sandbox stack gets corrupted. So if `sandbox_malloc` is going to cause
the memory to grow in size, we need to yield so that there are no
coroutines on the sandbox stack while the reallocation occurs.
2025-02-17 00:38:40 -05:00
刘皓
decb4236bd
Fix use after free in wasi.cpp found by AddressSanitizer 2025-02-17 00:07:54 -05:00
刘皓
cae4166765
Use rb_obj_alloc instead of rb_class_new_instance in binding-sandbox
Somehow, using `rb_class_new_instance` causes use-after-free errors in
the subsequent call to `set_private_data`.

Well, `rb_obj_alloc` is what's used in the normal MRI bindings. I just
replaced the `rb_obj_alloc` calls with `rb_class_new_instance`
at some point in binding-sandbox. Guess that wasn't a good idea.
2025-02-16 23:30:09 -05:00
刘皓
58cf92e482
Fix memory corruption in wasm-rt found by AddressSanitizer 2025-02-16 17:52:41 -05:00
刘皓
5e93e5e834
Mark wasm_rt_trap as noreturn 2025-02-16 01:26:16 -05:00
刘皓
ce54a5f898
Don't build relocatable objects in libretro console builds
It seems this isn't supported either.
2025-02-13 22:24:08 -05:00
刘皓
865285db51
Change the name of the PAGE_SIZE macro 2025-02-13 15:20:18 -05:00
刘皓
206e8508b6
Replace WABT's WebAssembly runtime with a custom implementation 2025-02-11 20:40:55 -05:00
刘皓
821f77b5bb
Add default initializer to Color, Tone and Rect in libretro builds 2025-02-11 01:16:22 -05:00
刘皓
4e05a3cc99
Fix objects being prematurely freed in binding-sandbox 2025-02-07 18:10:06 -05:00
刘皓
060fa3b9b3
Fix some mistakes in binding-sandbox 2025-02-07 12:14:29 -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
刘皓
1e42180fa2
Stub out more of the sprite bindings for binding-sandbox 2025-02-05 22:30:04 -05:00
刘皓
8ed8c5c984
Implement playing sound effects in libretro builds 2025-02-05 12:36:45 -05:00
刘皓
1c4d65e02e
Refactor the non-autogenerated parts of sandbox-bindgen into separate files 2025-02-05 01:11:23 -05:00
刘皓
f1ad41814a
Start implementing input for libretro builds 2025-02-04 23:47:54 -05:00
刘皓
d7e002f9b0
Compile Ruby with -Oz -DNDEBUG in libretro builds 2025-02-02 17:05:15 -05:00