From 36ec2f33637340bfd2f16d2957a87be9fc0f4ac8 Mon Sep 17 00:00:00 2001 From: coah <100182500+coah80@users.noreply.github.com> Date: Mon, 28 Sep 2026 05:05:12 +0000 Subject: [PATCH 1/2] feat: improve iplBoard matching Restructure calc, stt_wait_fadeaway and edge_arrow with early returns and split conditions, iterate hovered objects with an explicit next pointer, and add the VEC3 add helper used by calc_board_object. 93/94 functions now match; appendRecord still differs because the original keeps the interrupt state on the stack. Ported from agent/continue0923/src_scene_board_iplboard without its string-pool and volatile workarounds. --- src/scene/board/iplBoard.cpp | 150 ++++++++++++++++++----------------- 1 file changed, 78 insertions(+), 72 deletions(-) diff --git a/src/scene/board/iplBoard.cpp b/src/scene/board/iplBoard.cpp index 24eeb4df..612b4f6c 100644 --- a/src/scene/board/iplBoard.cpp +++ b/src/scene/board/iplBoard.cpp @@ -197,55 +197,53 @@ namespace ipl { mpLayoutBg->calc(); mpLayoutFocusBg->calc(); - if (mState != STATE_TO_SETTINGS && mState != STATE_TERMINATE) { - if (mState == STATE_DONE) { - return; + if (mState == STATE_TO_SETTINGS || mState == STATE_TERMINATE || mState == STATE_DONE) { + return; + } + + calc_board_object(); + + Button* button = get_button(); + + if (mbNewMsgAnimCount && button != NULL) { + /* Message count on button icon */ + + wchar_t numStr[3] = L""; + int index = 0; + + int mailCount; + + if (mMsgCount >= 0) { + mailCount = 99; + if (mMsgCount <= 99) { + mailCount = mMsgCount; + } + } else { + mailCount = 0; } - calc_board_object(); + if (mailCount >= 10) { + index = 1; + numStr[0] = scNumber[(mailCount / 10) % 10]; + } + numStr[index++] = scNumber[mailCount % 10]; - Button* button = get_button(); + button->setText("T_BbsMark1", numStr); - if (mbNewMsgAnimCount && button != NULL) { - /* Message count on button icon */ + // New mail animation - int index = 0; - wchar_t numStr[3] = L""; - - int mailCount; - - if (mMsgCount >= 0) { - mailCount = 99; - if (mMsgCount <= 99) { - mailCount = mMsgCount; - } - } else { - mailCount = 0; - } - - if (mailCount >= 10) { - index = 1; - numStr[0] = scNumber[(mailCount / 10) % 10]; - } - numStr[index++] = scNumber[mailCount % 10]; - - button->setText("T_BbsMark1", numStr); - - // New mail animation - - if (mailCount != 0) { - button->startMailNumAnm(); - } else { - button->stopMailNumAnm(); - } - - mbNewMsgAnimCount = false; + if (mailCount != 0) { + button->startMailNumAnm(); + } else { + button->stopMailNumAnm(); } - // Do SD process - if (System::getCdbManager() != NULL && mState != STATE_WAIT_INIT) { - mBoardSD.update(); - } + mbNewMsgAnimCount = false; + } + + // Do SD process + if (System::getCdbManager() != NULL && mState != STATE_WAIT_INIT) { + mBoardSD.update(); } } } @@ -907,14 +905,16 @@ namespace ipl { if (mState == STATE_NORMAL) { for (int i = 0; i < WPAD_MAX_CONTROLLERS; i++) { BoardObject* object = NULL; - FOREACH_OBJ_IN_LIST(object) { + BoardObject* nextObject = NULL; + while ((nextObject = mObjList.getNext(object)) != NULL) { + object = nextObject; if ((mHoveredObjs[i] == NULL || mHoveredObjs[i] == object) && mState == STATE_NORMAL) { object->update(i); } } if (System::getController(i) == NULL && mHoveredObjs[i] != NULL) { - object->start_left_event(i); + mHoveredObjs[i]->start_left_event(i); mHoveredObjs[i] = NULL; } } @@ -1134,9 +1134,11 @@ namespace ipl { bool result = mbDoReadTask == false; BoardObject* object = NULL; FOREACH_OBJ_IN_LIST(object) { - result = (result & (!object->mbRightWay && !object->mbLeftWay && !object->mMoveAnim.isPlaying() && object->mpLayout != NULL && - !object->mpLayout->getAnim(BoardObject::ANIM_NEXT_PAGE)->isPlaying())) != false && - object->mbModifiedPos == false; + bool stillMoving = (result & (!object->mbRightWay && !object->mbLeftWay && !object->mMoveAnim.isPlaying() && + object->mpLayout != NULL && + !object->mpLayout->getAnim(BoardObject::ANIM_NEXT_PAGE)->isPlaying())) != false; + bool modifiedPos = object->mbModifiedPos; + result = stillMoving & (modifiedPos == false); } if (result) { @@ -1565,31 +1567,30 @@ namespace ipl { void Board::edge_arrow() { Button* button = get_button(); - if (System::getScene(SCENE_CHANNEL_SELECT) == NULL && System::getReservedScene() == NULL) { - if (mState == STATE_WAIT_CHILD_CST) { - } else { - enable_licon(); - enable_ricon(); + if (System::getScene(SCENE_CHANNEL_SELECT) != NULL || System::getReservedScene() != NULL || mState == STATE_WAIT_CHILD_CST) { + return; + } - if (mCurrentDate == utility::Date::getMaxDate()) { - if (button->isArrowVisible(Button::ARROW_BTN_RIGHT) && mbRIconEnable != true) { - button->animation(Button::IDANIM_ARROW_RIGHT_DISAPPEAR); - } - if (!button->isArrowVisible(Button::ARROW_BTN_LEFT)) { - button->animation(Button::IDANIM_ARROW_LEFT_APPEAR); - } - } else { - if (mCurrentDate == utility::Date::getMinDate()) { - if (button->isArrowVisible(Button::ARROW_BTN_LEFT) && mbLIconEnable != true) { - button->animation(Button::IDANIM_ARROW_LEFT_DISAPPEAR); - } - if (!button->isArrowVisible(Button::ARROW_BTN_RIGHT)) { - button->animation(Button::IDANIM_ARROW_RIGHT_APPEAR); - } - } else { - appear_arrow(); - } + enable_licon(); + enable_ricon(); + + if (mCurrentDate == utility::Date::getMaxDate()) { + if (button->isArrowVisible(Button::ARROW_BTN_RIGHT) && mbRIconEnable != true) { + button->animation(Button::IDANIM_ARROW_RIGHT_DISAPPEAR); + } + if (!button->isArrowVisible(Button::ARROW_BTN_LEFT)) { + button->animation(Button::IDANIM_ARROW_LEFT_APPEAR); + } + } else { + if (mCurrentDate == utility::Date::getMinDate()) { + if (button->isArrowVisible(Button::ARROW_BTN_LEFT) && mbLIconEnable != true) { + button->animation(Button::IDANIM_ARROW_LEFT_DISAPPEAR); } + if (!button->isArrowVisible(Button::ARROW_BTN_RIGHT)) { + button->animation(Button::IDANIM_ARROW_RIGHT_APPEAR); + } + } else { + appear_arrow(); } } } @@ -1675,6 +1676,12 @@ namespace ipl { return result; } + static inline nw4r::math::VEC3 addTranslate(const nw4r::math::VEC3& a, const nw4r::math::VEC3& b) { + nw4r::math::VEC3 sum; + nw4r::math::VEC3Add(&sum, &a, &b); + return sum; + } + void Board::calc_board_object() { nw4r::lyt::Pane* pane = mpLayoutBg->FindPaneByName("N_TopBack"); @@ -1682,8 +1689,7 @@ namespace ipl { FOREACH_OBJ_IN_LIST(object) { nw4r::lyt::Pane* posPane = mpLayoutBg->FindPaneByName(scScrollPane[get_date_label(object->mBoardDate)]); - math::VEC3 pos; - nw4r::math::VEC3Add(&pos, &pane->GetTranslate(), &posPane->GetTranslate()); + math::VEC3 pos = addTranslate(pane->GetTranslate(), posPane->GetTranslate()); object->calc(math::VEC2(pos.x, pos.y)); } -- 2.49.1 From 0db31080b1dbe15300eb7f00f705f065b0b8dbf2 Mon Sep 17 00:00:00 2001 From: coah <100182500+coah80@users.noreply.github.com> Date: Mon, 28 Sep 2026 05:08:26 +0000 Subject: [PATCH 2/2] feat: improve iplChannelSelect matching Build the constructor with an initializer list, specialize HermiteIntp::get and HermiteIntp::get in the forms this unit inlines, keep only the three zoom frames setChanZoomOrtho reads, compute the drag delta as a VEC2 with an explicit zero-speed branch, and give setChannelScissor its ortho bounds as named locals. 101/102 functions now match. Ported from agent/continue0923/src_scene_channelselect_iplchannelselect without its IPL_CHANNEL_TITLE_NOVTABLE define, hand-placed lbl_ data, volatile constant loads or register keywords. --- src/scene/channelSelect/iplChannelSelect.cpp | 119 ++++++++++++------- 1 file changed, 78 insertions(+), 41 deletions(-) diff --git a/src/scene/channelSelect/iplChannelSelect.cpp b/src/scene/channelSelect/iplChannelSelect.cpp index 319c04e8..e4c83858 100644 --- a/src/scene/channelSelect/iplChannelSelect.cpp +++ b/src/scene/channelSelect/iplChannelSelect.cpp @@ -16,6 +16,48 @@ // #pragma sym on +namespace ipl { + namespace math { + static inline nw4r::math::VEC3 subHermitePoints(const VEC3& start, const VEC3& end) { + nw4r::math::VEC3 temp; + nw4r::math::VEC3Sub(&temp, &start, &end); + return temp; + } + + template <> + VEC3 HermiteIntp::get() const { + f32 var_f27 = mFrame; + f32 var_f28 = 1.0f / mMaxFrame; + VEC3 r(subHermitePoints( + mStart * (1.0f + ((var_f28 * (var_f28 * (var_f28 * (var_f27 * (2.0f * var_f27 * var_f27))))) - + (var_f28 * (var_f28 * (3.0f * var_f27 * var_f27))))), + mEnd * ((var_f28 * (var_f28 * (var_f28 * (var_f27 * (2.0f * var_f27 * var_f27))))) - + (var_f28 * (var_f28 * (3.0f * var_f27 * var_f27)))))); + f32 temp_f4 = var_f27 * var_f27; + f32 temp_f7 = var_f28 * (var_f28 * (var_f27 * temp_f4)); + f32 temp_f3 = (unkVal0 * (var_f27 + (temp_f7 - (var_f28 * (2.0f * var_f27 * var_f27))))) + + (unkVal1 * (temp_f7 - (var_f28 * temp_f4))); + r.x += temp_f3; + r.y += temp_f3; + r.z += temp_f3; + return r; + } + + template <> + f32 HermiteIntp::get() const { + f32 var_f27 = mFrame; + f32 var_f28 = 1.0f / mMaxFrame; + f32 r = (mStart * (1.0f + ((var_f28 * (var_f28 * (var_f28 * (var_f27 * (2.0f * var_f27 * var_f27))))) - + (var_f28 * (var_f28 * (3.0f * var_f27 * var_f27)))))) - + (mEnd * ((var_f28 * (var_f28 * (var_f28 * (var_f27 * (2.0f * var_f27 * var_f27))))) - + (var_f28 * (var_f28 * (3.0f * var_f27 * var_f27))))); + r += (unkVal0 * (var_f27 + ((var_f28 * (var_f28 * (var_f27 * (var_f27 * var_f27)))) - (var_f28 * (2.0f * var_f27 * var_f27))))) + + (unkVal1 * ((var_f28 * (var_f28 * (var_f27 * (var_f27 * var_f27)))) - (var_f28 * (var_f27 * var_f27)))); + return r; + } + } // namespace math +} // namespace ipl + namespace ipl { namespace scene { extern "C" char smArg__Q23ipl6System; @@ -368,20 +410,18 @@ namespace ipl { #define FOREACH_CHANNEL_OBJ(chanObj) while (chanObj = (ChannelObj*)nw4r::ut::List_GetNext(&mChanList, chanObj), chanObj != NULL) - ChannelSelect::ChannelSelect(EGG::Heap* heap, int startup) : scene::FaderSceneBase(heap), mpDiskChanObj(NULL) { - mpButtonEvent = new CsChanSelButtonEventHandler(this); - mpSDMenuEvent = new CsChanSelSDMenuEventHandler(this); - - mState = STATE_NONE; - - mStartType = startup; - - mChanThumbOff_X = cfChanThumbOfss[SCGetAspectRatio()][0]; - mChanThumbOff_Y = cfChanThumbOfss[SCGetAspectRatio()][1]; - - mDiskState = DISK_STATE_READ; - mspDiskID = NULL; - mspDiskMaker = NULL; + ChannelSelect::ChannelSelect(EGG::Heap* heap, int startup) + : scene::FaderSceneBase(heap), + mpDiskChanObj(NULL), + mpButtonEvent(new CsChanSelButtonEventHandler(this)), + mpSDMenuEvent(new CsChanSelSDMenuEventHandler(this)), + mState(STATE_NONE), + mStartType(startup), + mChanThumbOff_X(cfChanThumbOfss[SCGetAspectRatio()][0]), + mChanThumbOff_Y(cfChanThumbOfss[SCGetAspectRatio()][1]), + mDiskState(DISK_STATE_READ), + mspDiskID(NULL), + mspDiskMaker(NULL) { // mClock = clock(); @@ -2525,54 +2565,49 @@ calcNormalRestart_ChannelSelect_L7: void ChannelSelect::setChannelScissor(const ChannelObj* channelObj) const { nw4r::math::VEC3 vec(channelObj->getTranslate()); - nw4r::ut::Rect projRect; System::getProjectionRect(&projRect); - GXRenderModeObj* rMode = System::getRenderModeObj(); - f32 var_f29; f32 var_f30; f32 var_f31; f32 var_f1; - u16 var_r0; u16 var_r3; - if (mState == STATE_NORMAL_FADE_ZOOM || mState == STATE_NORMAL_DONE_FADE_ZOOM || mState == STATE_NORMAL_RESTART) { nw4r::math::MTX44 mtx; - f32 fVar1 = unk_0xE4.x; - f32 fVar2 = unk_0xE4.y; - f32 fVar3 = unk_0xD8.x; - f32 fVar4 = unk_0xD8.y; - MTXOrtho(mtx, fVar4 - projRect.top / fVar2, fVar4 - projRect.bottom / fVar2, fVar3 + projRect.left / fVar1, - fVar3 + projRect.right / fVar1, -100.0f, 100.0f); - nw4r::math::VEC4 vec4; + f32 rightScale = projRect.right / unk_0xE4.x; + f32 leftScale = projRect.left / unk_0xE4.x; + f32 topScale = projRect.top / unk_0xE4.y; + f32 bottomScale = projRect.bottom / unk_0xE4.y; + f32 bottom = unk_0xD8.y - bottomScale; + f32 right = unk_0xD8.x + rightScale; + f32 left = unk_0xD8.x + leftScale; + f32 top = unk_0xD8.y - topScale; + MTXOrtho(mtx, top, bottom, left, right, -100.0f, 100.0f); nw4r::math::VEC4 vec4_in(vec.x, vec.y, 0.0f, 1.0f); + nw4r::math::VEC4 vec4; nw4r::math::VEC4Transform(&vec4, &mtx, &vec4_in); - var_r0 = rMode->fbWidth; var_r3 = rMode->efbHeight; var_f29 = projRect.GetWidth(); + var_f30 = (var_r3 - ((1.0f + vec4.y) * var_r3 / 2)) - (mChanThumbOff_Y * unk_0xE4.y); f32 temp_f7_2 = var_r0 / var_f29; + var_f31 = ((1.0f + vec4.x) * var_r0 / 2) - ((mChanThumbOff_X * unk_0xE4.x) * (temp_f7_2)); var_f29 = 2.0f * (mChanThumbOff_X * unk_0xE4.x) * (var_r0 / var_f29); var_f1 = 2.0f * (mChanThumbOff_Y * unk_0xE4.y); - var_f30 = (var_r3 - ((1.0f + vec4.y) * var_r3 / 2)) - (mChanThumbOff_Y * unk_0xE4.y); - var_f31 = ((1.0f + vec4.x) * var_r0 / 2) - ((mChanThumbOff_X * unk_0xE4.x) * (temp_f7_2)); } else { var_r0 = rMode->fbWidth; var_r3 = rMode->efbHeight; - var_f29 = 2.0f * mChanThumbOff_X * (var_r0 / projRect.GetWidth()); - var_f30 = (((f32)var_r3 / 2) - vec.y) - mChanThumbOff_Y; var_f31 = ((f32)var_r0 / 2) + ((vec.x - mChanThumbOff_X) * (var_r0 / projRect.GetWidth())); + var_f30 = (((f32)var_r3 / 2) - vec.y) - mChanThumbOff_Y; + var_f29 = 2.0f * mChanThumbOff_X * (var_r0 / projRect.GetWidth()); var_f1 = 2.0f * mChanThumbOff_Y; } - var_f31 -= 1.0f; var_f30 -= 1.0f; var_f29 += 2.0f; var_f1 += 2.0f; - if (var_f31 >= var_r0 || (var_f31 + var_f29) <= 0.0f || var_f30 >= var_r3 || (var_f30 + var_f1) <= 0.0f) { GXSetScissor(0, 0, 0, 0); } else { @@ -2584,7 +2619,6 @@ calcNormalRestart_ChannelSelect_L7: var_f1 += var_f30; var_f30 = 0.0f; } - if ((var_f31 + var_f29) > 1705.0f) { var_f29 -= (var_f31 + var_f29) - 1705.0f; } @@ -2632,8 +2666,8 @@ calcNormalRestart_ChannelSelect_L7: } void ChannelSelect::setChanZoomOrtho() { - nw4r::math::VEC3 frames[4]; - for (int i = 0; i < 4; i++) { + nw4r::math::VEC3 frames[3]; + for (int i = 0; i < 3; i++) { frames[i] = mpChanZoomParams[i]->get(); } @@ -3174,14 +3208,17 @@ calcNormalMoveChanOut_ChannelSelect_L1: mpMoveLytObject->GetRootPane()->SetTranslate(newPos); mpMoveLytObject->calcMtx(); - f32 speed = 0.0f; + f32 speed; - f32 newY = pos.y - mDragPos.y; - f32 newX = pos.x - mDragPos.x; + math::VEC2 delta; + delta.y = pos.y - mDragPos.y; + delta.x = pos.x - mDragPos.x; - f32 val = (newX * newX) + (newY * newY); + f32 val = (delta.x * delta.x) + (delta.y * delta.y); - if (val > 0.0f) { + if (val <= 0.0f) { + speed = 0.0f; + } else { speed = (val * nw4r::math::FrSqrt(val)); } -- 2.49.1