cdrom: make the timing hack conditional
[pcsx_rearmed.git] / libpcsxcore / database.c
index 1ea8d43..f947b06 100644 (file)
@@ -5,16 +5,32 @@
 /* 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
@@ -42,10 +58,24 @@ cycle_multiplier_overrides[] =
 /* 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)
                {
@@ -53,6 +83,7 @@ void Apply_Hacks_Cdrom()
                        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;
                }
        }