--- nono/vm/xiospace.cpp 2026/04/29 17:04:45 1.1.1.5 +++ nono/vm/xiospace.cpp 2026/04/29 17:04:53 1.1.1.7 @@ -34,14 +34,6 @@ // X68030 のメイン空間 ($000000-$FFFFFF) 担当。 // -// デバイス -static std::unique_ptr areaset; -static std::unique_ptr pluto; -static std::unique_ptr ppi; -static std::unique_ptr printer; -static std::unique_ptr sprite; -static std::unique_ptr sysport; - // 1つの 8KB ブロックを複数のデバイスで共有する場合 class MuxDevice : public IODevice @@ -148,6 +140,8 @@ MuxDevice::Peek8(uint32 addr) } +std::unique_ptr gXIOSpace; + // コンストラクタ XIOSpaceDevice::XIOSpaceDevice() { @@ -160,7 +154,7 @@ XIOSpaceDevice::XIOSpaceDevice() } while (0) // デバイスクラス作成 (順序に注意) - ADD_DEVICE(areaset, AreaSetDevice()); + ADD_DEVICE(gAreaSet, AreaSetDevice()); ADD_DEVICE(gCGROM, CGROMDevice()); ADD_DEVICE(gCRTC, BusIO_W()); ADD_DEVICE(gDMAC, BusIO_B()); @@ -170,15 +164,15 @@ XIOSpaceDevice::XIOSpaceDevice() ADD_DEVICE(gIPLROM1, IPLROM1Device()); ADD_DEVICE(gIPLROM2, IPLROM2Device()); ADD_DEVICE(gMFP, BusIO_EB()); - ADD_DEVICE(pluto, PlutoDevice()); - ADD_DEVICE(ppi, BusIO_EB()); - ADD_DEVICE(printer, PrinterDevice()); + ADD_DEVICE(gPluto, PlutoDevice()); + ADD_DEVICE(gPPI, BusIO_EB()); + ADD_DEVICE(gPrinter, PrinterDevice()); ADD_DEVICE(gRTC, BusIO_EB()); ADD_DEVICE(gSCC, BusIO_EB()); ADD_DEVICE(gSRAM, SRAMDevice()); // Required by SPC ADD_DEVICE(gSPC, BusIO_X68kSPC()); - ADD_DEVICE(sprite, SpriteDevice()); - ADD_DEVICE(sysport, BusIO_FB()); + ADD_DEVICE(gSprite, SpriteDevice()); + ADD_DEVICE(gSysport, BusIO_FB()); ADD_DEVICE(gTVRAM, TVRAMDevice()); ADD_DEVICE(gVideoCtlr, BusIO_W()); ADD_DEVICE(gOPM, BusIO_EB()); @@ -193,16 +187,16 @@ bool XIOSpaceDevice::Init() { // RAM のみ RamDevice::Init() で ram_size が決定してから行う。 + int ram_size = gRAM->GetSize(); for (int i = 0; i < ram_size / 8192; i++) { table[i] = gRAM.get(); } // 必要なデバイスは全部埋めたので、この時点で nullptr なエントリを - // buserr に差し替える。 - IODevice *buserr = gVM->GetBusErrDevice(); + // BusErr に差し替える。 for (auto&& d : table) { if (d == nullptr) { - d = buserr; + d = gBusErr.get(); } } @@ -311,3 +305,31 @@ XIOSpaceDevice::Peek8(uint32 addr) IODevice *d = SearchDevice(addr); return d->Peek8(addr); } + +// ブートページを切り替える。 +// (VM_X68030::SwitchBootPage() の下請け) +void +XIOSpaceDevice::SwitchBootPage(bool isrom) +{ + IODevice *ram; + IODevice *rom; + + if (isrom) { + // 0x000000 からの 64KB ( 8エントリ)、 + // 0xfe0000 からの 128KB (16エントリ) のどちらも IPLROM0 が担当する。 + ram = gIPLROM0.get(); + rom = ram; + } else { + // 0x000000 からの 64KB ( 8エントリ) に RAM を見せる。 + // 0xfe0000 からの 128KB (16エントリ) に IPLROM1 を見せる。 + ram = gRAM.get(); + rom = gIPLROM1.get(); + } + + for (int i = 0; i < 8; i++) { + table[i] = ram; + } + for (int i = 0; i < 16; i++) { + table[table.size() - 16 + i] = rom; + } +}