--- nono/vm/x68kio.cpp 2026/04/29 17:05:24 1.1.1.3 +++ nono/vm/x68kio.cpp 2026/04/29 17:05:28 1.1.1.4 @@ -94,10 +94,10 @@ X68kIODevice::X68kIODevice() N(CRTC, new CRTCDevice(), 0xe80000, 0x2000); N(VideoCtlr, new VideoCtlrDevice(), 0xe82000, 0x2000); N(DMAC, new DMACDevice(), 0xe84000, 0x2000); - N(AreaSet, new AreaSetDevice(), 0xe86000, 0x2000); + N(AreaSet, new BusIO_EB(), 0xe86000, 0x2000); N(MFP, new BusIO_EB(), 0xe88000, 0x2000); N(RTC, new BusIO_EB(), 0xe8a000, 0x2000); - N(Printer, new PrinterDevice(), 0xe8c000, 0x2000); + N(Printer, new BusIO_EB(), 0xe8c000, 0x2000); N(Sysport,new BusIO_FB(), 0xe8e000, 0x2000); N(OPM, new BusIO_EB(), 0xe90000, 0x2000); N(ADPCM, new BusIO_EB(), 0xe92000, 0x2000); @@ -107,7 +107,7 @@ X68kIODevice::X68kIODevice() N(PPI, new BusIO_EB(), 0xe9a000, 0x2000); N(PEDEC, new BusIO_EB(), 0xe9c000, 0x2000); // Windrv はデバイスは常に作成し、マップするかどうかは設定による。 - NEWDV(Windrv, new WindrvDevice()); + NEWDV(Windrv, new BusIO_B()); if (WindrvDevice::IsWindrv()) { ADD_DEVICE(Windrv, 0xe9e000, 0x2000); } @@ -189,7 +189,7 @@ X68kIODevice::InitMainbus() // デバッグ表示 if (0) { for (int i = 1536; i < sdevice.size(); i++) { - printf("[%3d] $%06x ", i, i * 8192); + printf("[%3u] $%06x ", i, i * 8192); assert(sdevice[i]); assert(udevice[i]); printf("S:%-8s U:%s\n", @@ -209,8 +209,8 @@ X68kIODevice::SetUdevice(uint32 startadd { assert(startaddr < endaddr); assert(((endaddr + 1) & 0x1fff) == 0); - int start = startaddr / 8192; - int end = (endaddr + 1) / 8192; + uint start = startaddr / 8192; + uint end = (endaddr + 1) / 8192; // MPU の FC2 ピンカットの動作は本来 MPU 側を加工すべきだが、 // MPU アクセスのほうが圧倒的に多いので影響の少ない DMAC 側で処理する。 @@ -239,7 +239,7 @@ X68kIODevice::SetUdevice(uint32 startadd void X68kIODevice::AddDevice(IODevice *dev, uint devaddr, uint devlen) { - int idx = devaddr / 8192; + uint idx = devaddr / 8192; for (int i = idx; i < idx + (devlen + 8191) / 8192; i++) { // 重複するケースは未対応 assertmsg(sdevice[i] == nullptr, "X68kIODevice.AddDevice '%s'", @@ -262,24 +262,6 @@ X68kIODevice::Decoder(bool super, uint32 } } -busdata -X68kIODevice::Peek8(uint32 addr) -{ - addr &= 0x00ffffff; - - IODevice *d = Decoder(true, addr); - return d->Peek8(addr); -} - -bool -X68kIODevice::Poke8(uint32 addr, uint32 data) -{ - addr &= 0x00ffffff; - - IODevice *d = Decoder(true, addr); - return d->Poke8(addr, data); -} - // 回路図より CIIN は以下の通り。 // // FC1 ---------| @@ -300,74 +282,53 @@ X68kIODevice::CheckCI(busaddr addr) { // 16ビットポートはメインメモリ、GVRAM、TVRAM、ROM を除いた部分なので // 0xe80000 .. 0xefffff かな。 - busaddr cimask(0xf80000, busaddr::D); - busaddr data16(0xe80000, busaddr::D); + busaddr cimask = busaddr(0xf80000) | BusAddr::D; + busaddr data16 = busaddr(0xe80000) | BusAddr::D; if ((addr.Get() & cimask.Get()) == data16.Get()) { mpu->SetCI(); } } -// Read*/Write* 全部の共通部分。副作用のあるマクロ。 -#define PREPARE() \ - CheckCI(addr); \ - uint32 addr24 = addr.Addr() & 0x00ffffff; \ - IODevice *d = Decoder(addr.IsSuper(), addr24); - busdata -X68kIODevice::Read8(busaddr addr) +X68kIODevice::Read(busaddr addr) { - PREPARE(); - - busdata bd = d->Read8(addr24); - putlog(2, "Read $%06x -> $%02x", addr24, bd.Data()); - return bd; -} - -busdata -X68kIODevice::Read16(busaddr addr) -{ - PREPARE(); - - busdata bd = d->Read16(addr24); - putlog(2, "Read $%06x -> $%04x", addr24, bd.Data()); - return bd; -} - -busdata -X68kIODevice::Read32(busaddr addr) -{ - PREPARE(); + addr &= 0x00ffffff; + CheckCI(addr); - busdata bd = d->Read32(addr24); - putlog(2, "Read $%06x -> $%08x", addr24, bd.Data()); + IODevice *d = Decoder(addr.IsSuper(), addr.Addr()); + busdata bd = d->Read(addr); + putlog(2, "Read $%06x -> $%0*x", + addr.Addr(), addr.GetSize() * 2, bd.Data()); return bd; } busdata -X68kIODevice::Write8(busaddr addr, uint32 data) +X68kIODevice::Write(busaddr addr, uint32 data) { - PREPARE(); + addr &= 0x00ffffff; + CheckCI(addr); - putlog(1, "Write $%06x <- $%02x", addr24, data); - return d->Write8(addr24, data); + IODevice *d = Decoder(addr.IsSuper(), addr.Addr()); + putlog(2, "Write $%06x <- $%0*x", addr.Addr(), addr.GetSize() * 2, data); + return d->Write(addr, data); } busdata -X68kIODevice::Write16(busaddr addr, uint32 data) +X68kIODevice::Peek1(uint32 addr) { - PREPARE(); + addr &= 0x00ffffff; - putlog(1, "Write $%06x <- $%04x", addr24, data); - return d->Write16(addr24, data); + IODevice *d = Decoder(true, addr); + return d->Peek1(addr); } -busdata -X68kIODevice::Write32(busaddr addr, uint32 data) +bool +X68kIODevice::Poke1(uint32 addr, uint32 data) { - PREPARE(); + addr &= 0x00ffffff; - putlog(1, "Write $%06x <- $%08x", addr24, data); - return d->Write32(addr24, data); + IODevice *d = Decoder(true, addr); + return d->Poke1(addr, data); } void @@ -387,7 +348,7 @@ X68kIODevice::MonitorUpdate(Monitor *, T // 012345678901234567890 // $00'0000: 1234567 - int idx = pos * 8; + uint idx = pos * 8; for (int y = 1, end = screen.GetRow(); y < end; y++) { screen.Print(0, y, "$%02x'0000:", (idx * 0x2000) >> 16); for (int i = 0; i < 8; i++) { @@ -456,16 +417,16 @@ X68kIODevice::SetAreaset(uint8 arealimit // $00 なら $000000 から $001FFF まで (8KB)。 // $ff なら $000000 から $01FFFF まで (2MB)。 // X68030 なのでメモリは最低でも 4MB あるので上限チェックは不要。 - int end = (arealimit + 1); + uint end = (arealimit + 1); SetUdevice(0x00'0000, end * 8192 - 1, false); SetUdevice(end * 8192, 0x20'0000 - 1, true); } // 拡張エリアセット取得 uint8 -X68kIODevice::GetExtarea(int offset) const +X68kIODevice::GetExtarea(uint offset) const { - if (0 <= offset && offset < extarea.size()) { + if (offset < extarea.size()) { return extarea[offset]; } // ? @@ -474,9 +435,9 @@ X68kIODevice::GetExtarea(int offset) con // 拡張エリアセット設定 void -X68kIODevice::SetExtarea(int offset, uint8 data) +X68kIODevice::SetExtarea(uint offset, uint8 data) { - if (0 <= offset && offset < extarea.size()) { + if (offset < extarea.size()) { extarea[offset] = data; } @@ -516,7 +477,7 @@ X68kIODevice::SetExtarea(int offset, uin void X68kIODevice::MonitorUpdateAreaset(Monitor *, TextScreen& screen) { - int areaend; + uint areaend; screen.Clear(); @@ -528,7 +489,7 @@ X68kIODevice::MonitorUpdateAreaset(Monit // 拡張エリアセット for (int i = 0; i < extarea.size(); i++) { uint8 data = GetExtarea(i); - screen.Print(0, i + 1, "Extarea[%d] $%02x $%06x", i, data, + screen.Print(0, i + 1, "Extarea[%u] $%02x $%06x", i, data, (i + 1) * 0x20'0000); for (int j = 0; j < 8; j++) { screen.Putc(24 + j, i + 1, (((int8)data < 0) ? 'S' : '-'));