--- nono/hd64180/hd647180io.cpp 2026/04/29 17:05:18 1.1.1.1 +++ nono/hd64180/hd647180io.cpp 2026/04/29 17:05:30 1.1.1.2 @@ -12,10 +12,10 @@ #include "hd647180.h" #include "pio.h" #include "scheduler.h" +#include "ssg.h" #include "xpbus.h" //#define ENABLE_SERIAL_LOG -//#define ENABLE_SSG_LOG uint32 MPU64180Device::ReadIO(uint32 addr) @@ -210,9 +210,11 @@ MPU64180Device::ReadExternalIO(uint32 ad switch (addr & 0xff) { case 0x82: // SSG case 0x83: // SSG -#if !defined(ENABLE_SSG_LOG) - data = 0xff; -#endif + if (ssg) { + data = ssg->Read1(addr); + } else { + data = 0xff; // ? + } break; case 0x90: // INT0 ネゲート @@ -432,10 +434,10 @@ MPU64180Device::WriteExternalIO(uint32 a switch (addr & 0xff) { case 0x82: // SSG case 0x83: // SSG -#if !defined(ENABLE_SSG_LOG) + if (ssg) { + ssg->Write1(addr, data); + } return 0; -#endif - break; case 0x90: // INT0 ネゲート putlog(1, "%s Negate INT0", IOName(addr).c_str()); @@ -471,7 +473,7 @@ MPU64180Device::WriteTMDRL(int ch, uint3 IOName(HD647180::IO_TMDRL(ch)).c_str(), data); } else { t.count = (t.count & 0xff00) | data; - putlog(1, "%s <- $%02x (TMDR%d = $%04x)", + putlog(1, "%s <- $%02x (TMDR%u = $%04x)", IOName(HD647180::IO_TMDRL(ch)).c_str(), data, ch, t.count); } return 0; @@ -487,7 +489,7 @@ MPU64180Device::WriteTMDRH(int ch, uint3 IOName(HD647180::IO_TMDRH(ch)).c_str(), data); } else { t.count = (data << 8) | (t.count & 0x00ff); - putlog(1, "%s <- $%02x (TMDR%d = $%04x)", + putlog(1, "%s <- $%02x (TMDR%u = $%04x)", IOName(HD647180::IO_TMDRH(ch)).c_str(), data, ch, t.count); } return 0; @@ -499,7 +501,7 @@ MPU64180Device::WriteRLDRL(int ch, uint3 // 動作中にも変更可能 auto& t = timer[ch]; t.reload = (t.reload & 0xff00) | data; - putlog(1, "%s <- $%02x (RLDR%d = $%04x)", + putlog(1, "%s <- $%02x (RLDR%u = $%04x)", IOName(HD647180::IO_RLDRL(ch)).c_str(), data, ch, t.reload); return 0; } @@ -510,7 +512,7 @@ MPU64180Device::WriteRLDRH(int ch, uint3 // 動作中にも変更可能 auto& t = timer[ch]; t.reload = (data << 8) | (t.reload & 0x00ff); - putlog(1, "%s <- $%02x (RLDR%d = $%04x)", + putlog(1, "%s <- $%02x (RLDR%u = $%04x)", IOName(HD647180::IO_RLDRH(ch)).c_str(), data, ch, t.reload); return 0; } @@ -530,7 +532,7 @@ MPU64180Device::WriteTCR(uint32 data) new_tde[1] = (data & 0x02); new_tde[0] = (data & 0x01); - msg = string_format("TIE1=%d TIE0=%d TOC=$%d", + msg = string_format("TIE1=%u TIE0=%u TOC=$%x", (timer[1].intr_enable ? 1 : 0), (timer[0].intr_enable ? 1 : 0), timer_toc); @@ -542,7 +544,7 @@ MPU64180Device::WriteTCR(uint32 data) t.count = t.reload; t.running = true; MakeActiveTimer(); - msg += string_format(" Timer%d=Start", ch); + msg += string_format(" Timer%u=Start", ch); EnableTimer(); } else if (t.running == true && new_tde[ch] == false) { // カウントダウン停止 @@ -551,7 +553,7 @@ MPU64180Device::WriteTCR(uint32 data) // タイマーイベントの中で running が落ちてたら停止してくれる。 t.running = false; MakeActiveTimer(); - msg += string_format(" Timer%d=Stop", ch); + msg += string_format(" Timer%u=Stop", ch); } else { // 変化なし } @@ -831,6 +833,9 @@ MPU64180Device::PeekExternalIO(uint32 ad switch (addr & 0xff) { case 0x82: // SSG case 0x83: // SSG + if (ssg) { + return ssg->Peek1(addr); + } break; case 0x90: // INT0 ネゲート