30 |
|
#include "disk.h" |
31 |
|
#include "cdrom.h" |
32 |
|
#include "video.h" |
33 |
+ |
#include "extfs.h" |
34 |
|
#include "prefs.h" |
35 |
|
#include "rom_patches.h" |
36 |
|
|
37 |
< |
#define DEBUG 0 |
37 |
> |
#define DEBUG 1 |
38 |
|
#include "debug.h" |
39 |
|
|
40 |
|
|
46 |
|
uint32 UniversalInfo; // ROM offset of UniversalInfo |
47 |
|
uint32 PutScrapPatch; // Mac address of PutScrap() patch |
48 |
|
|
49 |
< |
static uint32 sony_offset; // ROM offset of .Sony driver |
50 |
< |
static uint32 serd_offset; // ROM offset of SERD resource (serial drivers) |
51 |
< |
static uint32 microseconds_offset; // ROM offset of Microseconds() replacement routine |
49 |
> |
static uint32 sony_offset; // ROM offset of .Sony driver |
50 |
> |
static uint32 serd_offset; // ROM offset of SERD resource (serial drivers) |
51 |
> |
static uint32 microseconds_offset; // ROM offset of Microseconds() replacement routine |
52 |
|
static uint32 memory_dispatch_offset; // ROM offset of MemoryDispatch() replacement routine |
53 |
|
|
54 |
|
// Prototypes |
147 |
|
|
148 |
|
static const uint8 sony_driver[] = { // Replacement for .Sony driver |
149 |
|
// Driver header |
150 |
< |
SonyDriverFlags >> 8, SonyDriverFlags & 0xff, SonyDriverDelay >> 8, SonyDriverDelay & 0xff, 0x00, 0x00, 0x00, 0x00, |
150 |
> |
SonyDriverFlags >> 8, SonyDriverFlags & 0xff, 0, 0, 0, 0, 0, 0, |
151 |
|
0x00, 0x18, // Open() offset |
152 |
|
0x00, 0x1c, // Prime() offset |
153 |
|
0x00, 0x20, // Control() offset |
195 |
|
|
196 |
|
static const uint8 disk_driver[] = { // Generic disk driver |
197 |
|
// Driver header |
198 |
< |
DiskDriverFlags >> 8, DiskDriverFlags & 0xff, DiskDriverDelay >> 8, DiskDriverDelay & 0xff, 0x00, 0x00, 0x00, 0x00, |
198 |
> |
DiskDriverFlags >> 8, DiskDriverFlags & 0xff, 0, 0, 0, 0, 0, 0, |
199 |
|
0x00, 0x18, // Open() offset |
200 |
|
0x00, 0x1c, // Prime() offset |
201 |
|
0x00, 0x20, // Control() offset |
243 |
|
|
244 |
|
static const uint8 cdrom_driver[] = { // CD-ROM driver |
245 |
|
// Driver header |
246 |
< |
CDROMDriverFlags >> 8, CDROMDriverFlags & 0xff, CDROMDriverDelay >> 8, CDROMDriverDelay & 0xff, 0x00, 0x00, 0x00, 0x00, |
246 |
> |
CDROMDriverFlags >> 8, CDROMDriverFlags & 0xff, 0, 0, 0, 0, 0, 0, |
247 |
|
0x00, 0x1c, // Open() offset |
248 |
|
0x00, 0x20, // Prime() offset |
249 |
|
0x00, 0x24, // Control() offset |
556 |
|
uint32 dce = ReadMacInt32(r.a[0]); |
557 |
|
WriteMacInt32(dce + dCtlDriver, ROMBaseMac + sony_offset + 0x100); |
558 |
|
WriteMacInt16(dce + dCtlFlags, DiskDriverFlags); |
558 |
– |
WriteMacInt16(dce + dCtlDelay, DiskDriverDelay); |
559 |
|
|
560 |
|
// Open disk driver |
561 |
|
WriteMacInt32(pb + ioNamePtr, ROMBaseMac + sony_offset + 0x112); |
574 |
|
dce = ReadMacInt32(r.a[0]); |
575 |
|
WriteMacInt32(dce + dCtlDriver, ROMBaseMac + sony_offset + 0x200); |
576 |
|
WriteMacInt16(dce + dCtlFlags, CDROMDriverFlags); |
577 |
– |
WriteMacInt16(dce + dCtlDelay, CDROMDriverDelay); |
577 |
|
|
578 |
|
// Open CD-ROM driver |
579 |
|
WriteMacInt32(pb + ioNamePtr, ROMBaseMac + sony_offset + 0x212); |
647 |
|
r.a[0] = ROMBaseMac + memory_dispatch_offset; |
648 |
|
r.d[0] = 0xa05c; |
649 |
|
Execute68kTrap(0xa247, &r); // SetOSTrapAddress() |
650 |
+ |
|
651 |
+ |
#if SUPPORTS_EXTFS |
652 |
+ |
// Install external file system |
653 |
+ |
InstallExtFS(); |
654 |
+ |
#endif |
655 |
|
} |
656 |
|
|
657 |
|
|
668 |
|
// Real addressing mode requires a 32-bit clean ROM |
669 |
|
return ROMVersion == ROM_VERSION_32; |
670 |
|
#else |
671 |
< |
// Virtual addressing mode works with 32-bit clean Mac II ROMs and Classic ROMs (experimental) |
671 |
> |
// Virtual addressing mode works with 32-bit clean Mac II ROMs and Classic ROMs |
672 |
|
return (ROMVersion == ROM_VERSION_CLASSIC) || (ROMVersion == ROM_VERSION_32); |
673 |
|
#endif |
674 |
|
} |
841 |
|
// ROM patches for 32-bit clean Mac-II ROMs (version $067c) |
842 |
|
static bool patch_rom_32(void) |
843 |
|
{ |
844 |
+ |
uint32 *lp; |
845 |
|
uint16 *wp; |
846 |
|
uint8 *bp; |
847 |
|
uint32 base; |
1157 |
|
*wp++ = htons(M68K_NOP); |
1158 |
|
*wp = htons(M68K_NOP); |
1159 |
|
|
1160 |
< |
// Fix logical/physical RAM size (CompBootStack) (must be done after InitMemMgr!) |
1161 |
< |
static const uint8 fix_memsize_dat[] = {0x4e, 0x75}; |
1162 |
< |
if ((base = find_rom_data(0x490, 0x4b0, fix_memsize_dat, sizeof(fix_memsize_dat))) == 0) return false; |
1163 |
< |
D(bug("fix_memsize %08lx\n", base)); |
1164 |
< |
wp = (uint16 *)(ROMBaseHost + base); |
1160 |
> |
// Compute boot stack pointer and fix logical/physical RAM size (CompBootStack) (must be done after InitMemMgr!) |
1161 |
> |
wp = (uint16 *)(ROMBaseHost + 0x490); |
1162 |
> |
*wp++ = htons(0x2038); // move.l $10c,d0 |
1163 |
> |
*wp++ = htons(0x010c); |
1164 |
> |
*wp++ = htons(0xd0b8); // add.l $2a6,d0 |
1165 |
> |
*wp++ = htons(0x02a6); |
1166 |
> |
*wp++ = htons(0xe288); // lsr.l #1,d0 |
1167 |
> |
*wp++ = htons(0x0880); // bclr #0,d0 |
1168 |
> |
*wp++ = htons(0x0000); |
1169 |
> |
*wp++ = htons(0x0440); // subi.w #$400,d0 |
1170 |
> |
*wp++ = htons(0x0400); |
1171 |
> |
*wp++ = htons(0x2040); // move.l d0,a0 |
1172 |
|
*wp++ = htons(M68K_EMUL_OP_FIX_MEMSIZE); |
1173 |
< |
*wp = htons(M68K_RTS); |
1173 |
> |
*wp++ = htons(M68K_RTS); |
1174 |
|
|
1175 |
|
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}; |
1176 |
|
base = find_rom_data(0x4c000, 0x4c080, fix_memsize2_dat, sizeof(fix_memsize2_dat)); |
1410 |
|
*wp++ = htons(M68K_EMUL_OP_MEMORY_DISPATCH); |
1411 |
|
*wp = htons(M68K_RTS); |
1412 |
|
|
1413 |
+ |
#if EMULATED_68K |
1414 |
+ |
// Replace BlockMove() |
1415 |
+ |
wp = (uint16 *)(ROMBaseHost + find_rom_trap(0xa02e)); // BlockMove() |
1416 |
+ |
*wp++ = htons(M68K_EMUL_OP_BLOCK_MOVE); |
1417 |
+ |
*wp++ = htons(0x7000); |
1418 |
+ |
*wp = htons(M68K_RTS); |
1419 |
+ |
#endif |
1420 |
+ |
|
1421 |
|
// Patch VIA interrupt handler |
1422 |
|
wp = (uint16 *)(ROMBaseHost + 0x9bc4); // Level 1 handler |
1423 |
|
*wp++ = htons(0x7002); // moveq #2,d0 (always 60Hz interrupt) |