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.1 by cebix, 1999-10-03T14:16:25Z vs.
Revision 1.12 by cebix, 2004-01-12T15:29:22Z

# Line 1 | Line 1
1   /*
2   *  rsrc_patches.cpp - Resource patches
3   *
4 < *  Basilisk II (C) 1997-1999 Christian Bauer
4 > *  Basilisk II (C) 1997-2004 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"
29   #include "audio_defs.h"
30   #include "rsrc_patches.h"
31  
32 + #if ENABLE_MON
33 + #include "mon.h"
34 + #endif
35 +
36   #define DEBUG 0
37   #include "debug.h"
38  
39  
35 #if !EMULATED_68K
36 // Assembly functions
37 extern "C" void Scod060Patch1(void);
38 extern "C" void Scod060Patch2(void);
39 extern "C" void ThInitFPUPatch(void);
40 #endif
41
42
40   /*
41   *  Search resource for byte string, return offset (or 0)
42   */
# Line 63 | 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 79 | 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 100 | 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 125 | 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 152 | 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 166 | 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 190 | Line 189 | void CheckLoad(uint32 type, int16 id, ui
189                          D(bug("  patch 2 applied\n"));
190                  }
191  
192 < #if !EMULATED_68K
194 <        } else if (CPUIs68060 && (type == 'gpch' && id == 669 || type == 'lpch' && id == 63)) {
195 <                D(bug(" gpch 669/lpch 63 found\n"));
196 <
197 <                static uint16 ThPatchSpace[1024];       // Replacement routines are constructed here
198 <                uint16 *q = ThPatchSpace;
199 <                uint32 start;
200 <                int i;
201 <
202 <                // Patch Thread Manager thread switcher for 68060 FPU (7.5, 8.0)
203 <                static const uint8 dat[] = {0x22, 0x6f, 0x00, 0x08, 0x20, 0x2f, 0x00, 0x04, 0x67, 0x18};
204 <                base = find_rsrc_data(p, size, dat, sizeof(dat));
205 <                if (base) {     // Skip first routine (no FPU -> no FPU)
206 <
207 <                        base = find_rsrc_data(p, size - base - 2, dat, sizeof(dat), base + 2);
208 <                        if (base) {     // no FPU -> FPU
209 <
210 <                                p16 = (uint16 *)(p + base);
211 <                                start = (uint32)q;
212 <                                for (i=0; i<28; i++) *q++ = *p16++;
213 <                                *q++ = htons(0x4a2f);           // tst.b 2(sp)                          (null FPU state or "FPU state saved" flag set?)
214 <                                *q++ = htons(2);
215 <                                *q++ = htons(0x6712);           // beq
216 <                                *q++ = htons(0x588f);           // addq.l #2,sp                         (flag set, skip it)
217 <                                *q++ = htons(0xf21f);           // fmove.l (sp)+,fpcr           (restore FPU registers)
218 <                                *q++ = htons(0x9000);
219 <                                *q++ = htons(0xf21f);           // fmove.l (sp)+,fpsr
220 <                                *q++ = htons(0x8800);
221 <                                *q++ = htons(0xf21f);           // fmove.l (sp)+,fpiar
222 <                                *q++ = htons(0x8400);
223 <                                *q++ = htons(0xf21f);           // fmovem.x (sp)+,fp0-fp7
224 <                                *q++ = htons(0xd0ff);
225 <                                *q++ = htons(0xf35f);           // frestore (sp)+
226 <                                *q++ = htons(0x4e75);           // rts
227 <
228 <                                p16 = (uint16 *)(p + base);
229 <                                *p16++ = htons(M68K_JMP);
230 <                                *p16++ = htons(start >> 16);
231 <                                *p16 = htons(start & 0xffff);
232 <                                FlushCodeCache(p + base, 6);
233 <                                D(bug("  patch 1 applied\n"));
234 <
235 <                                static const uint8 dat2[] = {0x22, 0x6f, 0x00, 0x08, 0x20, 0x2f, 0x00, 0x04, 0x67, 0x28};
236 <                                base = find_rsrc_data(p, size, dat2, sizeof(dat2));
237 <                                if (base) {     // FPU -> FPU
238 <
239 <                                        p16 = (uint16 *)(p + base);
240 <                                        start = (uint32)q;
241 <                                        for (i=0; i<4; i++) *q++ = *p16++;
242 <                                        *q++ = htons(0x6736);           // beq
243 <                                        *q++ = htons(0xf327);           // fsave -(sp)                          (save FPU state frame)
244 <                                        *q++ = htons(0x4a2f);           // tst.b 2(sp)                          (null FPU state?)
245 <                                        *q++ = htons(2);
246 <                                        *q++ = htons(0x6716);           // beq
247 <                                        *q++ = htons(0xf227);           // fmovem.x fp0-fp7,-(sp)       (no, save FPU registers)
248 <                                        *q++ = htons(0xe0ff);
249 <                                        *q++ = htons(0xf227);           // fmove.l fpiar,-(sp)
250 <                                        *q++ = htons(0xa400);
251 <                                        *q++ = htons(0xf227);           // fmove.l fpsr,-(sp)
252 <                                        *q++ = htons(0xa800);
253 <                                        *q++ = htons(0xf227);           // fmove.l fpcr,-(sp)
254 <                                        *q++ = htons(0xb000);
255 <                                        *q++ = htons(0x4879);           // pea -1                                       (push "FPU state saved" flag)
256 <                                        *q++ = htons(0xffff);
257 <                                        *q++ = htons(0xffff);
258 <                                        p16 += 9;
259 <                                        for (i=0; i<23; i++) *q++ = *p16++;
260 <                                        *q++ = htons(0x4a2f);           // tst.b 2(sp)                          (null FPU state or "FPU state saved" flag set?)
261 <                                        *q++ = htons(2);
262 <                                        *q++ = htons(0x6712);           // beq
263 <                                        *q++ = htons(0x588f);           // addq.l #2,sp                         (flag set, skip it)
264 <                                        *q++ = htons(0xf21f);           // fmove.l (sp)+,fpcr           (restore FPU registers)
265 <                                        *q++ = htons(0x9000);
266 <                                        *q++ = htons(0xf21f);           // fmove.l (sp)+,fpsr
267 <                                        *q++ = htons(0x8800);
268 <                                        *q++ = htons(0xf21f);           // fmove.l (sp)+,fpiar
269 <                                        *q++ = htons(0x8400);
270 <                                        *q++ = htons(0xf21f);           // fmovem.x (sp)+,fp0-fp7
271 <                                        *q++ = htons(0xd0ff);
272 <                                        *q++ = htons(0xf35f);           // frestore (sp)+
273 <                                        *q++ = htons(0x4e75);           // rts
274 <
275 <                                        p16 = (uint16 *)(p + base);
276 <                                        *p16++ = htons(M68K_JMP);
277 <                                        *p16++ = htons(start >> 16);
278 <                                        *p16 = htons(start & 0xffff);
279 <                                        FlushCodeCache(p + base, 6);
280 <                                        D(bug("  patch 2 applied\n"));
281 <
282 <                                        base = find_rsrc_data(p, size - base - 2, dat2, sizeof(dat2), base + 2);
283 <                                        if (base) {     // FPU -> no FPU
284 <        
285 <                                                p16 = (uint16 *)(p + base);
286 <                                                start = (uint32)q;
287 <                                                for (i=0; i<4; i++) *q++ = *p16++;
288 <                                                *q++ = htons(0x6736);           // beq
289 <                                                *q++ = htons(0xf327);           // fsave -(sp)                          (save FPU state frame)
290 <                                                *q++ = htons(0x4a2f);           // tst.b 2(sp)                          (null FPU state?)
291 <                                                *q++ = htons(2);
292 <                                                *q++ = htons(0x6716);           // beq
293 <                                                *q++ = htons(0xf227);           // fmovem.x fp0-fp7,-(sp)       (no, save FPU registers)
294 <                                                *q++ = htons(0xe0ff);
295 <                                                *q++ = htons(0xf227);           // fmove.l fpiar,-(sp)
296 <                                                *q++ = htons(0xa400);
297 <                                                *q++ = htons(0xf227);           // fmove.l fpsr,-(sp)
298 <                                                *q++ = htons(0xa800);
299 <                                                *q++ = htons(0xf227);           // fmove.l fpcr,-(sp)
300 <                                                *q++ = htons(0xb000);
301 <                                                *q++ = htons(0x4879);           // pea -1                                       (push "FPU state saved" flag)
302 <                                                *q++ = htons(0xffff);
303 <                                                *q++ = htons(0xffff);
304 <                                                p16 += 9;
305 <                                                for (i=0; i<24; i++) *q++ = *p16++;
306 <
307 <                                                p16 = (uint16 *)(p + base);
308 <                                                *p16++ = htons(M68K_JMP);
309 <                                                *p16++ = htons(start >> 16);
310 <                                                *p16 = htons(start & 0xffff);
311 <                                                FlushCodeCache(p + base, 6);
312 <                                                D(bug("  patch 3 applied\n"));
313 <                                        }
314 <                                }
315 <                        }
316 <                }
317 <
318 <                // Patch Thread Manager thread switcher for 68060 FPU (additional routines under 8.0 for Mixed Mode Manager)
319 <                static const uint8 dat3[] = {0x22, 0x6f, 0x00, 0x08, 0x20, 0x2f, 0x00, 0x04, 0x67, 0x40};
320 <                base = find_rsrc_data(p, size, dat3, sizeof(dat3));
321 <                if (base) {     // Skip first routine (no FPU -> no FPU)
322 <
323 <                        base = find_rsrc_data(p, size - base - 2, dat3, sizeof(dat3), base + 2);
324 <                        if (base) {     // no FPU -> FPU
325 <
326 <                                p16 = (uint16 *)(p + base);
327 <                                start = (uint32)q;
328 <                                for (i=0; i<48; i++) *q++ = *p16++;
329 <                                *q++ = htons(0x4a2f);           // tst.b 2(sp)                          (null FPU state or "FPU state saved" flag set?)
330 <                                *q++ = htons(2);
331 <                                *q++ = htons(0x6712);           // beq
332 <                                *q++ = htons(0x588f);           // addq.l #2,sp                         (flag set, skip it)
333 <                                *q++ = htons(0xf21f);           // fmove.l (sp)+,fpcr           (restore FPU registers)
334 <                                *q++ = htons(0x9000);
335 <                                *q++ = htons(0xf21f);           // fmove.l (sp)+,fpsr
336 <                                *q++ = htons(0x8800);
337 <                                *q++ = htons(0xf21f);           // fmove.l (sp)+,fpiar
338 <                                *q++ = htons(0x8400);
339 <                                *q++ = htons(0xf21f);           // fmovem.x (sp)+,fp0-fp7
340 <                                *q++ = htons(0xd0ff);
341 <                                p16 += 7;
342 <                                for (i=0; i<20; i++) *q++ = *p16++;
343 <
344 <                                p16 = (uint16 *)(p + base);
345 <                                *p16++ = htons(M68K_JMP);
346 <                                *p16++ = htons(start >> 16);
347 <                                *p16 = htons(start & 0xffff);
348 <                                FlushCodeCache(p + base, 6);
349 <                                D(bug("  patch 4 applied\n"));
350 <
351 <                                static const uint8 dat4[] = {0x22, 0x6f, 0x00, 0x08, 0x20, 0x2f, 0x00, 0x04, 0x67, 0x50};
352 <                                base = find_rsrc_data(p, size, dat4, sizeof(dat4));
353 <                                if (base) {     // FPU -> FPU
354 <
355 <                                        p16 = (uint16 *)(p + base);
356 <                                        start = (uint32)q;
357 <                                        for (i=0; i<4; i++) *q++ = *p16++;
358 <                                        *q++ = htons(0x675e);           // beq
359 <                                        p16++;
360 <                                        for (i=0; i<21; i++) *q++ = *p16++;
361 <                                        *q++ = htons(0x4a2f);           // tst.b 2(sp)                          (null FPU state?)
362 <                                        *q++ = htons(2);
363 <                                        *q++ = htons(0x6716);           // beq
364 <                                        *q++ = htons(0xf227);           // fmovem.x fp0-fp7,-(sp)       (no, save FPU registers)
365 <                                        *q++ = htons(0xe0ff);
366 <                                        *q++ = htons(0xf227);           // fmove.l fpiar,-(sp)
367 <                                        *q++ = htons(0xa400);
368 <                                        *q++ = htons(0xf227);           // fmove.l fpsr,-(sp)
369 <                                        *q++ = htons(0xa800);
370 <                                        *q++ = htons(0xf227);           // fmove.l fpcr,-(sp)
371 <                                        *q++ = htons(0xb000);
372 <                                        *q++ = htons(0x4879);           // pea -1                                       (push "FPU state saved" flag)
373 <                                        *q++ = htons(0xffff);
374 <                                        *q++ = htons(0xffff);
375 <                                        p16 += 7;
376 <                                        for (i=0; i<23; i++) *q++ = *p16++;
377 <                                        *q++ = htons(0x4a2f);           // tst.b 2(sp)                          (null FPU state or "FPU state saved" flag set?)
378 <                                        *q++ = htons(2);
379 <                                        *q++ = htons(0x6712);           // beq
380 <                                        *q++ = htons(0x588f);           // addq.l #2,sp                         (flag set, skip it)
381 <                                        *q++ = htons(0xf21f);           // fmove.l (sp)+,fpcr           (restore FPU registers)
382 <                                        *q++ = htons(0x9000);
383 <                                        *q++ = htons(0xf21f);           // fmove.l (sp)+,fpsr
384 <                                        *q++ = htons(0x8800);
385 <                                        *q++ = htons(0xf21f);           // fmove.l (sp)+,fpiar
386 <                                        *q++ = htons(0x8400);
387 <                                        *q++ = htons(0xf21f);           // fmovem.x (sp)+,fp0-fp7
388 <                                        *q++ = htons(0xd0ff);
389 <                                        p16 += 7;
390 <                                        for (i=0; i<20; i++) *q++ = *p16++;
391 <
392 <                                        p16 = (uint16 *)(p + base);
393 <                                        *p16++ = htons(M68K_JMP);
394 <                                        *p16++ = htons(start >> 16);
395 <                                        *p16 = htons(start & 0xffff);
396 <                                        FlushCodeCache(p + base, 6);
397 <                                        D(bug("  patch 5 applied\n"));
398 <
399 <                                        base = find_rsrc_data(p, size - base - 2, dat4, sizeof(dat4), base + 2);
400 <                                        if (base) {     // FPU -> no FPU
401 <
402 <                                                p16 = (uint16 *)(p + base);
403 <                                                start = (uint32)q;
404 <                                                for (i=0; i<4; i++) *q++ = *p16++;
405 <                                                *q++ = htons(0x675e);           // beq
406 <                                                p16++;
407 <                                                for (i=0; i<21; i++) *q++ = *p16++;
408 <                                                *q++ = htons(0x4a2f);           // tst.b 2(sp)                          (null FPU state?)
409 <                                                *q++ = htons(2);
410 <                                                *q++ = htons(0x6716);           // beq
411 <                                                *q++ = htons(0xf227);           // fmovem.x fp0-fp7,-(sp)       (no, save FPU registers)
412 <                                                *q++ = htons(0xe0ff);
413 <                                                *q++ = htons(0xf227);           // fmove.l fpiar,-(sp)
414 <                                                *q++ = htons(0xa400);
415 <                                                *q++ = htons(0xf227);           // fmove.l fpsr,-(sp)
416 <                                                *q++ = htons(0xa800);
417 <                                                *q++ = htons(0xf227);           // fmove.l fpcr,-(sp)
418 <                                                *q++ = htons(0xb000);
419 <                                                *q++ = htons(0x4879);           // pea -1                                       (push "FPU state saved" flag)
420 <                                                *q++ = htons(0xffff);
421 <                                                *q++ = htons(0xffff);
422 <                                                p16 += 7;
423 <                                                for (i=0; i<42; i++) *q++ = *p16++;
424 <
425 <                                                p16 = (uint16 *)(p + base);
426 <                                                *p16++ = htons(M68K_JMP);
427 <                                                *p16++ = htons(start >> 16);
428 <                                                *p16 = htons(start & 0xffff);
429 <                                                FlushCodeCache(p + base, 6);
430 <                                                D(bug("  patch 6 applied\n"));
431 <                                        }
432 <                                }
433 <                        }
434 <                }
435 <
436 <                FlushCodeCache(ThPatchSpace, 1024);
437 <
438 <                // Patch Thread Manager FPU init for 68060 FPU (7.5, 8.0)
439 <                static const uint8 dat5[] = {0x4a, 0x28, 0x00, 0xa4, 0x67, 0x0a, 0x4a, 0x2c, 0x00, 0x40};
440 <                base = find_rsrc_data(p, size, dat5, sizeof(dat5));
441 <                if (base) {
442 <                        p16 = (uint16 *)(p + base + 6);
443 <                        *p16++ = htons(M68K_JSR);
444 <                        *p16++ = htons((uint32)ThInitFPUPatch >> 16);
445 <                        *p16++ = htons((uint32)ThInitFPUPatch & 0xffff);
446 <                        *p16++ = htons(M68K_NOP);
447 <                        *p16 = htons(M68K_NOP);
448 <                        FlushCodeCache(p + base + 6, 10);
449 <                        D(bug("  patch 7 applied\n"));
450 <                }
451 < #endif
452 <
453 <        } 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 480 | 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 505 | Line 246 | void CheckLoad(uint32 type, int16 id, ui
246                          D(bug("  patch 2 applied\n"));
247                  }
248  
249 < #if !EMULATED_68K
509 <        } else if (CPUIs68060 && type == 'scod' && (id == -16463 || id == -16464)) {
510 <                D(bug(" scod -16463/-16464 found\n"));
511 <
512 <                // Correct 68060 FP frame handling in Process Manager task switches (7.1, 7.5, 8.0)
513 <                static const uint8 dat[] = {0xf3, 0x27, 0x4a, 0x17};
514 <                base = find_rsrc_data(p, size, dat, sizeof(dat));
515 <                if (base) {
516 <                        p16 = (uint16 *)(p + base);
517 <                        *p16++ = htons(M68K_JMP);
518 <                        *p16++ = htons((uint32)Scod060Patch1 >> 16);
519 <                        *p16 = htons((uint32)Scod060Patch1 & 0xffff);
520 <                        FlushCodeCache(p + base, 6);
521 <                        D(bug("  patch 1 applied\n"));
522 <                }
523 <
524 <                // Even a null FP frame is 3 longwords on the 68060 (7.1, 7.5, 8.0)
525 <                static const uint8 dat2[] = {0xf3, 0x5f, 0x4e, 0x75};
526 <                base = find_rsrc_data(p, size, dat2, sizeof(dat2));
527 <                if (base) {
528 <                        p16 = (uint16 *)(p + base - 2);
529 <                        *p16++ = htons(M68K_JMP);
530 <                        *p16++ = htons((uint32)Scod060Patch2 >> 16);
531 <                        *p16 = htons((uint32)Scod060Patch2 & 0xffff);
532 <                        FlushCodeCache(p + base - 2, 6);
533 <                        D(bug("  patch 2 applied\n"));
534 <                }
535 < #endif
536 <
537 <        } 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 558 | 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 571 | 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 584 | 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 595 | Line 307 | void CheckLoad(uint32 type, int16 id, ui
307                  FlushCodeCache(p, 6);
308                  D(bug("  patch 1 applied\n"));
309          }
310 + #if REAL_ADDRESSING && !defined(AMIGA)
311 +        else if (type == FOURCC('D','R','V','R') && id == 41) {
312 +                D(bug(" DRVR 41 found\n"));
313 +                
314 +                // gb-- [0x28E (ROM85)] contains 0x3fff that will be placed into a0
315 +                // Seems to be caused by the AppleShare extension from MacOS 8.1 (3.7.4)
316 +                // .AFPTranslator (DRVR addr 0x2372)
317 +                static const uint8 dat[] = {0x3a, 0x2e, 0x00, 0x0a, 0x55, 0x4f, 0x3e, 0xb8, 0x02, 0x8e, 0x30, 0x1f, 0x48, 0xc0, 0x24, 0x40, 0x20, 0x40};
318 +                base = find_rsrc_data(p, size, dat, sizeof(dat));
319 +                if (base) {
320 +                        p16 = (uint16 *)(p + base + 4);
321 +                        *p16++ = htons(0x3078);         // movea.w      ROM85,%a0
322 +                        *p16++ = htons(0x028e);
323 +                        *p16++ = htons(0xd1fc);         // adda.l       #RAMBaseMac,%a0
324 +                        *p16++ = htons((RAMBaseMac >> 16) & 0xffff);
325 +                        *p16++ = htons(RAMBaseMac & 0xffff);
326 +                        *p16++ = htons(0x2448);         // movea.l      %a0,%a2
327 +                        *p16++ = htons(M68K_NOP);
328 +                        FlushCodeCache(p + base + 4, 14);
329 +                        D(bug("  patch 1 applied\n"));
330 +                }
331 +        }
332 + #endif
333   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines