all repos — mgba @ 17ec2ceee2282837d810dac6630445226b267f20

mGBA Game Boy Advance Emulator

DS IPC: Fix Empty bits
Vicki Pfau vi@endrift.com
Mon, 20 Feb 2017 15:01:54 -0800
commit

17ec2ceee2282837d810dac6630445226b267f20

parent

b4fa4fe77e23ed774e749608144fc0d1330b941c

2 files changed, 6 insertions(+), 0 deletions(-)

jump to
M src/ds/io.csrc/ds/io.c

@@ -165,6 +165,7 @@ }

void DS7IOInit(struct DS* ds) { memset(ds->memory.io7, 0, sizeof(ds->memory.io7)); + ds->memory.io7[DS_REG_IPCFIFOCNT >> 1] = 0x0101; } void DS7IOWrite(struct DS* ds, uint32_t address, uint16_t value) {

@@ -320,6 +321,7 @@ }

void DS9IOInit(struct DS* ds) { memset(ds->memory.io9, 0, sizeof(ds->memory.io9)); + ds->memory.io9[DS_REG_IPCFIFOCNT >> 1] = 0x0101; } void DS9IOWrite(struct DS* ds, uint32_t address, uint16_t value) {
M src/ds/ipc.csrc/ds/ipc.c

@@ -21,11 +21,15 @@ int16_t DSIPCWriteFIFOCNT(struct DSCommon* dscore, int16_t value) {

value &= 0xC40C; int16_t oldValue = dscore->memory.io[DS_REG_IPCFIFOCNT >> 1] & 0x4303; int16_t newValue = value | oldValue; + // TODO: Does Enable set enabled on both ends? if (DSIPCFIFOCNTIsError(value)) { newValue = DSIPCFIFOCNTClearError(newValue); } if (DSIPCFIFOCNTIsSendClear(newValue)) { CircleBufferClear(&dscore->ipc->fifo); + dscore->ipc->memory.io[DS_REG_IPCFIFOCNT >> 1] = DSIPCFIFOCNTFillRecvEmpty(dscore->ipc->memory.io[DS_REG_IPCFIFOCNT >> 1]); + newValue = DSIPCFIFOCNTFillSendEmpty(newValue); + newValue = DSIPCFIFOCNTClearSendClear(newValue); } return newValue; }