--- nono/vm/areaset.cpp 2026/04/29 17:05:17 1.1.1.8 +++ nono/vm/areaset.cpp 2026/04/29 17:05:25 1.1.1.9 @@ -8,8 +8,11 @@ // エリアセット // +// 書き込み専用デバイスなので BusIO を使うのも余計手間な気がする。 + #include "areaset.h" #include "mpu.h" +#include "x68kio.h" // コンストラクタ AreaSetDevice::AreaSetDevice() @@ -22,58 +25,73 @@ AreaSetDevice::~AreaSetDevice() { } +// 初期化 +bool +AreaSetDevice::Init() +{ + if (inherited::Init() == false) { + return false; + } + + x68kio = GetX68kIODevice(); + + return true; +} + // リセット void AreaSetDevice::ResetHard(bool poweron) { - limit = 0; + // リセットでどうなるかは分からないけど、 + // さすがに不定ではないだろう。 + x68kio->SetAreaset(0); } -uint64 +busdata AreaSetDevice::Read8(uint32 addr) { - switch (addr) { - case 0xe86001: - return limit; - } - return (uint64)-1; + // 書き込み専用なので読み出しはすべてバスエラー。 + putlog(2, "Read $%06x.B (BusErr)", addr); + return busdata::BusErr; } -uint64 +busdata AreaSetDevice::Read16(uint32 addr) { - return 0xff00 | Read8(addr + 1); + // 書き込み専用なので読み出しはすべてバスエラー。 + putlog(2, "Read $%06x.W (BusErr)", addr); + return busdata::BusErr; } -uint64 +busdata AreaSetDevice::Write8(uint32 addr, uint32 data) { - mpu->AddCycle(7); // InsideOut p.135 + busdata r; - switch (addr) { - case 0xe86001: - putlog(0, "Write $%02x (NOT IMPLEMENTED)", data); - limit = data; - return 0; - default: - break; + // 2バイトおきのようだ。 + uint32 offset = addr & 1; + if (offset == 0) { + putlog(2, "Write $%06x.B (BusErr)", addr); + r.SetBusErr(); + } else { + putlog(1, "Write $%06x <- $%02x", addr, data); + x68kio->SetAreaset(data & 0xff); } - return (uint64)-1; + + const busdata wait = busdata::Wait(7 * 40_nsec); + r |= wait; + return r; } -uint64 +busdata AreaSetDevice::Write16(uint32 addr, uint32 data) { - return Write8(addr + 1, data); + // ワード書き込みは可能 + return Write8(addr + 1, data & 0xff); } -uint64 +busdata AreaSetDevice::Peek8(uint32 addr) { - switch (addr) { - case 0xe86001: - return limit; - default: - return 0xff; - } + return busdata::BusErr; }