--- nono/m88xx0/m88100.h 2026/04/29 17:04:44 1.1.1.5 +++ nono/m88xx0/m88100.h 2026/04/29 17:04:57 1.1.1.10 @@ -167,15 +167,17 @@ class m88kcpu : public m88100reg }; public: - m88kcpu(uint32 reset_vector_); + m88kcpu(); virtual ~m88kcpu(); + void PowerOn(); + void RequestReset(); + uint32 Run(uint32 delta); void Release(); - void RequestReset(); // 仮想時刻を返す - uint64 GetVTime(); + uint64 GetVTime() const { return total_vtime + Cycle2Vtime(used_cycle); } // 割り込み信号線が変化したことの通知を受ける。 // level は 0 か 1。 @@ -210,7 +212,7 @@ class m88kcpu : public m88100reg void AddCycle(int32 wait) { used_cycle += wait; } // MPU クロックを設定 - void SetClockSpeed(uint32 clock_khz_) { clock_khz = clock_khz_; } + void SetClockSpeed(uint32 clock_khz_); std::atomic atomic_reqflag {}; // リクエストフラグ @@ -219,9 +221,9 @@ class m88kcpu : public m88100reg m88200 cmmu[2] {}; // ブランチ履歴 (例外履歴を含む) - BranchHistory_m88xx0 brhist {}; + BranchHistory_m88xx0 brhist { BranchHistory::BrHist }; // 例外履歴のみ - BranchHistory_m88xx0 exhist {}; + BranchHistory_m88xx0 exhist { BranchHistory::ExHistOnly }; // 32bit 命令コードからディスパッチ用の 12bit に変換。 static uint32 op32_to_12(uint32 op) { @@ -231,6 +233,12 @@ class m88kcpu : public m88100reg // 例外名を返す static const char *GetExceptionName(int vector); + // 疑似 STOP 状態に入る機能を有効にする場合 true + bool pseudo_stop_enable {}; + + // DOS call エミュレーションコールバックを設定する + void SetFLineCallback(bool (*callback)(m88kcpu *, void *), void *arg); + private: void Reset(); @@ -297,28 +305,29 @@ OP_PROTO(illegal); // サイクル数を仮想時間 [nsec] に変換 uint64 Cycle2Vtime(int32 cycle) const { - return (int64)cycle * 1000 * 1000 / clock_khz; + return (int64)cycle * c2v; } // 仮想時間 [nsec] をサイクル数に変換 uint32 Vtime2Cycle(uint32 vtime) const { - return (uint32)((uint64)vtime * clock_khz / (1000 * 1000)); + return ((uint64)vtime * v2c_factor) >> v2c_shift; } - // 仕掛中のサイクルを仮想時刻に反映させる - void UpdateVTime(); - // 今のところサイクルを正確に実装するのは無理なので // 適当に全部積み上げてある。 uint32 used_cycle {}; // 現在のターンでこれまでに消費したサイクル数 uint32 goal_cycle {}; // 現在のターンで消費すべきサイクル数 uint32 clock_khz {}; // MPU クロック [kHz] + uint32 c2v {}; // サイクル数を nsec に変換する際の係数 + uint64 v2c_factor {}; // nsec をサイクル数に変換する際の乗算係数 + uint32 v2c_shift {}; // nsec をサイクル数に変換する際のシフト係数 // ペンディング中の割り込みレベル int intr_pending {}; - // リセットベクタ - uint32 reset_vector {}; + // DOS call エミュレーション + bool (*fline_callback)(m88kcpu *, void *) = NULL; + void *fline_arg {}; // 例外名 static const char * const exception_names[];