diff --git a/src/audio.cpp b/src/audio.cpp index ac79828..c4816e4 100644 --- a/src/audio.cpp +++ b/src/audio.cpp @@ -59,7 +59,8 @@ void APU::test() void APU::initializeWriteHandler() { if (mMap) - mMap->setAduioWriteHandler([this](Word address) { this->onWrite(address); }); + mMap->setAudioWriteHandler([this](Word address) + { this->onMemoryWrite(address); }); } void APU::writeByte(Word address, Byte value) @@ -202,7 +203,7 @@ void APU::stepAPU(int cycles) Word address[] = { 0xFF19, 0xFF1E, 0xFF23, 0xFF26 }; for (auto addr : address) { - writeUpdate(addr, AUDIO_WRITE); + audioRegisterUpdate(addr, AudioWrite); } printf("FramerSequencer ends\n"); } @@ -224,21 +225,21 @@ void APU::clearRegisters() // Could be done by simply writing 0s but for checking's sake done as such for (int address = 0xFF10; address <= 0xFF3F; address++) { - writeUpdate(address, AUDIO_WRITE); + audioRegisterUpdate(address, AudioWrite); } } // Updates APU registers on write in MemoryMap -void APU::onWrite(Word address) +void APU::onMemoryWrite(Word address) { // address where write has occurred - writeUpdate(address, AUDIO_MEMORY_WRITE); + audioRegisterUpdate(address, AudioMemoryWrite); // Update the audio channel controller register - writeUpdate(AUDIO_CHANNEL_CONTROL, AUDIO_WRITE); + audioRegisterUpdate(AUDIO_MASTER_CONTROL_REGISTER, AudioWrite); } // Write Update -void APU::writeUpdate(Word address, audioWriteFlag flag) +void APU::audioRegisterUpdate(Word address, audioWriteFlag flag) { Byte value = 0xFF; if (flag) @@ -247,7 +248,7 @@ void APU::writeUpdate(Word address, audioWriteFlag flag) writeByte(address, value); } value = readByte(address); - mMap->writeBackMemory(address, value); + mMap->MemoryWriteBack(address, value); } // PulseChannel diff --git a/src/audio.h b/src/audio.h index 8d58240..464f06f 100644 --- a/src/audio.h +++ b/src/audio.h @@ -4,7 +4,7 @@ #include #include // SDL Audio -#define AUDIO_CHANNEL_CONTROL 0xFF26 +#define AUDIO_MASTER_CONTROL_REGISTER 0xFF26 enum Channel { @@ -17,8 +17,8 @@ enum Channel // For checking whether Write is due to memory or APU itself enum audioWriteFlag { - AUDIO_WRITE = 0, - AUDIO_MEMORY_WRITE = 1 + AudioWrite = 0, + AudioMemoryWrite = 1 }; @@ -183,9 +183,9 @@ class APU void clearRegisters(); void setMemoryMap(MemoryMap* map) { mMap = map; } // Writes back on Memory Write - void onWrite(Word address); + void onMemoryWrite(Word address); // Write update - void writeUpdate(Word address, audioWriteFlag flag); + void audioRegisterUpdate(Word address, audioWriteFlag flag); // initializes the audioWriteHandler of MemoryMap void initializeWriteHandler(); }; \ No newline at end of file diff --git a/src/gameBoy.cpp b/src/gameBoy.cpp index 3ff18da..41c07b8 100644 --- a/src/gameBoy.cpp +++ b/src/gameBoy.cpp @@ -42,7 +42,7 @@ GBE::GBE() // printf("game rom file not opened"); // Open the Game ROM - if ((gameROM = fopen("../tests/dmg_sound/rom_singles/03-trigger.gb", "rb")) == NULL) + if ((gameROM = fopen("../tests/dmg_sound/rom_singles/02-len ctr.gb", "rb")) == NULL) printf("game rom file not opened\n"); // Set the Boot ROM diff --git a/src/mmap.cpp b/src/mmap.cpp index 59f2676..5f6da9b 100644 --- a/src/mmap.cpp +++ b/src/mmap.cpp @@ -1,8 +1,6 @@ #include "mmap.h" #include -// std::function globalFunction = nullptr; - // Constructor MemoryMap::MemoryMap() { @@ -225,7 +223,7 @@ void MemoryMap::debugWriteMemory(Word address, Byte value) romBank0[address] = value; } -bool MemoryMap::writeBackMemory(Word address, Byte value) +bool MemoryMap::MemoryWriteBack(Word address, Byte value) { if (address >= 0xFF10 && address <= 0xFF3F) { diff --git a/src/mmap.h b/src/mmap.h index 37b4aaf..17cd4ee 100644 --- a/src/mmap.h +++ b/src/mmap.h @@ -2,7 +2,7 @@ #include "types.h" #include #include -// extern std::function globalFunction; + // The Memory Map for GBE // Pulled from https://gbdev.io/pandocs/Memory_Map.html @@ -191,7 +191,7 @@ class MemoryMap void debugWriteMemory(Word address, Byte value); // Write Back - bool writeBackMemory(Word address, Byte value); + bool MemoryWriteBack(Word address, Byte value); // Reads a byte from the memory address Byte readMemory(Word address); @@ -278,5 +278,5 @@ class MemoryMap void setRomFile(FILE* file) { romFile = file; } // sets audiowritehandler function - void setAduioWriteHandler(const std::function& function) { audioWriteHandler = function; } + void setAudioWriteHandler(const std::function& function) { audioWriteHandler = function; } }; \ No newline at end of file