From 101c493b88430f0bc2ac76a10f8492d44c620b19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Magalh=C3=A3es?= Date: Mon, 2 Sep 2024 02:20:24 +0100 Subject: [PATCH] chore: moved tick calculus to emukit --- frontends/web/ts/gb.ts | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/frontends/web/ts/gb.ts b/frontends/web/ts/gb.ts index 89382abd..c2330407 100644 --- a/frontends/web/ts/gb.ts +++ b/frontends/web/ts/gb.ts @@ -18,7 +18,6 @@ import { SaveState, SectionInfo, Size, - TickMode, TickParams, Validation } from "emukit"; @@ -201,26 +200,9 @@ export class GameboyEmulator extends EmulatorLogic implements Emulator { // returns the control flow immediately (not possible to tick) if (!this.gameBoy) return; - // calculates the number of cycles that are going to be - // processed in the current tick operation, this value is - // calculated using the logic and visual frequencies and - // the current Game Boy multiplier (DMG vs CGB) - let tickCycles = 0; - switch (params.mode) { - case TickMode.Synced: - tickCycles = Math.round( - (this.logicFrequency * (this.gameBoy?.multiplier() ?? 1)) / - this.visualFrequency - ); - break; - case TickMode.Desynced: - tickCycles = Math.round( - this.logicFrequency * - (this.gameBoy?.multiplier() ?? 1) * - ((params.elapsedTime ?? 1000) / 1000) - ); - break; - } + // uses the Game Boy multiplier to re-calculate the number + // of cycles to be used for the tick + const tickCycles = params.cycles * (this.gameBoy?.multiplier() ?? 1); // calculates the target cycles for clocking in the current // tick operation, this is the ideal value and the concrete