From 17ec2ceee2282837d810dac6630445226b267f20 Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Mon, 20 Feb 2017 15:01:54 -0800 Subject: [PATCH] DS IPC: Fix Empty bits --- src/ds/io.c | 2 ++ src/ds/ipc.c | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/src/ds/io.c b/src/ds/io.c index 137b04fe2..0f79eb6f9 100644 --- a/src/ds/io.c +++ b/src/ds/io.c @@ -165,6 +165,7 @@ static void DSIOUpdateTimer(struct DSCommon* dscore, uint32_t address) { 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 @@ uint32_t DS7IORead32(struct DS* ds, uint32_t address) { 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) { diff --git a/src/ds/ipc.c b/src/ds/ipc.c index 2ba387dda..c5cbcce97 100644 --- a/src/ds/ipc.c +++ b/src/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; }