mods: support save-safe damage override and deadzone rounding

This commit is contained in:
Matthew Stanley
2026-08-04 18:50:31 -07:00
parent 1dcab6a2ff
commit 1bc84f38c6
3 changed files with 18 additions and 1 deletions
+6
View File
@@ -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
+7 -1
View File
@@ -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;
}
+5
View File
@@ -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);