--- nono/vm/crtc.h 2026/04/29 17:05:10 1.1.1.7 +++ nono/vm/crtc.h 2026/04/29 17:05:50 1.1.1.13 @@ -10,8 +10,11 @@ #pragma once -#include "event.h" -#include "monitor.h" +#include "device.h" + +class MFPDevice; +class TVRAMDevice; +class VideoCtlrDevice; struct CRTC { @@ -68,7 +71,7 @@ struct CRTC // // 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 // +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ - // R20 | - |SIZ| COL | - |HF | VD | HD | + // R20 | - |MEM|SIZ| COL | - |HF | VD | HD | // +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ // R21 | - |MEN|SA | AP | CP | // +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ @@ -76,7 +79,10 @@ struct CRTC // +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ // R23 | マスクパターン | // +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ - // R24 | - |RC | 0 |FC |VI | + // + // 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 + // +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ + // OP | - |RC | 0 |FC |VI | // +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ uint16 r[24]; @@ -109,6 +115,14 @@ struct CRTC static const uint32 REG_END = 0x18; static const uint32 REG_OP = 0x240; // $E80480 + // R20 + static const uint16 R20_MEM = 0x0800; + static const uint16 R20_SIZ = 0x0400; + static const uint16 R20_COL = 0x0300; + static const uint16 R20_HF = 0x0010; + static const uint16 R20_VD = 0x000c; + static const uint16 R20_HD = 0x0003; + // 動作ポート static const uint32 OP_RC = 0x08; // ラスターコピー開始(%1) static const uint32 OP_FC = 0x02; // 高速クリア開始(%1) @@ -120,40 +134,54 @@ class CRTCDevice : public IODevice using inherited = IODevice; public: CRTCDevice(); - virtual ~CRTCDevice() override; + ~CRTCDevice() override; + bool Init() override; void ResetHard(bool poweron) override; - protected: - // BusIO インタフェース - static const uint NPORT = 0x800; - uint64 Read(uint32 offset); - uint64 Write(uint32 offset, uint32 data); - uint64 Peek(uint32 offset); + busdata Read(busaddr addr) override; + busdata Write(busaddr addr, uint32 data) override; + busdata Peek1(uint32 offset) override; private: + static inline uint32 Decoder(uint32 addr); + + // ワード読み出し + busdata Peek2(uint32 addr) const; // レジスタへの書き込み void SetReg(uint32 offset, uint32 data); // 動作ポートへの書き込み void WriteOp(uint32 data); - // テキスト画面のラスターコピー - void StartRasterCopy(); - // 水平同期信号イベント - void HSyncCallback(Event& ev); + void HSyncCallback(Event *); + + // ラスターコピー完了イベント + void RasterCallback(Event *); // 垂直表示期間イベント - void VDispCallback(Event& ev); + void VDispCallback(Event *); DECLARE_MONITOR_CALLBACK(MonitorUpdate); struct CRTC crtc {}; - Event hsync_event { this }; - Event vdisp_event { this }; + // ラスターコピー指示 + bool raster_copy {}; - Monitor monitor { this }; -}; + // XXX もうちょっとなんとかする + uint hsync_state {}; + uint vdisp_state {}; + + MFPDevice *mfp {}; + TVRAMDevice *tvram {}; + VideoCtlrDevice *videoctlr {}; -extern CRTCDevice *gCRTC; + Event *hsync_event {}; + Event *vdisp_event {}; + Event *raster_event {}; + + Monitor *monitor {}; + + static const busdata wait; +};