GBA Audio: Support 16-bit writes to FIFO audio

This commit is contained in:
Jeffrey Pfau 2014-12-21 03:19:56 -08:00
parent ce0ad004e4
commit c52a5d2859
3 changed files with 31 additions and 3 deletions

View File

@ -453,6 +453,30 @@ void GBAAudioWriteFIFO(struct GBAAudio* audio, int address, uint32_t value) {
}
}
void GBAAudioWriteFIFO16(struct GBAAudio* audio, int address, uint16_t value) {
struct CircleBuffer* fifo;
switch (address) {
case REG_FIFO_A_LO:
case REG_FIFO_A_HI:
fifo = &audio->chA.fifo;
break;
case REG_FIFO_B_LO:
case REG_FIFO_B_HI:
fifo = &audio->chB.fifo;
break;
default:
GBALog(audio->p, GBA_LOG_ERROR, "Bad FIFO write to address 0x%03x", address);
return;
}
int i;
for (i = 0; i < 2; ++i) {
while (!CircleBufferWrite8(fifo, value >> (8 * i))) {
int8_t dummy;
CircleBufferRead8(fifo, &dummy);
}
}
}
void GBAAudioSampleFIFO(struct GBAAudio* audio, int fifoId, int32_t cycles) {
struct GBAAudioFIFO* channel;
if (fifoId == 0) {

View File

@ -252,6 +252,7 @@ void GBAAudioWriteSOUNDCNT_X(struct GBAAudio* audio, uint16_t value);
void GBAAudioWriteSOUNDBIAS(struct GBAAudio* audio, uint16_t value);
void GBAAudioWriteWaveRAM(struct GBAAudio* audio, int address, uint32_t value);
void GBAAudioWriteFIFO16(struct GBAAudio* audio, int address, uint16_t value);
void GBAAudioWriteFIFO(struct GBAAudio* audio, int address, uint32_t value);
void GBAAudioSampleFIFO(struct GBAAudio* audio, int fifoId, int32_t cycles);

View File

@ -356,8 +356,6 @@ void GBAIOWrite(struct GBA* gba, uint32_t address, uint16_t value) {
case REG_WAVE_RAM1_LO:
case REG_WAVE_RAM2_LO:
case REG_WAVE_RAM3_LO:
case REG_FIFO_A_LO:
case REG_FIFO_B_LO:
GBAIOWrite32(gba, address, (gba->memory.io[(address >> 1) + 1] << 16) | value);
break;
@ -365,9 +363,14 @@ void GBAIOWrite(struct GBA* gba, uint32_t address, uint16_t value) {
case REG_WAVE_RAM1_HI:
case REG_WAVE_RAM2_HI:
case REG_WAVE_RAM3_HI:
GBAIOWrite32(gba, address - 2, gba->memory.io[(address >> 1) - 1] | (value << 16));
break;
case REG_FIFO_A_LO:
case REG_FIFO_B_LO:
case REG_FIFO_A_HI:
case REG_FIFO_B_HI:
GBAIOWrite32(gba, address - 2, gba->memory.io[(address >> 1) - 1] | (value << 16));
GBAAudioWriteFIFO16(&gba->audio, address, value);
break;
// DMA