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.1.1 by cebix, 1999-10-03T14:16:25Z vs.
Revision 1.16 by gbeauche, 2008-01-01T09:40:31Z

# 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-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
# 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 "prefs.h"
28   #include "emul_op.h"
29   #include "audio.h"
30   #include "audio_defs.h"
31   #include "rsrc_patches.h"
32  
33 + #if ENABLE_MON
34 + #include "mon.h"
35 + #endif
36 +
37   #define DEBUG 0
38   #include "debug.h"
39  
40  
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
41   /*
42   *  Search resource for byte string, return offset (or 0)
43   */
# Line 56 | Line 54 | static uint32 find_rsrc_data(const uint8
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  
# Line 63 | Line 87 | void CheckLoad(uint32 type, int16 id, ui
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)
# Line 79 | Line 103 | void CheckLoad(uint32 type, int16 id, ui
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)
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
# Line 100 | Line 125 | void CheckLoad(uint32 type, int16 id, ui
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)
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
# Line 125 | Line 151 | void CheckLoad(uint32 type, int16 id, ui
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)
# Line 152 | Line 178 | void CheckLoad(uint32 type, int16 id, ui
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) {
# Line 166 | Line 192 | void CheckLoad(uint32 type, int16 id, ui
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)
# Line 190 | Line 216 | void CheckLoad(uint32 type, int16 id, ui
216                          D(bug("  patch 2 applied\n"));
217                  }
218  
219 < #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) {
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)
# Line 480 | Line 251 | void CheckLoad(uint32 type, int16 id, ui
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)
# Line 505 | Line 276 | void CheckLoad(uint32 type, int16 id, ui
276                          D(bug("  patch 2 applied\n"));
277                  }
278  
279 < #if !EMULATED_68K
280 <        } 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
279 >                // Patch SynchIdleTime()
280 >                patch_idle_time(p, size, 3);
281  
282 <        } 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)
# Line 558 | Line 303 | void CheckLoad(uint32 type, int16 id, ui
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)
# Line 571 | Line 316 | void CheckLoad(uint32 type, int16 id, ui
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
# Line 584 | Line 329 | void CheckLoad(uint32 type, int16 id, ui
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)
# Line 594 | Line 339 | void CheckLoad(uint32 type, int16 id, ui
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   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines