ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/rom_patches.cpp
(Generate patch)

Comparing BasiliskII/src/rom_patches.cpp (file contents):
Revision 1.6 by cebix, 1999-10-21T22:39:54Z vs.
Revision 1.10 by cebix, 1999-10-26T16:28:27Z

# Line 38 | Line 38
38   #include "debug.h"
39  
40  
41 < // Breakpoint
42 < //#define M68K_BREAKPOINT 0x2310        // CritError
43 < //#define M68K_BREAKPOINT 0x1d10        // BootMe
41 > // Breakpoint (offset into ROM)
42 > uint32 ROMBreakpoint = 0;       // 0 = disabled, 0x2310 = CritError
43  
44   // Global variables
45   uint32 UniversalInfo;   // ROM offset of UniversalInfo
# Line 547 | Line 546 | void InstallDrivers(uint32 pb)
546          r.d[0] = 0xa093;
547          Execute68kTrap(0xa247, &r);             // SetOSTrapAddress()
548  
549 +        // Install MemoryDispatch() replacement routine
550 +        r.a[0] = ROMBaseMac + memory_dispatch_offset;
551 +        r.d[0] = 0xa05c;
552 +        Execute68kTrap(0xa247, &r);             // SetOSTrapAddress()
553 +
554          // Install disk driver
555          r.a[0] = ROMBaseMac + sony_offset + 0x100;
556          r.d[0] = (uint32)DiskRefNum;
# Line 642 | Line 646 | void InstallSERD(void)
646  
647   void PatchAfterStartup(void)
648   {
645        // Install MemoryDispatch() replacement routine
646        M68kRegisters r;
647        r.a[0] = ROMBaseMac + memory_dispatch_offset;
648        r.d[0] = 0xa05c;
649        Execute68kTrap(0xa247, &r);             // SetOSTrapAddress()
650
649   #if SUPPORTS_EXTFS
650          // Install external file system
651          InstallExtFS();
# Line 1157 | Line 1155 | static bool patch_rom_32(void)
1155          *wp++ = htons(M68K_NOP);
1156          *wp = htons(M68K_NOP);
1157  
1158 <        // Fix logical/physical RAM size (CompBootStack) (must be done after InitMemMgr!)
1159 <        static const uint8 fix_memsize_dat[] = {0x4e, 0x75};
1160 <        if ((base = find_rom_data(0x490, 0x4b0, fix_memsize_dat, sizeof(fix_memsize_dat))) == 0) return false;
1161 <        D(bug("fix_memsize %08lx\n", base));
1162 <        wp = (uint16 *)(ROMBaseHost + base);
1158 >        // Compute boot stack pointer and fix logical/physical RAM size (CompBootStack) (must be done after InitMemMgr!)
1159 >        wp = (uint16 *)(ROMBaseHost + 0x490);
1160 >        *wp++ = htons(0x2038);  // move.l       $10c,d0
1161 >        *wp++ = htons(0x010c);
1162 >        *wp++ = htons(0xd0b8);  // add.l        $2a6,d0
1163 >        *wp++ = htons(0x02a6);
1164 >        *wp++ = htons(0xe288);  // lsr.l        #1,d0
1165 >        *wp++ = htons(0x0880);  // bclr         #0,d0
1166 >        *wp++ = htons(0x0000);
1167 >        *wp++ = htons(0x0440);  // subi.w       #$400,d0
1168 >        *wp++ = htons(0x0400);
1169 >        *wp++ = htons(0x2040);  // move.l       d0,a0
1170          *wp++ = htons(M68K_EMUL_OP_FIX_MEMSIZE);
1171 <        *wp = htons(M68K_RTS);
1171 >        *wp++ = htons(M68K_RTS);
1172  
1173          static const uint8 fix_memsize2_dat[] = {0x22, 0x30, 0x81, 0xe2, 0x0d, 0xdc, 0xff, 0xba, 0xd2, 0xb0, 0x81, 0xe2, 0x0d, 0xdc, 0xff, 0xec, 0x21, 0xc1, 0x1e, 0xf8};
1174          base = find_rom_data(0x4c000, 0x4c080, fix_memsize2_dat, sizeof(fix_memsize2_dat));
# Line 1296 | Line 1301 | static bool patch_rom_32(void)
1301                  }
1302          }
1303  
1304 +        // Don't set MemoryDispatch() to unimplemented trap
1305 +        static const uint8 memdisp_dat[] = {0x30, 0x3c, 0xa8, 0x9f, 0xa7, 0x46, 0x30, 0x3c, 0xa0, 0x5c, 0xa2, 0x47};
1306 +        base = find_rom_data(0x4f100, 0x4f180, memdisp_dat, sizeof(memdisp_dat));
1307 +        D(bug("memdisp %08lx\n", base));
1308 +        if (base) {     // ROM15/32
1309 +                wp = (uint16 *)(ROMBaseHost + base + 10);
1310 +                *wp = htons(M68K_NOP);
1311 +        }
1312 +
1313          // Patch .EDisk driver (don't scan for EDisks in the area ROMBase..0xe00000)
1314          uint32 edisk_offset = find_rom_resource('DRVR', 51);
1315          if (edisk_offset) {
# Line 1403 | Line 1417 | static bool patch_rom_32(void)
1417          *wp++ = htons(M68K_EMUL_OP_MEMORY_DISPATCH);
1418          *wp = htons(M68K_RTS);
1419  
1420 + #if EMULATED_68K
1421 +        // Replace BlockMove()
1422 +        wp = (uint16 *)(ROMBaseHost + find_rom_trap(0xa02e));   // BlockMove()
1423 +        *wp++ = htons(M68K_EMUL_OP_BLOCK_MOVE);
1424 +        *wp++ = htons(0x7000);
1425 +        *wp = htons(M68K_RTS);
1426 + #endif
1427 +
1428          // Patch VIA interrupt handler
1429          wp = (uint16 *)(ROMBaseHost + 0x9bc4);  // Level 1 handler
1430          *wp++ = htons(0x7002);          // moveq        #2,d0 (always 60Hz interrupt)
# Line 1440 | Line 1462 | bool PatchROM(void)
1462                          return false;
1463          }
1464  
1443 #ifdef M68K_BREAKPOINT
1465          // Install breakpoint
1466 <        uint16 *wp = (uint16 *)(ROMBaseHost + M68K_BREAKPOINT);
1467 <        *wp = htons(M68K_EMUL_BREAK);
1468 < #endif
1466 >        if (ROMBreakpoint) {
1467 >                uint16 *wp = (uint16 *)(ROMBaseHost + ROMBreakpoint);
1468 >                *wp = htons(M68K_EMUL_BREAK);
1469 >        }
1470  
1471          // Clear caches as we loaded and patched code
1472          FlushCodeCache(ROMBaseHost, ROMSize);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines