|
|
1.1 root 1: //
2: // nono
1.1.1.2 root 3: // Copyright (C) 2020 nono project
4: // Licensed under nono-license.txt
1.1 root 5: //
6:
1.1.1.12 root 7: //
8: // LUNA シリーズの ROM エミュレーション共通部分
9: //
10:
1.1 root 11: #pragma once
12:
1.1.1.10 root 13: #include "rom.h"
1.1 root 14:
1.1.1.13! root 15: class BT45xDevice;
! 16: class LunafbDevice;
! 17: class MainRAMDevice;
! 18: class MK48T02Device;
! 19: class SIODevice;
! 20: class SPCDevice;
! 21:
1.1.1.10 root 22: class LunaPROMEmuDevice : public ROMDevice
1.1 root 23: {
1.1.1.10 root 24: using inherited = ROMDevice;
1.1 root 25:
1.1.1.7 root 26: protected:
1.1 root 27: // このデバイス先頭アドレス
28: static const uint32 baseaddr = 0x41000000;
29:
30: // 謎の I/O 空間
1.1.1.2 root 31: static const uint32 ROMIO_BASE = 0x41010000;
32: static const uint32 ROMIO_INIT = (ROMIO_BASE + 0);
33: static const uint32 ROMIO_KEYIN = (ROMIO_BASE + 4);
34: static const uint32 ROMIO_CLOSE = (ROMIO_BASE + 8);
1.1.1.6 root 35: static const uint32 ROMIO_ENTRY = (ROMIO_BASE + 12);
1.1 root 36:
1.1.1.9 root 37: // 文字コード
38: // 概ね ASCII だが制御コード部分は必要な文字だけを適当に割り当てる。
39: static const char BS = 0x08;
40: static const char LF = 0x0a;
41: static const char UP = 0x1c;
42: static const char LEFT = 0x1d;
43: static const char RIGHT = 0x1e;
44: static const char DOWN = 0x1f;
45:
1.1.1.7 root 46: // ブート情報格納用
47: struct bootinfo_t {
48: int dkunit {};
49: int dkpart {};
50: std::string dkfile {};
51: };
52:
1.1 root 53: public:
54: LunaPROMEmuDevice();
1.1.1.5 root 55: virtual ~LunaPROMEmuDevice() override;
1.1 root 56:
1.1.1.2 root 57: bool Init() override;
1.1 root 58:
1.1.1.2 root 59: uint64 Read32(uint32 addr) override;
1.1 root 60:
1.1.1.7 root 61: protected:
62: virtual uint32 ROM_Init() = 0;
63: virtual uint32 ROM_Entry() = 0;
64: virtual void ROM_Close();
1.1.1.13! root 65: virtual void ProcessChar(char);
1.1.1.7 root 66: virtual void Command() = 0;
1.1 root 67:
1.1.1.7 root 68: void InitDevice();
1.1.1.12 root 69: void InitScreen();
70: void PrintTitle(const char *machine_name);
1.1.1.9 root 71: void ClearPrompt();
1.1.1.13! root 72: int Getc();
1.1.1.12 root 73: void Putc(uint ch);
74: void Print(const std::string& s);
75: void Print(const char *fmt, ...) __printflike(2, 3);
1.1.1.9 root 76:
77: // NVRAM
78: uint8 CalcNVRAMCsum() const;
79: void WriteNVRAMCsum();
80: bool VerifyNVRAM() const;
81:
1.1 root 82: uint32 LoadHostFile();
1.1.1.7 root 83: uint32 LoadGuestFile(const bootinfo_t&);
1.1.1.2 root 84:
1.1 root 85: // エラーメッセージの受け渡し用
86: // 基本的にエラーが起きた時だけ更新するので、ここにエラーメッセージを
87: // 返す可能性がある関数をコールする前に呼び出し側が clear() しておき、
88: // 関数から戻ったら empty() かどうか確認する、errno みたいな使い方。
1.1.1.4 root 89: std::string errmsg {};
1.1 root 90:
91: // 入力バッファ
92: std::string inputbuf {};
93:
1.1.1.7 root 94: // 現在のプロンプト文字列
95: std::string prompt {};
1.1 root 96:
1.1.1.11 root 97: // デフォルトプロンプト。
98: const std::string default_prompt = ">";
99:
1.1.1.9 root 100: // プロンプトのある行(最上行が 0)
101: int prompt_y {};
102:
103: // カーソル位置(入力バッファ先頭が0)
104: int inputpos {};
105:
1.1.1.12 root 106: int screen_w {}; // テキスト桁数
107: int screen_h {}; // テキスト行数
108: int cursor_x {}; // カーソル位置(桁)
109: int cursor_y {}; // カーソル位置(行)
110: int origin_px {}; // テキスト画面の左上 X 座標(ピクセル)
111: int origin_py {}; // テキスト画面の左上 Y 座標(ピクセル)
112:
1.1.1.13! root 113: BT45xDevice *bt45x {};
! 114: LunafbDevice *lunafb {};
! 115: MainRAMDevice *mainram {};
1.1.1.4 root 116: MK48T02Device *nvram {};
1.1.1.13! root 117: SIODevice *sio {};
! 118: SPCDevice *spc {};
1.1 root 119:
1.1.1.7 root 120: private:
121: // キー入力
122: void ROM_Keyin();
123:
124: bool is_shift {}; // SHIFT キー押し下げ中
125: int mousecnt {}; // マウス入力をスキップするためのカウンタ
126:
1.1 root 127: // LUNA キーコード -> ASCII 変換テーブル
128: static const uint8 lunakey2asciitable[128];
129: static const uint8 lunakey2shifttable[128];
130: };
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.