ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/rsrc_patches.cpp
(Generate patch)

Comparing BasiliskII/src/rsrc_patches.cpp (file contents):
Revision 1.3 by cebix, 2000-04-10T18:52:28Z vs.
Revision 1.14 by gbeauche, 2006-02-19T14:18:29Z

# Line 1 | Line 1
1   /*
2   *  rsrc_patches.cpp - Resource patches
3   *
4 < *  Basilisk II (C) 1997-2000 Christian Bauer
4 > *  Basilisk II (C) 1997-2005 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
# Line 22 | Line 22
22  
23   #include "sysdeps.h"
24   #include "cpu_emulation.h"
25 + #include "macos_util.h"
26   #include "main.h"
27   #include "emul_op.h"
28   #include "audio.h"
# Line 36 | Line 37
37   #include "debug.h"
38  
39  
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
40   /*
41   *  Search resource for byte string, return offset (or 0)
42   */
# Line 67 | Line 60 | void CheckLoad(uint32 type, int16 id, ui
60   {
61          uint16 *p16;
62          uint32 base;
63 <        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));
64 <
65 <        if (type == 'boot' && id == 3) {
63 >        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));
64 >        
65 >        if (type == FOURCC('b','o','o','t') && id == 3) {
66                  D(bug(" boot 3 found\n"));
67  
68                  // Set boot stack pointer (7.5, 7.6, 7.6.1, 8.0)
# Line 83 | Line 76 | void CheckLoad(uint32 type, int16 id, ui
76                  }
77  
78   #if !ROM_IS_WRITE_PROTECTED
79 <                // Set fake handle at 0x0000 to some safe place (so broken Mac programs won't write into Mac ROM) (7.5, 8.0)
79 >                // 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)
80                  static const uint8 dat2[] = {0x20, 0x78, 0x02, 0xae, 0xd1, 0xfc, 0x00, 0x01, 0x00, 0x00, 0x21, 0xc8, 0x00, 0x00};
81                  base = find_rsrc_data(p, size, dat2, sizeof(dat2));
82                  if (base) {
83                          p16 = (uint16 *)(p + base);
84  
85 < #if defined(AMIGA)
85 > #if defined(USE_SCRATCHMEM_SUBTERFUGE)
86                          // Set 0x0000 to scratch memory area
87 <                        extern uint32 ScratchMem;
87 >                        extern uint8 *ScratchMem;
88 >                        const uint32 ScratchMemBase = Host2MacAddr(ScratchMem);
89                          *p16++ = htons(0x207c);                 // move.l       #ScratchMem,a0
90 <                        *p16++ = htons(ScratchMem >> 16);
91 <                        *p16++ = htons(ScratchMem);
90 >                        *p16++ = htons(ScratchMemBase >> 16);
91 >                        *p16++ = htons(ScratchMemBase);
92                          *p16++ = htons(M68K_NOP);
93                          *p16 = htons(M68K_NOP);
94   #else
# Line 104 | Line 98 | void CheckLoad(uint32 type, int16 id, ui
98                          D(bug("  patch 2 applied\n"));
99                  }
100  
101 <        } else if (type == 'boot' && id == 2) {
101 >        } else if (type == FOURCC('b','o','o','t') && id == 2) {
102                  D(bug(" boot 2 found\n"));
103  
104 <                // Set fake handle at 0x0000 to some safe place (so broken Mac programs won't write into Mac ROM) (7.5, 8.0)
104 >                // 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)
105                  static const uint8 dat[] = {0x20, 0x78, 0x02, 0xae, 0xd1, 0xfc, 0x00, 0x01, 0x00, 0x00, 0x21, 0xc8, 0x00, 0x00};
106                  base = find_rsrc_data(p, size, dat, sizeof(dat));
107                  if (base) {
108                          p16 = (uint16 *)(p + base);
109  
110 < #if defined(AMIGA)
110 > #if defined(USE_SCRATCHMEM_SUBTERFUGE)
111                          // Set 0x0000 to scratch memory area
112 <                        extern uint32 ScratchMem;
112 >                        extern uint8 *ScratchMem;
113 >                        const uint32 ScratchMemBase = Host2MacAddr(ScratchMem);
114                          *p16++ = htons(0x207c);                 // move.l       #ScratchMem,a0
115 <                        *p16++ = htons(ScratchMem >> 16);
116 <                        *p16++ = htons(ScratchMem);
115 >                        *p16++ = htons(ScratchMemBase >> 16);
116 >                        *p16++ = htons(ScratchMemBase);
117                          *p16++ = htons(M68K_NOP);
118                          *p16 = htons(M68K_NOP);
119   #else
# Line 129 | Line 124 | void CheckLoad(uint32 type, int16 id, ui
124                  }
125   #endif
126  
127 <        } else if (type == 'PTCH' && id == 630) {
127 >        } else if (type == FOURCC('P','T','C','H') && id == 630) {
128                  D(bug("PTCH 630 found\n"));
129  
130                  // Don't replace Time Manager (Classic ROM, 6.0.3)
# Line 156 | Line 151 | void CheckLoad(uint32 type, int16 id, ui
151                          D(bug("  patch 1 applied\n"));
152                  }
153  
154 <        } else if (type == 'ptch' && id == 26) {
154 >        } else if (type == FOURCC('p','t','c','h') && id == 26) {
155                  D(bug(" ptch 26 found\n"));
156  
157 <                // Trap ABC4 is initialized with absolute ROM address (7.5, 7.6, 7.6.1, 8.0)
157 >                // Trap ABC4 is initialized with absolute ROM address (7.1, 7.5, 7.6, 7.6.1, 8.0)
158                  static const uint8 dat[] = {0x40, 0x83, 0x36, 0x10};
159                  base = find_rsrc_data(p, size, dat, sizeof(dat));
160                  if (base) {
# Line 170 | Line 165 | void CheckLoad(uint32 type, int16 id, ui
165                          D(bug("  patch 1 applied\n"));
166                  }
167  
168 <        } else if (type == 'ptch' && id == 34) {
168 >        } else if (type == FOURCC('p','t','c','h') && id == 34) {
169                  D(bug(" ptch 34 found\n"));
170  
171                  // Don't wait for VIA (Classic ROM, 6.0.8)
# Line 194 | Line 189 | void CheckLoad(uint32 type, int16 id, ui
189                          D(bug("  patch 2 applied\n"));
190                  }
191  
192 < #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) {
192 >        } else if (type == FOURCC('g','p','c','h') && id == 750) {
193                  D(bug(" gpch 750 found\n"));
194  
195                  // Don't use PTEST instruction in BlockMove() (7.5, 7.6, 7.6.1, 8.0)
196 <                static const uint8 dat[] = {0xa0, 0x8d, 0x0c, 0x81, 0x00, 0x00, 0x0c, 0x00, 0x65, 0x06, 0x4e, 0x71, 0xf4, 0xf8};
196 >                static const uint8 dat[] = {0x20, 0x5f, 0x22, 0x5f, 0x0c, 0x38, 0x00, 0x04, 0x01, 0x2f};
197                  base = find_rsrc_data(p, size, dat, sizeof(dat));
198                  if (base) {
199 <                        p16 = (uint16 *)(p + base + 8);
200 <                        *p16 = htons(M68K_NOP);
201 <                        FlushCodeCache(p + base + 8, 2);
199 >                        p16 = (uint16 *)(p + base + 4);
200 >                        *p16++ = htons(M68K_EMUL_OP_BLOCK_MOVE);
201 >                        *p16++ = htons(0x7000);
202 >                        *p16 = htons(M68K_RTS);
203 >                        FlushCodeCache(p + base + 4, 6);
204                          D(bug("  patch 1 applied\n"));
205                  }
206  
207 <        } else if (type == 'lpch' && id == 24) {
207 >        } else if (type == FOURCC('l','p','c','h') && id == 24) {
208                  D(bug(" lpch 24 found\n"));
209  
210                  // Don't replace Time Manager (7.0.1, 7.1, 7.5, 7.6, 7.6.1, 8.0)
# Line 484 | Line 221 | void CheckLoad(uint32 type, int16 id, ui
221                          D(bug("  patch 1 applied\n"));
222                  }
223  
224 <        } else if (type == 'lpch' && id == 31) {
224 >        } else if (type == FOURCC('l','p','c','h') && id == 31) {
225                  D(bug(" lpch 31 found\n"));
226  
227                  // Don't write to VIA in vSoundDead() (7.0.1, 7.1, 7.5, 7.6, 7.6.1, 8.0)
# Line 509 | Line 246 | void CheckLoad(uint32 type, int16 id, ui
246                          D(bug("  patch 2 applied\n"));
247                  }
248  
249 < #if !EMULATED_68K
513 <        } else if (CPUIs68060 && type == 'scod' && (id == -16463 || id == -16464)) {
514 <                D(bug(" scod -16463/-16464 found\n"));
515 <
516 <                // 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) {
249 >        } else if (type == FOURCC('t','h','n','g') && id == -16563) {
250                  D(bug(" thng -16563 found\n"));
251  
252                  // Set audio component flags (7.5, 7.6, 7.6.1, 8.0)
253                  *(uint32 *)(p + componentFlags) = htonl(audio_component_flags);
254                  D(bug("  patch 1 applied\n"));
255  
256 <        } else if (type == 'sift' && id == -16563) {
256 >        } else if (type == FOURCC('s','i','f','t') && id == -16563) {
257                  D(bug(" sift -16563 found\n"));
258  
259                  // Replace audio component (7.5, 7.6, 7.6.1, 8.0)
# Line 562 | Line 270 | void CheckLoad(uint32 type, int16 id, ui
270                  FlushCodeCache(p, 32);
271                  D(bug("  patch 1 applied\n"));
272  
273 <        } else if (type == 'inst' && id == -19069) {
273 >        } else if (type == FOURCC('i','n','s','t') && id == -19069) {
274                  D(bug(" inst -19069 found\n"));
275  
276                  // Don't replace Microseconds (QuickTime 2.0)
# Line 575 | Line 283 | void CheckLoad(uint32 type, int16 id, ui
283                          D(bug("  patch 1 applied\n"));
284                  }
285  
286 <        } else if (type == 'DRVR' && id == -20066) {
286 >        } else if (type == FOURCC('D','R','V','R') && id == -20066) {
287                  D(bug("DRVR -20066 found\n"));
288  
289                  // Don't access SCC in .Infra driver
# Line 588 | Line 296 | void CheckLoad(uint32 type, int16 id, ui
296                          D(bug("  patch 1 applied\n"));
297                  }
298  
299 <        } else if (type == 'ltlk' && id == 0) {
299 >        } else if (type == FOURCC('l','t','l','k') && id == 0) {
300                  D(bug(" ltlk 0 found\n"));
301  
302                  // Disable LocalTalk (7.0.1, 7.5, 7.6, 7.6.1, 8.0)
# Line 598 | Line 306 | void CheckLoad(uint32 type, int16 id, ui
306                  *p16 = htons(M68K_RTS);
307                  FlushCodeCache(p, 6);
308                  D(bug("  patch 1 applied\n"));
309 +
310 +        } else if (type == FOURCC('D','R','V','R') && id == 41) {
311 +                D(bug(" DRVR 41 found\n"));
312 +                
313 +                // Don't access ROM85 as it it was a pointer to a ROM version number (8.0, 8.1)
314 +                static const uint8 dat[] = {0x3a, 0x2e, 0x00, 0x0a, 0x55, 0x4f, 0x3e, 0xb8, 0x02, 0x8e, 0x30, 0x1f, 0x48, 0xc0, 0x24, 0x40, 0x20, 0x40};
315 +                base = find_rsrc_data(p, size, dat, sizeof(dat));
316 +                if (base) {
317 +                        p16 = (uint16 *)(p + base + 4);
318 +                        *p16++ = htons(0x303c);         // move.l       #ROM85,%d0
319 +                        *p16++ = htons(0x028e);
320 +                        *p16++ = htons(M68K_NOP);
321 +                        *p16++ = htons(M68K_NOP);
322 +                        FlushCodeCache(p + base + 4, 8);
323 +                        D(bug("  patch 1 applied\n"));
324 +                }
325          }
326   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines