|
|
1.1 root 1: //
2: // nono
1.1.1.2 root 3: // Copyright (C) 2020 nono project
4: // Licensed under nono-license.txt
1.1 root 5: //
6:
1.1.1.7 root 7: //
8: // CRTC
9: //
10:
1.1 root 11: #pragma once
12:
1.1.1.9 root 13: #include "device.h"
1.1 root 14:
1.1.1.9 root 15: class MFPDevice;
16: class TVRAMDevice;
1.1.1.12 root 17: class VideoCtlrDevice;
1.1.1.9 root 18:
1.1 root 19: struct CRTC
20: {
1.1.1.7 root 21: // 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
22: // +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
23: // R00 | - | 水平トータル |
24: // +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
25: // R01 | - | 水平同期終了位置 |
26: // +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
27: // R02 | - | 水平表示開始位置 |
28: // +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
29: // R03 | - | 水平表示終了位置 |
30: // +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
31: //
32: // +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
33: // R04 | - | 垂直トータル |
34: // +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
35: // R05 | - | 垂直同期終了位置 |
36: // +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
37: // R06 | - | 垂直表示開始位置 |
38: // +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
39: // R07 | - | 垂直表示終了位置 |
40: // +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
41: //
42: // 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
43: // +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
44: // R08 | - | 外部同期水平アジャスト |
45: // +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
46: // R09 | - | ラスタ番号 |
47: // +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
48: // R10 | - | テキスト画面スクロール X位置 |
49: // +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
50: // R11 | - | テキスト画面スクロール Y位置 |
51: // +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
52: //
53: // 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
54: // +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
55: // R12 | - | グラフィック画面スクロール X0 |
56: // +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
57: // R13 | - | グラフィック画面スクロール Y0 |
58: // +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
59: // R14 | - | グラフィック画面スクロール X1 |
60: // +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
61: // R15 | - | グラフィック画面スクロール Y1 |
62: // +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
63: // R16 | - | グラフィック画面スクロール X2 |
64: // +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
65: // R17 | - | グラフィック画面スクロール Y2 |
66: // +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
67: // R18 | - | グラフィック画面スクロール X3 |
68: // +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
69: // R19 | - | グラフィック画面スクロール Y3 |
70: // +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
71: //
72: // 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
73: // +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
1.1.1.8 root 74: // R20 | - |MEM|SIZ| COL | - |HF | VD | HD |
1.1.1.7 root 75: // +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
76: // R21 | - |MEN|SA | AP | CP |
77: // +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
78: // R22 | ソースラスタ | デスティネーションラスタ |
79: // +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
80: // R23 | マスクパターン |
81: // +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
1.1.1.11 root 82: //
83: // 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
84: // +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
85: // OP | - |RC | 0 |FC |VI |
1.1.1.7 root 86: // +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
87:
1.1 root 88: uint16 r[24];
89: uint16 op;
90:
91: static const uint32 R00 = 0x00; // $E80000
92: static const uint32 R01 = 0x01; // $E80002
93: static const uint32 R02 = 0x02; // $E80004
94: static const uint32 R03 = 0x03; // $E80006
95: static const uint32 R04 = 0x04; // $E80008
96: static const uint32 R05 = 0x05; // $E8000A
97: static const uint32 R06 = 0x06; // $E8000C
98: static const uint32 R07 = 0x07; // $E8000E
99: static const uint32 R08 = 0x08; // $E80010
100: static const uint32 R09 = 0x09; // $E80012
101: static const uint32 R10 = 0x0a; // $E80014
102: static const uint32 R11 = 0x0b; // $E80016
103: static const uint32 R12 = 0x0c; // $E80018
104: static const uint32 R13 = 0x0d; // $E8001A
105: static const uint32 R14 = 0x0e; // $E8001C
106: static const uint32 R15 = 0x0f; // $E8001E
107: static const uint32 R16 = 0x10; // $E80020
108: static const uint32 R17 = 0x11; // $E80022
109: static const uint32 R18 = 0x12; // $E80024
110: static const uint32 R19 = 0x13; // $E80026
111: static const uint32 R20 = 0x14; // $E80028
112: static const uint32 R21 = 0x15; // $E8002A
113: static const uint32 R22 = 0x16; // $E8002C
114: static const uint32 R23 = 0x17; // $E8002E
115: static const uint32 REG_END = 0x18;
1.1.1.5 root 116: static const uint32 REG_OP = 0x240; // $E80480
1.1.1.7 root 117:
1.1.1.8 root 118: // R20
119: static const uint16 R20_MEM = 0x0800;
120: static const uint16 R20_SIZ = 0x0400;
121: static const uint16 R20_COL = 0x0300;
122: static const uint16 R20_HF = 0x0010;
123: static const uint16 R20_VD = 0x000c;
124: static const uint16 R20_HD = 0x0003;
125:
1.1.1.7 root 126: // 動作ポート
127: static const uint32 OP_RC = 0x08; // ラスターコピー開始(%1)
128: static const uint32 OP_FC = 0x02; // 高速クリア開始(%1)
129: static const uint32 OP_VI = 0x01; // 画像取り込み開始(%1)
1.1 root 130: };
131:
1.1.1.6 root 132: class CRTCDevice : public IODevice
1.1 root 133: {
1.1.1.2 root 134: using inherited = IODevice;
1.1 root 135: public:
136: CRTCDevice();
1.1.1.10 root 137: ~CRTCDevice() override;
1.1 root 138:
1.1.1.9 root 139: bool Init() override;
1.1.1.7 root 140: void ResetHard(bool poweron) override;
1.1 root 141:
1.1.1.11 root 142: busdata Read(busaddr addr) override;
143: busdata Write(busaddr addr, uint32 data) override;
144: busdata Peek1(uint32 offset) override;
1.1 root 145:
146: private:
1.1.1.11 root 147: static inline uint32 Decoder(uint32 addr);
148:
1.1.1.10 root 149: // ワード読み出し
1.1.1.11 root 150: busdata Peek2(uint32 addr) const;
1.1.1.7 root 151: // レジスタへの書き込み
1.1.1.2 root 152: void SetReg(uint32 offset, uint32 data);
1.1.1.7 root 153: // 動作ポートへの書き込み
154: void WriteOp(uint32 data);
155:
156: // 水平同期信号イベント
1.1.1.13 root 157: void HSyncCallback(Event *);
1.1 root 158:
1.1.1.8 root 159: // ラスターコピー完了イベント
1.1.1.13 root 160: void RasterCallback(Event *);
1.1.1.8 root 161:
1.1 root 162: // 垂直表示期間イベント
1.1.1.13 root 163: void VDispCallback(Event *);
1.1 root 164:
1.1.1.14! root 165: DECLARE_MONITOR_SCREEN(MonitorScreen);
1.1.1.7 root 166:
1.1 root 167: struct CRTC crtc {};
168:
1.1.1.8 root 169: // ラスターコピー指示
170: bool raster_copy {};
171:
1.1.1.13 root 172: // XXX もうちょっとなんとかする
173: uint hsync_state {};
174: uint vdisp_state {};
175:
1.1.1.9 root 176: MFPDevice *mfp {};
177: TVRAMDevice *tvram {};
1.1.1.12 root 178: VideoCtlrDevice *videoctlr {};
1.1.1.9 root 179:
1.1.1.13 root 180: Event *hsync_event {};
181: Event *vdisp_event {};
182: Event *raster_event {};
1.1.1.7 root 183:
1.1.1.12 root 184: Monitor *monitor {};
1.1.1.13 root 185:
186: static const busdata wait;
1.1 root 187: };
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.