cdrom: make the timing hack conditional
[pcsx_rearmed.git] / libpcsxcore / database.c
CommitLineData
eedfe806 1#include "misc.h"
eedfe806 2#include "sio.h"
a3203cf4 3#include "new_dynarec/new_dynarec.h"
eedfe806 4
5/* It's duplicated from emu_if.c */
6#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
7
688bdb95 8static const char * const MemorycardHack_db[] =
eedfe806 9{
10 /* Lifeforce Tenka, also known as Codename Tenka */
688bdb95 11 "SLES00613", "SLED00690", "SLES00614", "SLES00615",
12 "SLES00616", "SLES00617", "SCUS94409"
13};
14
15static const char * const cdr_read_hack_db[] =
16{
17 /* T'ai Fu - Wrath of the Tiger */
18 "SLUS00787",
19};
20
21#define HACK_ENTRY(var, list) \
22 { #var, &Config.hacks.var, list, ARRAY_SIZE(list) }
23
24static const struct
25{
26 const char *name;
27 boolean *var;
28 const char * const * id_list;
29 size_t id_list_len;
30}
31hack_db[] =
32{
33 HACK_ENTRY(cdr_read_timing, cdr_read_hack_db),
eedfe806 34};
35
4a02afab 36static const struct
37{
38 const char * const id;
39 int mult;
40}
d5aeda23 41cycle_multiplier_overrides[] =
4a02afab 42{
43 /* Internal Section - fussy about timings */
44 { "SLPS01868", 202 },
45 /* Super Robot Taisen Alpha - on the edge with 175,
46 * changing memcard settings is enough to break/unbreak it */
47 { "SLPS02528", 190 },
48 { "SLPS02636", 190 },
7a8d521f 49#if defined(DRC_DISABLE) || defined(LIGHTREC) /* new_dynarec has a hack for this game */
d5aeda23 50 /* Parasite Eve II - internal timer checks */
51 { "SLUS01042", 125 },
52 { "SLUS01055", 125 },
53 { "SLES02558", 125 },
54 { "SLES12558", 125 },
55#endif
4a02afab 56};
57
eedfe806 58/* Function for automatic patching according to GameID. */
59void Apply_Hacks_Cdrom()
60{
688bdb95 61 size_t i, j;
62
63 memset(&Config.hacks, 0, sizeof(Config.hacks));
64
65 for (i = 0; i < ARRAY_SIZE(hack_db); i++)
66 {
67 for (j = 0; j < hack_db[i].id_list_len; j++)
68 {
69 if (strncmp(CdromId, hack_db[i].id_list[j], 9))
70 continue;
71 *hack_db[i].var = 1;
72 SysPrintf("using hack: %s\n", hack_db[i].name);
73 break;
74 }
75 }
76
eedfe806 77 /* Apply Memory card hack for Codename Tenka. (The game needs one of the memory card slots to be empty) */
688bdb95 78 for (i = 0; i < ARRAY_SIZE(MemorycardHack_db); i++)
eedfe806 79 {
80 if (strncmp(CdromId, MemorycardHack_db[i], 9) == 0)
81 {
82 /* Disable the second memory card slot for the game */
83 Config.Mcd2[0] = 0;
84 /* This also needs to be done because in sio.c, they don't use Config.Mcd2 for that purpose */
85 McdDisable[1] = 1;
688bdb95 86 break;
eedfe806 87 }
88 }
a3203cf4 89
90 /* Dynarec game-specific hacks */
d62c125a 91 new_dynarec_hacks_pergame = 0;
d5aeda23 92 Config.cycle_multiplier_override = 0;
a3203cf4 93
d5aeda23 94 for (i = 0; i < ARRAY_SIZE(cycle_multiplier_overrides); i++)
a3203cf4 95 {
d5aeda23 96 if (strcmp(CdromId, cycle_multiplier_overrides[i].id) == 0)
4a02afab 97 {
d5aeda23 98 Config.cycle_multiplier_override = cycle_multiplier_overrides[i].mult;
4a02afab 99 new_dynarec_hacks_pergame |= NDHACK_OVERRIDE_CYCLE_M;
d5aeda23 100 SysPrintf("using cycle_multiplier_override: %d\n",
101 Config.cycle_multiplier_override);
4a02afab 102 break;
103 }
a3203cf4 104 }
eedfe806 105}