--- nono/vm/mk48t02.cpp 2026/04/29 17:05:18 1.1.1.13 +++ nono/vm/mk48t02.cpp 2026/04/29 17:05:33 1.1.1.16 @@ -20,6 +20,7 @@ #include "bitops.h" #include "config.h" #include "mainapp.h" +#include "monitor.h" #include "mpu.h" #include #include @@ -38,9 +39,9 @@ MK48T02Device::MK48T02Device() // 今の所 UTC として使うケースだけのようだ。 use_localtime = false; - monitor.func = ToMonitorCallback(&MK48T02Device::MonitorUpdate); - monitor.SetSize(40, 13); - monitor.Regist(ID_MONITOR_MK48T02); + monitor = gMonitorManager->Regist(ID_MONITOR_MK48T02, this); + monitor->func = ToMonitorCallback(&MK48T02Device::MonitorUpdate); + monitor->SetSize(40, 13); } // デストラクタ @@ -159,19 +160,21 @@ MK48T02Device::BCD2num(uint8 bcd) return (bcd >> 4) * 10 + (bcd & 0x0f); } -uint64 -MK48T02Device::Read(uint32 offset) +busdata +MK48T02Device::ReadPort(uint32 offset) { - uint32 data; + busdata data; data = mem[offset]; - putlog(3, "$%08x -> $%02x", mpu->GetPaddr(), data); + putlog(3, "$%08x -> $%02x", mpu->GetPaddr(), data.Data()); + // XXX wait? + data |= BusData::Size1; return data; } -uint64 -MK48T02Device::Write(uint32 offset, uint32 data) +busdata +MK48T02Device::WritePort(uint32 offset, uint32 data) { putlog(3, "$%08x <- $%02x", mpu->GetPaddr(), data); @@ -208,26 +211,28 @@ MK48T02Device::Write(uint32 offset, uint mem[offset] = data; - return 0; + // XXX wait? + busdata r = BusData::Size1; + return r; } -uint64 -MK48T02Device::Peek(uint32 offset) +busdata +MK48T02Device::PeekPort(uint32 offset) { return mem[offset]; } -uint64 -MK48T02Device::Poke(uint32 offset, uint32 data) +bool +MK48T02Device::PokePort(uint32 offset, uint32 data) { // 時計部分にはコントロールレジスタもあるので書き込み不可。 if (offset >= 2040) { - return (uint64)-1; + return false; } else { if ((int32)data >= 0) { mem[offset] = data; } - return 0; + return true; } } @@ -242,44 +247,44 @@ MK48T02Device::MonitorUpdate(Monitor *, // BCD なので %x で表示する screen.Print(0, y++, - "Internal: %04d[%02x]/%02x/%02x(%s) %02x:%02x:%02x.%1x", + "Internal: %04u[%02x]/%02x/%02x(%s) %02x:%02x:%02x.%1x", DecodeYear(reg.in.year), reg.in.year, reg.in.mon, reg.in.mday, wdays[reg.in.wday], reg.in.hour, reg.in.min, reg.in.sec, (uint32)((cnt >> 1) & 0xf)); auto ex = Load(); screen.Print(0, y++, - "Register: %04d[%02x]/%02x/%02x(%s) %02x:%02x:%02x", + "Register: %04u[%02x]/%02x/%02x(%s) %02x:%02x:%02x", DecodeYear(ex.year), ex.year, ex.mon, ex.mday, wdays[ex.wday], ex.hour, ex.min, ex.sec); screen.Print(0, y++, "TimeZone: %s", use_localtime ? "Local" : "UTC"); - screen.Print(0, y++, "Epoch : %4d (Adjust Leap: %d)", + screen.Print(0, y++, "Epoch : %4u (Adjust Leap: %u)", year_epoch, adjust_leap); y++; addr = 0x800; - v = Peek(--addr); + v = PeekPort(--addr); screen.Print(0, y++, "$%3x: $%02x (year=%02x)", addr, v, v); - v = Peek(--addr); + v = PeekPort(--addr); screen.Print(0, y++, "$%3x: $%02x (mon =%02x)", addr, v, v); - v = Peek(--addr); + v = PeekPort(--addr); screen.Print(0, y++, "$%3x: $%02x (date=%02x)", addr, v, v); - v = Peek(--addr); - screen.Print(0, y++, "$%3x: $%02x (wday=%02x FT=%d)", + v = PeekPort(--addr); + screen.Print(0, y++, "$%3x: $%02x (wday=%02x FT=%u)", addr, v, (v & 0x07), (v & MK48T02Clock::FREQTEST) ? 1 : 0); - v = Peek(--addr); - screen.Print(0, y++, "$%3x: $%02x (hour=%02x KS=%d)", + v = PeekPort(--addr); + screen.Print(0, y++, "$%3x: $%02x (hour=%02x KS=%u)", addr, v, (v & 0x3f), (v & MK48T02Clock::KICKSTART) ? 1 : 0); - v = Peek(--addr); + v = PeekPort(--addr); screen.Print(0, y++, "$%3x: $%02x (min =%02x)", addr, v, (v & 0x7f)); - v = Peek(--addr); - screen.Print(0, y++, "$%3x: $%02x (sec =%02x ST=%d)", + v = PeekPort(--addr); + screen.Print(0, y++, "$%3x: $%02x (sec =%02x ST=%u)", addr, v, (v & 0x7f), (v & MK48T02Clock::STOP) ? 1 : 0); - v = Peek(--addr); - screen.Print(0, y++, "$%3x: $%02x (W=%d R=%d)", + v = PeekPort(--addr); + screen.Print(0, y++, "$%3x: $%02x (W=%u R=%u)", addr, v, (v & MK48T02Clock::WRITE) ? 1 : 0, (v & MK48T02Clock::READ) ? 1 : 0); @@ -380,7 +385,7 @@ MK48T02Device::GetWday() const // 1を月曜…という運用ということにする。 // 戻り値は 0..6 (0が日曜)。 - int v = reg.in.wday; + uint v = reg.in.wday; if (v == 7) { v = 0; }