all repos — mgba @ b50d8e35e98906e446701dbf3973e799306f13ed

mGBA Game Boy Advance Emulator

GB I/O: Implement preliminary support for PCM12/PCM34 (#1468)
Vicki Pfau vi@endrift.com
Wed, 25 Nov 2020 20:09:54 -0800
commit

b50d8e35e98906e446701dbf3973e799306f13ed

parent

a1c0318290b52302d919c33ce71763fc90353e4f

2 files changed, 16 insertions(+), 1 deletions(-)

jump to
M CHANGESCHANGES

@@ -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.csrc/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: