--- nono/vm/videoctlr.cpp 2026/04/29 17:04:42 1.1.1.3 +++ nono/vm/videoctlr.cpp 2026/04/29 17:04:56 1.1.1.5 @@ -17,9 +17,8 @@ std::unique_ptr gVideoCtlr; VideoCtlrDevice::VideoCtlrDevice() + : inherited("VideoCtlr") { - logname = "videoctlr"; - devname = "VideoCtlr"; devaddr = baseaddr; devlen = 0x2000; } @@ -34,28 +33,28 @@ VideoCtlrDevice::ResetHard() // XXX not yet } -// addr は何ワード目のポートかという意味になるので -// $E82002 が addr=1 (番目のワード)。 +// offset は何ワード目のポートかという意味になるので +// $E82002 が offset=1 (番目のワード)。 uint64 -VideoCtlrDevice::Read(uint32 addr) +VideoCtlrDevice::Read(uint32 offset) { uint32 data; gMPU->AddCycle(9); // InsideOut p.135 - if (addr < 0x400 / 2) { // パレット - data = palette.w[addr]; + if (offset < 0x400 / 2) { // パレット + data = palette.w[offset]; - } else if (addr < 0x500 / 2) { // $E82400 (R0) + } else if (offset < 0x500 / 2) { // $E82400 (R0) data = videoctlr.r0; - } else if (addr < 0x600 / 2) { // $E82500 (R1) + } else if (offset < 0x600 / 2) { // $E82500 (R1) data = videoctlr.r1; - } else if (addr < 0x700 / 2) { // $E82600 (R2) + } else if (offset < 0x700 / 2) { // $E82600 (R2) data = videoctlr.r2; - } else { // それ以降は $00 が読めるようだ + } else { // それ以降は $00 が読めるようだ data = 0; } @@ -63,48 +62,48 @@ VideoCtlrDevice::Read(uint32 addr) } uint64 -VideoCtlrDevice::Write(uint32 addr, uint32 data) +VideoCtlrDevice::Write(uint32 offset, uint32 data) { gMPU->AddCycle(11); // InsideOut p.135 - if (addr < 0x400 / 2) { // パレット - putlog(3, "パレット $%06x.W <- $%04x", baseaddr + addr * 2, data); - palette.w[addr] = data; + if (offset < 0x400 / 2) { // パレット + putlog(3, "パレット $%06x.W <- $%04x", baseaddr + offset * 2, data); + palette.w[offset] = data; MakePalette(); - } else if (addr < 0x500 / 2) { // $E82400 (R0) + } else if (offset < 0x500 / 2) { // $E82400 (R0) SetR0(data); - } else if (addr < 0x600 / 2) { // $E82500 (R1) + } else if (offset < 0x600 / 2) { // $E82500 (R1) SetR1(data); - } else if (addr < 0x700 / 2) { // $E82600 (R2) + } else if (offset < 0x700 / 2) { // $E82600 (R2) SetR2(data); - } else { // それ以降はたぶん何も起きない? + } else { // それ以降はたぶん何も起きない? } return 0; } uint64 -VideoCtlrDevice::Peek(uint32 addr) +VideoCtlrDevice::Peek(uint32 offset) { uint32 data; - if (addr < 0x400 / 2) { // パレット - data = palette.w[addr]; + if (offset < 0x400 / 2) { // パレット + data = palette.w[offset]; - } else if (addr < 0x500 / 2) { // $E82400 (R0) + } else if (offset < 0x500 / 2) { // $E82400 (R0) data = videoctlr.r0; - } else if (addr < 0x600 / 2) { // $E82500 (R1) + } else if (offset < 0x600 / 2) { // $E82500 (R1) data = videoctlr.r1; - } else if (addr < 0x700 / 2) { // $E82600 (R2) + } else if (offset < 0x700 / 2) { // $E82600 (R2) data = videoctlr.r2; - } else { // それ以降は $00 が読めるようだ + } else { // それ以降は $00 が読めるようだ data = 0; }