--- nono/vm/romemu_luna.h 2026/04/29 17:04:59 1.1.1.10 +++ nono/vm/romemu_luna.h 2026/04/29 17:05:18 1.1.1.13 @@ -4,10 +4,21 @@ // Licensed under nono-license.txt // +// +// LUNA シリーズの ROM エミュレーション共通部分 +// + #pragma once #include "rom.h" +class BT45xDevice; +class LunafbDevice; +class MainRAMDevice; +class MK48T02Device; +class SIODevice; +class SPCDevice; + class LunaPROMEmuDevice : public ROMDevice { using inherited = ROMDevice; @@ -51,13 +62,17 @@ class LunaPROMEmuDevice : public ROMDevi virtual uint32 ROM_Init() = 0; virtual uint32 ROM_Entry() = 0; virtual void ROM_Close(); - virtual void GetChar(char); + virtual void ProcessChar(char); virtual void Command() = 0; void InitDevice(); - void InitScreen(const char *machine_name); + void InitScreen(); + void PrintTitle(const char *machine_name); void ClearPrompt(); - void ConsoleUpdate(); + int Getc(); + void Putc(uint ch); + void Print(const std::string& s); + void Print(const char *fmt, ...) __printflike(2, 3); // NVRAM uint8 CalcNVRAMCsum() const; @@ -73,26 +88,34 @@ class LunaPROMEmuDevice : public ROMDevi // 関数から戻ったら empty() かどうか確認する、errno みたいな使い方。 std::string errmsg {}; - // ROM モニタ用コンソール画面 - TextScreen text {}; - // 入力バッファ std::string inputbuf {}; // 現在のプロンプト文字列 std::string prompt {}; + // デフォルトプロンプト。 + const std::string default_prompt = ">"; + // プロンプトのある行(最上行が 0) int prompt_y {}; // カーソル位置(入力バッファ先頭が0) int inputpos {}; - // NVRAM - // 本来他デバイスはすべてグローバル参照できるのだが、LUNA の NVRAM は - // RTC と兼用になっていて、RTCDevice *gRTC として見えるので - // MK48T02Device にするには dynamic_cast する必要がある。 + int screen_w {}; // テキスト桁数 + int screen_h {}; // テキスト行数 + int cursor_x {}; // カーソル位置(桁) + int cursor_y {}; // カーソル位置(行) + int origin_px {}; // テキスト画面の左上 X 座標(ピクセル) + int origin_py {}; // テキスト画面の左上 Y 座標(ピクセル) + + BT45xDevice *bt45x {}; + LunafbDevice *lunafb {}; + MainRAMDevice *mainram {}; MK48T02Device *nvram {}; + SIODevice *sio {}; + SPCDevice *spc {}; private: // キー入力