|
|
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.15 root 13: #include "romemu.h"
1.1 root 14:
1.1.1.13 root 15: class BT45xDevice;
1.1.1.15 root 16: class LanceDevice;
1.1.1.13 root 17: class LunafbDevice;
18: class MainRAMDevice;
19: class MK48T02Device;
20: class SIODevice;
21: class SPCDevice;
22:
1.1.1.15 root 23: class LunaPROMEmuDevice : public ROMEmuDevice
1.1 root 24: {
1.1.1.15 root 25: using inherited = ROMEmuDevice;
1.1 root 26:
1.1.1.7 root 27: protected:
1.1 root 28: // このデバイス先頭アドレス
29: static const uint32 baseaddr = 0x41000000;
30:
31: // 謎の I/O 空間
1.1.1.2 root 32: static const uint32 ROMIO_BASE = 0x41010000;
1.1.1.14 root 33: static const uint32 ROMIO_INIT = (ROMIO_BASE + 0x00);
34: static const uint32 ROMIO_LOAD = (ROMIO_BASE + 0x04);
35: static const uint32 ROMIO_KEYIN = (ROMIO_BASE + 0x08);
36: static const uint32 ROMIO_CLOSE = (ROMIO_BASE + 0x0c);
37: static const uint32 ROMIO_ENTRY = (ROMIO_BASE + 0x10);
38: static const uint32 ROMIO_AP1 = (ROMIO_BASE + 0x14);
39: static const uint32 ROMIO_AP2 = (ROMIO_BASE + 0x18);
40: static const uint32 ROMIO_CLKCNT = (ROMIO_BASE + 0x1c);
1.1.1.16! root 41: static const uint32 ROMIO_QUITSTOP = (ROMIO_BASE + 0x20);
1.1 root 42:
1.1.1.9 root 43: // 文字コード
44: // 概ね ASCII だが制御コード部分は必要な文字だけを適当に割り当てる。
45: static const char BS = 0x08;
46: static const char LF = 0x0a;
1.1.1.14 root 47: static const char CR = 0x0d;
1.1.1.9 root 48: static const char UP = 0x1c;
49: static const char LEFT = 0x1d;
50: static const char RIGHT = 0x1e;
51: static const char DOWN = 0x1f;
52:
1.1.1.7 root 53: // ブート情報格納用
54: struct bootinfo_t {
55: int dkunit {};
56: int dkpart {};
57: std::string dkfile {};
58: };
59:
1.1 root 60: public:
61: LunaPROMEmuDevice();
1.1.1.14 root 62: ~LunaPROMEmuDevice() override;
1.1 root 63:
1.1.1.2 root 64: bool Init() override;
1.1 root 65:
1.1.1.7 root 66: protected:
1.1.1.15 root 67: uint64 ReadROMIO(busaddr addr) override;
68: bool WriteROMIO(busaddr addr, uint32 data) override;
69:
70: void ROM_Init();
1.1.1.14 root 71: virtual void ROM_InitMD() = 0;
72: uint32 ROM_Load();
73: uint32 ROM_Entry();
1.1.1.7 root 74: virtual void ROM_Close();
1.1.1.14 root 75: void ROM_AP1();
76: void ROM_AP2();
77: virtual uint32 LoadFile(const std::string& fname) = 0;
1.1.1.13 root 78: virtual void ProcessChar(char);
1.1.1.7 root 79: virtual void Command() = 0;
1.1 root 80:
1.1.1.12 root 81: void InitScreen();
1.1.1.14 root 82: void InitPalette();
83: void PrintTitle();
1.1.1.9 root 84: void ClearPrompt();
1.1.1.13 root 85: int Getc();
1.1.1.12 root 86: void Putc(uint ch);
87: void Print(const std::string& s);
88: void Print(const char *fmt, ...) __printflike(2, 3);
1.1.1.9 root 89:
90: // NVRAM
1.1.1.14 root 91: virtual bool InitNVRAM() = 0;
92: virtual void GetNVRAM(bootinfo_t&) = 0;
1.1.1.9 root 93: uint8 CalcNVRAMCsum() const;
94: void WriteNVRAMCsum();
95: bool VerifyNVRAM() const;
96:
1.1 root 97: uint32 LoadHostFile();
1.1.1.7 root 98: uint32 LoadGuestFile(const bootinfo_t&);
1.1.1.2 root 99:
1.1.1.14 root 100: // 読み込んだプログラムのエントリポイント。
101: // エントリポイントがセットされていない時は -1。
102: uint32 entrypoint {};
103:
104: // エントリポイントに実行を移す時には true。
105: // LUNA-I は 'x' コマンドを実行したら。
106: // LUNA-88K では 'b'/'bh' コマンドで。
107: bool execute {};
108:
109: // 機種名 (タイトル表示用)
110: const char *machine_name {};
111:
1.1 root 112: // エラーメッセージの受け渡し用
113: // 基本的にエラーが起きた時だけ更新するので、ここにエラーメッセージを
114: // 返す可能性がある関数をコールする前に呼び出し側が clear() しておき、
115: // 関数から戻ったら empty() かどうか確認する、errno みたいな使い方。
1.1.1.4 root 116: std::string errmsg {};
1.1 root 117:
118: // 入力バッファ
119: std::string inputbuf {};
120:
1.1.1.7 root 121: // 現在のプロンプト文字列
122: std::string prompt {};
1.1 root 123:
1.1.1.11 root 124: // デフォルトプロンプト。
125: const std::string default_prompt = ">";
126:
1.1.1.9 root 127: // プロンプトのある行(最上行が 0)
128: int prompt_y {};
129:
130: // カーソル位置(入力バッファ先頭が0)
131: int inputpos {};
132:
1.1.1.12 root 133: int screen_w {}; // テキスト桁数
134: int screen_h {}; // テキスト行数
135: int cursor_x {}; // カーソル位置(桁)
136: int cursor_y {}; // カーソル位置(行)
1.1.1.14 root 137: bool cursor_on {}; // カーソル表示
138: bool bold {};
1.1.1.12 root 139: int origin_px {}; // テキスト画面の左上 X 座標(ピクセル)
140: int origin_py {}; // テキスト画面の左上 Y 座標(ピクセル)
141:
1.1.1.13 root 142: BT45xDevice *bt45x {};
1.1.1.15 root 143: LanceDevice *lance {};
1.1.1.13 root 144: LunafbDevice *lunafb {};
145: MainRAMDevice *mainram {};
1.1.1.4 root 146: MK48T02Device *nvram {};
1.1.1.13 root 147: SIODevice *sio {};
148: SPCDevice *spc {};
1.1 root 149:
1.1.1.7 root 150: private:
151: // キー入力
152: void ROM_Keyin();
153:
154: bool is_shift {}; // SHIFT キー押し下げ中
155: int mousecnt {}; // マウス入力をスキップするためのカウンタ
156:
1.1.1.14 root 157: uint32 clkcnt {}; // クロック割り込みカウンタ
158:
1.1.1.16! root 159: // luna88k で割り込みからジャンプして戻る時のアドレス。
! 160: // 0 なら作用しない。
! 161: uint32 quitstop {};
! 162:
1.1 root 163: // LUNA キーコード -> ASCII 変換テーブル
164: static const uint8 lunakey2asciitable[128];
165: static const uint8 lunakey2shifttable[128];
166: };
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.