--- nono/vm/pedec.cpp 2026/04/29 17:05:10 1.1.1.5 +++ nono/vm/pedec.cpp 2026/04/29 17:05:17 1.1.1.7 @@ -21,27 +21,37 @@ // +--| PEDECDevice | (X68030 の Lv1 担当コントローラ) // | +-------------+ // | -// +-- SysCtlrDevice (LUNA88K の割り込みコントローラ) +// +-- SysCtlrDevice (LUNA-88K の割り込みコントローラ) #include "pedec.h" #include "fdc.h" +#include "fdd.h" #include "spc.h" -// グローバル参照用 -PEDECDevice *gPEDEC; - // コンストラクタ PEDECDevice::PEDECDevice() - : inherited("PEDEC") + : inherited(OBJ_PEDEC) { - devaddr = baseaddr; - devlen = 0x2000; } // デストラクタ PEDECDevice::~PEDECDevice() { - gPEDEC = NULL; +} + +// 初期化 +bool +PEDECDevice::Init() +{ + if (inherited::Init() == false) { + return false; + } + + fdc = GetFDCDevice(); + interrupt = GetInterruptDevice(); + spc = GetSPCDevice(); + + return true; } // リセット @@ -81,7 +91,7 @@ PEDECDevice::Write(uint32 offset, uint32 intmap_enabled |= (data & 0x02) ? IntmapFDD : 0; intmap_enabled |= (data & 0x01) ? IntmapPRT : 0; - putlog(1, "割り込みマスク設定 HDD=%d FDC=%d FDD=%d PRT=%d", + putlog(1, "Set Interrupt Mask HDD=%d FDC=%d FDD=%d PRT=%d", ((intmap_enabled & IntmapHDD) ? 1 : 0), ((intmap_enabled & IntmapFDC) ? 1 : 0), ((intmap_enabled & IntmapFDD) ? 1 : 0), @@ -90,7 +100,7 @@ PEDECDevice::Write(uint32 offset, uint32 case 1: // $E9C003 割り込みベクタ vector = data & 0xfc; - putlog(1, "割り込みベクタ設定 $%02x", vector); + putlog(1, "Set Interrupt Vector $%02x", vector); return 0; default: @@ -131,12 +141,11 @@ PEDECDevice::MonitorUpdate(TextScreen& s for (int i = 0; i < countof(table); i++) { uint32 map = table[i].map; int clz = __builtin_clz(map); - screen.Puts(3, y, TA::OnOff(intmap & map), table[i].name); - screen.Print(8, y, "%11" PRIu64, counter[clz]); - + screen.Puts(4, y, TA::OnOff(intmap & map), table[i].name); if (intr_level >= 1 || (intmap_enabled & map) == 0) { - screen.Puts(21, y, "Mask"); + screen.Puts(10, y, "Mask"); } + screen.Print(14, y, "%26s", format_number(counter[clz]).c_str()); y++; } } @@ -172,7 +181,7 @@ PEDECDevice::ChangeInterrupt() #endif uint32 stat = (intmap & intmap_enabled); - gInterrupt->ChangeINT(this, stat); + interrupt->ChangeINT(this, stat); } // 割り込みアクノリッジ @@ -190,6 +199,8 @@ PEDECDevice::InterruptAcknowledge(int lv if ((stat & IntmapFDC)) { return vector + 0; + } else if ((stat & IntmapFDD)) { + return vector + 1; } else { VMPANIC("Unknown interrupt acknowledge"); } @@ -199,11 +210,14 @@ PEDECDevice::InterruptAcknowledge(int lv uint32 PEDECDevice::GetIntmap(Device *source) const { - if (__predict_true(source == gSPC)) { + if (__predict_true(source == spc)) { return IntmapSPC; } - if (__predict_true(source == gFDC)) { + if (__predict_true(source == fdc)) { return IntmapFDC; } + if (dynamic_cast(source)) { + return IntmapFDD; + } VMPANIC("Unsupported interrupt device"); }