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.7 by cebix, 2000-10-09T17:45:58Z

# 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-2000 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  
# Line 63 | Line 68 | void CheckLoad(uint32 type, int16 id, ui
68   {
69          uint16 *p16;
70          uint32 base;
71 <        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));
72 <
73 <        if (type == 'boot' && id == 3) {
71 >        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));
72 >        
73 >        if (type == FOURCC('b','o','o','t') && id == 3) {
74                  D(bug(" boot 3 found\n"));
75  
76                  // Set boot stack pointer (7.5, 7.6, 7.6.1, 8.0)
# Line 85 | Line 90 | void CheckLoad(uint32 type, int16 id, ui
90                  if (base) {
91                          p16 = (uint16 *)(p + base);
92  
93 < #if defined(AMIGA)
93 > #if defined(AMIGA) || defined(__NetBSD__) || defined(USE_SCRATCHMEM_SUBTERFUGE)
94                          // Set 0x0000 to scratch memory area
95 <                        extern uint32 ScratchMem;
95 >                        extern uint8 *ScratchMem;
96 >                        const uint32 ScratchMemBase = Host2MacAddr(ScratchMem);
97                          *p16++ = htons(0x207c);                 // move.l       #ScratchMem,a0
98 <                        *p16++ = htons(ScratchMem >> 16);
99 <                        *p16++ = htons(ScratchMem);
98 >                        *p16++ = htons(ScratchMemBase >> 16);
99 >                        *p16++ = htons(ScratchMemBase);
100                          *p16++ = htons(M68K_NOP);
101                          *p16 = htons(M68K_NOP);
102   #else
# Line 100 | Line 106 | void CheckLoad(uint32 type, int16 id, ui
106                          D(bug("  patch 2 applied\n"));
107                  }
108  
109 <        } else if (type == 'boot' && id == 2) {
109 >        } else if (type == FOURCC('b','o','o','t') && id == 2) {
110                  D(bug(" boot 2 found\n"));
111  
112                  // Set fake handle at 0x0000 to some safe place (so broken Mac programs won't write into Mac ROM) (7.5, 8.0)
# Line 109 | Line 115 | void CheckLoad(uint32 type, int16 id, ui
115                  if (base) {
116                          p16 = (uint16 *)(p + base);
117  
118 < #if defined(AMIGA)
118 > #if defined(AMIGA) || defined(__NetBSD__) || defined(USE_SCRATCHMEM_SUBTERFUGE)
119                          // Set 0x0000 to scratch memory area
120 <                        extern uint32 ScratchMem;
120 >                        extern uint8 *ScratchMem;
121 >                        const uint32 ScratchMemBase = Host2MacAddr(ScratchMem);
122                          *p16++ = htons(0x207c);                 // move.l       #ScratchMem,a0
123 <                        *p16++ = htons(ScratchMem >> 16);
124 <                        *p16++ = htons(ScratchMem);
123 >                        *p16++ = htons(ScratchMemBase >> 16);
124 >                        *p16++ = htons(ScratchMemBase);
125                          *p16++ = htons(M68K_NOP);
126                          *p16 = htons(M68K_NOP);
127   #else
# Line 125 | Line 132 | void CheckLoad(uint32 type, int16 id, ui
132                  }
133   #endif
134  
135 <        } else if (type == 'PTCH' && id == 630) {
135 >        } else if (type == FOURCC('P','T','C','H') && id == 630) {
136                  D(bug("PTCH 630 found\n"));
137  
138                  // Don't replace Time Manager (Classic ROM, 6.0.3)
# Line 152 | Line 159 | void CheckLoad(uint32 type, int16 id, ui
159                          D(bug("  patch 1 applied\n"));
160                  }
161  
162 <        } else if (type == 'ptch' && id == 26) {
162 >        } else if (type == FOURCC('p','t','c','h') && id == 26) {
163                  D(bug(" ptch 26 found\n"));
164  
165                  // Trap ABC4 is initialized with absolute ROM address (7.5, 7.6, 7.6.1, 8.0)
# Line 166 | Line 173 | void CheckLoad(uint32 type, int16 id, ui
173                          D(bug("  patch 1 applied\n"));
174                  }
175  
176 <        } else if (type == 'ptch' && id == 34) {
176 >        } else if (type == FOURCC('p','t','c','h') && id == 34) {
177                  D(bug(" ptch 34 found\n"));
178  
179                  // Don't wait for VIA (Classic ROM, 6.0.8)
# Line 191 | Line 198 | void CheckLoad(uint32 type, int16 id, ui
198                  }
199  
200   #if !EMULATED_68K
201 <        } else if (CPUIs68060 && (type == 'gpch' && id == 669 || type == 'lpch' && id == 63)) {
201 >        } else if (CPUIs68060 && (type == FOURCC('g','p','c','h') && id == 669 || type == FOURCC('l','p','c','h') && id == 63)) {
202                  D(bug(" gpch 669/lpch 63 found\n"));
203  
204                  static uint16 ThPatchSpace[1024];       // Replacement routines are constructed here
# Line 450 | Line 457 | void CheckLoad(uint32 type, int16 id, ui
457                  }
458   #endif
459  
460 <        } else if (type == 'gpch' && id == 750) {
460 >        } else if (type == FOURCC('g','p','c','h') && id == 750) {
461                  D(bug(" gpch 750 found\n"));
462  
463                  // Don't use PTEST instruction in BlockMove() (7.5, 7.6, 7.6.1, 8.0)
464 <                static const uint8 dat[] = {0xa0, 0x8d, 0x0c, 0x81, 0x00, 0x00, 0x0c, 0x00, 0x65, 0x06, 0x4e, 0x71, 0xf4, 0xf8};
464 >                static const uint8 dat[] = {0x20, 0x5f, 0x22, 0x5f, 0x0c, 0x38, 0x00, 0x04, 0x01, 0x2f};
465                  base = find_rsrc_data(p, size, dat, sizeof(dat));
466                  if (base) {
467 <                        p16 = (uint16 *)(p + base + 8);
468 <                        *p16 = htons(M68K_NOP);
469 <                        FlushCodeCache(p + base + 8, 2);
467 >                        p16 = (uint16 *)(p + base + 4);
468 >                        *p16++ = htons(M68K_EMUL_OP_BLOCK_MOVE);
469 >                        *p16++ = htons(0x7000);
470 >                        *p16 = htons(M68K_RTS);
471 >                        FlushCodeCache(p + base + 4, 6);
472                          D(bug("  patch 1 applied\n"));
473                  }
474  
475 <        } else if (type == 'lpch' && id == 24) {
475 >        } else if (type == FOURCC('l','p','c','h') && id == 24) {
476                  D(bug(" lpch 24 found\n"));
477  
478                  // Don't replace Time Manager (7.0.1, 7.1, 7.5, 7.6, 7.6.1, 8.0)
# Line 480 | Line 489 | void CheckLoad(uint32 type, int16 id, ui
489                          D(bug("  patch 1 applied\n"));
490                  }
491  
492 <        } else if (type == 'lpch' && id == 31) {
492 >        } else if (type == FOURCC('l','p','c','h') && id == 31) {
493                  D(bug(" lpch 31 found\n"));
494  
495                  // Don't write to VIA in vSoundDead() (7.0.1, 7.1, 7.5, 7.6, 7.6.1, 8.0)
# Line 506 | Line 515 | void CheckLoad(uint32 type, int16 id, ui
515                  }
516  
517   #if !EMULATED_68K
518 <        } else if (CPUIs68060 && type == 'scod' && (id == -16463 || id == -16464)) {
518 >        } else if (CPUIs68060 && type == FOURCC('s','c','o','d') && (id == -16463 || id == -16464)) {
519                  D(bug(" scod -16463/-16464 found\n"));
520  
521                  // Correct 68060 FP frame handling in Process Manager task switches (7.1, 7.5, 8.0)
# Line 534 | Line 543 | void CheckLoad(uint32 type, int16 id, ui
543                  }
544   #endif
545  
546 <        } else if (type == 'thng' && id == -16563) {
546 >        } else if (type == FOURCC('t','h','n','g') && id == -16563) {
547                  D(bug(" thng -16563 found\n"));
548  
549                  // Set audio component flags (7.5, 7.6, 7.6.1, 8.0)
550                  *(uint32 *)(p + componentFlags) = htonl(audio_component_flags);
551                  D(bug("  patch 1 applied\n"));
552  
553 <        } else if (type == 'sift' && id == -16563) {
553 >        } else if (type == FOURCC('s','i','f','t') && id == -16563) {
554                  D(bug(" sift -16563 found\n"));
555  
556                  // Replace audio component (7.5, 7.6, 7.6.1, 8.0)
# Line 558 | Line 567 | void CheckLoad(uint32 type, int16 id, ui
567                  FlushCodeCache(p, 32);
568                  D(bug("  patch 1 applied\n"));
569  
570 <        } else if (type == 'inst' && id == -19069) {
570 >        } else if (type == FOURCC('i','n','s','t') && id == -19069) {
571                  D(bug(" inst -19069 found\n"));
572  
573                  // Don't replace Microseconds (QuickTime 2.0)
# Line 571 | Line 580 | void CheckLoad(uint32 type, int16 id, ui
580                          D(bug("  patch 1 applied\n"));
581                  }
582  
583 <        } else if (type == 'DRVR' && id == -20066) {
583 >        } else if (type == FOURCC('D','R','V','R') && id == -20066) {
584                  D(bug("DRVR -20066 found\n"));
585  
586                  // Don't access SCC in .Infra driver
# Line 584 | Line 593 | void CheckLoad(uint32 type, int16 id, ui
593                          D(bug("  patch 1 applied\n"));
594                  }
595  
596 <        } else if (type == 'ltlk' && id == 0) {
596 >        } else if (type == FOURCC('l','t','l','k') && id == 0) {
597                  D(bug(" ltlk 0 found\n"));
598  
599                  // Disable LocalTalk (7.0.1, 7.5, 7.6, 7.6.1, 8.0)
# Line 595 | Line 604 | void CheckLoad(uint32 type, int16 id, ui
604                  FlushCodeCache(p, 6);
605                  D(bug("  patch 1 applied\n"));
606          }
607 + #if REAL_ADDRESSING && !defined(AMIGA)
608 +        else if (type == FOURCC('D','R','V','R') && id == 41) {
609 +                D(bug(" DRVR 41 found\n"));
610 +                
611 +                // gb-- [0x28E (ROM85)] contains 0x3fff that will be placed into a0
612 +                // Seems to be caused by the AppleShare extension from MacOS 8.1 (3.7.4)
613 +                // .AFPTranslator (DRVR addr 0x2372)
614 +                static const uint8 dat[] = {0x3a, 0x2e, 0x00, 0x0a, 0x55, 0x4f, 0x3e, 0xb8, 0x02, 0x8e, 0x30, 0x1f, 0x48, 0xc0, 0x24, 0x40, 0x20, 0x40};
615 +                base = find_rsrc_data(p, size, dat, sizeof(dat));
616 +                if (base) {
617 +                        p16 = (uint16 *)(p + base + 4);
618 +                        *p16++ = htons(0x3078);         // movea.w      ROM85,%a0
619 +                        *p16++ = htons(0x028e);
620 +                        *p16++ = htons(0xd1fc);         // adda.l       #RAMBaseMac,%a0
621 +                        *p16++ = htons((RAMBaseMac >> 16) & 0xffff);
622 +                        *p16++ = htons(RAMBaseMac & 0xffff);
623 +                        *p16++ = htons(0x2448);         // movea.l      %a0,%a2
624 +                        *p16++ = htons(M68K_NOP);
625 +                        FlushCodeCache(p + base + 4, 14);
626 +                        D(bug("  patch 1 applied\n"));
627 +                }
628 +        }
629 + #endif
630   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines