|
|
1.1 root 1: //
2: // nono
3: // Copyright (C) 2020 nono project
4: // Licensed under nono-license.txt
5: //
6:
1.1.1.2 root 7: //
8: // LUNA ビットマッププレーン
9: //
10:
1.1 root 11: #pragma once
12:
1.1.1.2 root 13: #include "planevram.h"
1.1 root 14: #include "monitor.h"
15:
1.1.1.2 root 16: // VRAM の ROP (定数)
17: struct ROP {
18: static const uint ZERO = 0; // 0
19: static const uint AND1 = 1; // vram & data
20: static const uint AND2 = 2; // vram & ~data
21: static const uint cmd = 3;
22: static const uint AND3 = 4; // ~vram & data
23: static const uint THRU = 5; // data
24: static const uint EOR = 6; // vram ^ data
25: static const uint OR1 = 7; // vram | data
26: static const uint NOR = 8; // ~vram | ~data
27: static const uint ENOR = 9; // (vram & data) | (~vram & ~data)
28: static const uint INV1 = 10; // ~data
29: static const uint OR2 = 11; // vram | ~data
30: static const uint INV2 = 12; // ~vram
31: static const uint OR3 = 13; // ~vram | data
32: static const uint NAND = 14; // ~vram | ~data
33: static const uint ONE = 15; // 1
34: };
35:
36: class LunafbDevice : public PlaneVRAMDevice
1.1 root 37: {
1.1.1.2 root 38: using inherited = PlaneVRAMDevice;
1.1 root 39:
40: static const uint32 plane0base = 0xb10c0000;
41: static const uint32 plane7end = 0xb12c0000;
42: static const uint32 fcset0base = 0xb1300000;
43: static const uint32 fcset7end = 0xb1500000;
1.1.1.2 root 44:
45: // プレーン数の上限
46: static const int MAX_PLANES = 8;
47:
1.1 root 48: public:
49: LunafbDevice();
50: virtual ~LunafbDevice() override;
51:
52: bool Init() override;
1.1.1.2 root 53: void ResetHard(bool poweron) override;
1.1 root 54:
55: uint64 Read8(uint32 addr) override;
56: uint64 Read16(uint32 addr) override;
57: uint64 Read32(uint32 addr) override;
58: uint64 Write8(uint32 addr, uint32 data) override;
59: uint64 Write16(uint32 addr, uint32 data) override;
60: uint64 Write32(uint32 addr, uint32 data) override;
61: uint64 Peek8(uint32 addr) override;
1.1.1.4 ! root 62: uint64 Poke8(uint32 addr, uint32 data) override;
! 63:
! 64: void UpdateInfo(TextScreen&, int x, int y) const override;
1.1 root 65:
66: // エミュレータによる出力
1.1.1.2 root 67: void EmuInitScreen();
68: void EmuFill(uint x, uint y, uint w, uint h, uint32 data);
69: void EmuPutc(uint x, uint y, uint c);
70: void EmuPutc(uint x, uint y, uint c, int rop);
71: void EmuScrollY(uint dy, uint sy, uint h);
1.1 root 72:
73: private:
1.1.1.2 root 74: // offset の VRAM が変更されたことを記録する
75: inline void SetDirty(uint32 offset);
76:
1.1.1.4 ! root 77: // X 方向にはみ出したときに対応する仮想画面の Y 座標を返す。
! 78: int GetWrapY(int y) const override;
! 79:
1.1 root 80: void WriteRFCNT(uint32);
81: void WriteCommonBitmap8(uint32, uint32);
82: void WriteCommonBitmap16(uint32, uint32);
83: void WriteCommonBitmap32(uint32, uint32);
1.1.1.2 root 84: void WriteCommonFCSet(uint rop, uint32 data);
1.1 root 85: void WritePlane8(uint, uint32, uint32);
86: void WritePlane16(uint, uint32, uint32);
87: void WritePlane32(uint, uint32, uint32);
88:
89: DECLARE_MONITOR_CALLBACK(MonitorUpdate);
90:
1.1.1.2 root 91: // 演算
92: static uint32 RasterOp(uint rop, uint32 vram, uint32 data);
93:
1.1 root 94: // ROP 文字列を返す
95: static const char *RopStr(uint rop);
96:
97: // 現在のプレーン数でのプレーンの終了アドレス
98: uint32 plane_end {};
1.1.1.3 root 99: // 現在のプレーン数での FCSet の(ブロック単位での)最終アドレス
100: uint32 fcset_end {};
1.1 root 101:
102: // RFCNT
1.1.1.2 root 103: //
104: // 3 2 1 0
105: // 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
106: // +---------------+---------------+-----------+---+---------------+
107: // | 無効 | 水平カウンタ | 無効 | ラスタカウンタ |
108: // +---------------+---------------+-----------+---+---------------+
1.1 root 109: uint32 rfcnt {};
1.1.1.2 root 110: // 親クラスにある
111: // int xscroll {};
112: // int yscroll {};
1.1 root 113:
114: // プレーンセレクタ
1.1.1.2 root 115: //
116: // 3 2 1 0
117: // 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
118: // +---------------+---------------+---------------+-------+-+-+-+-+
119: // | 無効 |3|2|1|0|
120: // +---------------+---------------+---------------+-------+-+-+-+-+
121: // | | | |
122: // プレーンN (%1 = 同時設定/書き込み有効、%0=無効) --------+-+-+-+
1.1 root 123:
1.1.1.2 root 124: uint32 bmsel {};
1.1 root 125:
126: // ファンクションセットとアクセスマスク
1.1.1.2 root 127: uint fcset[MAX_PLANES] {};
128: uint32 fcmask[MAX_PLANES] {};
1.1 root 129:
130: Monitor monitor { this };
131: };
132:
1.1.1.4 ! root 133: static inline LunafbDevice *GetLunafbDevice() {
! 134: return Object::GetObject<LunafbDevice>(OBJ_PLANEVRAM);
! 135: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.