Compare commits

...

1 Commits

Author SHA1 Message Date
coah
791a63a530 tiTextDrawer 23/24, MyTiLetterForm 26/26 (worker ea883a22) 2026-09-30 04:18:59 +00:00
11 changed files with 727 additions and 22 deletions

View File

@@ -53,9 +53,9 @@ Progress
<!-- progress:start -->
| Decompiled | Matched | Linked | Data |
|:---:|:---:|:---:|:---:|
| 86.34% | 76.29% | 56.92% | 87.18% |
| 86.57% | 76.50% | 56.92% | 87.26% |
units 752/1027 complete, functions 11150/12563 matched.
units 752/1027 complete, functions 11199/12563 matched.
decompiled = code with a C/C++ implementation (objdiff fuzzy), matched = byte-exact code, linked = code actually linked into the DOL, data = byte-exact data
<!-- progress:end -->

View File

@@ -20,7 +20,7 @@ namespace textinput {
virtual void moveNigaoeButton() {}
};
#ifdef MYTIINPUTFORM_IMPLEMENTATION
#if defined(MYTIINPUTFORM_IMPLEMENTATION) || defined(MYTILETTERFORM_IMPLEMENTATION)
class ScrollButton;
#endif
@@ -48,7 +48,7 @@ namespace textinput {
#endif
~InputForm();
#ifdef MYTIINPUTFORM_IMPLEMENTATION
#if defined(MYTIINPUTFORM_IMPLEMENTATION) || defined(MYTILETTERFORM_IMPLEMENTATION)
virtual void moveCursorUp();
virtual void moveCursorDown();
virtual void onCommand(INPUT_COMMAND command, void* data);
@@ -131,7 +131,7 @@ namespace textinput {
void setEditScrollDown(bool editScrollDown) { mbEditScrollUp = editScrollDown; }
void setCloseWithSend(bool closeWithSend) { mbCloseWithSend = closeWithSend; }
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(MYTIINPUTFORM_IMPLEMENTATION)
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(MYTIINPUTFORM_IMPLEMENTATION) || defined(MYTILETTERFORM_IMPLEMENTATION)
void setEditMode(EditMode editMode);
#else
void setEditMode(EditMode editMode) { meEditMode = editMode; }
@@ -147,8 +147,12 @@ namespace textinput {
tistring::Decolated* getSendString() { return mpSendString; }
#ifdef MYTILETTERFORM_IMPLEMENTATION
protected:
#else
private:
#ifdef MYTIINPUTFORM_IMPLEMENTATION
#endif
#if defined(MYTIINPUTFORM_IMPLEMENTATION) || defined(MYTILETTERFORM_IMPLEMENTATION)
nw4r::lyt::Pane* mpMemoPane;
nw4r::lyt::Pane* mpMemoRootPane;
nw4r::lyt::Pane* mpBoundPane;
@@ -172,7 +176,7 @@ namespace textinput {
nw4r::lyt::Size mDefaultBoundSize; // 0x358
Mtx mDrawMtx; // 0x360
Mtx mBoundMtx; // 0x390
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(MYTIINPUTFORM_IMPLEMENTATION)
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(MYTIINPUTFORM_IMPLEMENTATION) || defined(MYTILETTERFORM_IMPLEMENTATION)
util::Animation mExScrollAnm; // 0x3C0
#else
u8 /*todo*/ mExScrollAnm[32]; // 0x3C0
@@ -186,7 +190,7 @@ namespace textinput {
bool mbEditScrollDown; // 0x3EF
bool mbCloseWithSend; // 0x3F0
u8 padding[3]; // 0x3F1
#ifdef MYTIINPUTFORM_IMPLEMENTATION
#if defined(MYTIINPUTFORM_IMPLEMENTATION) || defined(MYTILETTERFORM_IMPLEMENTATION)
ScrollButton* mpScrollButton;
#else
undefined4* mpScrollButton;

View File

@@ -23,6 +23,15 @@ namespace textinput {
unk_0x400(0), mbPhotoDraw(false), meType(T_MailAddressSel) {}
#endif
#ifdef MYTILETTERFORM_IMPLEMENTATION
virtual ~InputForm();
virtual void create(MEMAllocator*, inputform::EditBuffer*);
virtual void drawBody();
virtual void drawFooter();
virtual void open();
virtual void close();
virtual bool isWholePaneInAnimation();
#endif
virtual nw4r::lyt::Material* getPhotoPaneMaterial();
virtual void onPhotoTrig();
@@ -38,7 +47,11 @@ namespace textinput {
void resizePhotoPane(f32 width, f32 height);
private:
#ifdef MYTILETTERFORM_IMPLEMENTATION
bool mbPhotoScaledUp;
#else
u8 unk_0x400;
#endif
bool mbPhotoDraw; // 0x401
Type meType; // 0x404
};

View File

@@ -144,6 +144,11 @@ namespace textinput {
#ifdef TISIGNWINDOW_IMPLEMENTATION
bool isAtokActive() const;
#endif
#ifdef MYTILETTERFORM_IMPLEMENTATION
virtual void create(MEMAllocator* allocator);
virtual void init();
virtual void onCommand(INPUT_COMMAND command, void* data);
#endif
virtual ~Base();
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
@@ -284,7 +289,7 @@ namespace textinput {
virtual void makeUpCursorPos(CursorPos* cursorPos, u32 pos, s32 startLine, s32 endLine);
#if defined(MYTIINPUTFORM_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
#if defined(MYTIINPUTFORM_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION) || defined(MYTILETTERFORM_IMPLEMENTATION)
protected:
#if !defined(TIINPUTFORM_IMPLEMENTATION) && !defined(TIMANAGER_IMPLEMENTATION)
void setCursorPos(tistring::Decolated* string, u32 pos);
@@ -294,7 +299,7 @@ namespace textinput {
#else
private:
#endif
#if defined(MYTIINPUTFORM_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
#if defined(MYTIINPUTFORM_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION) || defined(MYTILETTERFORM_IMPLEMENTATION)
nw4r::ut::Rect mRect;
#else
Rect mRect;
@@ -379,13 +384,13 @@ namespace textinput {
virtual void setRootPaneScaleFor16x9();
virtual void setRootPaneScaleFor4x3();
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION) || defined(MYTILETTERFORM_IMPLEMENTATION)
virtual void onSE(sound::SE seId);
#endif
virtual void visibleSeparator(bool flag);
#if defined(MYTIINPUTFORM_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
#if defined(MYTIINPUTFORM_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION) || defined(MYTILETTERFORM_IMPLEMENTATION)
protected:
const void* mpLayoutData;
const void* mpLanguageData;

View File

@@ -14,7 +14,7 @@ namespace textinput {
class TiEventHandler : public gui::EventHandler {
public:
typedef struct Input {
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION) || defined(TISIGNWINDOW_IMPLEMENTATION)
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION) || defined(TISIGNWINDOW_IMPLEMENTATION) || defined(MYTILETTERFORM_IMPLEMENTATION)
u32 controller;
f32 x;
f32 y;

View File

@@ -6,13 +6,13 @@
#include <nw4r/ut/CharWriter.h>
#include <nw4r/ut/Rect.h>
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION) || defined(TITEXTDRAWER_IMPLEMENTATION) || defined(MYTILETTERFORM_IMPLEMENTATION)
#include <string.h>
#endif
namespace textinput {
namespace textdrawer {
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(MYTIINPUTFORM_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(MYTIINPUTFORM_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION) || defined(TITEXTDRAWER_IMPLEMENTATION) || defined(MYTILETTERFORM_IMPLEMENTATION)
class Base : public nw4r::ut::CharWriter {
#else
class Base : nw4r::ut::CharWriter {
@@ -34,7 +34,7 @@ namespace textinput {
} CursorPos;
typedef struct DrawInfo {
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION) || defined(TITEXTDRAWER_IMPLEMENTATION) || defined(MYTILETTERFORM_IMPLEMENTATION)
nw4r::ut::Rect rect;
wchar_t character;
#else
@@ -94,7 +94,7 @@ namespace textinput {
virtual u32 getEndPos() const;
// todo
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION) || defined(TITEXTDRAWER_IMPLEMENTATION) || defined(MYTILETTERFORM_IMPLEMENTATION)
virtual void setDrawModifyScopeLine(s32 startLine, s32 endLine);
virtual void setDrawCacheScopeLine(s32 startLine, s32 endLine);
virtual void modifyCursorCache(s32 line, u32 position, f32 x, f32 y, f32 width, f32 height);
@@ -103,12 +103,12 @@ namespace textinput {
virtual void setDrawCacheScopeLine();
virtual void modifyCursorCache();
#endif
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION) || defined(TITEXTDRAWER_IMPLEMENTATION) || defined(MYTILETTERFORM_IMPLEMENTATION)
virtual bool isEnableCursorCache() const;
#else
virtual void isEnableCursorCache();
#endif
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION) || defined(TITEXTDRAWER_IMPLEMENTATION) || defined(MYTILETTERFORM_IMPLEMENTATION)
virtual u32 getDrawModifyStartLine() const;
virtual u32 getDrawModifyEndLine() const;
#else
@@ -119,7 +119,42 @@ namespace textinput {
virtual void dirtyDrawCache();
virtual void dirtyCursorCache();
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
#ifdef TITEXTDRAWER_IMPLEMENTATION
protected:
const wchar_t* mpDrawString;
ViewPort mSavedViewport;
f32 mSavedProjection[7];
nw4r::ut::Rect mProjectionRect;
f32 mfVIWidth;
bool mbAspect4x3;
bool mbDrawClipped;
s32 muLine;
f32 mfLineSpacing;
f32 mfCharacterSpacing;
f32 mfFontWidth;
f32 mfFontHeight;
f32 mfModifyStartY;
f32 mfMinScrollY;
u32 muDrawStartPos;
u32 muDrawEndPos;
u32 muDrawCacheStartPos;
bool mbSecretMode;
s32 muDrawModifyStartLine;
s32 muDrawModifyEndLine;
s32 muDrawModifyStartPos;
s32 muDrawModifyEndPos;
u32 muCachedStartPos;
u32 muCachedEndPos;
bool mbDrawCache;
f32 mfCachedCursorX;
f32 mfCachedCursorY;
f32 mfDrawScrollY;
s32 mnCachedCursorLine;
CursorPos mCachedCursor;
bool mbCursorCache;
bool mbMaintainCursorCache;
#else
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION) || defined(TITEXTDRAWER_IMPLEMENTATION) || defined(MYTILETTERFORM_IMPLEMENTATION)
protected:
MEMAllocator* mpDrawAllocator;
u8 mDrawConfiguration[0x34];
@@ -145,7 +180,7 @@ namespace textinput {
u8 unk_0x50[0x78];
#endif
bool mbSecretMode; // 0xC8
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION) || defined(TITEXTDRAWER_IMPLEMENTATION) || defined(MYTILETTERFORM_IMPLEMENTATION)
u32 muDrawModifyStartLine;
u32 muDrawModifyEndLine;
u32 muDrawModifyStartPos;
@@ -167,6 +202,7 @@ namespace textinput {
u8 mDrawCacheState[0x14];
#else
u8 unk_0xCC[0x3C];
#endif
#endif
};
}

View File

@@ -58,7 +58,7 @@ namespace textinput {
CommandReceiver() { clearSender(); }
virtual ~CommandReceiver();
#endif
#if defined(MYTIINPUTFORM_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
#if defined(MYTIINPUTFORM_IMPLEMENTATION) || defined(MYTILETTERFORM_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
struct Scroll {
bool absY;
f32 x;

View File

@@ -0,0 +1,310 @@
#define MYTILETTERFORM_IMPLEMENTATION
#include "keyboard/MyTiLetterForm.h"
#include "keyboard/tiUtil.h"
#include <nw4r/lyt/textbox.h>
#include <new>
namespace textinput {
namespace inputform {
class EventHandler : public nw4rmanager::TiEventHandler {
public:
EventHandler(textinput::InputForm* form) : mpInputForm(form) {}
virtual ~EventHandler() {}
virtual void onTiEvent(gui::PaneComponent*, u32, Input*);
protected:
textinput::InputForm* mpInputForm;
};
}
namespace extend {
namespace memo {
class EventHandler : public inputform::EventHandler {
public:
EventHandler(InputForm* form) : inputform::EventHandler(form), mpMemoForm(form) {}
virtual ~EventHandler() {}
virtual void onTiEvent(gui::PaneComponent*, u32, Input*);
protected:
InputForm* mpMemoForm;
};
}
namespace letter {
class EventHandler : public memo::EventHandler {
public:
EventHandler(InputForm* form) : memo::EventHandler(form) {}
virtual ~EventHandler();
virtual void onTiEvent(gui::PaneComponent*, u32, Input*);
};
class AnmPane : public nw4rmanager::AnmPane {
protected:
enum KeyType { KT_Whole, KT_Pic };
u32 meState;
KeyType meKeyType;
public:
AnmPane(nw4r::lyt::Pane* pane, nw4rmanager::AnmObserver* observer)
: nw4rmanager::AnmPane(pane, observer), meState(0), meKeyType(KT_Whole) {}
virtual ~AnmPane();
virtual void init();
virtual void changeAnimation(u32 id);
virtual KeyType getKeyType() const;
virtual u32 getState();
};
class WholePane : public AnmPane {
public:
WholePane(nw4r::lyt::Pane* pane, nw4rmanager::AnmObserver* observer)
: AnmPane(pane, observer) { meKeyType = KT_Whole; }
virtual ~WholePane();
virtual void onAnmEvent(AnmPaneEvent paneEvent);
};
class PicPane : public AnmPane {
public:
PicPane(nw4r::lyt::Pane* pane, nw4rmanager::AnmObserver* observer)
: AnmPane(pane, observer) { meKeyType = KT_Pic; }
virtual ~PicPane();
virtual void onAnmEvent(AnmPaneEvent paneEvent);
};
static const char* paneNames[] = {
"N_Header", "N_Body", "B_Body", "N_Footer", "Nigaoe",
"T_Nigaoe", "B_Nigaoe", "T_Letter", "T_TouchLetter"
};
struct AnimationFile { u32 id; char fileName[64]; };
static const AnimationFile animationFiles[] = {
{0, "my_LetterL_PicFocusIn.brlan"},
{1, "my_LetterL_SelectPic.brlan"},
{2, "my_LetterL_ExitPic.brlan"},
{3, "my_LetterL_PicFocusOut.brlan"},
{4, "my_LetterL_ReturnIn.brlan"},
{5, "my_LetterL_SendOut.brlan"},
{6, "my_LetterL_MailIn.brlan"},
{7, "my_LetterL_MailOut.brlan"},
};
struct PaneToAnimationGroup {
s32 type;
const char* paneName;
u32 count;
const AnimationFile* animations[12];
};
static const PaneToAnimationGroup animationGroups[] = {
{0, "N_MemoRoot", 4, {&animationFiles[4], &animationFiles[5], &animationFiles[6], &animationFiles[7]}},
{0, "SendPic", 4, {&animationFiles[4], &animationFiles[5], &animationFiles[6], &animationFiles[7]}},
{1, "N_Pic", 5, {&animationFiles[0], &animationFiles[1], &animationFiles[2], &animationFiles[3], &animationFiles[4]}},
{0, "N_SendMes", 1, {&animationFiles[5]}}
};
void InputForm::create(MEMAllocator* allocator, textinput::inputform::EditBuffer* editBuffer) {
memo::InputForm::create(allocator, editBuffer);
MEMFreeToAllocator(allocator, mpInputEventHandler);
mpInputEventHandler = new (MEMAllocFromAllocator(allocator, sizeof(EventHandler))) EventHandler(this);
mpInputEventHandler->setEventObserver(mpEventObserver);
mpPaneManager->changeEventHandler(mpInputEventHandler);
for (u16 i = 0; i < 4; i++) {
const PaneToAnimationGroup* group = &animationGroups[i];
AnmPane* pane = NULL;
switch (group->type) {
case 1:
pane = new (MEMAllocFromAllocator(allocator, sizeof(PicPane))) PicPane(
getPane(group->paneName), NULL);
break;
case 0:
pane = new (MEMAllocFromAllocator(allocator, sizeof(WholePane))) WholePane(
getPane(group->paneName), NULL);
break;
}
nw4r::ut::List_Append(&mAnmPanes, pane);
for (u16 j = 0; j < group->count; j++) {
void* resource = mpMultiArcResourceAccessor->GetResource(0, group->animations[j]->fileName);
AnimTransformPane* transform = static_cast<AnimTransformPane*>(
getLayout()->CreateAnimTransform(resource, mpMultiArcResourceAccessor));
pane->addAnimation(allocator, group->animations[j]->id, transform, false, true);
}
}
searchAnmPane("N_Pic")->changeAnimation(3);
mpLayout->Animate(0);
mpLayout->CalculateMtx(mDrawInfo);
mbPhotoScaledUp = 0;
mbPhotoDraw = false;
mbCloseWithSend = false;
}
AnmPane::~AnmPane() {}
void InputForm::drawBody() {
nw4r::lyt::Pane* bodyPane = getPane(paneNames[1]);
f32 y = 0.0f;
for (int row = 0; row < (mnLine - 1) / 4 + 1; row++) {
bodyPane->SetTranslate(nw4r::math::VEC2(0.0f, y));
bodyPane->CalculateMtx(mDrawInfo);
bodyPane->Draw(mDrawInfo);
y -= bodyPane->GetSize().height;
}
if (!mbEdited) {
getPane("T_TouchLetter")->Draw(mDrawInfo);
}
getPane("SendPic")->Draw(mDrawInfo);
getPane("N_SendMes")->Draw(mDrawInfo);
nw4r::lyt::Pane* scrollPane = getPane("N_txt_scrl");
f32 x = scrollPane->GetTranslate().x;
getPane("N_txt_scrl")->SetTranslate(nw4r::math::VEC2(x, -6.0f));
}
void InputForm::drawFooter() {
nw4r::lyt::Pane* bodyPane = getPane(paneNames[1]);
int row = (mnLine - 1) / 4;
f32 y = static_cast<f32>(row) * (bodyPane->GetSize().height * -1.0f);
nw4r::lyt::Pane* footerPane = getPane(paneNames[3]);
footerPane->SetTranslate(nw4r::math::VEC2(0.0f, y));
footerPane->CalculateMtx(mDrawInfo);
footerPane->Draw(mDrawInfo);
if (mbPhotoDraw) {
getPane("N_Pic")->Draw(mDrawInfo);
}
}
nw4r::lyt::Material* InputForm::getPhotoPaneMaterial() {
return getPane("Pic")->FindMaterialByName("Pic", true);
}
void InputForm::onPhotoTrig() {
if (getEditMode() != memo::InputForm::EM_Disp || !mbPhotoDraw) {
return;
}
}
void InputForm::onPhotoPoint() {
if (getEditMode() != memo::InputForm::EM_Disp || mbPhotoScaledUp || !mbPhotoDraw) {
return;
}
}
void InputForm::onPhotoLeft() {
if (getEditMode() != memo::InputForm::EM_Disp || mbPhotoScaledUp || !mbPhotoDraw) {
return;
}
}
void InputForm::open() {
memo::InputForm::open();
switch (meType) {
case T_MailAddressSel:
searchAnmPane("N_MemoRoot")->changeAnimation(6);
break;
case T_Address:
case T_Picture:
case T_Reply:
default:
searchAnmPane("N_MemoRoot")->changeAnimation(4);
break;
}
}
void InputForm::close() {
memo::InputForm::close();
if (mbCloseWithSend) {
searchAnmPane("N_MemoRoot")->changeAnimation(5);
searchAnmPane("SendPic")->changeAnimation(5);
searchAnmPane("N_SendMes")->changeAnimation(5);
} else {
searchAnmPane("N_MemoRoot")->changeAnimation(7);
searchAnmPane("SendPic")->changeAnimation(7);
}
}
bool InputForm::isWholePaneInAnimation() {
return searchAnmPane("N_MemoRoot")->isInAnimation();
}
void InputForm::resizePhotoPane(f32 width, f32 height) {
nw4r::lyt::Pane* pane = getPane("Pic");
pane->SetSize(nw4r::lyt::Size(412.0f, 309.0f));
nw4r::lyt::Size bounds(pane->GetSize());
nw4r::lyt::Size result(bounds);
if (0.0f == width) {
return;
}
if (0.0f == height) {
return;
}
if (width > height) {
result.height = bounds.width * height / width;
if (result.height > bounds.height) {
result.width = bounds.width * (bounds.height / result.height);
result.height = bounds.height;
}
} else {
result.width = bounds.height * width / height;
if (result.width > bounds.width) {
result.height = bounds.height * (bounds.width / result.width);
result.width = bounds.width;
}
}
pane->SetSize(result);
}
void InputForm::setSendOutMessage(const wchar_t* sendOutMessage) {
nw4r::ut::DynamicCast<nw4r::lyt::TextBox*>(
mpLayout->GetRootPane()->FindPaneByName("T_SendMes", true))->SetString(sendOutMessage);
}
void EventHandler::onTiEvent(gui::PaneComponent* paneComponent, u32 event, Input* input) {
if (!static_cast<InputForm*>(mpMemoForm)->isPhotoScaledUp()) {
memo::EventHandler::onTiEvent(paneComponent, event, input);
}
nw4r::lyt::Pane* pane = paneComponent->getPane();
const char* paneName = pane->GetName();
if (paneName[0] == 'B') {
if (event == gui::GUIComponent::EVENT_TRIG && (input->trigger & 0x800) &&
util::strcmp("B_Pic", paneName)) {
static_cast<InputForm*>(mpMemoForm)->onPhotoTrig();
}
if (event == 0 && util::strcmp("B_Pic", paneName)) {
static_cast<InputForm*>(mpMemoForm)->onPhotoPoint();
}
if (event == 1 && util::strcmp("B_Pic", paneName)) {
static_cast<InputForm*>(mpMemoForm)->onPhotoLeft();
}
}
}
bool InputForm::isPhotoScaledUp() {
return mbPhotoScaledUp;
}
u32 AnmPane::getState() {
return meState;
}
void AnmPane::changeAnimation(u32 id) {
meState = id;
nw4rmanager::AnmPane::changeAnimation(id);
}
AnmPane::KeyType AnmPane::getKeyType() const {
return meKeyType;
}
void AnmPane::init() {
meState = 0;
}
PicPane::~PicPane() {}
void PicPane::onAnmEvent(AnmPaneEvent paneEvent) {}
WholePane::~WholePane() {}
void WholePane::onAnmEvent(AnmPaneEvent paneEvent) {}
InputForm::~InputForm() {}
EventHandler::~EventHandler() {}
}
}
}

View File

@@ -0,0 +1,315 @@
#define TITEXTDRAWER_IMPLEMENTATION
#include "keyboard/tiTextDrawer.h"
#include "keyboard/tiUtil.h"
#include <revolution/gx/GXCull.h>
#include <revolution/gx/GXGet.h>
#include <revolution/gx/GXTransform.h>
#include <revolution/mtx.h>
namespace textinput {
namespace textdrawer {
s32 snWidthTable[0x160];
void Base::create(MEMAllocator*) {
for (s32 index = 0; index < 0x160; ++index) {
snWidthTable[index] = -1;
}
mfVIWidth = 640.0f;
}
void Base::setAspectRatio(bool aspect4x3) {
mbAspect4x3 = aspect4x3;
if (aspect4x3) {
util::getProjectionRect4x3(&mProjectionRect);
} else {
util::getProjectionRect16x9(&mProjectionRect);
}
}
void Base::setDrawString(const wchar_t* wcString, u32 startPos, u32 endPos) {
mpDrawString = wcString;
muDrawStartPos = startPos;
muDrawEndPos = endPos;
}
void Base::modifyCursorCache(s32 line, u32 pos, f32 left, f32 top, f32 right, f32 bottom) {
f32 height = mfDrawScrollY;
mnCachedCursorLine = line;
mCachedCursor.uCursorPos = pos;
mCachedCursor.fCursorX = left;
mCachedCursor.fCursorY = top - height;
mfCachedCursorX = right;
mfCachedCursorY = bottom - height;
mbCursorCache = true;
}
void Base::setDrawModifyScopeLine(s32 startLine, s32 endLine) {
muDrawModifyStartLine = startLine;
muDrawModifyEndLine = endLine;
}
void Base::setDrawCacheScopeLine(s32 startLine, s32 endLine) {
if (startLine < 0) {
startLine = 0;
}
if (muDrawModifyStartPos != startLine) {
dirtyDrawCache();
}
muDrawModifyStartPos = startLine;
muDrawModifyEndPos = endLine;
}
void Base::procCursor(CursorPos* cursorPos, s32) {
GetCursorX();
GetCursorY();
if (!onCursor(cursorPos)) {
cursorPos->fCursorX = GetCursorX();
cursorPos->fCursorY = GetCursorY();
}
}
bool Base::onCursor(CursorPos*) {
return false;
}
void Base::makeUpCursorPos(CursorPos* cursorPos, u32 pos, s32 line, s32) {
const wchar_t* drawString = mpDrawString;
if (drawString != NULL) {
const wchar_t* ch = drawString + pos;
f32 y = GetCursorY();
while (*ch != 0) {
DrawInfo drawInfo;
drawInfo.rect.left = 0.0f;
drawInfo.rect.top = 0.0f;
drawInfo.rect.right = 0.0f;
drawInfo.rect.bottom = 0.0f;
drawInfo.character = *ch;
calcRect(drawInfo);
doBeforeDrawProcess(drawString, pos, drawInfo);
if (cursorPos != NULL && cursorPos->uCursorPos == pos) {
procCursor(cursorPos, line + (y == GetCursorY() ? 0 : 1));
}
if (*ch == L'\n') {
doLineFeed();
break;
}
MoveCursorX((drawInfo.rect.right - drawInfo.rect.left) * getScale().x);
doAfterDrawProcess(drawString, pos, drawInfo);
if (y != GetCursorY()) {
line++;
}
y = GetCursorY();
++ch;
++pos;
}
if (cursorPos != NULL && *ch == 0 && cursorPos->uCursorPos == pos) {
procCursor(cursorPos, line);
}
}
}
void Base::doBeforeDrawProcess(const wchar_t*, u32, const DrawInfo&) {}
void Base::doLineFeed() {
++muLine;
}
void Base::doAfterDrawProcess(const wchar_t*, u32, const DrawInfo&) {}
void Base::put(wchar_t wc) {
if (!mbSecretMode) {
Print(wc);
} else {
Print(L'*');
}
}
void Base::draw(CursorPos* cursorPos) {
u32 startPos;
const wchar_t* drawString = mpDrawString;
u32 endPos;
if (GetFont() != NULL) {
startPos = muDrawStartPos;
endPos = muDrawEndPos;
muCachedStartPos = startPos;
muDrawCacheStartPos = startPos;
preDraw(startPos);
drawString += startPos;
SetFontSize(mfFontWidth * getScale().x,
mfFontHeight * getScale().y);
SetupGX();
while (*drawString != 0 && muDrawCacheStartPos < endPos) {
DrawInfo drawInfo;
drawInfo.rect.left = 0.0f;
drawInfo.rect.top = 0.0f;
drawInfo.rect.right = 0.0f;
drawInfo.rect.bottom = 0.0f;
drawInfo.character = *drawString;
calcRect(drawInfo);
doBeforeDrawProcess(mpDrawString,
muDrawCacheStartPos,
drawInfo);
if (cursorPos != NULL && cursorPos->uCursorPos == muDrawCacheStartPos) {
procCursor(cursorPos, 0);
}
if (*drawString == L'\n') {
nw4r::ut::Color color = GetTextColor();
SetTextColor(nw4r::ut::Color(200, 200, 200, color.a));
Print(0xe056);
SetTextColor(color);
doLineFeed();
} else if (*drawString != static_cast<wchar_t>(-1)) {
put(*drawString);
MoveCursorX(mfCharacterSpacing * getScale().x);
}
doAfterDrawProcess(mpDrawString,
muDrawCacheStartPos,
drawInfo);
++drawString;
++muDrawCacheStartPos;
}
if (cursorPos != NULL && cursorPos->uCursorPos == muDrawCacheStartPos) {
procCursor(cursorPos, 0);
}
finishDraw(muDrawCacheStartPos);
}
}
void Base::preDraw(u32) {}
void Base::finishDraw(u32) {}
f32 Base::getLineHeight() {
if (getScale().y == 0.0f) {
return 1.0f;
}
f32 height = getScale().y * (mfFontHeight +
mfLineSpacing);
return height >= 1.0f ? height : 1.0f;
}
void Base::setFont(const nw4r::ut::Font& font) {
nw4r::ut::CharWriter::SetFont(font);
for (s32 index = 0; index < 0x160; ++index) {
snWidthTable[index] = -1;
}
u32 ch = 0x20;
do {
DrawInfo drawInfo;
drawInfo.rect.left = 0.0f;
drawInfo.rect.top = 0.0f;
drawInfo.rect.right = 0.0f;
drawInfo.rect.bottom = 0.0f;
drawInfo.character = static_cast<wchar_t>(ch);
calcRect(drawInfo);
u16 index = static_cast<u16>(ch);
snWidthTable[index - 0x20] = static_cast<s32>(drawInfo.rect.right - drawInfo.rect.left);
ch++;
} while (ch <= 0x17f);
}
void Base::calcRect(DrawInfo& drawInfo) {
drawInfo.rect.left = 0.0f;
u16 ch = drawInfo.character;
drawInfo.rect.right = 0.0f;
drawInfo.rect.top = 0.0f;
drawInfo.rect.bottom = getLineHeight();
f32 width = 0.0f;
width += mfCharacterSpacing;
if (IsWidthFixed()) {
width += GetFixedWidth();
} else {
f32 height = getScale().x;
if (height == 0.0f) {
height = 0.0001f;
}
f32 scale = GetScaleH();
const nw4r::ut::Font* font = GetFont();
s32 charWidth = font->GetCharWidth(ch);
f32 widthOffset = static_cast<f32>(charWidth) * scale / height;
width += widthOffset;
}
drawInfo.rect.right = drawInfo.rect.right < width ? width : drawInfo.rect.right;
}
f32 Base::getWidth(const wchar_t* sz) {
f32 width = 0.0f;
DrawInfo drawInfo;
drawInfo.rect.left = 0.0f;
drawInfo.rect.top = 0.0f;
drawInfo.rect.right = 0.0f;
drawInfo.rect.bottom = 0.0f;
u16 ch;
goto check;
body:
drawInfo.character = ch;
calcRect(drawInfo);
width += drawInfo.rect.right - drawInfo.rect.left;
++sz;
check:
ch = *sz;
if (ch != 0) {
goto body;
}
return width;
}
void Base::beginDraw(const nw4r::ut::Rect& rect) {
Mtx44 projection;
Mtx matrix;
f32 viewport[6];
muDrawCacheStartPos = 0;
GXGetViewportv(&mSavedViewport.xOrig);
GXGetProjectionv(mSavedProjection);
C_MTXOrtho(projection, 0.0f, rect.top - rect.bottom, -50.0f, 50.0f + (rect.right - rect.left), -1.0f, 1.0f);
GXSetProjection(projection, GX_ORTHOGRAPHIC);
f32 width = mProjectionRect.right -
mProjectionRect.left;
f32 scale = mfVIWidth / width;
f32 halfWidth = width;
halfWidth *= 0.5f;
f32 left = (rect.left + halfWidth) - 50.0f;
f32 xOffset = left;
xOffset *= scale - 1.0f;
viewport[0] = left + xOffset;
f32 height = (mProjectionRect.bottom -
mProjectionRect.top) * 0.5f;
viewport[1] = rect.bottom + height;
viewport[2] = scale * (100.0f + (rect.right - rect.left));
viewport[3] = rect.top - rect.bottom;
viewport[4] = mSavedViewport.nearZ;
viewport[5] = mSavedViewport.farZ;
GXSetViewport(viewport[0], viewport[1], viewport[2], viewport[3], viewport[4], viewport[5]);
u32 x = static_cast<u32>(viewport[0]);
u32 y = static_cast<u32>(viewport[1]);
u32 viewportWidth = static_cast<u32>(viewport[2]);
if (viewportWidth >= 0x5dc) {
viewportWidth = 0x5dc;
}
u32 viewportHeight = static_cast<u32>(viewport[3]);
if (viewportHeight >= 0x5dc) {
viewportHeight = 0x5dc;
}
GXSetScissor(x, y, viewportWidth, viewportHeight);
PSMTXIdentity(matrix);
GXLoadPosMtxImm(matrix, 0);
mfMinScrollY = GetCursorY();
muLine = 0;
}
void Base::endDraw() {
f32* viewport = &mSavedViewport.xOrig;
GXSetViewport(viewport[0], viewport[1], viewport[2], viewport[3], viewport[4], viewport[5]);
GXSetScissor(static_cast<u32>(viewport[0]), static_cast<u32>(viewport[1]),
static_cast<u32>(viewport[2]), static_cast<u32>(viewport[3]));
mfModifyStartY = GetCursorX();
mfMinScrollY =
(mfMinScrollY - GetCursorY()) + getLineHeight();
}
void Base::drawCursor(f32, f32) {}
void Base::draw() {}
}
}

View File

@@ -0,0 +1,11 @@
# MyTiLetterForm attempts
- Initial reconstruction: 24/26 exact; create had three constructor-store ordering differences, drawBody four literal-offset differences. No source existed at the configured path.
- Pool: the fourth animation group is in the neighboring extracted tiHwKeyboard .rodata range, starting four bytes after 0x81616B88. Its real N_SendMes entry has one animation, animationFiles[5]. Reconstructing all four ordinary groups and correcting drawBody's conditional T_TouchLetter and unconditional N_SendMes references made the 13-string pool identical and drawBody exact.
- create attempt 1: two direct EventHandler members produced three reordered stores (179/179 instructions).
- create attempt 2: memo EventHandler base with the second pointer in letter EventHandler reduced the difference to two stores.
- create attempt 3: both pointers initialized by the memo constructor before the letter vtable store produced zero differences. Restoring the actual inputform EventHandler -> memo EventHandler -> letter EventHandler hierarchy preserves zero differences.
- Vtables: typed shared declarations behind MYTILETTERFORM_IMPLEMENTATION corrected create, scrolling, sound, cursor-cache signatures. Ordering class declarations EventHandler, AnmPane, WholePane, PicPane reproduced the four owned vtable positions without forced data.
- All 26 functions are instruction exact. The owned .data bytes are identical after clearing relocations; the only differing relocation is the malformed concatenated isEnableCursorCache/getStartPos name in the target, plus four relocations in the ordinary weak gui EventHandler vtable, which is zero-filled in the extracted original.
- .rodata is 784 bytes versus extracted 720; all 720 prefix bytes and normalized relocations agree. The remaining 64 bytes are the final null of group three and all of group four, visibly misassigned to tiHwKeyboard in splits.txt. No split, symbol or neighboring source changes were made.
- .sdata is 66 bytes versus extracted 72; every prefix byte agrees. The six trailing target zeros were not recreated with padding. .sdata2 is 32/32 identical. Pool is identical.

View File

@@ -0,0 +1,11 @@
# tiTextDrawer attempts
No source existed. Reconstructed all 24 functions using tiTextDrawer.h and tiUtil.h, with a private implementation macro preserving every existing guard branch. Replaced raw scratch offsets with viewport/projection/string/cache fields and typed DrawInfo members. Ordinary table initialization loops reproduce the compiler's 32-store unrolling. Pools are empty and identical.
## beginDraw
1. Direct scale * viewport width expression: 109/109 instructions, one difference at instruction 59, fmuls f7,f11,f7 versus fmuls f7,f7,f11.
2. Reverse multiplication operands: unchanged single difference; compiler canonicalizes this expression.
3. Separate scaledWidth temporary with compound multiplication: 109/109, sixteen floating scheduling/register differences. Discarded; retained attempt 1.
## data
BSS is 1408/1408. The .sdata2 constants have identical order and bytes for all 44 emitted bytes. The extracted object has four additional zero bytes at its section end; no padding object was added. The vtable has one relocation-name discrepancy: the target references isEnableCursorCache__Q39textinput10textdrawer4BaseCFvgetStartPos__Q39textinput10textdrawer4BaseCFv, a concatenated symbol name present in symbols.txt, whereas normal C++ references isEnableCursorCache__Q39textinput10textdrawer4BaseCFv. Kept ordinary declarations rather than renaming a real function or introducing a fabricated alias. Other data bytes and vtable entries match.