From 31dd2fc98edff73e6edc48b892bc0fe2e7dbeb37 Mon Sep 17 00:00:00 2001 From: Michel Kremer Date: Tue, 29 Dec 2020 12:29:43 +0100 Subject: [PATCH] Improve doTimers (#20) --- core/source/emulator/cpu.cpp | 4 ++-- core/source/emulator/cpu.h | 2 +- core/source/util/typedefs.h | 5 +++++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/core/source/emulator/cpu.cpp b/core/source/emulator/cpu.cpp index 07eb74c5..caa85cc9 100644 --- a/core/source/emulator/cpu.cpp +++ b/core/source/emulator/cpu.cpp @@ -344,12 +344,12 @@ void CPU::doTimers(Memory &memory, u8 clocks) { timerOverflowingCycles = -1; } } - u8 tac = memory.getTAC(); + u8_fast tac = memory.getTAC(); bool comp1 = (tac & 0b100u) != 0; comp1 &= doTimerObscureCheck(clocks, sysCounter, tac); // Falling edge detector if (delayedTIMAIncrease && !comp1) { - u8 tima = memory.getTIMA(); + u8_fast tima = memory.getTIMA(); if (tima == 0xff) { //fprintf(stdout, "# TIMA has overflown\n"); // Delay TIMA load by 1 m-cycle diff --git a/core/source/emulator/cpu.h b/core/source/emulator/cpu.h index 48b172e6..59a39387 100644 --- a/core/source/emulator/cpu.h +++ b/core/source/emulator/cpu.h @@ -52,7 +52,7 @@ namespace FunkyBoy { u8 registers[8]{}; - i8 timerOverflowingCycles; + int timerOverflowingCycles; bool delayedTIMAIncrease; bool joypadWasNotPressed; diff --git a/core/source/util/typedefs.h b/core/source/util/typedefs.h index 79de37e7..3ada4f2f 100644 --- a/core/source/util/typedefs.h +++ b/core/source/util/typedefs.h @@ -31,6 +31,11 @@ namespace FunkyBoy { typedef uint32_t u32; typedef uint64_t u64; + typedef uint_fast8_t u8_fast; + typedef uint_fast16_t u16_fast; + typedef uint_fast32_t u32_fast; + typedef uint_fast64_t u64_fast; + typedef u32 memory_address; typedef int8_t i8;