Annotation of nono/vm/romemu_luna.h, revision 1.1.1.12

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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.