add a nasty hack for gpu busy timing
[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
8c84ba5f 21static const char * const gpu_slow_llist_db[] =
22{
23 /* Crash Bash */
24 "SCES02834", "SCUS94570", "SCUS94616", "SCUS94654",
25 /* Final Fantasy IV */
26 "SCES03840", "SLPM86028", "SLUS01360",
27 /* Spot Goes to Hollywood */
28 "SLES00330", "SLPS00394", "SLUS00014",
29 /* Vampire Hunter D */
30 "SLES02731", "SLPS02477", "SLPS03198", "SLUS01138",
31};
32
979b861b 33static const char * const gpu_busy_hack_db[] =
34{
35 /* ToHeart (Japan) */
36 "SLPS01919", "SLPS01920",
37};
38
688bdb95 39#define HACK_ENTRY(var, list) \
40 { #var, &Config.hacks.var, list, ARRAY_SIZE(list) }
41
42static const struct
43{
44 const char *name;
45 boolean *var;
46 const char * const * id_list;
47 size_t id_list_len;
48}
49hack_db[] =
50{
51 HACK_ENTRY(cdr_read_timing, cdr_read_hack_db),
8c84ba5f 52 HACK_ENTRY(gpu_slow_list_walking, gpu_slow_llist_db),
979b861b 53 HACK_ENTRY(gpu_busy_hack, gpu_busy_hack_db),
eedfe806 54};
55
4a02afab 56static const struct
57{
58 const char * const id;
59 int mult;
60}
d5aeda23 61cycle_multiplier_overrides[] =
4a02afab 62{
bd9ad3d8 63 /* note: values are = (10000 / gui_option) */
4a02afab 64 /* Internal Section - fussy about timings */
65 { "SLPS01868", 202 },
66 /* Super Robot Taisen Alpha - on the edge with 175,
67 * changing memcard settings is enough to break/unbreak it */
68 { "SLPS02528", 190 },
69 { "SLPS02636", 190 },
54c4acac 70 /* Brave Fencer Musashi - cd sectors arrive too fast */
71 { "SLUS00726", 170 },
72 { "SLPS01490", 170 },
7a8d521f 73#if defined(DRC_DISABLE) || defined(LIGHTREC) /* new_dynarec has a hack for this game */
d5aeda23 74 /* Parasite Eve II - internal timer checks */
75 { "SLUS01042", 125 },
76 { "SLUS01055", 125 },
77 { "SLES02558", 125 },
78 { "SLES12558", 125 },
79#endif
7b9a83e8 80 /* Discworld Noir - audio skips if CPU runs too fast */
81 { "SLES01549", 222 },
82 { "SLES02063", 222 },
83 { "SLES02064", 222 },
bd9ad3d8 84 /* Judge Dredd - could also be poor MDEC timing */
85 { "SLUS00630", 128 },
86 { "SLES00755", 128 },
87 /* Digimon World */
88 { "SLUS01032", 153 },
89 { "SLES02914", 153 },
4a02afab 90};
91
eedfe806 92/* Function for automatic patching according to GameID. */
93void Apply_Hacks_Cdrom()
94{
688bdb95 95 size_t i, j;
96
97 memset(&Config.hacks, 0, sizeof(Config.hacks));
98
99 for (i = 0; i < ARRAY_SIZE(hack_db); i++)
100 {
101 for (j = 0; j < hack_db[i].id_list_len; j++)
102 {
103 if (strncmp(CdromId, hack_db[i].id_list[j], 9))
104 continue;
105 *hack_db[i].var = 1;
106 SysPrintf("using hack: %s\n", hack_db[i].name);
107 break;
108 }
109 }
110
eedfe806 111 /* Apply Memory card hack for Codename Tenka. (The game needs one of the memory card slots to be empty) */
688bdb95 112 for (i = 0; i < ARRAY_SIZE(MemorycardHack_db); i++)
eedfe806 113 {
114 if (strncmp(CdromId, MemorycardHack_db[i], 9) == 0)
115 {
116 /* Disable the second memory card slot for the game */
117 Config.Mcd2[0] = 0;
118 /* This also needs to be done because in sio.c, they don't use Config.Mcd2 for that purpose */
119 McdDisable[1] = 1;
688bdb95 120 break;
eedfe806 121 }
122 }
a3203cf4 123
124 /* Dynarec game-specific hacks */
d62c125a 125 new_dynarec_hacks_pergame = 0;
d5aeda23 126 Config.cycle_multiplier_override = 0;
a3203cf4 127
d5aeda23 128 for (i = 0; i < ARRAY_SIZE(cycle_multiplier_overrides); i++)
a3203cf4 129 {
d5aeda23 130 if (strcmp(CdromId, cycle_multiplier_overrides[i].id) == 0)
4a02afab 131 {
d5aeda23 132 Config.cycle_multiplier_override = cycle_multiplier_overrides[i].mult;
4a02afab 133 new_dynarec_hacks_pergame |= NDHACK_OVERRIDE_CYCLE_M;
d5aeda23 134 SysPrintf("using cycle_multiplier_override: %d\n",
135 Config.cycle_multiplier_override);
4a02afab 136 break;
137 }
a3203cf4 138 }
eedfe806 139}