From 7830c29f6a2b7e348ace2fa06527f7091a867d9e Mon Sep 17 00:00:00 2001 From: "Adrian.Conlon" Date: Thu, 21 Sep 2017 10:36:52 +0100 Subject: [PATCH] Update audio custom wave pattern data. Signed-off-by: Adrian.Conlon --- LR35902/inc/Audio.h | 7 +++++++ LR35902/inc/GameBoyBus.h | 6 +++--- LR35902/src/Disassembler.cpp | 8 ++++---- LR35902/src/GameBoyBus.cpp | 9 ++++++--- 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/LR35902/inc/Audio.h b/LR35902/inc/Audio.h index f224429..1e22b8c 100644 --- a/LR35902/inc/Audio.h +++ b/LR35902/inc/Audio.h @@ -751,6 +751,13 @@ namespace EightBit { setEnabled((value >> 7) & Processor::Mask1); // Bit 7 } + void setPackedWaveDatum(int i, uint8_t value) { + voice3()->setPackedWaveDatum(i, value); + } + + uint8_t packedWaveDatum(int i) { + return voice3()->packedWaveDatum(i); + } private: std::array, 4> m_voices; diff --git a/LR35902/inc/GameBoyBus.h b/LR35902/inc/GameBoyBus.h index e983c81..cb94c99 100644 --- a/LR35902/inc/GameBoyBus.h +++ b/LR35902/inc/GameBoyBus.h @@ -70,6 +70,9 @@ namespace EightBit { NR51 = 0x25, // R/W Mask8 NR52 = 0x26, // R/W Mask8 Mask8 + WAVE_PATTERN_RAM_START = 0x30, + WAVE_PATTERN_RAM_END = 0x3F, + // LCD Display Registers LCDC = 0x40, // R/W Mask8 STAT = 0x41, // R/W Mask7 @@ -84,9 +87,6 @@ namespace EightBit { WY = 0x4A, // R/W Mask8 WX = 0x4B, // R/W Mask8 - WPRAM_START = 0x30, - WPRAM_END = 0x3F, - // Boot rom control BOOT_DISABLE = 0x50, }; diff --git a/LR35902/src/Disassembler.cpp b/LR35902/src/Disassembler.cpp index da8297e..8e869f1 100644 --- a/LR35902/src/Disassembler.cpp +++ b/LR35902/src/Disassembler.cpp @@ -670,10 +670,10 @@ std::string EightBit::GameBoy::Disassembler::io(uint8_t value) { case Bus::NR52: return "NR52"; - case Bus::WPRAM_START: - return "WPRAM_START"; - case Bus::WPRAM_END: - return "WPRAM_END"; + case Bus::WAVE_PATTERN_RAM_START: + return "WAVE_PATTERN_RAM_START"; + case Bus::WAVE_PATTERN_RAM_END: + return "WAVE_PATTERN_RAM_END"; // Boot rom control case Bus::BOOT_DISABLE: diff --git a/LR35902/src/GameBoyBus.cpp b/LR35902/src/GameBoyBus.cpp index f836cc0..c697f94 100644 --- a/LR35902/src/GameBoyBus.cpp +++ b/LR35902/src/GameBoyBus.cpp @@ -195,7 +195,10 @@ void EightBit::GameBoy::Bus::Bus_ReadingByte(const uint16_t address) { break; default: - mask(0); + if ((address >= (BASE + WAVE_PATTERN_RAM_START)) && (address <= (BASE + WAVE_PATTERN_RAM_END))) + poke(address, audio().packedWaveDatum(address - WAVE_PATTERN_RAM_START)); + else + mask(0); break; } } @@ -403,8 +406,8 @@ void EightBit::GameBoy::Bus::Bus_WrittenByte(const uint16_t address) { break; default: - if ((address >= (BASE + WPRAM_START)) && (address <= (BASE + WPRAM_END))) - ; // Wave form data + if ((address >= (BASE + WAVE_PATTERN_RAM_START)) && (address <= (BASE + WAVE_PATTERN_RAM_END))) + audio().setPackedWaveDatum(address - WAVE_PATTERN_RAM_START, value); else if ((address > BASE) && (address < (BASE + 0x4c))) assert(false); }