SS: Patch the sound input driver if using New World ROM and ignore SEGV is false

This commit is contained in:
kanjitalk755 2020-09-04 19:06:49 +09:00
parent 98e12fbc2e
commit 09429e6021
4 changed files with 6 additions and 10 deletions

View File

@ -31,6 +31,7 @@ enum {
ROMTYPE_NEWWORLD
};
extern int ROMType;
extern bool SoundPatchFlag;
extern bool DecodeROM(uint8 *data, uint32 size);
extern bool PatchROM(void);

View File

@ -765,10 +765,6 @@ static void dump_disassembly(const uint32 pc, const int prefix_count, const int
}
}
static bool isSegvBinCue(uint32 a) {
return a == 0x389e00 || a == 0x389e08 || a == 0x389fe0 || a == 0x489e00 || a == 0x489e08 || a == 0x489fe0;
}
sigsegv_return_t sigsegv_handler(sigsegv_info_t *sip)
{
#if ENABLE_VOSF
@ -820,9 +816,6 @@ sigsegv_return_t sigsegv_handler(sigsegv_info_t *sip)
else if ((uint32)(addr - SheepMem::ZeroPage()) < (uint32)SheepMem::PageSize())
return SIGSEGV_RETURN_SKIP_INSTRUCTION;
else if (ROMType == ROMTYPE_NEWWORLD && isSegvBinCue(pc - ROMBase))
return SIGSEGV_RETURN_SKIP_INSTRUCTION;
// Ignore all other faults, if requested
if (PrefsFindBool("ignoresegv"))
return SIGSEGV_RETURN_SKIP_INSTRUCTION;

View File

@ -67,6 +67,7 @@ const uint32 ADDR_MAP_PATCH_SPACE = 0x2fd140;
// Global variables
int ROMType; // ROM type
bool SoundPatchFlag;
static uint32 sony_offset; // Offset of .Sony driver resource
// Prototypes
@ -694,6 +695,8 @@ bool PatchROM(void)
else
return false;
SoundPatchFlag = ROMType == ROMTYPE_NEWWORLD && !PrefsFindBool("ignoresegv");
// Check that other ROM addresses point to really free regions
if (!check_rom_patch_space(CHECK_LOAD_PATCH_SPACE, 0x40))
return false;

View File

@ -517,13 +517,12 @@ void CheckLoad(uint32 type, int16 id, uint16 *p, uint32 size)
D(bug(" patch applied\n"));
}
// patch for -16501 resource ID not even needed? seems to run off native driver without
/* } else if (type == FOURCC('D','R','V','R') && (id == -16501)){// || id == -16500)) { // -16500 will patch over native driver and traps out to code, but very hard to re-implement there!
} else if (SoundPatchFlag && type == FOURCC('D','R','V','R') && (id == -16501 || id == -16500)) {
D(bug("DRVR -16501/-16500 found\n"));
// Install sound input driver
memcpy(p, sound_input_driver, sizeof(sound_input_driver));
D(bug(" patch 1 applied\n"));
*/
} else if (type == FOURCC('I','N','I','T') && id == 1 && size == (2416 >> 1)) {
D(bug("INIT 1 (size 2416) found\n"));
size >>= 1;