From f3179a56af0204b122410eea131ccb70b32771c5 Mon Sep 17 00:00:00 2001 From: vibhatsu Date: Sat, 31 Aug 2024 22:16:00 +0530 Subject: [PATCH] code cleaning --- src/audio.cpp | 9 ++------- src/cpu.cpp | 3 +++ src/gameBoy.cpp | 2 -- src/mmap.h | 4 ---- src/types.h | 6 ------ 5 files changed, 5 insertions(+), 19 deletions(-) diff --git a/src/audio.cpp b/src/audio.cpp index 32c62ef..e4107ca 100644 --- a/src/audio.cpp +++ b/src/audio.cpp @@ -59,7 +59,8 @@ void APU::test() void APU::initializeWriteHandler() { if (mMap) - mMap->setAudioWriteHandler([this](Word address) { this->onMemoryWrite(address); }); + mMap->setAudioWriteHandler([this](Word address) + { this->onMemoryWrite(address); }); } void APU::writeByte(Word address, Byte value) @@ -288,7 +289,6 @@ void PulseChannel::writeByte(Word address, Byte value) // Sound length/Wave pattern duty waveDuty = (value & 0xC0) >> 6; lengthTimer = maxLengthTimer - (value & 0x3F); - printf("PC: lengthTimer\n"); return; case 0xFF12: case 0xFF17: @@ -319,7 +319,6 @@ void PulseChannel::writeByte(Word address, Byte value) } if (value & 0x80) { - printf("WC triggered\n"); trigger(); } return; @@ -475,7 +474,6 @@ void WaveChannel::writeByte(Word address, Byte value) // NR31 // Sound length lengthTimer = maxLengthTimer - value; - printf("WC: lengthTimer\n"); return; case 0xFF1C: // NR32 @@ -498,7 +496,6 @@ void WaveChannel::writeByte(Word address, Byte value) } if (value & 0x80) { - printf("WC triggered\n"); trigger(); } return; @@ -636,7 +633,6 @@ void NoiseChannel::writeByte(Word address, Byte value) // NR41 // Sound length lengthTimer = maxLengthTimer - (value & 0x3F); - printf("NC: lengthtimer\n"); return; case 0xFF21: // NR42 @@ -665,7 +661,6 @@ void NoiseChannel::writeByte(Word address, Byte value) } if (value & 0x80) { - printf("NC Triggered...\n"); trigger(); } return; diff --git a/src/cpu.cpp b/src/cpu.cpp index df0b25d..e3689a1 100644 --- a/src/cpu.cpp +++ b/src/cpu.cpp @@ -4114,6 +4114,7 @@ int CPU::RLC_HLp() mMap->writeMemory(reg_HL.dat, ((*mMap)[reg_HL.dat] << 1) | ((*mMap)[reg_HL.dat] >> 7)); (*mMap)[reg_HL.dat] ? UNSET_ZERO_FLAG : SET_ZERO_FLAG; + reg_PC.dat += 1; debugPrint("RLC (HL)\n"); return 12; @@ -4271,7 +4272,9 @@ int CPU::RRC_HLp() // Rotate the value at memory address pointed to by HL right by 1 mMap->writeMemory(reg_HL.dat, ((*mMap)[reg_HL.dat] >> 1) | ((*mMap)[reg_HL.dat] << 7)); + (*mMap)[reg_HL.dat] ? UNSET_ZERO_FLAG : SET_ZERO_FLAG; + reg_PC.dat += 1; debugPrint("RRC (HL)\n"); return 12; diff --git a/src/gameBoy.cpp b/src/gameBoy.cpp index 0f37e79..047ae3c 100644 --- a/src/gameBoy.cpp +++ b/src/gameBoy.cpp @@ -108,9 +108,7 @@ GBE::GBE() gbe_mMap->debugWriteMemory(0x132, 0x33); gbe_mMap->debugWriteMemory(0x133, 0x3E); - printf("Loading boot\n"); executeBootROM(); - printf("Exited boot\n"); update(); } diff --git a/src/mmap.h b/src/mmap.h index 17cd4ee..cfcb77b 100644 --- a/src/mmap.h +++ b/src/mmap.h @@ -143,10 +143,6 @@ class MemoryMap std::function audioWriteHandler; public: - // Audio Unit - // I know this is not the best way to do it - // But I am not sure how to do it better - Byte* joyPadState; // Constructor MemoryMap(); diff --git a/src/types.h b/src/types.h index 9ce281b..ee950ee 100644 --- a/src/types.h +++ b/src/types.h @@ -8,9 +8,3 @@ typedef char SByte; typedef unsigned short Word; typedef signed short SWord; typedef unsigned int color; - -typedef struct -{ - Word address; - Byte value; -} audioRegs; \ No newline at end of file