Skip to content

Commit

Permalink
chore: moved tick calculus to emukit
Browse files Browse the repository at this point in the history
  • Loading branch information
joamag committed Sep 2, 2024
1 parent f30753a commit 101c493
Showing 1 changed file with 3 additions and 21 deletions.
24 changes: 3 additions & 21 deletions frontends/web/ts/gb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import {
SaveState,
SectionInfo,
Size,
TickMode,
TickParams,
Validation
} from "emukit";
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 101c493

Please sign in to comment.