diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/librfu_intr.c | 16 | ||||
-rw-r--r-- | src/librfu_rfu.c | 14 | ||||
-rw-r--r-- | src/librfu_sio32id.c | 29 | ||||
-rw-r--r-- | src/m4a.c | 13 |
4 files changed, 29 insertions, 43 deletions
diff --git a/src/librfu_intr.c b/src/librfu_intr.c index 1361be40e..19ea60b06 100644 --- a/src/librfu_intr.c +++ b/src/librfu_intr.c @@ -148,11 +148,7 @@ static void sio32intr_clock_slave(void) { u32 regSIODATA32; u32 r0; - #ifndef NONMATCHING - register u32 reqLen asm("r2"); - #else - u32 reqLen; - #endif + u32 reqLen; gSTWIStatus->timerActive = 0; STWI_set_timer_in_RAM(100); @@ -165,10 +161,14 @@ static void sio32intr_clock_slave(void) ((u32*)gSTWIStatus->rxPacket)[0] = regSIODATA32; gSTWIStatus->reqNext = 1; r0 = 0x99660000; - if ((regSIODATA32 >> 16) == (r0 >> 16)) + // variable reuse required + reqLen = (regSIODATA32 >> 16); + if (reqLen == (r0 >> 16)) { - gSTWIStatus->reqLength = reqLen = regSIODATA32 >> 8; - gSTWIStatus->reqActiveCommand = regSIODATA32; + // only reqLen = regSIODATA32 >> 8 is needed to match, but it looks a bit + // more consistent when both lines update the variables. Might have been a macro? + gSTWIStatus->reqLength = reqLen = (regSIODATA32 >> 8); + gSTWIStatus->reqActiveCommand = reqLen = (regSIODATA32 >> 0); if (gSTWIStatus->reqLength == 0) { if ( diff --git a/src/librfu_rfu.c b/src/librfu_rfu.c index f39ccb74c..309fc4ead 100644 --- a/src/librfu_rfu.c +++ b/src/librfu_rfu.c @@ -1550,21 +1550,20 @@ u16 rfu_changeSendTarget(u8 connType, u8 slotStatusIndex, u8 bmNewTgtSlot) u16 rfu_NI_stopReceivingData(u8 slotStatusIndex) { - struct NIComm *NI_comm; u16 imeBak; + struct NIComm *NI_comm; if (slotStatusIndex >= RFU_CHILD_MAX) return ERR_SLOT_NO; NI_comm = &gRfuSlotStatusNI[slotStatusIndex]->recv; imeBak = REG_IME; - ++imeBak; --imeBak; // fix imeBak, NI_comm register swap REG_IME = 0; - if (gRfuSlotStatusNI[slotStatusIndex]->recv.state & SLOT_BUSY_FLAG) + if (NI_comm->state & SLOT_BUSY_FLAG) { - if (gRfuSlotStatusNI[slotStatusIndex]->recv.state == SLOT_STATE_RECV_LAST) - gRfuSlotStatusNI[slotStatusIndex]->recv.state = SLOT_STATE_RECV_SUCCESS_AND_SENDSIDE_UNKNOWN; + if (NI_comm->state == SLOT_STATE_RECV_LAST) + NI_comm->state = SLOT_STATE_RECV_SUCCESS_AND_SENDSIDE_UNKNOWN; else - gRfuSlotStatusNI[slotStatusIndex]->recv.state = SLOT_STATE_RECV_FAILED; + NI_comm->state = SLOT_STATE_RECV_FAILED; gRfuLinkStatus->recvSlotNIFlag &= ~(1 << slotStatusIndex); rfu_STC_releaseFrame(slotStatusIndex, 1, NI_comm); } @@ -1758,9 +1757,6 @@ static void rfu_constructSendLLFrame(void) { u8 *maxSize = llf_p - offsetof(struct RfuFixed, LLFBuffer[1]); - // Does the volatile qualifier make sense? - // It's the same as: - // asm("":::"memory"); pakcketSize = maxSize - *(u8 *volatile *)&gRfuFixed; } } diff --git a/src/librfu_sio32id.c b/src/librfu_sio32id.c index b6623540f..1c02840e8 100644 --- a/src/librfu_sio32id.c +++ b/src/librfu_sio32id.c @@ -123,34 +123,29 @@ static void Sio32IDIntr(void) { u32 regSIODATA32; u16 delay; -#ifndef NONMATCHING - register u32 rfuSIO32IdUnk0_times_16 asm("r1"); - register u16 negRfuSIO32IdUnk6 asm("r0"); -#else u32 rfuSIO32IdUnk0_times_16; - u16 negRfuSIO32IdUnk6; -#endif regSIODATA32 = REG_SIODATA32; if (gRfuSIO32Id.MS_mode != AGB_CLK_MASTER) REG_SIOCNT |= SIO_ENABLE; - rfuSIO32IdUnk0_times_16 = 16 * gRfuSIO32Id.MS_mode; // to handle side effect of inline asm - rfuSIO32IdUnk0_times_16 = (regSIODATA32 << rfuSIO32IdUnk0_times_16) >> 16; + rfuSIO32IdUnk0_times_16 = (regSIODATA32 << (16 * gRfuSIO32Id.MS_mode)) >> 16; regSIODATA32 = (regSIODATA32 << 16 * (1 - gRfuSIO32Id.MS_mode)) >> 16; if (gRfuSIO32Id.lastId == 0) { - if (rfuSIO32IdUnk0_times_16 == gRfuSIO32Id.recv_id) + u16 backup = rfuSIO32IdUnk0_times_16; + if (backup == gRfuSIO32Id.recv_id) { - if (gRfuSIO32Id.count > 3) + if (gRfuSIO32Id.count < 4) { - gRfuSIO32Id.lastId = regSIODATA32; - } - else if (rfuSIO32IdUnk0_times_16 == (u16)~gRfuSIO32Id.send_id) - { - negRfuSIO32IdUnk6 = ~gRfuSIO32Id.recv_id; - if (regSIODATA32 == negRfuSIO32IdUnk6) - ++gRfuSIO32Id.count; + backup = (u16)~gRfuSIO32Id.send_id; + if (gRfuSIO32Id.recv_id == backup) + { + if (regSIODATA32 == (u16)~gRfuSIO32Id.recv_id) + ++gRfuSIO32Id.count; + } } + else + gRfuSIO32Id.lastId = regSIODATA32; } else { @@ -887,18 +887,13 @@ void CgbModVol(struct CgbChannel *chan) if ((soundInfo->mode & 1) || !CgbPan(chan)) { chan->pan = 0xFF; - chan->envelopeGoal = (u32)(chan->rightVolume + chan->leftVolume) >> 4; + chan->envelopeGoal = (u32)(chan->leftVolume + chan->rightVolume); + chan->envelopeGoal /= 16; } else { - // Force chan->rightVolume and chan->leftVolume to be read from memory again, - // even though there is no reason to do so. - // The command line option "-fno-gcse" achieves the same result as this. - #ifndef NONMATCHING - asm("" : : : "memory"); - #endif - - chan->envelopeGoal = (u32)(chan->rightVolume + chan->leftVolume) >> 4; + chan->envelopeGoal = (u32)(chan->leftVolume + chan->rightVolume); + chan->envelopeGoal /= 16; if (chan->envelopeGoal > 15) chan->envelopeGoal = 15; } |