* active), but before the game's handler loop reads I_STAT. The time
* window for this is quite small (~1k cycles of so). Apparently this
* somehow happens naturally on the real hardware.
+ *
+ * Note: always enforcing this breaks other games like Crash PAL version
+ * (inputs get dropped because bios handler doesn't see interrupts).
*/
- u32 vint_rel = rcnts[3].cycleStart + 63000 - psxRegs.cycle;
+ u32 vint_rel;
+ if (psxRegs.cycle - rcnts[3].cycleStart > 250000)
+ return cycles;
+ vint_rel = rcnts[3].cycleStart + 63000 - psxRegs.cycle;
vint_rel += PSXCLK / 60;
while ((s32)(vint_rel - cycles) < 0)
vint_rel += PSXCLK / 60;
cycles = (cdr.Mode & 0x80) ? cdReadTime : cdReadTime * 2;
cycles += seekTime;
- cycles = cdrAlignTimingHack(cycles);
+ if (Config.hacks.cdr_read_timing)
+ cycles = cdrAlignTimingHack(cycles);
CDRPLAYREAD_INT(cycles, 1);
SetPlaySeekRead(cdr.StatP, STATUS_SEEK);
/* It's duplicated from emu_if.c */
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
-static const char MemorycardHack_db[8][10] =
+static const char * const MemorycardHack_db[] =
{
/* Lifeforce Tenka, also known as Codename Tenka */
- {"SLES00613"},
- {"SLED00690"},
- {"SLES00614"},
- {"SLES00615"},
- {"SLES00616"},
- {"SLES00617"},
- {"SCUS94409"}
+ "SLES00613", "SLED00690", "SLES00614", "SLES00615",
+ "SLES00616", "SLES00617", "SCUS94409"
+};
+
+static const char * const cdr_read_hack_db[] =
+{
+ /* T'ai Fu - Wrath of the Tiger */
+ "SLUS00787",
+};
+
+#define HACK_ENTRY(var, list) \
+ { #var, &Config.hacks.var, list, ARRAY_SIZE(list) }
+
+static const struct
+{
+ const char *name;
+ boolean *var;
+ const char * const * id_list;
+ size_t id_list_len;
+}
+hack_db[] =
+{
+ HACK_ENTRY(cdr_read_timing, cdr_read_hack_db),
};
static const struct
/* Function for automatic patching according to GameID. */
void Apply_Hacks_Cdrom()
{
- uint32_t i;
-
+ size_t i, j;
+
+ memset(&Config.hacks, 0, sizeof(Config.hacks));
+
+ for (i = 0; i < ARRAY_SIZE(hack_db); i++)
+ {
+ for (j = 0; j < hack_db[i].id_list_len; j++)
+ {
+ if (strncmp(CdromId, hack_db[i].id_list[j], 9))
+ continue;
+ *hack_db[i].var = 1;
+ SysPrintf("using hack: %s\n", hack_db[i].name);
+ break;
+ }
+ }
+
/* Apply Memory card hack for Codename Tenka. (The game needs one of the memory card slots to be empty) */
- for(i=0;i<ARRAY_SIZE(MemorycardHack_db);i++)
+ for (i = 0; i < ARRAY_SIZE(MemorycardHack_db); i++)
{
if (strncmp(CdromId, MemorycardHack_db[i], 9) == 0)
{
Config.Mcd2[0] = 0;
/* This also needs to be done because in sio.c, they don't use Config.Mcd2 for that purpose */
McdDisable[1] = 1;
+ break;
}
}