diff --git a/runtime/include/mod_plugins.h b/runtime/include/mod_plugins.h index 390891a9..2cdb6ee8 100644 --- a/runtime/include/mod_plugins.h +++ b/runtime/include/mod_plugins.h @@ -34,6 +34,12 @@ uint16_t psx_mod_read_half(uint32_t address); void psx_mod_write_half(uint32_t address, uint16_t value); uint32_t psx_mod_read_word(uint32_t address); void psx_mod_write_word(uint32_t address, uint32_t value); +/* + * Replace one guest instruction and route that address through the runtime's + * executable-RAM path. Use this instead of psx_mod_write_word for code so a + * restored save state cannot leave the compiled instruction stale. + */ +void psx_mod_write_code_word(uint32_t address, uint32_t value); /* * Allocate opt-in enhancement memory from Expansion 1. Until the first diff --git a/runtime/src/main.cpp b/runtime/src/main.cpp index 81e04830..6c6ba82c 100644 --- a/runtime/src/main.cpp +++ b/runtime/src/main.cpp @@ -6007,7 +6007,13 @@ int main(int argc, char** argv) { } #endif { - int rui_deadzone_pct = seed.deadzone * 100 / 32767; + /* + * Round to the nearest launcher percent. Truncation turned a + * saved 20% value (6553/32767) into 19%, which the launcher's + * 5% normalization then silently reduced to 15%. + */ + int rui_deadzone_pct = + (seed.deadzone * 100 + 32767 / 2) / 32767; ls.deadzone[0] = rui_deadzone_pct; ls.deadzone[1] = rui_deadzone_pct; } diff --git a/runtime/src/mod_runtime.cpp b/runtime/src/mod_runtime.cpp index acfaf51d..d2d9e607 100644 --- a/runtime/src/mod_runtime.cpp +++ b/runtime/src/mod_runtime.cpp @@ -1124,6 +1124,11 @@ extern "C" void psx_mod_write_word(uint32_t address, uint32_t value) { psx_write_word(address, value); } +extern "C" void psx_mod_write_code_word(uint32_t address, uint32_t value) { + psx_write_word(address, value); + dirty_ram_mark_executable_range(address & 0x1FFFFFFFu, 4u); +} + extern "C" uint32_t psx_mod_alloc_guest_memory(uint32_t size, uint32_t alignment) { return psx_mod_memory_alloc(size, alignment);