105 |
|
* Resource patches via vCheckLoad |
106 |
|
*/ |
107 |
|
|
108 |
+ |
// 680x0 code pattern matching helper |
109 |
+ |
#define PM(N, V) (p[N] == htons(V)) |
110 |
+ |
|
111 |
|
void CheckLoad(uint32 type, int16 id, uint16 *p, uint32 size) |
112 |
|
{ |
113 |
|
uint16 *p16; |
115 |
|
D(bug("vCheckLoad %c%c%c%c (%08x) ID %d, data %p, size %d\n", type >> 24, (type >> 16) & 0xff, (type >> 8) & 0xff, type & 0xff, type, id, p, size)); |
116 |
|
|
117 |
|
// Don't modify resources in ROM |
118 |
< |
if ((uint32)p >= ROM_BASE && (uint32)p <= (ROM_BASE + ROM_SIZE)) |
118 |
> |
if ((uintptr)p >= ROM_BASE && (uintptr)p <= (ROM_BASE + ROM_SIZE)) |
119 |
|
return; |
120 |
|
|
121 |
|
if (type == FOURCC('b','o','o','t') && id == 3) { |
122 |
|
D(bug("boot 3 found\n")); |
123 |
|
size >>= 1; |
124 |
|
while (size--) { |
125 |
< |
if (p[0] == 0x2e49) { |
125 |
> |
if (PM(0,0x2e49)) { |
126 |
|
// Set boot stack pointer (7.5.2, 7.5.3, 7.5.5, 7.6, 7.6.1, 8.0, 8.1, 8.5, 8.6) |
127 |
< |
p[0] = M68K_EMUL_OP_FIX_BOOTSTACK; |
127 |
> |
p[0] = htons(M68K_EMUL_OP_FIX_BOOTSTACK); |
128 |
|
D(bug(" patch 1 applied\n")); |
129 |
< |
} else if (p[0] == 0x4267 && p[1] == 0x3f01 && p[2] == 0x3f2a && p[3] == 0x0006 && p[4] == 0x6100) { |
129 |
> |
} else if (PM(0,0x4267) && PM(1,0x3f01) && PM(2,0x3f2a) && PM(3,0x0006) && PM(4,0x6100)) { |
130 |
|
// Check when ntrb 17 is installed (for native Resource Manager patch) (7.5.3, 7.5.5) |
131 |
< |
p[7] = M68K_EMUL_OP_NTRB_17_PATCH3; |
131 |
> |
p[7] = htons(M68K_EMUL_OP_NTRB_17_PATCH3); |
132 |
|
D(bug(" patch 2 applied\n")); |
133 |
< |
} else if (p[0] == 0x3f2a && p[1] == 0x0006 && p[2] == 0x3f2a && p[3] == 0x0002 && p[4] == 0x6100) { |
133 |
> |
} else if (PM(0,0x3f2a) && PM(1,0x0006) && PM(2,0x3f2a) && PM(3,0x0002) && PM(4,0x6100)) { |
134 |
|
// Check when ntrb 17 is installed (for native Resource Manager patch) (7.6, 7.6.1, 8.0, 8.1) |
135 |
< |
p[7] = M68K_EMUL_OP_NTRB_17_PATCH; |
135 |
> |
p[7] = htons(M68K_EMUL_OP_NTRB_17_PATCH); |
136 |
|
D(bug(" patch 3 applied\n")); |
137 |
< |
} else if (p[0] == 0x3f2a && p[1] == 0x0006 && p[2] == 0x3f2a && p[3] == 0x0002 && p[4] == 0x61ff) { |
137 |
> |
} else if (PM(0,0x3f2a) && PM(1,0x0006) && PM(2,0x3f2a) && PM(3,0x0002) && PM(4,0x61ff)) { |
138 |
|
// Check when ntrb 17 is installed (for native Resource Manager patch) (8.5, 8.6) |
139 |
< |
p[8] = M68K_EMUL_OP_NTRB_17_PATCH; |
139 |
> |
p[8] = htons(M68K_EMUL_OP_NTRB_17_PATCH); |
140 |
|
D(bug(" patch 4 applied\n")); |
141 |
< |
} else if (p[0] == 0x0c39 && p[1] == 0x0001 && p[2] == 0xf800 && p[3] == 0x0008 && p[4] == 0x6f00) { |
141 |
> |
} else if (PM(0,0x0c39) && PM(1,0x0001) && PM(2,0xf800) && PM(3,0x0008) && PM(4,0x6f00)) { |
142 |
|
// Don't read from 0xf8000008 (8.5 with Zanzibar ROM, 8.6) |
143 |
< |
p[0] = M68K_NOP; |
144 |
< |
p[1] = M68K_NOP; |
145 |
< |
p[2] = M68K_NOP; |
146 |
< |
p[3] = M68K_NOP; |
147 |
< |
p[4] = 0x6000; // bra |
143 |
> |
p[0] = htons(M68K_NOP); |
144 |
> |
p[1] = htons(M68K_NOP); |
145 |
> |
p[2] = htons(M68K_NOP); |
146 |
> |
p[3] = htons(M68K_NOP); |
147 |
> |
p[4] = htons(0x6000); // bra |
148 |
|
D(bug(" patch 5 applied\n")); |
149 |
< |
} else if (p[0] == 0x2f3c && p[1] == 0x6b72 && p[2] == 0x6e6c && p[3] == 0x4267 && p[4] == 0xa9a0 && p[5] == 0x265f && p[6] == 0x200b && p[7] == 0x6700) { |
149 |
> |
} else if (PM(0,0x2f3c) && PM(1,0x6b72) && PM(2,0x6e6c) && PM(3,0x4267) && PM(4,0xa9a0) && PM(5,0x265f) && PM(6,0x200b) && PM(7,0x6700)) { |
150 |
|
// Don't replace nanokernel ("krnl" resource) (8.6) |
151 |
< |
p[0] = M68K_NOP; |
152 |
< |
p[1] = M68K_NOP; |
153 |
< |
p[2] = M68K_NOP; |
154 |
< |
p[3] = M68K_NOP; |
155 |
< |
p[4] = M68K_NOP; |
156 |
< |
p[7] = 0x6000; // bra |
151 |
> |
p[0] = htons(M68K_NOP); |
152 |
> |
p[1] = htons(M68K_NOP); |
153 |
> |
p[2] = htons(M68K_NOP); |
154 |
> |
p[3] = htons(M68K_NOP); |
155 |
> |
p[4] = htons(M68K_NOP); |
156 |
> |
p[7] = htons(0x6000); // bra |
157 |
|
D(bug(" patch 6 applied\n")); |
158 |
< |
} else if (p[0] == 0xa8fe && p[1] == 0x3038 && p[2] == 0x017a && p[3] == 0x0c40 && p[4] == 0x8805 && p[5] == 0x6710) { |
158 |
> |
} else if (PM(0,0xa8fe) && PM(1,0x3038) && PM(2,0x017a) && PM(3,0x0c40) && PM(4,0x8805) && PM(5,0x6710)) { |
159 |
|
// No SCSI (calls via 0x205c jump vector which is not initialized in NewWorld ROM 1.6) (8.6) |
160 |
|
if (ROMType == ROMTYPE_NEWWORLD) { |
161 |
< |
p[5] = 0x6010; // bra |
161 |
> |
p[5] = htons(0x6010); // bra |
162 |
|
D(bug(" patch 7 applied\n")); |
163 |
|
} |
164 |
|
} |
172 |
|
static const uint8 dat[] = {0x4e, 0xba, 0x00, 0x9e, 0x3e, 0x00, 0x50, 0x4f, 0x67, 0x04}; |
173 |
|
base = find_rsrc_data((uint8 *)p, size, dat, sizeof(dat)); |
174 |
|
if (base) { |
175 |
< |
p16 = (uint16 *)((uint32)p + base + 6); |
175 |
> |
p16 = (uint16 *)((uintptr)p + base + 6); |
176 |
|
*p16 = htons(M68K_EMUL_OP_NTRB_17_PATCH2); |
177 |
|
D(bug(" patch 1 applied\n")); |
178 |
|
} |
181 |
|
D(bug("ptch 420 found\n")); |
182 |
|
size >>= 1; |
183 |
|
while (size--) { |
184 |
< |
if (p[0] == 0xa030 && p[1] == 0x5240 && p[2] == 0x303c && p[3] == 0x0100 && p[4] == 0xc06e && p[5] == 0xfef6) { |
184 |
> |
if (PM(0,0xa030) && PM(1,0x5240) && PM(2,0x303c) && PM(3,0x0100) && PM(4,0xc06e) && PM(5,0xfef6)) { |
185 |
|
// Disable VM (7.5.2, 7.5.3, 7.5.5, 7.6, 7.6.1) |
186 |
< |
p[1] = M68K_NOP; |
187 |
< |
p[2] = M68K_NOP; |
188 |
< |
p[3] = M68K_NOP; |
189 |
< |
p[4] = M68K_NOP; |
190 |
< |
p[5] = M68K_NOP; |
191 |
< |
p[6] = M68K_NOP; |
192 |
< |
p[7] = M68K_NOP; |
193 |
< |
p[8] = M68K_NOP; |
194 |
< |
p[9] = M68K_NOP; |
195 |
< |
p[10] = M68K_NOP; |
196 |
< |
p[11] = M68K_NOP; |
186 |
> |
p[1] = htons(M68K_NOP); |
187 |
> |
p[2] = htons(M68K_NOP); |
188 |
> |
p[3] = htons(M68K_NOP); |
189 |
> |
p[4] = htons(M68K_NOP); |
190 |
> |
p[5] = htons(M68K_NOP); |
191 |
> |
p[6] = htons(M68K_NOP); |
192 |
> |
p[7] = htons(M68K_NOP); |
193 |
> |
p[8] = htons(M68K_NOP); |
194 |
> |
p[9] = htons(M68K_NOP); |
195 |
> |
p[10] = htons(M68K_NOP); |
196 |
> |
p[11] = htons(M68K_NOP); |
197 |
|
D(bug(" patch 1 applied\n")); |
198 |
|
break; |
199 |
< |
} else if (p[0] == 0xa030 && p[1] == 0x5240 && p[2] == 0x7000 && p[3] == 0x302e && p[4] == 0xfef6 && p[5] == 0x323c && p[6] == 0x0100) { |
199 |
> |
} else if (PM(0,0xa030) && PM(1,0x5240) && PM(2,0x7000) && PM(3,0x302e) && PM(4,0xfef6) && PM(5,0x323c) && PM(6,0x0100)) { |
200 |
|
// Disable VM (8.0, 8.1) |
201 |
< |
p[8] = M68K_NOP; |
202 |
< |
p[15] = M68K_NOP; |
201 |
> |
p[8] = htons(M68K_NOP); |
202 |
> |
p[15] = htons(M68K_NOP); |
203 |
|
D(bug(" patch 2 applied\n")); |
204 |
|
break; |
205 |
< |
} else if (p[0] == 0xa030 && p[1] == 0x5240 && p[2] == 0x7000 && p[3] == 0x302e && p[4] == 0xfecc && p[5] == 0x323c && p[6] == 0x0100) { |
205 |
> |
} else if (PM(0,0xa030) && PM(1,0x5240) && PM(2,0x7000) && PM(3,0x302e) && PM(4,0xfecc) && PM(5,0x323c) && PM(6,0x0100)) { |
206 |
|
// Disable VM (8.5, 8.6) |
207 |
< |
p[8] = M68K_NOP; |
208 |
< |
p[15] = M68K_NOP; |
207 |
> |
p[8] = htons(M68K_NOP); |
208 |
> |
p[15] = htons(M68K_NOP); |
209 |
|
D(bug(" patch 3 applied\n")); |
210 |
|
break; |
211 |
|
} |
216 |
|
D(bug("gpch 16 found\n")); |
217 |
|
size >>= 1; |
218 |
|
while (size--) { |
219 |
< |
if (p[0] == 0x6700 && p[13] == 0x7013 && p[14] == 0xfe0a) { |
219 |
> |
if (PM(0,0x6700) && PM(13,0x7013) && PM(14,0xfe0a)) { |
220 |
|
// Don't call FE0A in Shutdown Manager (7.6.1, 8.0, 8.1, 8.5) |
221 |
< |
p[0] = 0x6000; |
221 |
> |
p[0] = htons(0x6000); |
222 |
|
D(bug(" patch 1 applied\n")); |
223 |
|
break; |
224 |
|
} |
229 |
|
D(bug("gpch 650 found\n")); |
230 |
|
size >>= 1; |
231 |
|
while (size--) { |
232 |
< |
if (p[0] == 0x6600 && p[1] == 0x001a && p[2] == 0x2278 && p[3] == 0x0134) { |
232 |
> |
if (PM(0,0x6600) && PM(1,0x001a) && PM(2,0x2278) && PM(3,0x0134)) { |
233 |
|
// We don't have SonyVars (7.5.2) |
234 |
< |
p[0] = 0x6000; |
234 |
> |
p[0] = htons(0x6000); |
235 |
|
D(bug(" patch 1 applied\n")); |
236 |
< |
} else if (p[0] == 0x6618 && p[1] == 0x2278 && p[2] == 0x0134) { |
236 |
> |
} else if (PM(0,0x6618) && PM(1,0x2278) && PM(2,0x0134)) { |
237 |
|
// We don't have SonyVars (7.5.3) |
238 |
< |
p[-6] = M68K_NOP; |
239 |
< |
p[-3] = M68K_NOP; |
240 |
< |
p[0] = 0x6018; |
238 |
> |
p[-6] = htons(M68K_NOP); |
239 |
> |
p[-3] = htons(M68K_NOP); |
240 |
> |
p[0] = htons(0x6018); |
241 |
|
D(bug(" patch 2 applied\n")); |
242 |
< |
} else if (p[0] == 0x666e && p[1] == 0x2278 && p[2] == 0x0134) { |
242 |
> |
} else if (PM(0,0x666e) && PM(1,0x2278) && PM(2,0x0134)) { |
243 |
|
// We don't have SonyVars (7.5.5) |
244 |
< |
p[-6] = M68K_NOP; |
245 |
< |
p[-3] = M68K_NOP; |
246 |
< |
p[0] = 0x606e; |
244 |
> |
p[-6] = htons(M68K_NOP); |
245 |
> |
p[-3] = htons(M68K_NOP); |
246 |
> |
p[0] = htons(0x606e); |
247 |
|
D(bug(" patch 3 applied\n")); |
248 |
< |
} else if (p[0] == 0x6400 && p[1] == 0x011c && p[2] == 0x2278 && p[3] == 0x0134) { |
248 |
> |
} else if (PM(0,0x6400) && PM(1,0x011c) && PM(2,0x2278) && PM(3,0x0134)) { |
249 |
|
// We don't have SonyVars (7.6.1, 8.0, 8.1, 8.5, 8.6) |
250 |
< |
p[0] = 0x6000; |
250 |
> |
p[0] = htons(0x6000); |
251 |
|
D(bug(" patch 4 applied\n")); |
252 |
< |
} else if (p[0] == 0x6400 && p[1] == 0x00e6 && p[2] == 0x2278 && p[3] == 0x0134) { |
252 |
> |
} else if (PM(0,0x6400) && PM(1,0x00e6) && PM(2,0x2278) && PM(3,0x0134)) { |
253 |
|
// We don't have SonyVars (7.6) |
254 |
< |
p[0] = 0x6000; |
254 |
> |
p[0] = htons(0x6000); |
255 |
|
D(bug(" patch 5 applied\n")); |
256 |
|
} |
257 |
|
p++; |
261 |
|
D(bug("gpch 655 found\n")); |
262 |
|
size >>= 1; |
263 |
|
while (size--) { |
264 |
< |
if (p[0] == 0x83a8 && p[1] == 0x0024 && p[2] == 0x4e71) { |
264 |
> |
if (PM(0,0x83a8) && PM(1,0x0024) && PM(2,0x4e71)) { |
265 |
|
// Don't write to GC interrupt mask (7.6, 7.6.1, 8.0, 8.1 with Zanzibar ROM) |
266 |
< |
p[0] = M68K_NOP; |
267 |
< |
p[1] = M68K_NOP; |
266 |
> |
p[0] = htons(M68K_NOP); |
267 |
> |
p[1] = htons(M68K_NOP); |
268 |
|
D(bug(" patch 1 applied\n")); |
269 |
< |
} else if (p[0] == 0x207c && p[1] == 0xf300 && p[2] == 0x0034) { |
269 |
> |
} else if (PM(0,0x207c) && PM(1,0xf300) && PM(2,0x0034)) { |
270 |
|
// Don't read PowerMac ID (7.6, 7.6.1, 8.0, 8.1 with Zanzibar ROM) |
271 |
< |
p[0] = 0x303c; // move.w #id,d0 |
272 |
< |
p[1] = 0x3020; |
273 |
< |
p[2] = M68K_RTS; |
271 |
> |
p[0] = htons(0x303c); // move.w #id,d0 |
272 |
> |
p[1] = htons(0x3020); |
273 |
> |
p[2] = htons(M68K_RTS); |
274 |
|
D(bug(" patch 2 applied\n")); |
275 |
< |
} else if (p[0] == 0x13fc && p[1] == 0x0081 && p[2] == 0xf130 && p[3] == 0xa030) { |
275 |
> |
} else if (PM(0,0x13fc) && PM(1,0x0081) && PM(2,0xf130) && PM(3,0xa030)) { |
276 |
|
// Don't write to hardware (7.6, 7.6.1, 8.0, 8.1 with Zanzibar ROM) |
277 |
< |
p[0] = M68K_NOP; |
278 |
< |
p[1] = M68K_NOP; |
279 |
< |
p[2] = M68K_NOP; |
280 |
< |
p[3] = M68K_NOP; |
277 |
> |
p[0] = htons(M68K_NOP); |
278 |
> |
p[1] = htons(M68K_NOP); |
279 |
> |
p[2] = htons(M68K_NOP); |
280 |
> |
p[3] = htons(M68K_NOP); |
281 |
|
D(bug(" patch 3 applied\n")); |
282 |
< |
} else if (p[0] == 0x4e56 && p[1] == 0x0000 && p[2] == 0x227c && p[3] == 0xf800 && p[4] == 0x0000) { |
282 |
> |
} else if (PM(0,0x4e56) && PM(1,0x0000) && PM(2,0x227c) && PM(3,0xf800) && PM(4,0x0000)) { |
283 |
|
// OpenFirmare? (7.6.1, 8.0, 8.1 with Zanzibar ROM) |
284 |
< |
p[0] = M68K_RTS; |
284 |
> |
p[0] = htons(M68K_RTS); |
285 |
|
D(bug(" patch 4 applied\n")); |
286 |
< |
} else if (p[0] == 0x4e56 && p[1] == 0xfffc && p[2] == 0x48e7 && p[3] == 0x0300 && p[4] == 0x598f && p[5] == 0x2eb8 && p[6] == 0x01dc) { |
286 |
> |
} else if (PM(0,0x4e56) && PM(1,0xfffc) && PM(2,0x48e7) && PM(3,0x0300) && PM(4,0x598f) && PM(5,0x2eb8) && PM(6,0x01dc)) { |
287 |
|
// Don't write to SCC (7.6.1, 8.0, 8.1 with Zanzibar ROM) |
288 |
< |
p[0] = M68K_RTS; |
288 |
> |
p[0] = htons(M68K_RTS); |
289 |
|
D(bug(" patch 5 applied\n")); |
290 |
< |
} else if (p[0] == 0x4e56 && p[1] == 0x0000 && p[2] == 0x227c && p[3] == 0xf300 && p[4] == 0x0034) { |
290 |
> |
} else if (PM(0,0x4e56) && PM(1,0x0000) && PM(2,0x227c) && PM(3,0xf300) && PM(4,0x0034)) { |
291 |
|
// Don't write to GC (7.6.1, 8.0, 8.1 with Zanzibar ROM) |
292 |
< |
p[0] = M68K_RTS; |
292 |
> |
p[0] = htons(M68K_RTS); |
293 |
|
D(bug(" patch 6 applied\n")); |
294 |
< |
} else if (p[0] == 0x40e7 && p[1] == 0x007c && p[2] == 0x0700 && p[3] == 0x48e7 && p[4] == 0x00c0 && p[5] == 0x2078 && p[6] == 0x0dd8 && p[7] == 0xd1e8 && p[8] == 0x0044 && p[9] == 0x8005 && p[11] == 0x93c8 && p[12] == 0x2149 && p[13] == 0x0024) { |
294 |
> |
} else if (PM(0,0x40e7) && PM(1,0x007c) && PM(2,0x0700) && PM(3,0x48e7) && PM(4,0x00c0) && PM(5,0x2078) && PM(6,0x0dd8) && PM(7,0xd1e8) && PM(8,0x0044) && PM(9,0x8005) && PM(11,0x93c8) && PM(12,0x2149) && PM(13,0x0024)) { |
295 |
|
// Don't replace NVRAM routines (7.6, 7.6.1, 8.0, 8.1 with Zanzibar ROM) |
296 |
< |
p[0] = M68K_RTS; |
296 |
> |
p[0] = htons(M68K_RTS); |
297 |
|
D(bug(" patch 7 applied\n")); |
298 |
< |
} else if (p[0] == 0x207c && p[1] == 0x50f1 && p[2] == 0xa101 && (p[3] == 0x08d0 || p[3] == 0x0890)) { |
298 |
> |
} else if (PM(0,0x207c) && PM(1,0x50f1) && PM(2,0xa101) && (PM(3,0x08d0) || PM(3,0x0890))) { |
299 |
|
// Don't write to 0x50f1a101 (8.1 with Zanzibar ROM) |
300 |
< |
p[3] = M68K_NOP; |
301 |
< |
p[4] = M68K_NOP; |
300 |
> |
p[3] = htons(M68K_NOP); |
301 |
> |
p[4] = htons(M68K_NOP); |
302 |
|
D(bug(" patch 8 applied\n")); |
303 |
|
} |
304 |
|
p++; |
308 |
|
D(bug("gpch 750 found\n")); |
309 |
|
size >>= 1; |
310 |
|
while (size--) { |
311 |
< |
if (p[0] == 0xf301 && p[1] == 0x9100 && p[2] == 0x0c11 && p[3] == 0x0044) { |
311 |
> |
if (PM(0,0xf301) && PM(1,0x9100) && PM(2,0x0c11) && PM(3,0x0044)) { |
312 |
|
// Don't read from 0xf3019100 (MACE ENET) (7.6, 7.6.1, 8.0, 8.1) |
313 |
< |
p[2] = M68K_NOP; |
314 |
< |
p[3] = M68K_NOP; |
315 |
< |
p[4] = 0x6026; |
313 |
> |
p[2] = htons(M68K_NOP); |
314 |
> |
p[3] = htons(M68K_NOP); |
315 |
> |
p[4] = htons(0x6026); |
316 |
|
D(bug(" patch 1 applied\n")); |
317 |
< |
} else if (p[0] == 0x41e8 && p[1] == 0x0374 && p[2] == 0xfc1e) { |
317 |
> |
} else if (PM(0,0x41e8) && PM(1,0x0374) && PM(2,0xfc1e)) { |
318 |
|
// Don't call FC1E opcode (7.6, 7.6.1, 8.0, 8.1, 8.5, 8.6) |
319 |
< |
p[2] = M68K_NOP; |
319 |
> |
p[2] = htons(M68K_NOP); |
320 |
|
D(bug(" patch 2 applied\n")); |
321 |
< |
} else if (p[0] == 0x700a && p[1] == 0xfe0a) { |
321 |
> |
} else if (PM(0,0x700a) && PM(1,0xfe0a)) { |
322 |
|
// Don't call FE0A opcode (7.6, 7.6.1, 8.0, 8.1, 8.5, 8.6) |
323 |
< |
p[1] = 0x7000; |
323 |
> |
p[1] = htons(0x7000); |
324 |
|
D(bug(" patch 3 applied\n")); |
325 |
< |
} else if (p[0] == 0x6c00 && p[1] == 0x016a && p[2] == 0x2278 && p[3] == 0x0134) { |
325 |
> |
} else if (PM(0,0x6c00) && PM(1,0x016a) && PM(2,0x2278) && PM(3,0x0134)) { |
326 |
|
// We don't have SonyVars (8.6) |
327 |
< |
p[-4] = 0x21fc; // move.l $40810000,($0000) |
328 |
< |
p[-3] = 0x4081; |
329 |
< |
p[-2] = 0x0000; |
330 |
< |
p[-1] = 0x0000; |
331 |
< |
p[0] = 0x6000; |
327 |
> |
p[-4] = htons(0x21fc); // move.l $40810000,($0000) |
328 |
> |
p[-3] = htons(0x4081); |
329 |
> |
p[-2] = htons(0x0000); |
330 |
> |
p[-1] = htons(0x0000); |
331 |
> |
p[0] = htons(0x6000); |
332 |
|
D(bug(" patch 4 applied\n")); |
333 |
|
} |
334 |
|
p++; |
338 |
|
D(bug("gpch 999 found\n")); |
339 |
|
size >>= 1; |
340 |
|
while (size--) { |
341 |
< |
if (p[0] == 0xf301 && p[1] == 0x9100 && p[2] == 0x0c11 && p[3] == 0x0044) { |
341 |
> |
if (PM(0,0xf301) && PM(1,0x9100) && PM(2,0x0c11) && PM(3,0x0044)) { |
342 |
|
// Don't read from 0xf3019100 (MACE ENET) (8.5, 8.6) |
343 |
< |
p[2] = M68K_NOP; |
344 |
< |
p[3] = M68K_NOP; |
345 |
< |
p[4] = 0x6026; |
343 |
> |
p[2] = htons(M68K_NOP); |
344 |
> |
p[3] = htons(M68K_NOP); |
345 |
> |
p[4] = htons(0x6026); |
346 |
|
D(bug(" patch 1 applied\n")); |
347 |
|
} |
348 |
|
p++; |
352 |
|
D(bug("gpch 3000 found\n")); |
353 |
|
size >>= 1; |
354 |
|
while (size--) { |
355 |
< |
if (p[0] == 0xf301 && p[1] == 0x9100 && p[2] == 0x0c11 && p[3] == 0x0044) { |
355 |
> |
if (PM(0,0xf301) && PM(1,0x9100) && PM(2,0x0c11) && PM(3,0x0044)) { |
356 |
|
// Don't read from 0xf3019100 (MACE ENET) (8.1 with NewWorld ROM) |
357 |
< |
p[2] = M68K_NOP; |
358 |
< |
p[3] = M68K_NOP; |
359 |
< |
p[4] = 0x6026; |
357 |
> |
p[2] = htons(M68K_NOP); |
358 |
> |
p[3] = htons(M68K_NOP); |
359 |
> |
p[4] = htons(0x6026); |
360 |
|
D(bug(" patch 1 applied\n")); |
361 |
|
} |
362 |
|
p++; |
367 |
|
#if 1 |
368 |
|
size >>= 1; |
369 |
|
while (size--) { |
370 |
< |
if (p[0] == 0xc2fc && p[1] == 0x0fa0 && p[2] == 0x82c5) { |
370 |
> |
if (PM(0,0xc2fc) && PM(1,0x0fa0) && PM(2,0x82c5)) { |
371 |
|
// Prevent division by 0 in speed test (7.5.2, 7.5.3, 7.5.5, 7.6, 7.6.1, 8.0, 8.1) |
372 |
< |
p[2] = 0x7200; |
372 |
> |
p[2] = htons(0x7200); |
373 |
|
WriteMacInt32(0x1d8, 0x2c00); |
374 |
|
WriteMacInt32(0x1dc, 0x2c00); |
375 |
|
D(bug(" patch 1 applied\n")); |
376 |
< |
} else if (p[0] == 0x1418 && p[1] == 0x84c1) { |
376 |
> |
} else if (PM(0,0x1418) && PM(1,0x84c1)) { |
377 |
|
// Prevent division by 0 (7.5.2, 7.5.3, 7.5.5, 7.6, 7.6.1, 8.0, 8.1) |
378 |
< |
p[1] = 0x7400; |
378 |
> |
p[1] = htons(0x7400); |
379 |
|
D(bug(" patch 2 applied\n")); |
380 |
< |
} else if (p[0] == 0x2678 && p[1] == 0x01dc && p[2] == 0x3018 && p[3] == 0x6708 && p[4] == 0x1680 && p[5] == 0xe058 && p[6] == 0x1680) { |
380 |
> |
} else if (PM(0,0x2678) && PM(1,0x01dc) && PM(2,0x3018) && PM(3,0x6708) && PM(4,0x1680) && PM(5,0xe058) && PM(6,0x1680)) { |
381 |
|
// Don't write to SCC (7.5.2, 7.5.3, 7.5.5, 7.6, 7.6.1, 8.0, 8.1) |
382 |
< |
p[4] = M68K_NOP; |
383 |
< |
p[6] = M68K_NOP; |
382 |
> |
p[4] = htons(M68K_NOP); |
383 |
> |
p[6] = htons(M68K_NOP); |
384 |
|
D(bug(" patch 3 applied\n")); |
385 |
< |
} else if (p[0] == 0x2278 && p[1] == 0x01dc && p[2] == 0x12bc && p[3] == 0x0006 && p[4] == 0x4e71 && p[5] == 0x1292) { |
385 |
> |
} else if (PM(0,0x2278) && PM(1,0x01dc) && PM(2,0x12bc) && PM(3,0x0006) && PM(4,0x4e71) && PM(5,0x1292)) { |
386 |
|
// Don't write to SCC (7.5.2, 7.5.3, 7.5.5, 7.6, 7.6.1, 8.0, 8.1) |
387 |
< |
p[2] = M68K_NOP; |
388 |
< |
p[3] = M68K_NOP; |
389 |
< |
p[5] = M68K_NOP; |
387 |
> |
p[2] = htons(M68K_NOP); |
388 |
> |
p[3] = htons(M68K_NOP); |
389 |
> |
p[5] = htons(M68K_NOP); |
390 |
|
D(bug(" patch 4 applied\n")); |
391 |
< |
} else if (p[0] == 0x2278 && p[1] == 0x01dc && p[2] == 0x12bc && p[3] == 0x0003 && p[4] == 0x4e71 && p[5] == 0x1281) { |
391 |
> |
} else if (PM(0,0x2278) && PM(1,0x01dc) && PM(2,0x12bc) && PM(3,0x0003) && PM(4,0x4e71) && PM(5,0x1281)) { |
392 |
|
// Don't write to SCC (7.5.2, 7.5.3, 7.5.5, 7.6, 7.6.1, 8.0, 8.1) |
393 |
< |
p[2] = M68K_NOP; |
394 |
< |
p[3] = M68K_NOP; |
395 |
< |
p[5] = M68K_NOP; |
393 |
> |
p[2] = htons(M68K_NOP); |
394 |
> |
p[3] = htons(M68K_NOP); |
395 |
> |
p[5] = htons(M68K_NOP); |
396 |
|
D(bug(" patch 5 applied\n")); |
397 |
< |
} else if (p[0] == 0x0811 && p[1] == 0x0000 && p[2] == 0x51c8 && p[3] == 0xfffa) { |
397 |
> |
} else if (PM(0,0x0811) && PM(1,0x0000) && PM(2,0x51c8) && PM(3,0xfffa)) { |
398 |
|
// Don't test SCC (7.5.2, 7.5.3, 7.5.5, 7.6, 7.6.1, 8.0, 8.1) |
399 |
< |
p[0] = M68K_NOP; |
400 |
< |
p[1] = M68K_NOP; |
399 |
> |
p[0] = htons(M68K_NOP); |
400 |
> |
p[1] = htons(M68K_NOP); |
401 |
|
D(bug(" patch 6 applied\n")); |
402 |
< |
} else if (p[0] == 0x4a2a && p[1] == 0x063e && p[2] == 0x66fa) { |
402 |
> |
} else if (PM(0,0x4a2a) && PM(1,0x063e) && PM(2,0x66fa)) { |
403 |
|
// Don't wait for SCC (7.5.2, 7.5.3, 7.5.5) |
404 |
< |
p[2] = M68K_NOP; |
404 |
> |
p[2] = htons(M68K_NOP); |
405 |
|
D(bug(" patch 7 applied\n")); |
406 |
< |
} else if (p[0] == 0x4a2a && p[1] == 0x03a6 && p[2] == 0x66fa) { |
406 |
> |
} else if (PM(0,0x4a2a) && PM(1,0x03a6) && PM(2,0x66fa)) { |
407 |
|
// Don't wait for SCC (7.6, 7.6.1, 8.0, 8.1) |
408 |
< |
p[2] = M68K_NOP; |
408 |
> |
p[2] = htons(M68K_NOP); |
409 |
|
D(bug(" patch 8 applied\n")); |
410 |
|
} |
411 |
|
p++; |
412 |
|
} |
413 |
|
#else |
414 |
|
// Disable LocalTalk |
415 |
< |
p[0] = M68K_JMP_A0; |
416 |
< |
p[1] = 0x7000; // moveq #0,d0 |
417 |
< |
p[2] = M68K_RTS; |
415 |
> |
p[0] = htons(M68K_JMP_A0); |
416 |
> |
p[1] = htons(0x7000); // moveq #0,d0 |
417 |
> |
p[2] = htons(M68K_RTS); |
418 |
|
D(bug(" patch 1 applied\n")); |
419 |
|
#endif |
420 |
|
|
436 |
|
D(bug("citt 45 found\n")); |
437 |
|
size >>= 1; |
438 |
|
while (size--) { |
439 |
< |
if (p[0] == 0x203c && p[1] == 0x0100 && p[2] == 0x0000 && p[3] == 0xc0ae && p[4] == 0xfffc) { |
439 |
> |
if (PM(0,0x203c) && PM(1,0x0100) && PM(2,0x0000) && PM(3,0xc0ae) && PM(4,0xfffc)) { |
440 |
|
// Don't replace SCSI Manager (8.1, 8.5, 8.6) |
441 |
< |
p[5] = (p[5] & 0xff) | 0x6000; // beq |
441 |
> |
p[5] = htons((p[5] & 0xff) | 0x6000); // beq |
442 |
|
D(bug(" patch 1 applied\n")); |
443 |
|
break; |
444 |
|
} |
452 |
|
if (c_type == FOURCC('s','d','e','v') && sub_type == FOURCC('s','i','n','g')) { |
453 |
|
1[(uint32 *)p] = FOURCC('a','w','g','c'); |
454 |
|
D(bug("thng %d, type %c%c%c%c (%08x), sub type %c%c%c%c (%08x), data %p\n", id, c_type >> 24, (c_type >> 16) & 0xff, (c_type >> 8) & 0xff, c_type & 0xff, c_type, sub_type >> 24, (sub_type >> 16) & 0xff, (sub_type >> 8) & 0xff, sub_type & 0xff, sub_type, p)); |
455 |
< |
AddSifter(*(uint32 *)(((uint32)p)+20), p[12]); |
455 |
> |
AddSifter(*(uint32 *)(((uintptr)p)+20), p[12]); |
456 |
|
if (p[28]) // componentPFCount |
457 |
< |
AddSifter(*(uint32 *)(((uint32)p)+62), p[33]); |
457 |
> |
AddSifter(*(uint32 *)(((uintptr)p)+62), p[33]); |
458 |
|
} |
459 |
|
|
460 |
|
} else if (type == FOURCC('s','i','f','t') || type == FOURCC('n','i','f','t')) { |
461 |
|
// Patch audio sifters |
462 |
|
if (FindSifter(type, id)) { |
463 |
|
D(bug("sifter found\n")); |
464 |
< |
p[0] = 0x4e56; p[1] = 0x0000; // link a6,#0 |
465 |
< |
p[2] = 0x48e7; p[3] = 0x8018; // movem.l d0/a3-a4,-(a7) |
466 |
< |
p[4] = 0x266e; p[5] = 0x000c; // movea.l $c(a6),a3 |
467 |
< |
p[6] = 0x286e; p[7] = 0x0008; // movea.l $8(a6),a4 |
468 |
< |
p[8] = M68K_EMUL_OP_AUDIO_DISPATCH; |
469 |
< |
p[9] = 0x2d40; p[10] = 0x0010; // move.l d0,$10(a6) |
470 |
< |
p[11] = 0x4cdf; p[12] = 0x1801; // movem.l (a7)+,d0/a3-a4 |
471 |
< |
p[13] = 0x4e5e; // unlk a6 |
472 |
< |
p[14] = 0x4e74; p[15] = 0x0008; // rtd #8 |
464 |
> |
p[0] = htons(0x4e56); p[1] = htons(0x0000); // link a6,#0 |
465 |
> |
p[2] = htons(0x48e7); p[3] = htons(0x8018); // movem.l d0/a3-a4,-(a7) |
466 |
> |
p[4] = htons(0x266e); p[5] = htons(0x000c); // movea.l $c(a6),a3 |
467 |
> |
p[6] = htons(0x286e); p[7] = htons(0x0008); // movea.l $8(a6),a4 |
468 |
> |
p[8] = htons(M68K_EMUL_OP_AUDIO_DISPATCH); |
469 |
> |
p[9] = htons(0x2d40); p[10] = htons(0x0010); // move.l d0,$10(a6) |
470 |
> |
p[11] = htons(0x4cdf); p[12] = htons(0x1801); // movem.l (a7)+,d0/a3-a4 |
471 |
> |
p[13] = htons(0x4e5e); // unlk a6 |
472 |
> |
p[14] = htons(0x4e74); p[15] = htons(0x0008); // rtd #8 |
473 |
|
D(bug(" patch applied\n")); |
474 |
|
} |
475 |
|
|
483 |
|
D(bug("INIT 1 (size 2416) found\n")); |
484 |
|
size >>= 1; |
485 |
|
while (size--) { |
486 |
< |
if (p[0] == 0x247c && p[1] == 0xf301 && p[2] == 0x9000) { |
486 |
> |
if (PM(0,0x247c) && PM(1,0xf301) && PM(2,0x9000)) { |
487 |
|
// Prevent "MacOS Licensing Extension" from accessing hardware (7.6) |
488 |
< |
p[22] = 0x6028; |
488 |
> |
p[22] = htons(0x6028); |
489 |
|
D(bug(" patch 1 applied\n")); |
490 |
|
break; |
491 |
|
} |
499 |
|
static const uint8 dat[] = {0x4e, 0x56, 0x00, 0x00, 0x48, 0xe7, 0x03, 0x18, 0x2c, 0x2e, 0x00, 0x10}; |
500 |
|
base = find_rsrc_data((uint8 *)p, size, dat, sizeof(dat)); |
501 |
|
if (base) { |
502 |
< |
p16 = (uint16 *)((uint32)p + base); |
503 |
< |
p16[0] = 0x7000; // moveq #0,d0 |
504 |
< |
p16[1] = M68K_RTS; |
502 |
> |
p16 = (uint16 *)((uintptr)p + base); |
503 |
> |
p16[0] = htons(0x7000); // moveq #0,d0 |
504 |
> |
p16[1] = htons(M68K_RTS); |
505 |
|
D(bug(" patch 1 applied\n")); |
506 |
|
} |
507 |
|
} |