diff --git a/configure.py b/configure.py index b1a9abaf2..4d30a0e1a 100644 --- a/configure.py +++ b/configure.py @@ -820,7 +820,7 @@ config.libs = [ Object(Matching, "JSystem/JUtility/JUTFont.cpp"), Object(Matching, "JSystem/JUtility/JUTResFont.cpp"), Object(Matching, "JSystem/JUtility/JUTDbPrint.cpp"), - Object(NonMatching, "JSystem/JUtility/JUTGamePad.cpp"), + Object(Matching, "JSystem/JUtility/JUTGamePad.cpp"), Object(NonMatching, "JSystem/JUtility/JUTException.cpp"), Object(NonMatching, "JSystem/JUtility/JUTDirectPrint.cpp"), Object(Matching, "JSystem/JUtility/JUTAssert.cpp"), diff --git a/include/JSystem/JGadget/linklist.h b/include/JSystem/JGadget/linklist.h index 811568ec8..1429846ba 100644 --- a/include/JSystem/JGadget/linklist.h +++ b/include/JSystem/JGadget/linklist.h @@ -144,13 +144,19 @@ struct TLinkList : public TNodeLinkList { /* 0x00 */ TNodeLinkList::const_iterator base; }; - static const TLinkListNode* Element_toNode(const T* element) { (void)element; return reinterpret_cast(reinterpret_cast(element) - I); } - static TLinkListNode* Element_toNode(T* element) { (void)element; return reinterpret_cast(reinterpret_cast(element) - I); } - static const T* Element_toValue(const TLinkListNode* node) { (void)node; return reinterpret_cast(reinterpret_cast(node) + I); } - static T* Element_toValue(TLinkListNode* node) { (void)node; return reinterpret_cast(reinterpret_cast(node) + I); } + static const TLinkListNode* Element_toNode(const T* element) { return reinterpret_cast(reinterpret_cast(element) - I); } + static TLinkListNode* Element_toNode(T* element) { return reinterpret_cast(reinterpret_cast(element) - I); } + static const T* Element_toValue(const TLinkListNode* node) { return reinterpret_cast(reinterpret_cast(node) + I); } + static T* Element_toValue(TLinkListNode* node) { return reinterpret_cast(reinterpret_cast(node) + I); } - iterator Insert(iterator iter, T* element) { return iterator(TNodeLinkList::Insert(iter.base, Element_toNode(element))); } - iterator Erase(T* element) { return iterator(TNodeLinkList::Erase(Element_toNode(element))); } + iterator Insert(iterator iter, T* element) { + TLinkListNode* node = Element_toNode(element); + return iterator(TNodeLinkList::Insert(iter.base, node)); + } + iterator Erase(T* element) { + TLinkListNode* node = Element_toNode(element); + return iterator(TNodeLinkList::Erase(node)); + } iterator begin() { return iterator(TNodeLinkList::begin()); } const_iterator begin() const { return const_iterator(const_cast(this)->begin()); } @@ -160,8 +166,14 @@ struct TLinkList : public TNodeLinkList { T& back() { return *--end(); } void Push_front(T* element) { Insert(begin(), element); } void Push_back(T* element) { Insert(end(), element); } - iterator Find(const T* element) { return iterator(TNodeLinkList::Find(Element_toNode(element))); } - void Remove(T* element) { TNodeLinkList::Remove(Element_toNode(element)); } + iterator Find(const T* element) { + const TLinkListNode* node = Element_toNode(element); + return iterator(TNodeLinkList::Find(node)); + } + void Remove(T* element) { + TLinkListNode* node = Element_toNode(element); + TNodeLinkList::Remove(node); + } }; template diff --git a/src/JSystem/JUtility/JUTConsole.cpp b/src/JSystem/JUtility/JUTConsole.cpp index b73448a85..b66c51cef 100644 --- a/src/JSystem/JUtility/JUTConsole.cpp +++ b/src/JSystem/JUtility/JUTConsole.cpp @@ -368,10 +368,8 @@ static void dummy3() { /* 802CB380-802CB4C4 .text appendConsole__17JUTConsoleManagerFP10JUTConsole */ void JUTConsoleManager::appendConsole(JUTConsole* console) { - /* Nonmatching */ JUT_ASSERT(0x3bf, sManager != 0 && console != 0); - // need to figure out how TLinkList works JUT_ASSERT(0x3c2, soLink_.Find( console ) == soLink_.end()); soLink_.Push_back(console); @@ -382,7 +380,6 @@ void JUTConsoleManager::appendConsole(JUTConsole* console) { /* 802CB4C4-802CB674 .text removeConsole__17JUTConsoleManagerFP10JUTConsole */ void JUTConsoleManager::removeConsole(JUTConsole* console) { - /* Nonmatching */ JUT_ASSERT(0x3d6, sManager != 0 && console != 0); JUT_ASSERT(0x3d9, soLink_.Find( console ) != soLink_.end()); diff --git a/src/JSystem/JUtility/JUTGamePad.cpp b/src/JSystem/JUtility/JUTGamePad.cpp index ec8b7f849..944c192da 100644 --- a/src/JSystem/JUtility/JUTGamePad.cpp +++ b/src/JSystem/JUtility/JUTGamePad.cpp @@ -397,14 +397,9 @@ void JUTGamePad::CRumble::stopMotorHard(int portNo) { } } -inline u8 getNumBit(u8* arr, u32 bitNo) { - u8 bit = (arr[bitNo >> 3] & (0x80 >> (bitNo & 7))); - return bit; -} - /* 802C45A4-802C46CC .text update__Q210JUTGamePad7CRumbleFs */ void JUTGamePad::CRumble::update(s16 portNo) { - if (!isEnabledPort(portNo)) { + if (!isEnabled(channel_mask[portNo])) { mFrame = 0; mLength = 0; mData = NULL; @@ -424,7 +419,8 @@ void JUTGamePad::CRumble::update(s16 portNo) { } return; } else { - u8 numBit = getNumBit(mData, mFrame % mFrameCount); + u32 bitNo = mFrame % mFrameCount; + u8 numBit = (mData[bitNo >> 3] & (0x80 >> (bitNo & 7))); if (numBit != 0 && mStatus[portNo] == 0) { startMotor(portNo); } else if (numBit == 0 && mStatus[portNo] != 0) { @@ -522,3 +518,17 @@ bool JUTGamePad::recalibrate(u32 mask) { return PADRecalibrate((PADMask)mask); } + +static void dummy() { + OSReport("JUTGamePad.cpp"); + OSReport("getDataSizePerFrame() > 0"); + OSReport("Halt"); + OSReport("mBuffer"); + OSReport("(u32)mBuffer <= (u32)dataEnd && (u32)dataEnd <= (u32)mBufferEnd"); + OSReport("part != 0"); + OSReport("getBuffer() == getDataEnd() || part == mPart"); + OSReport("JUTGamePad.h"); + OSReport("size > 0"); + OSReport("mBuffer && isValidData( mCurrent )"); + OSReport("mBuffer && isValidBuffer( mCurrent )"); +}