1 |
|
/* |
2 |
|
* rsrc_patches.cpp - Resource patches |
3 |
|
* |
4 |
< |
* Basilisk II (C) 1997-2000 Christian Bauer |
4 |
> |
* Basilisk II (C) 1997-2008 Christian Bauer |
5 |
|
* |
6 |
|
* This program is free software; you can redistribute it and/or modify |
7 |
|
* it under the terms of the GNU General Public License as published by |
22 |
|
|
23 |
|
#include "sysdeps.h" |
24 |
|
#include "cpu_emulation.h" |
25 |
+ |
#include "macos_util.h" |
26 |
|
#include "main.h" |
27 |
+ |
#include "prefs.h" |
28 |
|
#include "emul_op.h" |
29 |
|
#include "audio.h" |
30 |
|
#include "audio_defs.h" |
38 |
|
#include "debug.h" |
39 |
|
|
40 |
|
|
39 |
– |
#if !EMULATED_68K |
40 |
– |
// Assembly functions |
41 |
– |
extern "C" void Scod060Patch1(void); |
42 |
– |
extern "C" void Scod060Patch2(void); |
43 |
– |
extern "C" void ThInitFPUPatch(void); |
44 |
– |
#endif |
45 |
– |
|
46 |
– |
|
41 |
|
/* |
42 |
|
* Search resource for byte string, return offset (or 0) |
43 |
|
*/ |
54 |
|
|
55 |
|
|
56 |
|
/* |
57 |
+ |
* Install SynchIdleTime() patch |
58 |
+ |
*/ |
59 |
+ |
|
60 |
+ |
static void patch_idle_time(uint8 *p, uint32 size, int n = 1) |
61 |
+ |
{ |
62 |
+ |
if (!PrefsFindBool("idlewait")) |
63 |
+ |
return; |
64 |
+ |
|
65 |
+ |
static const uint8 dat[] = {0x70, 0x03, 0xa0, 0x9f}; |
66 |
+ |
uint32 base = find_rsrc_data(p, size, dat, sizeof(dat)); |
67 |
+ |
if (base) { |
68 |
+ |
uint8 *pbase = p + base - 0x80; |
69 |
+ |
static const uint8 dat2[] = {0x20, 0x78, 0x02, 0xb6, 0x41, 0xe8, 0x00, 0x80}; |
70 |
+ |
base = find_rsrc_data(pbase, 0x80, dat2, sizeof(dat2)); |
71 |
+ |
if (base) { |
72 |
+ |
uint16 *p16 = (uint16 *)(pbase + base); |
73 |
+ |
*p16++ = htons(M68K_EMUL_OP_IDLE_TIME); |
74 |
+ |
*p16 = htons(M68K_NOP); |
75 |
+ |
FlushCodeCache(pbase + base, 4); |
76 |
+ |
D(bug(" patch %d applied\n", n)); |
77 |
+ |
} |
78 |
+ |
} |
79 |
+ |
} |
80 |
+ |
|
81 |
+ |
|
82 |
+ |
/* |
83 |
|
* Resource patches via vCheckLoad |
84 |
|
*/ |
85 |
|
|
87 |
|
{ |
88 |
|
uint16 *p16; |
89 |
|
uint32 base; |
90 |
< |
D(bug("vCheckLoad %c%c%c%c (%08lx) ID %d, data %08lx, size %ld\n", (char)(type >> 24), (char)((type >> 16) & 0xff), (char )((type >> 8) & 0xff), (char )(type & 0xff), type, id, p, size)); |
91 |
< |
|
92 |
< |
if (type == 'boot' && id == 3) { |
90 |
> |
D(bug("vCheckLoad %c%c%c%c (%08x) ID %d, data %p, size %d\n", (char)(type >> 24), (char)((type >> 16) & 0xff), (char )((type >> 8) & 0xff), (char )(type & 0xff), type, id, p, size)); |
91 |
> |
|
92 |
> |
if (type == FOURCC('b','o','o','t') && id == 3) { |
93 |
|
D(bug(" boot 3 found\n")); |
94 |
|
|
95 |
|
// Set boot stack pointer (7.5, 7.6, 7.6.1, 8.0) |
103 |
|
} |
104 |
|
|
105 |
|
#if !ROM_IS_WRITE_PROTECTED |
106 |
< |
// Set fake handle at 0x0000 to some safe place (so broken Mac programs won't write into Mac ROM) (7.5, 8.0) |
106 |
> |
// Set fake handle at 0x0000 to some safe place (so broken Mac programs won't write into Mac ROM) (7.1, 7.5, 8.0) |
107 |
|
static const uint8 dat2[] = {0x20, 0x78, 0x02, 0xae, 0xd1, 0xfc, 0x00, 0x01, 0x00, 0x00, 0x21, 0xc8, 0x00, 0x00}; |
108 |
|
base = find_rsrc_data(p, size, dat2, sizeof(dat2)); |
109 |
|
if (base) { |
110 |
|
p16 = (uint16 *)(p + base); |
111 |
|
|
112 |
< |
#if defined(AMIGA) || defined(__NetBSD__) |
112 |
> |
#if defined(USE_SCRATCHMEM_SUBTERFUGE) |
113 |
|
// Set 0x0000 to scratch memory area |
114 |
< |
extern uint32 ScratchMem; |
114 |
> |
extern uint8 *ScratchMem; |
115 |
> |
const uint32 ScratchMemBase = Host2MacAddr(ScratchMem); |
116 |
|
*p16++ = htons(0x207c); // move.l #ScratchMem,a0 |
117 |
< |
*p16++ = htons(ScratchMem >> 16); |
118 |
< |
*p16++ = htons(ScratchMem); |
117 |
> |
*p16++ = htons(ScratchMemBase >> 16); |
118 |
> |
*p16++ = htons(ScratchMemBase); |
119 |
|
*p16++ = htons(M68K_NOP); |
120 |
|
*p16 = htons(M68K_NOP); |
121 |
|
#else |
125 |
|
D(bug(" patch 2 applied\n")); |
126 |
|
} |
127 |
|
|
128 |
< |
} else if (type == 'boot' && id == 2) { |
128 |
> |
} else if (type == FOURCC('b','o','o','t') && id == 2) { |
129 |
|
D(bug(" boot 2 found\n")); |
130 |
|
|
131 |
< |
// Set fake handle at 0x0000 to some safe place (so broken Mac programs won't write into Mac ROM) (7.5, 8.0) |
131 |
> |
// Set fake handle at 0x0000 to some safe place (so broken Mac programs won't write into Mac ROM) (7.1, 7.5, 8.0) |
132 |
|
static const uint8 dat[] = {0x20, 0x78, 0x02, 0xae, 0xd1, 0xfc, 0x00, 0x01, 0x00, 0x00, 0x21, 0xc8, 0x00, 0x00}; |
133 |
|
base = find_rsrc_data(p, size, dat, sizeof(dat)); |
134 |
|
if (base) { |
135 |
|
p16 = (uint16 *)(p + base); |
136 |
|
|
137 |
< |
#if defined(AMIGA) || defined(__NetBSD__) |
137 |
> |
#if defined(USE_SCRATCHMEM_SUBTERFUGE) |
138 |
|
// Set 0x0000 to scratch memory area |
139 |
< |
extern uint32 ScratchMem; |
139 |
> |
extern uint8 *ScratchMem; |
140 |
> |
const uint32 ScratchMemBase = Host2MacAddr(ScratchMem); |
141 |
|
*p16++ = htons(0x207c); // move.l #ScratchMem,a0 |
142 |
< |
*p16++ = htons(ScratchMem >> 16); |
143 |
< |
*p16++ = htons(ScratchMem); |
142 |
> |
*p16++ = htons(ScratchMemBase >> 16); |
143 |
> |
*p16++ = htons(ScratchMemBase); |
144 |
|
*p16++ = htons(M68K_NOP); |
145 |
|
*p16 = htons(M68K_NOP); |
146 |
|
#else |
151 |
|
} |
152 |
|
#endif |
153 |
|
|
154 |
< |
} else if (type == 'PTCH' && id == 630) { |
154 |
> |
} else if (type == FOURCC('P','T','C','H') && id == 630) { |
155 |
|
D(bug("PTCH 630 found\n")); |
156 |
|
|
157 |
|
// Don't replace Time Manager (Classic ROM, 6.0.3) |
178 |
|
D(bug(" patch 1 applied\n")); |
179 |
|
} |
180 |
|
|
181 |
< |
} else if (type == 'ptch' && id == 26) { |
181 |
> |
} else if (type == FOURCC('p','t','c','h') && id == 26) { |
182 |
|
D(bug(" ptch 26 found\n")); |
183 |
|
|
184 |
< |
// Trap ABC4 is initialized with absolute ROM address (7.5, 7.6, 7.6.1, 8.0) |
184 |
> |
// Trap ABC4 is initialized with absolute ROM address (7.1, 7.5, 7.6, 7.6.1, 8.0) |
185 |
|
static const uint8 dat[] = {0x40, 0x83, 0x36, 0x10}; |
186 |
|
base = find_rsrc_data(p, size, dat, sizeof(dat)); |
187 |
|
if (base) { |
192 |
|
D(bug(" patch 1 applied\n")); |
193 |
|
} |
194 |
|
|
195 |
< |
} else if (type == 'ptch' && id == 34) { |
195 |
> |
} else if (type == FOURCC('p','t','c','h') && id == 34) { |
196 |
|
D(bug(" ptch 34 found\n")); |
197 |
|
|
198 |
|
// Don't wait for VIA (Classic ROM, 6.0.8) |
216 |
|
D(bug(" patch 2 applied\n")); |
217 |
|
} |
218 |
|
|
219 |
< |
#if !EMULATED_68K |
198 |
< |
} else if (CPUIs68060 && (type == 'gpch' && id == 669 || type == 'lpch' && id == 63)) { |
199 |
< |
D(bug(" gpch 669/lpch 63 found\n")); |
200 |
< |
|
201 |
< |
static uint16 ThPatchSpace[1024]; // Replacement routines are constructed here |
202 |
< |
uint16 *q = ThPatchSpace; |
203 |
< |
uint32 start; |
204 |
< |
int i; |
205 |
< |
|
206 |
< |
// Patch Thread Manager thread switcher for 68060 FPU (7.5, 8.0) |
207 |
< |
static const uint8 dat[] = {0x22, 0x6f, 0x00, 0x08, 0x20, 0x2f, 0x00, 0x04, 0x67, 0x18}; |
208 |
< |
base = find_rsrc_data(p, size, dat, sizeof(dat)); |
209 |
< |
if (base) { // Skip first routine (no FPU -> no FPU) |
210 |
< |
|
211 |
< |
base = find_rsrc_data(p, size - base - 2, dat, sizeof(dat), base + 2); |
212 |
< |
if (base) { // no FPU -> FPU |
213 |
< |
|
214 |
< |
p16 = (uint16 *)(p + base); |
215 |
< |
start = (uint32)q; |
216 |
< |
for (i=0; i<28; i++) *q++ = *p16++; |
217 |
< |
*q++ = htons(0x4a2f); // tst.b 2(sp) (null FPU state or "FPU state saved" flag set?) |
218 |
< |
*q++ = htons(2); |
219 |
< |
*q++ = htons(0x6712); // beq |
220 |
< |
*q++ = htons(0x588f); // addq.l #2,sp (flag set, skip it) |
221 |
< |
*q++ = htons(0xf21f); // fmove.l (sp)+,fpcr (restore FPU registers) |
222 |
< |
*q++ = htons(0x9000); |
223 |
< |
*q++ = htons(0xf21f); // fmove.l (sp)+,fpsr |
224 |
< |
*q++ = htons(0x8800); |
225 |
< |
*q++ = htons(0xf21f); // fmove.l (sp)+,fpiar |
226 |
< |
*q++ = htons(0x8400); |
227 |
< |
*q++ = htons(0xf21f); // fmovem.x (sp)+,fp0-fp7 |
228 |
< |
*q++ = htons(0xd0ff); |
229 |
< |
*q++ = htons(0xf35f); // frestore (sp)+ |
230 |
< |
*q++ = htons(0x4e75); // rts |
231 |
< |
|
232 |
< |
p16 = (uint16 *)(p + base); |
233 |
< |
*p16++ = htons(M68K_JMP); |
234 |
< |
*p16++ = htons(start >> 16); |
235 |
< |
*p16 = htons(start & 0xffff); |
236 |
< |
FlushCodeCache(p + base, 6); |
237 |
< |
D(bug(" patch 1 applied\n")); |
238 |
< |
|
239 |
< |
static const uint8 dat2[] = {0x22, 0x6f, 0x00, 0x08, 0x20, 0x2f, 0x00, 0x04, 0x67, 0x28}; |
240 |
< |
base = find_rsrc_data(p, size, dat2, sizeof(dat2)); |
241 |
< |
if (base) { // FPU -> FPU |
242 |
< |
|
243 |
< |
p16 = (uint16 *)(p + base); |
244 |
< |
start = (uint32)q; |
245 |
< |
for (i=0; i<4; i++) *q++ = *p16++; |
246 |
< |
*q++ = htons(0x6736); // beq |
247 |
< |
*q++ = htons(0xf327); // fsave -(sp) (save FPU state frame) |
248 |
< |
*q++ = htons(0x4a2f); // tst.b 2(sp) (null FPU state?) |
249 |
< |
*q++ = htons(2); |
250 |
< |
*q++ = htons(0x6716); // beq |
251 |
< |
*q++ = htons(0xf227); // fmovem.x fp0-fp7,-(sp) (no, save FPU registers) |
252 |
< |
*q++ = htons(0xe0ff); |
253 |
< |
*q++ = htons(0xf227); // fmove.l fpiar,-(sp) |
254 |
< |
*q++ = htons(0xa400); |
255 |
< |
*q++ = htons(0xf227); // fmove.l fpsr,-(sp) |
256 |
< |
*q++ = htons(0xa800); |
257 |
< |
*q++ = htons(0xf227); // fmove.l fpcr,-(sp) |
258 |
< |
*q++ = htons(0xb000); |
259 |
< |
*q++ = htons(0x4879); // pea -1 (push "FPU state saved" flag) |
260 |
< |
*q++ = htons(0xffff); |
261 |
< |
*q++ = htons(0xffff); |
262 |
< |
p16 += 9; |
263 |
< |
for (i=0; i<23; i++) *q++ = *p16++; |
264 |
< |
*q++ = htons(0x4a2f); // tst.b 2(sp) (null FPU state or "FPU state saved" flag set?) |
265 |
< |
*q++ = htons(2); |
266 |
< |
*q++ = htons(0x6712); // beq |
267 |
< |
*q++ = htons(0x588f); // addq.l #2,sp (flag set, skip it) |
268 |
< |
*q++ = htons(0xf21f); // fmove.l (sp)+,fpcr (restore FPU registers) |
269 |
< |
*q++ = htons(0x9000); |
270 |
< |
*q++ = htons(0xf21f); // fmove.l (sp)+,fpsr |
271 |
< |
*q++ = htons(0x8800); |
272 |
< |
*q++ = htons(0xf21f); // fmove.l (sp)+,fpiar |
273 |
< |
*q++ = htons(0x8400); |
274 |
< |
*q++ = htons(0xf21f); // fmovem.x (sp)+,fp0-fp7 |
275 |
< |
*q++ = htons(0xd0ff); |
276 |
< |
*q++ = htons(0xf35f); // frestore (sp)+ |
277 |
< |
*q++ = htons(0x4e75); // rts |
278 |
< |
|
279 |
< |
p16 = (uint16 *)(p + base); |
280 |
< |
*p16++ = htons(M68K_JMP); |
281 |
< |
*p16++ = htons(start >> 16); |
282 |
< |
*p16 = htons(start & 0xffff); |
283 |
< |
FlushCodeCache(p + base, 6); |
284 |
< |
D(bug(" patch 2 applied\n")); |
285 |
< |
|
286 |
< |
base = find_rsrc_data(p, size - base - 2, dat2, sizeof(dat2), base + 2); |
287 |
< |
if (base) { // FPU -> no FPU |
288 |
< |
|
289 |
< |
p16 = (uint16 *)(p + base); |
290 |
< |
start = (uint32)q; |
291 |
< |
for (i=0; i<4; i++) *q++ = *p16++; |
292 |
< |
*q++ = htons(0x6736); // beq |
293 |
< |
*q++ = htons(0xf327); // fsave -(sp) (save FPU state frame) |
294 |
< |
*q++ = htons(0x4a2f); // tst.b 2(sp) (null FPU state?) |
295 |
< |
*q++ = htons(2); |
296 |
< |
*q++ = htons(0x6716); // beq |
297 |
< |
*q++ = htons(0xf227); // fmovem.x fp0-fp7,-(sp) (no, save FPU registers) |
298 |
< |
*q++ = htons(0xe0ff); |
299 |
< |
*q++ = htons(0xf227); // fmove.l fpiar,-(sp) |
300 |
< |
*q++ = htons(0xa400); |
301 |
< |
*q++ = htons(0xf227); // fmove.l fpsr,-(sp) |
302 |
< |
*q++ = htons(0xa800); |
303 |
< |
*q++ = htons(0xf227); // fmove.l fpcr,-(sp) |
304 |
< |
*q++ = htons(0xb000); |
305 |
< |
*q++ = htons(0x4879); // pea -1 (push "FPU state saved" flag) |
306 |
< |
*q++ = htons(0xffff); |
307 |
< |
*q++ = htons(0xffff); |
308 |
< |
p16 += 9; |
309 |
< |
for (i=0; i<24; i++) *q++ = *p16++; |
310 |
< |
|
311 |
< |
p16 = (uint16 *)(p + base); |
312 |
< |
*p16++ = htons(M68K_JMP); |
313 |
< |
*p16++ = htons(start >> 16); |
314 |
< |
*p16 = htons(start & 0xffff); |
315 |
< |
FlushCodeCache(p + base, 6); |
316 |
< |
D(bug(" patch 3 applied\n")); |
317 |
< |
} |
318 |
< |
} |
319 |
< |
} |
320 |
< |
} |
321 |
< |
|
322 |
< |
// Patch Thread Manager thread switcher for 68060 FPU (additional routines under 8.0 for Mixed Mode Manager) |
323 |
< |
static const uint8 dat3[] = {0x22, 0x6f, 0x00, 0x08, 0x20, 0x2f, 0x00, 0x04, 0x67, 0x40}; |
324 |
< |
base = find_rsrc_data(p, size, dat3, sizeof(dat3)); |
325 |
< |
if (base) { // Skip first routine (no FPU -> no FPU) |
326 |
< |
|
327 |
< |
base = find_rsrc_data(p, size - base - 2, dat3, sizeof(dat3), base + 2); |
328 |
< |
if (base) { // no FPU -> FPU |
329 |
< |
|
330 |
< |
p16 = (uint16 *)(p + base); |
331 |
< |
start = (uint32)q; |
332 |
< |
for (i=0; i<48; i++) *q++ = *p16++; |
333 |
< |
*q++ = htons(0x4a2f); // tst.b 2(sp) (null FPU state or "FPU state saved" flag set?) |
334 |
< |
*q++ = htons(2); |
335 |
< |
*q++ = htons(0x6712); // beq |
336 |
< |
*q++ = htons(0x588f); // addq.l #2,sp (flag set, skip it) |
337 |
< |
*q++ = htons(0xf21f); // fmove.l (sp)+,fpcr (restore FPU registers) |
338 |
< |
*q++ = htons(0x9000); |
339 |
< |
*q++ = htons(0xf21f); // fmove.l (sp)+,fpsr |
340 |
< |
*q++ = htons(0x8800); |
341 |
< |
*q++ = htons(0xf21f); // fmove.l (sp)+,fpiar |
342 |
< |
*q++ = htons(0x8400); |
343 |
< |
*q++ = htons(0xf21f); // fmovem.x (sp)+,fp0-fp7 |
344 |
< |
*q++ = htons(0xd0ff); |
345 |
< |
p16 += 7; |
346 |
< |
for (i=0; i<20; i++) *q++ = *p16++; |
347 |
< |
|
348 |
< |
p16 = (uint16 *)(p + base); |
349 |
< |
*p16++ = htons(M68K_JMP); |
350 |
< |
*p16++ = htons(start >> 16); |
351 |
< |
*p16 = htons(start & 0xffff); |
352 |
< |
FlushCodeCache(p + base, 6); |
353 |
< |
D(bug(" patch 4 applied\n")); |
354 |
< |
|
355 |
< |
static const uint8 dat4[] = {0x22, 0x6f, 0x00, 0x08, 0x20, 0x2f, 0x00, 0x04, 0x67, 0x50}; |
356 |
< |
base = find_rsrc_data(p, size, dat4, sizeof(dat4)); |
357 |
< |
if (base) { // FPU -> FPU |
358 |
< |
|
359 |
< |
p16 = (uint16 *)(p + base); |
360 |
< |
start = (uint32)q; |
361 |
< |
for (i=0; i<4; i++) *q++ = *p16++; |
362 |
< |
*q++ = htons(0x675e); // beq |
363 |
< |
p16++; |
364 |
< |
for (i=0; i<21; i++) *q++ = *p16++; |
365 |
< |
*q++ = htons(0x4a2f); // tst.b 2(sp) (null FPU state?) |
366 |
< |
*q++ = htons(2); |
367 |
< |
*q++ = htons(0x6716); // beq |
368 |
< |
*q++ = htons(0xf227); // fmovem.x fp0-fp7,-(sp) (no, save FPU registers) |
369 |
< |
*q++ = htons(0xe0ff); |
370 |
< |
*q++ = htons(0xf227); // fmove.l fpiar,-(sp) |
371 |
< |
*q++ = htons(0xa400); |
372 |
< |
*q++ = htons(0xf227); // fmove.l fpsr,-(sp) |
373 |
< |
*q++ = htons(0xa800); |
374 |
< |
*q++ = htons(0xf227); // fmove.l fpcr,-(sp) |
375 |
< |
*q++ = htons(0xb000); |
376 |
< |
*q++ = htons(0x4879); // pea -1 (push "FPU state saved" flag) |
377 |
< |
*q++ = htons(0xffff); |
378 |
< |
*q++ = htons(0xffff); |
379 |
< |
p16 += 7; |
380 |
< |
for (i=0; i<23; i++) *q++ = *p16++; |
381 |
< |
*q++ = htons(0x4a2f); // tst.b 2(sp) (null FPU state or "FPU state saved" flag set?) |
382 |
< |
*q++ = htons(2); |
383 |
< |
*q++ = htons(0x6712); // beq |
384 |
< |
*q++ = htons(0x588f); // addq.l #2,sp (flag set, skip it) |
385 |
< |
*q++ = htons(0xf21f); // fmove.l (sp)+,fpcr (restore FPU registers) |
386 |
< |
*q++ = htons(0x9000); |
387 |
< |
*q++ = htons(0xf21f); // fmove.l (sp)+,fpsr |
388 |
< |
*q++ = htons(0x8800); |
389 |
< |
*q++ = htons(0xf21f); // fmove.l (sp)+,fpiar |
390 |
< |
*q++ = htons(0x8400); |
391 |
< |
*q++ = htons(0xf21f); // fmovem.x (sp)+,fp0-fp7 |
392 |
< |
*q++ = htons(0xd0ff); |
393 |
< |
p16 += 7; |
394 |
< |
for (i=0; i<20; i++) *q++ = *p16++; |
395 |
< |
|
396 |
< |
p16 = (uint16 *)(p + base); |
397 |
< |
*p16++ = htons(M68K_JMP); |
398 |
< |
*p16++ = htons(start >> 16); |
399 |
< |
*p16 = htons(start & 0xffff); |
400 |
< |
FlushCodeCache(p + base, 6); |
401 |
< |
D(bug(" patch 5 applied\n")); |
402 |
< |
|
403 |
< |
base = find_rsrc_data(p, size - base - 2, dat4, sizeof(dat4), base + 2); |
404 |
< |
if (base) { // FPU -> no FPU |
405 |
< |
|
406 |
< |
p16 = (uint16 *)(p + base); |
407 |
< |
start = (uint32)q; |
408 |
< |
for (i=0; i<4; i++) *q++ = *p16++; |
409 |
< |
*q++ = htons(0x675e); // beq |
410 |
< |
p16++; |
411 |
< |
for (i=0; i<21; i++) *q++ = *p16++; |
412 |
< |
*q++ = htons(0x4a2f); // tst.b 2(sp) (null FPU state?) |
413 |
< |
*q++ = htons(2); |
414 |
< |
*q++ = htons(0x6716); // beq |
415 |
< |
*q++ = htons(0xf227); // fmovem.x fp0-fp7,-(sp) (no, save FPU registers) |
416 |
< |
*q++ = htons(0xe0ff); |
417 |
< |
*q++ = htons(0xf227); // fmove.l fpiar,-(sp) |
418 |
< |
*q++ = htons(0xa400); |
419 |
< |
*q++ = htons(0xf227); // fmove.l fpsr,-(sp) |
420 |
< |
*q++ = htons(0xa800); |
421 |
< |
*q++ = htons(0xf227); // fmove.l fpcr,-(sp) |
422 |
< |
*q++ = htons(0xb000); |
423 |
< |
*q++ = htons(0x4879); // pea -1 (push "FPU state saved" flag) |
424 |
< |
*q++ = htons(0xffff); |
425 |
< |
*q++ = htons(0xffff); |
426 |
< |
p16 += 7; |
427 |
< |
for (i=0; i<42; i++) *q++ = *p16++; |
428 |
< |
|
429 |
< |
p16 = (uint16 *)(p + base); |
430 |
< |
*p16++ = htons(M68K_JMP); |
431 |
< |
*p16++ = htons(start >> 16); |
432 |
< |
*p16 = htons(start & 0xffff); |
433 |
< |
FlushCodeCache(p + base, 6); |
434 |
< |
D(bug(" patch 6 applied\n")); |
435 |
< |
} |
436 |
< |
} |
437 |
< |
} |
438 |
< |
} |
439 |
< |
|
440 |
< |
FlushCodeCache(ThPatchSpace, 1024); |
441 |
< |
|
442 |
< |
// Patch Thread Manager FPU init for 68060 FPU (7.5, 8.0) |
443 |
< |
static const uint8 dat5[] = {0x4a, 0x28, 0x00, 0xa4, 0x67, 0x0a, 0x4a, 0x2c, 0x00, 0x40}; |
444 |
< |
base = find_rsrc_data(p, size, dat5, sizeof(dat5)); |
445 |
< |
if (base) { |
446 |
< |
p16 = (uint16 *)(p + base + 6); |
447 |
< |
*p16++ = htons(M68K_JSR); |
448 |
< |
*p16++ = htons((uint32)ThInitFPUPatch >> 16); |
449 |
< |
*p16++ = htons((uint32)ThInitFPUPatch & 0xffff); |
450 |
< |
*p16++ = htons(M68K_NOP); |
451 |
< |
*p16 = htons(M68K_NOP); |
452 |
< |
FlushCodeCache(p + base + 6, 10); |
453 |
< |
D(bug(" patch 7 applied\n")); |
454 |
< |
} |
455 |
< |
#endif |
456 |
< |
|
457 |
< |
} else if (type == 'gpch' && id == 750) { |
219 |
> |
} else if (type == FOURCC('g','p','c','h') && id == 750) { |
220 |
|
D(bug(" gpch 750 found\n")); |
221 |
|
|
222 |
|
// Don't use PTEST instruction in BlockMove() (7.5, 7.6, 7.6.1, 8.0) |
223 |
< |
static const uint8 dat[] = {0xa0, 0x8d, 0x0c, 0x81, 0x00, 0x00, 0x0c, 0x00, 0x65, 0x06, 0x4e, 0x71, 0xf4, 0xf8}; |
223 |
> |
static const uint8 dat[] = {0x20, 0x5f, 0x22, 0x5f, 0x0c, 0x38, 0x00, 0x04, 0x01, 0x2f}; |
224 |
|
base = find_rsrc_data(p, size, dat, sizeof(dat)); |
225 |
|
if (base) { |
226 |
< |
p16 = (uint16 *)(p + base + 8); |
227 |
< |
*p16 = htons(M68K_NOP); |
228 |
< |
FlushCodeCache(p + base + 8, 2); |
226 |
> |
p16 = (uint16 *)(p + base + 4); |
227 |
> |
*p16++ = htons(M68K_EMUL_OP_BLOCK_MOVE); |
228 |
> |
*p16++ = htons(0x7000); |
229 |
> |
*p16 = htons(M68K_RTS); |
230 |
> |
FlushCodeCache(p + base + 4, 6); |
231 |
|
D(bug(" patch 1 applied\n")); |
232 |
|
} |
233 |
|
|
234 |
< |
} else if (type == 'lpch' && id == 24) { |
234 |
> |
// Patch SynchIdleTime() |
235 |
> |
patch_idle_time(p, size, 2); |
236 |
> |
|
237 |
> |
} else if (type == FOURCC('l','p','c','h') && id == 24) { |
238 |
|
D(bug(" lpch 24 found\n")); |
239 |
|
|
240 |
|
// Don't replace Time Manager (7.0.1, 7.1, 7.5, 7.6, 7.6.1, 8.0) |
251 |
|
D(bug(" patch 1 applied\n")); |
252 |
|
} |
253 |
|
|
254 |
< |
} else if (type == 'lpch' && id == 31) { |
254 |
> |
} else if (type == FOURCC('l','p','c','h') && id == 31) { |
255 |
|
D(bug(" lpch 31 found\n")); |
256 |
|
|
257 |
|
// Don't write to VIA in vSoundDead() (7.0.1, 7.1, 7.5, 7.6, 7.6.1, 8.0) |
276 |
|
D(bug(" patch 2 applied\n")); |
277 |
|
} |
278 |
|
|
279 |
< |
#if !EMULATED_68K |
280 |
< |
} else if (CPUIs68060 && type == 'scod' && (id == -16463 || id == -16464)) { |
514 |
< |
D(bug(" scod -16463/-16464 found\n")); |
279 |
> |
// Patch SynchIdleTime() |
280 |
> |
patch_idle_time(p, size, 3); |
281 |
|
|
282 |
< |
// Correct 68060 FP frame handling in Process Manager task switches (7.1, 7.5, 8.0) |
517 |
< |
static const uint8 dat[] = {0xf3, 0x27, 0x4a, 0x17}; |
518 |
< |
base = find_rsrc_data(p, size, dat, sizeof(dat)); |
519 |
< |
if (base) { |
520 |
< |
p16 = (uint16 *)(p + base); |
521 |
< |
*p16++ = htons(M68K_JMP); |
522 |
< |
*p16++ = htons((uint32)Scod060Patch1 >> 16); |
523 |
< |
*p16 = htons((uint32)Scod060Patch1 & 0xffff); |
524 |
< |
FlushCodeCache(p + base, 6); |
525 |
< |
D(bug(" patch 1 applied\n")); |
526 |
< |
} |
527 |
< |
|
528 |
< |
// Even a null FP frame is 3 longwords on the 68060 (7.1, 7.5, 8.0) |
529 |
< |
static const uint8 dat2[] = {0xf3, 0x5f, 0x4e, 0x75}; |
530 |
< |
base = find_rsrc_data(p, size, dat2, sizeof(dat2)); |
531 |
< |
if (base) { |
532 |
< |
p16 = (uint16 *)(p + base - 2); |
533 |
< |
*p16++ = htons(M68K_JMP); |
534 |
< |
*p16++ = htons((uint32)Scod060Patch2 >> 16); |
535 |
< |
*p16 = htons((uint32)Scod060Patch2 & 0xffff); |
536 |
< |
FlushCodeCache(p + base - 2, 6); |
537 |
< |
D(bug(" patch 2 applied\n")); |
538 |
< |
} |
539 |
< |
#endif |
540 |
< |
|
541 |
< |
} else if (type == 'thng' && id == -16563) { |
282 |
> |
} else if (type == FOURCC('t','h','n','g') && id == -16563) { |
283 |
|
D(bug(" thng -16563 found\n")); |
284 |
|
|
285 |
|
// Set audio component flags (7.5, 7.6, 7.6.1, 8.0) |
286 |
|
*(uint32 *)(p + componentFlags) = htonl(audio_component_flags); |
287 |
|
D(bug(" patch 1 applied\n")); |
288 |
|
|
289 |
< |
} else if (type == 'sift' && id == -16563) { |
289 |
> |
} else if (type == FOURCC('s','i','f','t') && id == -16563) { |
290 |
|
D(bug(" sift -16563 found\n")); |
291 |
|
|
292 |
|
// Replace audio component (7.5, 7.6, 7.6.1, 8.0) |
303 |
|
FlushCodeCache(p, 32); |
304 |
|
D(bug(" patch 1 applied\n")); |
305 |
|
|
306 |
< |
} else if (type == 'inst' && id == -19069) { |
306 |
> |
} else if (type == FOURCC('i','n','s','t') && id == -19069) { |
307 |
|
D(bug(" inst -19069 found\n")); |
308 |
|
|
309 |
|
// Don't replace Microseconds (QuickTime 2.0) |
316 |
|
D(bug(" patch 1 applied\n")); |
317 |
|
} |
318 |
|
|
319 |
< |
} else if (type == 'DRVR' && id == -20066) { |
319 |
> |
} else if (type == FOURCC('D','R','V','R') && id == -20066) { |
320 |
|
D(bug("DRVR -20066 found\n")); |
321 |
|
|
322 |
|
// Don't access SCC in .Infra driver |
329 |
|
D(bug(" patch 1 applied\n")); |
330 |
|
} |
331 |
|
|
332 |
< |
} else if (type == 'ltlk' && id == 0) { |
332 |
> |
} else if (type == FOURCC('l','t','l','k') && id == 0) { |
333 |
|
D(bug(" ltlk 0 found\n")); |
334 |
|
|
335 |
|
// Disable LocalTalk (7.0.1, 7.5, 7.6, 7.6.1, 8.0) |
339 |
|
*p16 = htons(M68K_RTS); |
340 |
|
FlushCodeCache(p, 6); |
341 |
|
D(bug(" patch 1 applied\n")); |
342 |
+ |
|
343 |
+ |
} else if (type == FOURCC('D','R','V','R') && id == 41) { |
344 |
+ |
D(bug(" DRVR 41 found\n")); |
345 |
+ |
|
346 |
+ |
// Don't access ROM85 as it it was a pointer to a ROM version number (8.0, 8.1) |
347 |
+ |
static const uint8 dat[] = {0x3a, 0x2e, 0x00, 0x0a, 0x55, 0x4f, 0x3e, 0xb8, 0x02, 0x8e, 0x30, 0x1f, 0x48, 0xc0, 0x24, 0x40, 0x20, 0x40}; |
348 |
+ |
base = find_rsrc_data(p, size, dat, sizeof(dat)); |
349 |
+ |
if (base) { |
350 |
+ |
p16 = (uint16 *)(p + base + 4); |
351 |
+ |
*p16++ = htons(0x303c); // move.l #ROM85,%d0 |
352 |
+ |
*p16++ = htons(0x028e); |
353 |
+ |
*p16++ = htons(M68K_NOP); |
354 |
+ |
*p16++ = htons(M68K_NOP); |
355 |
+ |
FlushCodeCache(p + base + 4, 8); |
356 |
+ |
D(bug(" patch 1 applied\n")); |
357 |
+ |
} |
358 |
|
} |
359 |
|
} |