--- nono/vm/fdc.cpp 2026/04/29 17:04:35 1.1.1.4 +++ nono/vm/fdc.cpp 2026/04/29 17:04:50 1.1.1.7 @@ -5,9 +5,11 @@ // #include "fdc.h" -#include "ioctlr.h" +#include "pedec.h" #include "scheduler.h" +std::unique_ptr gFDC; + // コンストラクタ FDCDevice::FDCDevice() { @@ -30,13 +32,16 @@ void FDCDevice::ResetHard() { // XXX 他には + event.Stop(); idle_phase(); } uint64 -FDCDevice::Read(uint32 addr) +FDCDevice::Read(uint32 offset) { - switch (addr) { + gMPU->AddCycle(19); // InsideOut p.135 + + switch (offset) { case 0: return ReadStatus(); case 1: @@ -50,9 +55,11 @@ FDCDevice::Read(uint32 addr) } uint64 -FDCDevice::Write(uint32 addr, uint32 data) +FDCDevice::Write(uint32 offset, uint32 data) { - switch (addr) { + gMPU->AddCycle(19); // InsideOut p.135 + + switch (offset) { case 0: return 0; @@ -70,7 +77,8 @@ FDCDevice::Write(uint32 addr, uint32 dat (fdc.drivesel & 8) ? " #3" : ""); } if ((data & 0xe0) != 0) { - putlog(0, "未実装ビット書き込み $%06x <- $%02x", addr, data); + putlog(0, "未実装ビット書き込み $%06x <- $%02x", + gMPU->GetPaddr(), data); } return 0; @@ -92,7 +100,7 @@ FDCDevice::Write(uint32 addr, uint32 dat } uint64 -FDCDevice::Peek(uint32 addr) +FDCDevice::Peek(uint32 offset) { // XXX 未実装 return 0xff; @@ -253,6 +261,11 @@ FDCDevice::exec_phase() case FDC::CMD_SENSE_INTERRUPT_STATUS: { putlog(1, "Exec フェーズ: SENSE INTERRUPT STATUS"); + // XXX とりあえずここで割り込みを下げる。 + // 実際には割り込み状態をラッチして信号線に出すというコマンドで + // 割り込み要因がオフになっていればそれによってネゲートされる + // ということのようだ。 + gPEDEC->NegateINT(this); // XXX まだフロッピー挿入はない uint8 st0 = 0; st0 |= FDC::ST0_IC_NT; @@ -305,9 +318,9 @@ FDCDevice::result_phase() // イベントコールバック void -FDCDevice::Callback(int arg) +FDCDevice::Callback(Event& ev) { - switch (arg) { + switch (ev.code) { case FDC::CMD_RECALIBRATE: fdd[fdc.accdrive].seek = false; fdc.DIO = DIOtoHost; @@ -320,7 +333,7 @@ FDCDevice::Callback(int arg) void FDCDevice::Interrupt() { - gIOCtlr->IntFDC(); + gPEDEC->AssertINT(this); } // コマンド名