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.6 by gbeauche, 2000-09-22T17:17:56Z

# 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 67 | 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 89 | 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 104 | 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 113 | 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 129 | 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 156 | 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 170 | 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 195 | 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 454 | 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)
# Line 467 | Line 470 | void CheckLoad(uint32 type, int16 id, ui
470                          D(bug("  patch 1 applied\n"));
471                  }
472  
473 <        } else if (type == 'lpch' && id == 24) {
473 >        } else if (type == FOURCC('l','p','c','h') && id == 24) {
474                  D(bug(" lpch 24 found\n"));
475  
476                  // Don't replace Time Manager (7.0.1, 7.1, 7.5, 7.6, 7.6.1, 8.0)
# Line 484 | Line 487 | void CheckLoad(uint32 type, int16 id, ui
487                          D(bug("  patch 1 applied\n"));
488                  }
489  
490 <        } else if (type == 'lpch' && id == 31) {
490 >        } else if (type == FOURCC('l','p','c','h') && id == 31) {
491                  D(bug(" lpch 31 found\n"));
492  
493                  // Don't write to VIA in vSoundDead() (7.0.1, 7.1, 7.5, 7.6, 7.6.1, 8.0)
# Line 510 | Line 513 | void CheckLoad(uint32 type, int16 id, ui
513                  }
514  
515   #if !EMULATED_68K
516 <        } else if (CPUIs68060 && type == 'scod' && (id == -16463 || id == -16464)) {
516 >        } else if (CPUIs68060 && type == FOURCC('s','c','o','d') && (id == -16463 || id == -16464)) {
517                  D(bug(" scod -16463/-16464 found\n"));
518  
519                  // Correct 68060 FP frame handling in Process Manager task switches (7.1, 7.5, 8.0)
# Line 538 | Line 541 | void CheckLoad(uint32 type, int16 id, ui
541                  }
542   #endif
543  
544 <        } else if (type == 'thng' && id == -16563) {
544 >        } else if (type == FOURCC('t','h','n','g') && id == -16563) {
545                  D(bug(" thng -16563 found\n"));
546  
547                  // Set audio component flags (7.5, 7.6, 7.6.1, 8.0)
548                  *(uint32 *)(p + componentFlags) = htonl(audio_component_flags);
549                  D(bug("  patch 1 applied\n"));
550  
551 <        } else if (type == 'sift' && id == -16563) {
551 >        } else if (type == FOURCC('s','i','f','t') && id == -16563) {
552                  D(bug(" sift -16563 found\n"));
553  
554                  // Replace audio component (7.5, 7.6, 7.6.1, 8.0)
# Line 562 | Line 565 | void CheckLoad(uint32 type, int16 id, ui
565                  FlushCodeCache(p, 32);
566                  D(bug("  patch 1 applied\n"));
567  
568 <        } else if (type == 'inst' && id == -19069) {
568 >        } else if (type == FOURCC('i','n','s','t') && id == -19069) {
569                  D(bug(" inst -19069 found\n"));
570  
571                  // Don't replace Microseconds (QuickTime 2.0)
# Line 575 | Line 578 | void CheckLoad(uint32 type, int16 id, ui
578                          D(bug("  patch 1 applied\n"));
579                  }
580  
581 <        } else if (type == 'DRVR' && id == -20066) {
581 >        } else if (type == FOURCC('D','R','V','R') && id == -20066) {
582                  D(bug("DRVR -20066 found\n"));
583  
584                  // Don't access SCC in .Infra driver
# Line 588 | Line 591 | void CheckLoad(uint32 type, int16 id, ui
591                          D(bug("  patch 1 applied\n"));
592                  }
593  
594 <        } else if (type == 'ltlk' && id == 0) {
594 >        } else if (type == FOURCC('l','t','l','k') && id == 0) {
595                  D(bug(" ltlk 0 found\n"));
596  
597                  // Disable LocalTalk (7.0.1, 7.5, 7.6, 7.6.1, 8.0)
# Line 599 | Line 602 | void CheckLoad(uint32 type, int16 id, ui
602                  FlushCodeCache(p, 6);
603                  D(bug("  patch 1 applied\n"));
604          }
605 + #if REAL_ADDRESSING && !defined(AMIGA)
606 +        else if (type == FOURCC('D','R','V','R') && id == 41) {
607 +                D(bug(" DRVR 41 found\n"));
608 +                
609 +                // gb-- [0x28E (ROM85)] contains 0x3fff that will be placed into a0
610 +                // Seems to be caused by the AppleShare extension from MacOS 8.1 (3.7.4)
611 +                // .AFPTranslator (DRVR addr 0x2372)
612 +                static const uint8 dat[] = {0x3a, 0x2e, 0x00, 0x0a, 0x55, 0x4f, 0x3e, 0xb8, 0x02, 0x8e, 0x30, 0x1f, 0x48, 0xc0, 0x24, 0x40, 0x20, 0x40};
613 +                base = find_rsrc_data(p, size, dat, sizeof(dat));
614 +                if (base) {
615 +                        p16 = (uint16 *)(p + base + 4);
616 +                        *p16++ = htons(0x3078);         // movea.w      ROM85,%a0
617 +                        *p16++ = htons(0x028e);
618 +                        *p16++ = htons(0xd1fc);         // adda.l       #RAMBaseMac,%a0
619 +                        *p16++ = htons((RAMBaseMac >> 16) & 0xffff);
620 +                        *p16++ = htons(RAMBaseMac & 0xffff);
621 +                        *p16++ = htons(0x2448);         // movea.l      %a0,%a2
622 +                        *p16++ = htons(M68K_NOP);
623 +                        FlushCodeCache(p + base + 4, 14);
624 +                        D(bug("  patch 1 applied\n"));
625 +                }
626 +        }
627 + #endif
628   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines