--- nono/vm/vm.h 2026/04/29 17:05:13 1.1.1.10 +++ nono/vm/vm.h 2026/04/29 17:05:49 1.1.1.15 @@ -12,63 +12,47 @@ #include "device.h" -// ヘッダの依存関係を減らすための細工。 -// o pNAME はメンバ変数としてヘッダで宣言してあるが、vm*.h で各デバイスヘッダ -// を include したくないので、派生型ではなく Device* の unique_ptr にしたい。 -// o gNAME は各デバイスヘッダが持つ派生型のグローバルポインタ。 -// ベース型ではなく派生型で参照したい。また使いたい人が使いたいヘッダだけを -// include すれば済むよう、vm*.h とは切り離したい。 -#define NEWDV(NAME, NEW_CTOR) do { \ - __CONCAT(p,NAME).reset(NEW_CTOR); \ - __CONCAT(g,NAME) = \ - (decltype(__CONCAT(g,NAME)))(__CONCAT(p,NAME).get()); \ -} while (0) - class VM { + protected: + explicit VM(const char *vmname_); + public: + enum CreationPhase : bool { + First = false, + Second = true, + }; + public: - VM(); virtual ~VM(); // 明示的な後始末 void Dispose(); // 動的なコンストラクション - bool Create(); + bool Create(CreationPhase); // 初期化 - virtual bool Init(); + bool Init(); // スレッド開始 bool StartThread(); - // 設定の適用 - bool Apply(); - - // ブートページを ROM に切り替える - void SwitchBootPageToROM(Device *parent) { SwitchBootPage(parent, true); } - // ブートページを RAM に切り替える - void SwitchBootPageToRAM(Device *parent) { SwitchBootPage(parent, false); } - - // MPU の RESET 命令によるリセット (機種ごとに異なるため) - virtual void ResetByMPU(); + // VM 名取得 (ウィンドウタイトル用) + const char *GetVMName() const { return vmname; } protected: - // ブートページを切り替える (内部用) - virtual void SwitchBootPage(Device *parent, bool isrom); - - std::unique_ptr pBusErr {}; std::unique_ptr pDebugger {}; - std::unique_ptr pInterrupt {}; + std::unique_ptr pEventManager {}; std::unique_ptr pKeyboard {}; + std::unique_ptr pMainbus {}; std::unique_ptr pMPU {}; std::unique_ptr pNMI {}; std::unique_ptr pPower {}; std::unique_ptr pRenderer {}; - std::unique_ptr pRAM {}; std::unique_ptr pScheduler {}; std::unique_ptr pSignalThread {}; - std::unique_ptr pSync {}; -}; + std::unique_ptr pSyncer {}; -extern VM *gVM; + private: + const char *vmname {}; // VM 機種名(表示名) +};