--- nono/vm/areaset.cpp 2026/04/29 17:04:28 1.1.1.1 +++ nono/vm/areaset.cpp 2026/04/29 17:05:25 1.1.1.9 @@ -1,65 +1,97 @@ // // nono -// Copyright (C) 2017 isaki@NetBSD.org +// Copyright (C) 2020 nono project +// Licensed under nono-license.txt // +// +// エリアセット +// + +// 書き込み専用デバイスなので BusIO を使うのも余計手間な気がする。 + #include "areaset.h" +#include "mpu.h" +#include "x68kio.h" +// コンストラクタ AreaSetDevice::AreaSetDevice() + : inherited(OBJ_AREASET) { - logname = "area"; - devname = "AreaSet"; - devaddr = baseaddr; - devlen = 0x2000; } +// デストラクタ AreaSetDevice::~AreaSetDevice() { } -uint64 -AreaSetDevice::Read8(uint32 addr) +// 初期化 +bool +AreaSetDevice::Init() { - switch (addr) { - case 0xe86001: - return limit; + if (inherited::Init() == false) { + return false; } - return (uint64)-1; + + x68kio = GetX68kIODevice(); + + return true; } -uint64 +// リセット +void +AreaSetDevice::ResetHard(bool poweron) +{ + // リセットでどうなるかは分からないけど、 + // さすがに不定ではないだろう。 + x68kio->SetAreaset(0); +} + +busdata +AreaSetDevice::Read8(uint32 addr) +{ + // 書き込み専用なので読み出しはすべてバスエラー。 + putlog(2, "Read $%06x.B (BusErr)", addr); + return busdata::BusErr; +} + +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) { - switch (addr) { - case 0xe86001: - putlog(0, "未実装エリアセット書き込み $%02x", data); - limit = data; - return 0; - default: - break; + busdata r; + + // 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; }