GB I/O: Implement preliminary support for PCM12/PCM34 (#1468)

This commit is contained in:
Vicki Pfau 2020-11-25 20:09:54 -08:00
parent a1c0318290
commit b50d8e35e9
2 changed files with 16 additions and 1 deletions

View File

@ -84,6 +84,7 @@ Misc:
- Core: Rework thread state synchronization - Core: Rework thread state synchronization
- GB: Allow pausing event loop while CPU is blocked - GB: Allow pausing event loop while CPU is blocked
- GB: Add support for sleep and shutdown callbacks - 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: Allow pausing event loop while CPU is blocked
- GBA BIOS: Division by zero should emit a FATAL error - GBA BIOS: Division by zero should emit a FATAL error
- GBA Video: Convert OpenGL VRAM texture to integer - GBA Video: Convert OpenGL VRAM texture to integer

View File

@ -216,7 +216,7 @@ void GBIOReset(struct GB* gb) {
GBIOWrite(gb, GB_REG_HDMA4, 0xFF); GBIOWrite(gb, GB_REG_HDMA4, 0xFF);
gb->memory.io[GB_REG_HDMA5] = 0xFF; gb->memory.io[GB_REG_HDMA5] = 0xFF;
} else { } 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) { if (gb->model & GB_MODEL_SGB) {
@ -622,6 +622,20 @@ uint8_t GBIORead(struct GB* gb, unsigned address) {
return gb->audio.ch3.wavedata8[address - GB_REG_WAVE_0]; return gb->audio.ch3.wavedata8[address - GB_REG_WAVE_0];
} }
break; 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: case GB_REG_SB:
case GB_REG_SC: case GB_REG_SC:
case GB_REG_IF: case GB_REG_IF: