Skip to content

Commit

Permalink
Improve doTimers (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
kremi151 committed Dec 29, 2020
1 parent d4c4b18 commit 31dd2fc
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions core/source/emulator/cpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion core/source/emulator/cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ namespace FunkyBoy {

u8 registers[8]{};

i8 timerOverflowingCycles;
int timerOverflowingCycles;
bool delayedTIMAIncrease;

bool joypadWasNotPressed;
Expand Down
5 changes: 5 additions & 0 deletions core/source/util/typedefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 31dd2fc

Please sign in to comment.