--- nono/m88xx0/m88100.h 2026/04/29 17:04:46 1.1.1.6 +++ nono/m88xx0/m88100.h 2026/04/29 17:04:52 1.1.1.8 @@ -167,12 +167,14 @@ 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() const { return total_vtime + Cycle2Vtime(used_cycle); } @@ -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 {}; // リクエストフラグ @@ -297,12 +299,12 @@ 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; } // 今のところサイクルを正確に実装するのは無理なので @@ -310,13 +312,13 @@ OP_PROTO(illegal); 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 {}; - // 例外名 static const char * const exception_names[]; };