--- nono/vm/mpu64180.h 2026/04/29 17:05:18 1.1 +++ nono/vm/mpu64180.h 2026/04/29 17:05:33 1.1.1.4 @@ -10,20 +10,20 @@ #pragma once -#include "device.h" +#include "mpu.h" #include "branchhistory.h" #include "event.h" #include "hd64180.h" #include "message.h" #include -class Debugger; class PIO0Device; +class SSGDevice; class XPbusDevice; -class MPU64180Device : public Device, private HD64180 +class MPU64180Device : public MPUDevice, private HD64180 { - using inherited = Device; + using inherited = MPUDevice; // タイマー1個分 struct XPTimer { @@ -45,14 +45,14 @@ class MPU64180Device : public Device, pr public: MPU64180Device(); - virtual ~MPU64180Device() override; + ~MPU64180Device() override; void putlogn(const char *fmt, ...) const override; bool Init() override; void ResetHard(bool poweron) override; // 現在実行中の命令先頭の PC を取得 - uint32 GetPPC() const { return ppc; } + uint32 GetPPC() const override { return ppc; } // CPU の動作モードを返す。 OpMode GetOpMode() const { return opmode; } @@ -81,15 +81,8 @@ class MPU64180Device : public Device, pr bool GetIEF1() const { return ief1; } bool GetIEF2() const { return ief2; } - // CPU からの論理メモリアクセス - // (MSXDOSDevice からも呼ぶので public にしてある) - uint32 Read8(uint32 addr); - uint32 Write8(uint32 addr, uint32 data); - uint32 Read16(uint32 addr); - void Write16(uint32 addr, uint32 data); - // アドレス変換 (デバッガ用) - uint64 TranslatePeek(uint32) const; + uint32 TranslatePeek(uint32) const; // MSXDOS エミュレーションのコールバックを指定する。 void SetSYSCALLCallback(void (*callback)(void *), void *arg); @@ -119,8 +112,14 @@ class MPU64180Device : public Device, pr uint32 GetWW(uint) const; void SetWW(uint, uint32); - uint32 Fetch8(); - uint32 Fetch16(); + // CPU からの論理メモリアクセス + uint32 Fetch1(); + uint32 Fetch2(); + uint32 Read1(uint32 addr); + uint32 Write1(uint32 addr, uint32 data); + uint32 Read2(uint32 addr); + void Write2(uint32 addr, uint32 data); + void Jump(uint16); void op_illegal(int pos); @@ -146,11 +145,11 @@ class MPU64180Device : public Device, pr void ExceptionDirect(int source, uint32 addr); void ExceptionVector(int source); - uint32 Peek8(uint32 addr) const; - uint32 Peek16(uint32 addr) const; + uint32 Peek1(uint32 addr) const; + uint32 Peek2(uint32 addr) const; - void Push16(uint32 data); - uint32 Pop16(); + void Push2(uint32 data); + uint32 Pop2(); uint32 ReadIO(uint32 addr); uint32 ReadInternalIO(uint32 offset); @@ -212,7 +211,7 @@ class MPU64180Device : public Device, pr uint8 reg_i {}; // I レジスタ uint8 reg_r {}; // R レジスタ - int ixiy {}; // 0=HL, 1=IX, 2=IY + uint ixiy {}; // 0=HL, 1=IX, 2=IY // (IX+d)/(IY+d) の d。 // 読み込んでない時は (uint32)-1 にしておく。 // DD と DD CB で読む位置が違うので。 @@ -220,7 +219,7 @@ class MPU64180Device : public Device, pr bool ief1 {}; // IEF1: Interrupt Enable Flag1 bool ief2 {}; // IEF2: Interrupt Enable Flag2 - int int0mode {}; // INT0 mode + uint int0mode {}; // INT0 mode bool intcheck {}; // この命令後の境界で割り込みチェックするなら true // 割り込み信号線の状態 @@ -294,21 +293,22 @@ class MPU64180Device : public Device, pr void (*syscall_callback)(void *) = NULL; void *syscall_arg {}; - Debugger *debugger {}; PIO0Device *pio0 {}; + SSGDevice *ssg {}; XPbusDevice *xpbus {}; // モニター DECLARE_MONITOR_CALLBACK(MonitorUpdateReg); DECLARE_MONITOR_CALLBACK(MonitorUpdateIO); DECLARE_MONITOR_CALLBACK(MonitorUpdateIntr); - Monitor reg_monitor { this }; - Monitor io_monitor { this }; - Monitor intr_monitor { this }; + Monitor *reg_monitor {}; + Monitor *io_monitor {}; + Monitor *intr_monitor {}; + + // 実行コールバック + EventCallback_t exec_func {}; // イベント - EventCallback_t exec_func {}; // 実行コールバック - Event exec_event { this }; Event timer_event { this }; // 名前