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