--- nono/vm/human_mi.cpp 2026/04/29 17:05:11 1.1.1.2 +++ nono/vm/human_mi.cpp 2026/04/29 17:05:18 1.1.1.4 @@ -14,11 +14,11 @@ #include "mpu88xx0.h" #include "scheduler.h" -bool human_m680x0_fline_callback(m68kcpu *cpu, void *arg); -bool human_m88xx0_fline_callback(m88kcpu *cpu, void *arg); +bool human_m680x0_fline_callback(MPU680x0Device *cpu, void *arg); +bool human_m88xx0_fline_callback(MPU88xx0Device *cpu, void *arg); HumanMI::HumanMI() - : inherited("HumanMI") + : inherited(OBJ_HUMAN_MI) { #define SC_DEF(id, name) scTable[(id)] = &HumanMI::name @@ -143,6 +143,9 @@ HumanMI::HumanMI() SC_DEF(0xfd, DOS_SEND_PR); SC_DEF(0xfe, DOS_TIME_PR); SC_DEF(0xff, DOS_CHANGE_PR); + + // XXX not tested + scheduler = GetScheduler(); } HumanMI::~HumanMI() @@ -166,7 +169,7 @@ HumanMI::Dispatch() if (r == false) { // 未実装システムコール - putlog(0, "Unimplemented system call $%02X", scid); + putlog(0, "system call $%02X (NOT IMPLEMENTED)", scid); RequestExit(0); return false; } @@ -180,7 +183,7 @@ HumanMI::Dispatch() void HumanMI::RequestExit(int code) { - gScheduler->Terminate(); + scheduler->Terminate(); } // システムコールの実装 @@ -274,21 +277,22 @@ HumanMI::DOS_EXIT2() bool HumanMD_m680x0::Init() { - cpu = gMPU680x0->GetCPU(); - gMPU680x0->SetFLineCallback(human_m680x0_fline_callback, this); + mpu = GetMPU680x0Device(); + mpu->SetFLineCallback(human_m680x0_fline_callback, this); return true; } bool HumanMD_m680x0::SysCallEntry() { - if (RegIR == 0xf600) { + uint16 ir = mpu->GetIR(); + if (ir == 0xf600) { return false; } - scid = RegIR & 0xff; - sp = RegA(7); - putlog(1, "IR=%04X sp=%08x", RegIR, sp); + scid = ir & 0xff; + sp = mpu->reg.A[7]; + putlog(1, "IR=%04X sp=%08x", ir, sp); return Dispatch(); } @@ -313,14 +317,14 @@ uint32 HumanMD_m680x0::ReadReg(int rn) { assert(0 <= rn && rn < 16); - return RegR(rn); + return mpu->reg.R[rn]; } void HumanMD_m680x0::WriteReg(int rn, uint32 data) { assert(0 <= rn && rn < 16); - RegR(rn) = data; + mpu->reg.R[rn] = data; } void @@ -334,17 +338,17 @@ HumanMD_m680x0::Result(uint32 data) bool HumanMD_m88xx0::Init() { - cpu = gMPU88xx0->GetCPU(); - gMPU88xx0->SetFLineCallback(human_m88xx0_fline_callback, this); + auto mpu88xx0 = GetMPU88xx0Device(); + mpu88xx0->SetFLineCallback(human_m88xx0_fline_callback, this); return true; } bool HumanMD_m88xx0::SysCallEntry() { - scid = cpu->opX & 0xff; - rd = m88100opf_D(cpu->opX); - rs = m88100opf_S1(cpu->opX); + scid = cpu->reg.opX & 0xff; + rd = m88100opf_D(cpu->reg.opX); + rs = m88100opf_S1(cpu->reg.opX); return Dispatch(); } @@ -368,7 +372,7 @@ uint32 HumanMD_m88xx0::ReadReg(int rn) { assert(0 <= rn && rn < 32); - return cpu->r[rn]; + return cpu->reg.r[rn]; } void @@ -376,7 +380,7 @@ HumanMD_m88xx0::WriteReg(int rn, uint32 { assert(0 <= rn && rn < 32); if (rn != 0) { - cpu->r[rn] = data; + cpu->reg.r[rn] = data; } } @@ -389,14 +393,14 @@ HumanMD_m88xx0::Result(uint32 data) // CPU からのコールバックはグローバル関数宛なので // クラス呼び出しに変換するだけを担当。 bool -human_m680x0_fline_callback(m68kcpu *cpu, void *arg) +human_m680x0_fline_callback(MPU680x0Device *, void *arg) { auto *human = (HumanMD_m680x0 *)arg; return human->SysCallEntry(); } bool -human_m88xx0_fline_callback(m88kcpu *cpu, void *arg) +human_m88xx0_fline_callback(MPU88xx0Device *cpu, void *arg) { auto *human = (HumanMD_m88xx0 *)arg; return human->SysCallEntry();