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 | { |
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 | |
688bdb95 |
33 | #define HACK_ENTRY(var, list) \ |
34 | { #var, &Config.hacks.var, list, ARRAY_SIZE(list) } |
35 | |
36 | static const struct |
37 | { |
38 | const char *name; |
39 | boolean *var; |
40 | const char * const * id_list; |
41 | size_t id_list_len; |
42 | } |
43 | hack_db[] = |
44 | { |
45 | HACK_ENTRY(cdr_read_timing, cdr_read_hack_db), |
8c84ba5f |
46 | HACK_ENTRY(gpu_slow_list_walking, gpu_slow_llist_db), |
eedfe806 |
47 | }; |
48 | |
4a02afab |
49 | static const struct |
50 | { |
51 | const char * const id; |
52 | int mult; |
53 | } |
d5aeda23 |
54 | cycle_multiplier_overrides[] = |
4a02afab |
55 | { |
56 | /* Internal Section - fussy about timings */ |
57 | { "SLPS01868", 202 }, |
58 | /* Super Robot Taisen Alpha - on the edge with 175, |
59 | * changing memcard settings is enough to break/unbreak it */ |
60 | { "SLPS02528", 190 }, |
61 | { "SLPS02636", 190 }, |
54c4acac |
62 | /* Brave Fencer Musashi - cd sectors arrive too fast */ |
63 | { "SLUS00726", 170 }, |
64 | { "SLPS01490", 170 }, |
7a8d521f |
65 | #if defined(DRC_DISABLE) || defined(LIGHTREC) /* new_dynarec has a hack for this game */ |
d5aeda23 |
66 | /* Parasite Eve II - internal timer checks */ |
67 | { "SLUS01042", 125 }, |
68 | { "SLUS01055", 125 }, |
69 | { "SLES02558", 125 }, |
70 | { "SLES12558", 125 }, |
71 | #endif |
4a02afab |
72 | }; |
73 | |
eedfe806 |
74 | /* Function for automatic patching according to GameID. */ |
75 | void Apply_Hacks_Cdrom() |
76 | { |
688bdb95 |
77 | size_t i, j; |
78 | |
79 | memset(&Config.hacks, 0, sizeof(Config.hacks)); |
80 | |
81 | for (i = 0; i < ARRAY_SIZE(hack_db); i++) |
82 | { |
83 | for (j = 0; j < hack_db[i].id_list_len; j++) |
84 | { |
85 | if (strncmp(CdromId, hack_db[i].id_list[j], 9)) |
86 | continue; |
87 | *hack_db[i].var = 1; |
88 | SysPrintf("using hack: %s\n", hack_db[i].name); |
89 | break; |
90 | } |
91 | } |
92 | |
eedfe806 |
93 | /* Apply Memory card hack for Codename Tenka. (The game needs one of the memory card slots to be empty) */ |
688bdb95 |
94 | for (i = 0; i < ARRAY_SIZE(MemorycardHack_db); i++) |
eedfe806 |
95 | { |
96 | if (strncmp(CdromId, MemorycardHack_db[i], 9) == 0) |
97 | { |
98 | /* Disable the second memory card slot for the game */ |
99 | Config.Mcd2[0] = 0; |
100 | /* This also needs to be done because in sio.c, they don't use Config.Mcd2 for that purpose */ |
101 | McdDisable[1] = 1; |
688bdb95 |
102 | break; |
eedfe806 |
103 | } |
104 | } |
a3203cf4 |
105 | |
106 | /* Dynarec game-specific hacks */ |
d62c125a |
107 | new_dynarec_hacks_pergame = 0; |
d5aeda23 |
108 | Config.cycle_multiplier_override = 0; |
a3203cf4 |
109 | |
d5aeda23 |
110 | for (i = 0; i < ARRAY_SIZE(cycle_multiplier_overrides); i++) |
a3203cf4 |
111 | { |
d5aeda23 |
112 | if (strcmp(CdromId, cycle_multiplier_overrides[i].id) == 0) |
4a02afab |
113 | { |
d5aeda23 |
114 | Config.cycle_multiplier_override = cycle_multiplier_overrides[i].mult; |
4a02afab |
115 | new_dynarec_hacks_pergame |= NDHACK_OVERRIDE_CYCLE_M; |
d5aeda23 |
116 | SysPrintf("using cycle_multiplier_override: %d\n", |
117 | Config.cycle_multiplier_override); |
4a02afab |
118 | break; |
119 | } |
a3203cf4 |
120 | } |
eedfe806 |
121 | } |