Commit | Line | Data |
---|---|---|
630b122b | 1 | #include "misc.h" |
2 | #include "sio.h" | |
3 | #include "new_dynarec/new_dynarec.h" | |
8bccdd17 | 4 | #include "lightrec/plugin.h" |
630b122b | 5 | |
6 | /* It's duplicated from emu_if.c */ | |
7 | #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) | |
8 | ||
8bccdd17 PC |
9 | /* Corresponds to LIGHTREC_OPT_INV_DMA_ONLY of lightrec.h */ |
10 | #define LIGHTREC_HACK_INV_DMA_ONLY (1 << 0) | |
11 | ||
12 | u32 lightrec_hacks; | |
13 | ||
d0d2939d | 14 | static const char * const MemorycardHack_db[] = |
630b122b | 15 | { |
16 | /* Lifeforce Tenka, also known as Codename Tenka */ | |
d0d2939d | 17 | "SLES00613", "SLED00690", "SLES00614", "SLES00615", |
18 | "SLES00616", "SLES00617", "SCUS94409" | |
19 | }; | |
20 | ||
21 | static const char * const cdr_read_hack_db[] = | |
22 | { | |
23 | /* T'ai Fu - Wrath of the Tiger */ | |
24 | "SLUS00787", | |
25 | }; | |
26 | ||
fae38d7a | 27 | static const char * const gpu_slow_llist_db[] = |
28 | { | |
29 | /* Crash Bash */ | |
30 | "SCES02834", "SCUS94570", "SCUS94616", "SCUS94654", | |
31 | /* Final Fantasy IV */ | |
32 | "SCES03840", "SLPM86028", "SLUS01360", | |
33 | /* Spot Goes to Hollywood */ | |
34 | "SLES00330", "SLPS00394", "SLUS00014", | |
35 | /* Vampire Hunter D */ | |
36 | "SLES02731", "SLPS02477", "SLPS03198", "SLUS01138", | |
37 | }; | |
38 | ||
55ff7130 | 39 | static const char * const gpu_busy_hack_db[] = |
40 | { | |
41 | /* ToHeart (Japan) */ | |
42 | "SLPS01919", "SLPS01920", | |
43 | }; | |
44 | ||
d0d2939d | 45 | #define HACK_ENTRY(var, list) \ |
46 | { #var, &Config.hacks.var, list, ARRAY_SIZE(list) } | |
47 | ||
48 | static const struct | |
49 | { | |
50 | const char *name; | |
51 | boolean *var; | |
52 | const char * const * id_list; | |
53 | size_t id_list_len; | |
54 | } | |
55 | hack_db[] = | |
56 | { | |
57 | HACK_ENTRY(cdr_read_timing, cdr_read_hack_db), | |
fae38d7a | 58 | HACK_ENTRY(gpu_slow_list_walking, gpu_slow_llist_db), |
55ff7130 | 59 | HACK_ENTRY(gpu_busy_hack, gpu_busy_hack_db), |
630b122b | 60 | }; |
61 | ||
d7907215 | 62 | static const struct |
63 | { | |
64 | const char * const id; | |
65 | int mult; | |
66 | } | |
1562ed57 | 67 | cycle_multiplier_overrides[] = |
d7907215 | 68 | { |
9170c48e | 69 | /* note: values are = (10000 / gui_option) */ |
d7907215 | 70 | /* Internal Section - fussy about timings */ |
71 | { "SLPS01868", 202 }, | |
72 | /* Super Robot Taisen Alpha - on the edge with 175, | |
73 | * changing memcard settings is enough to break/unbreak it */ | |
74 | { "SLPS02528", 190 }, | |
75 | { "SLPS02636", 190 }, | |
b8f3d43d | 76 | /* Brave Fencer Musashi - cd sectors arrive too fast */ |
77 | { "SLUS00726", 170 }, | |
78 | { "SLPS01490", 170 }, | |
86be2515 | 79 | #if defined(DRC_DISABLE) || defined(LIGHTREC) /* new_dynarec has a hack for this game */ |
1562ed57 | 80 | /* Parasite Eve II - internal timer checks */ |
81 | { "SLUS01042", 125 }, | |
82 | { "SLUS01055", 125 }, | |
83 | { "SLES02558", 125 }, | |
84 | { "SLES12558", 125 }, | |
85 | #endif | |
b99a48f2 | 86 | /* Discworld Noir - audio skips if CPU runs too fast */ |
87 | { "SLES01549", 222 }, | |
88 | { "SLES02063", 222 }, | |
89 | { "SLES02064", 222 }, | |
9170c48e | 90 | /* Judge Dredd - could also be poor MDEC timing */ |
91 | { "SLUS00630", 128 }, | |
92 | { "SLES00755", 128 }, | |
93 | /* Digimon World */ | |
94 | { "SLUS01032", 153 }, | |
95 | { "SLES02914", 153 }, | |
d7907215 | 96 | }; |
97 | ||
8bccdd17 PC |
98 | static const struct |
99 | { | |
100 | const char * const id; | |
101 | u32 hacks; | |
102 | } | |
103 | lightrec_hacks_db[] = | |
104 | { | |
105 | /* Formula One Arcade */ | |
106 | { "SCES03886", LIGHTREC_HACK_INV_DMA_ONLY }, | |
107 | ||
108 | /* Formula One '99 */ | |
109 | { "SLUS00870", LIGHTREC_HACK_INV_DMA_ONLY }, | |
110 | { "SCPS10101", LIGHTREC_HACK_INV_DMA_ONLY }, | |
111 | { "SCES01979", LIGHTREC_HACK_INV_DMA_ONLY }, | |
112 | { "SLES01979", LIGHTREC_HACK_INV_DMA_ONLY }, | |
113 | ||
114 | /* Formula One 2000 */ | |
115 | { "SLUS01134", LIGHTREC_HACK_INV_DMA_ONLY }, | |
116 | { "SCES02777", LIGHTREC_HACK_INV_DMA_ONLY }, | |
117 | { "SCES02778", LIGHTREC_HACK_INV_DMA_ONLY }, | |
118 | { "SCES02779", LIGHTREC_HACK_INV_DMA_ONLY }, | |
119 | ||
120 | /* Formula One 2001 */ | |
121 | { "SCES03404", LIGHTREC_HACK_INV_DMA_ONLY }, | |
122 | { "SCES03423", LIGHTREC_HACK_INV_DMA_ONLY }, | |
123 | { "SCES03424", LIGHTREC_HACK_INV_DMA_ONLY }, | |
124 | { "SCES03524", LIGHTREC_HACK_INV_DMA_ONLY }, | |
125 | }; | |
126 | ||
630b122b | 127 | /* Function for automatic patching according to GameID. */ |
128 | void Apply_Hacks_Cdrom() | |
129 | { | |
d0d2939d | 130 | size_t i, j; |
131 | ||
132 | memset(&Config.hacks, 0, sizeof(Config.hacks)); | |
133 | ||
134 | for (i = 0; i < ARRAY_SIZE(hack_db); i++) | |
135 | { | |
136 | for (j = 0; j < hack_db[i].id_list_len; j++) | |
137 | { | |
138 | if (strncmp(CdromId, hack_db[i].id_list[j], 9)) | |
139 | continue; | |
140 | *hack_db[i].var = 1; | |
141 | SysPrintf("using hack: %s\n", hack_db[i].name); | |
142 | break; | |
143 | } | |
144 | } | |
145 | ||
630b122b | 146 | /* Apply Memory card hack for Codename Tenka. (The game needs one of the memory card slots to be empty) */ |
d0d2939d | 147 | for (i = 0; i < ARRAY_SIZE(MemorycardHack_db); i++) |
630b122b | 148 | { |
149 | if (strncmp(CdromId, MemorycardHack_db[i], 9) == 0) | |
150 | { | |
151 | /* Disable the second memory card slot for the game */ | |
152 | Config.Mcd2[0] = 0; | |
153 | /* This also needs to be done because in sio.c, they don't use Config.Mcd2 for that purpose */ | |
154 | McdDisable[1] = 1; | |
d0d2939d | 155 | break; |
630b122b | 156 | } |
157 | } | |
158 | ||
159 | /* Dynarec game-specific hacks */ | |
160 | new_dynarec_hacks_pergame = 0; | |
1562ed57 | 161 | Config.cycle_multiplier_override = 0; |
630b122b | 162 | |
1562ed57 | 163 | for (i = 0; i < ARRAY_SIZE(cycle_multiplier_overrides); i++) |
630b122b | 164 | { |
1562ed57 | 165 | if (strcmp(CdromId, cycle_multiplier_overrides[i].id) == 0) |
d7907215 | 166 | { |
1562ed57 | 167 | Config.cycle_multiplier_override = cycle_multiplier_overrides[i].mult; |
d7907215 | 168 | new_dynarec_hacks_pergame |= NDHACK_OVERRIDE_CYCLE_M; |
1562ed57 | 169 | SysPrintf("using cycle_multiplier_override: %d\n", |
170 | Config.cycle_multiplier_override); | |
d7907215 | 171 | break; |
172 | } | |
630b122b | 173 | } |
8bccdd17 PC |
174 | |
175 | lightrec_hacks = 0; | |
176 | ||
177 | for (i = 0; drc_is_lightrec() && i < ARRAY_SIZE(lightrec_hacks_db); i++) { | |
178 | if (strcmp(CdromId, lightrec_hacks_db[i].id) == 0) | |
179 | { | |
180 | lightrec_hacks = lightrec_hacks_db[i].hacks; | |
181 | SysPrintf("using lightrec_hacks: 0x%x\n", lightrec_hacks); | |
182 | break; | |
183 | } | |
184 | } | |
630b122b | 185 | } |