--- nono/vm/fdc.h 2026/04/29 17:05:14 1.1.1.8 +++ nono/vm/fdc.h 2026/04/29 17:05:51 1.1.1.13 @@ -11,12 +11,12 @@ #pragma once #include "device.h" -#include "event.h" #include "fixedqueue.h" -#include "monitor.h" #include +class DMACDevice; class FDDDevice; +class PEDECDevice; struct FDCCmdBuf { @@ -83,7 +83,7 @@ struct FDCCmdBuf }; }; - int len; + uint len; void Clear() { len = 0; @@ -142,11 +142,11 @@ struct FDCResBuf class FDCDevice : public IODevice { using inherited = IODevice; - static const int baseaddr = 0xe94000; + static const uint32 baseaddr = 0xe94000; public: // サポートしているドライブ数上限 - static const int MAX_DRIVE = 4; + static const uint MAX_DRIVE = 4; private: // コマンド定義 @@ -276,9 +276,10 @@ class FDCDevice : public IODevice public: FDCDevice(); - virtual ~FDCDevice() override; + ~FDCDevice() override; bool Create() override; + bool Init() override; void ResetHard(bool poweron) override; // READY 信号が変化したことの通知 (FDD から呼ばれる) @@ -291,15 +292,13 @@ class FDCDevice : public IODevice void AssertDACK(bool tc); void NegateDACK(); - // 接続されている FDD のリストを取得 (UI 用) - const std::vector& GetFDD() const { return fdd_vector; } - protected: // BusIO インタフェース static const uint32 NPORT = 4; - uint64 Read(uint32 offset); - uint64 Write(uint32 offset, uint32 data); - uint64 Peek(uint32 offset); + busdata ReadPort(uint32 offset); + busdata WritePort(uint32 offset, uint32 data); + busdata PeekPort(uint32 offset); + bool PokePort(uint32 offset, uint32 data); private: uint32 ReadData(); @@ -309,7 +308,7 @@ class FDCDevice : public IODevice uint32 GetDriveStatus() const; void PushDreg(uint8); - int PopDreg(); + uint32 PopDreg(); void RequestDataByte(); uint8 GetMSR() const; @@ -321,8 +320,8 @@ class FDCDevice : public IODevice void ExecPhase(); void ResultPhase(); - void CommandCallback(Event& ev); - void ResultCallback(Event&); + void CommandCallback(Event *); + void ResultCallback(Event *); void ChangeInterrupt(); @@ -331,9 +330,9 @@ class FDCDevice : public IODevice // データ転送 void XferStart(bool is_write); - void XferStartCallback(Event&); - void XferDataCallback(Event&); - void XferEndCallback(Event&); + void XferStartCallback(Event *); + void XferDataCallback(Event *); + void XferEndCallback(Event *); // FDC コマンド void CmdInvalid(); @@ -371,12 +370,12 @@ class FDCDevice : public IODevice // ポーリング void StartPoll(); - void PollEventCallback(Event&); + void PollEventCallback(Event *); bool PollReady(int); bool ExecSeek(int); // モータ停止用 - void MotorEventCallback(Event&); + void MotorEventCallback(Event *); DECLARE_MONITOR_CALLBACK(MonitorUpdate); void MonitorReg(TextScreen&, @@ -417,7 +416,7 @@ class FDCDevice : public IODevice FixedQueue dreg {}; // 内部データレジスタ bool hd {}; // Head address - uint8 us {}; // Unit Select + uint8 us {}; // Unit Select (US0,US1) 出力信号 bool tc {}; // TC 入力信号 bool dack {}; // DACK 入力信号 @@ -432,7 +431,7 @@ class FDCDevice : public IODevice uint sect_remain {}; int index_detected {}; - int seek_srt {}; // SEEK ステップレートタイマカウンタ + uint seek_srt {}; // SEEK ステップレートタイマカウンタ MSR msr {}; ST0 st0 {}; @@ -446,11 +445,16 @@ class FDCDevice : public IODevice // OPM bool force_ready {}; // 強制レディ - Event phase_event { this }; // 状態遷移用 - Event poll_event { this }; // ポーリング用 - Event motor_event { this }; // モータ停止用 + DMACDevice *dmac {}; + PEDECDevice *pedec {}; + + Event *phase_event {}; // 状態遷移用 + Event *poll_event {}; // ポーリング用 + Event *motor_event {}; // モータ停止用 - Monitor monitor { this }; + Monitor *monitor {}; }; -extern FDCDevice *gFDC; +static inline FDCDevice *GetFDCDevice() { + return Object::GetObject(OBJ_FDC); +}