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.9 by cebix, 2001-06-30T12:58:06Z vs.
Revision 1.15 by gbeauche, 2006-04-30T21:16:48Z

# Line 1 | Line 1
1   /*
2   *  rsrc_patches.cpp - Resource patches
3   *
4 < *  Basilisk II (C) 1997-2001 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 24 | Line 24
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"
# Line 53 | 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 60 | Line 87 | void CheckLoad(uint32 type, int16 id, ui
87   {
88          uint16 *p16;
89          uint32 base;
90 <        D(bug("vCheckLoad %c%c%c%c (%08x) ID %d, data %08x, size %d\n", (char)(type >> 24), (char)((type >> 16) & 0xff), (char )((type >> 8) & 0xff), (char )(type & 0xff), type, id, p, size));
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"));
# Line 76 | 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) {
# Line 101 | Line 128 | void CheckLoad(uint32 type, int16 id, ui
128          } else if (type == FOURCC('b','o','o','t') && id == 2) {
129                  D(bug(" boot 2 found\n"));
130  
131 <                // Set fake handle at 0x0000 to some safe place (so broken Mac programs won't write into Mac ROM) (7.5, 8.0)
131 >                // Set fake handle at 0x0000 to some safe place (so broken Mac programs won't write into Mac ROM) (7.1, 7.5, 8.0)
132                  static const uint8 dat[] = {0x20, 0x78, 0x02, 0xae, 0xd1, 0xfc, 0x00, 0x01, 0x00, 0x00, 0x21, 0xc8, 0x00, 0x00};
133                  base = find_rsrc_data(p, size, dat, sizeof(dat));
134                  if (base) {
135                          p16 = (uint16 *)(p + base);
136  
137 < #if defined(AMIGA) || defined(__NetBSD__) || defined(USE_SCRATCHMEM_SUBTERFUGE)
137 > #if defined(USE_SCRATCHMEM_SUBTERFUGE)
138                          // Set 0x0000 to scratch memory area
139                          extern uint8 *ScratchMem;
140                          const uint32 ScratchMemBase = Host2MacAddr(ScratchMem);
# Line 154 | Line 181 | void CheckLoad(uint32 type, int16 id, ui
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 204 | Line 231 | void CheckLoad(uint32 type, int16 id, ui
231                          D(bug("  patch 1 applied\n"));
232                  }
233  
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  
# Line 246 | Line 276 | void CheckLoad(uint32 type, int16 id, ui
276                          D(bug("  patch 2 applied\n"));
277                  }
278  
279 +                // Patch SynchIdleTime()
280 +                patch_idle_time(p, size, 3);
281 +
282          } else if (type == FOURCC('t','h','n','g') && id == -16563) {
283                  D(bug(" thng -16563 found\n"));
284  
# Line 306 | 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 < #if REAL_ADDRESSING && !defined(AMIGA)
311 <        else if (type == FOURCC('D','R','V','R') && id == 41) {
342 >
343 >        } else if (type == FOURCC('D','R','V','R') && id == 41) {
344                  D(bug(" DRVR 41 found\n"));
345                  
346 <                // 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)
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(0x3078);         // movea.w      ROM85,%a0
351 >                        *p16++ = htons(0x303c);         // move.l       #ROM85,%d0
352                          *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
353                          *p16++ = htons(M68K_NOP);
354 <                        FlushCodeCache(p + base + 4, 14);
354 >                        *p16++ = htons(M68K_NOP);
355 >                        FlushCodeCache(p + base + 4, 8);
356                          D(bug("  patch 1 applied\n"));
357                  }
358          }
332 #endif
359   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines