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