--- nono/vm/human68k.cpp 2026/04/29 17:04:58 1.1.1.8 +++ nono/vm/human68k.cpp 2026/04/29 17:05:11 1.1.1.9 @@ -5,23 +5,9 @@ // // -// human68k .r .x .z console emulator +// Human68k .r .x .z console emulator // -#include "human68k.h" -#include "autofd.h" -#include "bus.h" -#include "iodevstream.h" -#include "mainapp.h" -#include "m68030bus.h" -#include "m68030core.h" -#include "mpu680x0.h" -#include "scheduler.h" -#include "vm.h" -#include -#include -#include - // メモリマップ // // 0000'0000 ベクタ @@ -34,8 +20,23 @@ // 0002'0000 ロードアドレス // 00bf'ffff RAM_END +#include "human68k.h" +#include "autofd.h" +#include "iodevstream.h" +#include "mainapp.h" +#include "m68030bus.h" +#include "m68030core.h" +#include "mpu680x0.h" +#include "scheduler.h" +#include +#include +#include + static bool human68k_fline_callback(m68kcpu *cpu, void *arg); +// グローバル参照用 +Human68k *gHuman68k; + // コンストラクタ Human68k::Human68k() : inherited("Human68k") @@ -55,6 +56,7 @@ Human68k::Human68k() // デストラクタ Human68k::~Human68k() { + gHuman68k = NULL; } bool @@ -65,7 +67,7 @@ Human68k::Init() uint8 *file; // ショートカット用 - ram = gRAM.get(); + ram = gRAM; // Fライン命令をこちらで処理する gMPU680x0->SetFLineCallback(human68k_fline_callback, this); @@ -134,7 +136,7 @@ Human68k::Init() munmap(file, file_size); uint32 last_addr = load_addr + load_size + bss_size; - int ram_size = gRAM->GetSize(); + int ram_size = ram->GetSize(); IODeviceStream ds(ram); boot_addr = 0x200; @@ -358,8 +360,7 @@ Human68k::isext(const char *file, const void Human68k::RequestExit(int code) { - gMPU->Release(); - gScheduler->RequestExit(); + gScheduler->Terminate(); } // fileaddr: Human68k ファイル名のゲストVA @@ -394,7 +395,9 @@ Human68k::OpenFile(uint32 fileaddr, uint for (int i = 0; i < countof(filename) - 3; i++) { uint8 c = ds.Read8(); - if (c == 0) break; + if (c == 0) { + break; + } if (c < 32 || c >= 127 || c == 0x5c) { p += sprintf(p, "%02X", c); } else { @@ -512,7 +515,7 @@ Human68k::IOCS(m68kcpu *cpu) case 0x7f: // _ONTIME { putmsg(1, "IOCS ONTIME"); - uint64 t = gMPU->GetVirtTime(); + uint64 t = gScheduler->GetVirtTime(); // nanosec to 10msec, in day RegD(0) = (t / 10_msec) % 8640000; // nanosec to day @@ -592,7 +595,9 @@ Human68k::FLineOp(m68kcpu *cpu) uint32 dataptr = m68030_read_32(cpu, RegA(7)); do { int c = m68030_read_8(cpu, dataptr++); - if (c == 0) break; + if (c == 0) { + break; + } printf("%c", c); } while (1); RegD(0) = 0;