From 5d07b4022449b6eeb0225834822aa201fc84aa7f Mon Sep 17 00:00:00 2001 From: coah <100182500+coah80@users.noreply.github.com> Date: Wed, 30 Sep 2026 01:16:03 +0000 Subject: [PATCH] tiInputForm: convert 29 more asm bodies to C (12 left) (worker 99756b60) --- include/keyboard/tiCandidateBox.h | 3 + include/keyboard/tiGUIManager.h | 4 + include/keyboard/tiInputForm.h | 13 +- include/keyboard/tiString.h | 15 +- include/keyboard/tiTextDrawer.h | 33 +- include/keyboard/tiTextInputBase.h | 4 + include/keyboard/tiZiString.h | 7 +- src/keyboard/tiInputForm.cpp | 2488 ++++--------------- tools/decomp-assist/tiInputForm.attempts.md | 234 ++ 9 files changed, 721 insertions(+), 2080 deletions(-) diff --git a/include/keyboard/tiCandidateBox.h b/include/keyboard/tiCandidateBox.h index a50a5480..0468bb4e 100644 --- a/include/keyboard/tiCandidateBox.h +++ b/include/keyboard/tiCandidateBox.h @@ -48,6 +48,9 @@ namespace textinput { class CandidateBoxCaller { public: +#ifdef TIINPUTFORM_IMPLEMENTATION + CandidateBoxCaller() : mpCandidateBox(NULL) {} +#endif // This candidate thing is a bit different from the dwarf class Candidates { public: diff --git a/include/keyboard/tiGUIManager.h b/include/keyboard/tiGUIManager.h index 0efb43ad..15a1b66d 100644 --- a/include/keyboard/tiGUIManager.h +++ b/include/keyboard/tiGUIManager.h @@ -92,6 +92,9 @@ namespace textinput { EVENT_RELEASE }; +#ifdef TIINPUTFORM_IMPLEMENTATION + virtual void init(); +#else virtual void init() { // 0x10 for (int i = 0; i < GUI_POINTS_MAX; i++) { mbPointed[i] = false; @@ -100,6 +103,7 @@ namespace textinput { mFlightDuration[i] = 0; } } +#endif GUIComponent(u32 id) : GUIInterface(), mbInitialize(false), mDraggingButton(0xFFFF), mID(id), mbTriggerTarget(false), mpManager(NULL), mpListener(NULL) { diff --git a/include/keyboard/tiInputForm.h b/include/keyboard/tiInputForm.h index a7a0ea36..6cd73ca4 100644 --- a/include/keyboard/tiInputForm.h +++ b/include/keyboard/tiInputForm.h @@ -17,21 +17,24 @@ extern "C" wchar_t KPRGetChar(KPRQueue* queue); extern "C" void KPRPutChar(KPRQueue* queue, wchar_t character); extern "C" void KPRClearQueue(KPRQueue* queue); +extern "C" void KPRInitRegionUS(); extern "C" u8 KPRLookAhead(KPRQueue* queue, wchar_t* character, wchar_t* combining); #endif namespace textinput { namespace inputform { #ifdef TIINPUTFORM_IMPLEMENTATION + class Base; class EventHandler; class LayoutByNW4R; #endif class EditBuffer { #ifdef TIINPUTFORM_IMPLEMENTATION friend class LayoutByNW4R; + friend class Base; #endif public: -#ifdef MYTIMANAGER_IMPLEMENTATION +#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) void create(MEMAllocator* allocator); #endif #ifdef TIINPUTFORM_IMPLEMENTATION @@ -50,9 +53,11 @@ namespace textinput { class DeadKeyStream { #if defined(TIINPUTFORM_IMPLEMENTATION) public: + DeadKeyStream() { KPRInitRegionUS(); init(); } static wchar_t ToCombineClass(Language language, wchar_t code); static wchar_t ToIndependentClass(wchar_t code); inline wchar_t getChar(); + void init(); u8 lookAhead() { return KPRLookAhead(&mKPRQueue, NULL, NULL); } void putChar(wchar_t character) { KPRPutChar(&mKPRQueue, character); } bool isEmpty() const { return mKPRQueue.oCount == 0; } @@ -114,7 +119,9 @@ namespace textinput { class RowInfoManager { #ifdef TIINPUTFORM_IMPLEMENTATION friend class LayoutByNW4R; + friend class Base; public: + RowInfoManager(u16 maxLength) : mpInfo(NULL), mMaxLength(maxLength), mpAllocator(NULL) {} void init(); ~RowInfoManager(); #endif @@ -133,6 +140,7 @@ namespace textinput { void setCursorPos(tistring::Decolated* string, u32 pos); void calcCursorTimer(); bool isAtokActive() const; + bool isVacancy() const; void dirtyCacheAll(); tistring::Decolated* getCurrentString(bool inputting); void moveCandidateToIdx(s32 index); @@ -341,6 +349,9 @@ namespace textinput { virtual nw4r::math::VEC2 getScale() const; +#ifdef TIINPUTFORM_IMPLEMENTATION + void updateRepeatInput(u32 trig, u32 hold); +#endif virtual void updateInputCommon(int chan, u32 trig, u32 hold, u32 release, void* data); virtual bool updateInput(int chan, f32 x, f32 y, u32 trig, u32 hold, u32 release, void* data); virtual bool updateInput(textinput::input::HKBManager& hkbManager); diff --git a/include/keyboard/tiString.h b/include/keyboard/tiString.h index eb1c0923..030f80b3 100644 --- a/include/keyboard/tiString.h +++ b/include/keyboard/tiString.h @@ -3,6 +3,9 @@ #include #include +#ifdef TIINPUTFORM_IMPLEMENTATION +#include +#endif namespace textinput { namespace tistring { @@ -58,8 +61,15 @@ namespace textinput { }; class KanaStream { +#ifdef TIINPUTFORM_IMPLEMENTATION + public: + KPRQueue mQueue; + wchar_t mPending; + wchar_t mOutput[5]; +#else private: u8 field_0x00[0x24]; +#endif }; class Decolated : public StringBase { @@ -71,6 +81,7 @@ namespace textinput { #endif #ifdef TIINPUTFORM_IMPLEMENTATION + virtual ~Decolated(); enum TranslateMode { TM_Direct, TM_Kana, TM_Roman, TM_Hangul }; virtual void clear(); virtual void set(const wchar_t* string); @@ -168,6 +179,8 @@ namespace textinput { #ifdef TIINPUTFORM_IMPLEMENTATION class WithAtok : public Decolated { public: + WithAtok(u16 maxLength) : Decolated(maxLength) {} + virtual ~WithAtok(); virtual void pushBack(wchar_t ch); virtual void popBack(); virtual void inputChar(wchar_t ch); @@ -210,7 +223,7 @@ namespace textinput { virtual void setFixPrediction(int count, const char** predictions); virtual void setDefaultPrediction(int count, const char** predictions); virtual s16 getSelectedConverting(); - virtual s16 getFixedPredictionNum(); + virtual s32 getFixedPredictionNum(); }; #else class WithAtok : public StringBase {}; diff --git a/include/keyboard/tiTextDrawer.h b/include/keyboard/tiTextDrawer.h index 0549de73..ab231947 100644 --- a/include/keyboard/tiTextDrawer.h +++ b/include/keyboard/tiTextDrawer.h @@ -6,6 +6,9 @@ #include #include +#ifdef TIINPUTFORM_IMPLEMENTATION +#include +#endif namespace textinput { namespace textdrawer { @@ -39,6 +42,15 @@ namespace textinput { #endif } DrawInfo; +#ifdef TIINPUTFORM_IMPLEMENTATION + Base() : mpDrawAllocator(NULL), mfViewX(0.0f), mfViewY(0.0f), mfViewWidth(0.0f), mfViewHeight(0.0f), + mfVIWidth(640.0f), mbAspect4x3(false), mbDrawClipped(false), muLine(0), mfLineSpacing(0.0f), + mfCharacterSpacing(0.0f), mfFontWidth(0.0f), mfFontHeight(0.0f), mfModifyStartY(0.0f), mfMinScrollY(0.0f), + muDrawStartPos(0), muDrawEndPos(65535), mbSecretMode(false), muDrawModifyStartLine(0), muDrawModifyEndLine(0), + muDrawModifyStartPos(0), muDrawModifyEndPos(0), muCachedStartPos(0), muCachedEndPos(0), mbDrawCache(false), + mfCachedCursorX(0.0f), mfCachedCursorY(0.0f), mfDrawScrollY(0.0f), muCachedCursorPosition(0), + mbCursorCache(false), mbMaintainCursorCache(true) { memset(&mCachedCursor, 0, sizeof(mCachedCursor)); } +#endif virtual void create(MEMAllocator* allocator); virtual void draw(CursorPos* cursorPos); virtual void draw(); @@ -109,14 +121,22 @@ namespace textinput { #ifdef TIINPUTFORM_IMPLEMENTATION protected: - u8 mDrawConfiguration[0x50]; + MEMAllocator* mpDrawAllocator; + u8 mDrawConfiguration[0x34]; + f32 mfViewX; + f32 mfViewY; + f32 mfViewWidth; + f32 mfViewHeight; + f32 mfVIWidth; + bool mbAspect4x3; + bool mbDrawClipped; u32 muLine; f32 mfLineSpacing; f32 mfCharacterSpacing; f32 mfFontWidth; f32 mfFontHeight; - u32 muModifyStartLine; - u32 muModifyEndLine; + f32 mfModifyStartY; + f32 mfMinScrollY; u32 muDrawStartPos; u32 muDrawEndPos; u32 muDrawCacheStartPos; @@ -133,8 +153,13 @@ namespace textinput { u32 muCachedStartPos; u32 muCachedEndPos; bool mbDrawCache; - u8 mCursorCacheConfiguration[0x1F]; + f32 mfCachedCursorX; + f32 mfCachedCursorY; + f32 mfDrawScrollY; + u32 muCachedCursorPosition; + CursorPos mCachedCursor; bool mbCursorCache; + bool mbMaintainCursorCache; #elif defined(MYTIINPUTFORM_IMPLEMENTATION) protected: u8 mDrawState[0x27]; diff --git a/include/keyboard/tiTextInputBase.h b/include/keyboard/tiTextInputBase.h index 6858a425..46a21330 100644 --- a/include/keyboard/tiTextInputBase.h +++ b/include/keyboard/tiTextInputBase.h @@ -54,6 +54,10 @@ namespace textinput { class CommandSender; class CommandReceiver : public Base { public: +#ifdef TIINPUTFORM_IMPLEMENTATION + CommandReceiver() { clearSender(); } + virtual ~CommandReceiver(); +#endif #if defined(MYTIINPUTFORM_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) struct Scroll { bool absY; diff --git a/include/keyboard/tiZiString.h b/include/keyboard/tiZiString.h index b7ef92f8..4abc230d 100644 --- a/include/keyboard/tiZiString.h +++ b/include/keyboard/tiZiString.h @@ -13,6 +13,10 @@ namespace textinput { public: enum PredictLanguage { PL_Default }; enum LetterMode { LM_Lower, LM_Normal, LM_Upper }; + WithZi(u16 maxLength) : Decolated(maxLength), mbDictionaryOpen(false), mbContextChanged(false), + mCurrentWordLength(0), mpDictionaries(NULL), mpDictionaryWork(NULL), mInputLength(0), + mCandidateCount(0), mOemDictionaryId(0), mDictionaryLanguage(0xff), mSelectedCandidate(0), + mPredictLanguage(0), mLetterMode(2), mpHoldingKey(NULL), mbKoreanPartialConfirm(false) {} virtual ~WithZi(); virtual void init(); virtual void setInputting(wchar_t ch); @@ -33,7 +37,7 @@ namespace textinput { void setCurrentWord(const wchar_t* string); void update(); const wchar_t* getCurrentInput(); - void getCurrentInput(wchar_t* buffer, u32 length); + s32 getCurrentInput(wchar_t* buffer, u32 length); void clearCandidates(); void partialConfirmForKR(); private: @@ -52,6 +56,7 @@ namespace textinput { u32 mPredictLanguage; u32 mLetterMode; void* mpHoldingKey; + bool mbKoreanPartialConfirm; }; #else class WithZi { diff --git a/src/keyboard/tiInputForm.cpp b/src/keyboard/tiInputForm.cpp index e8b0e38a..e5862938 100644 --- a/src/keyboard/tiInputForm.cpp +++ b/src/keyboard/tiInputForm.cpp @@ -5,6 +5,7 @@ #include "keyboard/tiLayoutGather.h" #include +#include #include #include @@ -89,8 +90,8 @@ extern "C" asm void GetFontHeight__Q34nw4r2ut10CharWriterCFv(); extern "C" asm void GetFont__Q34nw4r2ut10CharWriterCFv(); extern "C" asm void SetFixedWidth__Q34nw4r2ut10CharWriterFf(); extern "C" asm void EnableFixedWidth__Q34nw4r2ut10CharWriterFb(); -extern "C" asm void KPRInitQueue(); -extern "C" asm void KPRSetMode(); +extern "C" void KPRInitQueue(KPRQueue* queue); +extern "C" void KPRSetMode(KPRQueue* queue, KPRMode mode); extern "C" asm void create__Q39textinput10textdrawer4BaseFP12MEMAllocator(); extern "C" asm void init__Q49textinput9inputform4Base14RowInfoManagerFv(); extern "C" asm void MEMAllocFromAllocator(); @@ -112,7 +113,7 @@ extern "C" asm void addCandidate__Q39textinput12candidatebox18CandidateBoxCaller extern "C" asm void updateCandidate__Q39textinput12candidatebox18CandidateBoxCallerFv(); extern "C" asm void setCurrentWord__Q39textinput8tistring6WithZiFPCw(); extern "C" asm void update__Q39textinput8tistring6WithZiFv(); -extern "C" asm void wcsnicmp(); +extern "C" int wcsnicmp(const wchar_t* left, const wchar_t* right, u32 length); extern "C" asm void List_Append__Q24nw4r2utFPQ34nw4r2ut4ListPv(); extern "C" asm void List_GetNext__Q24nw4r2utFPCQ34nw4r2ut4ListPCv(); extern "C" asm void List_Remove__Q24nw4r2utFPQ34nw4r2ut4ListPv(); @@ -159,8 +160,10 @@ extern "C" void _restgpr_20(); extern "C" void _savegpr_27(); extern "C" void _restgpr_27(); extern "C" asm void __ct__Q34nw4r2ut10CharWriterFv(); -extern "C" asm void memset(); -extern "C" asm void KPRInitRegionUS(); + + + + extern "C" asm void __vt__Q29textinput15CommandReceiver(); extern "C" asm void __vt__Q39textinput10textdrawer4Base(); extern "C" asm void __vt__Q39textinput9inputform4Base(); @@ -170,444 +173,86 @@ extern "C" asm void __vt__Q39textinput9inputform10EditBuffer(); extern "C" asm void __vt__Q39textinput8tistring9Decolated(); extern "C" asm void __vt__Q39textinput8tistring8WithAtok(); extern "C" asm void __vt__Q39textinput8tistring6WithZi(); -extern "C" asm void moveCandidateToIdx__Q39textinput9inputform4BaseFl() { - nofralloc - stwu r1, -0x20(r1) - mflr r0 - stw r0, 0x24(r1) - stw r31, 0x1c(r1) - stw r30, 0x18(r1) - mr r30, r4 - stw r29, 0x14(r1) - mr r29, r3 - lbz r0, 0x178(r3) - cmpwi r0, 0 - beq moveCandidateToIdx_L_set - lwz r3, 0x1d4(r3) - lwz r12, 0(r3) - lwz r12, 0x8c(r12) - mtctr r12 - bctrl - lwz r12, 0(r3) - lwz r12, 0x104(r12) - mtctr r12 - bctrl - cmpwi r3, 0 - bne moveCandidateToIdx_L_done - lwz r0, 0x174(r29) - cmpwi r0, 1 - bne moveCandidateToIdx_L_mid - lwz r3, 0x168(r29) - lwz r12, 0(r3) - lwz r12, 0x13c(r12) - mtctr r12 - bctrl - cmpwi r3, 0 - beq moveCandidateToIdx_L_select - lwz r3, 0x168(r29) - lwz r12, 0(r3) - lwz r12, 0xdc(r12) - mtctr r12 - bctrl - cmpwi r3, 0 - bne moveCandidateToIdx_L_select - lwz r3, 0x168(r29) - li r4, 0 - lwz r12, 0(r3) - lwz r12, 0x60(r12) - mtctr r12 - bctrl - lwz r3, 0x168(r29) - lwz r12, 0(r3) - lwz r12, 0xe0(r12) - mtctr r12 - bctrl - mr r31, r3 - lwz r3, 0x164(r29) - lwz r12, 0(r3) - lwz r12, 0x7c(r12) - mtctr r12 - bctrl - lwz r3, 0x164(r29) - mr r4, r31 - lwz r12, 0(r3) - lwz r12, 0x60(r12) - mtctr r12 - bctrl - lwz r3, 0x164(r29) - lwz r12, 0(r3) - lwz r12, 0x7c(r12) - mtctr r12 - bctrl - lwz r3, 0x168(r29) - li r4, 0 - lwz r12, 0(r3) - lwz r12, 0x114(r12) - mtctr r12 - bctrl -moveCandidateToIdx_L_select: - lwz r3, 0x168(r29) - mr r4, r30 - lwz r12, 0(r3) - lwz r12, 0xf0(r12) - mtctr r12 - bctrl - b moveCandidateToIdx_L_after -moveCandidateToIdx_L_mid: - lwz r3, 0x16c(r29) - mr r4, r30 - lwz r12, 0(r3) - lwz r12, 0xe8(r12) - mtctr r12 - bctrl -moveCandidateToIdx_L_after: - lwz r3, 0x1d4(r29) - lwz r12, 0(r3) - lwz r12, 0x8c(r12) - mtctr r12 - bctrl - mr r4, r30 - addi r3, r3, 0xe4 - bl ChangeSelectedText__Q39textinput12candidatebox10UITextAreaFl - b moveCandidateToIdx_L_done -moveCandidateToIdx_L_set: - li r0, 1 - stw r0, 0x1b0(r3) -moveCandidateToIdx_L_done: - lwz r0, 0x24(r1) - lwz r31, 0x1c(r1) - lwz r30, 0x18(r1) - lwz r29, 0x14(r1) - mtlr r0 - addi r1, r1, 0x20 - blr +void Base::moveCandidateToIdx(s32 index) { + if (mbPredictOn) { + if (mpManager->getCandidateBox()->isInScroll()) return; + if (mePredictMode == PM_Atok) { + if (mpUnfixString->getFixedPredictionNum() && !mpUnfixString->isConverting()) { + mpUnfixString->confirm(NULL); + wchar_t* confirmed = mpUnfixString->getConfirmedWCString(); + mpString->getCursorPos(); + mpString->confirm(confirmed); + mpString->getCursorPos(); + mpUnfixString->enableConfirmedString(false); + } + mpUnfixString->setSelectedCandidate(index); + } else { + mpZiString->setSelectedCandidate(index); + } + mpManager->getCandidateBox()->getTextArea().ChangeSelectedText(index); + } else { + meScrollFlag = SF_ScrollOn; + } } -extern "C" asm void confirmInput___Q39textinput9inputform4BaseFv() { - nofralloc - stwu r1, -0x20(r1) - mflr r0 - stw r0, 0x24(r1) - stw r31, 0x1c(r1) - stw r30, 0x18(r1) - mr r30, r3 - lbz r0, 0x178(r3) - cmpwi r0, 0 - bne confirmInput_L_atok - lwz r3, 0x164(r3) - lwz r12, 0(r3) - lwz r12, 0xc0(r12) - mtctr r12 - bctrl - cmpwi r3, 0 - bne confirmInput_L_end - lwz r3, 0x164(r30) - lwz r12, 0(r3) - lwz r12, 0x7c(r12) - mtctr r12 - bctrl - lwz r3, 0x164(r30) - lwz r12, 0(r3) - lwz r12, 0xc4(r12) - mtctr r12 - bctrl - lwz r3, 0x164(r30) - lwz r12, 0(r3) - lwz r12, 0x7c(r12) - mtctr r12 - bctrl - b confirmInput_L_end -confirmInput_L_atok: - lwz r0, 0x174(r3) - cmpwi r0, 1 - bne confirmInput_L_zi - lwz r3, 0x168(r3) - lwz r12, 0(r3) - lwz r12, 0xf4(r12) - mtctr r12 - bctrl - cmpwi r3, 0 - beq confirmInput_L_atok_empty - lwz r3, 0x168(r30) - lwz r12, 0(r3) - lwz r12, 0xf8(r12) - mtctr r12 - bctrl - stw r3, 8(r1) - mr r3, r30 - addi r5, r1, 8 - li r4, 0x15 - lwz r12, 0(r30) - lwz r12, 0x18(r12) - mtctr r12 - bctrl - b confirmInput_L_end -confirmInput_L_atok_empty: - lwz r3, 0x168(r30) - li r4, 0 - lwz r12, 0(r3) - lwz r12, 0x60(r12) - mtctr r12 - bctrl - lwz r3, 0x168(r30) - lwz r12, 0(r3) - lwz r12, 0xe0(r12) - mtctr r12 - bctrl - mr r31, r3 - lwz r3, 0x164(r30) - lwz r12, 0(r3) - lwz r12, 0x7c(r12) - mtctr r12 - bctrl - lwz r3, 0x164(r30) - mr r4, r31 - lwz r12, 0(r3) - lwz r12, 0x60(r12) - mtctr r12 - bctrl - lwz r3, 0x164(r30) - lwz r12, 0(r3) - lwz r12, 0x7c(r12) - mtctr r12 - bctrl - lwz r3, 0x168(r30) - li r4, 0 - lwz r12, 0(r3) - lwz r12, 0x114(r12) - mtctr r12 - bctrl - b confirmInput_L_end -confirmInput_L_zi: - lwz r3, 0x16c(r3) - lwz r12, 0(r3) - lwz r12, 0xe0(r12) - mtctr r12 - bctrl - mr r31, r3 - lwz r3, 0x16c(r30) - lwz r12, 0(r3) - lwz r12, 0xe4(r12) - mtctr r12 - bctrl - clrlwi. r0, r3, 0x10 - beq confirmInput_L_clear - lwz r3, 0x164(r30) - lwz r12, 0(r3) - lwz r12, 0x7c(r12) - mtctr r12 - bctrl - lwz r3, 0x164(r30) - mr r4, r31 - lwz r12, 0(r3) - lwz r12, 0x54(r12) - mtctr r12 - bctrl - lwz r3, 0x164(r30) - lwz r12, 0(r3) - lwz r12, 0x7c(r12) - mtctr r12 - bctrl - lwz r0, 0x1f0(r30) - cmpwi r0, 8 - bne confirmInput_L_clear - lwz r3, 0x16c(r30) - mr r4, r31 - bl setCurrentWord__Q39textinput8tistring6WithZiFPCw -confirmInput_L_clear: - lwz r3, 0x16c(r30) - bl clearCandidates__Q39textinput8tistring6WithZiFv - lwz r0, 0x1f0(r30) - li r3, 0 - stb r3, 0x1f4(r30) - cmpwi r0, 8 - bne confirmInput_L_end - lwz r3, 0x16c(r30) - bl update__Q39textinput8tistring6WithZiFv -confirmInput_L_end: - lwz r0, 0x24(r1) - lwz r31, 0x1c(r1) - lwz r30, 0x18(r1) - mtlr r0 - addi r1, r1, 0x20 - blr +void Base::confirmInput_() { + if (!mbPredictOn) { + if (!mpString->isKanaFix()) { + mpString->getCursorPos(); + mpString->confirmKana(); + mpString->getCursorPos(); + } + } else if (mePredictMode == PM_Atok) { + if (mpUnfixString->isCandidateSelected()) { + s32 selected = mpUnfixString->getSelectedCandidate(); + onCommand(static_cast(21), &selected); + } else { + mpUnfixString->confirm(NULL); + wchar_t* confirmed = mpUnfixString->getConfirmedWCString(); + mpString->getCursorPos(); + mpString->confirm(confirmed); + mpString->getCursorPos(); + mpUnfixString->enableConfirmedString(false); + } + } else { + const wchar_t* selected = mpZiString->getCurrentSelected(); + if (mpZiString->getInputStringLength()) { + mpString->getCursorPos(); + mpString->inputString(selected); + mpString->getCursorPos(); + if (meLanguage == CN) mpZiString->setCurrentWord(selected); + } + mpZiString->clearCandidates(); + mbZuSelected = false; + if (meLanguage == CN) mpZiString->update(); + } } -extern "C" asm void inputInputting___Q39textinput9inputform4BaseFw() { - nofralloc - stwu r1, -0x20(r1) - mflr r0 - stw r0, 0x24(r1) - stw r31, 0x1c(r1) - stw r30, 0x18(r1) - mr r30, r4 - li r4, 0 - stw r29, 0x14(r1) - mr r29, r3 - bl getCurrentString__Q39textinput9inputform4BaseFb - addis r4, r30, 1 - mr r31, r3 - addi r0, r4, -0x309b - clrlwi r0, r0, 0x10 - cmplwi r0, 1 - bgt inputInputting_L_command - lwz r12, 0(r29) - mr r3, r29 - li r4, 0x1b - li r5, 0 - lwz r12, 0x18(r12) - mtctr r12 - bctrl - b inputInputting_L_end -inputInputting_L_command: - lbz r3, 0x178(r29) - cmpwi r3, 0 - beq inputInputting_L_atok_empty - lwz r0, 0x174(r29) - cmpwi r0, 1 - bne inputInputting_L_atok_empty - lwz r3, 0x168(r29) - lwz r12, 0(r3) - lwz r12, 0xf4(r12) - mtctr r12 - bctrl - cmpwi r3, 0 - beq inputInputting_L_direct_input - lwz r12, 0(r29) - mr r3, r29 - li r4, 6 - li r5, 0 - lwz r12, 0x18(r12) - mtctr r12 - bctrl -inputInputting_L_direct_input: - lwz r3, 0x168(r29) - mr r4, r30 - lwz r12, 0(r3) - lwz r12, 0x100(r12) - mtctr r12 - bctrl - b inputInputting_L_end -inputInputting_L_atok_empty: - cmpwi r3, 0 - beq inputInputting_L_skip_atok - lwz r12, 0(r29) - mr r3, r29 - lwz r12, 0x114(r12) - mtctr r12 - bctrl - cmpwi r3, 0xb - bne inputInputting_L_skip_atok - lwz r3, 0x1d4(r29) - lwz r12, 0(r3) - lwz r12, 0x8c(r12) - mtctr r12 - bctrl - lwz r12, 0(r3) - lwz r12, 0x4c(r12) - mtctr r12 - bctrl - cmpwi r3, 0 - bne inputInputting_L_skip_atok - mr r3, r30 - bl isAlphabet__Q29textinput4utilFw - cmpwi r3, 0 - bne inputInputting_L_zi_input - cmplwi r30, 0x31 - blt inputInputting_L_keyboard_mode - cmplwi r30, 0x35 - bgt inputInputting_L_keyboard_mode -inputInputting_L_zi_input: - lwz r3, 0x16c(r29) - mr r4, r30 - lwz r12, 0(r3) - lwz r12, 0xd4(r12) - mtctr r12 - bctrl - b inputInputting_L_end -inputInputting_L_keyboard_mode: - lbz r0, 0x178(r29) - cmpwi r0, 0 - bne inputInputting_L_predict_mode - li r0, 0 - b inputInputting_L_input_check -inputInputting_L_predict_mode: - lwz r0, 0x174(r29) - cmpwi r0, 1 - beq inputInputting_L_input_false - lwz r3, 0x16c(r29) - lwz r12, 0(r3) - lwz r12, 0xd8(r12) - mtctr r12 - bctrl - cmpwi r3, 0 - ble inputInputting_L_input_false - li r0, 1 - b inputInputting_L_input_check -inputInputting_L_input_false: - li r0, 0 -inputInputting_L_input_check: - cmpwi r0, 0 - beq inputInputting_L_manager - lwz r3, 0x16c(r29) - lwz r12, 0(r3) - lwz r12, 0xe4(r12) - mtctr r12 - bctrl - clrlwi. r0, r3, 0x10 - beq inputInputting_L_manager - lwz r0, 0x1f0(r29) - cmpwi r0, 8 - bne inputInputting_L_get_current - lwz r3, 0x16c(r29) - lwz r12, 0(r3) - lwz r12, 0x48(r12) - mtctr r12 - bctrl - cmpwi r3, 0 - bne inputInputting_L_manager -inputInputting_L_get_current: - mr r3, r29 - bl getCurrentString__Q39textinput9inputform4BaseFb -inputInputting_L_manager: - lwz r3, 0x16c(r29) - mr r4, r30 - lwz r12, 0(r3) - lwz r12, 0xd4(r12) - mtctr r12 - bctrl - lwz r3, 0x16c(r29) - li r4, -1 - lwz r12, 0(r3) - lwz r12, 0xe8(r12) - mtctr r12 - bctrl - b inputInputting_L_done -inputInputting_L_skip_atok: - lwz r12, 0(r31) - mr r3, r31 - mr r4, r30 - lwz r12, 0x40(r12) - mtctr r12 - bctrl -inputInputting_L_end: - cmpwi r30, 0 - beq inputInputting_L_return - lwz r12, 0(r29) - mr r3, r29 - li r4, 0xa - lwz r12, 0x178(r12) - mtctr r12 - bctrl -inputInputting_L_return: - li r0, 1 - stw r0, 0x1b0(r29) -inputInputting_L_done: - lwz r0, 0x24(r1) - lwz r31, 0x1c(r1) - lwz r30, 0x18(r1) - lwz r29, 0x14(r1) - mtlr r0 - addi r1, r1, 0x20 - blr +void Base::inputInputting_(wchar_t character) { + tistring::Decolated* current = getCurrentString(false); + if (static_cast(character + 0xcf65) <= 1) { + onCommand(static_cast(27), NULL); + } else if (mbPredictOn && mePredictMode == PM_Atok) { + if (mpUnfixString->isCandidateSelected()) onCommand(static_cast(6), NULL); + mpUnfixString->setInputting(character); + } else { + if (mbPredictOn && getPredictMode() == PM_11 && !mpManager->getCandidateBox()->isInvalid()) { + if (util::isAlphabet(character) || (character >= L'1' && character <= L'5')) { + mpZiString->setInputting(character); + } else { + bool predictions; + if (!mbPredictOn) predictions = false; + else if (mePredictMode != PM_Atok && mpZiString->getCurrentNumPredicted() > 0) predictions = true; + else predictions = false; + if (predictions && mpZiString->getInputStringLength() != 0 && (meLanguage != CN || !mpZiString->hasCandidate())) confirmInput_(); + mpZiString->setInputting(character); + mpZiString->setSelectedCandidate(-1); + return; + } + } else { + current->setCandidate(character); + } + } + if (character != 0) onSE(static_cast(10)); + meScrollFlag = SF_ScrollOn; } void Base::inputCharDefault_(wchar_t character, u32 modifiers) { tistring::WithAtok* unfix; @@ -638,154 +283,7 @@ void Base::inputCharDefault_(wchar_t character, u32 modifiers) { else if (character != L'\n') onSE(static_cast(10)); meScrollFlag = SF_ScrollOn; } -extern "C" asm void calc__Q39textinput9inputform12LayoutByNW4RFv() { - nofralloc - stwu r1, -0x20(r1) - mflr r0 - stw r0, 0x24(r1) - stw r31, 0x1c(r1) - lis r31, lbl_8165C820@ha - addi r31, r31, lbl_8165C820@l - stw r30, 0x18(r1) - stw r29, 0x14(r1) - stw r28, 0x10(r1) - mr r28, r3 - bl calc__Q39textinput9inputform4BaseFv - addi r3, r28, 0x218 - bl calc__Q39textinput11nw4rmanager6LayoutFv - lwz r12, 0x218(r28) - addi r3, r28, 0x218 - lwz r4, 0x2c4(r28) - li r30, 0 - lwz r12, 0x2c(r12) - li r29, 0 - lwz r4, 4(r4) - mtctr r12 - bctrl - cmpwi r3, 0 - beq calcLayout_L_text - lwz r12, 0x218(r28) - addi r3, r28, 0x218 - lwz r4, 0x2c4(r28) - lwz r12, 0x54(r12) - lwz r4, 4(r4) - lbz r5, 0x2ce(r28) - mtctr r12 - bctrl - b calcLayout_L_animation -calcLayout_L_text: - lwz r12, 0x218(r28) - addi r3, r28, 0x218 - addi r4, r31, 0x418 - lbz r5, 0x2ce(r28) - lwz r12, 0x54(r12) - mtctr r12 - bctrl -calcLayout_L_animation: - lwz r12, 0x18c(r28) - addi r3, r28, 0x18c - lwz r12, 0x14(r12) - mtctr r12 - bctrl - cmpwi r3, 0 - bne calcLayout_L_done - lfs f1, lbl_81694D28(r0) - lfs f0, 0x188(r28) - fcmpo cr0, f1, f0 - ble calcLayout_L_scroll_x - li r30, 1 -calcLayout_L_scroll_x: - lfs f1, 0xc8(r28) - lfs f0, 0x188(r28) - fcmpo cr0, f1, f0 - bge calcLayout_L_scroll_y - li r29, 1 -calcLayout_L_scroll_y: - lbz r0, 0x2cc(r28) - cmplw r0, r30 - beq calcLayout_L_second_flag - cmpwi r30, 0 - stb r30, 0x2cc(r28) - beq calcLayout_L_first_disable - lwz r12, 0x218(r28) - addi r3, r28, 0x218 - addi r4, r31, 0x3f4 - lwz r12, 0x60(r12) - mtctr r12 - bctrl - lwz r12, 0(r3) - li r4, 6 - lwz r12, 0x10(r12) - mtctr r12 - bctrl - lwz r3, 0x228(r28) - addi r4, r31, 0x3f4 - bl searchPaneComponent__Q39textinput3gui11PaneManagerFPCc - lwz r12, 0(r3) - lwz r12, 0x10(r12) - mtctr r12 - bctrl - b calcLayout_L_second_flag -calcLayout_L_first_disable: - lwz r12, 0x218(r28) - addi r3, r28, 0x218 - addi r4, r31, 0x3f4 - lwz r12, 0x60(r12) - mtctr r12 - bctrl - lwz r12, 0(r3) - li r4, 7 - lwz r12, 0x10(r12) - mtctr r12 - bctrl -calcLayout_L_second_flag: - lbz r0, 0x2cd(r28) - cmplw r0, r29 - beq calcLayout_L_done - cmpwi r29, 0 - stb r29, 0x2cd(r28) - beq calcLayout_L_second_disable - lwz r12, 0x218(r28) - addi r3, r28, 0x218 - addi r4, r31, 0x408 - lwz r12, 0x60(r12) - mtctr r12 - bctrl - lwz r12, 0(r3) - li r4, 6 - lwz r12, 0x10(r12) - mtctr r12 - bctrl - lwz r3, 0x228(r28) - addi r4, r31, 0x408 - bl searchPaneComponent__Q39textinput3gui11PaneManagerFPCc - lwz r12, 0(r3) - lwz r12, 0x10(r12) - mtctr r12 - bctrl - b calcLayout_L_done -calcLayout_L_second_disable: - lwz r12, 0x218(r28) - addi r3, r28, 0x218 - addi r4, r31, 0x408 - lwz r12, 0x60(r12) - mtctr r12 - bctrl - lwz r12, 0(r3) - li r4, 7 - lwz r12, 0x10(r12) - mtctr r12 - bctrl -calcLayout_L_done: - lwz r0, 0x24(r1) - lwz r31, 0x1c(r1) - lwz r30, 0x18(r1) - lwz r29, 0x14(r1) - lwz r28, 0x10(r1) - mtlr r0 - addi r1, r1, 0x20 - blr -} + extern "C" asm void draw__Q39textinput9inputform12LayoutByNW4RFv() { nofralloc stwu r1, -0x50(r1) @@ -906,19 +404,10 @@ extern "C" asm void draw__Q39textinput9inputform12LayoutByNW4RFv() { void Base::calcCursorTimer() { muCursorTimer += 8; } -extern "C" asm bool isAtokActive__Q39textinput9inputform4BaseCFv() { - nofralloc - lbz r0, 0x178(r3) - cmpwi r0, 0 - bne isAtokActive_L1 - li r3, 0 - blr -isAtokActive_L1: - lwz r3, 0x174(r3) - addi r0, r3, -1 - cntlzw r0, r0 - srwi r3, r0, 5 - blr +bool Base::isAtokActive() const { + u32 enabled = mbPredictOn; + if (enabled == 0) return false; + return mePredictMode == PM_Atok; } void Base::dirtyCacheAll() { dirtyCursorCache(); @@ -1015,10 +504,7 @@ extern "C" const void* csLanguageDependencyDataCHN__Q29textinput9inputform[4] = }; #pragma section data_type ".data" -extern "C" const u32 pppURLCheck[10] = { - 0x00680074, 0x00740070, 0x003A002F, 0x002F0000, 0x00000000, - 0x00680074, 0x00740070, 0x0073003A, 0x002F002F, 0x00000000 -}; +extern "C" const wchar_t pppURLCheck[2][10] = {L"http://", L"https://"}; extern "C" const u32 lbl_816152D0[4] = {0x00200000, 0, 0, 0}; #pragma pop @@ -1048,7 +534,7 @@ extern "C" const f32 lbl_81694D74 = 127.0f; extern "C" const f32 lbl_81694D78 = 14592.0f; extern "C" const f64 lbl_81694D80 = 4503599627370496.0; extern "C" const f32 lbl_81694D88 = 15.0f; -extern "C" f32 lbl_81698D1C; +f32 sfColorPhase; bool mbHyphen = true; @@ -1845,7 +1331,33 @@ void LayoutByNW4R::init() { for (u16 index = 0; index < visibility->visibleCount; ++index) setVisible(visibility->visibleNames[index], true); for (u16 index = 0; index < visibility->hiddenCount; ++index) setVisible(visibility->hiddenNames[index], false); } -extern "C" const char lbl_8165D2A0[] = "N_separateBarAll"; +void LayoutByNW4R::calc() { + Base::calc(); + nw4rmanager::Layout::calc(); + bool up = false; + bool down = false; + const char* separator = static_cast(mpLanguageData)->separator; + if (getPane(separator)) setVisible(static_cast(mpLanguageData)->separator, mbRepeat); + else setVisible("N_separateBarAll", mbRepeat); + if (!mScrollAnm.isActive()) { + if (0.0f > mfScrollY) up = true; + if (mfMinScrollY < mfScrollY) down = true; + if (mbUpVisible != up) { + mbUpVisible = up; + if (up) { + searchAnmPane("P_txtScrll_UP")->onAnmEvent(nw4rmanager::AnmPane::PE_6); + mpPaneManager->searchPaneComponent("P_txtScrll_UP")->init(); + } else searchAnmPane("P_txtScrll_UP")->onAnmEvent(nw4rmanager::AnmPane::PE_7); + } + if (mbDownVisible != down) { + mbDownVisible = down; + if (down) { + searchAnmPane("P_txtScrll_DOWN")->onAnmEvent(nw4rmanager::AnmPane::PE_6); + mpPaneManager->searchPaneComponent("P_txtScrll_DOWN")->init(); + } else searchAnmPane("P_txtScrll_DOWN")->onAnmEvent(nw4rmanager::AnmPane::PE_7); + } + } +} void LayoutByNW4R::setLanguage(Language language) { Base::setLanguage(language); if (language == CN) mpLanguageData = csLanguageDependencyDataCHN__Q29textinput9inputform; @@ -2340,21 +1852,10 @@ void textinput::util::Animation::startAnm(f32 start, f32 end, f32 duration, Anim namespace inputform { -extern "C" asm void deselectCandidate__Q39textinput9inputform4BaseFv() { - nofralloc - lbz r0, 0x178(r3) - cmpwi r0, 0 - beqlr - lwz r0, 0x174(r3) - cmpwi r0, 1 - bnelr - lwz r3, 0x168(r3) - li r4, -1 - lwz r12, 0(r3) - lwz r12, 0xf0(r12) - mtctr r12 - bctr - blr +void Base::deselectCandidate() { + if (!mbPredictOn) return; + if (mePredictMode != PM_Atok) return; + mpUnfixString->setSelectedCandidate(-1); } void Base::resetRelation() { @@ -2362,89 +1863,30 @@ void Base::resetRelation() { mpUnfixString->resetRelation(); } -extern "C" asm void init__Q39textinput9inputform4BaseFv() { - nofralloc - stwu r1, -0x20(r1) - mflr r0 - lfs f0, lbl_81694D28(r0) - stw r0, 0x24(r1) - li r0, 0xff - stw r31, 0x1c(r1) - li r31, 0 - stw r30, 0x18(r1) - mr r30, r3 - stw r31, 0x170(r3) - stfs f0, 0x17c(r3) - stfs f0, 0x180(r3) - stfs f0, 0x184(r3) - stfs f0, 0x188(r3) - stfs f0, 0x1ac(r3) - stfs f0, 0x1c4(r3) - stb r0, 0x1c8(r3) - addi r3, r3, 0x1d8 - bl KPRInitQueue - addi r3, r30, 0x1d8 - li r4, 2 - bl KPRSetMode - addi r3, r30, 0x10 - bl GetFont__Q34nw4r2ut10CharWriterCFv - lwz r12, 0(r3) - lwz r12, 0xc(r12) - mtctr r12 - bctrl - xoris r3, r3, 0x8000 - lis r0, 0x4330 - stw r3, 0xc(r1) - addi r3, r30, 0x10 - lfd f1, lbl_81694D30(r0) - stw r0, 8(r1) - lfd f0, 8(r1) - fsubs f1, f0, f1 - bl SetFixedWidth__Q34nw4r2ut10CharWriterFf - addi r3, r30, 0x10 - li r4, 0 - bl EnableFixedWidth__Q34nw4r2ut10CharWriterFb - lwz r12, 0(r30) - mr r3, r30 - li r4, 1 - lwz r12, 0x130(r12) - mtctr r12 - bctrl - lwz r3, 0x1d4(r30) - lwz r12, 0(r3) - lwz r12, 0x6c(r12) - mtctr r12 - bctrl - stb r31, 0x15(r3) - stb r31, 0x16(r3) - lwz r3, 0x168(r30) - lwz r12, 0(r3) - lwz r12, 0x128(r12) - mtctr r12 - bctrl - lwz r12, 0(r30) - mr r3, r30 - lwz r12, 0xd8(r12) - mtctr r12 - bctrl - lwz r12, 0x5c(r30) - addi r3, r30, 0x10 - lwz r12, 0x90(r12) - mtctr r12 - bctrl - lwz r12, 0x5c(r30) - addi r3, r30, 0x10 - lwz r12, 0x94(r12) - mtctr r12 - bctrl - lfs f0, 0x188(r30) - stfs f0, 0x100(r30) - lwz r31, 0x1c(r1) - lwz r30, 0x18(r1) - lwz r0, 0x24(r1) - mtlr r0 - addi r1, r1, 0x20 - blr +inline void DeadKeyStream::init() { + KPRInitQueue(&mKPRQueue); + KPRSetMode(&mKPRQueue, KPR_MODE_DEADKEY); +} + +void Base::init() { + meInputMode = IM_Direct; + mfCursorX = 0.0f; + mfCursorY = 0.0f; + mfScrollX = 0.0f; + mfScrollY = 0.0f; + mfSustainTimer = 0.0f; + mfCursorTimer = 0.0f; + muGlobalAlpha = 255; + mDKStream.init(); + SetFixedWidth(GetFont()->GetWidth()); + EnableFixedWidth(false); + enableSpaceByRight(true); + mpManager->getHWKeyboard()->resetQuoteState(); + mpUnfixString->resetRelation(); + updateCandidateState_(); + dirtyDrawCache(); + dirtyCursorCache(); + mfDrawScrollY = mfScrollY; } extern "C" asm void create__Q39textinput9inputform4BaseFP12MEMAllocatorPQ39textinput9inputform10EditBuffer() { @@ -2651,364 +2093,79 @@ getCurrentString_Lend: blr } -extern "C" asm bool isVacancy__Q39textinput9inputform4BaseCFv() { - nofralloc - stwu r1, -0x30(r1) - mflr r0 - stw r0, 0x34(r1) - stw r31, 0x2c(r1) - mr r31, r3 - lwz r3, 0x164(r3) - lwz r12, 0(r3) - lwz r12, 0x1c(r12) - mtctr r12 - bctrl - clrlwi. r0, r3, 16 - bne isVacancy_L1 - lwz r3, 0x164(r31) - lwz r12, 0(r3) - lwz r12, 0xc0(r12) - mtctr r12 - bctrl - cmpwi r3, 0 - bne isVacancy_L2 -isVacancy_L1: - li r3, 0 - b isVacancy_Lend -isVacancy_L2: - lwz r0, 0x174(r31) - cmpwi r0, 1 - bne isVacancy_L3 - lwz r3, 0x168(r31) - lwz r12, 0(r3) - lwz r12, 0xd0(r12) - mtctr r12 - bctrl - cmpwi r3, 0 - bne isVacancy_L4 - li r3, 0 - b isVacancy_Lend -isVacancy_L4: - lwz r3, 0x164(r31) - lwz r12, 0(r3) - lwz r12, 0x1c(r12) - mtctr r12 - bctrl - clrlwi. r0, r3, 16 - beq isVacancy_L5 - li r3, 0 - b isVacancy_Lend -isVacancy_L5: - lwz r3, 0x168(r31) - lwz r12, 0(r3) - lwz r12, 0xf4(r12) - mtctr r12 - bctrl - cmpwi r3, 0 - beq isVacancy_L6 - li r3, 0 - b isVacancy_Lend -isVacancy_L3: - cmpwi r0, 0xc - bne isVacancy_L7 - li r3, 1 - b isVacancy_Lend -isVacancy_L7: - cmpwi r0, 0 - beq isVacancy_L6 - lwz r3, 0x16c(r31) - lwz r12, 0(r3) - lwz r12, 0x1c(r12) - mtctr r12 - bctrl - clrlwi. r0, r3, 16 - beq isVacancy_L8 - li r3, 0 - b isVacancy_Lend -isVacancy_L8: - lwz r3, 0x16c(r31) - addi r4, r1, 8 - li r5, 0x10 - bl getCurrentInput__Q39textinput8tistring6WithZiFPwUl - cmpwi r3, 0 - ble isVacancy_L9 - li r3, 0 - b isVacancy_Lend -isVacancy_L9: - lbz r3, 0x1f5(r31) - lbz r0, 0x1f4(r31) - or. r0, r3, r0 - beq isVacancy_L6 - lwz r3, 0x16c(r31) - lwz r12, 0(r3) - lwz r12, 0xe0(r12) - mtctr r12 - bctrl - cmpwi r3, 0 - beq isVacancy_L6 - lhz r0, 0(r3) - cmplwi r0, 0xfffe - beq isVacancy_L6 - li r3, 0 - b isVacancy_Lend -isVacancy_L6: - li r3, 1 -isVacancy_Lend: - lwz r0, 0x34(r1) - lwz r31, 0x2c(r1) - mtlr r0 - addi r1, r1, 0x30 - blr +bool Base::isVacancy() const { + if (mpString->getLength() != 0 || !mpString->isKanaFix()) return false; + if (mePredictMode == PM_Atok) { + if (!mpUnfixString->isFix()) return false; + if (mpString->getLength() != 0) return false; + if (mpUnfixString->isCandidateSelected()) return false; + } else { + if (mePredictMode == PM_12) return true; + if (mePredictMode != PM_Off) { + if (mpZiString->getLength() != 0) return false; + wchar_t input[16]; + if (mpZiString->getCurrentInput(input, 16) > 0) return false; + if (mbCursorSelected | mbZuSelected) { + const wchar_t* selected = mpZiString->getCurrentSelected(); + if (selected && *selected != 0xfffe) return false; + } + } + } + return true; } -extern "C" asm void notifyChangeMode__Q39textinput9inputform4BaseFv() { - nofralloc - stwu r1, -0x10(r1) - mflr r0 - stw r0, 0x14(r1) - stw r31, 0xc(r1) - mr r31, r3 - lwz r0, 0x174(r3) - cmpwi r0, 1 - bne notifyChangeMode_L1 - lwz r3, 0x1d4(r3) - lwz r12, 0(r3) - lwz r12, 0x94(r12) - mtctr r12 - bctrl - lwz r12, 0(r3) - lwz r12, 0x10(r12) - mtctr r12 - bctrl - cmpwi r3, 0 - beq notifyChangeMode_L2 - lwz r3, 0x1d4(r31) - lwz r12, 0(r3) - lwz r12, 0x74(r12) - mtctr r12 - bctrl - lwz r12, 0(r3) - lwz r12, 0x48(r12) - mtctr r12 - bctrl - cmpwi r3, 0 - beq notifyChangeMode_L2 - lwz r3, 0x1d4(r31) - lwz r12, 0(r3) - lwz r12, 0x74(r12) - mtctr r12 - bctrl - lwz r12, 0(r3) - lwz r12, 0x58(r12) - mtctr r12 - bctrl - cmpwi r3, 0 - beq notifyChangeMode_L3 -notifyChangeMode_L2: - lwz r3, 0x1d4(r31) - lwz r12, 0(r3) - lwz r12, 0x94(r12) - mtctr r12 - bctrl - lwz r12, 0(r3) - lwz r12, 0x10(r12) - mtctr r12 - bctrl - cmpwi r3, 0 - bne notifyChangeMode_L3 - lwz r3, 0x1d4(r31) - lwz r12, 0(r3) - lwz r12, 0x7c(r12) - mtctr r12 - bctrl - lwz r12, 0(r3) - lwz r12, 0x40(r12) - mtctr r12 - bctrl -notifyChangeMode_L3: - lwz r3, 0x168(r31) - lwz r12, 0(r3) - lwz r12, 0x124(r12) - mtctr r12 - bctrl - clrlwi. r0, r3, 16 - bne notifyChangeMode_L4 - lwz r12, 0(r31) - mr r3, r31 - lwz r12, 0xd8(r12) - mtctr r12 - bctrl - b notifyChangeMode_L4 -notifyChangeMode_L1: - cmpwi r0, 0xc - bne notifyChangeMode_L5 - lwz r3, 0x1d4(r3) - lwz r12, 0(r3) - lwz r12, 0x94(r12) - mtctr r12 - bctrl - lwz r12, 0(r3) - lwz r12, 0x10(r12) - mtctr r12 - bctrl - cmpwi r3, 0 - li r4, 0xb - beq notifyChangeMode_L6 - li r4, 0xa -notifyChangeMode_L6: - lwz r3, 0x16c(r31) - lwz r12, 0(r3) - lwz r12, 0xf0(r12) - mtctr r12 - bctrl - b notifyChangeMode_L4 -notifyChangeMode_L5: - cmpwi r0, 0xb - bne notifyChangeMode_L4 - lbz r0, 0x178(r3) - cmpwi r0, 0 - beq notifyChangeMode_L4 - lwz r3, 0x16c(r3) - li r4, 0 - bl setCurrentWord__Q39textinput8tistring6WithZiFPCw -notifyChangeMode_L4: - lwz r0, 0x14(r1) - lwz r31, 0xc(r1) - mtlr r0 - addi r1, r1, 0x10 - blr +void Base::notifyChangeMode() { + if (mePredictMode == PM_Atok) { + if (mpManager->getToolBar()->isQwerty()) { + if (mpManager->getPCKeyboard()->isABC()) { + if (!mpManager->getPCKeyboard()->getTranslateMode()) goto checkInput; + } + } + if (!mpManager->getToolBar()->isQwerty()) mpManager->getCellPhoneKeyboard()->getInputMode(); +checkInput: + if (mpUnfixString->getInputStringLength() == 0) updateCandidateState_(); + } else if (mePredictMode == PM_12) { + tistring::WithZi::PredictLanguage language; + if (mpManager->getToolBar()->isQwerty()) language = static_cast(10); + else language = static_cast(11); + mpZiString->setPredictLaunguage(language); + } else if (mePredictMode == PM_11) { + if (mbPredictOn) mpZiString->setCurrentWord(NULL); + } } -extern "C" asm void updateCandidateState___Q39textinput9inputform4BaseFv() { - nofralloc - stwu r1, -0xa0(r1) - mflr r0 - stw r0, 0xa4(r1) - stw r31, 0x9c(r1) - stw r30, 0x98(r1) - stw r29, 0x94(r1) - mr r29, r3 - lbz r0, 0x178(r3) - cmpwi r0, 0 - beq updateCandidateState_Lend - lwz r0, 0x174(r3) - cmpwi r0, 1 - bne updateCandidateState_L1 - lwz r3, 0x168(r3) - lwz r12, 0(r3) - lwz r12, 0x110(r12) - mtctr r12 - bctrl - cmpwi r3, 0 - beq updateCandidateState_L2 - lwz r3, 0x168(r29) - lwz r12, 0(r3) - lwz r12, 0xe0(r12) - mtctr r12 - bctrl - mr r31, r3 - lwz r3, 0x164(r29) - lwz r12, 0(r3) - lwz r12, 0x7c(r12) - mtctr r12 - bctrl - lwz r3, 0x164(r29) - mr r4, r31 - lwz r12, 0(r3) - lwz r12, 0x60(r12) - mtctr r12 - bctrl - lwz r3, 0x164(r29) - lwz r12, 0(r3) - lwz r12, 0x7c(r12) - mtctr r12 - bctrl - lwz r3, 0x168(r29) - li r4, 0 - lwz r12, 0(r3) - lwz r12, 0x114(r12) - mtctr r12 - bctrl - lwz r12, 0(r29) - mr r3, r29 - li r4, 9 - lwz r12, 0x178(r12) - mtctr r12 - bctrl -updateCandidateState_L2: - li r0, 0 - mr r3, r29 - stb r0, 8(r1) - addi r5, r1, 8 - li r4, 0x23 - bl onCommand__Q29textinput15CommandReceiverFQ39textinput15CommandReceiver13INPUT_COMMANDPv - addi r3, r29, 0x118 - bl resetCandidate__Q39textinput12candidatebox18CandidateBoxCallerFv - lbz r0, 8(r1) - cmpwi r0, 0 - bne updateCandidateState_Lend - lwz r3, 0x168(r29) - lwz r12, 0(r3) - lwz r12, 0xe4(r12) - mtctr r12 - bctrl - mr r31, r3 - li r30, 0 - b updateCandidateState_L3 -updateCandidateState_L4: - lwz r3, 0x168(r29) - mr r4, r30 - addi r5, r1, 0x10 - lwz r12, 0(r3) - lwz r12, 0xe8(r12) - mtctr r12 - bctrl - addi r3, r29, 0x118 - addi r4, r1, 0x10 - bl addCandidate__Q39textinput12candidatebox18CandidateBoxCallerFPCw - addi r30, r30, 1 -updateCandidateState_L3: - cmpw r30, r31 - blt updateCandidateState_L4 - addi r3, r29, 0x118 - bl updateCandidate__Q39textinput12candidatebox18CandidateBoxCallerFv - b updateCandidateState_Lend -updateCandidateState_L1: - addi r3, r3, 0x118 - bl resetCandidate__Q39textinput12candidatebox18CandidateBoxCallerFv - lwz r3, 0x16c(r29) - lwz r12, 0(r3) - lwz r12, 0xd8(r12) - mtctr r12 - bctrl - mr r31, r3 - li r30, 0 - b updateCandidateState_L5 -updateCandidateState_L6: - lwz r3, 0x16c(r29) - mr r4, r30 - addi r5, r1, 0x10 - lwz r12, 0(r3) - lwz r12, 0xdc(r12) - mtctr r12 - bctrl - addi r3, r29, 0x118 - addi r4, r1, 0x10 - bl addCandidate__Q39textinput12candidatebox18CandidateBoxCallerFPCw - addi r30, r30, 1 -updateCandidateState_L5: - cmpw r30, r31 - blt updateCandidateState_L6 - addi r3, r29, 0x118 - bl updateCandidate__Q39textinput12candidatebox18CandidateBoxCallerFv -updateCandidateState_Lend: - lwz r0, 0xa4(r1) - lwz r31, 0x9c(r1) - lwz r30, 0x98(r1) - lwz r29, 0x94(r1) - mtlr r0 - addi r1, r1, 0xa0 - blr +void Base::updateCandidateState_() { + if (!mbPredictOn) return; + wchar_t prediction[64]; + if (mePredictMode == PM_Atok) { + if (mpUnfixString->hasConfirmedString()) { + const wchar_t* confirmed = mpUnfixString->getConfirmedWCString(); + mpString->getCursorPos(); + mpString->confirm(confirmed); + mpString->getCursorPos(); + mpUnfixString->enableConfirmedString(false); + onSE(static_cast(9)); + } + bool suppress = false; + CommandReceiver::onCommand(static_cast(35), &suppress); + candidatebox::CandidateBoxCaller::resetCandidate(); + if (!suppress) { + int count = mpUnfixString->getCurrentNumPredicted(); + for (int index = 0; index < count; ++index) { + mpUnfixString->getPredicted(index, prediction); + candidatebox::CandidateBoxCaller::addCandidate(prediction); + } + candidatebox::CandidateBoxCaller::updateCandidate(); + } + } else { + candidatebox::CandidateBoxCaller::resetCandidate(); + int count = mpZiString->getCurrentNumPredicted(); + for (int index = 0; index < count; ++index) { + mpZiString->getPredicted(index, prediction); + candidatebox::CandidateBoxCaller::addCandidate(prediction); + } + candidatebox::CandidateBoxCaller::updateCandidate(); + } } extern "C" asm void moveCursorUp__Q39textinput9inputform4BaseFv() { @@ -3109,108 +2266,20 @@ moveCursorUp_L4: blr } -extern "C" asm void moveCursorDown__Q39textinput9inputform4BaseFv() { - nofralloc - stwu r1, -0x20(r1) - mflr r0 - stw r0, 0x24(r1) - stw r31, 0x1c(r1) - mr r31, r3 - lfs f2, 0x180(r3) - lfs f1, 0x188(r3) - lfs f0, 0xc8(r3) - fsubs f1, f2, f1 - fneg f1, f1 - fcmpo cr0, f1, f0 - bge moveCursorDown_L1 - lwz r3, 0x164(r3) - addi r4, r1, 0xc - addi r5, r1, 8 - lwz r12, 0(r3) - lwz r12, 0x80(r12) - mtctr r12 - bctrl - lwz r3, 0x164(r31) - lwz r12, 0(r3) - lwz r12, 0x1c(r12) - mtctr r12 - bctrl - lwz r0, 0xc(r1) - clrlwi r3, r3, 16 - cmplw r0, r3 - bne moveCursorDown_L2 - lwz r3, 0x164(r31) - lwz r12, 0(r3) - lwz r12, 0x1c(r12) - mtctr r12 - bctrl - lwz r0, 8(r1) - clrlwi r3, r3, 16 - cmplw r0, r3 - bne moveCursorDown_L2 - lwz r12, 0(r31) - mr r3, r31 - li r4, 6 - lwz r12, 0x178(r12) - mtctr r12 - bctrl - b moveCursorDown_L3 -moveCursorDown_L2: - lwz r12, 0(r31) - mr r3, r31 - li r4, 5 - lwz r12, 0x178(r12) - mtctr r12 - bctrl -moveCursorDown_L3: - lwz r3, 0x164(r31) - lwz r12, 0(r3) - lwz r12, 0x1c(r12) - mtctr r12 - bctrl - clrlwi r4, r3, 16 - lwz r3, 0x164(r31) - lwz r12, 0(r3) - lwz r12, 0x6c(r12) - mtctr r12 - bctrl - b moveCursorDown_L4 -moveCursorDown_L1: - lwz r12, 0x5c(r3) - lwz r12, 0x28(r12) - mtctr r12 - addi r3, r3, 0x10 - bctrl - lfs f0, 0x180(r31) - mr r3, r31 - lwz r12, 0(r31) - fadds f2, f0, f1 - lfs f0, lbl_81694D38(r0) - lwz r12, 0x180(r12) - lfs f1, 0x17c(r31) - fadds f2, f0, f2 - mtctr r12 - bctrl - mr r4, r3 - lwz r3, 0x164(r31) - lwz r12, 0(r3) - lwz r12, 0x6c(r12) - mtctr r12 - bctrl - lwz r12, 0(r31) - mr r3, r31 - li r4, 5 - lwz r12, 0x178(r12) - mtctr r12 - bctrl -moveCursorDown_L4: - li r0, 1 - stw r0, 0x1b0(r31) - lwz r31, 0x1c(r1) - lwz r0, 0x24(r1) - mtlr r0 - addi r1, r1, 0x20 - blr +void Base::moveCursorDown() { + if (-(mfCursorY - mfScrollY) < mfMinScrollY) { + u32 start, end; + mpString->getCursorPos(&start, &end); + if (start == mpString->getLength() && end == mpString->getLength()) onSE(static_cast(6)); + else onSE(static_cast(5)); + mpString->setCursorPos(mpString->getLength()); + } else { + f32 lineHeight = getLineHeight(); + f32 y = mfCursorY + lineHeight; + mpString->setCursorPos(calcCursorPos(mfCursorX, 1.0f + y)); + onSE(static_cast(5)); + } + meScrollFlag = SF_ScrollOn; } void Base::confirmInputting_(wchar_t character, bool direct, u16 letterMode, bool confirmOnly, void* holdingKey) { @@ -4199,7 +3268,7 @@ calc_L3: lwz r12, 0xc(r12) mtctr r12 bctrl - lfs f1, lbl_81698D1C(r0) + lfs f1, sfColorPhase(r0) lfs f0, lbl_81694D40(r0) fmuls f1, f0, f1 bl SinFIdx__Q24nw4r4mathFf @@ -4276,7 +3345,7 @@ calc_L4: stb r0, 0x1c1(r30) bl hermiteInterporation__Q29textinput4utilFfffffff fctiwz f1, f1 - lfs f2, lbl_81698D1C(r0) + lfs f2, sfColorPhase(r0) lfs f0, lbl_81694D40(r0) stfd f1, 0x18(r1) fmuls f1, f0, f2 @@ -4301,12 +3370,12 @@ calc_L4: stb r0, 0x1c3(r30) calc_L7: lwz r3, 0x214(r30) - lfs f1, lbl_81698D1C(r0) + lfs f1, sfColorPhase(r0) lfs f0, lbl_81694D58(r0) addi r0, r3, 8 stw r0, 0x214(r30) fadds f0, f1, f0 - stfs f0, lbl_81698D1C(r0) + stfs f0, sfColorPhase(r0) psq_l f31, 0x38(r1), 0, 0 lfd f31, 0x30(r1) lwz r31, 0x2c(r1) @@ -4323,140 +3392,14 @@ Base::RowInfoManager::~RowInfoManager() { Base::~Base() {} -extern "C" asm void __ct__Q39textinput9inputform4BaseFPQ29textinput7Manager() { - nofralloc - stwu r1, -0x20(r1) - mflr r0 - stw r0, 0x24(r1) - addi r11, r1, 0x20 - bl _savegpr_27 - lis r12, __vt__Q29textinput15CommandReceiver@ha - mr r31, r3 - addi r12, r12, __vt__Q29textinput15CommandReceiver@l - mr r27, r4 - stw r12, 0(r3) - lwz r12, 0x14(r12) - mtctr r12 - bctrl - addi r28, r31, 0x10 - mr r3, r28 - bl __ct__Q34nw4r2ut10CharWriterFv - lfs f1, lbl_81694D28(r0) - lis r4, __vt__Q39textinput10textdrawer4Base@ha - li r29, 0 - lfs f0, lbl_81694D2C(r0) - lis r3, 1 - addi r4, r4, __vt__Q39textinput10textdrawer4Base@l - subi r0, r3, 1 - li r30, 1 - stw r4, 0x4c(r28) - addi r3, r28, 0xf8 - li r4, 0 - li r5, 0xc - stw r29, 0x50(r28) - stfs f1, 0x88(r28) - stfs f1, 0x8c(r28) - stfs f1, 0x90(r28) - stfs f1, 0x94(r28) - stfs f0, 0x98(r28) - stb r29, 0x9c(r28) - stb r29, 0x9d(r28) - stw r29, 0xa0(r28) - stfs f1, 0xa4(r28) - stfs f1, 0xa8(r28) - stfs f1, 0xac(r28) - stfs f1, 0xb0(r28) - stfs f1, 0xb4(r28) - stfs f1, 0xb8(r28) - stw r29, 0xbc(r28) - stw r0, 0xc0(r28) - stb r29, 0xc8(r28) - stw r29, 0xcc(r28) - stw r29, 0xd0(r28) - stw r29, 0xd4(r28) - stw r29, 0xd8(r28) - stw r29, 0xdc(r28) - stw r29, 0xe0(r28) - stb r29, 0xe4(r28) - stfs f1, 0xe8(r28) - stfs f1, 0xec(r28) - stfs f1, 0xf0(r28) - stw r29, 0xf4(r28) - stb r29, 0x104(r28) - stb r30, 0x105(r28) - bl memset - lis r10, __vt__Q39textinput9inputform4Base@ha - lfs f0, lbl_81694D28(r0) - addi r10, r10, __vt__Q39textinput9inputform4Base@l - lis r6, __vt__Q39textinput4util9Animation@ha - addi r9, r10, 0x20 - li r7, 2 - addi r8, r10, 0xb8 - addi r6, r6, __vt__Q39textinput4util9Animation@l - li r5, 0x400 - li r4, 0x270f - li r3, 0xff - li r0, -1 - stw r29, 0x11c(r31) - stw r10, 0(r31) - stw r9, 0x5c(r31) - stw r8, 0x118(r31) - stfs f0, 0x120(r31) - stfs f0, 0x124(r31) - stfs f0, 0x128(r31) - stfs f0, 0x12c(r31) - stw r29, 0x164(r31) - stw r29, 0x168(r31) - stw r29, 0x16c(r31) - stw r29, 0x170(r31) - stw r7, 0x174(r31) - stb r29, 0x178(r31) - stb r30, 0x179(r31) - stb r30, 0x17a(r31) - stfs f0, 0x17c(r31) - stfs f0, 0x180(r31) - stfs f0, 0x184(r31) - stfs f0, 0x188(r31) - stw r6, 0x18c(r31) - stfs f0, 0x19c(r31) - stb r29, 0x1a0(r31) - stb r29, 0x1a1(r31) - stw r29, 0x1a4(r31) - stfs f0, 0x1ac(r31) - stw r29, 0x1b0(r31) - stw r29, 0x1b4(r31) - stw r5, 0x1b8(r31) - stw r4, 0x1bc(r31) - stfs f0, 0x1c4(r31) - stb r3, 0x1c8(r31) - stw r0, 0x1cc(r31) - stw r29, 0x1d0(r31) - stw r27, 0x1d4(r31) - bl KPRInitRegionUS - addi r3, r31, 0x1d8 - bl KPRInitQueue - addi r3, r31, 0x1d8 - li r4, 2 - bl KPRSetMode - lwz r0, 0x1b8(r31) - addi r11, r1, 0x20 - stw r30, 0x1f0(r31) - mr r3, r31 - stb r29, 0x1f4(r31) - stb r29, 0x1f5(r31) - stw r29, 0x1f8(r31) - sth r0, 0x1fc(r31) - stw r29, 0x200(r31) - stw r29, 0x204(r31) - sth r29, 0x20c(r31) - stb r30, 0x20e(r31) - stw r29, 0x210(r31) - stw r29, 0x214(r31) - bl _restgpr_27 - lwz r0, 0x24(r1) - mtlr r0 - addi r1, r1, 0x20 - blr +Base::Base(Manager* manager) : CommandReceiver(), textdrawer::Base(), candidatebox::CandidateBoxCaller(), + mpString(NULL), mpUnfixString(NULL), mpZiString(NULL), meInputMode(IM_Direct), mePredictMode(PM_USEn), + mbPredictOn(false), mbDoWordWrap(true), mbRightWithSpace(true), mfCursorX(0.0f), mfCursorY(0.0f), + mfScrollX(0.0f), mfScrollY(0.0f), mScrollAnm(), mfSustainTimer(0.0f), meScrollFlag(SF_NoScroll), + muWordWrapCounter(0), muLimitStringLength(1024), muLimitRowNum(9999), mfCursorTimer(0.0f), muGlobalAlpha(255), + mCharColor(0xffffffff), mpAllocator(NULL), mpManager(manager), mDKStream(), meLanguage(USA), + mbZuSelected(false), mbCursorSelected(false), mriManager(muLimitStringLength), mpCursorLine(NULL), + mCursorLinePos(0), mbLineDraw(true), muSpecifyLineDrawCount(0), muCursorTimer(0) { } @@ -4521,12 +3464,14 @@ bool textinput::util::Animation::isActive() { } namespace inputform { -extern "C" asm void getKanaBuffer__Q39textinput8tistring9DecolatedFv() { - nofralloc - addi r3, r3, 0x42 - blr } +wchar_t* tistring::Decolated::getKanaBuffer() { + return mKanaStream.mOutput; +} + +namespace inputform { + @@ -4548,12 +3493,14 @@ namespace inputform { void Base::create(MEMAllocator*) {} -extern "C" asm void setVIWidth__Q39textinput10textdrawer4BaseFf() { - nofralloc - stfs f1, 0x98(r3) - blr } +void textdrawer::Base::setVIWidth(f32 width) { + mfVIWidth = width; +} + +namespace inputform { + } @@ -4588,114 +3535,43 @@ namespace inputform { void LayoutByNW4R::onSE(sound::SE seId) { mpEventObserver->onSE(seId); } -extern "C" asm void addSender__Q29textinput15CommandReceiverFPQ29textinput13CommandSender() { - nofralloc - addi r3, r3, 4 - b List_Append__Q24nw4r2utFPQ34nw4r2ut4ListPv } -extern "C" asm void isInScroll__Q39textinput12candidatebox12LayoutByNW4RFv() { - nofralloc - addi r3, r3, 0xe4 - b IsScrolling__Q39textinput12candidatebox10UITextAreaFv + +void CommandReceiver::addSender(CommandSender* sender) { + nw4r::ut::List_Append(&mSenderList, sender); } -extern "C" asm void __dt__Q39textinput8tistring9DecolatedFv() { - nofralloc - stwu r1, -0x10(r1) - mflr r0 - cmpwi r3, 0 - stw r0, 0x14(r1) - stw r31, 0xc(r1) - mr r31, r4 - stw r30, 8(r1) - mr r30, r3 - beq __dt_Decolated_L1 - li r4, 0 - bl __dt__Q39textinput8tistring10StringBaseFv - cmpwi r31, 0 - ble __dt_Decolated_L1 - mr r3, r30 - bl __dl__FPv -__dt_Decolated_L1: - mr r3, r30 - lwz r31, 0xc(r1) - lwz r30, 8(r1) - lwz r0, 0x14(r1) - mtlr r0 - addi r1, r1, 0x10 - blr + +namespace inputform { } -extern "C" asm void __dt__Q39textinput8tistring8WithAtokFv() { - nofralloc - stwu r1, -0x10(r1) - mflr r0 - cmpwi r3, 0 - stw r0, 0x14(r1) - stw r31, 0xc(r1) - mr r31, r4 - stw r30, 8(r1) - mr r30, r3 - beq __dt_WithAtok_L1 - beq __dt_WithAtok_L2 - li r4, 0 - bl __dt__Q39textinput8tistring10StringBaseFv -__dt_WithAtok_L2: - cmpwi r31, 0 - ble __dt_WithAtok_L1 - mr r3, r30 - bl __dl__FPv -__dt_WithAtok_L1: - mr r3, r30 - lwz r31, 0xc(r1) - lwz r30, 8(r1) - lwz r0, 0x14(r1) - mtlr r0 - addi r1, r1, 0x10 - blr + +bool candidatebox::LayoutByNW4R::isInScroll() { + return mTextArea.IsScrolling(); } -extern "C" asm void __dt__Q29textinput15CommandReceiverFv() { - nofralloc - stwu r1, -0x10(r1) - mflr r0 - cmpwi r3, 0 - stw r0, 0x14(r1) - stw r31, 0xc(r1) - mr r31, r3 - beq __dt_CommandReceiver_L1 - cmpwi r4, 0 - ble __dt_CommandReceiver_L1 - bl __dl__FPv -__dt_CommandReceiver_L1: - mr r3, r31 - lwz r31, 0xc(r1) - lwz r0, 0x14(r1) - mtlr r0 - addi r1, r1, 0x10 - blr + +namespace inputform { } -extern "C" asm bool isKanaFix__Q39textinput8tistring9DecolatedCFv() { - nofralloc - stwu r1, -0x10(r1) - mflr r0 - stw r0, 0x14(r1) - lwz r0, 0x24(r3) - cmpwi r0, 3 - bne isKanaFix_L1 - li r3, 1 - b isKanaFix_L2 -isKanaFix_L1: - li r4, 0 - li r5, 0 - addi r3, r3, 0x28 - bl KPRLookAhead - clrlwi r0, r3, 24 - cntlzw r0, r0 - srwi r3, r0, 5 -isKanaFix_L2: - lwz r0, 0x14(r1) - mtlr r0 - addi r1, r1, 0x10 - blr + +tistring::Decolated::~Decolated() {} + +namespace inputform { } + +tistring::WithAtok::~WithAtok() {} + +namespace inputform { +} + +CommandReceiver::~CommandReceiver() {} + +namespace inputform { +} + +bool tistring::Decolated::isKanaFix() const { + if (static_cast(mTranslateMode) == TM_Hangul) return true; + return KPRLookAhead(const_cast(&mKanaStream.mQueue), NULL, NULL) == 0; +} + +namespace inputform { } void textinput::util::Animation::calc() { @@ -4801,144 +3677,23 @@ LayoutByNW4R::~LayoutByNW4R() { } } -extern "C" asm void create__Q39textinput9inputform10EditBufferFP12MEMAllocator() { - nofralloc - stwu r1, -0x20(r1) - mflr r0 - stw r0, 0x24(r1) - stw r31, 0x1c(r1) - stw r30, 0x18(r1) - stw r29, 0x14(r1) - mr r29, r4 - stw r28, 0x10(r1) - mr r28, r3 - stw r4, 0x10(r3) - li r4, 0x4c - mr r3, r29 - bl MEMAllocFromAllocator - cmpwi r3, 0 - mr r30, r3 - beq create_EditBuffer_L1 - li r0, 0x400 - lis r12, __vt__Q39textinput8tistring9Decolated@ha - sth r0, 4(r3) - li r0, 0 - addi r12, r12, __vt__Q39textinput8tistring9Decolated@l - sth r0, 6(r3) - stw r0, 8(r3) - stw r0, 0xc(r3) - sth r0, 0x10(r3) - stw r0, 0x14(r3) - stw r12, 0(r3) - stw r0, 0x18(r3) - stw r0, 0x1c(r3) - stb r0, 0x20(r3) - stw r0, 0x24(r3) - lwz r12, 0xb8(r12) - mtctr r12 - bctrl -create_EditBuffer_L1: - stw r30, 4(r28) - mr r3, r30 - mr r4, r29 - lwz r12, 0(r30) - lwz r12, 0xc(r12) - mtctr r12 - bctrl - mr r3, r29 - li r4, 0x4c - bl MEMAllocFromAllocator - cmpwi r3, 0 - mr r30, r3 - beq create_EditBuffer_L2 - li r0, 0x400 - lis r12, __vt__Q39textinput8tistring9Decolated@ha - sth r0, 4(r3) - li r0, 0 - addi r12, r12, __vt__Q39textinput8tistring9Decolated@l - sth r0, 6(r3) - stw r0, 8(r3) - stw r0, 0xc(r3) - sth r0, 0x10(r3) - stw r0, 0x14(r3) - stw r12, 0(r3) - stw r0, 0x18(r3) - stw r0, 0x1c(r3) - stb r0, 0x20(r3) - stw r0, 0x24(r3) - lwz r12, 0xb8(r12) - mtctr r12 - bctrl - lis r3, __vt__Q39textinput8tistring8WithAtok@ha - addi r3, r3, __vt__Q39textinput8tistring8WithAtok@l - stw r3, 0(r30) -create_EditBuffer_L2: - stw r30, 8(r28) - mr r3, r30 - mr r4, r29 - lwz r12, 0(r30) - lwz r12, 0xc(r12) - mtctr r12 - bctrl - mr r3, r29 - li r4, 0xac - bl MEMAllocFromAllocator - cmpwi r3, 0 - mr r30, r3 - beq create_EditBuffer_L3 - li r0, 0x400 - lis r12, __vt__Q39textinput8tistring9Decolated@ha - sth r0, 4(r3) - li r31, 0 - addi r12, r12, __vt__Q39textinput8tistring9Decolated@l - sth r31, 6(r3) - stw r31, 8(r3) - stw r31, 0xc(r3) - sth r31, 0x10(r3) - stw r31, 0x14(r3) - stw r12, 0(r3) - stw r31, 0x18(r3) - stw r31, 0x1c(r3) - stb r31, 0x20(r3) - stw r31, 0x24(r3) - lwz r12, 0xb8(r12) - mtctr r12 - bctrl - lis r4, __vt__Q39textinput8tistring6WithZi@ha - li r3, 0xff - addi r4, r4, __vt__Q39textinput8tistring6WithZi@l - li r0, 2 - stw r4, 0(r30) - stb r31, 0x78(r30) - stb r31, 0x79(r30) - stw r31, 0x7c(r30) - stw r31, 0x80(r30) - stw r31, 0x84(r30) - sth r31, 0x88(r30) - stw r31, 0x8c(r30) - stw r31, 0x90(r30) - stb r3, 0x94(r30) - stw r31, 0x98(r30) - stw r31, 0x9c(r30) - stw r0, 0xa0(r30) - stw r31, 0xa4(r30) - stb r31, 0xa8(r30) -create_EditBuffer_L3: - stw r30, 0xc(r28) - mr r3, r30 - mr r4, r29 - lwz r12, 0(r30) - lwz r12, 0xc(r12) - mtctr r12 - bctrl - lwz r0, 0x24(r1) - lwz r31, 0x1c(r1) - lwz r30, 0x18(r1) - lwz r29, 0x14(r1) - lwz r28, 0x10(r1) - mtlr r0 - addi r1, r1, 0x20 - blr +void EditBuffer::create(MEMAllocator* allocator) { + mpAllocator = allocator; + void* memory = MEMAllocFromAllocator(allocator, sizeof(tistring::Decolated)); + tistring::Decolated* fixed = static_cast(memory); + fixed = new (memory) tistring::Decolated(1024); + mpString = fixed; + fixed->create(allocator); + memory = MEMAllocFromAllocator(allocator, sizeof(tistring::WithAtok)); + tistring::WithAtok* atok = static_cast(memory); + atok = new (memory) tistring::WithAtok(1024); + mpUnfixString = atok; + atok->create(allocator); + memory = MEMAllocFromAllocator(allocator, sizeof(tistring::WithZi)); + tistring::WithZi* zi = static_cast(memory); + zi = new (memory) tistring::WithZi(1024); + mpZiString = zi; + zi->create(allocator); } EditBuffer::~EditBuffer() { if (mpString) { @@ -4957,115 +3712,46 @@ EditBuffer::~EditBuffer() { mpUnfixString = NULL; mpZiString = NULL; } -extern "C" asm void updateInputCommon__Q39textinput9inputform12LayoutByNW4RFiUlUlUlPv() { - nofralloc - stwu r1, -0x10(r1) - mflr r0 - mr r4, r5 - mr r5, r6 - stw r0, 0x14(r1) - stw r31, 0xc(r1) - mr r31, r3 - bl updateRepeatInput__Q39textinput9inputform12LayoutByNW4RFUlUl - lwz r0, 0x304(r31) - rlwinm. r0, r0, 0, 19, 19 - beq updateInputCommon_L1 - lwz r12, 0(r31) - mr r3, r31 - li r4, 1 - li r5, 0 - lwz r12, 0x18(r12) - mtctr r12 - bctrl -updateInputCommon_L1: - lwz r0, 0x14(r1) - lwz r31, 0xc(r1) - mtlr r0 - addi r1, r1, 0x10 - blr +void LayoutByNW4R::updateInputCommon(int chan, u32 trig, u32 hold, u32 release, void* data) { + updateRepeatInput(trig, hold); + if (mRepeatButtons & 0x1000) onCommand(static_cast(1), NULL); } -extern "C" asm void updateRepeatInput__Q39textinput9inputform12LayoutByNW4RFUlUl() { - nofralloc - clrlwi. r0, r5, 31 - stw r4, 0x304(r3) - beq updateRepeatInput_L1 - lwz r0, 0x2f4(r3) - subic. r0, r0, 1 - stw r0, 0x2f4(r3) - bne updateRepeatInput_L2 - ori r4, r4, 1 - li r0, 9 - stw r4, 0x304(r3) - stw r0, 0x2f4(r3) - b updateRepeatInput_L2 -updateRepeatInput_L1: - li r0, 0x1e - stw r0, 0x2f4(r3) -updateRepeatInput_L2: - rlwinm. r0, r5, 0, 30, 30 - beq updateRepeatInput_L3 - lwz r0, 0x2f8(r3) - subic. r0, r0, 1 - stw r0, 0x2f8(r3) - bne updateRepeatInput_L4 - lwz r4, 0x304(r3) - li r0, 9 - stw r0, 0x2f8(r3) - ori r0, r4, 2 - stw r0, 0x304(r3) - b updateRepeatInput_L4 -updateRepeatInput_L3: - li r0, 0x1e - stw r0, 0x2f8(r3) -updateRepeatInput_L4: - rlwinm. r0, r5, 0, 28, 28 - beq updateRepeatInput_L5 - lwz r0, 0x2ec(r3) - subic. r0, r0, 1 - stw r0, 0x2ec(r3) - bne updateRepeatInput_L6 - lwz r4, 0x304(r3) - li r0, 9 - stw r0, 0x2ec(r3) - ori r0, r4, 8 - stw r0, 0x304(r3) - b updateRepeatInput_L6 -updateRepeatInput_L5: - li r0, 0x1e - stw r0, 0x2ec(r3) -updateRepeatInput_L6: - rlwinm. r0, r5, 0, 29, 29 - beq updateRepeatInput_L7 - lwz r0, 0x2f0(r3) - subic. r0, r0, 1 - stw r0, 0x2f0(r3) - bne updateRepeatInput_L8 - lwz r4, 0x304(r3) - li r0, 9 - stw r0, 0x2f0(r3) - ori r0, r4, 4 - stw r0, 0x304(r3) - b updateRepeatInput_L8 -updateRepeatInput_L7: - li r0, 0x1e - stw r0, 0x2f0(r3) -updateRepeatInput_L8: - rlwinm. r0, r5, 0, 19, 19 - beq updateRepeatInput_L9 - lwz r0, 0x2fc(r3) - subic. r0, r0, 1 - stw r0, 0x2fc(r3) - bnelr - lwz r4, 0x304(r3) - li r0, 9 - stw r0, 0x2fc(r3) - ori r0, r4, 0x1000 - stw r0, 0x304(r3) - blr -updateRepeatInput_L9: - li r0, 0x1e - stw r0, 0x2fc(r3) - blr +void LayoutByNW4R::updateRepeatInput(u32 trig, u32 hold) { + mRepeatButtons = trig; + if (hold & 1) { + if (--mLeftRepeat == 0) { + mRepeatButtons |= 1; + mLeftRepeat = 9; + } + } else mLeftRepeat = 30; + if (hold & 2) { + if (--mRightRepeat == 0) { + trig = mRepeatButtons; + mRightRepeat = 9; + mRepeatButtons = trig | 2; + } + } else mRightRepeat = 30; + if (hold & 8) { + if (--mUpRepeat == 0) { + trig = mRepeatButtons; + mUpRepeat = 9; + mRepeatButtons = trig | 8; + } + } else mUpRepeat = 30; + if (hold & 4) { + if (--mDownRepeat == 0) { + trig = mRepeatButtons; + mDownRepeat = 9; + mRepeatButtons = trig | 4; + } + } else mDownRepeat = 30; + if (hold & 0x1000) { + if (--mDeleteRepeat == 0) { + trig = mRepeatButtons; + mDeleteRepeat = 9; + mRepeatButtons = trig | 0x1000; + } + } else mDeleteRepeat = 30; } wchar_t DeadKeyStream::ToCombineClass(Language language, wchar_t code) { switch (language) { @@ -5094,63 +3780,19 @@ wchar_t DeadKeyStream::ToCombineClass(Language language, wchar_t code) { } return code; } -extern "C" asm void init__Q39textinput3gui12GUIComponentFv() { - nofralloc - lbz r0, 4(r3) - cmpwi r0, 0 - bnelr - lfs f0, lbl_81694D28(r0) - li r0, 0 - stb r0, 5(r3) - stfs f0, 0x18(r3) - stfs f0, 0x1c(r3) - stfs f0, 0x20(r3) - stb r0, 0xd(r3) - sth r0, 0x80(r3) - stb r0, 6(r3) - stfs f0, 0x24(r3) - stfs f0, 0x28(r3) - stfs f0, 0x2c(r3) - stb r0, 0xe(r3) - sth r0, 0x82(r3) - stb r0, 7(r3) - stfs f0, 0x30(r3) - stfs f0, 0x34(r3) - stfs f0, 0x38(r3) - stb r0, 0xf(r3) - sth r0, 0x84(r3) - stb r0, 8(r3) - stfs f0, 0x3c(r3) - stfs f0, 0x40(r3) - stfs f0, 0x44(r3) - stb r0, 0x10(r3) - sth r0, 0x86(r3) - stb r0, 9(r3) - stfs f0, 0x48(r3) - stfs f0, 0x4c(r3) - stfs f0, 0x50(r3) - stb r0, 0x11(r3) - sth r0, 0x88(r3) - stb r0, 0xa(r3) - stfs f0, 0x54(r3) - stfs f0, 0x58(r3) - stfs f0, 0x5c(r3) - stb r0, 0x12(r3) - sth r0, 0x8a(r3) - stb r0, 0xb(r3) - stfs f0, 0x60(r3) - stfs f0, 0x64(r3) - stfs f0, 0x68(r3) - stb r0, 0x13(r3) - sth r0, 0x8c(r3) - stb r0, 0xc(r3) - stfs f0, 0x6c(r3) - stfs f0, 0x70(r3) - stfs f0, 0x74(r3) - stb r0, 0x14(r3) - sth r0, 0x8e(r3) - blr } +void gui::GUIComponent::init() { + if (mbInitialize) return; + for (int point = 0; point < GUI_POINTS_MAX; ++point) { + mbPointed[point] = false; + mDraggingPos[point].x = 0.0f; + mDraggingPos[point].y = 0.0f; + mDraggingPos[point].z = 0.0f; + mbDragging[point] = false; + mFlightDuration[point] = 0; + } +} +namespace inputform { bool Base::isEditMode() { switch (mePredictMode) { @@ -5638,46 +4280,12 @@ bool Base::doWordWrap(const wchar_t* string, u32 pos, f32 width) { return false; } -asm void Base::doLineFeed() { - nofralloc - stwu r1, -0x30(r1) - mflr r0 - stw r0, 0x34(r1) - stfd f31, 0x20(r1) - psq_st f31, 0x28(r1), 0, 0 - stw r31, 0x1c(r1) - mr r31, r3 - lwz r4, 0xb0(r3) - addi r0, r4, 1 - stw r0, 0xb0(r3) - lwz r12, 0x5c(r3) - lwz r12, 0x28(r12) - mtctr r12 - addi r3, r3, 0x10 - bctrl - fmr f31, f1 - addi r3, r31, 0x10 - bl GetCursorY__Q34nw4r2ut10CharWriterCFv - fadds f1, f1, f31 - addi r3, r31, 0x10 - bl SetCursorY__Q34nw4r2ut10CharWriterFf - lwz r12, 0(r31) - mr r3, r31 - lwz r12, 0x188(r12) - mtctr r12 - bctrl - stw r3, 8(r1) - addi r3, r31, 0x10 - stw r4, 0xc(r1) - lfs f1, 8(r1) - bl SetCursorX__Q34nw4r2ut10CharWriterFf - psq_l f31, 0x28(r1), 0, 0 - lwz r0, 0x34(r1) - lfd f31, 0x20(r1) - lwz r31, 0x1c(r1) - mtlr r0 - addi r1, r1, 0x30 - blr +void Base::doLineFeed() { + ++muLine; + f32 height = getLineHeight(); + f32 cursorY = GetCursorY(); + SetCursorY(cursorY + height); + SetCursorX(getScale().x); } asm bool Base::isOverLine(const DrawInfo& drawInfo) { @@ -5735,153 +4343,32 @@ asm bool Base::isOverLine(const DrawInfo& drawInfo) { blr } -asm void Base::drawFixString(u32) { - nofralloc - stwu r1, -0x20(r1) - mflr r0 - lfs f0, lbl_81694D28(r0) - stw r0, 0x24(r1) - stw r31, 0x1c(r1) - stw r30, 0x18(r1) - mr r30, r3 - stw r4, 0xc(r1) - addi r4, r1, 8 - stfs f0, 0x10(r1) - stfs f0, 0x14(r1) - lbz r5, 0x1c8(r3) - lbz r0, 0x1cc(r3) - stb r5, 0x1cf(r3) - stb r0, 8(r1) - lbz r0, 0x1cd(r3) - stb r0, 9(r1) - lbz r0, 0x1ce(r3) - stb r0, 0xa(r1) - lbz r0, 0x1cf(r3) - addi r3, r3, 0x10 - stb r0, 0xb(r1) - bl SetTextColor__Q34nw4r2ut10CharWriterFQ34nw4r2ut5Color - lwz r3, 0x164(r30) - lwz r12, 0(r3) - lwz r12, 0x1c(r12) - mtctr r12 - bctrl - clrlwi r31, r3, 16 - lwz r3, 0x164(r30) - lwz r12, 0(r3) - lwz r12, 0x3c(r12) - mtctr r12 - bctrl - mr r4, r3 - mr r6, r31 - addi r3, r30, 0x10 - li r5, 0 - bl setDrawString__Q39textinput10textdrawer4BaseFPCwUlUl - addi r3, r30, 0x10 - addi r4, r1, 0xc - bl draw__Q39textinput10textdrawer4BaseFPQ49textinput10textdrawer4Base9CursorPos - lwz r12, 0(r30) - mr r3, r30 - lfs f1, 0x10(r1) - lwz r12, 0x164(r12) - lfs f2, 0x14(r1) - mtctr r12 - bctrl - lwz r0, 0x24(r1) - lwz r31, 0x1c(r1) - lwz r30, 0x18(r1) - mtlr r0 - addi r1, r1, 0x20 - blr +void Base::drawFixString(u32 position) { + CursorPos cursor; + cursor.fCursorX = 0.0f; + cursor.fCursorY = 0.0f; + cursor.uCursorPos = position; + mCharColor.a = muGlobalAlpha; + SetTextColor(mCharColor); + u32 length = mpString->getLength(); + textdrawer::Base::setDrawString(mpString->getWCString(), 0, length); + textdrawer::Base::draw(&cursor); + drawCursor(cursor.fCursorX, cursor.fCursorY); } -asm void Base::draw() { - nofralloc - stwu r1, -0x50(r1) - mflr r0 - stw r0, 0x54(r1) - stw r31, 0x4c(r1) - stw r30, 0x48(r1) - mr r30, r3 - lwz r12, 0(r3) - lwz r12, 0x188(r12) - mtctr r12 - bctrl - stw r3, 0x18(r1) - addi r3, r30, 0x10 - lfs f2, 0x188(r30) - stw r4, 0x1c(r1) - lfs f1, 0x18(r1) - bl SetCursor__Q34nw4r2ut10CharWriterFff - lwz r12, 0(r30) - mr r3, r30 - lwz r12, 0x188(r12) - mtctr r12 - bctrl - lfs f0, lbl_81694D28(r0) - stw r3, 0x10(r1) - stfs f0, 0x30(r1) - stfs f0, 0x34(r1) - stfs f0, 0x38(r1) - stfs f0, 0x3c(r1) - lwz r12, 0(r30) - stw r3, 0x28(r1) - mr r3, r30 - lwz r12, 0x184(r12) - stw r4, 0x14(r1) - stw r4, 0x2c(r1) - mtctr r12 - bctrl - stw r3, 0x20(r1) - lfs f1, 0x28(r1) - stw r4, 0x24(r1) - lfs f5, 0x20(r1) - lfs f4, 0x24(r1) - stfs f5, 0x30(r1) - lfs f0, 0x2c(r1) - stfs f4, 0x3c(r1) - lfs f3, 0x128(r30) - lfs f2, 0x120(r30) - stw r3, 8(r1) - fsubs f2, f3, f2 - stw r4, 0xc(r1) - fmuls f1, f1, f2 - fadds f1, f5, f1 - stfs f1, 0x38(r1) - lfs f2, 0x124(r30) - lfs f1, 0x12c(r30) - fsubs f1, f2, f1 - fmuls f0, f0, f1 - fadds f0, f4, f0 - stfs f0, 0x34(r1) - lwz r3, 0x164(r30) - lwz r12, 0(r3) - lwz r12, 0x7c(r12) - mtctr r12 - bctrl - lwz r12, 0x5c(r30) - mr r31, r3 - addi r3, r30, 0x10 - addi r4, r1, 0x30 - lwz r12, 0x20(r12) - mtctr r12 - bctrl - lwz r12, 0(r30) - mr r3, r30 - mr r4, r31 - lwz r12, 0x174(r12) - mtctr r12 - bctrl - lwz r12, 0x5c(r30) - addi r3, r30, 0x10 - lwz r12, 0x24(r12) - mtctr r12 - bctrl - lwz r0, 0x54(r1) - lwz r31, 0x4c(r1) - lwz r30, 0x48(r1) - mtlr r0 - addi r1, r1, 0x50 - blr +void Base::draw() { + SetCursor(getScale().x, mfScrollY); + nw4r::math::VEC2 scale = getScale(); + nw4r::ut::Rect clip(0.0f, 0.0f, 0.0f, 0.0f); + nw4r::math::VEC2 origin = getGlobalLeftTopPos(); + clip.left = origin.x; + clip.bottom = origin.y; + clip.right = origin.x + scale.x * (mRect.right - mRect.left); + clip.top = origin.y + scale.y * (mRect.top - mRect.bottom); + u32 position = mpString->getCursorPos(); + beginDraw(clip); + drawFixString(position); + endDraw(); } asm void Base::drawCursor(f32, f32) { @@ -5958,183 +4445,38 @@ asm void Base::drawCursor(f32, f32) { blr } -extern "C" asm void doScroll__Q39textinput9inputform4BaseFPQ39textinput15CommandReceiver6Scroll() { - nofralloc - stwu r1, -0x10(r1) - mflr r0 - stw r0, 0x14(r1) - stw r31, 0xc(r1) - mr r31, r4 - stw r30, 8(r1) - mr r30, r3 - lwz r12, 0x18c(r3) - lwz r12, 0x14(r12) - mtctr r12 - addi r3, r3, 0x18c - bctrl - cmpwi r3, 0 - bne doScroll_L1 - lbz r0, 0(r31) - cmpwi r0, 0 - beq doScroll_L2 - lfs f0, 4(r31) - stfs f0, 0x184(r30) - lfs f0, 8(r31) - stfs f0, 0x188(r30) - stfs f0, 0x100(r30) - b doScroll_L3 -doScroll_L2: - lfs f2, 0x184(r30) - addi r3, r30, 0x18c - lfs f0, 4(r31) - li r4, 0 - lfs f1, 0x188(r30) - li r5, 0 - fadds f0, f2, f0 - lfs f3, lbl_81694D88(r0) - stfs f0, 0x184(r30) - lwz r12, 0x18c(r30) - lfs f0, 8(r31) - lwz r12, 8(r12) - fadds f2, f1, f0 - mtctr r12 - bctrl -doScroll_L3: - lwz r12, 0(r30) - mr r3, r30 - li r4, 0xb - lwz r12, 0x178(r12) - mtctr r12 - bctrl -doScroll_L1: - lwz r0, 0x14(r1) - lwz r31, 0xc(r1) - lwz r30, 8(r1) - mtlr r0 - addi r1, r1, 0x10 - blr +void Base::doScroll(Scroll* scroll) { + if (mScrollAnm.isActive()) return; + if (scroll->absY) { + mfScrollX = scroll->x; + mfScrollY = scroll->y; + mfDrawScrollY = mfScrollY; + } else { + mfScrollX += scroll->x; + mScrollAnm.startAnm(mfScrollY, mfScrollY + scroll->y, 15.0f, NULL, NULL); + } + onSE(static_cast(11)); } -asm void Base::doBeforeDrawProcess(const wchar_t*, u32, const DrawInfo&) { - nofralloc - stwu r1, -0x60(r1) - mflr r0 - stw r0, 0x64(r1) - stfd f31, 0x50(r1) - psq_st f31, 0x58(r1), 0, 0 - stfd f30, 0x40(r1) - psq_st f30, 0x48(r1), 0, 0 - stfd f29, 0x30(r1) - psq_st f29, 0x38(r1), 0, 0 - stw r31, 0x2c(r1) - mr r31, r6 - stw r30, 0x28(r1) - mr r30, r5 - stw r29, 0x24(r1) - mr r29, r4 - stw r28, 0x20(r1) - mr r28, r3 - addi r3, r3, 0x10 - bl GetCursorX__Q34nw4r2ut10CharWriterCFv - lwz r12, 0(r28) - mr r3, r28 - mr r4, r29 - mr r5, r30 - lwz r12, 0x170(r12) - mtctr r12 - bctrl - cmpwi r3, 0 - beq doBeforeDrawProcess_L1 - lwz r12, 0(r28) - mr r3, r28 - lwz r12, 0x158(r12) - mtctr r12 - bctrl -doBeforeDrawProcess_L1: - lwz r12, 0(r28) - mr r3, r28 - mr r4, r31 - lwz r12, 0x160(r12) - mtctr r12 - bctrl - cmpwi r3, 0 - beq doBeforeDrawProcess_L2 - lwz r4, 0xb0(r28) - addi r3, r28, 0x10 - addi r0, r4, 1 - stw r0, 0xb0(r28) - lwz r12, 0x5c(r28) - lwz r12, 0x28(r12) - mtctr r12 - bctrl - fmr f31, f1 - addi r3, r28, 0x10 - bl GetCursorY__Q34nw4r2ut10CharWriterCFv - fadds f1, f1, f31 - addi r3, r28, 0x10 - bl SetCursorY__Q34nw4r2ut10CharWriterFf - lwz r12, 0(r28) - mr r3, r28 - lwz r12, 0x188(r12) - mtctr r12 - bctrl - stw r3, 0x10(r1) - addi r3, r28, 0x10 - stw r4, 0x14(r1) - lfs f1, 0x10(r1) - bl SetCursorX__Q34nw4r2ut10CharWriterFf -doBeforeDrawProcess_L2: - lwz r3, 0x164(r28) - addi r4, r1, 0xc - addi r5, r1, 8 - lwz r12, 0(r3) - lwz r12, 0x8c(r12) - mtctr r12 - bctrl - lwz r0, 0xc(r1) - cmplw r30, r0 - blt doBeforeDrawProcess_L3 - lwz r0, 8(r1) - cmplw r30, r0 - bge doBeforeDrawProcess_L3 - addi r3, r28, 0x10 - bl GetCursorX__Q34nw4r2ut10CharWriterCFv - lfs f0, 0(r31) - addi r3, r28, 0x10 - fadds f31, f0, f1 - bl GetCursorY__Q34nw4r2ut10CharWriterCFv - lfs f0, 4(r31) - addi r3, r28, 0x10 - fadds f30, f0, f1 - bl GetCursorX__Q34nw4r2ut10CharWriterCFv - lfs f0, 8(r31) - addi r3, r28, 0x10 - fadds f29, f0, f1 - bl GetCursorY__Q34nw4r2ut10CharWriterCFv - lfs f0, 0xc(r31) - fmr f2, f30 - fmr f3, f29 - lfs f5, lbl_81694D28(r0) - fadds f4, f0, f1 - lfs f6, lbl_81694D38(r0) - fmr f1, f31 - addi r3, r28, 0x1c0 - bl drawBox___Q29textinput5debugFffffffR8_GXColor -doBeforeDrawProcess_L3: - psq_l f31, 0x58(r1), 0, 0 - lfd f31, 0x50(r1) - psq_l f30, 0x48(r1), 0, 0 - lfd f30, 0x40(r1) - psq_l f29, 0x38(r1), 0, 0 - lfd f29, 0x30(r1) - lwz r31, 0x2c(r1) - lwz r30, 0x28(r1) - lwz r29, 0x24(r1) - lwz r0, 0x64(r1) - lwz r28, 0x20(r1) - mtlr r0 - addi r1, r1, 0x60 - blr +void Base::doBeforeDrawProcess(const wchar_t* string, u32 position, const DrawInfo& info) { + f32 cursorX = GetCursorX(); + if (doWordWrap(string, position, cursorX)) doLineFeed(); + if (isOverLine(info)) { + ++muLine; + f32 height = getLineHeight(); + f32 cursorY = GetCursorY(); + SetCursorY(cursorY + height); + SetCursorX(getScale().x); + } + u32 start, end; + mpString->getSelected(start, end); + if (position >= start && position < end) { + f32 left = info.rect.left + GetCursorX(); + f32 top = info.rect.top + GetCursorY(); + f32 right = info.rect.right + GetCursorX(); + f32 bottom = info.rect.bottom + GetCursorY(); + debug::drawBox_(left, top, right, bottom, 0.0f, 1.0f, mSelectedColor); + } } void Base::finishDraw(u32) {} @@ -6367,7 +4709,7 @@ bool WithAtok::hasConfirmedString() { return false; } int WithAtok::getCurrentNumPredicted() { return 0; } bool WithAtok::isCandidateSelected() { return false; } s32 WithAtok::getSelectedCandidate() { return 0; } -s16 WithAtok::getFixedPredictionNum() { return 0; } +s32 WithAtok::getFixedPredictionNum() { return 0; } wchar_t WithAtok::getInputStringLength() { return 0; } bool WithAtok::moveCursorLeft() { return false; } bool WithAtok::moveCursorRight() { return false; } diff --git a/tools/decomp-assist/tiInputForm.attempts.md b/tools/decomp-assist/tiInputForm.attempts.md index 630826aa..50ae41c1 100644 --- a/tools/decomp-assist/tiInputForm.attempts.md +++ b/tools/decomp-assist/tiInputForm.attempts.md @@ -92,3 +92,237 @@ Every measured state retained the original 20-string pool. The first gate lacked - Nine additional asm conversions are instruction-exact: initZiString 14/14, resetContextPredict_ 27/27, resetRelation 23/23, textinput Base init 1/1, drawer getLine 3/3, StringBase hasCandidate 5/5, inputform Base create allocator overload 1/1, Decolated set 19/19, Decolated clear 20/20. Layout onSE 5/5 and EditBuffer destructor 61/61 are also exact C++. The allocator overload and base initializer faithfully retain their original empty bodies. - Data limits: ordinary literal pool and .rodata/.sdata/.sdata2 are identical. Vtable relocation comparison now agrees except the reference cursor-cache concatenated symbol. EditBuffer vtable target size includes four trailing bytes and textinput Base vtable includes 28 trailing bytes without relocations; no padding was added. Other zero-filled weak data and anonymous jump-table differences remain. - Final clean full gate: GATE PASS, pool IDENTICAL, zero regressions/forbidden additions/readability warnings; instruction-exact 206/221 unchanged, objdiff exact 208/221 unchanged, code 28300/50656 unchanged, data 868 -> 908/3772, fuzzy 97.1980 -> 97.2205. Eleven existing asm bodies converted instruction-exact to C++; 41 asm bodies remain. Linking was not changed. The literal pane tables have 100% .rodata and .sdata. + +## Third continuation: remaining asm +- Kana buffer getter 2/2, VI width setter 2/2, command sender append 2/2, candidate scroll query 2/2, Decolated destructor 22/22, WithAtok destructor 23/23, CommandReceiver destructor 16/16: real C++ first builds, diffs 0. Original KanaStream layout is a KPRQueue, pending character and five-character output. +- Decolated::isKanaFix: literal 19/19, one unsigned comparison difference; explicit signed translation-mode comparison gives diffs 0. +- Base::moveCandidateToIdx: typed translation 104/104, one return-width difference; correcting the fixed prediction count to s32 gives diffs 0. Base::confirmInput_ 141/141, diffs 0 on first translation. +- Base::init: literal 81/81, two wrong reconstructed members; original slot is enableSpaceByRight and the cursor-cache scroll offset is textdrawer 0xf0. Corrected guarded declarations give diffs 0. Base::deselectCandidate 13/13, diffs 0. +- Layout calc: direct bool comparisons 132/137; initializing real up/down state before the pane query, positive separator branch and explicit comparisons give 137/137, diffs 0. Existing bar literal object replaced by the ordinary literal at its real source position; pool stays identical. +- Layout draw: natural VEC2 initialization 114/114, 12 stack temporary differences; separate vector assignments 116/114; const references 114/114 with the same 12 offsets. Restored existing exact asm. +- updateInputCommon__Q39textinput9inputform12LayoutByNW4RFiUlUlUlPv: typed repeat dispatch: src 0x5c base 0x5c insns 23/23; diffs 0: []; retained exact C++. +- updateRepeatInput__Q39textinput9inputform12LayoutByNW4RFUlUl: typed directional repeat timers: src 0x11c base 0x11c insns 71/71; diffs 16: [20, 21, 22, 23, 34, 35, 36, 37, 48, 49, 50, 51, 62, 63, 64, 65]; restored prior body. +- doLineFeed__Q39textinput9inputform4BaseFv: line height before cursor query: src 0x98 base 0x98 insns 38/38; diffs 1: [18]; restored prior body. +- doScroll__Q39textinput9inputform4BaseFPQ39textinput15CommandReceiver6Scroll: absolute or animated scroll: src 0xc8 base 0xc8 insns 50/50; diffs 0: []; retained exact C++. +- init__Q39textinput3gui12GUIComponentFv: guarded point initialization: src 0xd8 base 0xd8 insns 54/54; diffs 0: []; retained exact C++. +- updateRepeatInput__Q39textinput9inputform12LayoutByNW4RFUlUl: reuse trigger mask: src 0x11c base 0x11c insns 71/71; diffs 0: []; retained exact C++. +- doLineFeed__Q39textinput9inputform4BaseFv: height plus current cursor: src 0x98 base 0x98 insns 38/38; diffs 1: [18]; restored prior body. +- doLineFeed__Q39textinput9inputform4BaseFv: cursor scalar addition: src 0x98 base 0x98 insns 38/38; diffs 0: []; retained exact C++. +- drawFixString__Q39textinput9inputform4BaseFUl: cursor aggregate initializer: src 0xdc base 0xdc insns 55/55; diffs 7: [2, 3, 9, 10, 28, 35, 36]; restored prior body. +- drawFixString__Q39textinput9inputform4BaseFUl: cursor fields first: src 0xdc base 0xdc insns 55/55; diffs 3: [28, 35, 36]; restored prior body. +- drawFixString__Q39textinput9inputform4BaseFUl: cursor late position: src 0xdc base 0xdc insns 55/55; diffs 10: [7, 8, 9, 10, 11, 12, 13, 28, 35, 36]; restored prior body. +- draw__Q39textinput9inputform4BaseFv: natural draw vectors: src 0x158 base 0x158 insns 86/86; diffs 0: []; retained exact C++. +- doBeforeDrawProcess__Q39textinput9inputform4BaseFPCwUlRCQ49textinput10textdrawer4Base8DrawInfo: typed wrapping and selection rectangle: src 0x1cc base 0x1cc insns 115/115; diffs 2: [73, 74]; restored prior body. +- doBeforeDrawProcess__Q39textinput9inputform4BaseFPCwUlRCQ49textinput10textdrawer4Base8DrawInfo: selection cursor first operands: src 0x1cc base 0x1cc insns 115/115; diffs 2: [73, 74]; restored prior body. +- doBeforeDrawProcess__Q39textinput9inputform4BaseFPCwUlRCQ49textinput10textdrawer4Base8DrawInfo: selected range declaration order: src 0x1cc base 0x1cc insns 115/115; diffs 6: [66, 67, 72, 73, 74, 75]; restored prior body. +- drawFixString__Q39textinput9inputform4BaseFUl: widen string length before draw call: src 0xdc base 0xdc insns 55/55; diffs 0: []; retained exact C++. +- doBeforeDrawProcess__Q39textinput9inputform4BaseFPCwUlRCQ49textinput10textdrawer4Base8DrawInfo: position-first selected range compare: src 0x1cc base 0x1cc insns 115/115; diffs 0: []; retained exact C++. +- getCurrentString__Q39textinput9inputform4BaseFb: typed current string selection: src 0x1bc base 0x1c0 insns 111/112; --- replace mine 11:12 base 11:12; restored prior body. +- getCurrentString__Q39textinput9inputform4BaseFb: positive Korean keyboard branch: src 0x1bc base 0x1c0 insns 111/112; --- replace mine 11:12 base 11:12; restored prior body. +- getCurrentString__Q39textinput9inputform4BaseFb: separate fix and input predicates: src 0x1cc base 0x1c0 insns 115/112; --- replace mine 11:12 base 11:12; restored prior body. +- moveCursorUp__Q39textinput9inputform4BaseFv: typed upper row cursor: src 0x158 base 0x160 insns 86/88; --- replace mine 5:6 base 5:6; restored prior body. +- moveCursorUp__Q39textinput9inputform4BaseFv: cursor upper operands: src 0x158 base 0x160 insns 86/88; --- replace mine 5:6 base 5:6; restored prior body. +- moveCursorUp__Q39textinput9inputform4BaseFv: upper row index declaration: src 0x158 base 0x160 insns 86/88; --- replace mine 5:6 base 5:6; restored prior body. +- moveCursorDown__Q39textinput9inputform4BaseFv: typed lower row cursor: src 0x184 base 0x180 insns 97/96; --- replace mine 5:41 base 5:12; restored prior body. +- moveCursorDown__Q39textinput9inputform4BaseFv: cursor lower operands: src 0x184 base 0x180 insns 97/96; --- replace mine 5:41 base 5:12; restored prior body. +- moveCursorDown__Q39textinput9inputform4BaseFv: lower row index declaration: src 0x184 base 0x180 insns 97/96; --- replace mine 5:41 base 5:12; restored prior body. +- updateCandidateState___Q39textinput9inputform4BaseFv: typed candidate refresh: src 0x228 base 0x1e4 insns 138/121; --- replace mine 9:10 base 9:10; restored prior body. +- updateCandidateState___Q39textinput9inputform4BaseFv: prediction buffer after suppress: src 0x228 base 0x1e4 insns 138/121; --- replace mine 9:10 base 9:10; restored prior body. +- updateCandidateState___Q39textinput9inputform4BaseFv: bottom-tested candidate loops: src 0x228 base 0x1e4 insns 138/121; --- replace mine 9:10 base 9:10; restored prior body. +- updateCandidateState___Q39textinput9inputform4BaseFv: qualified candidate caller methods: src 0x1e4 base 0x1e4 insns 121/121; diffs 0: []; retained exact C++. +- moveCursorUp__Q39textinput9inputform4BaseFv: upper boundary emitted first: src 0x158 base 0x160 insns 86/88; --- replace mine 47:48 base 47:48; restored prior body. +- moveCursorUp__Q39textinput9inputform4BaseFv: upper clamp ternary: src 0x160 base 0x160 insns 88/88; diffs 2: [58, 59]; restored prior body. +- moveCursorUp__Q39textinput9inputform4BaseFv: upper cached coordinate clamp: src 0x158 base 0x160 insns 86/88; --- replace mine 47:48 base 47:48; restored prior body. +- moveCursorDown__Q39textinput9inputform4BaseFv: lower boundary emitted first: src 0x180 base 0x180 insns 96/96; diffs 2: [67, 70]; restored prior body. +- getCurrentString__Q39textinput9inputform4BaseFb: boolean switch for Atok fix guard: src 0x1c4 base 0x1c0 insns 113/112; --- replace mine 11:12 base 11:12; restored prior body. +- moveCursorUp__Q39textinput9inputform4BaseFv: subtract line before virtual cursor setup: src 0x160 base 0x160 insns 88/88; diffs 3: [58, 59, 63]; restored prior body. +- moveCursorDown__Q39textinput9inputform4BaseFv: add line before virtual cursor setup: src 0x180 base 0x180 insns 96/96; diffs 0: []; retained exact C++. +- isVacancy__Q39textinput9inputform4BaseCFv: typed vacancy predicates: src 0x194 base 0x180 insns 101/96; --- replace mine 20:21 base 20:21; restored prior body. +- isVacancy__Q39textinput9inputform4BaseCFv: vacancy signed character comparison: src 0x194 base 0x180 insns 101/96; --- replace mine 20:21 base 20:21; restored prior body. +- isVacancy__Q39textinput9inputform4BaseCFv: vacancy positive mode branches: src 0x194 base 0x180 insns 101/96; --- replace mine 20:21 base 20:21; restored prior body. +- notifyChangeMode__Q39textinput9inputform4BaseFv: typed keyboard mode notification: src 0x1bc base 0x1b0 insns 111/108; --- replace mine 4:6 base 4:5; restored prior body. +- notifyChangeMode__Q39textinput9inputform4BaseFv: Korean predict mode ternary: src 0x1b0 base 0x1b0 insns 108/108; diffs 6: [85, 86, 87, 88, 89, 90]; restored prior body. +- notifyChangeMode__Q39textinput9inputform4BaseFv: mode notification switch: src 0x1c8 base 0x1b0 insns 114/108; --- replace mine 4:6 base 4:5; restored prior body. +- inputInputting___Q39textinput9inputform4BaseFw: typed inputting dispatch: src 0x280 base 0x284 insns 160/161; --- replace mine 10:11 base 10:11; restored prior body. +- inputInputting___Q39textinput9inputform4BaseFw: explicit alphabet input branch: src 0x280 base 0x284 insns 160/161; --- replace mine 10:11 base 10:11; restored prior body. +- inputInputting___Q39textinput9inputform4BaseFw: nonpositive prediction count: src 0x280 base 0x284 insns 160/161; --- replace mine 10:11 base 10:11; restored prior body. +- isVacancy__Q39textinput9inputform4BaseCFv: if-chain modes and combined selection flags: src 0x180 base 0x180 insns 96/96; diffs 0: []; retained exact C++. +- notifyChangeMode__Q39textinput9inputform4BaseFv: separate language assignment branches: src 0x1b0 base 0x1b0 insns 108/108; diffs 0: []; retained exact C++. +- inputInputting___Q39textinput9inputform4BaseFw: original range expression and alphabet-first branch: src 0x284 base 0x284 insns 161/161; diffs 0: []; retained exact C++. +- autoScroll__Q39textinput9inputform4BaseFv: typed automatic scrolling: src 0x260 base 0x258 insns 152/150; --- replace mine 0:1 base 0:1; restored prior body. +- autoScroll__Q39textinput9inputform4BaseFv: auto scroll separate vector assignment: src 0x268 base 0x258 insns 154/150; --- replace mine 0:1 base 0:1; restored prior body. +- autoScroll__Q39textinput9inputform4BaseFv: auto scroll scalar scale: src 0x268 base 0x258 insns 154/150; --- replace mine 0:1 base 0:1; restored prior body. +- create__Q39textinput9inputform10EditBufferFP12MEMAllocator: typed placement construction: src 0x220 base 0x214 insns 136/133; --- replace mine 14:16 base 14:15; restored prior body. +- create__Q39textinput9inputform10EditBufferFP12MEMAllocator: separate construction allocation temporaries: src 0x220 base 0x214 insns 136/133; --- replace mine 14:16 base 14:15; restored prior body. +- create__Q39textinput9inputform10EditBufferFP12MEMAllocator: implicit placement null checks: src 0x214 base 0x214 insns 133/133; diffs 0: []; retained exact C++. +- onPressLeft__Q39textinput9inputform4BaseFv: typed software left cursor: src 0x264 base 0x268 insns 153/154; --- replace mine 15:16 base 15:16; restored prior body. +- onPressLeft__Q39textinput9inputform4BaseFv: left positive motion branch: src 0x264 base 0x268 insns 153/154; --- replace mine 15:16 base 15:16; restored prior body. +- onPressLeft__Q39textinput9inputform4BaseFv: left positive prediction count: src 0x264 base 0x268 insns 153/154; --- replace mine 15:16 base 15:16; restored prior body. +- onPressRight__Q39textinput9inputform4BaseFv: typed software right cursor: src 0x308 base 0x2e4 insns 194/185; --- replace mine 0:1 base 0:1; restored prior body. +- onPressRight__Q39textinput9inputform4BaseFv: right nested space condition: src 0x308 base 0x2e4 insns 194/185; --- replace mine 0:1 base 0:1; restored prior body. +- onPressRight__Q39textinput9inputform4BaseFv: right space initialized fields: src 0x308 base 0x2e4 insns 194/185; --- replace mine 0:1 base 0:1; restored prior body. +- __ct__Q39textinput9inputform4BaseFPQ29textinput7Manager: typed input form constructor: src 0x218 base 0x210 insns 134/132; --- replace mine 6:7 base 6:7; restored prior body. +- __ct__Q39textinput9inputform4BaseFPQ29textinput7Manager: constructor body pointer assignments: src 0x218 base 0x210 insns 134/132; --- replace mine 6:7 base 6:7; restored prior body. +- __ct__Q39textinput9inputform4BaseFPQ29textinput7Manager: constructor explicit rectangle: src 0x218 base 0x210 insns 134/132; --- replace mine 6:7 base 6:7; restored prior body. +- __ct__Q39textinput9inputform4BaseFPQ29textinput7Manager: correct sender reset and packed color: src 0x210 base 0x210 insns 132/132; diffs 0: []; retained exact C++. +- init__Q49textinput9inputform4Base14RowInfoManagerFv: typed row sentinel initialization: src 0xbc base 0x9c insns 47/39; --- replace mine 16:18 base 16:21; restored prior body. +- init__Q49textinput9inputform4Base14RowInfoManagerFv: row sentinel pointer temporary: src 0xac base 0x9c insns 43/39; --- replace mine 12:13 base 12:13; restored prior body. +- init__Q49textinput9inputform4Base14RowInfoManagerFv: row unused sentinel pointer: src 0xb0 base 0x9c insns 44/39; --- replace mine 16:18 base 16:21; restored prior body. +- create__Q39textinput9inputform4BaseFP12MEMAllocatorPQ39textinput9inputform10EditBuffer: typed base row allocation: compile failed (10412 illegal access from 'textinput::inputform::EditBuffer' to); restored prior body. +- create__Q39textinput9inputform4BaseFP12MEMAllocatorPQ39textinput9inputform10EditBuffer: detached-row insertion guard: compile failed (10412 illegal access from 'textinput::inputform::EditBuffer' to); restored prior body. +- create__Q39textinput9inputform4BaseFP12MEMAllocatorPQ39textinput9inputform10EditBuffer: reload row-list after removal: compile failed (10412 illegal access from 'textinput::inputform::EditBuffer' to); restored prior body. +- create__Q39textinput9inputform4BaseFP12MEMAllocatorPQ39textinput9inputform10EditBuffer: typed base row allocation: compile failed (10412 illegal access from 'textinput::inputform::EditBuffer' to); restored prior body. +- create__Q39textinput9inputform4BaseFP12MEMAllocatorPQ39textinput9inputform10EditBuffer: detached-row insertion guard: compile failed (10412 illegal access from 'textinput::inputform::EditBuffer' to); restored prior body. +- create__Q39textinput9inputform4BaseFP12MEMAllocatorPQ39textinput9inputform10EditBuffer: reload row-list after removal: compile failed (10412 illegal access from 'textinput::inputform::EditBuffer' to); restored prior body. +- create__Q39textinput9inputform4BaseFP12MEMAllocatorPQ39textinput9inputform10EditBuffer: typed base row allocation: src 0x114 base 0x120 insns 69/72; --- replace mine 27:28 base 27:60; restored prior body. +- create__Q39textinput9inputform4BaseFP12MEMAllocatorPQ39textinput9inputform10EditBuffer: detached-row insertion guard: src 0x11c base 0x120 insns 71/72; --- replace mine 28:29 base 28:29; restored prior body. +- create__Q39textinput9inputform4BaseFP12MEMAllocatorPQ39textinput9inputform10EditBuffer: reload row-list after removal: src 0x118 base 0x120 insns 70/72; --- replace mine 27:28 base 27:60; restored prior body. +- calc__Q39textinput9inputform4BaseFv: typed selection color animation: src 0x294 base 0x294 insns 165/165; diffs 13: [21, 53, 126, 127, 128, 129, 130, 131, 132, 151, 152, 153, 154]; restored prior body. +- calc__Q39textinput9inputform4BaseFv: color green before red assignment: src 0x294 base 0x294 insns 165/165; diffs 17: [21, 53, 78, 79, 82, 83, 126, 127, 128, 129, 130, 131, 132, 151, 152, 153, 154]; restored prior body. +- calc__Q39textinput9inputform4BaseFv: color time increment operand order: src 0x294 base 0x294 insns 165/165; diffs 12: [21, 53, 126, 127, 128, 129, 130, 131, 132, 152, 153, 154]; restored prior body. +- findURL__Q39textinput9inputform4BaseFPUlPUlPCwUlUl: typed URL prefix scan: compile failed (10248 function call '[textinput::inputform::Base].wcsnicmp({lval} const); restored prior body. +- findURL__Q39textinput9inputform4BaseFPUlPUlPCwUlUl: nested character range scan: compile failed (10248 function call '[textinput::inputform::Base].wcsnicmp({lval} const); restored prior body. +- findURL__Q39textinput9inputform4BaseFPUlPUlPCwUlUl: pointer iterator URL prefix scan: compile failed (10248 function call '[textinput::inputform::Base].wcsnicmp({lval} const); restored prior body. +- findURL__Q39textinput9inputform4BaseFPUlPUlPCwUlUl: typed URL prefix scan: src 0x190 base 0x1bc insns 100/111; --- insert mine 5:5 base 5:6; restored prior body. +- findURL__Q39textinput9inputform4BaseFPUlPUlPCwUlUl: nested character range scan: src 0x190 base 0x1bc insns 100/111; --- insert mine 5:5 base 5:6; restored prior body. +- findURL__Q39textinput9inputform4BaseFPUlPUlPCwUlUl: pointer iterator URL prefix scan: src 0x190 base 0x1bc insns 100/111; --- insert mine 5:5 base 5:6; restored prior body. +- drawCursor__Q39textinput9inputform4BaseFff: typed blinking cursor line: src 0x11c base 0x118 insns 71/70; --- insert mine 48:48 base 48:57; restored prior body. +- drawCursor__Q39textinput9inputform4BaseFff: cursor scalar opacity after coordinates: src 0x11c base 0x118 insns 71/70; --- insert mine 48:48 base 48:57; restored prior body. +- drawCursor__Q39textinput9inputform4BaseFff: cursor explicit alpha accumulator: src 0x11c base 0x118 insns 71/70; --- replace mine 34:35 base 34:35; restored prior body. +- isOverLine__Q39textinput9inputform4BaseFRCQ49textinput10textdrawer4Base8DrawInfo: typed line limit scales: src 0xdc base 0xcc insns 55/51; --- replace mine 0:1 base 0:1; restored prior body. +- isOverLine__Q39textinput9inputform4BaseFRCQ49textinput10textdrawer4Base8DrawInfo: line limit scalar scale: src 0xec base 0xcc insns 59/51; --- replace mine 0:1 base 0:1; restored prior body. +- isOverLine__Q39textinput9inputform4BaseFRCQ49textinput10textdrawer4Base8DrawInfo: line limit const vector references: src 0xdc base 0xcc insns 55/51; --- replace mine 0:1 base 0:1; restored prior body. +- isAtokActive__Q39textinput9inputform4BaseCFv: explicit Atok boolean assignment: src 0x30 base 0x28 insns 12/10; --- delete mine 2:5 base 2:2; restored prior body. +- isAtokActive__Q39textinput9inputform4BaseCFv: Atok boolean switch guard: src 0x28 base 0x28 insns 10/10; diffs 2: [1, 2]; restored prior body. +- isAtokActive__Q39textinput9inputform4BaseCFv: Atok integer guard: src 0x28 base 0x28 insns 10/10; diffs 0: []; retained exact C++. +- create__Q39textinput9inputform4BaseFP12MEMAllocatorPQ39textinput9inputform10EditBuffer: detached row guard with fresh list pointer: src 0x120 base 0x120 insns 72/72; diffs 26: [28, 30, 33, 34, 35, 36, 37, 38, 39, 40, 42, 43, 44, 46, 49, 51, 53, 54, 55, 56]; restored prior body. +- drawCursor__Q39textinput9inputform4BaseFff: font height in line endpoint argument: src 0x118 base 0x118 insns 70/70; diffs 2: [59, 61]; restored prior body. +- onPressRightHWKB__Q39textinput9inputform4BaseFv: onPressRightHWKB integer zero switch: src 0x450 base 0x44c insns 276/275; --- replace mine 19:20 base 19:20; restored prior body. +- onPressRightHWKB__Q39textinput9inputform4BaseFv: onPressRightHWKB integer one switch: src 0x44c base 0x44c insns 275/275; diffs 2: [93, 94]; restored prior body. +- onPressRightHWKB__Q39textinput9inputform4BaseFv: onPressRightHWKB integer zero guard: src 0x448 base 0x44c insns 274/275; --- replace mine 19:20 base 19:20; restored prior body. +- onPressLeftHWKB__Q39textinput9inputform4BaseFv: onPressLeftHWKB integer zero switch: src 0x424 base 0x420 insns 265/264; --- replace mine 19:20 base 19:20; restored prior body. +- onPressLeftHWKB__Q39textinput9inputform4BaseFv: onPressLeftHWKB integer one switch: src 0x420 base 0x420 insns 264/264; diffs 2: [93, 94]; restored prior body. +- onPressLeftHWKB__Q39textinput9inputform4BaseFv: onPressLeftHWKB integer zero guard: src 0x41c base 0x420 insns 263/264; --- replace mine 19:20 base 19:20; restored prior body. +- onPressUp__Q39textinput9inputform4BaseFv: onPressUp integer zero switch: src 0x3dc base 0x3d8 insns 247/246; --- replace mine 11:12 base 11:12; restored prior body. +- onPressUp__Q39textinput9inputform4BaseFv: onPressUp integer one switch: src 0x3d8 base 0x3d8 insns 246/246; diffs 2: [199, 200]; restored prior body. +- onPressUp__Q39textinput9inputform4BaseFv: onPressUp integer zero guard: src 0x3d4 base 0x3d8 insns 245/246; --- replace mine 11:12 base 11:12; restored prior body. +- onPressDown__Q39textinput9inputform4BaseFv: onPressDown integer zero switch: src 0x3dc base 0x3d8 insns 247/246; --- replace mine 11:12 base 11:12; restored prior body. +- onPressDown__Q39textinput9inputform4BaseFv: onPressDown integer one switch: src 0x3d8 base 0x3d8 insns 246/246; diffs 2: [199, 200]; restored prior body. +- onPressDown__Q39textinput9inputform4BaseFv: onPressDown integer zero guard: src 0x3d4 base 0x3d8 insns 245/246; --- replace mine 11:12 base 11:12; restored prior body. +- calc__Q39textinput9inputform4BaseFv: real color phase and scrolling float assignment: compile failed (10140 undefined identifier 'sfColorPhase'); restored prior body. +- calc__Q39textinput9inputform4BaseFv: pulse query beside blue interpolation: compile failed (10140 undefined identifier 'sfColorPhase'); restored prior body. +- calc__Q39textinput9inputform4BaseFv: real color phase and scrolling float assignment: src 0x294 base 0x294 insns 165/165; diffs 11: [53, 126, 127, 128, 129, 130, 131, 132, 152, 153, 154]; restored prior body. +- calc__Q39textinput9inputform4BaseFv: pulse query beside blue interpolation: src 0x294 base 0x294 insns 165/165; diffs 8: [53, 126, 128, 129, 130, 152, 153, 154]; restored prior body. +- onCursor__Q39textinput9inputform4BaseFPQ49textinput10textdrawer4Base9CursorPos: cursor centered width subtraction: compile failed (33026 ); restored prior body. +- onCursor__Q39textinput9inputform4BaseFPQ49textinput10textdrawer4Base9CursorPos: cursor scale first multiplication: compile failed (33026 ); restored prior body. +- onCursor__Q39textinput9inputform4BaseFPQ49textinput10textdrawer4Base9CursorPos: cursor half-width local: compile failed (33026 ); restored prior body. +- onPressDownHWKB__Q39textinput9inputform4BaseFv: down HWKB selected local scope: compile failed (33026 ); restored prior body. +- onPressDownHWKB__Q39textinput9inputform4BaseFv: down HWKB selected initial value: compile failed (33026 ); restored prior body. +- onPressDownHWKB__Q39textinput9inputform4BaseFv: down HWKB unsigned kana predicate: compile failed (33026 ); restored prior body. +- onCursor__Q39textinput9inputform4BaseFPQ49textinput10textdrawer4Base9CursorPos: cursor centered width subtraction: src 0x764 base 0x764 insns 473/473; diffs 15: [265, 267, 268, 269, 271, 272, 273, 274, 275, 276, 277, 278, 280, 281, 283]; restored prior body. +- onCursor__Q39textinput9inputform4BaseFPQ49textinput10textdrawer4Base9CursorPos: cursor scale first multiplication: src 0x764 base 0x764 insns 473/473; diffs 5: [271, 273, 276, 281, 283]; restored prior body. +- onCursor__Q39textinput9inputform4BaseFPQ49textinput10textdrawer4Base9CursorPos: cursor half-width local: src 0x764 base 0x764 insns 473/473; diffs 17: [265, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 283]; restored prior body. +- onPressDownHWKB__Q39textinput9inputform4BaseFv: down HWKB selected local scope: src 0x428 base 0x438 insns 266/270; --- replace mine 16:17 base 16:17; restored prior body. +- onPressDownHWKB__Q39textinput9inputform4BaseFv: down HWKB selected initial value: src 0x428 base 0x438 insns 266/270; --- replace mine 16:17 base 16:17; restored prior body. +- onPressDownHWKB__Q39textinput9inputform4BaseFv: down HWKB unsigned kana predicate: src 0x428 base 0x438 insns 266/270; --- replace mine 16:17 base 16:17; restored prior body. +- onSpaceKeyHWKB__Q39textinput9inputform4BaseFUl: space-key prediction integer predicate: src 0x96c base 0x96c insns 603/603; diffs 7: [193, 194, 195, 196, 197, 198, 199]; restored prior body. +- onSpaceKeyHWKB__Q39textinput9inputform4BaseFUl: space-key prediction initialization: src 0x96c base 0x96c insns 603/603; diffs 7: [193, 194, 195, 196, 197, 198, 199]; restored prior body. +- onSpaceKeyHWKB__Q39textinput9inputform4BaseFUl: space-key positive prediction predicate: src 0x96c base 0x96c insns 603/603; diffs 11: [92, 93, 193, 194, 195, 196, 197, 198, 199, 410, 411]; restored prior body. +- setLanguage__Q39textinput9inputform12LayoutByNW4RFQ29textinput8Language: language root query reference: src 0x3b8 base 0x3b4 insns 238/237; --- delete mine 52:53 base 52:52; restored prior body. +- setLanguage__Q39textinput9inputform12LayoutByNW4RFQ29textinput8Language: language selected pane name temporary: src 0x3b4 base 0x3b4 insns 237/237; diffs 22: [57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 118, 119, 120, 121, 122, 123, 124, 125, 126]; restored prior body. +- setLanguage__Q39textinput9inputform12LayoutByNW4RFQ29textinput8Language: language title pane declaration: src 0x3b4 base 0x3b4 insns 237/237; diffs 59: [57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 78, 79, 82, 83, 90, 91, 92, 95, 98]; restored prior body. +- create__Q39textinput9inputform12LayoutByNW4RFP12MEMAllocatorPQ39textinput9inputform10EditBuffer: layout detached row insertion guard: src 0x5a0 base 0x590 insns 360/356; --- replace mine 5:6 base 5:6; restored prior body. +- create__Q39textinput9inputform12LayoutByNW4RFP12MEMAllocatorPQ39textinput9inputform10EditBuffer: layout row list reload: src 0x594 base 0x590 insns 357/356; --- replace mine 5:6 base 5:6; restored prior body. +- create__Q39textinput9inputform12LayoutByNW4RFP12MEMAllocatorPQ39textinput9inputform10EditBuffer: layout narrow button counter: src 0x590 base 0x590 insns 356/356; diffs 205: [5, 7, 8, 10, 14, 15, 16, 20, 22, 23, 25, 26, 28, 29, 30, 31, 32, 33, 34, 35]; restored prior body. +- calcCursorPos__Q39textinput9inputform4BaseFff: cursor position bottom-independent loop: src 0x518 base 0x518 insns 326/326; diffs 81: [28, 45, 49, 51, 58, 60, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 94]; restored prior body. +- calcCursorPos__Q39textinput9inputform4BaseFff: cursor position separate scale assignment: src 0x520 base 0x518 insns 328/326; --- replace mine 28:29 base 28:29; restored prior body. +- calcCursorPos__Q39textinput9inputform4BaseFff: cursor position string before scroll coordinate: src 0x51c base 0x518 insns 327/326; --- delete mine 22:23 base 22:22; restored prior body. +- isOverRowLimit__Q39textinput9inputform4BaseFUlPCw: row limit separate scale assignment: src 0x3b4 base 0x3b8 insns 237/238; --- replace mine 0:1 base 0:1; restored prior body. +- isOverRowLimit__Q39textinput9inputform4BaseFUlPCw: row limit defer scalar width: src 0x3b0 base 0x3b8 insns 236/238; --- replace mine 0:1 base 0:1; restored prior body. +- isOverRowLimit__Q39textinput9inputform4BaseFUlPCw: row limit glyph rectangle constructor: src 0x3c0 base 0x3b8 insns 240/238; --- replace mine 14:15 base 14:15; restored prior body. +- onCommand__Q39textinput9inputform4BaseFQ39textinput15CommandReceiver13INPUT_COMMANDPv: command fixed string predicate integer: src 0x2020 base 0x2014 insns 2056/2053; --- replace mine 0:1 base 0:1; restored prior body. +- onCommand__Q39textinput9inputform4BaseFQ39textinput15CommandReceiver13INPUT_COMMANDPv: command uncached fixed string comparison: src 0x2020 base 0x2014 insns 2056/2053; --- replace mine 0:1 base 0:1; restored prior body. +- onCommand__Q39textinput9inputform4BaseFQ39textinput15CommandReceiver13INPUT_COMMANDPv: command fixed string declaration after predicate: src 0x2020 base 0x2014 insns 2056/2053; --- replace mine 0:1 base 0:1; restored prior body. +- isEnableCursorCache__Q39textinput10textdrawer4BaseCFv: cache bool ternary: ; restored prior body. +- Cursor-cache cache bool ternary: 8/8 bytes; raw equal True. Original symbol remains malformed; no aliases/config changes. +- isEnableCursorCache__Q39textinput10textdrawer4BaseCFv: cache positive branch: ; restored prior body. +- Cursor-cache cache positive branch: 8/8 bytes; raw equal True. Original symbol remains malformed; no aliases/config changes. +- isEnableCursorCache__Q39textinput10textdrawer4BaseCFv: cache byte predicate: ; restored prior body. +- Cursor-cache cache byte predicate: 20/8 bytes; raw equal False. Original symbol remains malformed; no aliases/config changes. + +## Third continuation handoff +- Converted 29 existing asm bodies instruction-exact to C++; 41 -> 12 remain. All twelve remaining asm bodies and every report-nonmatching function have at least three distinct compiled source-level attempts logged, including the cursor-cache raw-byte audit. Failed preliminary builds are recorded separately. +- Real data restored: UTF-16 URL prefix table uses ordinary wide literals; selection-color phase is an ordinary zero-initialized float replacing the inherited address-label extern. No explicit data placement was added. Pool remains identical, and .rodata/.sdata/.sdata2 remain 100%. +- Data experiment: deferring the real singleton inline definition moves its weak guard/object after the color storage, but also moves its destructor registrar behind the colors, changing seven initializer offsets. Restored the original singleton definition. Real color state occupies offsets 0x08..0x24 in the compiled .sbss because the guard/object occupy the first eight bytes; the extracted target lacks these deduplicated weak objects. No padding, force-active, section changes or symbol aliases were added. +- Weak Decolated and GUIComponent vtables appear after genuine constructors/init are restored. Their original deduplicated output is absent/zero-filled; extracted EditBuffer and textinput Base vtables also retain trailing zero gaps. Data is still incomplete. No linking-mode changes or DOL investigation. +- The gate's character-plus-0xcf65 review note concerns a wchar_t numeric range test, not a pointer into a string blob. It reproduces the target addis/addi and inclusive range comparison. +- Uncertain: the exact semantic name of WithZi's final flag at 0xa8, and some reconstructed drawer viewport/cache fields. Their offsets, sizes, zero initialization and instruction uses are verified; linking of weak data remains outside this phase. + +### Remaining report-nonmatching functions +Base::onCommand, 88.05163%, stack frame, register allocation and case scheduling. +Base::onCursor, 99.915436%, five centered-space FP register/operand differences. +Base::calcCursorPos, 90.671776%, FP scheduling and register allocation. +Base::onPressUp, 99.55285%, one missing kana guard tail branch. +Base::onPressDown, 99.55285%, one missing kana guard tail branch. +Base::onPressDownHWKB, 98.35185%, candidate branches, index registers and trailing comparison. +Base::onPressLeftHWKB, 99.97727%, two kana comparison/polarity instructions. +Base::onPressRightHWKB, 99.97818%, two kana comparison/polarity instructions. +Base::onSpaceKeyHWKB, 99.32007%, seven Atok Boolean block-order instructions. +LayoutByNW4R::create, 88.91854%, row-list scheduling, registers and loops. +LayoutByNW4R::setLanguage, 96.44726%, 22 root-load scheduling differences. +Base::isOverRowLimit, 93.63866%, stack frame, FP scheduling and registers. +textdrawer::Base::isEnableCursorCache, None%, original report symbol concatenates getStartPos; actual 8 bytes are exact. + +### Exact asm bodies still requiring C++ +extern "C" asm void draw__Q39textinput9inputform12LayoutByNW4RFv(), objdiff 100%, 114/114 C++ instructions, twelve vector temporary offsets. +extern "C" asm bool findURL__Q39textinput9inputform4BaseFPUlPUlPCwUlUl(), objdiff 100%, 100/111 C++ instructions, balanced character classification and registers. +extern "C" asm void autoScroll__Q39textinput9inputform4BaseFv(), objdiff 100%, 152/150 C++ instructions, frame and FP scheduling. +extern "C" asm void create__Q39textinput9inputform4BaseFP12MEMAllocatorPQ39textinput9inputform10EditBuffer(), objdiff 100%, 72/72 C++ instructions, 26 register differences. +extern "C" asm void getCurrentString__Q39textinput9inputform4BaseFb(), objdiff 100%, 111/112 C++ instructions, Atok guard tail branch. +extern "C" asm void moveCursorUp__Q39textinput9inputform4BaseFv(), objdiff 100%, 88/88 C++ instructions, two subtract/vtable scheduling differences. +extern "C" asm void onPressLeft__Q39textinput9inputform4BaseFv(), objdiff 100%, 153/154 C++ instructions, kana guard and Boolean block order. +extern "C" asm void onPressRight__Q39textinput9inputform4BaseFv(), objdiff 100%, 194/185 C++ instructions, space buffer copy and kana guard. +extern "C" asm void calc__Q39textinput9inputform4BaseFv(), objdiff 100%, 165/165 C++ instructions, eight FP/store scheduling differences. +extern "C" asm void init__Q49textinput9inputform4Base14RowInfoManagerFv(), objdiff 100%, 43/39 C++ instructions, sentinel pointer loads. +asm bool Base::isOverLine(const DrawInfo& drawInfo), objdiff 100%, 55/51 C++ instructions, vector temporary copies. +asm void Base::drawCursor(f32, f32), objdiff 100%, 70/70 C++ instructions, two linewidth result register differences. + +### Final full gate +```text +full build: ok +main.dol sha1: 26116613f624061ba99c8d1a299aaa6efa85670d +[src/keyboard/tiInputForm] pool: IDENTICAL +[src/keyboard/tiInputForm] objdiff: code 28300/50656 data 908/3772 functions 208/221 fuzzy 97.2205 linked code 0 +[src/keyboard/tiInputForm] instruction-exact functions: 206/221 +[src/keyboard/tiInputForm] section .bss size 96 match None +[src/keyboard/tiInputForm] section .ctors size 4 match 100.0 +[src/keyboard/tiInputForm] section .data size 2736 match 65.53332 +[src/keyboard/tiInputForm] section .rodata size 760 match 100.0 +[src/keyboard/tiInputForm] section .sbss size 32 match 33.333336 +[src/keyboard/tiInputForm] section .sdata size 40 match 100.0 +[src/keyboard/tiInputForm] section .sdata2 size 104 match 100.0 +[src/keyboard/tiInputForm] section .text size 50656 match 97.22054 +[src/keyboard/tiInputForm] below 100: onCommand__Q39textinput9inputform4BaseFQ39textinput15CommandReceiver13INPUT_COMMANDPv 88.05163 +[src/keyboard/tiInputForm] below 100: onCursor__Q39textinput9inputform4BaseFPQ49textinput10textdrawer4Base9CursorPos 99.915436 +[src/keyboard/tiInputForm] below 100: calcCursorPos__Q39textinput9inputform4BaseFff 90.671776 +[src/keyboard/tiInputForm] below 100: onPressUp__Q39textinput9inputform4BaseFv 99.55285 +[src/keyboard/tiInputForm] below 100: onPressDown__Q39textinput9inputform4BaseFv 99.55285 +[src/keyboard/tiInputForm] below 100: onPressDownHWKB__Q39textinput9inputform4BaseFv 98.35185 +[src/keyboard/tiInputForm] below 100: onPressLeftHWKB__Q39textinput9inputform4BaseFv 99.97727 +[src/keyboard/tiInputForm] below 100: onPressRightHWKB__Q39textinput9inputform4BaseFv 99.97818 +[src/keyboard/tiInputForm] below 100: onSpaceKeyHWKB__Q39textinput9inputform4BaseFUl 99.32007 +[src/keyboard/tiInputForm] below 100: create__Q39textinput9inputform12LayoutByNW4RFP12MEMAllocatorPQ39textinput9inputform10EditBuffer 88.91854 +[src/keyboard/tiInputForm] below 100: setLanguage__Q39textinput9inputform12LayoutByNW4RFQ29textinput8Language 96.44726 +[src/keyboard/tiInputForm] below 100: isOverRowLimit__Q39textinput9inputform4BaseFUlPCw 93.63866 +[src/keyboard/tiInputForm] below 100: isEnableCursorCache__Q39textinput10textdrawer4BaseCFvgetStartPos__Q39textinput10textdrawer4BaseCFv None +[src/keyboard/tiInputForm] baseline: code 28300/50656 data 908 functions 208 fuzzy 97.2205 +regressions vs baseline: 0 +global matched_code_percent: 72.81211 -> 72.81211 +global fuzzy_match_percent: 82.03321 -> 82.03321 +global complete_code_percent: 56.76068 -> 56.76068 +global matched_data_percent: 86.27892 -> 86.27892 +forbidden patterns added (net, per file): 0 +readability warnings (net, per file; must be 0 in the final result): 0 +review note: src/keyboard/tiInputForm.cpp: possible pointer+offset into a blob (orchestrator reviews) (+1 net), e.g. if (static_cast(character + 0xcf65) <= 1) { +GATE PASS +``` -- 2.49.1