--- nono/vm/x68kio.cpp 2026/04/29 17:05:17 1.1.1.1 +++ nono/vm/x68kio.cpp 2026/04/29 17:05:20 1.1.1.2 @@ -17,8 +17,10 @@ #include "dmac.h" #include "fdc.h" #include "gvram.h" +#include "mainbus.h" #include "mainram.h" #include "mfp.h" +#include "nereid.h" #include "opm.h" #include "pedec.h" #include "pio.h" @@ -40,6 +42,11 @@ X68kIODevice::X68kIODevice() : inherited(OBJ_X68KIO) { + monitor.func = ToMonitorCallback(&X68kIODevice::MonitorUpdate); + monitor.SetSize(73, 1 + 32); + monitor.SetMaxHeight(1 + 256); + monitor.Regist(ID_SUBWIN_X68KIO); + #define ADD_DEVICE(NAME, ADDR, LEN) \ AddDevice(__CONCAT(p,NAME).get(), ADDR, LEN) @@ -70,6 +77,8 @@ X68kIODevice::X68kIODevice() N(PEDEC, new BusIO_EB(), 0xe9c000, 0x2000); N(Pluto, new PlutoDevice(), 0xeac000, 0x2000); N(Sprite, new SpriteDevice(), 0xeb0000, 0x10000); + // Nereid はこの時点ではデバイスの追加のみ。Init() 参照。 + NEWDV(Nereid, new NereidDevice()); // 0xece000, 0x2000 N(SRAM, new SRAMDevice(), 0xed0000, 0x4000); N(CGROM, new CGROMDevice(), 0xf00000, 0xc0000); if (gConfig->Find("iplrom2-image").AsString().empty()) { @@ -97,11 +106,19 @@ X68kIODevice::Init() auto buserr = GetBusErrDevice(); auto mainram = GetMainRAMDevice(); - // RAM のみ RamDevice::Init() で ram_size が決定してから行う。 + // RAM は RamDevice::Init() で ram_size が決定してから行う。 for (int i = 0; i < mainram->GetSize() / 8192; i++) { table[i] = mainram; } + // Nereid は1枚でもボードがある時だけメモリ空間に追加する。 + // Nereid が1枚もない場合でもモニタやログ(この場合のログは起動時にどれが + // 有効とか無効と判断したことを表示するもの)のためデバイス自体は常に存在。 + auto nereid = GetNereidDevice(); + if (nereid->IsInstalled()) { + ADD_DEVICE(Nereid, 0xece000, 0x2000); + } + // 必要なデバイスは全部埋めたので、この時点で nullptr なエントリを // BusErr に差し替える。 for (auto&& d : table) { @@ -209,6 +226,37 @@ X68kIODevice::GetDevice(uint32 addr) con return SearchDevice(addr & 0x00ffffff); } +void +X68kIODevice::MonitorUpdate(Monitor *, TextScreen& screen) +{ + screen.Clear(); + + // 012345678901234567890 + // $00'0000: 1234567 + + // pos が表示開始位置(0-) + int pos = (int)screen.userdata; + int row = screen.GetRow(); + + for (int i = 0; i < 8; i++) { + screen.Print(10 + i * 8, 0, "+$%04x", i * 0x2000); + } + + int idx = pos * 8; + for (int y = 1; y < row; y++) { + uint32 addr = idx * 0x2000; + std::string addrstr = '$' + strhex(addr >> 16, 2) + "'0000:"; + screen.Puts(0, y, addrstr.c_str()); + for (int i = 0; i < 8; i++) { + auto pair = MainbusDevice::FormatDevName(table[idx]); + const std::string& name = pair.first; + TA attr = pair.second; + screen.Print(10 + i * 8, y, attr, "%s", name.c_str()); + idx++; + } + } +} + // ブートページを切り替える。 // (VM_X68030::SwitchBootPage() の下請け) void