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