|
|
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();
1.1.1.5 ! root 50: ~LunafbDevice() override;
1.1 root 51:
52: bool Init() override;
1.1.1.2 root 53: void ResetHard(bool poweron) override;
1.1 root 54:
1.1.1.5 ! root 55: busdata Read8(uint32 addr) override;
! 56: busdata Read16(uint32 addr) override;
! 57: busdata Read32(uint32 addr) override;
! 58: busdata Write8(uint32 addr, uint32 data) override;
! 59: busdata Write16(uint32 addr, uint32 data) override;
! 60: busdata Write32(uint32 addr, uint32 data) override;
! 61: busdata Peek8(uint32 addr) override;
! 62: bool Poke8(uint32 addr, uint32 data) override;
1.1.1.4 root 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.1.5 ! root 72: void SetBMSEL(uint8 bmsel_) { bmsel = bmsel_; }
1.1 root 73:
74: private:
1.1.1.2 root 75: // offset の VRAM が変更されたことを記録する
76: inline void SetDirty(uint32 offset);
77:
1.1.1.4 root 78: // X 方向にはみ出したときに対応する仮想画面の Y 座標を返す。
79: int GetWrapY(int y) const override;
80:
1.1 root 81: void WriteRFCNT(uint32);
82: void WriteCommonBitmap8(uint32, uint32);
83: void WriteCommonBitmap16(uint32, uint32);
84: void WriteCommonBitmap32(uint32, uint32);
1.1.1.2 root 85: void WriteCommonFCSet(uint rop, uint32 data);
1.1 root 86: void WritePlane8(uint, uint32, uint32);
87: void WritePlane16(uint, uint32, uint32);
88: void WritePlane32(uint, uint32, uint32);
89:
90: DECLARE_MONITOR_CALLBACK(MonitorUpdate);
91:
1.1.1.2 root 92: // 演算
93: static uint32 RasterOp(uint rop, uint32 vram, uint32 data);
94:
1.1 root 95: // ROP 文字列を返す
96: static const char *RopStr(uint rop);
97:
98: // 現在のプレーン数でのプレーンの終了アドレス
99: uint32 plane_end {};
1.1.1.3 root 100: // 現在のプレーン数での FCSet の(ブロック単位での)最終アドレス
101: uint32 fcset_end {};
1.1 root 102:
103: // RFCNT
1.1.1.2 root 104: //
105: // 3 2 1 0
106: // 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
107: // +---------------+---------------+-----------+---+---------------+
108: // | 無効 | 水平カウンタ | 無効 | ラスタカウンタ |
109: // +---------------+---------------+-----------+---+---------------+
1.1 root 110: uint32 rfcnt {};
1.1.1.2 root 111: // 親クラスにある
112: // int xscroll {};
113: // int yscroll {};
1.1 root 114:
115: // プレーンセレクタ
1.1.1.2 root 116: //
117: // 3 2 1 0
118: // 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
119: // +---------------+---------------+---------------+-------+-+-+-+-+
120: // | 無効 |3|2|1|0|
121: // +---------------+---------------+---------------+-------+-+-+-+-+
122: // | | | |
123: // プレーンN (%1 = 同時設定/書き込み有効、%0=無効) --------+-+-+-+
1.1 root 124:
1.1.1.2 root 125: uint32 bmsel {};
1.1 root 126:
127: // ファンクションセットとアクセスマスク
1.1.1.2 root 128: uint fcset[MAX_PLANES] {};
129: uint32 fcmask[MAX_PLANES] {};
1.1 root 130:
1.1.1.5 ! root 131: // ウェイト [nsec]
! 132: busdata wait {};
! 133:
1.1 root 134: Monitor monitor { this };
135: };
136:
1.1.1.4 root 137: static inline LunafbDevice *GetLunafbDevice() {
138: return Object::GetObject<LunafbDevice>(OBJ_PLANEVRAM);
139: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.