Compare commits

..

1 Commits

Author SHA1 Message Date
coah
f262dbc485 NWC24MBoxCtrl: 20/25 functions (worker 1f47cc11) 2026-09-30 01:35:14 +00:00
38 changed files with 455 additions and 5645 deletions

View File

@@ -53,9 +53,9 @@ Progress
<!-- progress:start -->
| Decompiled | Matched | Linked | Data |
|:---:|:---:|:---:|:---:|
| 84.89% | 75.24% | 56.76% | 86.70% |
| 83.34% | 73.81% | 56.76% | 86.40% |
units 748/1027 complete, functions 10976/12563 matched.
units 748/1027 complete, functions 10754/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

@@ -77,9 +77,6 @@ namespace textinput {
class Base : public CommandSender {
public:
#ifdef TIMANAGER_IMPLEMENTATION
Base(Manager* manager) : mpCandidates(NULL), mpAllocator(NULL), mbOn(false), mbInvalid(true), meLanguage(USA), mpManager(manager) {}
#endif
virtual ~Base();
virtual void create(MEMAllocator* allocator) override;
virtual void init() override {}
@@ -114,9 +111,6 @@ namespace textinput {
class EventHandler : public nw4rmanager::TiEventHandler {
public:
#ifdef TIMANAGER_IMPLEMENTATION
EventHandler(LayoutByNW4R* layout) : mpLayoutByNW4R(layout) {}
#endif
virtual void onTiEvent(gui::PaneComponent* paneComponent, u32 event, Input* input) override; // 0x18
LayoutByNW4R* mpLayoutByNW4R; // 0xC
@@ -290,13 +284,6 @@ namespace textinput {
// TODO
class LayoutByNW4R : public Base, public nw4rmanager::Layout, public UIObj::Listener {
public:
#ifdef TIMANAGER_IMPLEMENTATION
LayoutByNW4R(Manager* manager, nw4r::lyt::MultiArcResourceAccessor* accessor, EventObserver* observer, const char* layoutName)
: Base(manager), nw4rmanager::Layout(accessor, layoutName, observer), mEventHandler(this), mpTiString(NULL),
mTextArea(0, this, this), mLeftScroll(1, this, this), mRightScroll(2, this, this), mOnOffButton(3, this, this),
mTextWindow(4, this, this), mbActive(true) {}
const UIOnOffButton& getOnOffButton() const { return mOnOffButton; }
#endif
virtual ~LayoutByNW4R();
virtual void create(MEMAllocator* allocator) override;
virtual void init() override;

View File

@@ -2,20 +2,20 @@
#define TEXTINPUT_CELL_PHONE_H
#include "tiNw4rManager.h"
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION)
#include "tiKeyboard.h"
#endif
namespace textinput {
namespace keyboard {
namespace cellphonetype {
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION)
class Base : public textinput::keyboard::KeyboardBase {
#else
class Base {
#endif
public:
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION)
enum InputMode {
IM_00,
IM_01,
@@ -29,12 +29,7 @@ namespace textinput {
virtual void init() override;
virtual void updateFromReceiver(u32, void*) override;
virtual void onKey(u32, void*) override;
#ifdef TIMANAGER_IMPLEMENTATION
Base(Manager* manager) : mpManager(manager) {}
virtual int getType() override;
#else
virtual void getType() override;
#endif
virtual void onActive() override;
virtual void calc();
virtual void draw();
@@ -79,7 +74,7 @@ namespace textinput {
virtual void vt_0x4C();
virtual void vt_0x50();
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION)
virtual void doNumericMode(bool);
#else
virtual void vt_0x54();
@@ -95,11 +90,11 @@ namespace textinput {
// TODO enum?
int getInputType() const;
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
#ifdef TIINPUTFORM_IMPLEMENTATION
void resetHoldingButton();
#endif
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION)
private:
u32 mPreviousInputMode;
u32 mCurrentInputMode;
@@ -112,47 +107,17 @@ namespace textinput {
u32 mHoldingButton;
void* mpInputModeTable;
MEMAllocator* mpAllocator;
#ifdef TIMANAGER_IMPLEMENTATION
Manager* mpManager;
#else
void* mpInputSettings;
#endif
u32 mInputState;
#endif
};
class LayoutByNW4R : public Base, public nw4rmanager::Layout {
public:
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
#ifdef TIMANAGER_IMPLEMENTATION
LayoutByNW4R(Manager* manager, nw4r::lyt::MultiArcResourceAccessor* accessor, EventObserver* observer, const char* layoutName)
: Base(manager), nw4rmanager::Layout(accessor, layoutName, observer), mpEventHandler(NULL) {}
virtual ~LayoutByNW4R();
virtual void create(MEMAllocator* allocator);
virtual void init();
virtual void setCommandReceiver(CommandReceiver* receiver);
virtual void updateFromReceiver(u32 command, void* data);
virtual void onKey(u32 event, void* data);
virtual void setLanguage(Language language);
virtual void update();
virtual void onActive();
virtual void calc();
virtual void draw();
virtual void changeInputMode(InputMode mode);
virtual void setInputMode(InputMode mode);
virtual void setUpperCaseJP(bool upper);
virtual void setLangKeyActive(bool active);
virtual void goSignInputMode();
virtual void changePredictLanguage();
virtual void setAbcMode(bool abc);
virtual void doNumericMode(bool);
virtual void setPredictLanguageDialog(predictlang::LayoutByNW4R* dialog);
virtual void setSignWindow(signwindow::LayoutByNW4R* window);
#else
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION)
virtual void doNumericMode(bool);
virtual void setPredictLanguageDialog(void*);
virtual void setSignWindow(void*);
#endif
virtual void doNumericWithDotMode(bool);
virtual void setLineFeedButton(bool);
virtual void setPredictLanguageButton(bool);
@@ -162,31 +127,15 @@ namespace textinput {
void onPressedShift(bool shift);
void onReleasedShift();
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
#ifdef TIINPUTFORM_IMPLEMENTATION
bool hasLineFeedButton() const { return mbLineFeedButton; }
private:
bool mbLineFeedButton;
#ifdef TIMANAGER_IMPLEMENTATION
GXTexObj mSpaceTexture;
GXTexObj mSpaceTextureCN;
GXTexObj mSpaceTextureKR;
nw4rmanager::TiEventHandler* mpEventHandler;
predictlang::LayoutByNW4R* mpPredictDialog;
signwindow::LayoutByNW4R* mpSignWindow;
#endif
public:
#endif
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION)
virtual bool updateInput(int chan, f32 x, f32 y, u32 trig, u32 hold, u32 release, void* data) override;
virtual bool updateInput(input::HKBManager& hkbManager) override;
#endif
#ifdef TIMANAGER_IMPLEMENTATION
virtual nw4rmanager::AnmPane* getAnmPane(InputMode mode);
virtual void throwReleaseForAll();
virtual void changeAnimationAllToNormal();
virtual void updatePredictLanguage(CommandReceiver::ChangePredictMode* mode);
virtual void changeKeyTop(const struct PaneNameToCharCode* table);
virtual void changeSpaceKeyTop(const struct PaneNameToCharCode* table);
#endif
};

View File

@@ -11,9 +11,6 @@ namespace textinput {
namespace input {
class HKBManager {
public:
#ifdef TIMANAGER_IMPLEMENTATION
void ClearState();
#endif
static HKBManager& getInstance() { return sInstance; }
void Initialize();
@@ -22,7 +19,7 @@ namespace textinput {
u32 GetModifierState() const;
void SetModifierState(u32, u32);
#if defined(TI_PC_KEYBOARD_IMPLEMENTATION) || defined(TISIGNWINDOW_IMPLEMENTATION)
#ifdef TI_PC_KEYBOARD_IMPLEMENTATION
class KeySet {
public:
u8 GetKey() const;

View File

@@ -8,28 +8,17 @@ namespace textinput {
class Manager;
namespace keyboard {
namespace hwkey {
#ifdef TIMANAGER_IMPLEMENTATION
class HWKeyboard : public CommandSender {
#else
class HWKeyboard : CommandSender {
#endif
public:
HWKeyboard(Manager *);
#ifdef TIMANAGER_IMPLEMENTATION
inline ~HWKeyboard();
#else
~HWKeyboard();
#endif
#ifdef TIMANAGER_IMPLEMENTATION
void setLanguage(Destination destination, Language language);
#endif
virtual void init();
#ifdef TI_PC_KEYBOARD_IMPLEMENTATION
wchar_t convertWCCode(wchar_t code) const;
#endif
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
#ifdef MYTIMANAGER_IMPLEMENTATION
void updateInput(int chan, f32 x, f32 y, u32 trig, u32 hold, u32 release, void* data);
#else
virtual void updateInput(int chan, f32 x, f32 y, u32 trig, u32 hold, u32 release, void* data);

View File

@@ -13,7 +13,7 @@
#include "tiZiString.h"
#include "tiSEId.h"
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
#ifdef TIINPUTFORM_IMPLEMENTATION
extern "C" wchar_t KPRGetChar(KPRQueue* queue);
extern "C" void KPRPutChar(KPRQueue* queue, wchar_t character);
extern "C" void KPRClearQueue(KPRQueue* queue);
@@ -22,30 +22,22 @@ extern "C" u8 KPRLookAhead(KPRQueue* queue, wchar_t* character, wchar_t* combini
#endif
namespace textinput {
#ifdef TIMANAGER_IMPLEMENTATION
class Manager;
#endif
namespace inputform {
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
#ifdef TIINPUTFORM_IMPLEMENTATION
class Base;
class EventHandler;
class LayoutByNW4R;
#endif
class EditBuffer {
#ifdef TIMANAGER_IMPLEMENTATION
friend class textinput::Manager;
public:
EditBuffer() : mpString(NULL), mpUnfixString(NULL), mpZiString(NULL), mpAllocator(NULL) {}
#endif
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
#ifdef TIINPUTFORM_IMPLEMENTATION
friend class LayoutByNW4R;
friend class Base;
#endif
public:
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION)
void create(MEMAllocator* allocator);
#endif
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
#ifdef TIINPUTFORM_IMPLEMENTATION
virtual ~EditBuffer();
#else
~EditBuffer();
@@ -59,7 +51,7 @@ namespace textinput {
};
class DeadKeyStream {
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
#if defined(TIINPUTFORM_IMPLEMENTATION)
public:
DeadKeyStream() { KPRInitRegionUS(); init(); }
static wchar_t ToCombineClass(Language language, wchar_t code);
@@ -71,9 +63,6 @@ namespace textinput {
bool isEmpty() const { return mKPRQueue.oCount == 0; }
void clear() { KPRClearQueue(&mKPRQueue); }
private:
#ifdef TIMANAGER_IMPLEMENTATION
friend class textinput::Manager;
#endif
static bool sbCompatibleFilterEnabled;
static inline bool isCompatible(wchar_t character);
#elif defined(TI_PC_KEYBOARD_IMPLEMENTATION)
@@ -128,7 +117,7 @@ namespace textinput {
// TODO - location
class RowInfoManager {
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
#ifdef TIINPUTFORM_IMPLEMENTATION
friend class LayoutByNW4R;
friend class Base;
public:
@@ -142,11 +131,8 @@ namespace textinput {
MEMAllocator* mpAllocator; // 0x08
};
#ifdef TISIGNWINDOW_IMPLEMENTATION
bool isAtokActive() const;
#endif
virtual ~Base();
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
#ifdef TIINPUTFORM_IMPLEMENTATION
Base(Manager* manager);
virtual void create(MEMAllocator* allocator);
virtual void init();
@@ -284,9 +270,9 @@ 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)
protected:
#if !defined(TIINPUTFORM_IMPLEMENTATION) && !defined(TIMANAGER_IMPLEMENTATION)
#ifndef TIINPUTFORM_IMPLEMENTATION
void setCursorPos(tistring::Decolated* string, u32 pos);
void calcCursorTimer();
#endif
@@ -294,7 +280,7 @@ namespace textinput {
#else
private:
#endif
#if defined(MYTIINPUTFORM_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
#if defined(MYTIINPUTFORM_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION)
nw4r::ut::Rect mRect;
#else
Rect mRect;
@@ -306,9 +292,6 @@ namespace textinput {
tistring::WithZi* mpZiString; // 0x16C
InputMode meInputMode; // 0x170
PredictMode mePredictMode; // 0x174
#ifdef TIMANAGER_IMPLEMENTATION
friend class textinput::Manager;
#endif
bool mbPredictOn; // 0x178
bool mbDoWordWrap; // 0x179
bool mbRightWithSpace; // 0x17A
@@ -344,12 +327,12 @@ namespace textinput {
};
class LayoutByNW4R : public Base, public nw4rmanager::Layout {
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
#ifdef TIINPUTFORM_IMPLEMENTATION
friend class EventHandler;
inline const nw4r::lyt::Pane* getLanguageTextPane() const;
#endif
public:
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION)
LayoutByNW4R(textinput::Manager*, nw4r::lyt::MultiArcResourceAccessor*, const char*, EventObserver*, const char*);
#endif
~LayoutByNW4R();
@@ -366,7 +349,7 @@ namespace textinput {
virtual nw4r::math::VEC2 getScale() const;
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
#ifdef TIINPUTFORM_IMPLEMENTATION
void updateRepeatInput(u32 trig, u32 hold);
#endif
virtual void updateInputCommon(int chan, u32 trig, u32 hold, u32 release, void* data);
@@ -379,13 +362,13 @@ namespace textinput {
virtual void setRootPaneScaleFor16x9();
virtual void setRootPaneScaleFor4x3();
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
#ifdef TIINPUTFORM_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)
protected:
const void* mpLayoutData;
const void* mpLanguageData;

View File

@@ -8,36 +8,27 @@ namespace textinput {
class KeyboardBase : public CommandSender {
public:
#ifdef TIMANAGER_IMPLEMENTATION
KeyboardBase() : meLanguage(JP) {}
#endif
virtual ~KeyboardBase() {}
#if !defined(TI_PC_KEYBOARD_IMPLEMENTATION) && !defined(TIMANAGER_IMPLEMENTATION) && !defined(TISIGNWINDOW_IMPLEMENTATION)
#ifndef TI_PC_KEYBOARD_IMPLEMENTATION
virtual void create(MEMAllocator* alloc) override;
virtual void init() override;
virtual void setCommandReceiver(CommandReceiver* receiver) override;
virtual void sendCommand(u32 command, void*) override;
#endif
#if !defined(TIMANAGER_IMPLEMENTATION) && !defined(TISIGNWINDOW_IMPLEMENTATION)
virtual void updateFromReceiver(u32, void*) override;
#endif
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TI_PC_KEYBOARD_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION) || defined(TISIGNWINDOW_IMPLEMENTATION)
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TI_PC_KEYBOARD_IMPLEMENTATION)
virtual void onKey(u32, void*);
#else
virtual void onKey(u32);
#endif
#if defined(TI_PC_KEYBOARD_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION) || defined(TISIGNWINDOW_IMPLEMENTATION)
#ifdef TI_PC_KEYBOARD_IMPLEMENTATION
virtual int getType();
#else
virtual void getType();
#endif
virtual void setLanguage(Language language);
#if defined(TI_PC_KEYBOARD_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION) || defined(TISIGNWINDOW_IMPLEMENTATION)
#ifdef TISIGNWINDOW_IMPLEMENTATION
virtual Language getLanguage() const;
#else
#ifdef TI_PC_KEYBOARD_IMPLEMENTATION
virtual Language getLanguage() const { return meLanguage; }
#endif
virtual void update() {}
#else
virtual Language getLanguage() const;

View File

@@ -28,20 +28,11 @@ namespace textinput {
virtual void onEvent(nw4r::lyt::Pane* pane, u32 event) {} // 0x10
virtual void onSE(sound::SE seId) {}
#ifdef TIMANAGER_IMPLEMENTATION
virtual void onOK();
virtual void onCancel();
virtual void onOutOfLength();
#else
virtual void onOK() { printf("OK!\n"); }
virtual void onCancel() { printf("Cancel!\n"); }
virtual void onOutOfLength() { printf("OutOfLength\n"); }
#endif
};
#ifdef TIMANAGER_IMPLEMENTATION
namespace predictlang { class LayoutByNW4R; }
#endif
class Manager : public Base {
public:
Manager(MEMAllocator* allocator, nw4r::lyt::MultiArcResourceAccessor* multiArc, textinput::EventObserver* event);
@@ -103,19 +94,14 @@ namespace textinput {
#endif
virtual void setSecretInputMode(bool secretInputMode) { mpInputForm->setSecretModeOn(secretInputMode); }
#if defined(IPL_ADDRESS_EDIT_CPP) || defined(TIMANAGER_IMPLEMENTATION)
#ifdef IPL_ADDRESS_EDIT_CPP
void enableKSXFilter(bool compatibleFilter);
#endif
virtual void setDefaultPredictionJP(int num, const char** predicts);
virtual void setFixedPredictionJP(int num, const char** predicts);
#ifdef TIMANAGER_IMPLEMENTATION
virtual void setTitleText(wchar_t* titleText);
void initAspect();
#else
virtual void setTitleText(const wchar_t* titleText);
#endif
virtual void start() {}
virtual void end() {}
@@ -160,7 +146,7 @@ namespace textinput {
void enableCompatibleFilter(bool compatibleFilter);
bool isVacancy() const;
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
#ifdef TIINPUTFORM_IMPLEMENTATION
bool isPredictTurning() const;
void startPredictTurnOn(bool enabled);
#endif
@@ -177,14 +163,9 @@ namespace textinput {
InputForm* mpInputForm; // 0x1C
candidatebox::LayoutByNW4R* mpCandidateBox; // 0x20
toolbar::LayoutByNW4R* mpToolBar; // 0x24
#ifdef TIMANAGER_IMPLEMENTATION
predictlang::LayoutByNW4R* mpPredictLanguageDialog;
keyboard::signwindow::LayoutByNW4R* mpSignWindow;
#else
void* mpPredictLanguageDialog; // 0x28
void* mpSignWindow; // 0x2C
#endif
EventObserver* mpEventObserver; // 0x30
Destination meDestination; // 0x34

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)
#ifdef TIINPUTFORM_IMPLEMENTATION
u32 controller;
f32 x;
f32 y;

View File

@@ -1,7 +1,7 @@
#ifndef TEXTINPUT_PC_KEYBOARD_H
#define TEXTINPUT_PC_KEYBOARD_H
#if defined(TI_PC_KEYBOARD_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION) || defined(TISIGNWINDOW_IMPLEMENTATION)
#ifdef TI_PC_KEYBOARD_IMPLEMENTATION
#include "tiPcKeyboardImpl.h"
#else

View File

@@ -17,62 +17,6 @@ namespace textinput {
}
namespace keyboard {
namespace signwindow {
#ifndef TISIGNWINDOW_IMPLEMENTATION
#ifdef TIMANAGER_IMPLEMENTATION
struct LanguageDependencyData;
class Base : public KeyboardBase {
public:
Base(Manager* manager) : mpAllocator(NULL), mpManager(manager) {}
virtual ~Base();
virtual void create(MEMAllocator* allocator);
virtual void init();
virtual int getType();
virtual void setLanguage(Language language);
virtual bool isLocked();
virtual void setPage(u8 page);
virtual u8 getPage();
virtual void movePrevSignPage();
virtual void moveNextSignPage();
virtual void close();
private:
u32 mInputState;
const LanguageDependencyData* mpLanguageData;
MEMAllocator* mpAllocator;
Manager* mpManager;
};
class EventHandler;
class LayoutByNW4R : public Base, public nw4rmanager::Layout, public nw4rmanager::AnmObserver {
public:
LayoutByNW4R(Manager* manager, nw4r::lyt::MultiArcResourceAccessor* accessor, EventObserver* observer, const char* layoutName)
: Base(manager), nw4rmanager::Layout(accessor, layoutName, observer), mbActive(false), mbInput(false), mpEventHandler(NULL), mpCaller(NULL) {}
virtual ~LayoutByNW4R();
virtual void create(MEMAllocator* allocator);
virtual void init();
virtual void onKey(u32 event, void* data);
virtual void movePrevSignPage();
virtual void moveNextSignPage();
virtual void close();
virtual void draw();
virtual void open(KeyboardBase* keyboard, bool repeat);
virtual bool isActive();
virtual void onChangeAnmState(AnmEvent event, nw4rmanager::AnmPane* pane, nw4rmanager::Anim* animation);
virtual bool updateInput(int chan, f32 x, f32 y, u32 trig, u32 hold, u32 release, void* data);
virtual bool updateInput(input::HKBManager& hkb);
virtual void throwReleaseForAll();
virtual void resetAnmSignWindow();
virtual void setSignKeyTop(u16 first, u16 count);
virtual void setPageNumber(u16 page);
virtual void endToClose();
virtual void startToInput();
virtual void movePrevSignWindow();
virtual void moveNextSignWindow();
private:
bool mbActive;
bool mbInput;
EventHandler* mpEventHandler;
KeyboardBase* mpCaller;
};
#else
class Base : public KeyboardBase {
public:
virtual bool isLocked();
@@ -88,10 +32,7 @@ namespace textinput {
virtual void open(KeyboardBase* keyboard, bool repeat);
virtual bool isActive();
};
#endif
#endif
}
namespace pctype {
struct GridKey {
@@ -176,19 +117,6 @@ namespace textinput {
const LanguageData* data;
Base* owner;
};
#ifdef TIMANAGER_IMPLEMENTATION
Base(Manager* manager) {
mKeyState.abcFlags = 0;
mKeyState.inputType = 0;
mKeyState.aiuFlags = 0;
mKeyState.language = USA;
mKeyState.data = NULL;
mKeyState.owner = this;
mpAllocator = NULL;
mbOnlyQwerty = false;
mpManager = manager;
}
#endif
virtual ~Base();
virtual void create(MEMAllocator* allocator);
virtual inline void init();
@@ -291,11 +219,6 @@ namespace textinput {
};
class LayoutByNW4R : public Base, public nw4rmanager::Layout, public UIObj::Listener {
public:
#ifdef TIMANAGER_IMPLEMENTATION
LayoutByNW4R(Manager* manager, nw4r::lyt::MultiArcResourceAccessor* accessor, EventObserver* observer, const char* layoutName)
: Base(manager), nw4rmanager::Layout(accessor, layoutName, observer), mpKeyboardEventHandler(NULL),
mShiftButton(1, this, this), mCapsButton(0, this, this), mModePanel(2, this, this) {}
#endif
virtual ~LayoutByNW4R();
virtual void create(MEMAllocator* allocator);
virtual void init();

View File

@@ -14,17 +14,11 @@ namespace textinput {
class Base : public CommandSender {
public:
#if defined(TI_PREDICTLANG_SAMPLE_CLASS) || defined(TIMANAGER_IMPLEMENTATION)
#ifdef TI_PREDICTLANG_SAMPLE_CLASS
Base(Manager* manager) : mePredictMode(inputform::Base::PM_USEn), mpAllocator(NULL), mpManager(manager) {}
#endif
#ifdef TIMANAGER_IMPLEMENTATION
virtual ~Base();
virtual void init();
virtual void create(MEMAllocator* allocator) override;
#else
virtual void create(MEMAllocator* allocator) override { mpAllocator = allocator; }
#endif
virtual void setPredictMode(inputform::Base::PredictMode mode) { mePredictMode = mode; }
protected:
@@ -38,11 +32,7 @@ namespace textinput {
class LayoutByNW4R : public Base, public nw4rmanager::Layout, public nw4rmanager::AnmObserver {
public:
#ifdef TIMANAGER_IMPLEMENTATION
LayoutByNW4R(Manager* manager, nw4r::lyt::MultiArcResourceAccessor* resAccessor, EventObserver* observer, const char* layoutName)
: Base(manager), nw4rmanager::Layout(resAccessor, layoutName, observer), mbActive(false), mbInput(false),
mpEventHandler(NULL), meDestination(DST_US), mpCaller(NULL) {}
#elif defined(TI_PREDICTLANG_SAMPLE_CLASS)
#ifdef TI_PREDICTLANG_SAMPLE_CLASS
LayoutByNW4R(Manager* manager, nw4r::lyt::MultiArcResourceAccessor* resAccessor, EventObserver* observer)
: Base(manager), nw4rmanager::Layout(resAccessor, "fs_prdicSelWidw_a.brlyt", observer), mbActive(false), mbInput(false),
mpEventHandler(NULL), meDestination(DST_US), mpCaller(NULL) {}
@@ -78,21 +68,12 @@ namespace textinput {
keyboard::KeyboardBase* mpCaller; // 0xD4
};
#if defined(TI_PREDICTLANG_SAMPLE_CLASS) || defined(TIMANAGER_IMPLEMENTATION)
#ifdef TI_PREDICTLANG_SAMPLE_CLASS
class Sample : public LayoutByNW4R {
public:
#ifdef TIMANAGER_IMPLEMENTATION
Sample(Manager* manager, nw4r::lyt::MultiArcResourceAccessor* resAccessor, EventObserver* observer, const char* layoutName)
: LayoutByNW4R(manager, resAccessor, observer, layoutName) {}
#else
Sample(Manager* manager, nw4r::lyt::MultiArcResourceAccessor* resAccessor, EventObserver* observer)
: LayoutByNW4R(manager, resAccessor, observer) {}
#endif
#ifdef TIMANAGER_IMPLEMENTATION
virtual ~Sample();
#else
virtual ~Sample() {}
#endif
};
#endif

View File

@@ -1,134 +0,0 @@
#ifndef TEXTINPUT_SIGN_WINDOW_H
#define TEXTINPUT_SIGN_WINDOW_H
#include "tiKeyboard.h"
#include "tiNw4rManager.h"
#include "tiSwData.h"
namespace textinput {
class Manager;
namespace keyboard {
namespace signwindow {
struct LanguageDependency {
u8 count;
const PaneNameToCharCodeInSignMode* keys;
};
class Base : public KeyboardBase {
public:
virtual ~Base();
virtual void create(MEMAllocator*) override;
virtual void init() override;
virtual void onKey(u32, void*) override;
virtual bool isLocked();
virtual void setPage(u8);
virtual u8 getPage();
virtual void movePrevSignPage();
virtual void moveNextSignPage();
virtual void close();
virtual int getType() override;
virtual void setLanguage(Language) override;
protected:
u8 mInputFlags;
bool mbLocked;
bool mbRepeat;
u8 muPage;
const LanguageDependency* mpLanguageDependency;
MEMAllocator* mpAllocator;
Manager* mpManager;
};
class EventHandler;
class LayoutByNW4R : public Base, public nw4rmanager::Layout, public nw4rmanager::AnmObserver {
public:
virtual ~LayoutByNW4R();
virtual void create(MEMAllocator*) override;
virtual void init() override;
virtual void onKey(u32, void*) override;
virtual void movePrevSignPage() override;
virtual void moveNextSignPage() override;
virtual void close() override;
virtual void draw() override;
virtual void open(KeyboardBase*, bool);
virtual bool isActive();
virtual void onChangeAnmState(AnmEvent, nw4rmanager::AnmPane*, nw4rmanager::Anim*) override;
virtual bool updateInput(int, f32, f32, u32, u32, u32, void*) override;
virtual bool updateInput(input::HKBManager&) override;
virtual void throwReleaseForAll();
virtual void resetAnmSignWindow();
virtual void setSignKeyTop(u16, u16);
virtual void setPageNumber(u16);
virtual void endToClose();
virtual void startToInput();
virtual void movePrevSignWindow();
virtual void moveNextSignWindow();
bool mbActive;
bool mbInput;
EventHandler* mpEventHandler;
KeyboardBase* mpKeyboard;
};
class Sample : public LayoutByNW4R {
public:
virtual ~Sample();
};
class EventHandler : public nw4rmanager::TiEventHandler {
public:
explicit EventHandler(LayoutByNW4R* layout) : mpLayoutByNW4R(layout) {}
virtual ~EventHandler();
virtual void onTiEvent(gui::PaneComponent*, u32, Input*) override;
LayoutByNW4R* mpLayoutByNW4R;
};
class AnmPane : public nw4rmanager::AnmPane {
public:
AnmPane(nw4r::lyt::Pane* pane, nw4rmanager::AnmObserver* observer)
: nw4rmanager::AnmPane(pane, observer), muAnimation(0) {}
inline virtual ~AnmPane();
virtual void init() override;
virtual void changeAnimation(u32) override;
virtual u32 getKeyType() const;
protected:
s32 muAnimation;
u32 muKeyType;
};
class CellPhoneSignAllAnmPane : public AnmPane {
public:
CellPhoneSignAllAnmPane(nw4r::lyt::Pane* pane, nw4rmanager::AnmObserver* observer)
: AnmPane(pane, observer) { muKeyType = 0; }
virtual ~CellPhoneSignAllAnmPane();
virtual void init() override;
virtual void onAnmEvent(AnmPaneEvent) override;
};
class CellPhoneSignScrollAnmPane : public AnmPane {
public:
CellPhoneSignScrollAnmPane(nw4r::lyt::Pane* pane, nw4rmanager::AnmObserver* observer)
: AnmPane(pane, observer) { muKeyType = 1; }
virtual ~CellPhoneSignScrollAnmPane();
virtual void init() override;
virtual void onAnmEvent(AnmPaneEvent) override;
};
class CellPhoneSignButtonPane : public AnmPane {
public:
CellPhoneSignButtonPane(nw4r::lyt::Pane* pane, nw4rmanager::AnmObserver* observer)
: AnmPane(pane, observer) { muKeyType = 2; }
virtual ~CellPhoneSignButtonPane();
virtual void init() override;
virtual void onAnmEvent(AnmPaneEvent) override;
};
}
}
}
#endif

View File

@@ -3,7 +3,7 @@
#include <revolution/types.h>
#include <revolution/mem/allocator.h>
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
#ifdef TIINPUTFORM_IMPLEMENTATION
#include <revolution/kpr.h>
#endif
@@ -39,7 +39,7 @@ namespace textinput {
virtual wchar_t* getWCString() const { return mpszString; }
virtual void setCandidate(wchar_t candidate) { mwcCandidate = candidate; }
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
#ifdef TIINPUTFORM_IMPLEMENTATION
virtual wchar_t getCandidate() const { return mwcCandidate; }
#else
virtual wchar_t getCandidate() { return mwcCandidate; }
@@ -61,7 +61,7 @@ namespace textinput {
};
class KanaStream {
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
#ifdef TIINPUTFORM_IMPLEMENTATION
public:
KPRQueue mQueue;
wchar_t mPending;
@@ -74,13 +74,13 @@ namespace textinput {
class Decolated : public StringBase {
public:
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
#ifdef TIINPUTFORM_IMPLEMENTATION
Decolated(u16 maxLen) : StringBase(maxLen), mCursorStart(0), mCursorEnd(0), mbSustain(false), mTranslateMode(0) { initKanaConverter(); }
#else
Decolated(u16 maxLen) : StringBase(maxLen), field_0x18(0), field_0x1C(0), field_0x20(0), field_0x24(0) { initKanaConverter(); }
#endif
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
#ifdef TIINPUTFORM_IMPLEMENTATION
virtual ~Decolated();
enum TranslateMode { TM_Direct, TM_Kana, TM_Roman, TM_Hangul };
virtual void clear();
@@ -103,7 +103,7 @@ namespace textinput {
virtual u32 getCursorPos() const;
virtual void getCursorPos(u32* start, u32* end);
virtual bool canBackSpace();
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
#ifdef TIINPUTFORM_IMPLEMENTATION
virtual bool deleteForward();
#else
virtual void deleteForward();
@@ -162,7 +162,7 @@ namespace textinput {
#endif
private:
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
#ifdef TIINPUTFORM_IMPLEMENTATION
u32 mCursorStart;
u32 mCursorEnd;
bool mbSustain;
@@ -176,7 +176,7 @@ namespace textinput {
KanaStream mKanaStream; // 0x28
};
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
#ifdef TIINPUTFORM_IMPLEMENTATION
class WithAtok : public Decolated {
public:
WithAtok(u16 maxLength) : Decolated(maxLength) {}

View File

@@ -6,13 +6,13 @@
#include <nw4r/ut/CharWriter.h>
#include <nw4r/ut/Rect.h>
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
#ifdef TIINPUTFORM_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)
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)
#ifdef TIINPUTFORM_IMPLEMENTATION
nw4r::ut::Rect rect;
wchar_t character;
#else
@@ -42,7 +42,7 @@ namespace textinput {
#endif
} DrawInfo;
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
#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),
@@ -94,7 +94,7 @@ namespace textinput {
virtual u32 getEndPos() const;
// todo
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
#ifdef TIINPUTFORM_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)
#ifdef TIINPUTFORM_IMPLEMENTATION
virtual bool isEnableCursorCache() const;
#else
virtual void isEnableCursorCache();
#endif
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
#ifdef TIINPUTFORM_IMPLEMENTATION
virtual u32 getDrawModifyStartLine() const;
virtual u32 getDrawModifyEndLine() const;
#else
@@ -119,7 +119,7 @@ namespace textinput {
virtual void dirtyDrawCache();
virtual void dirtyCursorCache();
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
#ifdef TIINPUTFORM_IMPLEMENTATION
protected:
MEMAllocator* mpDrawAllocator;
u8 mDrawConfiguration[0x34];
@@ -145,7 +145,7 @@ namespace textinput {
u8 unk_0x50[0x78];
#endif
bool mbSecretMode; // 0xC8
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
#ifdef TIINPUTFORM_IMPLEMENTATION
u32 muDrawModifyStartLine;
u32 muDrawModifyEndLine;
u32 muDrawModifyStartPos;

View File

@@ -39,7 +39,7 @@ namespace textinput {
f32 y; // 0x08
} Scroll;
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
#ifdef TIINPUTFORM_IMPLEMENTATION
enum HVKCode { HVK_None = 0 };
#endif
@@ -54,11 +54,11 @@ namespace textinput {
class CommandSender;
class CommandReceiver : public Base {
public:
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
#ifdef TIINPUTFORM_IMPLEMENTATION
CommandReceiver() { clearSender(); }
virtual ~CommandReceiver();
#endif
#if defined(MYTIINPUTFORM_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
#if defined(MYTIINPUTFORM_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION)
struct Scroll {
bool absY;
f32 x;
@@ -70,7 +70,7 @@ namespace textinput {
INPUT_COMMAND_37 = 37,
} INPUT_COMMAND;
#if defined(TI_PC_KEYBOARD_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION) || defined(TISIGNWINDOW_IMPLEMENTATION)
#ifdef TI_PC_KEYBOARD_IMPLEMENTATION
struct ChangePredictMode { u32 mode; bool enabled; };
#endif
virtual void clearSender();
@@ -86,7 +86,7 @@ namespace textinput {
CommandSender() : mpCommandReceiver(NULL) {}
virtual void setCommandReceiver(CommandReceiver* cmdRecv);
#if defined(TI_PC_KEYBOARD_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
#ifdef TI_PC_KEYBOARD_IMPLEMENTATION
virtual void sendCommand(u32 command, void* data) {
if (mpCommandReceiver != NULL) mpCommandReceiver->onCommand(static_cast<CommandReceiver::INPUT_COMMAND>(command), data);
}

View File

@@ -10,7 +10,7 @@ namespace textinput {
namespace toolbar {
class Base {
public:
#if defined(TI_TOOLBAR_SAMPLE_CLASS) || defined(TIMANAGER_IMPLEMENTATION)
#ifdef TI_TOOLBAR_SAMPLE_CLASS
Base(Manager* manager) : mQwerty(true), meLanguage(USA), mpAllocator(NULL), mpManager(manager) {}
#endif
@@ -35,11 +35,7 @@ namespace textinput {
class LayoutByNW4R : public Base, public nw4rmanager::Layout {
public:
#ifdef TIMANAGER_IMPLEMENTATION
LayoutByNW4R(Manager* manager, nw4r::lyt::MultiArcResourceAccessor* resAccessor, EventObserver* observer, const char* layoutName)
: Base(manager), nw4rmanager::Layout(resAccessor, layoutName, observer), mpEventHandler(NULL),
mbIsEnableQwertyChg(false) {}
#elif defined(TI_TOOLBAR_SAMPLE_CLASS)
#ifdef TI_TOOLBAR_SAMPLE_CLASS
LayoutByNW4R(Manager* manager, nw4r::lyt::MultiArcResourceAccessor* resAccessor, EventObserver* observer)
: Base(manager), nw4rmanager::Layout(resAccessor, "fs_VK_toolbar_a.brlyt", observer), mpEventHandler(NULL),
mbIsEnableQwertyChg(false) {}
@@ -121,21 +117,12 @@ namespace textinput {
KeyType meKeyType; // 0x30
};
#if defined(TI_TOOLBAR_SAMPLE_CLASS) || defined(TIMANAGER_IMPLEMENTATION)
#ifdef TI_TOOLBAR_SAMPLE_CLASS
class Sample : public LayoutByNW4R {
public:
#ifdef TIMANAGER_IMPLEMENTATION
Sample(Manager* manager, nw4r::lyt::MultiArcResourceAccessor* resAccessor, EventObserver* observer, const char* layoutName)
: LayoutByNW4R(manager, resAccessor, observer, layoutName) {}
#else
Sample(Manager* manager, nw4r::lyt::MultiArcResourceAccessor* resAccessor, EventObserver* observer)
: LayoutByNW4R(manager, resAccessor, observer) {}
#endif
#ifdef TIMANAGER_IMPLEMENTATION
virtual ~Sample();
#else
virtual ~Sample() {}
#endif
};
#else
class Sample {};

View File

@@ -1,14 +1,14 @@
#ifndef TEXTINPUT_ZI_STRING_H
#define TEXTINPUT_ZI_STRING_H
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
#ifdef TIINPUTFORM_IMPLEMENTATION
#include "tiString.h"
#include <eztx.h>
#endif
namespace textinput {
namespace tistring {
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
#ifdef TIINPUTFORM_IMPLEMENTATION
class WithZi : public Decolated {
public:
enum PredictLanguage { PL_Default };

View File

@@ -28,7 +28,7 @@ namespace ipl {
int getIndex() const { return mIndex; }
nw4r::math::VEC3& getTranslate() const;
#if defined(IPL_SD_CHANNEL_TITLE_CPP) || defined(IPL_SD_CHANNEL_OBJ_CPP)
#ifdef IPL_SD_CHANNEL_TITLE_CPP
public:
#else
private:
@@ -39,20 +39,12 @@ namespace ipl {
EGG::ExpHeap* mpDialogHeap;
EGG::ExpHeap* mpChannelHeap;
EGG::Heap* mpHeap;
#ifdef IPL_SD_CHANNEL_OBJ_CPP
int mState;
#else
u32 mState;
#endif
int mPage;
int mIndex;
nand::LayoutFile* mpLayoutFile;
nw4r::lyt::Pane* mpPane;
#ifdef IPL_SD_CHANNEL_OBJ_CPP
nand::File* mpPaneAnimator;
#else
layout::Animator* mpPaneAnimator;
#endif
layout::Object* mpBaseLayout;
layout::Animator* mpBaseAnimator;
layout::Object* mpPageLayout;
@@ -66,11 +58,7 @@ namespace ipl {
int mDialogTimer;
int mAnimationState;
nw4r::lyt::Group* mpNewMessageGroup;
#ifdef IPL_SD_CHANNEL_OBJ_CPP
layout::Animator* mpNewMessageAnimator;
#else
int mNewMessageCount;
#endif
u8 mbNewMessageGroupActive;
int mNewMessageState;
int mNewMessageFrame;
@@ -188,7 +176,7 @@ namespace ipl {
static const char* mscClockPaneNames[3];
static const char* mscMaskPaneName;
#if defined(IPL_SD_CHANNEL_TITLE_CPP) || defined(IPL_SD_CHANNEL_OBJ_CPP)
#ifdef IPL_SD_CHANNEL_TITLE_CPP
public:
#else
private:

View File

@@ -1,986 +0,0 @@
#include <private/vf/PrFILE2/fatfs/pf_cache.h>
typedef struct PFCACHE_BPB {
pf_u16 bytes_per_sector;
pf_u16 num_reserved_sectors;
pf_u16 num_root_dir_entries;
pf_u8 sectors_per_cluster;
pf_u8 num_FATs;
pf_u32 total_sectors;
pf_u32 sectors_per_FAT;
pf_u32 root_dir_cluster;
pf_u16 fs_info_sector;
pf_u16 backup_boot_sector;
pf_u16 ext_flags;
pf_u8 media;
pf_s32 fat_type;
pf_u8 log2_bytes_per_sector;
pf_u8 log2_sectors_per_cluster;
pf_u8 num_active_FATs;
pf_u16 num_root_dir_sectors;
pf_u32 active_FAT_sector;
pf_u32 first_root_dir_sector;
pf_u32 first_data_sector;
pf_u32 num_clusters;
} PFCACHE_BPB;
struct PF_VOLUME {
PFCACHE_BPB bpb;
pf_u32 num_free_clusters;
pf_u32 last_free_cluster;
pf_u8 file_and_directory_state[0x1624 - 0x40];
PF_SECTOR_CACHE cache;
};
enum { FAT_32 = 2 };
extern void* pf_memcpy(void* dest, const void* src, pf_u32 size);
extern void* pf_memset(void* dest, pf_s32 value, pf_u32 size);
extern pf_s32 PFDRV_lread(PF_VOLUME* p_vol, pf_u8* buffer, pf_u32 sector, pf_u32 num_sector, pf_u32* p_num_success);
extern pf_s32 PFDRV_lwrite(PF_VOLUME* p_vol, const pf_u8* buffer, pf_u32 sector, pf_u32 num_sector, pf_u32* p_num_success);
pf_s32 PFCACHE_FlushAllCaches(PF_VOLUME* p_vol);
#pragma dont_inline on
pf_s32 PFCACHE_InitPageList(PF_VOLUME* p_vol, PF_CACHE_PAGE** pp_head, PF_CACHE_PAGE* pages, PF_CACHE_BUFFER* buffers, pf_u32 num,
pf_u32 size, pf_bool is_fat) {
pf_u32 i;
pf_u32 bps_per_buf;
*pp_head = pages;
bps_per_buf = (p_vol->bpb.bytes_per_sector >> 9) * size;
if ((num / bps_per_buf) == 0) {
return 30;
}
if ((num / bps_per_buf) == 1) {
pages->p_prev = pages;
pages->p_next = pages;
pages->buffer = *buffers;
pages->p_buf = *buffers;
pages->p_mod_sbuf = PF_NULL;
pages->p_mod_ebuf = PF_NULL;
pages->size = size;
pages->sector = 0xFFFFFFFF;
pages->option = 0;
pages->signature = PF_NULL;
pages->stat &= ~(0x01 | 0x02);
if (is_fat) {
pages->stat |= 0x04;
} else {
pages->stat &= ~0x04;
}
return 0;
}
pages->p_prev = &pages[(num - (num % bps_per_buf)) - bps_per_buf];
pages->p_next = &pages[bps_per_buf];
pages->buffer = *buffers;
pages->p_buf = *buffers;
pages->p_mod_sbuf = PF_NULL;
pages->p_mod_ebuf = PF_NULL;
pages->size = size;
pages->sector = 0xFFFFFFFF;
pages->option = 0;
pages->signature = PF_NULL;
pages->stat &= ~(0x01 | 0x02);
if (is_fat) {
pages->stat |= 0x04;
} else {
pages->stat &= ~0x04;
}
for (i = bps_per_buf; i < (num - (num % bps_per_buf) - bps_per_buf); i += bps_per_buf) {
pages[i].p_prev = &pages[i - bps_per_buf];
pages[i].p_next = &pages[i + bps_per_buf];
pages[i].buffer = buffers[i];
pages[i].p_buf = buffers[i];
pages[i].p_mod_sbuf = PF_NULL;
pages[i].p_mod_ebuf = PF_NULL;
pages[i].size = size;
pages[i].sector = 0xFFFFFFFF;
pages[i].option = 0;
pages[i].signature = PF_NULL;
pages[i].stat &= ~(0x01 | 0x02);
if (is_fat) {
pages[i].stat |= 0x04;
} else {
pages[i].stat &= ~0x04;
}
}
pages[(num - (num % bps_per_buf)) - bps_per_buf].p_prev = &pages[((num - (num % bps_per_buf)) - bps_per_buf) - bps_per_buf];
pages[(num - (num % bps_per_buf)) - bps_per_buf].p_next = pages;
pages[(num - (num % bps_per_buf)) - bps_per_buf].buffer = buffers[(num - (num % bps_per_buf)) - bps_per_buf];
pages[(num - (num % bps_per_buf)) - bps_per_buf].p_buf = buffers[(num - (num % bps_per_buf)) - bps_per_buf];
pages[(num - (num % bps_per_buf)) - bps_per_buf].p_mod_sbuf = PF_NULL;
pages[(num - (num % bps_per_buf)) - bps_per_buf].p_mod_ebuf = PF_NULL;
pages[(num - (num % bps_per_buf)) - bps_per_buf].size = size;
pages[(num - (num % bps_per_buf)) - bps_per_buf].sector = 0xFFFFFFFF;
pages[(num - (num % bps_per_buf)) - bps_per_buf].option = 0;
pages[(num - (num % bps_per_buf)) - bps_per_buf].signature = PF_NULL;
pages[(num - (num % bps_per_buf)) - bps_per_buf].stat &= ~(0x01 | 0x02);
if (is_fat) {
pages[(num - (num % bps_per_buf)) - bps_per_buf].stat |= 0x04;
} else {
pages[(num - (num % bps_per_buf)) - bps_per_buf].stat &= ~0x04;
}
return 0;
}
#pragma dont_inline reset
#pragma dont_inline on
PF_CACHE_PAGE* PFCACHE_SearchForPage(PF_VOLUME* p_vol, PF_CACHE_PAGE* p_head, pf_u32 sector) {
PF_CACHE_PAGE* p_page;
if (sector == 0xFFFFFFFF) {
return PF_NULL;
}
if ((p_head->stat & 1) == 0) {
return PF_NULL;
}
if (p_head->sector <= sector && p_head->sector + p_head->size - 1 >= sector) {
p_head->p_buf = &p_head->buffer[(sector - p_head->sector) << p_vol->bpb.log2_bytes_per_sector];
return p_head;
}
for (p_page = p_head->p_next; p_page != p_head; p_page = p_page->p_next) {
if ((p_page->stat & 1) == 0) {
return PF_NULL;
}
if (p_page->sector <= sector && p_page->sector + p_page->size - 1 >= sector) {
p_page->p_buf = &p_page->buffer[(sector - p_page->sector) << p_vol->bpb.log2_bytes_per_sector];
return p_page;
}
}
return PF_NULL;
}
#pragma dont_inline reset
#pragma dont_inline on
pf_bool PFCACHE_SearchForFreePage(PF_CACHE_PAGE* p_head, PF_CACHE_PAGE** pp_page) {
PF_CACHE_PAGE* p_page;
for (p_page = p_head->p_prev; p_page != p_head; p_page = p_page->p_prev) {
if ((p_page->stat & 1) == 0) {
*pp_page = p_page;
return PF_TRUE;
}
if (p_page->sector != 0xFFFFFFFF) {
*pp_page = p_page;
return PF_FALSE;
}
}
if ((p_page->stat & 1) == 0) {
*pp_page = p_page;
return PF_TRUE;
}
if (p_page->sector != 0xFFFFFFFF) {
*pp_page = p_page;
return PF_FALSE;
}
*pp_page = PF_NULL;
return PF_FALSE;
}
#pragma dont_inline reset
#pragma dont_inline on
pf_s32 PFCACHE_FlushPageIfNeeded(PF_VOLUME* p_vol, PF_CACHE_PAGE* p_page) {
pf_s32 err;
pf_u32 num_success;
pf_u32 size;
if (p_page != PF_NULL && (p_page->stat & 0x02) != 0 && p_page->sector != 0xFFFFFFFF) {
if (p_page->p_mod_sbuf == PF_NULL) {
size = p_page->size;
err = PFDRV_lwrite(p_vol, p_page->buffer, p_page->sector, size, &num_success);
} else {
size = (((pf_u32)p_page->p_mod_ebuf >> p_vol->bpb.log2_bytes_per_sector) -
((pf_u32)p_page->p_mod_sbuf >> p_vol->bpb.log2_bytes_per_sector)) + 1;
err = PFDRV_lwrite(p_vol, p_page->p_mod_sbuf,
p_page->sector + ((pf_u32)(p_page->p_mod_sbuf - p_page->buffer) >> p_vol->bpb.log2_bytes_per_sector),
size, &num_success);
}
if (err != 0) {
return err;
}
if (num_success != size) {
return 17;
}
p_page->p_mod_sbuf = NULL;
p_page->p_mod_ebuf = NULL;
p_page->stat &= ~2;
}
return 0;
}
#pragma dont_inline reset
#pragma dont_inline on
pf_s32 PFCACHE_DoAllocatePage(PF_VOLUME* p_vol, PF_CACHE_PAGE** pp_head, pf_u32 sector, PF_CACHE_PAGE** pp_page, pf_bool* p_is_hit) {
pf_s32 err;
*pp_page = PFCACHE_SearchForPage(p_vol, *pp_head, sector);
if (*pp_page != PF_NULL) {
*p_is_hit = PF_TRUE;
} else {
*p_is_hit = PF_FALSE;
if (PFCACHE_SearchForFreePage(*pp_head, pp_page) == 0) {
if (*pp_page == 0) {
*pp_page = PF_NULL;
return 30;
}
err = PFCACHE_FlushPageIfNeeded(p_vol, *pp_page);
if (err != 0) {
*pp_page = PF_NULL;
return err;
}
(*pp_page)->p_mod_sbuf = NULL;
(*pp_page)->p_mod_ebuf = NULL;
}
if (sector != 0xFFFFFFFF) {
if (((*pp_page)->stat & 0x04) != 0) {
(*pp_page)->sector = sector - (sector % (*pp_page)->size);
(*pp_page)->p_buf = &(*pp_page)->buffer[(sector % (*pp_page)->size) << p_vol->bpb.log2_bytes_per_sector];
} else {
if (p_vol->bpb.fat_type == FAT_32 && (sector < p_vol->bpb.first_data_sector || sector >= p_vol->bpb.total_sectors)) {
if (sector == p_vol->bpb.fs_info_sector) {
(*pp_page)->size = 1;
}
}
(*pp_page)->sector = sector - (sector % (*pp_page)->size);
(*pp_page)->p_buf = &(*pp_page)->buffer[(sector % (*pp_page)->size) << p_vol->bpb.log2_bytes_per_sector];
}
} else {
(*pp_page)->sector = sector;
(*pp_page)->p_buf = (*pp_page)->buffer;
}
(*pp_page)->stat |= 0x01;
}
{
PF_CACHE_PAGE* p_page = *pp_page;
if (p_page != *pp_head) {
if (p_page == (*pp_head)->p_prev) {
*pp_head = p_page;
} else {
p_page->p_prev->p_next = p_page->p_next;
p_page->p_next->p_prev = p_page->p_prev;
p_page->p_next = *pp_head;
p_page->p_prev = (*pp_head)->p_prev;
p_page->p_next->p_prev = p_page;
p_page->p_prev->p_next = p_page;
*pp_head = p_page;
}
}
}
return 0;
}
#pragma dont_inline reset
#pragma dont_inline on
pf_s32 PFCACHE_DoReadPage(PF_VOLUME* p_vol, PF_CACHE_PAGE** pp_head, pf_u32 sector, PF_CACHE_PAGE** pp_page, pf_bool set_sig) {
pf_u32 num_success;
pf_bool is_hit;
pf_s32 err;
err = PFCACHE_DoAllocatePage(p_vol, pp_head, sector, pp_page, &is_hit);
if (err != 0) {
return err;
}
if (!is_hit) {
err = PFDRV_lread(p_vol, (*pp_page)->buffer, (*pp_page)->sector, (*pp_page)->size, &num_success);
if (err != 0) {
{
PF_CACHE_PAGE* p_page = *pp_page;
p_page->stat &= ~3;
p_page->p_mod_sbuf = NULL;
p_page->p_mod_ebuf = NULL;
p_page->sector = 0xFFFFFFFF;
p_page->signature = PF_NULL;
if (p_page == *pp_head) {
*pp_head = p_page->p_next;
} else if (p_page != (*pp_head)->p_prev) {
p_page->p_prev->p_next = p_page->p_next;
p_page->p_next->p_prev = p_page->p_prev;
p_page->p_next = *pp_head;
p_page->p_prev = (*pp_head)->p_prev;
p_page->p_next->p_prev = p_page;
p_page->p_prev->p_next = p_page;
}
}
return err;
}
if (num_success != (*pp_page)->size && p_vol->bpb.total_sectors != ((*pp_page)->sector + num_success)) {
{
PF_CACHE_PAGE* p_page = *pp_page;
p_page->stat &= ~3;
p_page->p_mod_sbuf = NULL;
p_page->p_mod_ebuf = NULL;
p_page->sector = 0xFFFFFFFF;
p_page->signature = PF_NULL;
if (p_page == *pp_head) {
*pp_head = p_page->p_next;
} else if (p_page != (*pp_head)->p_prev) {
p_page->p_prev->p_next = p_page->p_next;
p_page->p_next->p_prev = p_page->p_prev;
p_page->p_next = *pp_head;
p_page->p_prev = (*pp_head)->p_prev;
p_page->p_next->p_prev = p_page;
p_page->p_prev->p_next = p_page;
}
}
return 17;
}
(*pp_page)->stat &= ~2;
(*pp_page)->p_mod_sbuf = NULL;
(*pp_page)->p_mod_ebuf = NULL;
if (set_sig) {
(*pp_page)->signature = p_vol->cache.signature;
} else {
(*pp_page)->signature = PF_NULL;
}
}
return 0;
}
#pragma dont_inline reset
#pragma dont_inline on
pf_s32 PFCACHE_DoReadPageAndFlushIfNeeded(PF_VOLUME* p_vol, PF_CACHE_PAGE** pp_head, pf_u32 sector, PF_CACHE_PAGE** pp_page,
pf_bool set_sig) {
pf_u32 num_success;
pf_bool is_hit;
pf_s32 err;
err = PFCACHE_DoAllocatePage(p_vol, pp_head, sector, pp_page, &is_hit);
if (err != 0) {
return err;
}
if (!is_hit) {
err = PFDRV_lread(p_vol, (*pp_page)->buffer, (*pp_page)->sector, (*pp_page)->size, &num_success);
if (err != 0) {
{
PF_CACHE_PAGE* p_page = *pp_page;
p_page->stat &= ~3;
p_page->p_mod_sbuf = NULL;
p_page->p_mod_ebuf = NULL;
p_page->sector = 0xFFFFFFFF;
p_page->signature = PF_NULL;
if (p_page == *pp_head) {
*pp_head = p_page->p_next;
} else if (p_page != (*pp_head)->p_prev) {
p_page->p_prev->p_next = p_page->p_next;
p_page->p_next->p_prev = p_page->p_prev;
p_page->p_next = *pp_head;
p_page->p_prev = (*pp_head)->p_prev;
p_page->p_next->p_prev = p_page;
p_page->p_prev->p_next = p_page;
}
}
return err;
}
if (num_success != (*pp_page)->size && p_vol->bpb.total_sectors != ((*pp_page)->sector + num_success)) {
{
PF_CACHE_PAGE* p_page = *pp_page;
p_page->stat &= ~3;
p_page->p_mod_sbuf = NULL;
p_page->p_mod_ebuf = NULL;
p_page->sector = 0xFFFFFFFF;
p_page->signature = PF_NULL;
if (p_page == *pp_head) {
*pp_head = p_page->p_next;
} else if (p_page != (*pp_head)->p_prev) {
p_page->p_prev->p_next = p_page->p_next;
p_page->p_next->p_prev = p_page->p_prev;
p_page->p_next = *pp_head;
p_page->p_prev = (*pp_head)->p_prev;
p_page->p_next->p_prev = p_page;
p_page->p_prev->p_next = p_page;
}
}
return 17;
}
(*pp_page)->stat &= ~2;
(*pp_page)->p_mod_sbuf = NULL;
(*pp_page)->p_mod_ebuf = NULL;
if (set_sig) {
(*pp_page)->signature = p_vol->cache.signature;
} else {
(*pp_page)->signature = PF_NULL;
}
} else if (set_sig && ((*pp_page)->stat & 0x02) != 0 && (p_vol->cache.mode & 0x02) != 0 && (*pp_page)->signature != p_vol->cache.signature) {
err = PFCACHE_FlushPageIfNeeded(p_vol, *pp_page);
if (err != 0) {
*pp_page = PF_NULL;
return err;
}
}
return 0;
}
#pragma dont_inline reset
#pragma dont_inline on
pf_s32 PFCACHE_DoReadNumSector(PF_VOLUME* p_vol, PF_CACHE_PAGE** pp_head, pf_u8* p_buf, pf_u32 sector, pf_u32 num_sector,
pf_u32* p_num_success) {
PF_CACHE_PAGE* p_page;
pf_s32 err;
pf_u32 num_rest_sector;
pf_u32 num_success_sector;
*p_num_success = 0;
err = PFDRV_lread(p_vol, p_buf, sector, num_sector, p_num_success);
if (err != 0) {
return err;
}
p_page = PF_NULL;
num_rest_sector = *p_num_success;
num_success_sector = *p_num_success;
do {
if (p_page == PF_NULL) {
p_page = *pp_head;
} else {
p_page = p_page->p_next;
if (p_page == *pp_head) {
p_page = PF_NULL;
goto found_page;
}
}
for (; (p_page->stat & 1) != 0; p_page = p_page->p_next) {
if (p_page->sector != 0xFFFFFFFF) {
p_page->p_buf = p_page->buffer;
goto found_page;
}
}
p_page = PF_NULL;
found_page:
if (p_page != PF_NULL && p_page->sector != 0xFFFFFFFF) {
if (p_page->sector <= sector && p_page->sector + p_page->size >= sector + num_success_sector) {
pf_memcpy(p_buf, &p_page->buffer[(sector - p_page->sector) << p_vol->bpb.log2_bytes_per_sector],
num_success_sector << p_vol->bpb.log2_bytes_per_sector);
num_rest_sector -= num_success_sector;
} else if (p_page->sector >= sector && p_page->sector + p_page->size <= sector + num_success_sector) {
pf_memcpy(&p_buf[(p_page->sector - sector) << p_vol->bpb.log2_bytes_per_sector], p_page->buffer,
p_page->size << p_vol->bpb.log2_bytes_per_sector);
num_rest_sector -= p_page->size;
} else if (p_page->sector > sector && p_page->sector < sector + num_success_sector &&
p_page->sector + p_page->size >= sector + num_success_sector) {
pf_memcpy(&p_buf[(p_page->sector - sector) << p_vol->bpb.log2_bytes_per_sector], p_page->buffer,
(p_page->size - (p_page->sector + p_page->size - (sector + num_success_sector))) << p_vol->bpb.log2_bytes_per_sector);
num_rest_sector -= p_page->size - ((p_page->sector + p_page->size) - (sector + num_success_sector));
} else if (p_page->sector < sector && (p_page->sector + p_page->size) > sector &&
(p_page->sector + p_page->size) <= (sector + num_success_sector)) {
pf_memcpy(p_buf, &p_page->buffer[(sector - p_page->sector) << p_vol->bpb.log2_bytes_per_sector],
(p_page->size - (sector - p_page->sector)) << p_vol->bpb.log2_bytes_per_sector);
num_rest_sector -= p_page->size - (sector - p_page->sector);
}
}
} while (p_page != PF_NULL && num_rest_sector != 0);
if (*p_num_success != num_sector && p_vol->bpb.total_sectors != (sector + *p_num_success)) {
return 17;
}
return 0;
}
#pragma dont_inline reset
#pragma dont_inline on
pf_s32 PFCACHE_DoWritePage(PF_VOLUME* p_vol, PF_CACHE_PAGE** pp_head, PF_CACHE_PAGE* p_page, pf_bool set_sig) {
pf_s32 err;
if (p_page != *pp_head) {
if (p_page == (*pp_head)->p_prev) {
*pp_head = p_page;
} else {
p_page->p_prev->p_next = p_page->p_next;
p_page->p_next->p_prev = p_page->p_prev;
p_page->p_next = *pp_head;
p_page->p_prev = (*pp_head)->p_prev;
p_page->p_next->p_prev = p_page;
p_page->p_prev->p_next = p_page;
*pp_head = p_page;
}
}
p_page->stat |= 2;
if (p_page->p_mod_sbuf == PF_NULL) {
p_page->p_mod_sbuf = p_page->p_buf;
p_page->p_mod_ebuf = p_page->p_buf;
} else if (p_page->p_buf < p_page->p_mod_sbuf) {
p_page->p_mod_sbuf = p_page->p_buf;
} else if (p_page->p_buf > p_page->p_mod_ebuf) {
p_page->p_mod_ebuf = p_page->p_buf;
}
if (set_sig) {
p_page->signature = p_vol->cache.signature;
} else {
p_page->signature = PF_NULL;
}
if ((p_vol->cache.mode & 0x01) != 0 || ((p_vol->cache.mode & 0x04) != 0 && (p_page->stat & 0x04) != 0)) {
err = PFCACHE_FlushPageIfNeeded(p_vol, p_page);
if (err != 0) {
return err;
}
}
return 0;
}
#pragma dont_inline reset
#pragma dont_inline on
pf_s32 PFCACHE_DoWriteSector(PF_VOLUME* p_vol, PF_CACHE_PAGE** pp_head, const pf_u8* p_buf, pf_u32 sector) {
PF_CACHE_PAGE* p_page;
pf_u32 num_success;
pf_s32 err;
p_page = PFCACHE_SearchForPage(p_vol, *pp_head, sector);
if (p_page != PF_NULL) {
pf_memcpy(p_page->p_buf, (pf_u8*)p_buf, p_vol->bpb.bytes_per_sector);
p_page->stat |= 2;
if (p_page->p_mod_sbuf == PF_NULL) {
p_page->p_mod_sbuf = p_page->p_buf;
p_page->p_mod_ebuf = p_page->p_buf;
} else if (p_page->p_buf < p_page->p_mod_sbuf) {
p_page->p_mod_sbuf = p_page->p_buf;
} else if (p_page->p_buf > p_page->p_mod_ebuf) {
p_page->p_mod_ebuf = p_page->p_buf;
}
err = PFCACHE_FlushPageIfNeeded(p_vol, p_page);
if (err != 0) {
return err;
}
} else {
err = PFDRV_lwrite(p_vol, p_buf, sector, 1, &num_success);
if (err != 0) {
return err;
}
if (num_success != 1) {
return 17;
}
}
return 0;
}
#pragma dont_inline reset
#pragma dont_inline on
pf_s32 PFCACHE_DoWriteNumSectorAndFreeIfNeeded(PF_VOLUME* p_vol, PF_CACHE_PAGE** pp_head, const pf_u8* p_buf, pf_u32 sector,
pf_u32 num_sector, pf_u32* p_num_success) {
PF_CACHE_PAGE* p_page = PF_NULL;
pf_s32 err;
pf_u32 num_rest_sector = num_sector;
pf_u8* p_sbuf;
pf_u8* p_ebuf;
pf_u32 num_overlap;
pf_u32 last_sector;
*p_num_success = 0;
do {
if (p_page == PF_NULL) {
p_page = *pp_head;
} else {
p_page = p_page->p_next;
if (p_page == *pp_head) {
p_page = PF_NULL;
goto found_page;
}
}
for (; (p_page->stat & 1) != 0; p_page = p_page->p_next) {
if (p_page->sector != 0xFFFFFFFF) {
p_page->p_buf = p_page->buffer;
goto found_page;
}
}
p_page = PF_NULL;
found_page:
if (p_page != PF_NULL && p_page->sector != 0xFFFFFFFF) {
if (p_page->sector <= sector && (p_page->sector + p_page->size) >= (sector + num_sector)) {
pf_memcpy(&p_page->buffer[(sector - p_page->sector) << p_vol->bpb.log2_bytes_per_sector], (pf_u8*)p_buf,
num_sector << p_vol->bpb.log2_bytes_per_sector);
*p_num_success += num_rest_sector;
num_rest_sector = 0;
p_page->stat |= 2;
p_sbuf = &p_page->buffer[(sector - p_page->sector) << p_vol->bpb.log2_bytes_per_sector];
p_ebuf = &(&p_page->buffer[(sector - p_page->sector) << p_vol->bpb.log2_bytes_per_sector])[(num_sector - 1)
<< p_vol->bpb.log2_bytes_per_sector];
if (p_page->p_mod_sbuf == NULL) {
p_page->p_mod_sbuf = p_sbuf;
p_page->p_mod_ebuf = p_ebuf;
} else if (p_sbuf < p_page->p_mod_sbuf) {
p_page->p_mod_sbuf = p_sbuf;
} else if (p_page->p_mod_ebuf < p_ebuf) {
p_page->p_mod_ebuf = p_ebuf;
}
} else if (p_page->sector >= sector && (p_page->sector + p_page->size) <= (sector + num_sector)) {
pf_memcpy(p_page->buffer, (pf_u8*)&p_buf[(p_page->sector - sector) << p_vol->bpb.log2_bytes_per_sector],
p_page->size << p_vol->bpb.log2_bytes_per_sector);
num_rest_sector -= p_page->size;
*p_num_success += p_page->size;
p_page->stat |= 2;
p_page->p_mod_sbuf = p_page->buffer;
p_page->p_mod_ebuf = &p_page->buffer[(p_page->size - 1) << p_vol->bpb.log2_bytes_per_sector];
} else if (p_page->sector > sector && p_page->sector < (sector + num_sector) &&
(p_page->sector + p_page->size) >= (sector + num_sector)) {
pf_memcpy(p_page->buffer, (pf_u8*)&p_buf[(p_page->sector - sector) << p_vol->bpb.log2_bytes_per_sector],
(sector + num_sector - p_page->sector) << p_vol->bpb.log2_bytes_per_sector);
num_overlap = p_page->size - ((p_page->sector + p_page->size) - (num_sector + sector));
last_sector = p_page->sector + num_overlap - 1;
*p_num_success += num_overlap;
num_rest_sector -= num_overlap;
p_page->stat |= 2;
p_ebuf = &p_page->buffer[(last_sector - p_page->sector) << p_vol->bpb.log2_bytes_per_sector];
p_page->p_mod_sbuf = p_page->buffer;
if (p_page->p_mod_ebuf == NULL || p_page->p_mod_ebuf < p_ebuf) {
p_page->p_mod_ebuf = p_ebuf;
}
} else if (p_page->sector < sector && (p_page->sector + p_page->size) > sector &&
(p_page->sector + p_page->size) <= (sector + num_sector)) {
pf_memcpy(&p_page->buffer[(sector - p_page->sector) << p_vol->bpb.log2_bytes_per_sector], (pf_u8*)p_buf,
(p_page->size - (sector - p_page->sector)) << p_vol->bpb.log2_bytes_per_sector);
num_rest_sector -= p_page->size - (sector - p_page->sector);
*p_num_success += p_page->size - (sector - p_page->sector);
p_page->stat |= 2;
p_sbuf = &p_page->buffer[(p_page->size - (sector - p_page->sector) - 1) << p_vol->bpb.log2_bytes_per_sector];
if (p_page->p_mod_sbuf == NULL || p_sbuf < p_page->p_mod_sbuf) {
p_page->p_mod_sbuf = p_sbuf;
}
p_page->p_mod_ebuf = &p_page->buffer[(p_page->size - 1) << p_vol->bpb.log2_bytes_per_sector];
}
}
} while (p_page != PF_NULL && num_rest_sector != 0);
if (num_rest_sector != 0) {
err = PFDRV_lwrite(p_vol, p_buf, sector, num_sector, p_num_success);
if (err != 0) {
return err;
}
}
return 0;
}
#pragma dont_inline reset
#pragma dont_inline on
pf_s32 PFCACHE_DoFlushCache(PF_VOLUME* p_vol, PF_CACHE_PAGE* p_head) {
PF_CACHE_PAGE* p_page;
pf_s32 err;
pf_s32 first_err;
first_err = 0;
p_page = p_head;
if ((p_page->stat & 0x01) == 0) {
return 0;
}
if ((p_vol->cache.mode & 1) != 0 || ((p_vol->cache.mode & 4) != 0 && (p_page->stat & 4) != 0)) {
return 0;
}
do {
if ((p_page->stat & 0x01) == 0) {
break;
}
err = PFCACHE_FlushPageIfNeeded(p_vol, p_page);
if (err != 0 && first_err == 0) {
first_err = err;
}
p_page = p_page->p_next;
} while (p_page != p_head);
return first_err;
}
#pragma dont_inline reset
void PFCACHE_SetCache(PF_VOLUME* p_vol, PF_CACHE_PAGE* p_cache_page, PF_CACHE_BUFFER* p_cache_buf, pf_u16 num_fat_pages, pf_u16 num_data_pages) {
p_vol->cache.pages = p_cache_page;
p_vol->cache.buffers = p_cache_buf;
p_vol->cache.num_fat_pages = num_fat_pages;
p_vol->cache.num_data_pages = num_data_pages;
}
void PFCACHE_SetFATBufferSize(PF_VOLUME* p_vol, pf_u32 size) {
if (size != 0) {
p_vol->cache.fat_buff_size = size;
}
}
void PFCACHE_SetDataBufferSize(PF_VOLUME* p_vol, pf_u32 size) {
if (size != 0) {
p_vol->cache.data_buff_size = size;
}
}
pf_s32 PFCACHE_InitCaches(PF_VOLUME* p_vol) {
pf_s32 err;
p_vol->cache.mode &= ~0x01;
p_vol->cache.mode |= 0x02;
p_vol->cache.mode &= ~0x04;
pf_memset(p_vol->cache.buffers, 0, (p_vol->cache.num_fat_pages + p_vol->cache.num_data_pages) << 9);
err = PFCACHE_InitPageList(p_vol, &p_vol->cache.p_current_fat, p_vol->cache.pages, p_vol->cache.buffers, p_vol->cache.num_fat_pages,
p_vol->cache.fat_buff_size, PF_TRUE);
if (err != 0) {
return err;
}
err = PFCACHE_InitPageList(p_vol, &p_vol->cache.p_current_data, &p_vol->cache.pages[p_vol->cache.num_fat_pages],
(PF_CACHE_BUFFER*)p_vol->cache.buffers[p_vol->cache.num_fat_pages], p_vol->cache.num_data_pages,
p_vol->cache.data_buff_size, PF_FALSE);
if (err != 0) {
return err;
}
return 0;
}
pf_s32 PFCACHE_SetWriteThroughMode(PF_VOLUME* p_vol) {
pf_s32 err = PFCACHE_FlushAllCaches(p_vol);
if (err != 0) {
return err;
}
p_vol->cache.mode |= 1;
return 0;
}
pf_s32 PFCACHE_SetWriteBackMode(PF_VOLUME* p_vol) {
p_vol->cache.mode &= ~1;
return 0;
}
pf_s32 PFCACHE_AllocateFATPage(PF_VOLUME* p_vol, pf_u32 sector, PF_CACHE_PAGE** pp_page, pf_bool* p_is_hit) {
pf_s32 err;
if (p_vol->cache.p_current_fat == 0) {
p_vol->cache.pages->buffer = *p_vol->cache.buffers;
p_vol->cache.pages->p_buf = *p_vol->cache.buffers;
*pp_page = p_vol->cache.pages;
return 0;
}
err = PFCACHE_DoAllocatePage(p_vol, &p_vol->cache.p_current_fat, sector, pp_page, p_is_hit);
if (err != 0) {
return err;
}
return 0;
}
pf_s32 PFCACHE_AllocateDataPage(PF_VOLUME* p_vol, pf_u32 sector, PF_CACHE_PAGE** pp_page, pf_bool* p_is_hit) {
pf_s32 err;
if (p_vol->cache.p_current_data == 0) {
p_vol->cache.pages->buffer = *p_vol->cache.buffers;
p_vol->cache.pages->p_buf = *p_vol->cache.buffers;
*pp_page = p_vol->cache.pages;
return 0;
}
err = PFCACHE_DoAllocatePage(p_vol, &p_vol->cache.p_current_data, sector, pp_page, p_is_hit);
if (err != 0) {
return err;
}
return 0;
}
void PFCACHE_FreeFATPage(PF_VOLUME* p_vol, PF_CACHE_PAGE* p_page) {
if (p_vol->cache.p_current_fat != 0) {
p_page->p_mod_sbuf = NULL;
p_page->stat &= ~3;
p_page->p_mod_ebuf = NULL;
p_page->sector = 0xFFFFFFFF;
p_page->signature = PF_NULL;
if (p_page == p_vol->cache.p_current_fat) {
p_vol->cache.p_current_fat = p_page->p_next;
} else if (p_page != (p_vol->cache.p_current_fat)->p_prev) {
p_page->p_prev->p_next = p_page->p_next;
p_page->p_next->p_prev = p_page->p_prev;
p_page->p_next = p_vol->cache.p_current_fat;
p_page->p_prev = (p_vol->cache.p_current_fat)->p_prev;
p_page->p_next->p_prev = p_page;
p_page->p_prev->p_next = p_page;
}
}
}
void PFCACHE_FreeDataPage(PF_VOLUME* p_vol, PF_CACHE_PAGE* p_page) {
if (p_vol->cache.p_current_data != 0) {
p_page->p_mod_sbuf = NULL;
p_page->stat &= ~3;
p_page->p_mod_ebuf = NULL;
p_page->sector = 0xFFFFFFFF;
p_page->signature = PF_NULL;
if (p_page == p_vol->cache.p_current_data) {
p_vol->cache.p_current_data = p_page->p_next;
} else if (p_page != (p_vol->cache.p_current_data)->p_prev) {
p_page->p_prev->p_next = p_page->p_next;
p_page->p_next->p_prev = p_page->p_prev;
p_page->p_next = p_vol->cache.p_current_data;
p_page->p_prev = (p_vol->cache.p_current_data)->p_prev;
p_page->p_next->p_prev = p_page;
p_page->p_prev->p_next = p_page;
}
}
}
pf_s32 PFCACHE_ReadFATPage(PF_VOLUME* p_vol, pf_u32 sector, PF_CACHE_PAGE** pp_page) {
pf_s32 err;
err = PFCACHE_DoReadPage(p_vol, &p_vol->cache.p_current_fat, sector, pp_page, 0U);
if (err != 0) {
return err;
}
return 0;
}
pf_s32 PFCACHE_ReadDataPage(PF_VOLUME* p_vol, pf_u32 sector, PF_CACHE_PAGE** pp_page, pf_bool set_sig) {
pf_s32 err;
err = PFCACHE_DoReadPage(p_vol, &p_vol->cache.p_current_data, sector, pp_page, set_sig);
if (err != 0) {
return err;
}
return 0;
}
pf_s32 PFCACHE_ReadDataPageAndFlushIfNeeded(PF_VOLUME* p_vol, pf_u32 sector, PF_CACHE_PAGE** pp_page, pf_bool set_sig) {
pf_s32 err;
err = PFCACHE_DoReadPageAndFlushIfNeeded(p_vol, &p_vol->cache.p_current_data, sector, pp_page, set_sig);
if (err != 0) {
return err;
}
return 0;
}
pf_s32 PFCACHE_ReadDataNumSector(PF_VOLUME* p_vol, pf_u8* p_buf, pf_u32 sector, pf_u32 num_sector, pf_u32* p_num_success) {
pf_s32 err;
if (sector >= p_vol->bpb.total_sectors) {
return 16;
}
err = PFCACHE_DoReadNumSector(p_vol, &p_vol->cache.p_current_data, p_buf, sector, num_sector, p_num_success);
if (err != 0) {
return err;
}
return 0;
}
pf_s32 PFCACHE_WriteFATPage(PF_VOLUME* p_vol, PF_CACHE_PAGE* p_page) {
pf_s32 err;
err = PFCACHE_DoWritePage(p_vol, &p_vol->cache.p_current_fat, p_page, 0);
if (err != 0) {
return err;
}
return 0;
}
pf_s32 PFCACHE_WriteDataPage(PF_VOLUME* p_vol, PF_CACHE_PAGE* p_page, pf_bool set_sig) {
pf_s32 err;
err = PFCACHE_DoWritePage(p_vol, &p_vol->cache.p_current_data, p_page, set_sig);
if (err != 0) {
return err;
}
return 0;
}
pf_s32 PFCACHE_WriteFATSectorAndFreeIfNeeded(PF_VOLUME* p_vol, const pf_u8* p_buf, pf_u32 sector) {
pf_s32 err;
if (sector >= p_vol->bpb.total_sectors) {
return 16;
}
err = PFCACHE_DoWriteSector(p_vol, &p_vol->cache.p_current_fat, p_buf, sector);
if (err != 0) {
return err;
}
return 0;
}
pf_s32 PFCACHE_WriteDataNumSectorAndFreeIfNeeded(PF_VOLUME* p_vol, const pf_u8* p_buf, pf_u32 sector, pf_u32 num_sector, pf_u32* p_num_success) {
pf_s32 err;
if (sector >= p_vol->bpb.total_sectors) {
return 16;
}
err = PFCACHE_DoWriteNumSectorAndFreeIfNeeded(p_vol, &p_vol->cache.p_current_data, p_buf, sector, num_sector, p_num_success);
if (err != 0) {
return err;
}
return 0;
}
PF_CACHE_PAGE* PFCACHE_SearchDataCache(PF_VOLUME* p_vol, pf_u32 sector) {
return PFCACHE_SearchForPage(p_vol, p_vol->cache.p_current_data, sector);
}
pf_s32 PFCACHE_FlushFATCache(PF_VOLUME* p_vol) {
pf_s32 err;
err = PFCACHE_DoFlushCache(p_vol, p_vol->cache.p_current_fat);
if (err != 0) {
return err;
}
return 0;
}
pf_s32 PFCACHE_FlushDataCache(PF_VOLUME* p_vol) {
pf_s32 err;
err = PFCACHE_DoFlushCache(p_vol, p_vol->cache.p_current_data);
if (err != 0) {
return err;
}
return 0;
}
pf_s32 PFCACHE_FlushDataCacheSpecific(PF_VOLUME* p_vol, void* signature) {
pf_s32 err = 0;
PF_CACHE_PAGE* p_head;
PF_CACHE_PAGE* p_page;
if ((p_vol->cache.mode & 7) != 0) {
p_head = p_vol->cache.p_current_data;
p_page = p_head;
if (p_page->signature == PF_NULL || p_page->signature == signature) {
err = PFCACHE_FlushPageIfNeeded(p_vol, p_page);
if (err != 0) {
return err;
}
}
for (p_page = p_page->p_next; p_page != p_head; p_page = p_page->p_next) {
if (p_page->signature == PF_NULL || p_page->signature == signature) {
err = PFCACHE_FlushPageIfNeeded(p_vol, p_page);
if (err != 0) {
return err;
}
continue;
}
}
}
return err;
}
pf_s32 PFCACHE_FlushAllCaches(PF_VOLUME* p_vol) {
pf_s32 err;
err = PFCACHE_DoFlushCache(p_vol, p_vol->cache.p_current_fat);
if (err != 0) {
return err;
}
err = PFCACHE_DoFlushCache(p_vol, p_vol->cache.p_current_data);
if (err != 0) {
return err;
}
return 0;
}
void PFCACHE_FreeAllCaches(PF_VOLUME* p_vol) {
while ((p_vol->cache.p_current_fat->stat & 0x01) != 0) {
{
PF_CACHE_PAGE* p_page = p_vol->cache.p_current_fat;
if (p_vol->cache.p_current_fat != 0) {
p_page->stat &= ~3;
p_page->p_mod_sbuf = NULL;
p_page->p_mod_ebuf = NULL;
p_page->sector = 0xFFFFFFFF;
p_page->signature = PF_NULL;
if (p_page == p_vol->cache.p_current_fat) {
p_vol->cache.p_current_fat = p_page->p_next;
} else if (p_page != (p_vol->cache.p_current_fat)->p_prev) {
p_page->p_prev->p_next = p_page->p_next;
p_page->p_next->p_prev = p_page->p_prev;
p_page->p_next = p_vol->cache.p_current_fat;
p_page->p_prev = (p_vol->cache.p_current_fat)->p_prev;
p_page->p_next->p_prev = p_page;
p_page->p_prev->p_next = p_page;
}
}
}
}
while ((p_vol->cache.p_current_data->stat & 0x01) != 0) {
{
PF_CACHE_PAGE* p_page = p_vol->cache.p_current_data;
if (p_vol->cache.p_current_data != 0) {
p_page->stat &= ~3;
p_page->p_mod_sbuf = NULL;
p_page->p_mod_ebuf = NULL;
p_page->sector = 0xFFFFFFFF;
p_page->signature = PF_NULL;
if (p_page == p_vol->cache.p_current_data) {
p_vol->cache.p_current_data = p_page->p_next;
} else if (p_page != (p_vol->cache.p_current_data)->p_prev) {
p_page->p_prev->p_next = p_page->p_next;
p_page->p_next->p_prev = p_page->p_prev;
p_page->p_next = p_vol->cache.p_current_data;
p_page->p_prev = (p_vol->cache.p_current_data)->p_prev;
p_page->p_next->p_prev = p_page;
p_page->p_prev->p_next = p_page;
}
}
}
}
}

View File

@@ -1,747 +0,0 @@
#include <private/vf/PrFILE2/fatfs/pf_entry.h>
typedef struct PFITER_FAT_HINT {
pf_u32 chain_index;
pf_u32 cluster;
pf_u32 previous_cluster;
} PFITER_FAT_HINT;
typedef struct PFITER_FFD {
pf_u32 start_cluster;
pf_u32 current_start_cluster;
pf_u32* p_start_cluster;
PF_LAST_CLUSTER last_cluster;
PF_FAT_LAST_ACCESS last_access_cluster;
PF_CLUSTER_LINK cluster_link;
PFITER_FAT_HINT* p_hint;
PF_VOLUME* p_vol;
} PFITER_FFD;
typedef struct PFITER_ENT_ITER {
pf_u32 index;
PF_VOLUME* p_vol;
PFITER_FFD ffd;
pf_u32 file_sector_index;
pf_u32 sector;
pf_u16 offset;
pf_u16 offset_mask;
pf_u8 buf[32];
pf_u8 log2_entries_per_sector;
} PFITER_ENT_ITER;
typedef struct PFITER_BPB {
pf_u16 bytes_per_sector;
pf_u16 num_reserved_sectors;
pf_u16 num_root_dir_entries;
pf_u8 sectors_per_cluster;
pf_u8 num_FATs;
pf_u32 total_sectors;
pf_u32 sectors_per_FAT;
pf_u32 root_dir_cluster;
pf_u16 fs_info_sector;
pf_u16 backup_boot_sector;
pf_u16 ext_flags;
pf_u8 media;
pf_s32 fat_type;
pf_u8 log2_bytes_per_sector;
pf_u8 log2_sectors_per_cluster;
pf_u8 num_active_FATs;
pf_u16 num_root_dir_sectors;
pf_u32 active_FAT_sector;
pf_u32 first_root_dir_sector;
pf_u32 first_data_sector;
pf_u32 num_clusters;
} PFITER_BPB;
struct PF_VOLUME {
PFITER_BPB bpb;
};
typedef struct PFITER_CONTEXT_VOLUME {
pf_u32 stat;
pf_s32 context_id;
PF_VOLUME* p_vol;
} PFITER_CONTEXT_VOLUME;
typedef struct PFITER_VOLUME_SET {
pf_u32 flags;
pf_u32 reserved;
PF_VOLUME* current_volume;
PFITER_CONTEXT_VOLUME context_volumes[3];
pf_s32 num_attached;
pf_s32 num_mounted;
pf_u32 config;
void* user_data;
pf_s32 last_error;
pf_s32 last_driver_error;
void (*code_callbacks[6])(void);
pf_u32 setting;
} PFITER_VOLUME_SET;
extern PFITER_VOLUME_SET pf_vol_set;
pf_s8* PFSTR_GetStrPos(PF_STR*, pf_u32);
pf_u32 PFSTR_GetCodeMode(PF_STR* p_str);
void PFSTR_MoveStrPos(PF_STR* p_str, pf_s16 num_char);
pf_u16 PFSTR_StrLen(PF_STR* p_str);
pf_u16 PFSTR_StrNumChar(PF_STR* p_str, pf_u32 target);
pf_s32 PFSTR_StrCmp(const PF_STR* p_str, const pf_s8* s);
pf_s32 PFSTR_StrNCmp(PF_STR* p_str, const pf_s8* s, pf_u32 target, pf_s16 offset, pf_u16 num);
void* pf_memcpy(void* dst, void* src, pf_u32 length);
void* pf_memset(void* dst, pf_s32 c, pf_u32 length);
pf_s32 pf_strncmp(const pf_s8* s1, const pf_s8* s2, pf_u32 length);
pf_u8 PFENT_CalcCheckSum(PF_DIR_ENT* p_ent);
void PFENT_LoadShortNameFromBuf(PF_DIR_ENT* p_ent, const pf_u8* buf);
void PFENT_loadEntryNumericFieldsFromBuf(PF_DIR_ENT* p_ent, const pf_u8* buf);
pf_s32 PFENT_LoadLFNEntryFieldsFromBuf(PF_DIR_ENT* p_ent, const pf_u8* buf);
pf_s32 PFENT_GetRootDir(PF_VOLUME* p_vol, PF_DIR_ENT* p_ent);
pf_s32 PFFAT_GetSectorSpecified(PFITER_FFD* p_ffd, pf_u32 file_sector_index, pf_u32 may_allocate, pf_u32* p_sector);
pf_s32 PFFAT_getBeforeChain(PF_VOLUME* p_vol, pf_u32 start_cluster, pf_u32 lActive, pf_u32* p_cluster);
pf_s32 PFFAT_ResetFFD(PFITER_FFD* p_ffd, pf_u32* p_start_cluster);
pf_s32 PFFAT_InitFFD(PFITER_FFD* p_ffd, PFITER_FAT_HINT* p_hint, PF_VOLUME* p_vol, pf_u32* p_start_cluster);
void PFPATH_InitTokenOfPath(PF_STR* p_str, pf_s8* path, pf_u32 code_mode);
pf_s32 PFPATH_GetNextTokenOfPath(PF_STR* p_str, pf_bool wildcard);
pf_bool PFPATH_MatchFileNameWithPattern(const pf_s8* file_name, PF_STR* p_pattern, pf_bool is_long_name);
void PFPATH_getLongNameformShortName(pf_s8* short_name, pf_s8* long_name, pf_u8 flag);
pf_u32 PFPATH_GetLengthFromShortname(const pf_s8* sSrc);
pf_u32 PFPATH_GetLengthFromUnicode(const pf_u16* sSrc);
pf_s32 PFPATH_transformInUnicode(pf_u16* sDestStr, const pf_s8* sSrcStr);
pf_bool PFPATH_GetExtShortNameIndex(PF_STR* p_str, pf_u32* p_index);
pf_s32 PFSEC_ReadData(PF_VOLUME* p_vol, pf_u8* p_buf, pf_u32 sector, pf_u16 offset, pf_u32 size, pf_u32* p_success_size, pf_bool set_sig);
pf_s32 PFSEC_WriteData(PF_VOLUME* p_vol, const pf_u8* p_buf, pf_u32 sector, pf_u16 offset, pf_u32 size, pf_u32* p_success_size, pf_bool set_sig);
pf_s32 PFVOL_GetCurrentDir(PF_VOLUME*, PF_DIR_ENT*);
pf_s32 PFCACHE_AllocateDataPage(PF_VOLUME*, pf_u32, PF_CACHE_PAGE**, pf_bool*);
pf_s32 PFCACHE_FreeDataPage(PF_VOLUME*, PF_CACHE_PAGE*);
pf_s32 PFENT_RecalcEntryIterator(PFITER_ENT_ITER*, pf_u32);
pf_s32 PFENT_ITER_IteratorInitialize(PFITER_ENT_ITER*, pf_u32);
pf_bool PFENT_ITER_IsAtLogicalEnd(PFITER_ENT_ITER*);
pf_s32 PFENT_ITER_MoveTo(PFITER_ENT_ITER*, pf_u32, pf_u32);
pf_s32 PFENT_ITER_Advance(PFITER_ENT_ITER*, pf_u32);
pf_s32 PFENT_ITER_Retreat(PFITER_ENT_ITER*, pf_u32);
pf_s32 PFENT_ITER_FindDirEntryFromCluster(PFITER_ENT_ITER*, PF_DIR_ENT*, pf_u32, pf_bool*);
#pragma dont_inline on
pf_s32 PFENT_RecalcEntryIterator(PFITER_ENT_ITER* p_iter, pf_u32 may_allocate) {
pf_u32 file_sector_index;
pf_u32 previous_fsindex;
pf_u32 sector_count;
pf_s32 err;
PF_CACHE_PAGE* page;
pf_u32 success_size;
pf_bool hit;
file_sector_index = p_iter->index >> p_iter->log2_entries_per_sector;
previous_fsindex = p_iter->file_sector_index;
if (file_sector_index != p_iter->file_sector_index) {
p_iter->file_sector_index = file_sector_index;
err = PFFAT_GetSectorSpecified(&p_iter->ffd, file_sector_index, 0, &p_iter->sector);
if (err != 0) return err;
if (p_iter->sector == -1U && may_allocate != 0) {
err = PFFAT_GetSectorSpecified(&p_iter->ffd, file_sector_index, 1, &p_iter->sector);
if (err != 0) return err;
if (p_iter->sector != -1U && previous_fsindex != -1U) {
err = PFCACHE_AllocateDataPage(p_iter->p_vol, -1U, &page, &hit);
if (err != 0) return err;
pf_memset(page->p_buf, 0, p_iter->p_vol->bpb.bytes_per_sector);
for (sector_count = 0; sector_count < p_iter->p_vol->bpb.sectors_per_cluster; ++sector_count) {
err = PFSEC_WriteData(p_iter->p_vol, page->p_buf, p_iter->sector + sector_count, 0,
p_iter->p_vol->bpb.bytes_per_sector, &success_size, 0);
if (err != 0) {
PFCACHE_FreeDataPage(p_iter->p_vol, page);
return err;
}
if (success_size != p_iter->p_vol->bpb.bytes_per_sector) {
PFCACHE_FreeDataPage(p_iter->p_vol, page);
return 17;
}
}
PFCACHE_FreeDataPage(p_iter->p_vol, page);
}
}
}
p_iter->offset = (p_iter->index & p_iter->offset_mask) * 32;
return 0;
}
#pragma dont_inline reset
static inline pf_s32 PFENT_ITER_LoadEntry(PFITER_ENT_ITER* p_iter) {
pf_u32 success_size;
pf_s32 err;
if (p_iter->sector == -1) {
return 16;
}
err = PFSEC_ReadData(p_iter->p_vol, p_iter->buf, p_iter->sector, p_iter->offset, 0x20U, &success_size, 0U);
if (success_size != 0x20) {
return 17;
}
return err;
}
static inline pf_s32 PFENT_ITER_DoMoveTo(PFITER_ENT_ITER* p_iter, pf_u32 index, pf_u32 may_allocate) {
pf_u32 prev_index = p_iter->index;
pf_s32 err;
p_iter->index = index;
err = PFENT_RecalcEntryIterator(p_iter, may_allocate);
if (err != 0) {
p_iter->index = prev_index;
PFENT_RecalcEntryIterator(p_iter, 0U);
return err;
}
err = PFENT_ITER_LoadEntry(p_iter);
if (err != 0) {
return err;
}
return 0;
}
static inline void PFENT_ITER_MakeLongFileName(PFITER_ENT_ITER* p_iter, PF_DIR_ENT* p_ent) {
pf_s32 lengthName;
signed char filename[13];
lengthName = 0;
PFPATH_getLongNameformShortName(p_ent->short_name, filename, p_iter->buf[0xC]);
lengthName = PFPATH_transformInUnicode(p_ent->long_name, filename);
p_ent->num_entry_LFNs = ((lengthName % 13) ? 1 : 0) + (lengthName / 13);
p_ent->check_sum = PFENT_CalcCheckSum(p_ent);
p_ent->ordinal = 1;
}
static inline pf_s32 InitializeIterator(PFITER_ENT_ITER* p_iter, pf_u32 index) {
p_iter->p_vol = p_iter->ffd.p_vol;
p_iter->log2_entries_per_sector = p_iter->p_vol->bpb.log2_bytes_per_sector - 5;
p_iter->offset_mask = (1 << p_iter->log2_entries_per_sector) - 1;
p_iter->file_sector_index = -1U;
return PFENT_ITER_DoMoveTo(p_iter, index, 0);
}
static inline pf_s32 AdvanceIterator(PFITER_ENT_ITER* p_iter, pf_u32 may_allocate) {
pf_s32 err = PFENT_ITER_DoMoveTo(p_iter, p_iter->index + 1, may_allocate);
if (err != 0) return err;
return 0;
}
static inline void LoadNumericEntry(PFITER_ENT_ITER* p_iter, PF_DIR_ENT* p_ent) {
PFENT_loadEntryNumericFieldsFromBuf(p_ent, p_iter->buf);
p_ent->entry_sector = p_iter->sector;
p_ent->entry_offset = p_iter->offset;
p_ent->p_vol = p_iter->ffd.p_vol;
if ((p_ent->attr & 0x10) && p_ent->start_cluster == 0) p_ent->start_cluster = 1;
}
pf_s32 PFENT_ITER_DoFindEntry(PFITER_ENT_ITER* p_iter, PF_DIR_ENT* p_ent, PF_STR* p_pattern,
pf_u32 attr_required, pf_u32 attr_forbidden, pf_bool* p_is_found) {
pf_s32 err = 0;
pf_u32 index_search_from;
pf_u32 is_extsfn = 0;
*p_is_found = 0;
if (PFSTR_StrCmp(p_pattern, (pf_s8*)"..") == 0 && (p_ent->attr & 0x10) && p_ent->start_cluster == 1) return 2;
if (PFSTR_StrCmp(p_pattern, (pf_s8*)".") == 0) {
*p_is_found = 1;
return 0;
}
p_ent->num_entry_LFNs = 0;
p_ent->ordinal = 0;
p_ent->check_sum = 0;
p_ent->long_name[0] = 0;
if ((pf_vol_set.setting & 2) == 2) is_extsfn = PFPATH_GetExtShortNameIndex(p_pattern, &index_search_from);
if (is_extsfn == 1) {
for (err = InitializeIterator(p_iter, index_search_from - 1);; err = PFENT_ITER_Retreat(p_iter, 0)) {
pf_s32 attr;
if (err != 0) return err;
if ((p_iter->buf[11] & 15) == 15) {
if (PFENT_LoadLFNEntryFieldsFromBuf(p_ent, p_iter->buf) != 0) return 3;
if (!(p_iter->buf[0] & 0x40)) continue;
} else return 0;
err = InitializeIterator(p_iter, index_search_from);
if (err != 0) return err;
attr = p_iter->buf[11];
if (attr == 0) attr = 0x40;
if (attr_required & 0x80) {
attr_required &= 0x7f;
attr_forbidden &= 0x7f;
if ((attr_required && (pf_s32)(attr_required & attr) != (pf_s32)attr_required) ||
(attr_forbidden && (pf_s32)(attr_forbidden & attr) == (pf_s32)attr_forbidden)) err = -1;
} else if (attr_required != 0x7f && attr != attr_required &&
(!(attr & attr_required) || (attr & attr_forbidden))) err = -1;
if (err == -1) return 0;
if (attr & 8) return 3;
PFENT_LoadShortNameFromBuf(p_ent, p_iter->buf);
if (PFPATH_MatchFileNameWithPattern(p_ent->short_name, p_pattern, 0)) {
LoadNumericEntry(p_iter, p_ent);
*p_is_found = 1;
return 0;
}
goto finish;
}
}
for (; PFENT_ITER_IsAtLogicalEnd(p_iter) == PF_FALSE; err = AdvanceIterator(p_iter, 0)) {
pf_s32 attr;
if (err != 0) return err;
if (p_iter->buf[0] == 0) break;
if (p_iter->buf[0] == 0xe5) {
p_ent->num_entry_LFNs = 0;
p_ent->long_name[0] = 0;
continue;
}
attr = p_iter->buf[11];
if ((attr & 15) == 15) {
if (PFENT_LoadLFNEntryFieldsFromBuf(p_ent, p_iter->buf) != 0) {
p_ent->num_entry_LFNs = 0;
p_ent->long_name[0] = 0;
}
continue;
}
if (attr == 0) attr = 0x40;
if (attr_required & 0x80) {
attr_required &= 0x7f;
attr_forbidden &= 0x7f;
if ((attr_required && (pf_s32)(attr_required & attr) != (pf_s32)attr_required) ||
(attr_forbidden && (pf_s32)(attr_forbidden & attr) == (pf_s32)attr_forbidden)) err = -1;
} else if ((pf_u8)attr_required != 0x7f && (pf_u32)attr != (pf_u8)attr_required &&
(!(attr & (pf_u8)attr_required) || (attr & (pf_u8)attr_forbidden))) err = -1;
if (err == -1) {
p_ent->num_entry_LFNs = 0;
p_ent->long_name[0] = 0;
continue;
}
if (attr & 8) {
p_ent->num_entry_LFNs = 0;
p_ent->long_name[0] = 0;
}
PFENT_LoadShortNameFromBuf(p_ent, p_iter->buf);
if (p_ent->num_entry_LFNs && p_ent->ordinal == 1 && p_ent->check_sum == PFENT_CalcCheckSum(p_ent) &&
PFPATH_MatchFileNameWithPattern((pf_s8*)p_ent->long_name, p_pattern, 1)) {
LoadNumericEntry(p_iter, p_ent);
*p_is_found = 1;
return 0;
}
if (PFPATH_MatchFileNameWithPattern(p_ent->short_name, p_pattern, 0)) {
if (p_iter->buf[12] & 0x18) PFENT_ITER_MakeLongFileName(p_iter, p_ent);
LoadNumericEntry(p_iter, p_ent);
*p_is_found = 1;
return 0;
}
p_ent->num_entry_LFNs = 0;
p_ent->long_name[0] = 0;
}
finish:
return 0;
}
pf_s32 PFENT_ITER_DoGetEntry(PFITER_ENT_ITER* p_iter, PF_DIR_ENT* p_ent, PF_VOLUME* p_vol, PF_STR* p_path, pf_bool wildcard,
pf_bool no_look_last_token) {
pf_s8* p;
PF_STR token;
pf_bool is_found;
PFITER_FAT_HINT hint;
pf_u32 start_cluster;
PF_DIR_ENT current_ent;
pf_s32 err;
pf_u32 code_mode;
if (PFSTR_StrNCmp(p_path, (pf_s8*)":", 1, 1, 1) == 0) {
PFSTR_MoveStrPos(p_path, 2);
}
if ((PFSTR_StrNCmp(p_path, (pf_s8*)"\\", 1, 0, 1) == 0 || PFSTR_StrNCmp(p_path, (pf_s8*)"/", 1, 0, 1) == 0)) {
err = PFENT_GetRootDir(p_vol, p_ent);
if (err != 0) {
return err;
}
if (PFSTR_StrNumChar(p_path, 1) == 1 && (PFSTR_StrNCmp(p_path, (pf_s8*)"\0", 2, 0, 1) == 0)) {
return 0;
}
} else {
err = PFVOL_GetCurrentDir(p_vol, p_ent);
if (err != 0) {
return err;
}
}
p = PFSTR_GetStrPos(p_path, 1);
PFFAT_InitFFD(&p_iter->ffd, &hint, p_vol, &p_iter->ffd.current_start_cluster);
p_iter->ffd.current_start_cluster = p_ent->start_cluster;
code_mode = PFSTR_GetCodeMode(p_path);
PFPATH_InitTokenOfPath(&token, p, code_mode);
for (err = PFPATH_GetNextTokenOfPath(&token, wildcard); token.p_head != 0; err = PFPATH_GetNextTokenOfPath(&token, wildcard)) {
if (err != 0) {
return err;
}
if (no_look_last_token != 0 && (PFSTR_StrNCmp(&token, (pf_s8*)"\0", 2, 0, 1) == 0)) {
break;
}
if ((p_ent->attr & 0x10) == 0) {
return 2;
}
if (PFSTR_StrLen(&token) == 0) {
return 2;
}
p_iter->ffd.current_start_cluster = p_ent->start_cluster;
PFFAT_ResetFFD(&p_iter->ffd, &p_iter->ffd.current_start_cluster);
err = InitializeIterator(p_iter, 0);
if (err != 0) {
return err;
}
start_cluster = *p_iter->ffd.p_start_cluster;
err = PFENT_ITER_DoFindEntry(p_iter, p_ent, &token, 0x7F, 0, &is_found);
if (err != 0) {
return err;
}
if (!is_found) {
err = PFPATH_GetNextTokenOfPath(&token, wildcard);
if (err != 0) {
return err;
}
return (token.p_head == PF_NULL) + 2;
}
if (!wildcard) {
if ((p_ent->attr & 0x10) != 0 && p_ent->start_cluster == 1) {
p_ent->path_len = 3;
continue;
}
if ((p_ent->attr & 0x10) != 0 && p_ent->short_name[0] == '.' && p_ent->short_name[1] == '.') {
PFFAT_ResetFFD(&p_iter->ffd, &p_ent->start_cluster);
err = InitializeIterator(p_iter, 0);
if (err != 0) {
return err;
}
current_ent.attr = p_ent->attr;
current_ent.start_cluster = p_ent->start_cluster;
err = PFENT_ITER_FindDirEntryFromCluster(p_iter, &current_ent, start_cluster, &is_found);
if (err != 0) {
return err;
}
if (is_found == 0) {
return 2;
}
if (current_ent.num_entry_LFNs != 0) {
p_ent->path_len -= PFPATH_GetLengthFromUnicode(current_ent.long_name);
} else {
p_ent->path_len -= PFPATH_GetLengthFromShortname(&current_ent.short_name[0]);
}
p_ent->path_len--;
continue;
}
if ((p_ent->attr & 0x10) == 0 || p_ent->short_name[0] != '.') {
p_ent->path_len = (PFSTR_StrNumChar(&token, 1) + 1) + p_ent->path_len;
if ((PFSTR_StrNCmp(&token, (pf_s8*)"\0", 2, 0, 1) != 0)) {
p_ent->path_len -= PFSTR_StrNumChar(&token, 2);
}
}
continue;
}
}
return 0;
}
pf_s32 PFENT_ITER_IteratorInitialize(PFITER_ENT_ITER* p_iter, pf_u32 index_start_from) {
pf_s32 err;
p_iter->p_vol = p_iter->ffd.p_vol;
p_iter->log2_entries_per_sector = p_iter->p_vol->bpb.log2_bytes_per_sector - 5;
p_iter->offset_mask = (1 << p_iter->log2_entries_per_sector) - 1;
p_iter->file_sector_index = -1;
err = PFENT_ITER_DoMoveTo(p_iter, index_start_from, 0U);
return err;
}
pf_bool PFENT_ITER_IsAtLogicalEnd(PFITER_ENT_ITER* p_iter) {
pf_s32 err;
pf_u32 save_index;
pf_u32 save_fsindex;
if (p_iter->sector == -1U || p_iter->buf[0] == 0 || p_iter->index >= (1000000 - 1)) {
save_index = p_iter->index;
save_fsindex = p_iter->file_sector_index;
p_iter->index = (p_iter->file_sector_index + 1) << p_iter->log2_entries_per_sector;
err = PFENT_RecalcEntryIterator(p_iter, PF_FALSE);
if (err != 0) {
p_iter->index = save_index;
p_iter->file_sector_index = save_fsindex;
return PF_TRUE;
}
if (p_iter->sector != -1) {
err = PFENT_ITER_LoadEntry(p_iter);
if (err != 0) {
return PF_TRUE;
}
return PF_FALSE;
}
return PF_TRUE;
}
return PF_FALSE;
}
pf_s32 PFENT_ITER_MoveTo(PFITER_ENT_ITER* p_iter, pf_u32 index, pf_u32 may_allocate) {
pf_s32 err;
if (p_iter->index != index || p_iter->sector != -1U || may_allocate == PF_FALSE) {
err = PFENT_ITER_DoMoveTo(p_iter, index, may_allocate);
if (err != 0) {
return err;
}
}
return 0;
}
pf_s32 PFENT_ITER_Advance(PFITER_ENT_ITER* p_iter, pf_u32 may_allocate) {
return PFENT_ITER_MoveTo(p_iter, p_iter->index + 1, may_allocate);
}
pf_s32 PFENT_ITER_FindCluster(PF_DIR_ENT* p_ent, pf_u32 cluster, pf_bool* p_is_found) {
PFITER_FAT_HINT hint;
pf_u32 entries_per_sector;
pf_u32 current_cluster;
PFITER_ENT_ITER iter;
pf_u32 sector_index;
pf_s32 err;
*p_is_found = 0;
if (p_ent->entry_sector < p_ent->p_vol->bpb.first_data_sector) return 0;
current_cluster = (p_ent->entry_sector - p_ent->p_vol->bpb.first_data_sector) >> p_ent->p_vol->bpb.log2_sectors_per_cluster;
sector_index = (p_ent->p_vol->bpb.sectors_per_cluster - 1) & (p_ent->entry_sector - p_ent->p_vol->bpb.first_data_sector);
if (current_cluster == cluster) {
*p_is_found = 1;
return 0;
}
iter.ffd.p_start_cluster = &current_cluster;
iter.ffd.p_hint = &hint;
iter.ffd.p_vol = p_ent->p_vol;
iter.ffd.start_cluster = 1;
iter.ffd.cluster_link.buffer = PF_NULL;
iter.log2_entries_per_sector = p_ent->p_vol->bpb.log2_bytes_per_sector - 5;
iter.file_sector_index = sector_index;
entries_per_sector = 1 << iter.log2_entries_per_sector;
iter.offset_mask = entries_per_sector - 1;
iter.p_vol = p_ent->p_vol;
iter.sector = p_ent->entry_sector;
iter.offset = p_ent->entry_offset;
iter.index = ((pf_u32)p_ent->entry_offset >> 5) + sector_index * entries_per_sector;
hint.chain_index = 0;
hint.cluster = current_cluster;
hint.previous_cluster = 1;
if (iter.index < 2) {
hint.chain_index = 1;
iter.file_sector_index += p_ent->p_vol->bpb.sectors_per_cluster;
iter.index += entries_per_sector << p_ent->p_vol->bpb.log2_sectors_per_cluster;
}
while (iter.index != 0) {
err = PFENT_ITER_LoadEntry(&iter);
if (err != 0) return err;
if (pf_strncmp((pf_s8*)iter.buf, (pf_s8*)"..", 2) == 0) break;
err = PFENT_ITER_Retreat(&iter, 0);
if (err != 0) return err;
if (current_cluster == cluster) {
*p_is_found = 1;
return 0;
}
if (current_cluster <= 2) return 0;
if (iter.index < 1) {
++hint.chain_index;
iter.file_sector_index += p_ent->p_vol->bpb.sectors_per_cluster;
iter.index += (1 << iter.log2_entries_per_sector) << p_ent->p_vol->bpb.log2_sectors_per_cluster;
}
}
current_cluster = (PF_SWAP_16(*(pf_u16*)&iter.buf[20]) << 16) | PF_SWAP_16(*(pf_u16*)&iter.buf[26]);
hint.chain_index = 0;
iter.file_sector_index = 0;
hint.cluster = current_cluster;
iter.sector = p_ent->p_vol->bpb.first_data_sector + ((current_cluster - 2) << p_ent->p_vol->bpb.log2_sectors_per_cluster);
iter.offset = 32;
iter.index = 1;
while (current_cluster > 2) {
err = PFENT_ITER_LoadEntry(&iter);
if (err != 0) return err;
if (pf_strncmp((pf_s8*)iter.buf, (pf_s8*)"..", 2) == 0) {
if (current_cluster == cluster) {
*p_is_found = 1;
return 0;
}
current_cluster = (PF_SWAP_16(*(pf_u16*)&iter.buf[20]) << 16) | PF_SWAP_16(*(pf_u16*)&iter.buf[26]);
hint.cluster = current_cluster;
iter.sector = p_ent->p_vol->bpb.first_data_sector + ((current_cluster - 2) << p_ent->p_vol->bpb.log2_sectors_per_cluster);
} else return 0;
}
return 0;
}
pf_s32 PFENT_ITER_Retreat(PFITER_ENT_ITER* p_iter, pf_u32 may_allocate) {
pf_u32 before_cluster;
pf_u32 cur_cluster;
pf_s32 err;
if (p_iter->index == 0) {
return 0;
}
if (p_iter->file_sector_index != ((p_iter->index - 1) >> p_iter->log2_entries_per_sector)) {
cur_cluster = ((p_iter->sector - p_iter->p_vol->bpb.first_data_sector) >> p_iter->p_vol->bpb.log2_sectors_per_cluster) + 2;
if ((p_iter->file_sector_index % p_iter->p_vol->bpb.sectors_per_cluster) == 0 || p_iter->p_vol->bpb.sectors_per_cluster == 1) {
if (p_iter->p_vol->bpb.fat_type == FAT_32 ||
(*p_iter->ffd.p_start_cluster > 1 && p_iter->p_vol->bpb.first_data_sector <= p_iter->sector)) {
err = PFFAT_getBeforeChain(p_iter->p_vol, cur_cluster, cur_cluster, &before_cluster);
if (err != 0) {
return err;
}
if (before_cluster == -1) {
return 14;
}
} else {
before_cluster = *p_iter->ffd.p_start_cluster;
}
} else {
before_cluster = cur_cluster;
}
p_iter->index--;
p_iter->file_sector_index--;
if (p_iter->p_vol->bpb.fat_type == FAT_32 || *p_iter->ffd.p_start_cluster > 1 && p_iter->p_vol->bpb.first_data_sector <= p_iter->sector) {
p_iter->sector = (p_iter->p_vol->bpb.first_data_sector + ((before_cluster - 2) << p_iter->p_vol->bpb.log2_sectors_per_cluster)) +
(p_iter->file_sector_index & (p_iter->p_vol->bpb.sectors_per_cluster - 1));
} else {
p_iter->sector--;
}
p_iter->offset = (p_iter->index & p_iter->offset_mask) * 0x20;
return 0;
}
return PFENT_ITER_MoveTo(p_iter, p_iter->index - 1, may_allocate);
}
pf_s32 PFENT_ITER_FindDirEntryFromCluster(PFITER_ENT_ITER* p_iter, PF_DIR_ENT* p_ent, pf_u32 cluster, pf_bool* p_is_found) {
pf_u8 attr;
pf_s32 err = 0;
*p_is_found = PF_FALSE;
p_ent->num_entry_LFNs = 0;
p_ent->ordinal = 0;
p_ent->check_sum = 0;
if ((p_ent->attr & 0x10) && p_ent->start_cluster == 1) return 2;
for (; PFENT_ITER_IsAtLogicalEnd(p_iter) == PF_FALSE; err = AdvanceIterator(p_iter, PF_FALSE)) {
if (err != 0) {
return err;
}
if (p_iter->buf[0] == 0xE5) {
p_ent->num_entry_LFNs = 0;
p_ent->long_name[0] = 0;
continue;
}
attr = p_iter->buf[0xB];
if ((attr & (0x01 | 0x02 | 0x04 | 0x08)) == (0x01 | 0x02 | 0x04 | 0x08)) {
err = PFENT_LoadLFNEntryFieldsFromBuf(p_ent, p_iter->buf);
if (err != 0) {
p_ent->num_entry_LFNs = 0;
p_ent->long_name[0] = 0;
}
continue;
}
if ((attr & 0x08) != 0) {
p_ent->num_entry_LFNs = 0;
p_ent->long_name[0] = 0;
continue;
}
if ((attr & 0x10) == 0) {
p_ent->num_entry_LFNs = 0;
p_ent->long_name[0] = 0;
continue;
}
PFENT_LoadShortNameFromBuf(p_ent, p_iter->buf);
if (p_ent->num_entry_LFNs != 0 && p_ent->ordinal == 1 && p_ent->check_sum == PFENT_CalcCheckSum(p_ent)) {
PFENT_loadEntryNumericFieldsFromBuf(p_ent, p_iter->buf);
p_ent->entry_sector = p_iter->sector;
p_ent->entry_offset = p_iter->offset;
p_ent->p_vol = p_iter->ffd.p_vol;
if ((p_ent->attr & 0x10) != 0 && p_ent->start_cluster != cluster) {
p_ent->num_entry_LFNs = 0;
p_ent->long_name[0] = 0;
continue;
}
if ((p_ent->attr & 0x10) != 0 && p_ent->start_cluster == 0) {
p_ent->start_cluster = 1;
}
*p_is_found = 1;
}
if ((p_iter->buf[0xC] & (0x10 | 0x08)) != 0) {
PFENT_ITER_MakeLongFileName(p_iter, p_ent);
}
PFENT_loadEntryNumericFieldsFromBuf(p_ent, p_iter->buf);
p_ent->entry_sector = p_iter->sector;
p_ent->entry_offset = p_iter->offset;
p_ent->p_vol = p_iter->ffd.p_vol;
if ((p_ent->attr & 0x10) && p_ent->start_cluster != cluster) {
p_ent->num_entry_LFNs = 0;
p_ent->long_name[0] = 0;
*p_is_found = 0;
continue;
}
if ((p_ent->attr & 0x10) && p_ent->start_cluster == 0) p_ent->start_cluster = 1;
*p_is_found = 1;
return 0;
}
return 0;
}
pf_s32 PFENT_ITER_FindEntry(PFITER_ENT_ITER* p_iter, PF_DIR_ENT* p_ent, PF_STR* p_pattern,
pf_u32 attr_required, pf_u32 attr_forbidden, pf_bool* p_is_found) {
pf_s32 err;
*p_is_found = 0;
if (attr_required & attr_forbidden) return 10;
if (PFSTR_StrNCmp(p_pattern, (pf_s8*)":", 1, 1, 1) == 0) PFSTR_MoveStrPos(p_pattern, 2);
if (PFSTR_StrNCmp(p_pattern, (pf_s8*)"\\", 1, 0, 1) == 0 || PFSTR_StrNCmp(p_pattern, (pf_s8*)"/", 1, 0, 1) == 0) {
err = PFENT_GetRootDir(p_iter->p_vol, p_ent);
if (err != 0) return err;
if (PFSTR_StrNumChar(p_pattern, 1) == 1 && PFSTR_StrNCmp(p_pattern, (pf_s8*)"\0", 2, 0, 1) == 0) return 0;
} else {
err = PFVOL_GetCurrentDir(p_iter->p_vol, p_ent);
if (err != 0) return err;
}
err = PFENT_ITER_DoFindEntry(p_iter, p_ent, p_pattern, attr_required, attr_forbidden, p_is_found);
if (err != 0) return err;
return 0;
}
pf_s32 PFENT_ITER_FindEntryNoPathCheck(PFITER_ENT_ITER* p_iter, PF_DIR_ENT* p_ent, PF_STR* p_pattern,
pf_u32 attr_required, pf_u32 attr_forbidden, pf_bool* p_is_found) {
pf_s32 err;
*p_is_found = 0;
if (attr_required & attr_forbidden) return 10;
err = PFENT_ITER_DoFindEntry(p_iter, p_ent, p_pattern, attr_required, attr_forbidden, p_is_found);
if (err != 0) return err;
return 0;
}
pf_s32 PFENT_ITER_GetEntryOfPath(PFITER_ENT_ITER* p_iter, PF_DIR_ENT* p_ent, PF_VOLUME* p_vol, PF_STR* p_path, pf_u32 no_look_last_token) {
return PFENT_ITER_DoGetEntry(p_iter, p_ent, p_vol, p_path, 0, no_look_last_token);
}
pf_s32 PFENT_ITER_GetEntryOfPattern(PFITER_ENT_ITER* p_iter, PF_DIR_ENT* p_ent, PF_VOLUME* p_vol, PF_STR* p_path) {
return PFENT_ITER_DoGetEntry(p_iter, p_ent, p_vol, p_path, 1, 1);
}
pf_s32 PFENT_ITER_GetEntryOfIter(PFITER_ENT_ITER* p_iter, PF_DIR_ENT* p_ent) {
PFENT_LoadShortNameFromBuf(p_ent, p_iter->buf);
PFENT_loadEntryNumericFieldsFromBuf(p_ent, p_iter->buf);
p_ent->entry_sector = p_iter->sector;
p_ent->entry_offset = p_iter->offset;
p_ent->p_vol = p_iter->p_vol;
return 0;
}
pf_s32 PFENT_ITER_GetLFNEntryName(PFITER_ENT_ITER* p_iter, PF_DIR_ENT* p_ent) {
pf_u32 i;
pf_s32 err;
if (p_ent->num_entry_LFNs != 0 && !(p_ent->small_letter_flag & 0x18)) {
for (i = 0; i < p_ent->num_entry_LFNs; ++i) {
pf_u16* destination;
err = PFENT_ITER_Retreat(p_iter, 0);
if (err != 0) return err;
err = PFENT_ITER_LoadEntry(p_iter);
if (err != 0) return err;
destination = &p_ent->long_name[(i * 26U) / 2U];
pf_memcpy(destination, &p_iter->buf[1], 10);
pf_memcpy(destination + 5, &p_iter->buf[14], 12);
pf_memcpy(destination + 11, &p_iter->buf[28], 4);
}
p_ent->long_name[(p_ent->num_entry_LFNs * 26U) / 2U] = 0;
}
return 0;
}

View File

@@ -21,22 +21,19 @@ typedef struct NWC24MsgObjPrivate {
u32 type; // 0x04
u32 length; // 0x08
u32 appId; // 0x0C
#if defined(NWC24_MBOX_CTRL) || defined(NWC24_MSG_COMMIT)
#ifdef NWC24_MBOX_CTRL
u32 unk_0x10;
#else
u8 unk_0x10[0x4];
#endif
u32 tag; // 0x14
u32 ledPattern; // 0x18
#if defined(NWC24_MBOX_CTRL) || defined(NWC24_MSG_COMMIT)
#ifdef NWC24_MBOX_CTRL
u32 unk_0x1C;
#endif
#if defined(NWC24_MBOX_CTRL) || defined(NWC24_MSG_COMMIT)
#ifdef NWC24_MBOX_CTRL
union {
NWC24UserId fromId;
#ifdef NWC24_MSG_COMMIT
NWC24Data fromAddr;
#endif
struct { u32 fromIdHigh, fromIdLow; };
};
#else

View File

@@ -243,11 +243,10 @@ BOOL NWC24iIsMsgObjReadable(const MBCEntry* entry) {
NWC24Err NWC24GetMsgIdList(NWC24MBoxType type, u32* ids, u32 maxLength) {
MBCHeader* header;
NWC24File file;
NWC24Err result;
NWC24Err result, err, closeResult;
u32 count, offset;
char* path;
NWC24Err err, closeResult;
u32 offset;
u32 count;
u32* next;
MBCEntry* entry;
if (!NWC24IsMsgLibOpened() && !NWC24IsMsgLibOpenedByTool())
return NWC24_ERR_LIB_NOT_OPENED;
@@ -263,6 +262,7 @@ NWC24Err NWC24GetMsgIdList(NWC24MBoxType type, u32* ids, u32 maxLength) {
if (result != NWC24_OK)
return result;
count = 0;
next = ids;
for (offset = 128; offset < header->fileSize; offset += 128) {
err = NWC24FSeek(&file, offset, NWC24_SEEK_BEG);
if (err != NWC24_OK) {
@@ -275,7 +275,7 @@ NWC24Err NWC24GetMsgIdList(NWC24MBoxType type, u32* ids, u32 maxLength) {
break;
}
if (entry->msgId != 0 && entry->msgId <= 1000000) {
ids[count] = entry->msgId;
*next++ = entry->msgId;
++count;
if (count == header->numMessages) {
result = NWC24_OK;
@@ -560,30 +560,28 @@ static inline void GetOldestMsgId(const MBCHeader* header, u32* id) {
}
NWC24Err NWC24iMBoxCheck(NWC24MBoxType type, u32 size) {
u32 oldestId;
u32 required;
struct {
u32 oldestId;
MBCHeader* header;
} mailbox;
MBCHeader* header;
NWC24Err err;
if (size >= 0x31C00)
return NWC24_ERR_OVERFLOW;
required = size + 0x4000;
err = GetCachedMBCHeader(type, &mailbox.header);
err = GetCachedMBCHeader(type, &header);
if (err != NWC24_OK)
return err;
if (type == NWC24_MBOX_TYPE_SEND) {
if (mailbox.header->numMessages >= mailbox.header->capacity)
if (header->numMessages >= header->capacity)
return NWC24_ERR_FULL;
if (mailbox.header->freeBytes <= required)
if (header->freeBytes <= required)
return NWC24_ERR_FULL;
} else if (type == NWC24_MBOX_TYPE_RECV) {
while (mailbox.header->numMessages >= mailbox.header->capacity || mailbox.header->freeBytes <= required) {
GetOldestMsgId(mailbox.header, &mailbox.oldestId);
err = DeleteMsg(type, mailbox.oldestId, FALSE);
while (header->numMessages >= header->capacity || header->freeBytes <= required) {
GetOldestMsgId(header, &oldestId);
err = DeleteMsg(type, oldestId, FALSE);
if (err != NWC24_OK)
return err;
err = GetCachedMBCHeader(type, &mailbox.header);
err = GetCachedMBCHeader(type, &header);
if (err != NWC24_OK)
return err;
}
@@ -666,14 +664,13 @@ static inline int CompareMsgId(u32 left, u32 right) {
static NWC24Err DeleteMsg(NWC24MBoxType type, u32 id, BOOL protect) {
MBCHeader* header;
NWC24File file;
NWC24Err result;
u32 count = 0;
u32 offset;
u32 foundOffset = 0;
u32 oldest = 0;
MBCEntry* entry;
char* path;
NWC24Err err, deleteResult, closeResult;
u32 count = 0;
u32 foundOffset = 0;
u32 oldest = 0;
u32 offset;
NWC24Err err, result, clearResult, deleteResult, writeResult, closeResult;
if (!NWC24IsMsgLibOpened() && !NWC24IsMsgLibOpenedByTool())
return NWC24_ERR_LIB_NOT_OPENED;
entry = (MBCEntry*)NWC24WorkP->unk_0x1800;
@@ -690,15 +687,11 @@ static NWC24Err DeleteMsg(NWC24MBoxType type, u32 id, BOOL protect) {
result = NWC24_ERR_NOT_FOUND;
for (offset = 128; offset < header->fileSize; offset += 128) {
err = NWC24FSeek(&file, offset, NWC24_SEEK_BEG);
if (err != NWC24_OK) {
result = err;
if (err != NWC24_OK)
break;
}
err = NWC24FRead(entry, 128, &file);
if (err != NWC24_OK) {
result = err;
if (err != NWC24_OK)
break;
}
if (entry->msgId == 0)
continue;
++count;
@@ -706,12 +699,12 @@ static NWC24Err DeleteMsg(NWC24MBoxType type, u32 id, BOOL protect) {
if (protect) {
if ((entry->type & 2) && entry->appId == 0) {
if (NWC24GetAppId() != 0x48414541) {
result = NWC24_ERR_PROTECTED;
err = NWC24_ERR_PROTECTED;
break;
}
} else if ((entry->appId & 0xFFFFFF00) != (NWC24GetAppId() & 0xFFFFFF00)) {
if (!(entry->type & 8) || NWC24GetAppId() != 0x48414541) {
result = NWC24_ERR_PROTECTED;
err = NWC24_ERR_PROTECTED;
break;
}
}
@@ -721,43 +714,41 @@ static NWC24Err DeleteMsg(NWC24MBoxType type, u32 id, BOOL protect) {
} else if (oldest == 0 || CompareMsgId(oldest, entry->msgId) > 0)
oldest = entry->msgId;
}
err = result;
if (offset >= header->fileSize)
err = result;
if (err == NWC24_ERR_NOT_FOUND && header->numMessages != count) {
header->numMessages = count;
WriteMBCHeader(header, &file);
if (NWC24FSeek(&file, 0, NWC24_SEEK_BEG) == NWC24_OK)
NWC24FWrite(header, 128, &file);
}
if (err != NWC24_OK) {
NWC24FClose(&file);
return id == 0 ? NWC24_ERR_INVALID_VALUE : err;
}
header->oldestId = oldest;
protect = ClearMBCEntry(header, &file, foundOffset);
clearResult = ClearMBCEntry(header, &file, foundOffset);
deleteResult = DeleteMsgFile(type, id);
if (protect != NWC24_OK)
deleteResult = protect;
type = WriteMBCHeader(header, &file);
if (clearResult != NWC24_OK)
deleteResult = clearResult;
writeResult = NWC24FSeek(&file, 0, NWC24_SEEK_BEG);
if (writeResult == NWC24_OK)
writeResult = NWC24FWrite(header, 128, &file);
if (deleteResult != NWC24_OK)
type = deleteResult;
writeResult = deleteResult;
closeResult = NWC24FClose(&file);
return type != NWC24_OK ? type : closeResult;
return writeResult != NWC24_OK ? writeResult : closeResult;
}
static NWC24Err DuplicationCheck(MBCHeader* header, const NWC24MsgObjPrivate* msg, NWC24File* file, NWC24MBoxType type) {
NWC24Err err = NWC24_OK;
u32 offset;
u32 count = 0;
u32 duplicateId = 0;
u32 duplicateOffset = 0;
u32 oldest = 0;
MBCEntry* entry;
u32 count = 0, oldest = 0, duplicateId = 0, duplicateOffset = 0;
u32 offset;
BOOL candidate;
NWC24Err clearResult, deleteResult;
NWC24Err err = NWC24_OK, clearResult, deleteResult;
if (type == NWC24_MBOX_TYPE_SEND)
return NWC24_OK;
entry = (MBCEntry*)NWC24WorkP->unk_0x1800;
for (offset = 128; offset < header->fileSize; offset += 128) {
if (count >= header->numMessages)
break;
for (offset = 128; offset < header->fileSize && count < header->numMessages; offset += 128) {
err = NWC24FSeek(file, offset, NWC24_SEEK_BEG);
if (err != NWC24_OK)
break;
@@ -767,40 +758,31 @@ static NWC24Err DuplicationCheck(MBCHeader* header, const NWC24MsgObjPrivate* ms
if (entry->msgId == 0)
continue;
++count;
candidate = TRUE;
if (entry->msgId == msg->msgId)
candidate = FALSE;
candidate = entry->msgId != msg->msgId;
if (entry->type & msg->type & 1) {
if (entry->appId != msg->appId)
candidate = FALSE;
if (entry->fromId != msg->fromId)
candidate = FALSE;
}
if (candidate) {
if ((msg->tag & 0xFFFF) && (entry->tag & 0xFFFF) == (msg->tag & 0xFFFF)) {
duplicateId = entry->msgId;
duplicateOffset = offset;
continue;
}
if (msg->unk_0x1C != 0 && entry->crc == msg->unk_0x1C && entry->type == msg->type && entry->length == msg->length &&
entry->flags == msg->unk_0x10 && (s32)entry->date == (s32)msg->unk_0x28) {
duplicateId = entry->msgId;
duplicateOffset = offset;
continue;
}
if (candidate && (((msg->tag & 0xFFFF) && (entry->tag & 0xFFFF) == (msg->tag & 0xFFFF)) ||
(msg->unk_0x1C != 0 && entry->crc == msg->unk_0x1C && entry->type == msg->type && entry->length == msg->length &&
entry->flags == msg->unk_0x10 && entry->date == msg->unk_0x28))) {
duplicateOffset = offset;
duplicateId = entry->msgId;
} else {
if (oldest == 0 || CompareMsgId(oldest, entry->msgId) > 0)
oldest = entry->msgId;
}
if (oldest == 0 || CompareMsgId(oldest, entry->msgId) > 0)
oldest = entry->msgId;
}
if (err != NWC24_OK)
return err;
header->oldestId = oldest;
if (duplicateId != 0) {
clearResult = ClearMBCEntry(header, file, duplicateOffset);
deleteResult = DeleteMsgFile(type, duplicateId);
return clearResult != NWC24_OK ? clearResult : deleteResult;
}
return err;
if (duplicateId == 0)
return err;
clearResult = ClearMBCEntry(header, file, duplicateOffset);
deleteResult = DeleteMsgFile(type, duplicateId);
return clearResult != NWC24_OK ? clearResult : deleteResult;
}
static NWC24Err GetCachedMBCHeader(NWC24MBoxType type, MBCHeader** header) {

View File

@@ -1,906 +0,0 @@
#define NWC24_MSG_COMMIT
#include <private/nwc24.h>
#include <revolution/net/NETMisc.h>
#include <revolution/nwc24.h>
static char MultiPartDivider[64];
BOOL LoopBackEnable = TRUE;
static NWC24File* m_pFile;
static NWC24Err NWC24CommitMsgInternal(NWC24MsgObjPrivate* msg, NWC24MBoxType type);
static NWC24Err CheckMsgObject(const NWC24MsgObjPrivate* msg);
static NWC24Err CheckMsgBoxSpace(const NWC24MsgObjPrivate* msg, NWC24MBoxType type);
static NWC24Err SynthesizeAddrStr(const NWC24Data* address, u32 type, char* dest, s32 capacity, u32* length);
static NWC24Err WriteSMTP_MAILFROM(NWC24MsgObjPrivate* msg);
static NWC24Err WriteSMTP_RCPTTO(NWC24MsgObjPrivate* msg);
static NWC24Err WriteFromField(NWC24MsgObjPrivate* msg);
static NWC24Err WriteToField(NWC24MsgObjPrivate* msg);
static NWC24Err WriteDateField(NWC24MsgObjPrivate* msg);
static NWC24Err WriteXWiiAppIdField(NWC24MsgObjPrivate* msg);
static NWC24Err WriteXWiiFaceField(NWC24MsgObjPrivate* msg);
static NWC24Err WriteXWiiAltNameField(NWC24MsgObjPrivate* msg);
static NWC24Err WriteMIMEAttachHeader(NWC24MsgObjPrivate* msg, u32 index);
static NWC24Err WriteContentTypeField(NWC24MsgObjPrivate* msg);
static NWC24Err WritePlainText(NWC24MsgObjPrivate* msg);
static NWC24Err WriteBase64Data(const u8* data, s32 size, u32* length);
static NWC24Err WriteQPData(const u8* data, s32 size, u32* length);
NWC24Err NWC24iMBoxOpenNewMsg(NWC24MBoxType type, NWC24File* file, u32* id);
NWC24Err NWC24iMBoxCloseMsg(NWC24File* file);
NWC24Err NWC24iMBoxAddMsgObj(NWC24MBoxType type, NWC24MsgObjPrivate* msg);
NWC24Err NWC24iMBoxCancelMsg(NWC24File* file, NWC24MBoxType type, u32 id);
NWC24Err NWC24iMBoxFlushHeader(NWC24MBoxType type);
NWC24Err NWC24iMBoxCheck(NWC24MBoxType type, u32 size);
NWC24Err NWC24iDateToMinutes(u32* minutes, const NWC24Date* date);
NWC24Err NWC24iMinutesToDate(NWC24Date* date, u32 minutes);
static inline NWC24Err WriteString(NWC24MsgObjPrivate* msg, char* buffer) {
s32 length = Mail_strlen(buffer);
NWC24Err err = NWC24FWrite(buffer, length, m_pFile);
if (err == NWC24_OK)
msg->length += length;
return err;
}
#define CHECK_WRITE(operation) \
do { \
err = (operation); \
if (err != NWC24_OK) { \
NWC24FClose(&file); \
result = err; \
goto finish; \
} \
} while (0)
static inline NWC24Err WriteSubjectField(NWC24MsgObjPrivate* msg) {
char* buffer = NWC24WorkP->stringWork;
s32 length;
NWC24Err err;
if (msg->subject.size == 0)
return NWC24_ERR_NULL;
Mail_memset(buffer, 0, 1024);
Mail_strcpy(buffer, "Subject: ");
Mail_strncat(buffer, msg->subject.ptr, 1021);
Mail_strncat(buffer, "\r\n", 1024);
length = STD_strnlen(buffer, 1024);
err = NWC24FWrite(buffer, length, m_pFile);
if (err == NWC24_OK)
msg->length += length;
return err;
}
static inline NWC24Err WriteSMTPData(NWC24MsgObjPrivate* msg, const char* text) {
char* buffer = NWC24WorkP->stringWork;
s32 length;
NWC24Err err;
Mail_strcpy(buffer, text);
length = Mail_strlen(buffer);
err = NWC24FWrite(buffer, length, m_pFile);
if (err == NWC24_OK)
msg->length += 6;
return err;
}
static inline NWC24Err WriteCmdField(NWC24MsgObjPrivate* msg) {
char* buffer = NWC24WorkP->stringWork;
s32 length;
NWC24Err err;
if (msg->ledPattern == 0)
return NWC24_OK;
Mail_memset(buffer, 0, 1024);
Mail_sprintf(buffer, "X-Wii-Cmd: %08X\r\n", msg->ledPattern);
length = Mail_strlen(buffer);
err = NWC24FWrite(buffer, length, m_pFile);
if (err == NWC24_OK)
msg->length += length;
return err;
}
static inline NWC24Err WriteTagField(NWC24MsgObjPrivate* msg) {
char* buffer = NWC24WorkP->stringWork;
s32 length;
NWC24Err err;
if (msg->tag == 0)
return NWC24_OK;
Mail_memset(buffer, 0, 1024);
Mail_sprintf(buffer, "X-Wii-Tag: %08X\r\n", msg->tag);
length = Mail_strlen(buffer);
err = NWC24FWrite(buffer, length, m_pFile);
if (err == NWC24_OK)
msg->length += length;
return err;
}
static inline NWC24Err WriteDWCIdField(NWC24MsgObjPrivate* msg) {
char* buffer = NWC24WorkP->stringWork;
s32 length;
NWC24Err err;
if (!(msg->type & 0x2000))
return NWC24_OK;
Mail_memset(buffer, 0, 1024);
Mail_sprintf(buffer, "X-Wii-DWCId: %08X\r\n", msg->dwcId);
length = Mail_strlen(buffer);
err = NWC24FWrite(buffer, length, m_pFile);
if (err == NWC24_OK)
msg->length += length;
return err;
}
static inline NWC24Err WriteIconNewField(NWC24MsgObjPrivate* msg) {
char* buffer = NWC24WorkP->stringWork;
s32 length;
NWC24Err err;
if (msg->iconNew == 0 || msg->iconNew == 0x80000000)
return NWC24_OK;
Mail_memset(buffer, 0, 1024);
Mail_sprintf(buffer, "X-Wii-IconNew: %08X\r\n", msg->iconNew);
length = Mail_strlen(buffer);
err = NWC24FWrite(buffer, length, m_pFile);
if (err == NWC24_OK)
msg->length += length;
return err;
}
static inline NWC24Err WriteMessageIdField(NWC24MsgObjPrivate* msg) {
char* buffer = NWC24WorkP->stringWork;
const char* domain;
NWC24UserId myId;
char idText[32];
s32 length;
NWC24Err err;
domain = NWC24GetAccountDomain();
NWC24GetMyUserId(&myId);
Mail_memset(buffer, 0, 1024);
Mail_strcpy(buffer, "Message-Id: <");
Mail_memset(idText, 0, 32);
Mail_sprintf(idText, "%05X%08X%08X%08X", msg->msgId, (u32)(myId >> 32), (u32)myId, msg->unk_0x28);
Mail_strcat(buffer, idText);
Mail_strcat(buffer, domain);
Mail_strcat(buffer, ">\r\n");
length = Mail_strlen(buffer);
err = NWC24FWrite(buffer, length, m_pFile);
if (err == NWC24_OK)
msg->length += length;
return err;
}
NWC24Err NWC24CommitMsg(NWC24MsgObj* object) {
BOOL loopback = FALSE;
NWC24MsgObjPrivate* msg = (NWC24MsgObjPrivate*)object;
NWC24UserId myId;
if (!NWC24IsMsgLibOpened() && !NWC24IsMsgLibOpenedByTool())
return NWC24_ERR_LIB_NOT_OPENED;
if (!(msg->type & 0x100) || (msg->type & 0x200))
return NWC24_ERR_PROTECTED;
if (LoopBackEnable && (msg->type & 1)) {
NWC24GetMyUserId(&myId);
if (msg->numTo == 1 && msg->toIds[0] == myId)
loopback = TRUE;
}
return NWC24CommitMsgInternal(msg, loopback);
}
static NWC24Err NWC24CommitMsgInternal(NWC24MsgObjPrivate* msg, NWC24MBoxType type) {
NWC24File file;
NWC24Data attached[2];
NWC24Data subject;
NWC24Data text;
u32 id, encodedLength;
s32 initIndex;
u32 index;
char* buffer;
s32 length;
NWC24Err result, err;
NWC24Data_Init(&subject);
NWC24Data_Init(&text);
for (initIndex = 0; initIndex < 2; ++initIndex)
NWC24Data_Init(&attached[initIndex]);
NWC24iSetErrorCode(0);
result = CheckMsgObject(msg);
if (result != NWC24_OK)
goto report;
result = CheckMsgBoxSpace(msg, type);
if (result != NWC24_OK)
goto report;
err = NWC24iMBoxOpenNewMsg(type, &file, &id);
if (err != NWC24_OK) {
result = err;
goto finish;
}
{
msg->msgId = id;
msg->length = 0;
m_pFile = &file;
if (type == NWC24_MBOX_TYPE_SEND) {
CHECK_WRITE(WriteSMTP_MAILFROM(msg));
CHECK_WRITE(WriteSMTP_RCPTTO(msg));
CHECK_WRITE(WriteSMTPData(msg, "DATA\r\n"));
}
CHECK_WRITE(WriteDateField(msg));
CHECK_WRITE(WriteFromField(msg));
CHECK_WRITE(WriteToField(msg));
CHECK_WRITE(WriteMessageIdField(msg));
subject.ptr = (const void*)(msg->length + 9);
err = WriteSubjectField(msg);
if (err == NWC24_OK)
subject.size = msg->length - (u32)subject.ptr - 2;
else if (err == NWC24_ERR_NULL) {
err = NWC24_OK;
subject.ptr = NULL;
}
if (err != NWC24_OK) {
NWC24FClose(&file);
result = err;
goto finish;
}
if (msg->type & 1) {
CHECK_WRITE(WriteXWiiAppIdField(msg));
CHECK_WRITE(WriteCmdField(msg));
CHECK_WRITE(WriteTagField(msg));
CHECK_WRITE(WriteDWCIdField(msg));
CHECK_WRITE(WriteXWiiAltNameField(msg));
CHECK_WRITE(WriteXWiiFaceField(msg));
CHECK_WRITE(WriteIconNewField(msg));
if (msg->msgBoardFlags.raw != 0) {
if (msg->msgBoardFlags.raw & 0x80000000) {
buffer = NWC24WorkP->stringWork;
Mail_memset(buffer, 0, 1024);
Mail_strcpy(buffer, "X-Wii-MB-NoReply: -\r\n");
err = NWC24FWrite(buffer, 21, m_pFile);
if (err == NWC24_OK)
msg->length += 21;
if (err != NWC24_OK) {
NWC24FClose(&file);
result = err;
goto finish;
}
}
if (msg->msgBoardFlags.raw & 0xFFFF) {
buffer = NWC24WorkP->stringWork;
Mail_memset(buffer, 0, 1024);
Mail_sprintf(buffer, "X-Wii-MB-RegDate: %04X\r\n", msg->msgBoardFlags.raw & 0xFFFF);
length = STD_strnlen(buffer, 1024);
err = NWC24FWrite(buffer, length, m_pFile);
if (err == NWC24_OK)
msg->length += length;
if (err != NWC24_OK) {
NWC24FClose(&file);
result = err;
goto finish;
}
}
if (msg->msgBoardFlags.raw & 0xFF0000) {
buffer = NWC24WorkP->stringWork;
Mail_memset(buffer, 0, 1024);
Mail_sprintf(buffer, "X-Wii-MB-Delay: %02X\r\n", (msg->msgBoardFlags.raw >> 16) & 0xFF);
length = STD_strnlen(buffer, 1024);
err = NWC24FWrite(buffer, length, m_pFile);
if (err == NWC24_OK)
msg->length += length;
if (err != NWC24_OK) {
NWC24FClose(&file);
result = err;
goto finish;
}
}
}
}
if (msg->unk_0xD0.size != 0) {
err = NWC24FWrite(msg->unk_0xD0.ptr, msg->unk_0xD0.size, m_pFile);
if (err == NWC24_OK)
msg->length += msg->unk_0xD0.size;
if (err != NWC24_OK) {
NWC24FClose(&file);
result = err;
goto finish;
}
}
Mail_memset(MultiPartDivider, 0, 40);
Mail_sprintf(MultiPartDivider, "Boundary-NWC24-%08X%05X", msg->unk_0x28, msg->msgId);
buffer = NWC24WorkP->stringWork;
Mail_memset(buffer, 0, 1024);
Mail_strcpy(buffer, "MIME-Version: 1.0\r\n");
if (msg->type & 0x10000) {
Mail_strcat(buffer, "Content-Type: multipart/mixed;\r\n boundary=\"");
Mail_strcat(buffer, MultiPartDivider);
Mail_strcat(buffer, "\"\r\n");
}
CHECK_WRITE(WriteString(msg, buffer));
if (msg->type & 0x10000) {
msg->unk_0x10 = msg->length;
buffer = NWC24WorkP->stringWork;
Mail_memset(buffer, 0, 1024);
Mail_sprintf(buffer, "\r\n--%s", MultiPartDivider);
Mail_strcat(buffer, "\r\n");
CHECK_WRITE(WriteString(msg, buffer));
}
CHECK_WRITE(WriteContentTypeField(msg));
if (!(msg->type & 0x10000))
msg->unk_0x10 = msg->length;
text.ptr = (const void*)msg->length;
err = WritePlainText(msg);
if (err == NWC24_ERR_NULL)
err = NWC24_OK;
if (err != NWC24_OK) {
NWC24FClose(&file);
result = err;
goto finish;
}
text.size = msg->length - (u32)text.ptr;
for (index = 0; index < msg->numAttached; ++index) {
buffer = NWC24WorkP->stringWork;
Mail_memset(buffer, 0, 1024);
Mail_sprintf(buffer, "\r\n--%s", MultiPartDivider);
Mail_strcat(buffer, "\r\n");
CHECK_WRITE(WriteString(msg, buffer));
CHECK_WRITE(WriteMIMEAttachHeader(msg, index));
attached[index].ptr = (const void*)msg->length;
err = WriteBase64Data(msg->attached[index].ptr, msg->attached[index].size, &encodedLength);
msg->length += encodedLength;
if (err != NWC24_OK) {
NWC24FClose(&file);
result = err;
goto finish;
}
attached[index].size = msg->length - (u32)attached[index].ptr;
if (index == msg->numAttached - 1) {
buffer = NWC24WorkP->stringWork;
Mail_memset(buffer, 0, 1024);
Mail_sprintf(buffer, "\r\n--%s", MultiPartDivider);
Mail_strcat(buffer, "--\r\n");
CHECK_WRITE(WriteString(msg, buffer));
}
}
}
finish:
if (result == NWC24_OK) {
NWC24iMBoxCloseMsg(&file);
} else {
NWC24iMBoxCancelMsg(&file, type, id);
NWC24iMBoxFlushHeader(type);
goto report;
}
{
msg->subject = subject;
msg->text = text;
msg->attached[0] = attached[0];
msg->attached[1] = attached[1];
msg->type |= 0x200;
if (type == NWC24_MBOX_TYPE_RECV)
msg->type |= 0x20;
else if (type == NWC24_MBOX_TYPE_SEND)
msg->type |= 0x10;
err = NWC24iMBoxAddMsgObj(type, msg);
if (result != NWC24_OK)
err = result;
result = err;
if (type == NWC24_MBOX_TYPE_RECV) {
u32 flags = 1;
if (msg->type & 8)
flags |= 2;
NWC24iSetNewMsgArrived(flags);
}
}
report:
if (result == NWC24_ERR_FULL || (result <= -16 && result >= -21) || result == -38 || result == -41 || result == -43 || result == -46)
NWC24iSetErrorCode(result - 109300);
return result;
}
static NWC24Err CheckMsgObject(const NWC24MsgObjPrivate* msg) {
const char* subject;
if (msg->numTo == 0)
return NWC24_ERR_NULL;
if (msg->numTo > 8)
return NWC24_ERR_INVALID_VALUE;
subject = msg->subject.ptr;
if (subject != NULL) {
for (; *subject != '\0'; ++subject) {
if (*subject == '\r' && subject[1] != '\n')
return NWC24_ERR_FORMAT;
if (*subject == '\n' && subject[1] != ' ')
return NWC24_ERR_FORMAT;
}
}
if (msg->numAttached > 2)
return NWC24_ERR_INVALID_VALUE;
return NWC24_OK;
}
static NWC24Err CheckMsgBoxSpace(const NWC24MsgObjPrivate* msg, NWC24MBoxType type) {
u32 total = 0;
u32 textSize = 0;
s32 index;
NWC24Err err;
for (index = 0; index < msg->numAttached; ++index) {
u32 size = msg->attachedSize[index];
total += (size * 4 + 2) / 3 + size / 57 * 2 + 4;
}
switch (msg->encoding) {
case NWC24_ENC_7BIT:
case NWC24_ENC_8BIT:
textSize = msg->text.size;
break;
case NWC24_ENC_BASE64:
textSize = (msg->text.size * 4 + 2) / 3 + msg->text.size / 57 * 2 + 4;
break;
case NWC24_ENC_QUOTED_PRINTABLE:
textSize = msg->text.size * 4 / 3;
break;
default:
textSize = 0;
break;
}
total += textSize;
if (total >= 0x31C00)
return NWC24_ERR_OVERFLOW;
err = NWC24iMBoxCheck(type, total + 1024);
if (err != NWC24_OK)
return err;
return NWC24_OK;
}
static NWC24Err SynthesizeAddrStr(const NWC24Data* address, u32 type, char* dest, s32 capacity, u32* length) {
char id[32];
NWC24Err err = NWC24_OK;
const char* domain;
s32 domainLength, written;
if (type & 1) {
domain = NWC24GetAccountDomain();
domainLength = Mail_strlen(domain);
if (domainLength <= 0)
err = NWC24_ERR_CONFIG;
else if (domainLength + 18 >= capacity)
err = NWC24_ERR_NOMEM;
else {
NWC24iConvIdToStr(*(const NWC24UserId*)address, id);
written = Mail_sprintf(dest, "%c%s%s", 'w', id, domain);
if (written == 0)
err = NWC24_ERR_FATAL;
else
*length = written;
}
} else if (type & 2) {
if (address->size + 3 >= (u32)capacity)
err = NWC24_ERR_NOMEM;
else {
written = Mail_sprintf(dest, "%s", address->ptr);
if (written == 0)
err = NWC24_ERR_FATAL;
else
*length = written;
}
} else
err = NWC24_ERR_INVALID_VALUE;
return err;
}
static NWC24Err WriteSMTP_MAILFROM(NWC24MsgObjPrivate* msg) {
char* buffer = NWC24WorkP->stringWork;
char* address;
u32 length;
s32 total;
u32 type;
NWC24Err err;
Mail_memset(buffer, 0, 1024);
Mail_strncat(buffer, "MAIL FROM: ", 1022);
address = buffer + 11;
type = 1;
if (msg->type & 0x100000)
type = 2;
err = SynthesizeAddrStr(&msg->fromAddr, type, address, 1009, &length);
if (err != NWC24_OK)
return err;
{
address += length;
address[0] = '\r';
address[1] = '\n';
total = length + 13;
if ((s32)(1009 - length) <= 0)
return NWC24_ERR_NOMEM;
}
if (err == NWC24_OK) {
err = NWC24FWrite(NWC24WorkP->stringWork, total, m_pFile);
if (err == NWC24_OK)
msg->length += total;
}
return err;
}
static NWC24Err WriteSMTP_RCPTTO(NWC24MsgObjPrivate* msg) {
char* cursor = NWC24WorkP->stringWork;
u32 index;
s32 total = 0, remaining;
u32 length;
NWC24Err err = NWC24_OK;
Mail_memset(cursor, 0, 1024);
remaining = 1022;
for (index = 0; index < msg->numTo; ++index) {
Mail_strncat(cursor, "RCPT TO: ", remaining);
cursor += 9;
remaining -= 11;
err = SynthesizeAddrStr(&msg->toAddrs[index], msg->type, cursor, remaining, &length);
if (err != NWC24_OK)
break;
cursor += length;
cursor[0] = '\r';
cursor[1] = '\n';
cursor += 2;
remaining -= length;
total += length + 11;
if (remaining <= 0) {
err = NWC24_ERR_NOMEM;
break;
}
}
if (err == NWC24_OK) {
err = NWC24FWrite(NWC24WorkP->stringWork, total, m_pFile);
if (err == NWC24_OK)
msg->length += total;
}
return err;
}
static NWC24Err WriteFromField(NWC24MsgObjPrivate* msg) {
char* buffer = NWC24WorkP->stringWork;
char* address;
u32 length;
s32 total;
u32 type;
NWC24Err err;
Mail_memset(buffer, 0, 1024);
Mail_strncat(buffer, "From: ", 1022);
address = buffer + 6;
msg->unk_0x30.ptr = (const void*)(msg->length + 6);
type = 1;
if (msg->type & 0x100000)
type = 2;
err = SynthesizeAddrStr(&msg->fromAddr, type, address, 1014, &length);
if (err != NWC24_OK)
return err;
{
address += length;
address[0] = '\r';
address[1] = '\n';
total = length + 8;
if ((s32)(1014 - length) <= 0)
return NWC24_ERR_NOMEM;
}
if (err == NWC24_OK) {
err = NWC24FWrite(NWC24WorkP->stringWork, total, m_pFile);
if (err == NWC24_OK) {
msg->length += total;
msg->unk_0x30.size = msg->length - (u32)msg->unk_0x30.ptr - 2;
}
}
return err;
}
static NWC24Err WriteToField(NWC24MsgObjPrivate* msg) {
char* buffer = NWC24WorkP->stringWork;
char* cursor;
s32 index, total, remaining;
u32 length;
NWC24Err err = NWC24_OK;
Mail_memset(buffer, 0, 1024);
Mail_strncat(buffer, "To: ", 1022);
cursor = buffer + 4;
index = 0;
total = 4;
msg->unk_0x38.ptr = (const void*)(msg->length + 4);
remaining = 1018;
for (; index < msg->numTo; ++index) {
err = SynthesizeAddrStr(&msg->toAddrs[index], msg->type, cursor, remaining, &length);
if (err != NWC24_OK)
break;
remaining -= length;
cursor += length;
total += length;
if (remaining <= 4) {
err = NWC24_ERR_NOMEM;
break;
}
if (index < msg->numTo - 1) {
cursor[0] = ',';
cursor[1] = '\r';
cursor[2] = '\n';
cursor[3] = ' ';
total += 4;
remaining -= 4;
cursor += 4;
}
}
cursor[0] = '\r';
cursor[1] = '\n';
if (err == NWC24_OK) {
err = NWC24FWrite(NWC24WorkP->stringWork, total + 2, m_pFile);
if (err == NWC24_OK) {
msg->length += total + 2;
msg->unk_0x38.size = msg->length - (u32)msg->unk_0x38.ptr - 2;
}
}
return err;
}
static NWC24Err WriteDateField(NWC24MsgObjPrivate* msg) {
static const char* months[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
NWC24Date date;
OSCalendarTime calendar;
char* buffer;
s32 length;
NWC24Err err;
NWC24Date_Init(&date);
NETGetUniversalCalendar(&calendar);
date.year = calendar.year;
date.month = calendar.mon + 1;
date.day = calendar.mday;
date.hour = calendar.hour;
date.min = calendar.min;
date.sec = calendar.sec;
if (date.month > 12)
return NWC24_ERR_FORMAT;
NWC24iDateToMinutes(&msg->unk_0x28, &date);
if (msg->type & 0x1000000)
NWC24iMinutesToDate(&date, msg->unk_0x2C);
buffer = NWC24WorkP->stringWork;
Mail_memset(buffer, 0, 1024);
Mail_sprintf(buffer, "Date: %02d %s %d %02d:%02d:%02d -0000\r\n", date.day, months[date.month - 1], date.year, date.hour, date.min, date.sec);
length = Mail_strlen(buffer);
err = NWC24FWrite(buffer, length, m_pFile);
if (err == NWC24_OK)
msg->length += length;
return err;
}
static NWC24Err WriteXWiiAppIdField(NWC24MsgObjPrivate* msg) {
char* buffer = NWC24WorkP->stringWork;
char appIdText[16];
u32 type = 0;
s32 length;
NWC24Err err;
Mail_memset(buffer, 0, 1024);
Mail_strcpy(buffer, "X-Wii-AppId: ");
if (!NWC24IsMsgLibOpenedByTool() && NWC24GetAppId() != 0x48414541 && msg->appId != 0x48414341)
msg->appId = NWC24GetAppId();
if (msg->type & 4)
type |= 1;
if (msg->type & 8)
type |= 2;
Mail_memset(appIdText, 0, 16);
Mail_sprintf(appIdText, "%d-%08X-%04X\r\n", type, msg->appId, msg->groupId);
Mail_strcat(buffer, appIdText);
length = Mail_strlen(buffer);
err = NWC24FWrite(buffer, length, m_pFile);
if (err == NWC24_OK)
msg->length += length;
return err;
}
static NWC24Err WriteXWiiFaceField(NWC24MsgObjPrivate* msg) {
char* buffer;
const u8* data;
s32 offset, remaining, chunk;
u32 length;
NWC24Err err;
if (msg->faceData.size == 0)
return NWC24_OK;
buffer = NWC24WorkP->stringWork;
Mail_memset(buffer, 0, 1024);
Mail_strcpy(buffer, "X-WiiFace:");
data = msg->faceData.ptr;
offset = 10;
for (remaining = msg->faceData.size; remaining > 0; remaining -= chunk) {
buffer[offset++] = ' ';
chunk = remaining;
if (remaining > 42)
chunk = 42;
NWC24Base64Encode((u8*)data, chunk, (u8*)(buffer + offset), 76, &length);
data += chunk;
offset += length;
buffer[offset++] = '\r';
buffer[offset++] = '\n';
}
err = NWC24FWrite(buffer, offset, m_pFile);
if (err == NWC24_OK)
msg->length += offset;
return err;
}
static NWC24Err WriteXWiiAltNameField(NWC24MsgObjPrivate* msg) {
char* buffer;
const u8* data;
s32 offset, remaining, chunk;
u32 length;
NWC24Err err;
if (msg->altName.size == 0)
return NWC24_OK;
buffer = NWC24WorkP->stringWork;
Mail_memset(buffer, 0, 1024);
Mail_strcpy(buffer, "X-Wii-AltName:");
data = msg->altName.ptr;
offset = 14;
for (remaining = msg->altName.size; remaining > 0; remaining -= chunk) {
buffer[offset++] = ' ';
chunk = remaining;
if (remaining > 42)
chunk = 42;
NWC24Base64Encode((u8*)data, chunk, (u8*)(buffer + offset), 76, &length);
data += chunk;
offset += length;
buffer[offset++] = '\r';
buffer[offset++] = '\n';
}
err = NWC24FWrite(buffer, offset, m_pFile);
if (err == NWC24_OK)
msg->length += offset;
return err;
}
const char* ContentTypeA = "Content-Type: %s;\r\n name=%c%07d.%s\r\n";
const char* ContentTxEncA = "Content-Transfer-Encoding: base64\r\n";
const char* ContentDispA = "Content-Disposition: attachment;\r\n filename=%c%07d.%s\r\n\r\n";
static NWC24Err WriteMIMEAttachHeader(NWC24MsgObjPrivate* msg, u32 index) {
char* buffer;
const char* mime;
const char* suffix;
s32 typeLength, encodingLength, dispositionLength, mimeLength;
s32 first, second, third, total;
NWC24Err err;
Mail_memset(NWC24WorkP->stringWork, 0, 1024);
buffer = NWC24WorkP->stringWork;
mime = NWC24GetMIMETypeStr(msg->attachedType[index]);
suffix = NWC24iGetMIMETypeSuffix(msg->attachedType[index]);
encodingLength = Mail_strlen(ContentTxEncA);
typeLength = Mail_strlen(ContentTypeA);
dispositionLength = Mail_strlen(ContentDispA);
typeLength += encodingLength;
mimeLength = Mail_strlen(mime);
if (mimeLength + (dispositionLength + typeLength) + 4 >= 1024)
return NWC24_ERR_NOMEM;
first = Mail_sprintf(buffer, (char*)ContentTypeA, mime, (char)('a' + index), msg->msgId, suffix);
if (first <= 0)
return NWC24_ERR_FAILED;
buffer += first;
second = Mail_sprintf(buffer, (char*)ContentTxEncA);
if (second <= 0)
return NWC24_ERR_FAILED;
buffer += second;
total = first + second;
third = Mail_sprintf(buffer, (char*)ContentDispA, (char)('a' + index), msg->msgId, suffix);
if (third <= 0)
return NWC24_ERR_FAILED;
total += third;
err = NWC24FWrite(NWC24WorkP->stringWork, total, m_pFile);
if (err == NWC24_OK)
msg->length += total;
return err;
}
const char* ContentTypeTP = "Content-Type: text/plain; charset=%s\r\n";
const char* ContentTxEncT = "Content-Transfer-Encoding: %s\r\n\r\n";
static NWC24Err WriteContentTypeField(NWC24MsgObjPrivate* msg) {
char* buffer = NWC24WorkP->stringWork;
const char* name;
const char* encoding;
s32 total = 0;
NWC24Err err;
Mail_memset(buffer, 0, 1024);
name = NWC24GetCharsetStr(msg->charset);
if (name != NULL) {
Mail_sprintf(buffer, (char*)ContentTypeTP, name);
msg->unk_0x50.ptr = (const void*)(msg->length + 34);
msg->unk_0x50.size = Mail_strlen(name) + 1;
total = Mail_strlen(buffer);
buffer += total;
}
encoding = NWC24GetEncodingStr(msg->encoding);
if (encoding != NULL) {
Mail_sprintf(buffer, (char*)ContentTxEncT, encoding);
msg->unk_0x58.ptr = (const void*)(total + msg->length + 27);
msg->unk_0x58.size = Mail_strlen(encoding) + 1;
total += Mail_strlen(buffer);
}
if (total == 0)
return NWC24_OK;
err = NWC24FWrite(NWC24WorkP->stringWork, total, m_pFile);
if (err == NWC24_OK)
msg->length += total;
return err;
}
static NWC24Err WritePlainText(NWC24MsgObjPrivate* msg) {
u32 length;
NWC24Err err;
if (msg->text.size == 0)
return NWC24_ERR_NULL;
switch (msg->encoding) {
case NWC24_ENC_7BIT:
case NWC24_ENC_8BIT:
err = NWC24FWrite(msg->text.ptr, msg->text.size, m_pFile);
length = msg->text.size;
break;
case NWC24_ENC_BASE64:
err = WriteBase64Data(msg->text.ptr, msg->text.size, &length);
break;
case NWC24_ENC_QUOTED_PRINTABLE:
err = WriteQPData(msg->text.ptr, msg->text.size, &length);
break;
default:
err = NWC24_ERR_INVALID_VALUE;
break;
}
if (err == NWC24_OK) {
msg->textSize = msg->text.size;
msg->length += length;
}
return err;
}
static NWC24Err WriteBase64Data(const u8* data, s32 size, u32* totalLength) {
const u8* cursor = data;
char* buffer = NWC24WorkP->stringWork;
u32 length;
u32 total = 0;
NWC24Err err = NWC24_OK;
while (size >= 57) {
Mail_memset(buffer, 0, 1024);
err = NWC24Base64Encode((u8*)cursor, 57, (u8*)buffer, 76, &length);
if (err != NWC24_OK)
break;
buffer[length++] = '\r';
buffer[length++] = '\n';
buffer[length] = '\0';
err = NWC24FWrite(buffer, length, m_pFile);
if (err != NWC24_OK)
break;
cursor += 57;
size -= 57;
total += length;
}
if (err == NWC24_OK) {
Mail_memset(buffer, 0, 1024);
err = NWC24Base64Encode((u8*)cursor, size, (u8*)buffer, 76, &length);
if (err == NWC24_OK) {
buffer[length++] = '\r';
buffer[length++] = '\n';
buffer[length++] = '\r';
buffer[length++] = '\n';
buffer[length] = '\0';
err = NWC24FWrite(buffer, length, m_pFile);
if (err == NWC24_OK)
total += length;
}
}
*totalLength = total;
return err;
}
static NWC24Err WriteQPData(const u8* data, s32 size, u32* totalLength) {
char* buffer = NWC24WorkP->stringWork;
const u8* cursor = data;
s32 total = 0;
s32 remaining = size;
u32 consumed, length;
NWC24Err err = NWC24_OK;
for (; remaining > 0; remaining -= consumed) {
if (total > 0) {
Mail_memcpy(buffer, "=\r\n", 3);
err = NWC24FWrite(buffer, 3, m_pFile);
if (err != NWC24_OK)
break;
total += 3;
}
Mail_memset(buffer, 0, 1024);
err = NWC24EncodeQuotedPrintable(buffer, 1024, &length, (u8*)cursor, remaining, &consumed);
if (err != NWC24_OK && err != NWC24_ERR_OVERFLOW)
break;
err = NWC24FWrite(buffer, length, m_pFile);
if (err != NWC24_OK)
break;
cursor += consumed;
total += length;
}
*totalLength = total;
return err;
}

View File

@@ -445,16 +445,28 @@ extern "C" const InputFormAnimationFile csAninationFile__Q29textinput9inputform[
};
#pragma section data_type ".rodata"
extern "C" const VisiblePanes csVisiblePaneUEJ__Q29textinput9inputform = {
1, 2,
{lbl_8165C8C0, NULL, NULL, NULL},
{"N_KOR", "N_CHN", NULL, NULL},
extern "C" const void* csVisiblePaneUEJ__Q29textinput9inputform[9] = {
(const void*)0x00010002,
lbl_8165C8C0,
0,
0,
0,
"N_KOR",
"N_CHN",
0,
0,
};
extern "C" const VisiblePanes csVisiblePaneKOR__Q29textinput9inputform = {
1, 2,
{"N_KOR", NULL, NULL, NULL},
{"N_CHN", lbl_8165C8C0, NULL, NULL},
extern "C" const void* csVisiblePaneKOR__Q29textinput9inputform[9] = {
(const void*)0x00010002,
"N_KOR",
0,
0,
0,
"N_CHN",
lbl_8165C8C0,
0,
0,
};
extern "C" const void* csVisiblePaneCHN__Q29textinput9inputform[10] = {
@@ -470,22 +482,22 @@ extern "C" const void* csVisiblePaneCHN__Q29textinput9inputform[10] = {
0,
};
extern "C" const LanguagePaneData csLanguageDependencyDataUEJ__Q29textinput9inputform = {
&csVisiblePaneUEJ__Q29textinput9inputform,
extern "C" const void* csLanguageDependencyDataUEJ__Q29textinput9inputform[4] = {
csVisiblePaneUEJ__Q29textinput9inputform,
lbl_8165C8CC,
lbl_8165C8E0,
lbl_8165C8F0,
};
extern "C" const LanguagePaneData csLanguageDependencyDataKOR__Q29textinput9inputform = {
&csVisiblePaneKOR__Q29textinput9inputform,
extern "C" const void* csLanguageDependencyDataKOR__Q29textinput9inputform[4] = {
csVisiblePaneKOR__Q29textinput9inputform,
lbl_8165C900,
lbl_8165C918,
lbl_8165C928,
};
extern "C" const LanguagePaneData csLanguageDependencyDataCHN__Q29textinput9inputform = {
reinterpret_cast<const VisiblePanes*>(csVisiblePaneCHN__Q29textinput9inputform),
extern "C" const void* csLanguageDependencyDataCHN__Q29textinput9inputform[4] = {
csVisiblePaneCHN__Q29textinput9inputform,
lbl_8165C938,
lbl_8165C950,
lbl_8165C960,
@@ -1212,7 +1224,7 @@ void Base::onHKBCtrlCode(HVKCode code, u32 modifiers) {
LayoutByNW4R::LayoutByNW4R(Manager* manager, nw4r::lyt::MultiArcResourceAccessor* accessor, const char* layout, EventObserver* observer, const char* fontName)
: Base(manager), nw4rmanager::Layout(accessor, layout, observer), mpLayoutData("T_2l_TextBox"),
mpLanguageData(&csLanguageDependencyDataUEJ__Q29textinput9inputform), mpFontName(fontName),
mpLanguageData(csLanguageDependencyDataUEJ__Q29textinput9inputform), mpFontName(fontName),
mbUpVisible(false), mbDownVisible(false), mbRepeat(false), mpInputEventHandler(NULL) {}
void LayoutByNW4R::create(MEMAllocator* allocator, EditBuffer* editBuffer) {
@@ -1348,9 +1360,9 @@ void LayoutByNW4R::calc() {
}
void LayoutByNW4R::setLanguage(Language language) {
Base::setLanguage(language);
if (language == CN) mpLanguageData = &csLanguageDependencyDataCHN__Q29textinput9inputform;
else if (language == KR) mpLanguageData = &csLanguageDependencyDataKOR__Q29textinput9inputform;
else mpLanguageData = &csLanguageDependencyDataUEJ__Q29textinput9inputform;
if (language == CN) mpLanguageData = csLanguageDependencyDataCHN__Q29textinput9inputform;
else if (language == KR) mpLanguageData = csLanguageDependencyDataKOR__Q29textinput9inputform;
else mpLanguageData = csLanguageDependencyDataUEJ__Q29textinput9inputform;
const char* textName;
if (!getLanguageTextPane()) textName = "T_2l_TextBox";
else textName = static_cast<const LanguagePaneData*>(mpLanguageData)->textBox;
@@ -1954,27 +1966,131 @@ create_L1:
blr
}
tistring::Decolated* Base::getCurrentString(bool inputting) {
if (!mbPredictOn) return mpString;
if (meLanguage == KR) {
if (mpManager->getToolBar()->isQwerty()) {
if (mpManager->getPCKeyboard()->getTranslateMode() == 0) return mpString;
} else {
if (mpManager->getCellPhoneKeyboard()->getInputMode() != 0) return mpString;
}
}
if (meLanguage == CN) {
if (mpManager->getCandidateBox()->isInvalid() || !mpManager->getCandidateBox()->isActive()) return mpString;
}
switch (mePredictMode) {
case PM_Atok:
if (!mpUnfixString->isFix() || inputting) return mpUnfixString;
break;
default:
if (!mpZiString->isFix() || inputting) return mpZiString;
break;
}
return mpString;
extern "C" asm void getCurrentString__Q39textinput9inputform4BaseFb() {
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
lbz r0, 0x178(r3)
cmpwi r0, 0
bne getCurrentString_L1
lwz r3, 0x164(r3)
b getCurrentString_Lend
getCurrentString_L1:
lwz r0, 0x1f0(r3)
cmpwi r0, 9
bne getCurrentString_L2
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 getCurrentString_L3
lwz r3, 0x1d4(r30)
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
bne getCurrentString_L2
lwz r3, 0x164(r30)
b getCurrentString_Lend
getCurrentString_L3:
lwz r3, 0x1d4(r30)
lwz r12, 0(r3)
lwz r12, 0x7c(r12)
mtctr r12
bctrl
lwz r12, 0(r3)
lwz r12, 0x40(r12)
mtctr r12
bctrl
cmpwi r3, 0
beq getCurrentString_L2
lwz r3, 0x164(r30)
b getCurrentString_Lend
getCurrentString_L2:
lwz r0, 0x1f0(r30)
cmpwi r0, 8
bne getCurrentString_L4
lwz r3, 0x1d4(r30)
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 getCurrentString_L5
lwz r3, 0x1d4(r30)
lwz r12, 0(r3)
lwz r12, 0x8c(r12)
mtctr r12
bctrl
lwz r12, 0(r3)
lwz r12, 0x10c(r12)
mtctr r12
bctrl
cmpwi r3, 0
bne getCurrentString_L4
getCurrentString_L5:
lwz r3, 0x164(r30)
b getCurrentString_Lend
getCurrentString_L4:
lwz r0, 0x174(r30)
cmpwi r0, 1
beq getCurrentString_L6
b getCurrentString_L7
getCurrentString_L6:
lwz r3, 0x168(r30)
lwz r12, 0(r3)
lwz r12, 0xd0(r12)
mtctr r12
bctrl
cmpwi r3, 0
beq getCurrentString_L8
cmpwi r31, 0
beq getCurrentString_L9
getCurrentString_L8:
lwz r3, 0x168(r30)
b getCurrentString_Lend
getCurrentString_L7:
lwz r3, 0x16c(r30)
lwz r12, 0(r3)
lwz r12, 0xec(r12)
mtctr r12
bctrl
cmpwi r3, 0
beq getCurrentString_L10
cmpwi r31, 0
beq getCurrentString_L9
getCurrentString_L10:
lwz r3, 0x16c(r30)
b getCurrentString_Lend
getCurrentString_L9:
lwz r3, 0x164(r30)
getCurrentString_Lend:
lwz r0, 0x14(r1)
lwz r31, 0xc(r1)
lwz r30, 8(r1)
mtlr r0
addi r1, r1, 0x10
blr
}
bool Base::isVacancy() const {
@@ -2052,23 +2168,102 @@ void Base::updateCandidateState_() {
}
}
void Base::moveCursorUp() {
f32 y = mfCursorY;
if (-(mfCursorY - mfScrollY) >= 0.0f) {
u32 start, end;
mpString->getCursorPos(&start, &end);
if (start == 0 && end == 0) onSE(static_cast<sound::SE>(6));
else onSE(static_cast<sound::SE>(5));
mpString->setCursorPos(0);
} else {
y = mfCursorY >= 0.0f ? mfCursorY : 0.0f;
f32 lineHeight = getLineHeight();
f32 targetY = 1.0f + (y - lineHeight);
u32 position = calcCursorPos(mfCursorX, targetY);
mpString->setCursorPos(position);
onSE(static_cast<sound::SE>(5));
}
meScrollFlag = SF_ScrollOn;
extern "C" asm void moveCursorUp__Q39textinput9inputform4BaseFv() {
nofralloc
stwu r1, -0x30(r1)
mflr r0
stw r0, 0x34(r1)
stfd f31, 0x20(r1)
psq_st f31, 0x28(r1), 0, 0
lfs f0, lbl_81694D28(r0)
stw r31, 0x1c(r1)
mr r31, r3
lfs f31, 0x180(r3)
lfs f1, 0x188(r3)
fsubs f1, f31, f1
fneg f1, f1
fcmpo cr0, f1, f0
cror eq, gt, eq
bne moveCursorUp_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 r0, 0xc(r1)
cmpwi r0, 0
bne moveCursorUp_L2
lwz r0, 8(r1)
cmpwi r0, 0
bne moveCursorUp_L2
lwz r12, 0(r31)
mr r3, r31
li r4, 6
lwz r12, 0x178(r12)
mtctr r12
bctrl
b moveCursorUp_L3
moveCursorUp_L2:
lwz r12, 0(r31)
mr r3, r31
li r4, 5
lwz r12, 0x178(r12)
mtctr r12
bctrl
moveCursorUp_L3:
lwz r3, 0x164(r31)
li r4, 0
lwz r12, 0(r3)
lwz r12, 0x6c(r12)
mtctr r12
bctrl
b moveCursorUp_L4
moveCursorUp_L1:
fcmpo cr0, f31, f0
cror eq, gt, eq
bne moveCursorUp_L5
b moveCursorUp_L6
moveCursorUp_L5:
fmr f31, f0
moveCursorUp_L6:
lwz r12, 0x5c(r3)
lwz r12, 0x28(r12)
mtctr r12
addi r3, r3, 0x10
bctrl
fsubs f2, f31, f1
lwz r12, 0(r31)
lfs f0, lbl_81694D38(r0)
mr r3, r31
lwz r12, 0x180(r12)
fadds f2, f0, f2
lfs f1, 0x17c(r31)
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
moveCursorUp_L4:
li r0, 1
stw r0, 0x1b0(r31)
psq_l f31, 0x28(r1), 0, 0
lfd f31, 0x20(r1)
lwz r31, 0x1c(r1)
lwz r0, 0x34(r1)
mtlr r0
addi r1, r1, 0x30
blr
}
void Base::moveCursorDown() {
@@ -2291,8 +2486,7 @@ void Base::onSpaceKeyHWKB(u32 modifiers) {
}
} else {
bool useAtok;
u32 enabled = mbPredictOn;
if (enabled == 0) useAtok = false;
if (!mbPredictOn) useAtok = false;
else useAtok = mePredictMode == PM_Atok;
if (useAtok && current == mpUnfixString) {
if (!mpUnfixString->isKanaFix()) mpUnfixString->confirmKana();
@@ -4177,15 +4371,78 @@ void Base::draw() {
endDraw();
}
void Base::drawCursor(f32 x, f32 y) {
f32 opacity = static_cast<u32>(muGlobalAlpha) / 255.0f;
mfCursorX = x;
mfCursorY = y;
GXColor color = {lbl_81694D6C, lbl_81694D6D, lbl_81694D6E, lbl_81694D6F};
f32 pulse = nw4r::math::SinFIdx(0.7111111f * muCursorTimer);
color.a = static_cast<s32>(opacity * (127.0f + 127.0f * pulse));
f32 width = mfViewWidth - mfViewX;
debug::drawLine_(mfCursorX, 2.0f + mfCursorY, mfCursorX, (mfCursorY + GetFontHeight()) - 2.0f, 0.0f, static_cast<u8>(14592.0f / width), color);
asm void Base::drawCursor(f32, f32) {
nofralloc
stwu r1, -0x50(r1)
mflr r0
stw r0, 0x54(r1)
stfd f31, 0x40(r1)
psq_st f31, 0x48(r1), 0, 0
lis r7, 0x4330
lfd f4, lbl_81694D80(r0)
stw r31, 0x3c(r1)
mr r31, r3
lfs f3, lbl_81694D70(r0)
lbz r0, 0x1c8(r3)
stw r7, 0x10(r1)
stw r0, 0x14(r1)
lfd f0, 0x10(r1)
stfs f1, 0x17c(r3)
fsubs f1, f0, f4
lfs f0, lbl_81694D40(r0)
stfs f2, 0x180(r3)
lbz r6, lbl_81694D6C(r0)
fdivs f31, f1, f3
lbz r5, lbl_81694D6D(r0)
lbz r4, lbl_81694D6E(r0)
lbz r0, lbl_81694D6F(r0)
stb r6, 8(r1)
stb r5, 9(r1)
stb r4, 0xa(r1)
stb r0, 0xb(r1)
lwz r0, 0x214(r3)
stw r7, 0x18(r1)
stw r0, 0x1c(r1)
lfd f1, 0x18(r1)
fsubs f1, f1, f4
fmuls f1, f0, f1
bl SinFIdx__Q24nw4r4mathFf
lfs f2, lbl_81694D74(r0)
addi r3, r31, 0x10
fmuls f0, f2, f1
fadds f0, f2, f0
fmuls f0, f31, f0
fctiwz f0, f0
stfd f0, 0x20(r1)
lwz r0, 0x24(r1)
stb r0, 0xb(r1)
lfs f1, 0xa0(r31)
lfs f0, 0x98(r31)
fsubs f31, f1, f0
bl GetFontHeight__Q34nw4r2ut10CharWriterCFv
lfs f0, lbl_81694D78(r0)
addi r4, r1, 8
lfs f6, 0x180(r31)
fdivs f0, f0, f31
lfs f2, lbl_81694D58(r0)
lfs f5, lbl_81694D28(r0)
fctiwz f0, f0
fadds f4, f6, f1
lfs f1, 0x17c(r31)
stfd f0, 0x28(r1)
fmr f3, f1
fsubs f4, f4, f2
lwz r3, 0x2c(r1)
fadds f2, f2, f6
clrlwi r3, r3, 24
bl drawLine___Q29textinput5debugFfffffUcR8_GXColor
psq_l f31, 0x48(r1), 0, 0
lwz r0, 0x54(r1)
lfd f31, 0x40(r1)
lwz r31, 0x3c(r1)
mtlr r0
addi r1, r1, 0x50
blr
}
void Base::doScroll(Scroll* scroll) {

View File

@@ -1,327 +0,0 @@
#define TIMANAGER_IMPLEMENTATION
#include "keyboard/tiPcKeyboard.h"
#include "keyboard/tiCellPhone.h"
#include "keyboard/tiInputForm.h"
#include <revolution/sc.h>
#include <new>
namespace textinput {
namespace keyboard {
namespace pctype {
class Sample : public LayoutByNW4R {
public:
Sample(Manager* manager, nw4r::lyt::MultiArcResourceAccessor* accessor, EventObserver* observer, const char* layoutName)
: LayoutByNW4R(manager, accessor, observer, layoutName) {}
virtual ~Sample();
};
}
}
}
namespace textinput {
namespace keyboard {
namespace cellphonetype {
class Sample : public LayoutByNW4R {
public:
Sample(Manager* manager, nw4r::lyt::MultiArcResourceAccessor* accessor, EventObserver* observer, const char* layoutName)
: LayoutByNW4R(manager, accessor, observer, layoutName) {}
virtual ~Sample();
};
}
}
}
namespace textinput {
namespace candidatebox {
class Sample : public LayoutByNW4R {
public:
Sample(Manager* manager, nw4r::lyt::MultiArcResourceAccessor* accessor, EventObserver* observer, const char* layoutName)
: LayoutByNW4R(manager, accessor, observer, layoutName) {}
virtual ~Sample();
};
}
}
namespace textinput {
namespace inputform {
class Sample : public LayoutByNW4R {
public:
Sample(Manager* manager, nw4r::lyt::MultiArcResourceAccessor* accessor, EventObserver* observer, const char* layoutName)
: LayoutByNW4R(manager, accessor, layoutName, observer, NULL) {}
virtual ~Sample();
};
}
}
#include "keyboard/tiToolBar.h"
#include "keyboard/tiPredictLang.h"
namespace textinput { namespace keyboard {
namespace signwindow {
class Sample : public LayoutByNW4R {
public:
Sample(Manager* manager, nw4r::lyt::MultiArcResourceAccessor* accessor, EventObserver* observer, const char* layoutName)
: LayoutByNW4R(manager, accessor, observer, layoutName) {}
virtual ~Sample();
};
}
}}
#include "keyboard/tiManager.h"
namespace textinput {
static EventObserver defaultEventObserver;
Manager::Manager(MEMAllocator* allocator, nw4r::lyt::MultiArcResourceAccessor* accessor, EventObserver* observer)
: mpAllocator(allocator), mpMultiArcResourceAccessor(accessor), mpEditBuffer(NULL), mpHWKeyboard(NULL), mpPCKeyboard(NULL),
mpCellPhoneKeyboard(NULL), mpInputForm(NULL), mpCandidateBox(NULL), mpToolBar(NULL), mpPredictLanguageDialog(NULL),
mpSignWindow(NULL), mpEventObserver(observer), meDestination(DST_JP), meLanguage(JP), mbAspectRatio4x3(true) {
if (observer == NULL) mpEventObserver = &defaultEventObserver;
}
Manager::~Manager() {
if (mpPCKeyboard) { mpPCKeyboard->~LayoutByNW4R(); MEMFreeToAllocator(mpAllocator, mpPCKeyboard); }
if (mpCellPhoneKeyboard) { mpCellPhoneKeyboard->~LayoutByNW4R(); MEMFreeToAllocator(mpAllocator, mpCellPhoneKeyboard); }
if (mpInputForm) { mpInputForm->~LayoutByNW4R(); MEMFreeToAllocator(mpAllocator, mpInputForm); }
if (mpCandidateBox) { mpCandidateBox->~LayoutByNW4R(); MEMFreeToAllocator(mpAllocator, mpCandidateBox); }
if (mpToolBar) { mpToolBar->~LayoutByNW4R(); MEMFreeToAllocator(mpAllocator, mpToolBar); }
if (mpPredictLanguageDialog) { mpPredictLanguageDialog->~LayoutByNW4R(); MEMFreeToAllocator(mpAllocator, mpPredictLanguageDialog); }
if (mpSignWindow) { mpSignWindow->~LayoutByNW4R(); MEMFreeToAllocator(mpAllocator, mpSignWindow); }
if (mpHWKeyboard) { mpHWKeyboard->~HWKeyboard(); MEMFreeToAllocator(mpAllocator, mpHWKeyboard); }
if (mpEditBuffer) { mpEditBuffer->~EditBuffer(); MEMFreeToAllocator(mpAllocator, mpEditBuffer); }
}
keyboard::hwkey::HWKeyboard::~HWKeyboard() {}
void Manager::create(MEMAllocator*) {
mpEditBuffer = createEditBuffer();
mpEditBuffer->create(mpAllocator);
mpHWKeyboard = createHWKeyboard();
mpPCKeyboard = static_cast<keyboard::pctype::LayoutByNW4R*>(createPCTypeKeyboard());
mpPCKeyboard->create(mpAllocator);
mpCellPhoneKeyboard = static_cast<keyboard::cellphonetype::LayoutByNW4R*>(createCellPhoneTypeKeyboard());
mpCellPhoneKeyboard->create(mpAllocator);
mpInputForm = createInputForm();
mpInputForm->create(mpAllocator, mpEditBuffer);
mpCandidateBox = static_cast<candidatebox::LayoutByNW4R*>(createCandidateBox());
mpCandidateBox->create(mpAllocator);
mpToolBar = static_cast<toolbar::LayoutByNW4R*>(createToolBar());
mpToolBar->create(mpAllocator);
mpPredictLanguageDialog = static_cast<predictlang::LayoutByNW4R*>(createPredictLanguageDialog());
mpPredictLanguageDialog->create(mpAllocator);
mpSignWindow = static_cast<keyboard::signwindow::LayoutByNW4R*>(createSignWindow());
mpSignWindow->create(mpAllocator);
if (SCGetAspectRatio() == 1) { setLayoutScaleFor16x9(); mbAspectRatio4x3 = false; }
else { setLayoutScaleFor4x3(); mbAspectRatio4x3 = true; }
init();
}
void Manager::initAspect() {
if (SCGetAspectRatio() == 1) { setLayoutScaleFor16x9(); mbAspectRatio4x3 = false; }
else { setLayoutScaleFor4x3(); mbAspectRatio4x3 = true; }
}
void Manager::init() {
input::HKBManager::getInstance().ClearState();
mpInputForm->clearSender();
mpHWKeyboard->setCommandReceiver(mpInputForm);
mpPCKeyboard->setCommandReceiver(mpInputForm);
mpCellPhoneKeyboard->setCommandReceiver(mpInputForm);
mpCandidateBox->setCommandReceiver(mpInputForm);
mpPredictLanguageDialog->setCommandReceiver(mpInputForm);
mpSignWindow->setCommandReceiver(mpInputForm);
mpInputForm->setCandidateBox(mpCandidateBox);
mpPCKeyboard->setPredictLanguageDialog(mpPredictLanguageDialog);
mpPCKeyboard->setSignWindow(mpSignWindow);
mpCellPhoneKeyboard->setPredictLanguageDialog(mpPredictLanguageDialog);
mpCellPhoneKeyboard->setSignWindow(mpSignWindow);
if (mbAspectRatio4x3 == true) setLayoutScaleFor4x3();
else setLayoutScaleFor16x9();
mpPredictLanguageDialog->setDestination(meDestination);
mpInputForm->setDestination(meDestination);
mpInputForm->setLanguage(meLanguage);
mpPCKeyboard->setLanguage(meLanguage);
mpCellPhoneKeyboard->setLanguage(meLanguage);
mpSignWindow->setLanguage(meLanguage);
mpCandidateBox->setLanguage(meLanguage);
mpToolBar->setLanguage(meLanguage);
mpPredictLanguageDialog->setLanguage(meLanguage);
mpHWKeyboard->setLanguage(meDestination, meLanguage);
mpHWKeyboard->init();
mpPCKeyboard->init();
mpCellPhoneKeyboard->init();
mpInputForm->init();
mpCandidateBox->init();
mpToolBar->init();
mpPredictLanguageDialog->init();
mpSignWindow->init();
setFixedPredictionJP(0, NULL);
setSecretInputMode(false);
}
void Manager::setFixedPredictionJP(int count, const char** predictions) {
static_cast<tistring::WithAtok*>(getInputForm()->getAtokString())->setFixPrediction(count, predictions);
}
void Manager::calc() {
if (mpToolBar->isQwerty()) mpPCKeyboard->calc();
else mpCellPhoneKeyboard->calc();
static_cast<nw4rmanager::Layout&>(*mpToolBar).calc();
mpCandidateBox->calc();
mpInputForm->calc();
if (mpPredictLanguageDialog->isActive()) static_cast<nw4rmanager::Layout&>(*mpPredictLanguageDialog).calc();
if (mpSignWindow->isActive()) static_cast<nw4rmanager::Layout&>(*mpSignWindow).calc();
}
void Manager::draw() {
GXSetZMode(GX_TRUE, GX_LEQUAL, GX_TRUE);
mpToolBar->draw();
mpInputForm->draw();
if (mpToolBar->isQwerty()) mpPCKeyboard->draw();
else mpCellPhoneKeyboard->draw();
mpCandidateBox->draw();
if (mpPredictLanguageDialog->isActive()) mpPredictLanguageDialog->draw();
if (mpSignWindow->isActive()) mpSignWindow->draw();
}
bool Manager::updateInput(int channel, f32 x, f32 y, u32 trigger, u32 hold, u32 release) {
bool wasQwerty = mpToolBar->isQwerty();
nw4rmanager::TiEventHandler::Input input;
input.controller = channel;
input.x = x;
input.y = y;
input.trigger = trigger;
input.hold = hold;
input.release = release;
mpHWKeyboard->updateInput(channel, x, y, trigger, hold, release, &input);
bool handled;
if (mpPredictLanguageDialog->isActive()) {
return static_cast<nw4rmanager::Layout&>(*mpPredictLanguageDialog).updateInput(channel, x, y, trigger, hold, release, &input);
}
mpInputForm->updateInputCommon(channel, trigger, hold, release, &input);
if (mpSignWindow->isActive()) {
return mpSignWindow->updateInput(channel, x, y, trigger, hold, release, &input);
} else {
bool keyboardHandled;
if (wasQwerty) keyboardHandled = mpPCKeyboard->updateInput(channel, x, y, trigger, hold, release, &input);
else keyboardHandled = mpCellPhoneKeyboard->updateInput(channel, x, y, trigger, hold, release, &input);
bool toolbarHandled = static_cast<nw4rmanager::Layout&>(*mpToolBar).updateInput(channel, x, y, trigger, hold, release, &input);
bool candidateHandled = static_cast<nw4rmanager::Layout&>(*mpCandidateBox).updateInput(channel, x, y, trigger, hold, release, &input);
bool formHandled = mpInputForm->updateInput(channel, x, y, trigger, hold, release, &input);
handled = (keyboardHandled | candidateHandled) | (formHandled | toolbarHandled);
}
if (wasQwerty != mpToolBar->isQwerty()) {
getInputForm()->onCommand(static_cast<CommandReceiver::INPUT_COMMAND>(6), NULL);
mpCandidateBox->checkValidation();
if (mpToolBar->isQwerty()) mpPCKeyboard->onActive();
else mpCellPhoneKeyboard->onActive();
}
return handled;
}
bool Manager::updateInput(input::HKBManager& keyboard) {
bool wasQwerty = mpToolBar->isQwerty();
bool handled;
if (mpPredictLanguageDialog->isActive()) return static_cast<nw4rmanager::Layout&>(*mpPredictLanguageDialog).updateInput(keyboard);
else if (mpSignWindow->isActive()) return mpSignWindow->updateInput(keyboard);
else {
bool keyboardHandled;
if (wasQwerty) keyboardHandled = mpPCKeyboard->updateInput(keyboard);
else keyboardHandled = mpCellPhoneKeyboard->updateInput(keyboard);
bool toolbarHandled = static_cast<nw4rmanager::Layout&>(*mpToolBar).updateInput(keyboard);
bool candidateHandled = static_cast<nw4rmanager::Layout&>(*mpCandidateBox).updateInput(keyboard);
bool formHandled = mpInputForm->updateInput(keyboard);
handled = (keyboardHandled | candidateHandled) | (formHandled | toolbarHandled);
}
if (wasQwerty != mpToolBar->isQwerty()) {
getInputForm()->onCommand(static_cast<CommandReceiver::INPUT_COMMAND>(6), NULL);
mpCandidateBox->checkValidation();
if (mpToolBar->isQwerty()) mpPCKeyboard->onActive();
else mpCellPhoneKeyboard->onActive();
}
return handled;
}
wchar_t* Manager::getWCString() const { return mpInputForm->getWCString(); }
void Manager::setWCString(const wchar_t* string) { mpInputForm->inputform::Base::setString(string); }
void Manager::setLanguage(Language language) { meLanguage = language; }
void Manager::setDestination(Destination destination) { meDestination = destination; }
void Manager::limitStringLength(u32 length) { mpInputForm->limitStringLength(length); }
void Manager::limitRowNum(u32 rows) { mpInputForm->limitRowNum(rows); }
void Manager::setAnimationOn(bool enabled) {
static_cast<nw4rmanager::Layout&>(*mpPCKeyboard).setAnimOn(enabled);
static_cast<nw4rmanager::Layout&>(*mpCellPhoneKeyboard).setAnimOn(enabled);
static_cast<nw4rmanager::Layout&>(*mpInputForm).setAnimOn(enabled);
static_cast<nw4rmanager::Layout&>(*mpCandidateBox).setAnimOn(enabled);
static_cast<nw4rmanager::Layout&>(*mpToolBar).setAnimOn(enabled);
static_cast<nw4rmanager::Layout&>(*mpPredictLanguageDialog).setAnimOn(enabled);
static_cast<nw4rmanager::Layout&>(*mpSignWindow).setAnimOn(enabled);
}
void Manager::setAspectRatio(bool standard) {
mbAspectRatio4x3 = standard;
if (static_cast<u8>(standard) == true) setLayoutScaleFor4x3();
else setLayoutScaleFor16x9();
}
void Manager::setTitleText(wchar_t* title) {
nw4r::lyt::TextBox* text = nw4r::ut::DynamicCast<nw4r::lyt::TextBox*>(static_cast<nw4rmanager::Layout&>(*mpInputForm).getPane("T_title_text"));
if (text != NULL) text->SetString(title, 0);
}
void Manager::setLayoutScaleFor16x9() {
static_cast<nw4rmanager::Layout&>(*mpPCKeyboard).setRootPaneScaleFor16x9();
static_cast<nw4rmanager::Layout&>(*mpCellPhoneKeyboard).setRootPaneScaleFor16x9();
mpInputForm->setRootPaneScaleFor16x9();
mpCandidateBox->setRootPaneScaleFor16x9();
static_cast<nw4rmanager::Layout&>(*mpToolBar).setRootPaneScaleFor16x9();
static_cast<nw4rmanager::Layout&>(*mpPredictLanguageDialog).setRootPaneScaleFor16x9();
static_cast<nw4rmanager::Layout&>(*mpSignWindow).setRootPaneScaleFor16x9();
}
void Manager::setLayoutScaleFor4x3() {
static_cast<nw4rmanager::Layout&>(*mpPCKeyboard).setRootPaneScaleFor4x3();
static_cast<nw4rmanager::Layout&>(*mpCellPhoneKeyboard).setRootPaneScaleFor4x3();
mpInputForm->setRootPaneScaleFor4x3();
mpCandidateBox->setRootPaneScaleFor4x3();
static_cast<nw4rmanager::Layout&>(*mpToolBar).setRootPaneScaleFor4x3();
static_cast<nw4rmanager::Layout&>(*mpPredictLanguageDialog).setRootPaneScaleFor4x3();
static_cast<nw4rmanager::Layout&>(*mpSignWindow).setRootPaneScaleFor4x3();
}
inputform::EditBuffer* Manager::createEditBuffer() { return new (MEMAllocFromAllocator(mpAllocator, sizeof(inputform::EditBuffer))) inputform::EditBuffer; }
keyboard::hwkey::HWKeyboard* Manager::createHWKeyboard() { return new (MEMAllocFromAllocator(mpAllocator, sizeof(keyboard::hwkey::HWKeyboard))) keyboard::hwkey::HWKeyboard(this); }
void* Manager::createPCTypeKeyboard() { return new (MEMAllocFromAllocator(mpAllocator, sizeof(keyboard::pctype::Sample))) keyboard::pctype::Sample(this, mpMultiArcResourceAccessor, mpEventObserver, "fs_VK_ascii_keytop_a.brlyt"); }
void* Manager::createCellPhoneTypeKeyboard() { return new (MEMAllocFromAllocator(mpAllocator, sizeof(keyboard::cellphonetype::Sample))) keyboard::cellphonetype::Sample(this, mpMultiArcResourceAccessor, mpEventObserver, "fs_VK_cellPhone_a.brlyt"); }
InputForm* Manager::createInputForm() { return new (MEMAllocFromAllocator(mpAllocator, sizeof(inputform::Sample))) inputform::Sample(this, mpMultiArcResourceAccessor, mpEventObserver, "fs_VK_textBox_a.brlyt"); }
void* Manager::createCandidateBox() { return new (MEMAllocFromAllocator(mpAllocator, sizeof(candidatebox::Sample))) candidatebox::Sample(this, mpMultiArcResourceAccessor, mpEventObserver, "fs_VK_predictInput_a.brlyt"); }
void* Manager::createToolBar() { return new (MEMAllocFromAllocator(mpAllocator, sizeof(toolbar::Sample))) toolbar::Sample(this, mpMultiArcResourceAccessor, mpEventObserver, "fs_VK_toolbar_a.brlyt"); }
void* Manager::createPredictLanguageDialog() { return new (MEMAllocFromAllocator(mpAllocator, sizeof(predictlang::Sample))) predictlang::Sample(this, mpMultiArcResourceAccessor, mpEventObserver, "fs_prdicSelWidw_a.brlyt"); }
predictlang::Base::~Base() {}
void* Manager::createSignWindow() { return new (MEMAllocFromAllocator(mpAllocator, sizeof(keyboard::signwindow::Sample))) keyboard::signwindow::Sample(this, mpMultiArcResourceAccessor, mpEventObserver, "fs_signWindow_a.brlyt"); }
void Manager::startPredictTurnOn(bool enabled) {
if (getInputForm()->mbPredictOn != enabled) getCandidateBox()->startTurnOn(enabled);
}
bool Manager::isPredictTurning() const { return getCandidateBox()->getOnOffButton().IsTurning(); }
void Manager::enableCompatibleFilter(bool enabled) { inputform::DeadKeyStream::sbCompatibleFilterEnabled = enabled; }
void Manager::enableKSXFilter(bool enabled) {
static_cast<tistring::Decolated*>(mpEditBuffer->mpString)->EnableKSXFilter(enabled);
static_cast<tistring::Decolated*>(mpEditBuffer->mpZiString)->EnableKSXFilter(enabled);
}
bool Manager::isVacancy() const {
if (!getInputForm() || !getToolBar()) return true;
if (!getToolBar()->isQwerty() && getCellPhoneKeyboard()->isHoldingButton()) return false;
return getInputForm()->inputform::Base::isVacancy();
}
void Manager::SetFont(nw4r::lyt::FontRefLink* link) {
nw4r::ut::Font* font = link->GetFont();
if (mpToolBar) static_cast<nw4rmanager::Layout&>(*mpToolBar).SetFontForce(font);
if (mpPCKeyboard) static_cast<nw4rmanager::Layout&>(*mpPCKeyboard).SetFontForce(font);
if (mpCandidateBox) static_cast<nw4rmanager::Layout&>(*mpCandidateBox).SetFontForce(font);
if (mpSignWindow) static_cast<nw4rmanager::Layout&>(*mpSignWindow).SetFontForce(font);
if (mpInputForm) mpInputForm->nw4r::ut::CharWriter::SetFont(*font);
if (mpCellPhoneKeyboard) static_cast<nw4rmanager::Layout&>(*mpCellPhoneKeyboard).SetFontForce(font);
}
void Manager::setDefaultPredictionJP(int count, const char** predictions) {
static_cast<tistring::WithAtok*>(getInputForm()->getAtokString())->setDefaultPrediction(count, predictions);
}
void predictlang::Base::init() {}
void predictlang::Base::create(MEMAllocator* allocator) { mpAllocator = allocator; }
keyboard::pctype::Sample::~Sample() {}
keyboard::cellphonetype::Sample::~Sample() {}
candidatebox::Sample::~Sample() {}
inputform::Sample::~Sample() {}
toolbar::Sample::~Sample() {}
predictlang::Sample::~Sample() {}
keyboard::signwindow::Sample::~Sample() {}
}

View File

@@ -1,678 +0,0 @@
#define TISIGNWINDOW_IMPLEMENTATION
#include "keyboard/tiSignWindow.h"
#include "keyboard/tiManager.h"
#include "keyboard/tiLanguageIndependentData.h"
#include "keyboard/tiUtil.h"
#include <new>
#include <string.h>
#include <wchar.h>
namespace textinput {
namespace keyboard {
namespace signwindow {
struct AnimationFile {
u32 id;
char name[64];
};
struct PaneAnimation {
s32 type;
char paneName[20];
u32 animationCount;
const char* forceName;
const AnimationFile* animations[8];
};
struct PaneControlKey {
char paneName[20];
u32 key;
};
const char* csSgnKeys[20] = {
"P_SGNkey_00", "P_SGNkey_01", "P_SGNkey_02", "P_SGNkey_03", "P_SGNkey_04",
"P_SGNkey_05", "P_SGNkey_06", "P_SGNkey_07", "P_SGNkey_08", "P_SGNkey_09",
"P_SGNkey_10", "P_SGNkey_11", "P_SGNkey_12", "P_SGNkey_13", "P_SGNkey_14",
"P_SGNkey_15", "P_SGNkey_16", "P_SGNkey_17", "P_SGNkey_18", "P_SGNkey_19",
};
static const char* csSgnKeyBase = "P_SGNkey_00";
static const char* csSgnKeyClose = "P_SGNkey_close";
const AnimationFile csAninationFileForSign[9] = {
{0, "fs_signWindow_a_SGN_normal.brlan"},
{1, "fs_signWindow_a_SGN_FADE-IN.brlan"},
{8, "fs_signWindow_a_Scroll_FADE-OUT.brlan"},
{2, "fs_signWindow_a_SGN_Focus-IN.brlan"},
{6, "fs_signWindow_a_SGN_Focus-OUT.brlan"},
{3, "fs_signWindow_a_SGN_Roll_over.brlan"},
{4, "fs_signWindow_a_SGN_Pushed.brlan"},
{7, "fs_signWindow_a_SGN_scroll_next.brlan"},
{5, "fs_signWindow_a_SGN_scroll_prev.brlan"},
};
static const PaneControlKey csPaneNameToControlKey[3] = {
{"B_SGNkey_close", 0x18},
{"B_SGNkey_prev", 0x1A},
{"B_SGNkey_next", 0x19},
};
static const LanguageDependency csLanguageDependencyData[10] = {
{4, csSignKeyJP}, {10, csSignKeyUS}, {10, csSignKeyUK}, {10, csSignKeyFR}, {10, csSignKeyDE},
{10, csSignKeyIT}, {10, csSignKeySP}, {10, csSignKeyNL}, {4, csSignKeyCN}, {4, csSignKeyKR},
};
struct InputCharacter {
wchar_t character;
u16 type;
bool repeat;
u32 value;
};
static const InputCharacter inputCharacterTemplate = {0, 3, false, 0};
static PaneAnimation csPaneToAnimationInSign[25] = {
{0, "N_SGNkeytop_all", 3, 0, {&csAninationFileForSign[0], &csAninationFileForSign[1], &csAninationFileForSign[2]}},
{1, "N_SGNkeyall", 3, 0, {&csAninationFileForSign[0], &csAninationFileForSign[7], &csAninationFileForSign[8]}},
{2, "P_SGNkey_00", 7, 0, {&csAninationFileForSign[0], &csAninationFileForSign[1], &csAninationFileForSign[2], &csAninationFileForSign[3], &csAninationFileForSign[4], &csAninationFileForSign[5], &csAninationFileForSign[6]}},
{2, "P_SGNkey_01", 7, csSgnKeyBase, {&csAninationFileForSign[0], &csAninationFileForSign[1], &csAninationFileForSign[2], &csAninationFileForSign[3], &csAninationFileForSign[4], &csAninationFileForSign[5], &csAninationFileForSign[6]}},
{2, "P_SGNkey_02", 7, csSgnKeyBase, {&csAninationFileForSign[0], &csAninationFileForSign[1], &csAninationFileForSign[2], &csAninationFileForSign[3], &csAninationFileForSign[4], &csAninationFileForSign[5], &csAninationFileForSign[6]}},
{2, "P_SGNkey_03", 7, csSgnKeyBase, {&csAninationFileForSign[0], &csAninationFileForSign[1], &csAninationFileForSign[2], &csAninationFileForSign[3], &csAninationFileForSign[4], &csAninationFileForSign[5], &csAninationFileForSign[6]}},
{2, "P_SGNkey_04", 7, csSgnKeyBase, {&csAninationFileForSign[0], &csAninationFileForSign[1], &csAninationFileForSign[2], &csAninationFileForSign[3], &csAninationFileForSign[4], &csAninationFileForSign[5], &csAninationFileForSign[6]}},
{2, "P_SGNkey_05", 7, csSgnKeyBase, {&csAninationFileForSign[0], &csAninationFileForSign[1], &csAninationFileForSign[2], &csAninationFileForSign[3], &csAninationFileForSign[4], &csAninationFileForSign[5], &csAninationFileForSign[6]}},
{2, "P_SGNkey_06", 7, csSgnKeyBase, {&csAninationFileForSign[0], &csAninationFileForSign[1], &csAninationFileForSign[2], &csAninationFileForSign[3], &csAninationFileForSign[4], &csAninationFileForSign[5], &csAninationFileForSign[6]}},
{2, "P_SGNkey_07", 7, csSgnKeyBase, {&csAninationFileForSign[0], &csAninationFileForSign[1], &csAninationFileForSign[2], &csAninationFileForSign[3], &csAninationFileForSign[4], &csAninationFileForSign[5], &csAninationFileForSign[6]}},
{2, "P_SGNkey_08", 7, csSgnKeyBase, {&csAninationFileForSign[0], &csAninationFileForSign[1], &csAninationFileForSign[2], &csAninationFileForSign[3], &csAninationFileForSign[4], &csAninationFileForSign[5], &csAninationFileForSign[6]}},
{2, "P_SGNkey_09", 7, csSgnKeyBase, {&csAninationFileForSign[0], &csAninationFileForSign[1], &csAninationFileForSign[2], &csAninationFileForSign[3], &csAninationFileForSign[4], &csAninationFileForSign[5], &csAninationFileForSign[6]}},
{2, "P_SGNkey_10", 7, csSgnKeyBase, {&csAninationFileForSign[0], &csAninationFileForSign[1], &csAninationFileForSign[2], &csAninationFileForSign[3], &csAninationFileForSign[4], &csAninationFileForSign[5], &csAninationFileForSign[6]}},
{2, "P_SGNkey_11", 7, csSgnKeyBase, {&csAninationFileForSign[0], &csAninationFileForSign[1], &csAninationFileForSign[2], &csAninationFileForSign[3], &csAninationFileForSign[4], &csAninationFileForSign[5], &csAninationFileForSign[6]}},
{2, "P_SGNkey_12", 7, csSgnKeyBase, {&csAninationFileForSign[0], &csAninationFileForSign[1], &csAninationFileForSign[2], &csAninationFileForSign[3], &csAninationFileForSign[4], &csAninationFileForSign[5], &csAninationFileForSign[6]}},
{2, "P_SGNkey_13", 7, csSgnKeyBase, {&csAninationFileForSign[0], &csAninationFileForSign[1], &csAninationFileForSign[2], &csAninationFileForSign[3], &csAninationFileForSign[4], &csAninationFileForSign[5], &csAninationFileForSign[6]}},
{2, "P_SGNkey_14", 7, csSgnKeyBase, {&csAninationFileForSign[0], &csAninationFileForSign[1], &csAninationFileForSign[2], &csAninationFileForSign[3], &csAninationFileForSign[4], &csAninationFileForSign[5], &csAninationFileForSign[6]}},
{2, "P_SGNkey_15", 7, csSgnKeyBase, {&csAninationFileForSign[0], &csAninationFileForSign[1], &csAninationFileForSign[2], &csAninationFileForSign[3], &csAninationFileForSign[4], &csAninationFileForSign[5], &csAninationFileForSign[6]}},
{2, "P_SGNkey_16", 7, csSgnKeyBase, {&csAninationFileForSign[0], &csAninationFileForSign[1], &csAninationFileForSign[2], &csAninationFileForSign[3], &csAninationFileForSign[4], &csAninationFileForSign[5], &csAninationFileForSign[6]}},
{2, "P_SGNkey_17", 7, csSgnKeyBase, {&csAninationFileForSign[0], &csAninationFileForSign[1], &csAninationFileForSign[2], &csAninationFileForSign[3], &csAninationFileForSign[4], &csAninationFileForSign[5], &csAninationFileForSign[6]}},
{2, "P_SGNkey_18", 7, csSgnKeyBase, {&csAninationFileForSign[0], &csAninationFileForSign[1], &csAninationFileForSign[2], &csAninationFileForSign[3], &csAninationFileForSign[4], &csAninationFileForSign[5], &csAninationFileForSign[6]}},
{2, "P_SGNkey_19", 7, csSgnKeyBase, {&csAninationFileForSign[0], &csAninationFileForSign[1], &csAninationFileForSign[2], &csAninationFileForSign[3], &csAninationFileForSign[4], &csAninationFileForSign[5], &csAninationFileForSign[6]}},
{2, "P_SGNkey_prev", 7, csSgnKeyClose, {&csAninationFileForSign[0], &csAninationFileForSign[1], &csAninationFileForSign[2], &csAninationFileForSign[3], &csAninationFileForSign[4], &csAninationFileForSign[5], &csAninationFileForSign[6]}},
{2, "P_SGNkey_next", 7, csSgnKeyClose, {&csAninationFileForSign[0], &csAninationFileForSign[1], &csAninationFileForSign[2], &csAninationFileForSign[3], &csAninationFileForSign[4], &csAninationFileForSign[5], &csAninationFileForSign[6]}},
{2, "P_SGNkey_close", 7, 0, {&csAninationFileForSign[0], &csAninationFileForSign[1], &csAninationFileForSign[2], &csAninationFileForSign[3], &csAninationFileForSign[4], &csAninationFileForSign[5], &csAninationFileForSign[6]}},
};
static inline s32 findControlKey(const char* paneName) {
u32 index = 0;
do {
if (util::strcmp(csPaneNameToControlKey[index & 0xFFFF].paneName, paneName))
return csPaneNameToControlKey[index & 0xFFFF].key;
++index;
} while (index < 3);
return 0x1B;
}
static inline wchar_t findSignCharacter(const PaneNameToCharCodeInSignMode* keys, u16 page, const char* paneName) {
u32 index = 0;
do {
if (util::strcmp(keys[index & 0xFFFF].szPaneName, paneName))
return keys[index & 0xFFFF].wc[page];
++index;
} while (index < 20);
return 0;
}
void Base::create(MEMAllocator*) {
muPage = 0;
mbLocked = 0;
mbRepeat = 0;
mpLanguageDependency = &csLanguageDependencyData[getLanguage()];
}
void Base::init() {
muPage = 0;
mbLocked = 0;
mbRepeat = 0;
mpLanguageDependency = &csLanguageDependencyData[getLanguage()];
}
void Base::onKey(u32 command, void* data) {
s32 key;
if (command != 4) {
return;
}
key = findControlKey(static_cast<const char*>(data));
if (key != 0x1B) {
switch (key) {
case 0x18:
close();
break;
case 0x1A:
movePrevSignPage();
break;
case 0x19:
moveNextSignPage();
break;
}
return;
}
u16 code = findSignCharacter(mpLanguageDependency->keys, muPage, static_cast<const char*>(data));
if (code != 0) {
InputCharacter input = inputCharacterTemplate;
input.character = code;
input.repeat = mbRepeat;
if (mpManager->getInputForm()->isAtokActive()) {
input.repeat = true;
}
if (meLanguage - 8U <= 1U) {
input.repeat = 1;
}
sendCommand(5, &input);
}
}
void Base::close() {}
void Base::movePrevSignPage() {
if (muPage == 0) {
muPage = mpLanguageDependency->count - 1;
return;
}
muPage = muPage - 1;
return;
}
void Base::moveNextSignPage() {
u8 page = muPage + 1;
muPage = page;
if (page < mpLanguageDependency->count) {
return;
}
muPage = 0;
return;
}
LayoutByNW4R::~LayoutByNW4R() {
mpEventHandler->~EventHandler();
MEMFreeToAllocator(mpAllocator, mpEventHandler);
AnmPane* pane = static_cast<AnmPane*>(nw4r::ut::List_GetNext(&mAnmPanes, NULL));
while (pane != NULL) {
nw4r::ut::List_Remove(&mAnmPanes, pane);
pane->destroy(mpAllocator);
pane = static_cast<AnmPane*>(nw4r::ut::List_GetNext(&mAnmPanes, NULL));
}
}
Base::~Base() {}
EventHandler::~EventHandler() {}
void LayoutByNW4R::create(MEMAllocator* allocator) {
mpAllocator = allocator;
Base::create(allocator);
void* eventBuffer = MEMAllocFromAllocator(allocator, sizeof(EventHandler));
mpEventHandler = new (eventBuffer) EventHandler(this);
Layout::createWithEventHandler(allocator, mpEventHandler);
mpPaneManager->setAllComponentTriggerTarget(false);
mpPaneManager->setAllBoundingBoxComponentTriggerTarget(true);
const char* forceName;
u32 animationCount;
u32 paneIndex = 0;
do {
AnmPane* pane = NULL;
const PaneAnimation& paneInfo = csPaneToAnimationInSign[paneIndex & 0xFFFF];
switch (paneInfo.type) {
case 2: {
void* paneBuffer = MEMAllocFromAllocator(allocator, sizeof(CellPhoneSignButtonPane));
pane = new (paneBuffer) CellPhoneSignButtonPane(getPane(paneInfo.paneName), this);
break;
}
case 1: {
void* paneBuffer = MEMAllocFromAllocator(allocator, sizeof(CellPhoneSignScrollAnmPane));
pane = new (paneBuffer) CellPhoneSignScrollAnmPane(getPane(paneInfo.paneName), this);
break;
}
case 0: {
void* paneBuffer = MEMAllocFromAllocator(allocator, sizeof(CellPhoneSignAllAnmPane));
pane = new (paneBuffer) CellPhoneSignAllAnmPane(getPane(paneInfo.paneName), this);
break;
}
}
nw4r::ut::List_Append(&mAnmPanes, pane);
forceName = paneInfo.forceName;
animationCount = paneInfo.animationCount;
u16 animationIndex = 0;
while (animationIndex < animationCount) {
void* resource = mpMultiArcResourceAccessor->GetResource(0, paneInfo.animations[animationIndex]->name);
AnimTransformPane* transform = static_cast<AnimTransformPane*>(
getLayout()->CreateAnimTransform(resource, mpMultiArcResourceAccessor));
if (forceName != NULL) {
pane->forceAddAnimation(allocator, paneInfo.animations[animationIndex]->id, transform, forceName, false, true);
} else {
pane->addAnimation(allocator, paneInfo.animations[animationIndex]->id, transform, false, true);
}
++animationIndex;
}
++paneIndex;
} while (paneIndex < 25);
init();
}
AnmPane::~AnmPane() {}
void LayoutByNW4R::init() {
Base::init();
searchAnmPane("N_SGNkeytop_all")->changeAnimation(0);
setVisible("N_SGNkeytop_all", true);
searchAnmPane("P_SGNkey_prev")->changeAnimation(0);
searchAnmPane("P_SGNkey_next")->changeAnimation(0);
setSignKeyTop(muPage, muPage);
setPageNumber(muPage);
mpLayout->Animate(0);
mpLayout->CalculateMtx(mDrawInfo);
}
void LayoutByNW4R::onKey(u32 command, void* data) {
Base::onKey(command, data);
if (command == 4) {
s32 key;
const char* paneName = static_cast<const char*>(data);
key = findControlKey(paneName);
if (key == 0x1B) {
goto character;
}
switch (key) {
case 0x18:
mpEventObserver->onSE(sound::SE_CHAR_DECIDE);
break;
case 0x19:
case 0x1A:
break;
}
return;
character:
u16 code = findSignCharacter(mpLanguageDependency->keys, muPage, paneName);
if ((code != 0) && (mpKeyboard->getType() == 0)) {
sendCommand(0x27, NULL);
}
}
}
void LayoutByNW4R::open(KeyboardBase* keyboard, bool input) {
resetAnmSignWindow();
throwReleaseForAll();
getPaneManager()->init();
if (meLanguage - 8U <= 1U) {
sendCommand(6, NULL);
}
mbActive = 1;
mbInput = 0;
mpKeyboard = keyboard;
initPaneLastDrawReceived();
mbRepeat = input;
setSignKeyTop(muPage, muPage);
setPageNumber(muPage);
searchAnmPane("N_SGNkeytop_all")->onAnmEvent(nw4rmanager::AnmPane::PE_6);
mpEventObserver->onSE(sound::SE_SYMBOL_PAGE_OPEN);
}
void LayoutByNW4R::close() {
if (mpKeyboard->getType() == 0) {
keyboard::pctype::LayoutByNW4R* keyboard = static_cast<keyboard::pctype::LayoutByNW4R*>(mpKeyboard);
static_cast<nw4rmanager::Layout&>(*keyboard).getLayout()->GetRootPane()->SetVisible(true);
}
searchAnmPane("N_SGNkeytop_all")->onAnmEvent(nw4rmanager::AnmPane::PE_7);
mbInput = 0;
}
void LayoutByNW4R::endToClose() {
if (mpKeyboard != NULL) {
mpKeyboard->update();
}
mbActive = 0;
setVisible("N_SGNkeytop_all", false);
}
void LayoutByNW4R::startToInput() {
mbInput = 1;
if (mpKeyboard->getType() == 0) {
keyboard::pctype::LayoutByNW4R* keyboard = static_cast<keyboard::pctype::LayoutByNW4R*>(mpKeyboard);
static_cast<nw4rmanager::Layout&>(*keyboard).getLayout()->GetRootPane()->SetVisible(false);
}
}
void LayoutByNW4R::onChangeAnmState(AnmEvent event, nw4rmanager::AnmPane* pane, nw4rmanager::Anim* anim) {
if (util::strcmp("N_SGNkeyall", pane->getPane()->GetName()) &&
((anim->muID == 7 || anim->muID == 5) && event == nw4rmanager::AnmObserver::E_1)) {
setSignKeyTop(muPage, muPage);
}
if (util::strcmp("N_SGNkeytop_all", pane->getPane()->GetName())) {
if ((anim->muID == 8) && (event == nw4rmanager::AnmObserver::E_1)) {
endToClose();
}
if ((anim->muID == 1) && (event == nw4rmanager::AnmObserver::E_1)) {
startToInput();
}
}
if (anim->muID == 7 || anim->muID == 5) {
if (event == nw4rmanager::AnmObserver::E_0) {
mbLocked = 1;
}
if (event == nw4rmanager::AnmObserver::E_1) {
mbLocked = 0;
}
}
}
void LayoutByNW4R::throwReleaseForAll() {
nw4rmanager::AnmPane* pane = static_cast<nw4rmanager::AnmPane*>(nw4r::ut::List_GetNext(&mAnmPanes, NULL));
while (pane != NULL) {
s32 keyType = static_cast<AnmPane*>(pane)->getKeyType();
if (keyType == 2) {
pane->onAnmEvent(nw4rmanager::AnmPane::PE_2);
}
pane = static_cast<nw4rmanager::AnmPane*>(nw4r::ut::List_GetNext(&mAnmPanes, pane));
}
}
u32 AnmPane::getKeyType() const {
return muKeyType;
}
void LayoutByNW4R::resetAnmSignWindow() {
for (u16 i = 0; i < 25; i++) {
searchAnmPane(csPaneToAnimationInSign[i].paneName)->init();
}
}
void AnmPane::init() {
muAnimation = 0;
}
void LayoutByNW4R::setSignKeyTop(u16 oldPage, u16 newPage) {
char paneName[17];
wchar_t oldCharacter[2];
wchar_t newCharacter[2];
for (u16 i = 0; i < 20; i++) {
const char* sourcePaneName = mpLanguageDependency->keys[i].szPaneName;
memset(paneName, 0, 0x11);
strncpy(paneName, sourcePaneName, strlen(sourcePaneName));
paneName[0] = 'T';
oldCharacter[0] = mpLanguageDependency->keys[i].wc[oldPage];
oldCharacter[1] = 0;
const char* nextPaneName = mpLanguageDependency->keys[i].szNextPaneName;
newCharacter[0] = mpLanguageDependency->keys[i].wc[newPage];
newCharacter[1] = 0;
nw4r::lyt::TextBox* textBox = static_cast<nw4r::lyt::TextBox*>(getPane(paneName));
textBox->SetString(oldCharacter, 0);
textBox = static_cast<nw4r::lyt::TextBox*>(getPane(nextPaneName));
textBox->SetString(newCharacter, 0);
}
setString("T_SGNkey_prev", langindependent::cLanguageIndependentString[langindependent::LANG_STRID_PREV][getLanguage()]);
setString("T_SGNkey_next", langindependent::cLanguageIndependentString[langindependent::LANG_STRID_NEXT][getLanguage()]);
setString("T_SGNkey_close", langindependent::cLanguageIndependentString[langindependent::LANG_STRID_CLOSE][getLanguage()]);
}
void LayoutByNW4R::setPageNumber(u16 page) {
wchar_t text[17];
swprintf(text, 0x11, L"%d/%d", page + 1, mpLanguageDependency->count);
nw4r::lyt::TextBox* textBox = static_cast<nw4r::lyt::TextBox*>(getPane("T_SGN_pageNumber"));
textBox->SetString(text, 0);
}
void LayoutByNW4R::movePrevSignPage() {
u8 oldPage = muPage;
if (oldPage == 0) {
muPage = mpLanguageDependency->count - 1;
} else {
muPage = oldPage - 1;
}
u8 newPage = muPage;
setSignKeyTop(oldPage, newPage);
setPageNumber(newPage);
movePrevSignWindow();
mpEventObserver->onSE(sound::SE_15);
}
void LayoutByNW4R::moveNextSignPage() {
u8 oldPage = muPage;
u8 page = oldPage + 1;
muPage = page;
if (page >= mpLanguageDependency->count) {
muPage = 0;
}
u8 newPage = muPage;
setSignKeyTop(oldPage, newPage);
setPageNumber(newPage);
moveNextSignWindow();
mpEventObserver->onSE(sound::SE_15);
}
void LayoutByNW4R::movePrevSignWindow() {
searchAnmPane("N_SGNkeyall")->onAnmEvent(static_cast<nw4rmanager::AnmPane::AnmPaneEvent>(8));
}
void LayoutByNW4R::moveNextSignWindow() {
searchAnmPane("N_SGNkeyall")->onAnmEvent(static_cast<nw4rmanager::AnmPane::AnmPaneEvent>(9));
}
bool LayoutByNW4R::updateInput(int point, f32 x, f32 y, u32 trig, u32 hold, u32 release, void* data) {
if (mbInput != 0) {
return nw4rmanager::Layout::updateInput(point, x, y, trig, hold, release, data);
}
return false;
}
bool LayoutByNW4R::updateInput(input::HKBManager& manager) {
if (mbInput == 0) {
return false;
}
input::HKBManager::KeySet keySet = manager.GetTriggeredKeySet();
if (keySet.IsValid()) {
throwReleaseForAll();
close();
mpEventObserver->onSE(sound::SE_CHAR_DECIDE);
return false;
}
return nw4rmanager::Layout::updateInput(manager);
}
void EventHandler::onTiEvent(gui::PaneComponent* paneComponent, u32 event, Input* input) {
s32 eventType = event;
const char* name = paneComponent->getPane()->GetName();
if (!mpLayoutByNW4R->isLocked() || event != 4) {
if (event == 4 && (input->trigger & 0x800) != 0) {
mpLayoutByNW4R->onKey(4, const_cast<char*>(name));
}
if (name[0] == 'B') {
char paneName[24];
memset(paneName, 0, 0x11);
strncpy(paneName, name, strlen(name));
paneName[0] = 'P';
AnmPane* pane = static_cast<AnmPane*>(mpLayoutByNW4R->searchAnmPane(paneName));
if (pane != NULL) {
switch (eventType) {
case 4:
if ((input->trigger & 0x800) != 0) {
pane->onAnmEvent(nw4rmanager::AnmPane::PE_0);
}
break;
case 1:
pane->onAnmEvent(nw4rmanager::AnmPane::PE_2);
break;
case 0:
mpEventObserver->onSE(sound::SE_SELECT);
mpLayoutByNW4R->setPaneLastDrawReceived(pane->getPane());
pane->onAnmEvent(nw4rmanager::AnmPane::PE_1);
break;
}
}
}
}
}
bool Base::isLocked() {
return mbLocked;
}
void CellPhoneSignAllAnmPane::onAnmEvent(AnmPaneEvent event) {
if (event == 6) {
getPane()->SetVisible(true);
changeAnimation(1);
return;
}
if (event == 7) {
changeAnimation(8);
return;
}
if (muAnimation != 8) {
if (muAnimation >= 8) {
return;
}
if (muAnimation != 1) {
return;
}
if (event != 4) {
return;
}
changeAnimation(0);
return;
}
if (event == 4) {
getPane()->SetVisible(false);
}
}
void AnmPane::changeAnimation(u32 animation) {
muAnimation = animation;
nw4rmanager::AnmPane::changeAnimation(animation);
}
void CellPhoneSignScrollAnmPane::onAnmEvent(AnmPaneEvent event) {
switch (muAnimation) {
case 0:
if (event == 9) {
changeAnimation(5);
}
if (event != 8) {
return;
}
changeAnimation(7);
return;
case 5:
case 7:
if (event != 4) {
return;
}
changeAnimation(0);
return;
default:
return;
}
}
void CellPhoneSignButtonPane::onAnmEvent(AnmPaneEvent event) {
if (event == 0) {
changeAnimation(4);
}
switch (muAnimation) {
case 0:
if (event == 1) {
changeAnimation(2);
}
break;
case 2:
if (event == 4) {
changeAnimation(3);
}
if (event == 2) {
changeAnimation(6);
}
break;
case 3:
if (event == 2) {
changeAnimation(6);
}
break;
case 6:
if (event == 4) {
changeAnimation(0);
}
if (event == 1) {
changeAnimation(2);
}
break;
case 4:
if (event == 4) {
changeAnimation(3);
}
if (event == 2) {
changeAnimation(6);
}
break;
}
}
void LayoutByNW4R::draw() {
nw4rmanager::Layout::draw();
}
}
void KeyboardBase::onActive() {}
namespace signwindow {
u8 Base::getPage() {
return muPage;
}
void Base::setPage(u8 page) {
muPage = page;
if (muPage < mpLanguageDependency->count) {
return;
}
muPage = 0;
}
void Base::setLanguage(Language language) {
meLanguage = language;
init();
}
int Base::getType() {
return 2;
}
bool LayoutByNW4R::isActive() {
return mbActive;
}
CellPhoneSignButtonPane::~CellPhoneSignButtonPane() {}
void CellPhoneSignButtonPane::init() {
muAnimation = 0;
}
void CellPhoneSignScrollAnmPane::init() {
muAnimation = 0;
}
CellPhoneSignAllAnmPane::~CellPhoneSignAllAnmPane() {}
void CellPhoneSignAllAnmPane::init() {
muAnimation = 0;
}
CellPhoneSignScrollAnmPane::~CellPhoneSignScrollAnmPane() {}
}
}
}

View File

@@ -84,7 +84,7 @@ void sendCardFormatCmd(u8 slot) {
}
void sendCardCopyCmd(u8 slot, s16 fileNo) {
u32 message = ((u32)fileNo & 0xFF) << 24 | ((slot & 1) << 16);
u32 message = ((u8)fileNo << 24) | ((slot & 1) << 16);
sThread->sourceSlot = slot;
sThread->lastCommand = 2;
sThread->lastResult = -21;
@@ -94,7 +94,7 @@ void sendCardCopyCmd(u8 slot, s16 fileNo) {
}
void sendCardMoveCmd(u8 slot, s16 fileNo) {
u32 message = ((u32)fileNo & 0xFF) << 24 | ((slot & 1) << 16);
u32 message = ((u8)fileNo << 24) | ((slot & 1) << 16);
sThread->sourceSlot = slot;
sThread->lastCommand = 3;
sThread->lastResult = -21;
@@ -104,7 +104,7 @@ void sendCardMoveCmd(u8 slot, s16 fileNo) {
}
void sendCardDeleteCmd(u8 slot, s16 fileNo) {
u32 message = ((u32)fileNo & 0xFF) << 24 | ((slot & 1) << 16);
u32 message = ((u8)fileNo << 24) | ((slot & 1) << 16);
sThread->sourceSlot = slot;
sThread->lastCommand = 4;
sThread->lastResult = -21;
@@ -805,19 +805,19 @@ iconSpeedDone:
sThread->icons[slot][fileNo].iconOffset[iconCount + 1] =
paletteSize + sThread->icons[slot][fileNo].iconOffset[iconCount];
} else {
sThread->icons[slot][fileNo].iconTlutOffset =
sThread->icons[0][0].iconTlutOffset =
paletteSize + sThread->icons[slot][fileNo].iconOffset[iconCount];
}
iconImageSize += paletteSize;
sThread->icons[slot][fileNo].unk_0x02 =
sThread->icons[slot][fileNo].unk_0x02 + 1;
iconCount = iconCount + 1;
shift += 2;
} else {
sThread->icons[slot][fileNo].iconTlutOffset =
sThread->icons[slot][fileNo].iconOffset[iconCount];
break;
}
++iconCount;
shift += 2;
}
if (hasTlut) {
iconImageSize += 0x200;

View File

@@ -1,804 +0,0 @@
#define IPL_SD_CHANNEL_OBJ_CPP
#include "scene/sdChannelSelect/iplSDChannelSelect.h"
#include "iplSound.h"
#include "iplSystem.h"
#include <private/es.h>
#include <revolution/sc.h>
namespace ipl {
namespace scene {
static const wchar_t scUnknownName[] = L"???";
static const char* scCursur = "Cursur_a";
static const char* scCursorAnims[] = {
"my_IplTop_d_FocusOff.brlan",
"my_IplTop_d_FocusOn.brlan",
"my_IplTop_d_Select.brlan",
};
static const char* scBalloon = "T_Balloon";
static const char* scBase = "W_Base";
static const char* scShade = "W_Shade";
static const char* scLangGroups[] = {"JPN", "ENG", "GER", "FRA", "SPA", "ITA", "NED", "CHN", "ENG", "KOR"};
static const char* scRegionGroups[SC_PRODUCT_AREA_MAX][16] = {
{"JPN"},
{"ENG", "FRA", "SPA"},
{"ENG", "FRA", "GER", "SPA", "ITA", "NED"},
{NULL},
{NULL},
{NULL},
{"KOR"},
{NULL},
{NULL},
{NULL},
{NULL},
{"CHN"},
};
static const u32 scLangLookup[SC_PRODUCT_AREA_MAX][16] = {
{SC_LANG_JAPANESE, -1},
{SC_LANG_ENGLISH, SC_LANG_FRENCH, SC_LANG_SPANISH, -1},
{SC_LANG_ENGLISH, SC_LANG_FRENCH, SC_LANG_GERMAN, SC_LANG_SPANISH, SC_LANG_ITALIAN, SC_LANG_DUTCH, -1},
{-1},
{-1},
{-1},
{SC_LANG_KOREAN, -1},
{-1},
{-1},
{-1},
{-1},
{SC_PRODUCT_AREA_HKG, -1},
};
static const f32 scThumbnailOffsets[][2] = {{64.0f, 48.0f}, {85.0f, 48.0f}};
extern "C" void iplSDChannelObj_813E3104(SDChannelObj* channel) NO_INLINE;
extern "C" void iplSDChannelObj_813E311C(SDChannelObj* channel, EGG::ExpHeap* firstHeap,
EGG::ExpHeap* secondHeap) NO_INLINE;
extern "C" void* iplSDChannelObj_813E3128(SDChannelObj* channel) NO_INLINE;
extern "C" void iplSDChannelObj_813E3178(SDChannelObj* channel, nw4r::lyt::Pane* pane) NO_INLINE;
extern "C" void iplSDChannelObj_813E3180(SDChannelObj* channel, nand::LayoutFile* layoutFile) NO_INLINE;
extern "C" void iplSDChannelObj_813E322C(SDChannelObj* channel) NO_INLINE;
extern "C" void iplSDChannelObj_813E32C8(SDChannelObj* channel) NO_INLINE;
extern "C" void iplSDChannelObj_813E3304(SDChannelObj* channel) NO_INLINE;
extern "C" void iplSDChannelObj_813E330C(SDChannelObj* channel) NO_INLINE;
extern "C" bool iplSDChannelObj_813E3330(SDChannelObj* channel) NO_INLINE;
extern "C" void iplSDChannelObj_813E3354(SDChannelObj* channel, int request) NO_INLINE;
extern "C" void iplSDChannelObj_813E33EC(SDChannelObj* channel, int request) NO_INLINE;
extern "C" void iplSDChannelObj_813E3480(SDChannelObj* channel, bool request) NO_INLINE;
extern "C" void iplSDChannelObj_813E34E0(SDChannelObj* channel) NO_INLINE;
extern "C" void iplSDChannelObj_813E34E8(SDChannelObj* channel, int request) NO_INLINE;
extern "C" void iplSDChannelObj_813E3534(SDChannelObj* channel, bool request) NO_INLINE;
extern "C" void iplSDChannelObj_813E3580(const layout::Object* layout) NO_INLINE;
extern "C" void iplSDChannelObj_813E3858(SDChannelObj* channel) NO_INLINE;
extern "C" f32 iplSDChannelObj_813E3920(SDChannelObj* channel) NO_INLINE;
extern "C" f32 iplSDChannelObj_813E3A84(SDChannelObj* channel) NO_INLINE;
extern "C" void iplSDChannelObj_813E3B1C(SDChannelObj* channel) NO_INLINE;
extern "C" void iplSDChannelObj_813E3BA0(SDChannelObj* channel) NO_INLINE;
extern "C" void iplSDChannelObj_813E3C58(SDChannelObj* channel, const nw4r::math::VEC3& vec) NO_INLINE;
extern "C" void iplSDChannelObj_813E3C9C(SDChannelObj* channel, int request) NO_INLINE;
extern "C" void iplSDChannelObj_813E3E38(SDChannelObj* channel) NO_INLINE;
extern "C" void iplSDChannelObj_813E3F28(SDChannelObj* channel, int request) NO_INLINE;
extern "C" void iplSDChannelObj_813E3F74(SDChannelObj* channel) NO_INLINE;
extern "C" const wchar_t* iplSDChannelObj_813E4060(SDChannelObj* channel, int index) NO_INLINE;
extern "C" void iplSDChannelObj_813E413C(SDChannelObj* channel, const wchar_t* text) NO_INLINE;
extern "C" void iplSDChannelObj_813E4410(SDChannelObj* channel, const nw4r::math::VEC3& vec) NO_INLINE;
extern "C" void iplSDChannelObj_813E4558(SDChannelObj* channel, int request) NO_INLINE;
extern "C" void iplSDChannelObj_813E4704(SDChannelObj* channel) NO_INLINE;
extern "C" void iplSDChannelObj_813E481C(SDChannelObj* channel, layout::Object* layout) NO_INLINE;
extern "C" void iplSDChannelObj_813E49A8(SDChannelObj* channel) NO_INLINE;
extern "C" BOOL iplSDChannelObj_813E4A54(SDChannelObj* channel) NO_INLINE;
SDChannelObj::SDChannelObj(EGG::Heap* heap, int page, int index)
: mpHeap(heap), mpDialogHeap(NULL), mpChannelHeap(NULL), mState(0), mPage(page), mIndex(index),
mpPane(NULL), mpBaseLayout(NULL), mpPageLayout(NULL), mPageAnimation(0), mPageAnimationFrame(0),
mpDialogLayout(NULL), mDialogState(0), mDialogFrame(0), mDialogTimer(0), mAnimationState(0),
mpNewMessageGroup(NULL), mpNewMessageAnimator(NULL), mbNewMessageGroupActive(false), mNewMessageState(0),
mNewMessageFrame(0), mOffsetX(scThumbnailOffsets[SCGetAspectRatio()][0]),
mOffsetY(scThumbnailOffsets[SCGetAspectRatio()][1]), mStateFlags(1), mpThumbnailData(NULL) {
if (SCGetAspectRatio() == SC_ASPECT_RATIO_16x9) {
nw4r::ut::Rect projection4x3;
System::getProjectionRect4x3(&projection4x3);
nw4r::ut::Rect projection16x9;
System::getProjectionRect16x9(&projection16x9);
mAspectRatioScale = projection16x9.GetWidth() / projection4x3.GetWidth();
} else {
mAspectRatioScale = 1.0f;
}
memset(&mAppMeta, 0, sizeof(mAppMeta));
}
SDChannelObj::~SDChannelObj() {
if (mpBaseLayout != NULL)
mpBaseLayout->destroyHeap();
if (mpPageLayout != NULL)
delete mpPageLayout;
if (mpDialogLayout != NULL)
delete mpDialogLayout;
}
extern "C" void iplSDChannelObj_813E3104(SDChannelObj* channel) {
if (channel->mState == 0)
channel->mState = 2;
}
extern "C" void iplSDChannelObj_813E311C(SDChannelObj* channel, EGG::ExpHeap* firstHeap,
EGG::ExpHeap* secondHeap) {
channel->mpDialogHeap = firstHeap;
channel->mpChannelHeap = secondHeap;
}
extern "C" void* iplSDChannelObj_813E3128(SDChannelObj* channel) {
if (channel->mpThumbnailData == NULL)
channel->mpThumbnailData = new (channel->mpHeap, 32) u8[0x19000];
return channel->mpThumbnailData;
}
extern "C" void iplSDChannelObj_813E3178(SDChannelObj* channel, nw4r::lyt::Pane* pane) {
channel->mpPane = pane;
}
extern "C" void iplSDChannelObj_813E3180(SDChannelObj* channel, nand::LayoutFile* layoutFile) {
if (!SDChannelSelect::isChannelReady(channel)) {
channel->mpLayoutFile = layoutFile;
if (channel->mpPageLayout == NULL)
iplSDChannelObj_813E3BA0(channel);
if (channel->mpDialogLayout == NULL)
iplSDChannelObj_813E3F74(channel);
if (channel->mState == 2 || channel->mState == 1 && channel->mpPaneAnimator->isFinished()) {
iplSDChannelObj_813E3858(channel);
channel->mState = 3;
}
}
}
extern "C" void iplSDChannelObj_813E322C(SDChannelObj* channel) {
switch (channel->mState) {
case 0:
channel->mState = 2;
break;
case 1:
if (!channel->mpPaneAnimator->isFinished())
break;
channel->mState = 2;
case 2:
iplSDChannelObj_813E3858(channel);
channel->mState = 3;
break;
case 3:
iplSDChannelObj_813E3B1C(channel);
break;
}
}
extern "C" void iplSDChannelObj_813E32C8(SDChannelObj* channel) {
if (SDChannelSelect::isChannelReady(channel))
channel->mpBaseLayout->draw();
}
extern "C" void iplSDChannelObj_813E3304(SDChannelObj* channel) {
channel->mpPageLayout->draw();
}
extern "C" void iplSDChannelObj_813E330C(SDChannelObj* channel) {
if (channel->mpDialogLayout != NULL)
channel->mpDialogLayout->draw();
}
nw4r::math::VEC3& SDChannelObj::getTranslate() const {
return (nw4r::math::VEC3&)mpBaseLayout->GetRootPane()->GetTranslate();
}
extern "C" bool iplSDChannelObj_813E3330(SDChannelObj* channel) {
if (channel->mStateFlags == 0 || channel->mStateFlags == 3)
return true;
else
return false;
}
extern "C" void iplSDChannelObj_813E3354(SDChannelObj* channel, int request) {
if (request & 0x10000U) {
channel->mAnimationState = 0;
} else if (request & 0x20000U) {
channel->mAnimationState = 1;
} else if ((channel->mAnimationState += 1) > 1) {
return;
}
if (!(request & 1)) {
iplSDChannelObj_813E3C9C(channel, 1);
}
if (!(request & 2)) {
iplSDChannelObj_813E4558(channel, 1);
}
}
extern "C" void iplSDChannelObj_813E33EC(SDChannelObj* channel, int request) {
if (request & 0x10000U) {
channel->mAnimationState = 0;
} else if (request & 0x20000U) {
channel->mAnimationState = 1;
} else if ((channel->mAnimationState -= 1) > 0) {
return;
}
if (!(request & 1)) {
iplSDChannelObj_813E3C9C(channel, 3);
}
if (!(request & 2)) {
iplSDChannelObj_813E4558(channel, 4);
}
}
extern "C" void iplSDChannelObj_813E3480(SDChannelObj* channel, bool request) {
if (request) {
iplSDChannelObj_813E3C9C(channel, 1);
channel->mAnimationState = 1;
} else {
iplSDChannelObj_813E3C9C(channel, 0);
channel->mAnimationState = 0;
}
iplSDChannelObj_813E4558(channel, 0);
}
extern "C" void iplSDChannelObj_813E34E0(SDChannelObj* channel) {
iplSDChannelObj_813E3C9C(channel, 4);
}
extern "C" void iplSDChannelObj_813E34E8(SDChannelObj* channel, int request) {
iplSDChannelObj_813E3C9C(channel, 0);
if (request) {
channel->mAnimationState = 0;
}
}
extern "C" void iplSDChannelObj_813E3534(SDChannelObj* channel, bool request) {
iplSDChannelObj_813E4558(channel, 0);
if (request) {
channel->mAnimationState = 0;
}
}
extern "C" void iplSDChannelObj_813E3580(const layout::Object* layout) {
int lang = System::getLanguage();
const char* langGroup = scLangGroups[lang];
char availableLanguages[10][4] = {};
bool languageFound = false;
for (nw4r::lyt::GroupList::Iterator it = layout->GetGroupList().GetBeginIter();
it != layout->GetGroupList().GetEndIter(); it++) {
if (strcmp(it->GetName(), langGroup) == 0) {
languageFound = true;
} else {
bool languageGroup = true;
for (int i = 0; i < channel::MAX_ANIMS; i++) {
char name[8];
sprintf(name, "Rso%d", i);
if (strncmp(it->GetName(), name, 5) == 0) {
languageGroup = false;
break;
}
}
if (languageGroup) {
for (nw4r::lyt::PaneLinkList::Iterator it2 = it->GetPaneList().GetBeginIter();
it2 != it->GetPaneList().GetEndIter(); it2++) {
it2->mTarget->SetVisible(false);
}
for (int i = 0; i < 10; i++) {
if (strncmp(it->GetName(), scLangGroups[i], 3) == 0) {
memcpy(availableLanguages[i], it->GetName(), 3);
availableLanguages[i][3] = 0;
break;
}
}
}
}
}
if (languageFound) {
nw4r::lyt::Group* group = layout->FindGroupByName(langGroup);
for (nw4r::lyt::PaneLinkList::Iterator it = group->GetPaneList().GetBeginIter();
it != group->GetPaneList().GetEndIter(); it++) {
it->mTarget->SetVisible(true);
}
} else {
s32 region = System::getRegion();
for (int i = 0; i < channel::MAX_ANIMS; i++) {
if (scRegionGroups[region][i] != NULL) {
if (strcmp(scRegionGroups[region][i], availableLanguages[scLangLookup[region][i]]) == 0) {
nw4r::lyt::Group* group = layout->FindGroupByName(scRegionGroups[region][i]);
for (nw4r::lyt::PaneLinkList::Iterator it = group->GetPaneList().GetBeginIter();
it != group->GetPaneList().GetEndIter(); it++) {
it->mTarget->SetVisible(true);
}
break;
}
} else {
break;
}
}
}
}
extern "C" void iplSDChannelObj_813E3858(SDChannelObj* channel) {
bool adjust = false;
if (channel->mpDialogLayout == NULL)
iplSDChannelObj_813E3F74(channel);
f32 frame;
if (iplSDChannelObj_813E3330(channel))
frame = iplSDChannelObj_813E3920(channel);
else {
frame = iplSDChannelObj_813E3A84(channel);
adjust = true;
}
iplSDChannelObj_813E3B1C(channel);
if (channel->mpBaseAnimator != NULL)
channel->mpBaseAnimator->play();
channel->mpBaseLayout->finishBinding();
if (channel->mpBaseAnimator != NULL)
channel->mpBaseAnimator->setCurrentFrame(frame);
if (adjust)
channel->mpBaseLayout->adjustHeap();
}
extern "C" f32 iplSDChannelObj_813E3920(SDChannelObj* channel) {
f32 frame = 0.0f;
channel->mpBaseLayout =
layout::Object::create(channel->mpHeap, 0x8000, channel->mpThumbnailData, "arc", "icon.brlyt");
iplSDChannelObj_813E3580(channel->mpBaseLayout);
if (channel->mpBaseLayout->searchFile("icon.brlan"))
channel->mpBaseAnimator = channel->mpBaseLayout->bind("icon.brlan");
else if (channel->mpBaseLayout->searchFile("icon_Whole.brlan"))
channel->mpBaseAnimator = channel->mpBaseLayout->bind("icon_Whole.brlan");
else
channel->mpBaseAnimator = NULL;
if (channel->mpBaseAnimator != NULL) {
f32 minimum = channel->mpBaseAnimator->getMinFrame();
f32 maximum = channel->mpBaseAnimator->getMaxFrame();
frame = minimum + (System::getRndm()->get_u16() % (u16)(maximum - minimum));
}
if (channel->mStateFlags == 0) {
iplSDChannelObj_813E481C(channel, channel->mpBaseLayout);
channel->mNewMessageState = 1;
}
return frame;
}
extern "C" f32 iplSDChannelObj_813E3A84(SDChannelObj* channel) {
channel->mpBaseLayout =
layout::Object::create(channel->mpHeap, 0x8000, channel->mpLayoutFile, "arc", "mn_SdcardMenu_d.brlyt");
channel->mpBaseAnimator = channel->mpBaseLayout->bind("mn_SdcardMenu_d.brlan");
return System::getRndm()->get_u16() % 2000;
}
extern "C" void iplSDChannelObj_813E3B1C(SDChannelObj* channel) {
iplSDChannelObj_813E49A8(channel);
nw4r::math::VEC3 position(0, 0, 0);
MTXMultVec(channel->mpPane->GetGlobalMtx(), position, position);
channel->mpBaseLayout->GetRootPane()->SetTranslate(position);
channel->mpBaseLayout->calc();
iplSDChannelObj_813E3C58(channel, position);
iplSDChannelObj_813E4410(channel, position);
}
extern "C" void iplSDChannelObj_813E3BA0(SDChannelObj* channel) {
channel->mpPageLayout = new (channel->mpDialogHeap, 4)
layout::Object(channel->mpDialogHeap, channel->mpLayoutFile, "arc", "my_IplTop_d.brlyt");
for (int i = 0; i < 3; i++) {
channel->mpPageAnimators[i] = channel->mpPageLayout->bind(scCursorAnims[i], scCursur, false);
}
iplSDChannelObj_813E3C9C(channel, 0);
channel->mpPageLayout->finishBinding();
}
extern "C" void iplSDChannelObj_813E3C58(SDChannelObj* channel, const nw4r::math::VEC3& vec) {
channel->mpPageLayout->GetRootPane()->SetTranslate(vec);
iplSDChannelObj_813E3E38(channel);
channel->mpPageLayout->calc();
}
extern "C" void iplSDChannelObj_813E3C9C(SDChannelObj* channel, int request) {
if (request == 0) {
channel->mPageAnimation = 0;
channel->mPageAnimationFrame = 0;
for (int i = 0; i < 3; i++) {
channel->mpPageAnimators[i]->initFrame();
}
channel->mpPageLayout->getAnim(1)->initAnmFrame();
channel->mpPageLayout->GetRootPane()->SetVisible(false);
} else if (request == 4) {
channel->mPageAnimation = 4;
channel->mPageAnimationFrame = 0;
channel->mpPageLayout->GetRootPane()->SetVisible(true);
iplSDChannelObj_813E3F28(channel, 2);
} else {
switch (channel->mPageAnimation) {
case 0: {
if (request == 1) {
channel->mPageAnimation = 1;
channel->mpPageLayout->GetRootPane()->SetVisible(true);
iplSDChannelObj_813E3F28(channel, 1);
}
break;
}
case 1: {
if (request == 2) {
channel->mPageAnimation = 2;
} else if (request == 3) {
channel->mPageAnimationFrame = 3;
} else if (request == 1) {
channel->mPageAnimationFrame = 0;
}
break;
}
case 2: {
if (request == 3) {
channel->mPageAnimation = 3;
iplSDChannelObj_813E3F28(channel, 0);
}
break;
}
case 3: {
if (request == 1) {
channel->mPageAnimationFrame = 1;
} else if (request == 3) {
channel->mPageAnimationFrame = 0;
}
break;
}
}
}
}
extern "C" void iplSDChannelObj_813E3E38(SDChannelObj* channel) {
switch (channel->mPageAnimation) {
case 1: {
if (!channel->mpPageAnimators[1]->isPlaying()) {
int prev = channel->mPageAnimationFrame;
switch (channel->mPageAnimation) {
case 0:
break;
case 1:
channel->mPageAnimation = 2;
break;
case 2:
break;
case 3:
break;
default:
break;
}
if (prev == 3) {
iplSDChannelObj_813E3C9C(channel, 3);
channel->mPageAnimationFrame = 0;
}
}
break;
}
case 3: {
if (!channel->mpPageAnimators[0]->isPlaying()) {
int prev = channel->mPageAnimationFrame;
iplSDChannelObj_813E3C9C(channel, 0);
if (prev == 1) {
iplSDChannelObj_813E3C9C(channel, 1);
}
}
break;
}
case 4: {
if (!channel->mpPageAnimators[2]->isPlaying()) {
iplSDChannelObj_813E3C9C(channel, 0);
}
break;
}
}
}
extern "C" void iplSDChannelObj_813E3F28(SDChannelObj* channel, int request) {
channel->mpPageAnimators[request]->setAnmType(ANIM_TYPE_FORWARD);
channel->mpPageAnimators[request]->play();
}
extern "C" void iplSDChannelObj_813E3F74(SDChannelObj* channel) {
if (!iplSDChannelObj_813E3330(channel)) {
channel->mpDialogLayout = NULL;
return;
}
channel->mpDialogLayout = new (channel->mpChannelHeap, 4)
layout::Object(channel->mpChannelHeap, channel->mpLayoutFile, "arc", "my_IplTopBalloon_a.brlyt");
if (channel->mStateFlags == 0)
iplSDChannelObj_813E413C(channel, iplSDChannelObj_813E4060(channel, 0));
else if (channel->mStateFlags == 3)
iplSDChannelObj_813E413C(channel, scUnknownName);
else
iplSDChannelObj_813E413C(channel, L"");
channel->mpDialogAnimator = channel->mpDialogLayout->bind("my_IplTopBalloon_a_BalloonInOut.brlan");
iplSDChannelObj_813E4558(channel, 0);
channel->mpDialogLayout->finishBinding();
}
extern "C" const wchar_t* iplSDChannelObj_813E4060(SDChannelObj* channel, int index) {
if (channel->mAppMeta.metaHdr.names[System::getLanguage()][index][0] != 0)
return channel->mAppMeta.metaHdr.names[System::getLanguage()][index];
const u32* languages = scLangLookup[System::getRegion()];
for (int i = 0; i < 16; ++i) {
if (channel->mAppMeta.metaHdr.names[languages[i]][index][0] != 0)
return channel->mAppMeta.metaHdr.names[languages[i]][index];
if (languages[i] == -1)
break;
}
return channel->mAppMeta.metaHdr.names[languages[0]][index];
}
extern "C" void iplSDChannelObj_813E413C(SDChannelObj* channel, const wchar_t* text) {
nw4r::lyt::TextBox* textPane =
nw4r::ut::DynamicCast<nw4r::lyt::TextBox*>(channel->mpDialogLayout->FindPaneByName(scBalloon));
wchar_t titleText[channel::META_CHANNEL_NAME_LENGTH + 3] = L"";
u32 titleLength;
wcsncpy(titleText, text, channel::META_CHANNEL_NAME_LENGTH);
titleLength = wcslen(titleText);
f32 ellipsisWidth = 0.0f;
int ellipsisLength = 0;
if (titleLength == 0) {
textPane->SetString(titleText, 0, 1);
} else {
for (u32 i = titleLength; i != 0; i--) {
textPane->SetString(titleText, 0, i + ellipsisLength);
textPane->CalculateMtx(*channel->mpDialogLayout->getDrawInfo());
nw4r::ut::Rect textRect = textPane->GetTextDrawRect(*channel->mpDialogLayout->getDrawInfo());
if (textRect.GetWidth() <= ellipsisWidth + 391.5f) {
break;
}
if (System::getRegion() == SC_PRODUCT_AREA_JPN) {
titleText[i - 1] = NULL;
titleText[i - 2] = L'…';
} else {
ellipsisWidth = -1.179962f;
ellipsisLength = 2;
titleText[i + 1] = NULL;
titleText[i] = '.';
titleText[i - 1] = '.';
titleText[i - 2] = '.';
}
}
}
nw4r::ut::Rect textRect = textPane->GetTextDrawRect(*channel->mpDialogLayout->getDrawInfo());
nw4r::lyt::Size newSize(channel->mpDialogLayout->FindPaneByName(scBase)->GetSize());
newSize.width = textRect.right - textRect.left + 40.0f;
if (newSize.width < channel->mAspectRatioScale * 160.0f) {
newSize.width = channel->mAspectRatioScale * 160.0f;
}
channel->mpDialogLayout->FindPaneByName(scShade)->SetSize(newSize);
channel->mpDialogLayout->FindPaneByName(scBase)->SetSize(newSize);
}
extern "C" void iplSDChannelObj_813E4410(SDChannelObj* channel, const nw4r::math::VEC3& vec) {
if (channel->mpDialogLayout != NULL) {
nw4r::lyt::Size size;
size = channel->mpDialogLayout->FindPaneByName(scBase)->GetSize();
f32 verticalOffset = -2.0f + ((size.height / 2) + channel->mOffsetY);
verticalOffset *= -1.0f;
nw4r::ut::Rect projRect;
System::getProjectionRect(&projRect);
f32 centerX = vec.x;
f32 halfWidth = size.width / 2;
f32 horizontalOffset = 0.0f;
f32 leftMargin = (centerX - halfWidth) - projRect.left;
f32 rightMargin = projRect.right - (centerX + halfWidth);
if (leftMargin < 60.0f) {
horizontalOffset = 60.0f - leftMargin;
} else if (rightMargin < 60.0f) {
horizontalOffset = rightMargin - 60.0f;
}
const nw4r::math::VEC3 pos(vec.x + horizontalOffset, vec.y + verticalOffset, 0.0f);
channel->mpDialogLayout->GetRootPane()->SetTranslate(pos);
iplSDChannelObj_813E4704(channel);
channel->mpDialogLayout->calc();
}
}
extern "C" void iplSDChannelObj_813E4558(SDChannelObj* channel, int request) {
if (channel->mpDialogLayout != NULL) {
if (request == 0) {
channel->mDialogState = 0;
channel->mDialogFrame = 0;
channel->mpDialogLayout->setMinFrame(0.0f);
channel->mpDialogLayout->GetRootPane()->SetVisible(false);
} else {
switch (channel->mDialogState) {
case 0: {
if (request == 1) {
channel->mDialogTimer = 0;
channel->mDialogState = 1;
}
break;
}
case 1: {
if (request == 2) {
channel->mDialogState = 2;
channel->mpDialogLayout->GetRootPane()->SetVisible(true);
channel->mpDialogLayout->setAnmType(ANIM_TYPE_FORWARD);
channel->mpDialogLayout->start();
snd::getSystem()->startSE("WIPL_SE_BALLOON");
} else if (request == 4) {
channel->mDialogState = 0;
}
break;
}
case 2: {
if (request == 3) {
channel->mDialogState = 3;
} else if (request == 4) {
channel->mDialogFrame = 4;
} else if (request == 1) {
channel->mDialogFrame = 0;
}
break;
}
case 3: {
if (request == 4) {
channel->mDialogState = 4;
channel->mpDialogLayout->setAnmType(ANIM_TYPE_BACKWARD);
channel->mpDialogLayout->start();
}
break;
}
case 4: {
if (request == 1) {
channel->mDialogFrame = 1;
} else if (request == 4) {
channel->mDialogFrame = 0;
}
break;
}
}
}
}
}
extern "C" void iplSDChannelObj_813E4704(SDChannelObj* channel) {
switch (channel->mDialogState) {
case 1: {
if ((reinterpret_cast<u32&>(channel->mDialogTimer) += 1) >= 20.0f) {
iplSDChannelObj_813E4558(channel, 2);
break;
}
}
case 3: {
break;
}
case 2: {
if (!channel->mpDialogLayout->isPlaying(0)) {
int prev = channel->mDialogFrame;
iplSDChannelObj_813E4558(channel, 3);
if (prev == 4) {
iplSDChannelObj_813E4558(channel, 4);
channel->mDialogFrame = 0;
}
}
break;
}
case 4: {
if (!channel->mpDialogLayout->isPlaying(0)) {
int prev = channel->mDialogFrame;
iplSDChannelObj_813E4558(channel, 0);
if (prev == 1) {
iplSDChannelObj_813E4558(channel, 1);
}
}
break;
}
}
}
extern "C" void iplSDChannelObj_813E481C(SDChannelObj* channel, layout::Object* layout) {
char groupName[20];
char** lookup;
nw4r::lyt::Group* group;
group = layout->FindGroupByName("New");
if (group != NULL) {
channel->mpNewMessageGroup = group;
} else {
sprintf(groupName, "New_%s", scLangGroups[System::getLanguage()]);
group = layout->FindGroupByName(groupName);
if (group != NULL) {
channel->mpNewMessageGroup = group;
} else {
lookup = (char**)scRegionGroups[System::getRegion()];
for (int i = 0; lookup[i] != NULL; i++) {
sprintf(groupName, "New_%s", lookup[i]);
group = layout->FindGroupByName(groupName);
if (group != NULL) {
channel->mpNewMessageGroup = group;
break;
}
}
}
}
if (group != NULL) {
for (nw4r::lyt::PaneLinkList::Iterator it = group->GetPaneList().GetBeginIter();
it != group->GetPaneList().GetEndIter(); it++) {
it->mTarget->UnbindAllAnimation();
}
if (layout->searchFile("icon_New.brlan")) {
channel->mpNewMessageAnimator = layout->bindToGroup("icon_New.brlan", group);
}
}
}
extern "C" void iplSDChannelObj_813E49A8(SDChannelObj* channel) {
if (System::getNwc24Manager() != NULL) {
switch (channel->mNewMessageState) {
case 1: {
if (iplSDChannelObj_813E4A54(channel)) {
channel->mNewMessageState = 2;
channel->mNewMessageFrame = 0;
}
break;
}
case 2: {
if (++reinterpret_cast<u32&>(channel->mNewMessageFrame) >= 4200) {
channel->mNewMessageState = 1;
}
break;
}
}
}
}
extern "C" BOOL iplSDChannelObj_813E4A54(SDChannelObj* channel) {
if (System::getNwc24Manager() == NULL || !System::getNwc24Manager()->getNewTitleTbl(NULL)) {
return FALSE;
}
u32 titleCode = ES_TITLE_CODE(channel->mAppMeta.titleId);
if (!System::getNwc24Manager()->isNewMessageThere(titleCode)) {
return TRUE;
}
if (!channel->mbNewMessageGroupActive) {
if (channel->mpNewMessageGroup != NULL) {
for (nw4r::lyt::PaneLinkList::Iterator it =
channel->mpNewMessageGroup->GetPaneList().GetBeginIter();
it != channel->mpNewMessageGroup->GetPaneList().GetEndIter(); it++) {
it->mTarget->SetVisible(true);
}
if (channel->mpNewMessageAnimator != NULL) {
channel->mpNewMessageAnimator->play();
}
}
channel->mbNewMessageGroupActive = true;
}
return TRUE;
}
} // namespace scene
} // namespace ipl

View File

@@ -18,72 +18,3 @@ Scalar assignments with explicit packed-field temporaries match both conversion
Cached-header lifetimes, file declaration order, explicit close-error returns, and separate send-file status resolve the control/header/open/close functions. Inline header-write and forced-unmount helpers reproduce the target lifetimes without assembly or uninitialized values.
The eight strings are identical in pool order. .data and .sdata are 100%; .sbss scores 50%. MountInfo is an eight-byte count/type structure, while the extracted target labels its first four bytes and leaves the second word unnamed. No symbol-size or placement edits were made.
## Continuation after the first merge
Starting point: 20/25 instruction-exact functions, 7420/10604 matched code bytes,
184/192 matched data bytes. All five previously open functions received at least
three distinct source-level attempts in this continuation.
### Newly exact functions
- NWC24GetMsgIdList: indexing the output by count replaces the explicit cursor
and reduces register differences from 21 to 19. Separating offset/count
declarations gives eight differences. Declaring the path before the errors
gives four differences; putting it between the persistent result and the
transient errors gives zero differences, 153/153 instructions, 100%.
An inline open helper was also tried; it left five differences, including
an error-branch destination, and was discarded.
- DeleteMsg: keeping seek/read/protection failures in the persistent scan result
corrects the scan's exit paths. Using the existing inline header writer for
both recovery and final flush gives 296/296 instructions. Result/counter/entry
declaration order then reduces 41 register differences to 25, 16, and 12.
Reusing the consumed protection/type arguments for completion status and
ordering the scan declarations gives zero differences, 100%. Named completion
helpers were tried as alternatives: a header-value helper gives 78 differences,
a header-reference helper gives eight, and a clear/delete helper gives ten.
Separate named completion errors give nine differences. None was retained.
- DuplicationCheck: explicit candidate initialization gives 94.27928%; separate
tag/content duplicate branches give 91.927925%; putting the message-count
limit inside the scan gives 93.07658%. Combining those changes gives
98.62613%, 223/222 instructions. A positive final duplicate branch removes
the extra instruction, giving 99.12162%, 222/222. Moving the error before
counters and ordering offset/count/duplicate-ID/duplicate-offset/oldest/entry
declarations then gives zero differences, 100%. Date comparisons use the
signed comparison shown in the target.
### Functions still open
- NWC24iIsMsgObjReadable: an immutable message-pointer local, a separate
private-message pointer view, and a copied entry parameter retain five
prologue scheduling differences, 57/57 instructions, 92.98245%. A cached type
scalar gives 58/57 instructions and 90.61404%. Combining type validity checks
gives 55/57 and 89.29825%. A nested LED-validity body gives 57/57 but 41
differences, 85.789474%. An inline readability helper retains the five
differences. The target stores LR/r31 and copies the argument before loading
type; MWCC schedules the load and mask among those prologue instructions.
- NWC24iMBoxCheck: an oldest-ID wrapper, a one-element output array, and a
returned output pointer retain 66/68 instructions and 96.92647%. Grouping
the cached header and oldest ID in a mailbox local gives 67/68 instructions,
98.382355%; reversing the fields gives 98.30882%. A direct oldest-ID
assignment gives 96.92647%. Copying the ID through memcpy or Mail_memcpy
gives 70/68 instructions and 90.867645%. The retained mailbox local restores
the target's oldest-ID store and header stack offset, but MWCC forwards the
stored value into r4 rather than emitting the target's subsequent load.
### Data verification
The eight strings remain identical in pool order. .data and .sdata each score
100%. The compiler emits 166/12 bytes versus extracted 168/16 bytes respectively;
the target's additional trailing bytes are alignment zeros. The eight .sbss
bytes are byte-identical zeros. The sole MountInfo symbol has size eight in the
compiled object, whereas the extraction labels only the first four bytes.
Target instructions access the type using MountInfo plus its four-byte field
position. Its real count/type structure therefore remains eight bytes; the
extracted symbol boundary accounts for the 50% .sbss score. No symbol metadata,
placement directive, extra object, or other unit was changed.
Current result: 23/25 instruction-exact functions, 10104/10604 matched code
bytes, 184/192 matched data bytes. All 23 exact functions have zero ctxdiff
differences. The two open functions and extracted MountInfo extent remain
unresolved.

View File

@@ -1,99 +0,0 @@
# NWC24MsgCommit matching attempts
Baseline: no source, 0/18 functions, 0/8532 code bytes, 0/904 data bytes.
All 18 functions are implemented in target object order. The private header's
additional mailbox/message views are guarded by NWC24_MSG_COMMIT, defined only
in this source. NWC24_MBOX_CTRL retains its existing view.
## Remaining functions
- NWC24CommitMsgInternal: the initial implementation has 781/827 instructions,
82.8549%. A signed initialization index, swapping subject/text declarations,
and inclusive file-error bounds were tested separately. Separating the overall
result from each write's status gives 812/827 instructions, 88.46554%. Generic
optional field writers give 826/827, 90.1052%; individual command/tag/DWC/icon
inline writers give 817/827, 92.53204%. Moving cancellation before object
publication gives 818/827, 94.54534%. Combining unsigned attachment iteration,
partial-write byte accounting, subject/text declaration order, and inclusive
status bounds gives 94.71463%. A separate inline message-ID writer gives
94.72672%, 818/827. Remaining differences involve write/error control flow,
formatting temporaries, and register allocation.
- CheckMsgBoxSpace: the initial estimate gives 223/223 instructions, 85.57399%.
Splitting the base64 estimate into three accumulation statements gives
78.098656%, 109 differences. Signed accumulation counters give 86.13453%,
76 differences, but change the final unsigned capacity comparison. Moving
the per-attachment size temporary outside the scan gives 85.57399%,
75 differences. The final source keeps unsigned counters and the original
unsigned overflow comparison. Remaining differences are chiefly scheduling
and allocation in the compiler's eight-way unrolled attachment estimate.
- WriteToField: deferring field-counter initialization gives 99.71111%,
90/90 instructions, six differences. An inclusive capacity check reduces this
to four differences, 99.77778%. Moving the cursor before the buffer, moving
the buffer after the counters/length/error, and separating initialization
from declaration retain those four differences. An explicit recipient
pointer gives 98.977776%, 14 differences; moving the cursor declaration after
the length gives 97.5%, 36 differences. The remaining four differences select
r24 instead of r25 for the initial scratch buffer, before recipient iteration.
- WriteMIMEAttachHeader: the initial form gives 92/92 instructions, 86.815216%,
53 differences. Reloading the work buffer after clearing gives 92.41304%,
25 differences. Nonpositive format-count checks give 87.01087%. Computing
the first two formatted counts before the final format gives 91/92
instructions. Advancing the cursor before that sum restores 92/92 and gives
97.33696%, eight differences. Combining template lengths before reading the
MIME-name length gives 99.45652%; grouping the final template sum gives
99.51087%, seven differences. Reusing template-length temporaries for
formatted lengths and reordering those declarations do not resolve them.
Remaining differences are the template-sum schedule and register choices.
- WriteQPData: the initial form gives 60/60 instructions, 98.333336%,
19 differences. Signed total and reversed encoded/consumed-count declarations
give 98.5%, 13 differences. An input cursor declared before the total gives
98.833336%, ten differences. Separating the remaining-byte count gives 99%,
nine differences. Moving the error/counters/output pointer and trying cursor
declarations before/after those locals were also tested. The remaining nine
differences are callee-saved register choices; instruction count matches.
## Exact objdiff results
13/18 functions, 3364/8532 code bytes. The exact functions are NWC24CommitMsg,
CheckMsgObject, SynthesizeAddrStr, WriteSMTP_MAILFROM, WriteSMTP_RCPTTO,
WriteFromField, WriteDateField, WriteXWiiAppIdField, WriteXWiiFaceField,
WriteXWiiAltNameField, WriteContentTypeField, WritePlainText, and WriteBase64Data.
Declaration/lifetime changes resolve loopback, address synthesis, recipient
iteration, application flags, folded base64 headers, and content headers.
Advancing the synthesized-address cursor and caching the complete field length
resolve the SMTP sender and From header. A while loop with explicit cursor and
remaining-byte updates resolves the base64 writer. Inclusive validation bounds
resolve message validation and the Date header.
The gate counts 11 instruction-exact functions. Its disassembler and ctxdiff
misnormalize the two cr1 branches in each of WriteSMTP_MAILFROM and
WriteFromField: odiff.dis reads operands[0].imm as the target even when the first
operand is the condition-register field. These functions are at different unit
positions while the preceding commit function remains short. Direct .text byte
comparison confirms all 232/256 bytes respectively are identical to the target;
objdiff reports both at 100%. No tool or target metadata was edited to bypass
that count. All other eleven exact functions have zero ctxdiff differences.
## Data
pool_diff and the gate report identical pools. Every long string occupies its
target .data offset, and the twelve-month table is at 0x140 in source order.
The unrelocated .data bytes match the complete 678-byte source prefix of the
680-byte target; the remaining target bytes are alignment zeros. The twelve
month-pointer relocations are present in both objects. The target extraction
combines the first thirteen strings into one 296-byte symbol, whereas MWCC
emits individual literal symbols. The table's small-string destinations also
retain the .sdata offset differences below. Objdiff does not score .data as
matched despite the identical raw prefix; its relocations/symbol grouping
remain open.
.bss MultiPartDivider is 64 bytes and matches 100%. .sbss m_pFile matches 100%.
.sdata scores 18.765432%. Its first difference is byte four: the target's
LoopBackEnable symbol includes a trailing zero word, whereas the source's
ordinary BOOL definition is four bytes. The target also contains separate
subject and multipart CRLF literals; MWCC pools the source literals together.
The source .sdata is 140 bytes versus the target's 152 bytes, including trailing
section alignment. No extra object, packed string blob, alignment directive,
symbol-size change, or placement trick was introduced to cover these gaps.
Total matched data is 72/904 bytes. These data-layout differences remain open.

View File

@@ -155,70 +155,3 @@ All variants were applied to all three command functions.
Retained only the instruction-exact initCardThread change. Every remaining
function has three new distinct attempts in this continuation. All data
sections and the complete pool remain exact; no DOL link investigation.
## Continuation after the second merge
Baseline: 24/30 exact functions, 3916/9852 exact code bytes, 1496/1496 data
bytes. The pool is identical at 43 strings. The three long functions were
examined in decreasing baseline score; command packing experiments followed.
Every variant below was built as the owned object and inspected with ctxdiff.
### CardSequence_813D2C8C
1. Unified mount, listing and delete file indices and widened the slot local
to u32: 301/301 instructions, 70 differences versus the baseline 78.
Saved registers and validity-response scheduling still differ. Reverted.
2. Reused the slot and result locals for the free-space scan rather than
separate outerSlot/freeBlocks locals: 301/301, 69 differences. Reverted.
3. Made the validity flag u8 and passed its value to the validity report:
301/301, unchanged 78 differences. Reverted.
### CardSequence_813D3D14
1. Native bool flags for temporary creation, metadata completion and cancel:
608/608 instructions, unchanged 186 differences. Reverted.
2. Scoped permissionResult for the initial permission check, independent of
the transfer result: 608/608, 177 differences. Initial saved-register
assignments, metadata joins and cleanup conversions remain different.
Reverted for the focused final diff.
3. With the scoped permission result, used a full-width destination result,
explicit s16 conversions when accepting the creation result and at file
APIs: 608/608, same 177 differences. Reverted.
### sendCardCopyCmd / sendCardMoveCmd / sendCardDeleteCmd
Each variant was applied to all three commands. The final mask expression
was checked independently for each symbol: 21/21 instructions, diffs 0.
1. Packed the slot first in a union value, then assigned its file byte:
21/21, 11 differences in packing registers and instruction ordering.
2. Shared inline sendFileRequest helper for the final OR and nonblocking
queue send: inlined, 21/21, unchanged two scheduling differences.
3. Signed message temporary: 21/21, unchanged two differences.
4. Separate masked slot temporary: 21/21, eight packing/scheduling differences.
5. Explicit file-byte temporary: 21/21, unchanged two differences.
6. Separate initial slot assignment and OR of the shifted file byte:
21/21, 11 differences. Reverted.
7. Explicit unsigned file mask before shifting, replacing the narrowing byte
cast: 21/21, diffs 0 for Copy, Move and Delete. Retained. Both express the
same file-byte truncation; the mask produces the original li/ori order.
### CardSequence_813D3424
1. Corrected the eighth-icon palette destination to icons[slot][fileNo].
The original at 813D384C adds the selected icon offset before storing
iconTlutOffset at 813D385C. The previous icons[0][0] destination was wrong.
499/512 instructions; objdiff improves from 87.23633% to 87.92969%.
Retained this behavior correction.
2. Moved iconCount and shift increments to the common bottom of the format
loop: 499/512, objdiff improves further to 89.44531%. The source now
expresses the shared loop continuation directly. Retained.
3. Extracted the sector-size checks, image read/copy and invalid-image clearing
into a real inline readCardImages helper: inlined to 480/512 instructions.
Pool identical; more original error-path instructions were optimized away.
Reverted.
The final diff retains three exact command functions and the palette destination
correction and shared loop continuation. All remaining functions have at least
three new distinct attempts.
Shared headers and configure.py are unchanged. All data sections remain exact.

View File

@@ -1,26 +0,0 @@
# SDChannelObj matching attempts
All 38 target functions are implemented in address order. No configure or symbol changes.
The string pool is identical. The .data and .rodata sections match completely.
## iplSDChannelObj_813E3580
- Initial translation of ChannelObj::setLangPane: 182 instructions, 112 instruction diffs. Fixed language-name storage from flat byte indices to 10 four-byte entries and changed the Rso name buffer to eight bytes. This also fixes the fallback comparison to select a four-byte language entry.
- Removed the cached fallback group-name local: 182 instructions, 37 diffs. Giving the region table external linkage did not change these diffs; restored internal linkage.
- Explicit region-name and language-index pointer locals: 182 instructions, 40 diffs. Restored indexed table accesses.
- Restored the target's breaks after selecting a fallback group and at its NULL terminator: 182 instructions, four diffs, only r27 versus r29 for the selected group.
- One common Group pointer declared before the language scan: same four register diffs.
- Reused that Group pointer while traversing the first list: 181 instructions and additional frame/register diffs. Restored iterator accesses and locally scoped Group pointers.
- Final retained form: 182/182 instructions, four register-allocation differences at indices 103, 115, 149, 161. No artificial register coercion.
## Resolved functions
- iplSDChannelObj_813E4060: initial 54/55 instructions; changed the language sentinel to unsigned for the target addis/cmplwi pair. This left eight register diffs. Removed the language temporary and indexed the lookup directly: 55/55 instructions, zero diffs.
- iplSDChannelObj_813E4A54: initial 90/90 instructions with ten scheduling diffs. Computed the title code before querying the NWC24 manager: 90/90 instructions, zero diffs.
- The other functions matched on their first literal implementation from target assembly and corresponding ChannelObj routines.
## Measurement caveats
- iplSDChannelObj_813E3E38 is 100% in objdiff. Gate/ctxdiff reports three instruction differences because odiff.dis treats the first operand of a cr1 branch as its target and subtracts the function's object offset. The actual instruction words at indices 11, 21, 22 are identical: 41860014, 41860010, 40840014. Both objects have identical call relocation positions and targets. No tool changes were made.
- .sdata2 was fixed by representing the unknown title as an ordinary const wchar_t array, rather than a pointer to a wide string literal.
- Original .sdata additionally contains B_BtnA and B_BtnB beyond the New group literals. No owned text relocation references those two strings. Their source ownership is uncertain; they were not recreated as unreferenced data just to increase the section score.

View File

@@ -1,55 +0,0 @@
# RVL SDK fa cache matching
Unit: `libs/RVL_SDK/src/fa/pf_cache`, 43U only, still NonMatching.
Starting report: 0 instruction-exact functions, 0/7396 matched code bytes.
Source adapted from the Matching RevoEX `vf/fatfs/pf_cache.c`.
The SDK variant uses the cache at volume offset 0x1624, accepts one data page,
passes the allocation-hit output through its public allocation functions,
marks modified ranges inside writes, and handles whole-page flushing when the
modified start pointer is null. Its bulk write does not perform the RevoEX
write-through clearing pass. The target's left-overlap modified-start
calculation is preserved, including its unusual endpoint arithmetic.
The existing compiler's `dont_inline` pragma preserves the target's calls
between cache operations. List manipulation and used-page scans are written
as ordinary C where the target embeds them. No shared headers were changed.
## Remaining function: PFCACHE_DoWriteNumSectorAndFreeIfNeeded
1. Retain the RevoEX range updater, then adapt dirty-pointer handling to the
target branches. Changed the overlap branches and removed the write-through
clearing pass. Result: 233/233 instructions, 185 instruction differences,
95.77253% objdiff. Direct last-sector arithmetic was hoisted outside the
loop and occupied another preserved register.
2. Introduce an explicit last-sector temporary and increment successful
sectors before decrementing remaining sectors. Result: 234/233 instructions;
last-sector arithmetic still hoisted and aliasing forced a repeated load.
3. Restore the full page-size overlap expression for the modified end pointer.
Result: 236/233 instructions; an additional preserved end-sector temporary
survived the memcpy call.
4. Cache the overlap count once and derive its last sector from the page start.
Result: 234/233 instructions; most instructions matched, but the complex
memcpy-length expression retained a second end-sector register.
5. Simplify the memcpy length and compute last sector directly from the request.
Result: 232/233 instructions; last sector hoisted again, shifting registers.
6. Keep the simple memcpy length, cache the overlap count, and derive last sector
from page start plus overlap count. Result: 233/233 instructions, nine
instruction differences, 98.21889% objdiff. All surviving differences are
instructions 136-144 in the right-overlap count/last-sector calculation.
7. Reverse operands in the overlap request-end expression. Result unchanged:
233/233 instructions, the same nine differences, 98.21889% objdiff.
The retained version computes the same overlapping sector range. The compiler
uses the request end already held in r31; the target recomputes the request end
in r4 and schedules last-sector subtraction before updating success/remaining
counts. No assembly, volatile values, or uninitialized values were introduced.
## Data and validation
Both original and candidate ELF objects have zero allocated non-code sections.
There is no data or string pool in this unit. `pool_diff.py` raises KeyError
because it assumes a .data section; the gate reports IDENTICAL empty pools.
Final report: 35/36 instruction-exact functions, 6464/7396 matched code bytes,
99.77555% fuzzy code, data None/None. Full gate reports zero regressions,
zero forbidden patterns, zero readability warnings, and the target DOL SHA1.

View File

@@ -1,20 +0,0 @@
# fa/pf_entry_iterator attempts
The matching vf implementation supplied iterator movement, path traversal, and directory parsing. The fa object adds a word to FFD, extends the FAT hint, changes search attribute handling and entry-name matching, and replaces FindCluster with an ancestor search. All 16 target functions are implemented in object order; 14 are instruction-exact.
PFENT_ITER_FindCluster:
- Initial ancestor traversal: 231/237 instructions; unused standalone chain counter disappeared.
- Use hint.chain_index, correct cluster_link initialization, and unsigned entry-offset shift: 237/237; 48 differences, mostly register allocation.
- Move hint before current_cluster and delay hint.chain_index initialization: 237/237; 11 register differences.
- Swap sector-index/entries-per-sector declaration order: 237/237; 8 register differences. Retained.
- Reverse sector-index bitwise operands: no change. Move entries declaration first: no change. Delay FFD start-cluster assignment: 16 differences; reverted.
PFENT_ITER_GetLFNEntryName:
- Separate long_name expressions for each copy: 77/73 instructions; three independently advanced destination offsets.
- Reuse one destination pointer: 78/73; fewer address calculations, but signed final division added correction instructions.
- Unsigned final index and explicit byte-offset loop: 76/73; compiler advances destination pointer directly, unlike target's offset addition.
- Signed loop counter: 76/73, adds signed comparison; reverted.
- Destination index (i * 26U) / 2U: 74/73; one extra alignment-mask instruction and loop/destination register allocation. Retained.
- Byte-pointer arithmetic, integer-address arithmetic, or three byte-pointer copy expressions: 76/73; same pointer induction. Reverted.
Data: ordinary literals occur in target order. Candidate .sdata is 22 bytes; target is 24 bytes. The common 22 bytes are identical; two trailing zero bytes remain unresolved. No padding or extra literals added. pool_diff.py requires .data and raises KeyError for this unit; the gate reports identical empty .data pools, so the explicit ELF .sdata comparison is the meaningful data check.

View File

@@ -326,167 +326,3 @@ 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<u16>(character + 0xcf65) <= 1) {
GATE PASS
```
## Fourth continuation
- Baseline: 206/221 instruction-exact, 208/221 objdiff exact, code 28300/50656, data 908/3772; twelve exact asm bodies remain. Applying unslop to the attempt log and final handoff.
- onPressLeftHWKB__Q39textinput9inputform4BaseFv: signed kana direct zero guard: src 0x41c base 0x420 insns 263/264; --- replace mine 19:20 base 19:20; restored prior body.
- onPressLeftHWKB__Q39textinput9inputform4BaseFv: signed kana zero case switch: src 0x424 base 0x420 insns 265/264; --- replace mine 19:20 base 19:20; restored prior body.
- onPressLeftHWKB__Q39textinput9inputform4BaseFv: signed kana result local: src 0x41c base 0x420 insns 263/264; --- replace mine 19:20 base 19:20; restored prior body.
- onPressRightHWKB__Q39textinput9inputform4BaseFv: signed kana direct zero guard: src 0x448 base 0x44c insns 274/275; --- replace mine 19:20 base 19:20; restored prior body.
- onPressRightHWKB__Q39textinput9inputform4BaseFv: signed kana zero case switch: src 0x450 base 0x44c insns 276/275; --- replace mine 19:20 base 19:20; restored prior body.
- onPressRightHWKB__Q39textinput9inputform4BaseFv: signed kana result local: src 0x448 base 0x44c insns 274/275; --- replace mine 19:20 base 19:20; restored prior body.
- isOverLine__Q39textinput9inputform4BaseFRCQ49textinput10textdrawer4Base8DrawInfo: plain scale aggregates: src 0xdc base 0xcc insns 55/51; --- replace mine 0:1 base 0:1; restored prior body.
- isOverLine__Q39textinput9inputform4BaseFRCQ49textinput10textdrawer4Base8DrawInfo: scale assignment into declared vectors: src 0xec base 0xcc insns 59/51; --- replace mine 0:1 base 0:1; restored prior body.
- isOverLine__Q39textinput9inputform4BaseFRCQ49textinput10textdrawer4Base8DrawInfo: plain scale aggregates width first: src 0xdc base 0xcc insns 55/51; --- replace mine 0:1 base 0:1; restored prior body.
- draw__Q39textinput9inputform12LayoutByNW4RFv: clip declared before scale: src 0x1dc base 0x1c8 insns 119/114; --- insert mine 44:44 base 44:49; restored prior body.
- draw__Q39textinput9inputform12LayoutByNW4RFv: global declared before scale: src 0x1c8 base 0x1c8 insns 114/114; diffs 14: [50, 56, 59, 60, 63, 64, 65, 66, 67, 68, 69, 70, 73, 75]; restored prior body.
- draw__Q39textinput9inputform12LayoutByNW4RFv: plain global scale aggregates: src 0x1c8 base 0x1c8 insns 114/114; diffs 12: [50, 56, 59, 60, 63, 64, 65, 66, 67, 69, 73, 75]; restored prior body.
- drawCursor__Q39textinput9inputform4BaseFff: cursor direct byte thickness: src 0x118 base 0x118 insns 70/70; diffs 0: []; retained exact C++.
- Guarded signed isKanaFix return experiment: the callee stays 19/19 exact; HWKB direct zero guard loses one tail branch, zero-case switch adds one, result local loses one. Restored the original bool signature.
- moveCursorUp__Q39textinput9inputform4BaseFv: upper row coordinate compound subtract: src 0x160 base 0x160 insns 88/88; diffs 3: [58, 59, 63]; restored prior body.
- moveCursorUp__Q39textinput9inputform4BaseFv: upper row coordinate separate index: src 0x160 base 0x160 insns 88/88; diffs 0: []; retained exact C++.
- isOverLine__Q39textinput9inputform4BaseFRCQ49textinput10textdrawer4Base8DrawInfo: line direct scale expressions: src 0xc0 base 0xcc insns 48/51; --- delete mine 7:8 base 7:7; restored prior body.
- isOverLine__Q39textinput9inputform4BaseFRCQ49textinput10textdrawer4Base8DrawInfo: line intermediate field span: src 0xbc base 0xcc insns 47/51; --- replace mine 0:1 base 0:1; restored prior body.
- isOverLine__Q39textinput9inputform4BaseFRCQ49textinput10textdrawer4Base8DrawInfo: line direct width expressions: src 0xac base 0xcc insns 43/51; --- replace mine 0:1 base 0:1; restored prior body.
- getCurrentString__Q39textinput9inputform4BaseFb: current string prediction switch: src 0x1c0 base 0x1c0 insns 112/112; diffs 0: []; retained exact C++.
- findURL__Q39textinput9inputform4BaseFPUlPUlPCwUlUl: URL switch with ASCII character classes: src 0x1b8 base 0x1bc insns 110/111; --- insert mine 5:5 base 5:6; restored prior body.
- findURL__Q39textinput9inputform4BaseFPUlPUlPCwUlUl: URL switch reordered letter cases: src 0x1b4 base 0x1bc insns 109/111; --- insert mine 5:5 base 5:6; restored prior body.
- findURL__Q39textinput9inputform4BaseFPUlPUlPCwUlUl: URL switch prefix pointer iteration: src 0x1b8 base 0x1bc insns 110/111; --- insert mine 5:5 base 5:6; restored prior body.
- findURL__Q39textinput9inputform4BaseFPUlPUlPCwUlUl: URL prefix table cached before scan: src 0x1bc base 0x1bc insns 111/111; diffs 20: [5, 9, 10, 11, 15, 57, 66, 73, 74, 76, 79, 80, 82, 88, 89, 91, 93, 95, 101, 102]; restored prior body.
- findURL__Q39textinput9inputform4BaseFPUlPUlPCwUlUl: URL cached prefix iterator: src 0x1bc base 0x1bc insns 111/111; diffs 36: [5, 9, 10, 11, 12, 13, 15, 53, 57, 58, 60, 62, 66, 69, 71, 73, 74, 75, 76, 77]; restored prior body.
- findURL__Q39textinput9inputform4BaseFPUlPUlPCwUlUl: URL length before word pointer declaration: src 0x1bc base 0x1bc insns 111/111; diffs 31: [5, 9, 10, 11, 12, 13, 15, 53, 57, 58, 60, 62, 66, 69, 71, 73, 75, 76, 79, 82]; restored prior body.
- onPressLeft__Q39textinput9inputform4BaseFv: left explicit kana cases: src 0x278 base 0x268 insns 158/154; --- replace mine 15:16 base 15:16; restored prior body.
- onPressLeft__Q39textinput9inputform4BaseFv: left kana guard in loop: src 0x26c base 0x268 insns 155/154; --- replace mine 15:16 base 15:16; restored prior body.
- onPressLeft__Q39textinput9inputform4BaseFv: left kana negative switch: src 0x274 base 0x268 insns 157/154; --- replace mine 15:16 base 15:16; restored prior body.
- onPressRight__Q39textinput9inputform4BaseFv: right aggregate space then clear: src 0x308 base 0x2e4 insns 194/185; --- replace mine 0:1 base 0:1; restored prior body.
- onPressRight__Q39textinput9inputform4BaseFv: right byte-copy ordinary wide literal: src 0x2cc base 0x2e4 insns 179/185; --- replace mine 15:16 base 15:16; restored prior body.
- onPressRight__Q39textinput9inputform4BaseFv: right initialized space pair: src 0x2cc base 0x2e4 insns 179/185; --- replace mine 15:16 base 15:16; restored prior body.
- autoScroll__Q39textinput9inputform4BaseFv: automatic scroll direct scale expression: src 0x26c base 0x258 insns 155/150; --- replace mine 0:1 base 0:1; restored prior body.
- autoScroll__Q39textinput9inputform4BaseFv: automatic scroll inline row conversion: src 0x26c base 0x258 insns 155/150; --- replace mine 0:1 base 0:1; restored prior body.
- autoScroll__Q39textinput9inputform4BaseFv: automatic scroll height-first scale expression: src 0x258 base 0x258 insns 150/150; diffs 25: [26, 50, 52, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 118, 120, 122, 123, 124, 125, 126]; restored prior body.
- init__Q49textinput9inputform4Base14RowInfoManagerFv: row sentinel full-width index: src 0xbc base 0x9c insns 47/39; --- replace mine 1:3 base 1:2; restored prior body.
- init__Q49textinput9inputform4Base14RowInfoManagerFv: row end indices captured before stores: src 0xb8 base 0x9c insns 46/39; --- replace mine 12:13 base 12:13; restored prior body.
- init__Q49textinput9inputform4Base14RowInfoManagerFv: row sentinel pair reference: src 0xa0 base 0x9c insns 40/39; --- replace mine 12:13 base 12:13; restored prior body.
- init__Q49textinput9inputform4Base14RowInfoManagerFv: row end cached preceding index: src 0x9c base 0x9c insns 39/39; diffs 15: [12, 14, 16, 17, 18, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29]; restored prior body.
- init__Q49textinput9inputform4Base14RowInfoManagerFv: row end pointer instead of reference: src 0x9c base 0x9c insns 39/39; diffs 15: [12, 14, 16, 17, 18, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29]; restored prior body.
- init__Q49textinput9inputform4Base14RowInfoManagerFv: row end loop pair references: src 0x9c base 0x9c insns 39/39; diffs 15: [12, 14, 16, 17, 18, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29]; restored prior body.
- calc__Q39textinput9inputform4BaseFv: color direct byte blue conversion: src 0x294 base 0x294 insns 165/165; diffs 8: [53, 126, 128, 129, 130, 152, 153, 154]; restored prior body.
- calc__Q39textinput9inputform4BaseFv: color timer and phase locals before updates: src 0x294 base 0x294 insns 165/165; diffs 6: [53, 126, 128, 129, 130, 155]; restored prior body.
- calc__Q39textinput9inputform4BaseFv: color direct byte channels: src 0x294 base 0x294 insns 165/165; diffs 8: [53, 126, 128, 129, 130, 152, 153, 154]; restored prior body.
- create__Q39textinput9inputform4BaseFP12MEMAllocatorPQ39textinput9inputform10EditBuffer: base row selected reference: compile failed build/43U/src/src/keyboard && "/usr/bin/python3" tools/transform_dep.py build/43U/src/src/keyboard/tiInputForm.d build/43U/src/src/keyboard/tiInputForm.d ### mwcceppc.exe Compiler: # File: src\keyboard\tiInputForm.cpp # ------------------------------------- # 1903: u16 previous = selected.Back; # Error: ^^^^ # (10141) expression syntax error # Too many errors printed, aborting program User break, cancelled... ninja: build stopped: subcommand failed. ; restored prior body.
- create__Q39textinput9inputform4BaseFP12MEMAllocatorPQ39textinput9inputform10EditBuffer: base row detached state captured: 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.
- create__Q39textinput9inputform4BaseFP12MEMAllocatorPQ39textinput9inputform10EditBuffer: base row next preceding index order: 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.
- onPressRight__Q39textinput9inputform4BaseFv: right string buffer aggregate: src 0x308 base 0x2e4 insns 194/185; --- replace mine 0:1 base 0:1; restored prior body.
- onPressRight__Q39textinput9inputform4BaseFv: right string buffer aggregate byte copy: src 0x328 base 0x2e4 insns 202/185; --- replace mine 0:1 base 0:1; restored prior body.
- onPressRight__Q39textinput9inputform4BaseFv: right string buffer whole literal byte copy: src 0x2d0 base 0x2e4 insns 180/185; --- replace mine 15:16 base 15:16; restored prior body.
- onSpaceKeyHWKB__Q39textinput9inputform4BaseFUl: space Atok integer enable guard: src 0x96c base 0x96c insns 603/603; diffs 0: []; retained exact C++.
- onCursor__Q39textinput9inputform4BaseFPQ49textinput10textdrawer4Base9CursorPos: space marker scale final operand: src 0x764 base 0x764 insns 473/473; diffs 5: [271, 273, 276, 281, 283]; restored prior body.
- onCursor__Q39textinput9inputform4BaseFPQ49textinput10textdrawer4Base9CursorPos: space marker factor after width locals: src 0x764 base 0x764 insns 473/473; diffs 9: [271, 273, 274, 275, 276, 277, 278, 281, 283]; restored prior body.
- onCursor__Q39textinput9inputform4BaseFPQ49textinput10textdrawer4Base9CursorPos: space marker offset computed by compound steps: 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.
- onPressLeftHWKB__Q39textinput9inputform4BaseFv: onPressLeftHWKB kana false case before default: src 0x424 base 0x420 insns 265/264; --- replace mine 19:20 base 19:20; restored prior body.
- onPressLeftHWKB__Q39textinput9inputform4BaseFv: onPressLeftHWKB kana explicit false and true cases: src 0x430 base 0x420 insns 268/264; --- replace mine 19:20 base 19:20; restored prior body.
- onPressLeftHWKB__Q39textinput9inputform4BaseFv: onPressLeftHWKB kana conditional positive block: src 0x41c base 0x420 insns 263/264; --- replace mine 19:20 base 19:20; restored prior body.
- onPressRightHWKB__Q39textinput9inputform4BaseFv: onPressRightHWKB kana false case before default: src 0x450 base 0x44c insns 276/275; --- replace mine 19:20 base 19:20; restored prior body.
- onPressRightHWKB__Q39textinput9inputform4BaseFv: onPressRightHWKB kana explicit false and true cases: src 0x45c base 0x44c insns 279/275; --- replace mine 19:20 base 19:20; restored prior body.
- onPressRightHWKB__Q39textinput9inputform4BaseFv: onPressRightHWKB kana conditional positive block: src 0x448 base 0x44c insns 274/275; --- replace mine 19:20 base 19:20; restored prior body.
- onPressUp__Q39textinput9inputform4BaseFv: onPressUp kana false case before default: src 0x3dc base 0x3d8 insns 247/246; --- replace mine 11:12 base 11:12; restored prior body.
- onPressUp__Q39textinput9inputform4BaseFv: onPressUp kana explicit false and true cases: src 0x3e8 base 0x3d8 insns 250/246; --- replace mine 11:12 base 11:12; restored prior body.
- onPressUp__Q39textinput9inputform4BaseFv: onPressUp kana conditional positive block: src 0x3d4 base 0x3d8 insns 245/246; --- replace mine 11:12 base 11:12; restored prior body.
- onPressDown__Q39textinput9inputform4BaseFv: onPressDown kana false case before default: src 0x3dc base 0x3d8 insns 247/246; --- replace mine 11:12 base 11:12; restored prior body.
- onPressDown__Q39textinput9inputform4BaseFv: onPressDown kana explicit false and true cases: src 0x3e8 base 0x3d8 insns 250/246; --- replace mine 11:12 base 11:12; restored prior body.
- onPressDown__Q39textinput9inputform4BaseFv: onPressDown kana conditional positive block: src 0x3d4 base 0x3d8 insns 245/246; --- replace mine 11:12 base 11:12; restored prior body.
- onPressDownHWKB__Q39textinput9inputform4BaseFv: down HWKB candidate decrement narrow type: src 0x428 base 0x438 insns 266/270; --- replace mine 16:17 base 16:17; restored prior body.
- onPressDownHWKB__Q39textinput9inputform4BaseFv: down HWKB candidate count local: src 0x428 base 0x438 insns 266/270; --- replace mine 16:17 base 16:17; restored prior body.
- onPressDownHWKB__Q39textinput9inputform4BaseFv: down HWKB explicit kana switch: src 0x42c base 0x438 insns 267/270; --- replace mine 97:98 base 97:98; restored prior body.
- setLanguage__Q39textinput9inputform12LayoutByNW4RFQ29textinput8Language: language text pane name before root query: 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 repeated title query direct cast: 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.
- setLanguage__Q39textinput9inputform12LayoutByNW4RFQ29textinput8Language: language selected name conditional assignment: 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.
- create__Q39textinput9inputform12LayoutByNW4RFP12MEMAllocatorPQ39textinput9inputform10EditBuffer: layout placement constructor implicit null check: src 0x584 base 0x590 insns 353/356; --- replace mine 5:6 base 5:6; restored prior body.
- create__Q39textinput9inputform12LayoutByNW4RFP12MEMAllocatorPQ39textinput9inputform10EditBuffer: layout row previous index widened: 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.
- create__Q39textinput9inputform12LayoutByNW4RFP12MEMAllocatorPQ39textinput9inputform10EditBuffer: layout unused detached-state local, discarded: 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 coordinate scale operands reversed: 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 coordinate line bottom recomputed local: 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 coordinate draw info brace initialization: src 0x548 base 0x518 insns 338/326; --- replace mine 0:1 base 0:1; restored prior body.
- isOverRowLimit__Q39textinput9inputform4BaseFUlPCw: row limit width from direct scale query: src 0x3a8 base 0x3b8 insns 234/238; --- replace mine 0:1 base 0:1; restored prior body.
- isOverRowLimit__Q39textinput9inputform4BaseFUlPCw: row limit current iterator const local: src 0x3b0 base 0x3b8 insns 236/238; --- replace mine 0:1 base 0:1; restored prior body.
- isOverRowLimit__Q39textinput9inputform4BaseFUlPCw: row limit field width operand reversed: src 0x3b0 base 0x3b8 insns 236/238; --- replace mine 0:1 base 0:1; restored prior body.
- onCommand__Q39textinput9inputform4BaseFQ39textinput15CommandReceiver13INPUT_COMMANDPv: command fixed comparison positive ternary: src 0x2020 base 0x2014 insns 2056/2053; --- replace mine 0:1 base 0:1; restored prior body.
- onCommand__Q39textinput9inputform4BaseFQ39textinput15CommandReceiver13INPUT_COMMANDPv: command active mode integer temporary: src 0x2020 base 0x2014 insns 2056/2053; --- replace mine 0:1 base 0:1; restored prior body.
- onCommand__Q39textinput9inputform4BaseFQ39textinput15CommandReceiver13INPUT_COMMANDPv: command fixed pointer query after current: src 0x2020 base 0x2014 insns 2056/2053; --- replace mine 0:1 base 0:1; restored prior body.
- create__Q39textinput9inputform4BaseFP12MEMAllocatorPQ39textinput9inputform10EditBuffer: base row reference corrected declaration: 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.
- create__Q39textinput9inputform12LayoutByNW4RFP12MEMAllocatorPQ39textinput9inputform10EditBuffer: layout genuine detached-row guard: src 0x598 base 0x590 insns 358/356; --- replace mine 5:6 base 5:6; restored prior body.
- isEnableCursorCache__Q39textinput10textdrawer4BaseCFv: cache bool conditional return: 8/8 bytes, raw equality True; restored prior body. Original concatenated symbol remains unchanged.
- isEnableCursorCache__Q39textinput10textdrawer4BaseCFv: cache explicit positive branch: 8/8 bytes, raw equality True; restored prior body. Original concatenated symbol remains unchanged.
- isEnableCursorCache__Q39textinput10textdrawer4BaseCFv: cache nonzero integer predicate: 20/8 bytes, raw equality False; restored prior body. Original concatenated symbol remains unchanged.
### Fourth continuation handoff
- Three exact asm bodies converted to readable C++: getCurrentString 112/112, moveCursorUp 88/88, drawCursor 70/70. Remaining asm count is 12 -> 9. onSpaceKeyHWKB now matches 603/603, adding one instruction-exact function and 2412 exact code bytes.
- Prediction-mode switch preserves getCurrentString's original extra branch. Separating the upper-row coordinate and cursor index matches moveCursorUp's virtual-call scheduling. Direct u8 thickness conversion matches drawCursor's two integer registers. The integer prediction-enabled local preserves onSpaceKeyHWKB's original Boolean block order.
- Every remaining asm body has at least three fresh compiled source-level attempts this round. Every remaining report-nonmatching entry also has at least three fresh attempts. The malformed cursor-cache symbol was checked with three compiled implementations against its original eight bytes. Failed preliminary reference declarations were corrected and rebuilt before counting attempts.
- Data: UEJ/KOR visibility tables now use their actual u16 counts and pane-name arrays; all three language tables use their actual visibility/separator/text/title fields. Binary contents, relocations, token order and section sizes remain unchanged. Chinese visibility storage still has its inherited trailing word; this round adds no padding or objects.
- Fresh ELF audit: all main vtables through WithAtok retain the original offsets. Genuine Decolated/GUIComponent vtables occupy additional weak storage, whereas the extracted target omits these deduplicated objects. EditBuffer and textinput Base target vtable sizes include four and 28 trailing zero bytes. The singleton weak guard/object precede seven real colors, shifting their .sbss offsets by eight bytes. These differences remain unresolved without artificial data placement. No linking investigation or Matching status changes.
- The literal pool is identical, and .rodata/.sdata/.sdata2 remain 100%. .data retains jump-table target differences from unmatched code and weak vtable differences; .sbss is below 100%. Full data completion is still open.
- Uncertain: original spelling/types of some drawer fields, the intended source form of weak singleton/color storage, and the trailing Chinese visibility word. No shared headers are changed this round.
### Fourth continuation remaining report-nonmatching functions
Base::onPressLeftHWKB, 99.97727%, two kana comparison/branch-polarity instructions; direct guard loses a tail branch, explicit cases add instructions.
Base::onPressRightHWKB, 99.97818%, same two kana comparison/branch-polarity instructions.
Base::onCursor, 99.915436%, five centered-space FP register/operand differences; compound offset evaluation worsens scheduling.
Base::onPressUp, 99.55285%, missing kana tail branch; false/default switch adds one instruction, explicit cases add four.
Base::onPressDown, 99.55285%, same missing kana tail branch.
Base::onPressDownHWKB, 98.35185%, candidate index/branch scheduling and final comparison; three variants remain 266/270 or 267/270 instructions.
LayoutByNW4R::setLanguage, 96.44726%, 22 root-query scheduling differences; name local and ternary retain those differences, title local worsens allocation.
Base::isOverRowLimit, 93.63866%, stack frame and FP/register scheduling; direct scale removes four instructions, operand variants remain 236/238.
Base::calcCursorPos, 90.671776%, FP/register scheduling; two variants retain 326/326 with 81 differences, aggregate glyph initialization adds instructions.
LayoutByNW4R::create, 88.91854%, row-list allocation/register scheduling; narrow index unchanged, implicit placement constructor removes three instructions, detached guard adds two.
Base::onCommand, 88.05163%, frame, case scheduling and register allocation; three variants retain 2056/2053 instructions.
textdrawer::Base::isEnableCursorCache, None%, original report concatenates getStartPos; actual accessor remains eight exact bytes. No aliases or symbol edits.
### Fourth continuation remaining exact asm bodies
LayoutByNW4R::draw, 100%, closest C++ 114/114 with twelve vector temporary stack offsets.
Base::findURL, 100%, balanced ASCII switch and cached real prefix table produce 111/111; closest twenty register differences. Three later variants change allocation, without improving the closest result.
Base::autoScroll, 100%, direct height/scale expression produces 150/150; twenty-five FP and instruction scheduling differences.
Base::create(MEMAllocator*, EditBuffer*), 100%, typed detached-row guard and list reload produce 72/72; twenty-six register differences.
Base::onPressLeft, 100%, kana guard and prediction Boolean block order remain; fresh case/loop variants 158/154, 155/154, 157/154.
Base::onPressRight, 100%, wide space buffer uses halfword stores while target uses word copies; fresh ordinary aggregate/copy variants differ in counts and kana guard.
Base::calc, 100%, closest C++ 165/165 with six FP/store scheduling differences after genuine timer/phase locals.
Base::RowInfoManager::init, 100%, references and preceding-row index produce 39/39 with fifteen index-load/store scheduling/register differences.
Base::isOverLine, 100%, named vectors copy four extra words; expression variants reduce to 48/51, 47/51, 43/51 by changing scale/width scheduling.
### Fourth continuation final full gate
```text
full build: ok
main.dol sha1: 26116613f624061ba99c8d1a299aaa6efa85670d
[src/keyboard/tiInputForm] pool: IDENTICAL
[src/keyboard/tiInputForm] objdiff: code 30712/50656 data 908/3772 functions 209/221 fuzzy 97.2529 linked code 0
[src/keyboard/tiInputForm] instruction-exact functions: 207/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.25292
[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: 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: 73.53608 -> 73.61661
global fuzzy_match_percent: 82.99180 -> 82.99235
global complete_code_percent: 56.76068 -> 56.76068
global matched_data_percent: 86.39154 -> 86.39154
forbidden patterns added (net, per file): 0
readability warnings (net, per file; must be 0 in the final result): 0
GATE PASS
```

View File

@@ -1,55 +0,0 @@
# tiManager matching attempts
Baseline: source absent; 0/62 functions, 0/8368 code bytes. The implementation uses only C++, existing keyboard interfaces, and constructors for the seven concrete Sample layouts. Shared declarations are enabled only by TIMANAGER_IMPLEMENTATION.
## Pool and data
1. Initial Sample constructors contained their layout literals. Deferred inline expansion placed these after the vtables and emitted them in constructor order. Pool diverged at string 1. Passing ordinary layout-name literals from the factories restored all eight strings and their offsets.
2. Sample declarations initially followed input includes and the factory order. The vtable contents mostly matched but table addresses differed. Declaring the Samples in reverse emission order, with the manager header last, restored the target's table order.
3. The out-of-line HWKeyboard destructor emitted a strong HWKeyboard vtable absent from the target. Declaring its C++ destructor inline made that table weak and restored every strong table's offset. The destructor still matches all 16 instructions.
4. Enabled the actual inherited CommandReceiver::Scroll and inherited CommandSender::updateFromReceiver declarations for this unit. This corrected the inputform and signwindow vtable relocation names without affecting other units.
A word-by-word comparison of .data now finds exactly two relocation-name differences, at 0x520 and 0xa44. The original names are `isEnableCursorCache__Q39textinput10textdrawer4BaseCFvgetStartPos__Q39textinput10textdrawer4BaseCFv` and `@236@onEvent__Q49textinput8keyboard6pctype12LayoutByNW4RFPQ49textinput8keyboard6pctype5`. The compiler produces the ordinary complete C++ names. All other .data bytes and relocations agree within the target's 2696-byte extent. The compiler additionally emits 48 bytes of weak vtables for pctype::UIObj::Listener, nw4rmanager::AnmObserver, and gui::EventHandler; these are absent from the extracted target object. No symbol aliases, forced labels, or edits to target symbol names were attempted. Objdiff nevertheless reports .data below 100%; automatic string symbols, the weak tables, and those malformed target names remain unresolved.
## Functions
- Constructor, create, initAspect, draw, prediction wrappers, string/length wrappers, factories, filters, isVacancy, and Sample destructors matched from the first implementation or after correcting header types and string placement.
- Destructor: initial implementation cleared seven members after freeing them (131 instructions versus 123). Removing those unsupported stores gave 123/123, zero diffs.
- init: 209/209 with three diffs. Comparing the aspect flag to true corrected branch direction; calling setSecretInputMode(false), as the target slot 0x4c specifies, corrected the last virtual call. Zero diffs.
- calc, setAnimationOn, scale functions, SetFont: pointer-to-secondary-base conversions added null checks. Casting dereferenced objects to Layout references removed those checks. All matched.
- createPCTypeKeyboard: 82/82, nine ordering diffs. Initializing KeyState before allocator, qwerty flag, and manager in the Base constructor gave zero diffs.
- updateInput(HKBManager&): initial 137/130 instructions. Returning immediately from modal dialog/window branches, selecting the keyboard using the saved qwerty state, and grouping the four boolean results as (keyboard | candidates) | (form | toolbar) produced 130/130, zero diffs.
- updateInput(Wii): initial 206/206 with 25 diffs after the preceding changes. Moving updateInputCommon before the sign-window activity check reproduced the target's call order, 206/206, zero diffs.
- setAspectRatio: initial 11/12 instructions; converting the bool to u8 before comparing with true restored the target's byte extension, 12/12, zero diffs.
- setTitleText: a separate pane temporary followed by DynamicCast gave 49/49 with seven register differences. Nesting the getPane call directly in DynamicCast gave 49/49, zero diffs.
## Remaining generated initializer
`__sinit_\tiKeyboard_cpp` is not emitted under that name because the required source file is tiManager.cpp.
1. A namespace-scope static default observer with its implicit constructor emits `__sinit_\tiManager_cpp`, four instructions: lis, addi, stw, blr, matching the target initializer's instruction sequence.
2. An anonymous-namespace default observer changes its object linkage name but still emits the same four instructions under the tiManager initializer name. Reverted for simpler source.
3. An explicitly empty EventObserver constructor also emits the same four instructions and unchanged initializer name. Reverted because the implicit constructor suffices.
The name mismatch remains. No generated-function rename, assembler alias, or filename override was introduced.
## Changed files
- src/keyboard/tiManager.cpp
- include/keyboard/tiCandidateBox.h
- include/keyboard/tiCellPhone.h
- include/keyboard/tiHKBManager.h
- include/keyboard/tiHwKeyboard.h
- include/keyboard/tiInputForm.h
- include/keyboard/tiKeyboard.h
- include/keyboard/tiManager.h
- include/keyboard/tiNw4rManager.h
- include/keyboard/tiPcKeyboard.h
- include/keyboard/tiPcKeyboardImpl.h
- include/keyboard/tiPredictLang.h
- include/keyboard/tiString.h
- include/keyboard/tiTextDrawer.h
- include/keyboard/tiTextInputBase.h
- include/keyboard/tiToolBar.h
- include/keyboard/tiZiString.h
- tools/decomp-assist/tiManager.attempts.md

View File

@@ -1,45 +0,0 @@
# tiSignWindow matching attempts
Baseline: absent source, 0/56 functions and 0/7184 code bytes. The source reconstructs the actual animation, pane, language, and key-name tables using ordinary literals and typed objects. Previous scratch C++ and the original-object Ghidra export were references. Their explicit padding, mangled free-function calls, manual vtable dispatch, and raw pointer offsets were removed before the first build.
## Data
The first build already had all 30 strings in the original pool order. The nine animation records occupy 612 bytes; the compiler supplies the following alignment naturally, without a padding record. InputCharacter is a real 12-byte command payload with ordinary aggregate initialization.
The first .data score was 83.582375%. Declaring the three concrete animation-pane classes in reverse vtable emission order restored their table order. Inheriting CommandSender::setCommandReceiver and sendCommand for this unit corrected the two Base/Layout vtables. All data sections subsequently reached 100% in objdiff: .data, .rodata, .sdata, and .ctors. A trial making the key-name table static caused the compiler to remove it and broke the pool; the table retains ordinary external linkage so the real target table is present.
## Matched functions
Most functions matched on the first readable implementation, including destruction, initialization, modal-window operations, character/page rendering, input handling, and animation callbacks.
- The input payload's repeat flag initially read an unsigned-byte member into bool and emitted three normalization instructions. Declaring the actual boolean repeat/locked/input/active fields restored the target loads and stores.
- CellPhoneSignAllAnmPane::onAnmEvent had 39/39 instructions with two unsigned comparisons. Making the stored animation state signed restored both comparisons and gave zero diffs.
- Base::onKey initially had 115/115 instructions with 13 differences. Moving counters into their respective scopes produced 19 differences; reversing the two counter declarations also produced 19; using an unsigned control-key result increased the count to 116. These variants were reverted.
- A real inline control-key lookup reduced Base::onKey to ten differences and LayoutByNW4R::onKey to eight. A character lookup accepting LanguageDependency reduced the layout function to five differences. Swapping the helper's parameter order left five differences. Passing the actual key array to the character helper restored the target register allocation for both functions.
- Base::onKey then showed two false ctxdiff differences on CR1 branches. Inspection found identical instruction bytes for both branches; the helper normalizes the CR operand as if it were a branch address when function offsets differ. Declaring the already-existing KeyboardBase::getLanguage externally in this unit avoided a duplicate weak inline body, restored the original function offset, and ctxdiff reported zero differences without any instruction changes to onKey.
## Remaining function: LayoutByNW4R::create
All variants use typed placement construction, real class sizes, and the same 221 instructions as the target. The remaining differences are callee-saved register allocation, including hoisted vtable addresses, animation count, and animation-record temporaries.
1. Initial scoped const forceName/animationCount variables: 61 differences.
2. Declared forceName and animationCount outside the pane loop and assigned them after appending the pane: 34 differences.
3. Declared the pane pointer before the pane-table reference: still 34 differences.
4. Reversed the forceName/count declarations: 37 differences, reverted.
5. Changed the outer for loop to a do/while loop with an explicit paneIndex: still 34 differences, retained.
6. Kept forceName outside but made animationCount local and const: 59 differences, reverted.
The retained version has 221/221 instructions and 34 register differences. No artificial code or data placement was used.
## Changed files
- src/keyboard/tiSignWindow.cpp
- include/keyboard/tiSignWindow.h
- include/keyboard/tiHKBManager.h
- include/keyboard/tiInputForm.h
- include/keyboard/tiKeyboard.h
- include/keyboard/tiNw4rManager.h
- include/keyboard/tiPcKeyboard.h
- include/keyboard/tiPcKeyboardImpl.h
- include/keyboard/tiTextInputBase.h
- tools/decomp-assist/tiSignWindow.attempts.md