DS IPC: Fix Empty bits

This commit is contained in:
Vicki Pfau 2017-02-20 15:01:54 -08:00
parent b4fa4fe77e
commit 17ec2ceee2
2 changed files with 6 additions and 0 deletions

View File

@ -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) {

View File

@ -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;
}