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