GB I/O: Implement preliminary support for PCM12/PCM34 (#1468)
Vicki Pfau vi@endrift.com
Wed, 25 Nov 2020 20:09:54 -0800
2 files changed,
16 insertions(+),
1 deletions(-)
M
CHANGES
→
CHANGES
@@ -84,6 +84,7 @@ - Core: Add shutdown callback
- Core: Rework thread state synchronization - GB: Allow pausing event loop while CPU is blocked - GB: Add support for sleep and shutdown callbacks + - GB I/O: Implement preliminary support for PCM12/PCM34 (closes mgba.io/i/1468) - GBA: Allow pausing event loop while CPU is blocked - GBA BIOS: Division by zero should emit a FATAL error - GBA Video: Convert OpenGL VRAM texture to integer
M
src/gb/io.c
→
src/gb/io.c
@@ -216,7 +216,7 @@ GBIOWrite(gb, GB_REG_HDMA3, 0xFF);
GBIOWrite(gb, GB_REG_HDMA4, 0xFF); gb->memory.io[GB_REG_HDMA5] = 0xFF; } else { - memset(&gb->memory.io[GB_REG_KEY0], 0xFF, GB_REG_PCM34 - GB_REG_KEY0); + memset(&gb->memory.io[GB_REG_KEY0], 0xFF, GB_REG_PCM34 - GB_REG_KEY0 + 1); } if (gb->model & GB_MODEL_SGB) {@@ -620,6 +620,20 @@ return 0xFF;
} } else { return gb->audio.ch3.wavedata8[address - GB_REG_WAVE_0]; + } + break; + case GB_REG_PCM12: + if (gb->model < GB_MODEL_CGB) { + mLOG(GB_IO, GAME_ERROR, "Reading from CGB register FF%02X in DMG mode", address); + } else if (gb->audio.enable) { + return (gb->audio.ch1.sample) | (gb->audio.ch2.sample << 4); + } + break; + case GB_REG_PCM34: + if (gb->model < GB_MODEL_CGB) { + mLOG(GB_IO, GAME_ERROR, "Reading from CGB register FF%02X in DMG mode", address); + } else if (gb->audio.enable) { + return (gb->audio.ch3.sample) | (gb->audio.ch4.sample << 4); } break; case GB_REG_SB: