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