|
|
1.1 root 1: //
2: // nono
1.1.1.3 root 3: // Copyright (C) 2020 nono project
4: // Licensed under nono-license.txt
1.1 root 5: //
6:
7: #pragma once
8:
9: #include "device.h"
1.1.1.3 root 10: #include <atomic>
1.1 root 11:
12: class BitmapDevice
13: : public IODevice
14: {
1.1.1.3 root 15: using inherited = IODevice;
1.1 root 16:
17: static const uint32 plane0base = 0xb10c0000;
18: static const uint32 plane7end = 0xb12c0000;
19: static const uint32 fcset0base = 0xb1300000;
20: static const uint32 fcset7end = 0xb1500000;
21: public:
22: BitmapDevice();
1.1.1.6 root 23: virtual ~BitmapDevice() override;
1.1 root 24:
1.1.1.7 ! root 25: bool Init() override;
! 26: bool PowerOn() override;
1.1.1.3 root 27: void ResetHard() override;
1.1 root 28:
1.1.1.3 root 29: uint64 Read8(uint32 addr) override;
30: uint64 Read16(uint32 addr) override;
31: uint64 Read32(uint32 addr) override;
32: uint64 Write8(uint32 addr, uint32 data) override;
33: uint64 Write16(uint32 addr, uint32 data) override;
34: uint64 Write32(uint32 addr, uint32 data) override;
35: uint64 Peek8(uint32 addr) override;
1.1.1.4 root 36: void MonitorUpdate(TextScreen&) override;
1.1 root 37:
38: // プレーン数を取得
39: int GetPlaneCount() const { return nplane; }
40:
41: // RFCNT によるオフセットを取得 (レンダラ用)
42: void GetRFCNT(int *h, int *v) const {
43: *h = hscroll;
44: *v = vscroll;
45: }
46:
47: // ビットマップのアドレスを取得
1.1.1.2 root 48: const uint8 *GetBuf() const { return mem.get(); }
1.1 root 49:
50: // 更新フラグのアドレスを取得
51: std::atomic<uint8> *GetDirty() { return atomic_dirty; }
52:
1.1.1.2 root 53: // エミュレータによる出力
54: void EmuConsoleOpen(TextScreen *t);
55: void EmuConsoleUpdate();
56: void EmuConsoleClose();
57:
1.1 root 58: private:
59: void Invalidate();
60: void WriteRFCNT(uint32);
61: void WriteCommonBitmap8(uint32, uint32);
62: void WriteCommonBitmap16(uint32, uint32);
63: void WriteCommonBitmap32(uint32, uint32);
64: void WritePlane8(uint, uint32, uint32);
65: void WritePlane16(uint, uint32, uint32);
66: void WritePlane32(uint, uint32, uint32);
67:
68: // ROP 文字列を返す
69: static const char *RopStr(uint rop);
70:
71: // プレーン数の上限
72: static const int MAX_PLANES = 8;
73:
74: // プレーン数 (設定による)
1.1.1.5 root 75: int nplane {};
1.1 root 76:
77: // RFCNT
78: // b31..b24 b23..b16 b15..b10 b09..b00
79: // 無効 水平カウンタ 無効 ラスタカウンタ
1.1.1.5 root 80: uint32 rfcnt {};
81: int hscroll {};
82: int vscroll {};
1.1 root 83:
84: // プレーンセレクタ
85: // b31...b4 b3 b2 b1 b0
86: // <-無効-> | | | +-- プレーン0 (%1=同時設定/書き込み有効、%0=無効)
87: // | | +----- プレーン1
88: // | +-------- プレーン2
89: // +----------- プレーン3
1.1.1.5 root 90: uint32 bmsel {};
1.1 root 91:
92: // ビットマッププレーン。
93: // ロングワードでホストバイトオーダー。
94: // 1枚が 256KB。1 or 4枚
1.1.1.2 root 95: std::unique_ptr<uint8[]> mem {};
1.1 root 96:
97: // 更新フラグ。
98: // 更新があったラインは 1、なければ 0。
99: // 1ラインごとなので 1プレーンにつき 1024 エントリ。
100: // XXX 水平の非描画区間は今の所検出していないので描画側で多少無駄足。
101: std::atomic<uint8> atomic_dirty[1024] {};
102:
103: // ファンクションセットとアクセスマスク
104: u_int fcs[MAX_PLANES] {};
105: uint32 mask[MAX_PLANES] {};
1.1.1.2 root 106:
107: // エミュレータによるコンソール出力
1.1.1.5 root 108: TextScreen *textscr {};
1.1.1.7 ! root 109: std::vector<uint16> prev {};
1.1.1.5 root 110: int screen_w {}; // 桁数
111: int screen_h {}; // 行数
112: int origin_x {}; // 原点 X [dot]
113: int origin_y {}; // 原点 Y [dot]
1.1 root 114: };
115:
1.1.1.2 root 116: extern std::unique_ptr<BitmapDevice> gBitmap;
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.