fengb / fundude

Gameboy emulator: Zig -> wasm
https://fengb.github.io/fundude/
MIT License
181 stars 8 forks source link

Unrolled timer #62

Open fengb opened 3 years ago

fengb commented 3 years ago

Followup to https://github.com/fengb/fundude/issues/61

Certain components never require the fastest clock. The most obvious offenders are the timer interrupt and temportal.

What if we unroll the timer mechanism?

fn tick8() void {
    // 8 times per function call
    inline for ("12345678") |_| {
        self.timer.tick();
        self.cpu.tick();
        self.video.tick();
        self.audio.tick();
    }

    // 1 time per function call
    self.slow_timer.tick();
    self.temportal.tick();
    self.serial.tick();
}