Compare commits

...

8 Commits

Author SHA1 Message Date
Devin
b85045cd53 esmisc: implement DeleteUnauthorizedData (91.97% fuzzy, allocator tie-break)
Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-28 11:03:49 +00:00
coah
b1fd404137 Improve iplBoard and iplChannelSelect matching (#223)
* feat: improve iplBoard matching

Restructure calc, stt_wait_fadeaway and edge_arrow with early returns
and split conditions, iterate hovered objects with an explicit next
pointer, and add the VEC3 add helper used by calc_board_object. 93/94
functions now match; appendRecord still differs because the original
keeps the interrupt state on the stack.

Ported from agent/continue0923/src_scene_board_iplboard without its
string-pool and volatile workarounds.

* feat: improve iplChannelSelect matching

Build the constructor with an initializer list, specialize
HermiteIntp<VEC3>::get and HermiteIntp<f32>::get in the forms this unit
inlines, keep only the three zoom frames setChanZoomOrtho reads, compute
the drag delta as a VEC2 with an explicit zero-speed branch, and give
setChannelScissor its ortho bounds as named locals. 101/102 functions
now match.

Ported from agent/continue0923/src_scene_channelselect_iplchannelselect
without its IPL_CHANNEL_TITLE_NOVTABLE define, hand-placed lbl_ data,
volatile constant loads or register keywords.
2026-09-28 00:09:53 -05:00
coah
9a9f937e9e fix: link RevoEX ncdsystem (#222)
NCDiGetWirelessMacAddress is global in the original (net/wireless_macaddr.c
calls it), and the two .sbss statics are defined in reverse so MWCC emits
ncdInitialized first.
2026-09-28 00:05:58 -05:00
coah
0792087bf1 Salvage CDBAttr, CDBSystem, nand_drv, iplGraphics and RFL_NANDAccess matches (#221)
* feat: match CDBAttr unit

Make CDBAttrGetDescOffset static and fold the IV generation into
CDBAttrInitIV with a function-local seed, then link the unit.

Salvaged from agent/hard0928/clibs.

* feat: match CDBSystem unit

Implement the database and record pool functions, give the CDB work
buffer pointer a real name (shared with CDBDatabase), size s_mutex as a
plain OSMutex, and link the unit.

Salvaged from agent/hard0928/clibs.

* feat: match VF develop nand_drv unit

Make the NAND write/seek/create/delete wrappers inline so they fold into
_CreatePrfFile, test the override callbacks directly, fix the order of
the retry and sleep globals, size l_nandFunc without the trailing
padding, and link the unit. _MountPrfFile stays the existing asm.

Salvaged from agent/hard0928/clibs and
agent/continue0923/libs_revoex_src_vf_develop_nand_drv.

* feat: match iplGraphics unit

Compute the ortho projection bounds in the original order, size
Graphics::mArg without the trailing .bss padding, and link the unit.

Salvaged from agent/continue0923/src_utility_iplgraphics (without its
struct padding member).

* feat: complete RFL_NANDAccess data

Inline the NAND command block helpers so they no longer leave extab
entries, bringing extabindex to 100%.

Salvaged from agent/continue0924/rfl-nandaccess-data.

* feat: add eZiText zkokeyp source

Decompile the Korean keypad candidate functions. The unit stays
NonMatching: Zi8_81483118 matches exactly and the rest differ only by
register allocation or larger control-flow differences.

Salvaged from agent/hard0928/clibs.
2026-09-28 00:00:39 -05:00
coah
1542f73080 feat: link tiPredictLang unit (#220)
Declare the predictlang Sample class with its inline constructors so the
LayoutByNW4R thunks are emitted in the original order, and link the unit.
2026-09-27 23:50:01 -05:00
coah
d51e34beb2 Link iplLetterWriter as matching (#219)
Use string literals instead of hand-placed pool arrays so sendToPC addresses the pool base, emit calcFadeout before onEventDerived, and force-active the NigaoeEventObserver vtable that the original link keeps.
2026-09-27 23:47:34 -05:00
coah
5ffea56c30 feat: match tiToolBar unit (#218)
Fix the cancelStateFocusIn case label, declare the toolbar Sample class
with its inline constructors so the LayoutByNW4R thunks are emitted in
the original order, relabel the unit's data, and point the two
one-past-the-end csPaneToAnimation entries at csAninationFile+0x1DC.
2026-09-27 23:40:50 -05:00
coah
3dfeacd4f6 Match HomeButton base unit (#217)
Name the HBMAllocMem result so create's pane manager web colors like the original, replace the lbl_ float externs with literals, move the unused HomeButton int constants to in-class initializers, and emit calc_battery before calc_letter. HBMBase.cpp is now Matching.
2026-09-27 23:32:44 -05:00
22 changed files with 1244 additions and 397 deletions

View File

@@ -20,6 +20,22 @@ force_active:
- padding__Q23ipl5scene
- lbl_81695063
- lbl_81695067
- __vt__Q49textinput6extend4memo19NigaoeEventObserver
# textinput::toolbar::csPaneToAnimation points one past the end of csAninationFile.
block_relocations:
- source: .data:0x8165E15C
- source: .data:0x8165E19C
add_relocations:
- source: .data:0x8165E15C
type: abs
target: csAninationFile__Q29textinput7toolbar
addend: 0x1DC
- source: .data:0x8165E19C
type: abs
target: csAninationFile__Q29textinput7toolbar
addend: 0x1DC
quick_analysis: true
fill_gaps: false

View File

@@ -7,7 +7,7 @@ mMac__Q33ipl6socket13SocketSetting = .bss:0x81089720; // type:object size:0x40
_database__7LibTVRC = .bss:0x81089760; // type:object size:0x20 data:4byte
_alarm__7LibTVRC = .bss:0x81089780; // type:object size:0x30
_tickWait__7LibTVRC = .bss:0x810897B0; // type:object size:0x10 data:4byte
mArg__Q33ipl7utility8Graphics = .bss:0x810897C0; // type:object size:0x88
mArg__Q33ipl7utility8Graphics = .bss:0x810897C0; // type:object size:0x84
unk__Q23ipl3snd = .bss:0x81089848; // type:object size:0xC
_seBlk__Q23ipl3snd = .bss:0x81089854; // type:object size:0xD8 data:4byte
sSystem__Q23ipl3snd = .bss:0x8108992C; // type:object size:0x63C data:4byte
@@ -123,7 +123,7 @@ CDB_SD_ROOT_PATH_LS = .bss:0x810C8A08; // type:object size:0x20
CDB_SD_VFF_FILE_NAME = .bss:0x810C8A28; // type:object size:0x48
lbl_810C8A80 = .bss:0x810C8A80; // type:object size:0x40 align:32
lbl_810C8AC0 = .bss:0x810C8AC0; // type:object size:0x40 align:32
s_mutex = .bss:0x810C8B00; // type:object size:0x20 scope:local
s_mutex = .bss:0x810C8B00; // type:object size:0x18 scope:local
s_cdbWiiId = .bss:0x810C8B20; // type:object size:0x40 scope:local
ncdMutex = .bss:0x810C8B60; // type:object size:0x20
ncdCommonResult = .bss:0x810C8B80; // type:object size:0x20 align:32 data:4byte
@@ -161,7 +161,7 @@ l_dev_init_info_table = .bss:0x810F55C0; // type:object size:0xD0 scope:local
l_tmpWName = .bss:0x810F5690; // type:object size:0x10 scope:local data:2byte
hashTable = .bss:0x810F56A0; // type:object size:0x22E scope:local data:byte
l_driveInfo = .bss:0x810F58D0; // type:object size:0x208 scope:local data:4byte
l_nandFunc = .bss:0x810F5AD8; // type:object size:0x1A8 scope:local
l_nandFunc = .bss:0x810F5AD8; // type:object size:0x1A0 scope:local
l_event = .bss:0x810F5C80; // type:object size:0x340 scope:local
l_sddrv_info = .bss:0x810F5FC0; // type:object size:0x80 scope:local
sZeroBuffer__Q44nw4r3snd6detail9AxManager = .bss:0x810F6040; // type:object size:0x100
@@ -13938,7 +13938,7 @@ pppURLCheck = .rodata:0x816152A8; // type:object size:0x28 scope:local
lbl_816152D0 = .rodata:0x816152D0; // type:object size:0x10 scope:local data:4byte
csAninationFile__Q29textinput12candidatebox = .rodata:0x816152E0; // type:object size:0x378 scope:local
lbl_81615658 = .rodata:0x81615658; // type:object size:0xA0 scope:local data:4byte
csAninationFile__Q29textinput7toolbar = .rodata:0x816156F8; // type:object size:0x1E0 scope:local data:4byte
csAninationFile__Q29textinput7toolbar = .rodata:0x816156F8; // type:object size:0x1DC scope:local data:4byte
csAninationFile__Q29textinput11predictlang = .rodata:0x816158D8; // type:object size:0x268 scope:local
csAninationFileForSign__Q39textinput8keyboard10signwindow = .rodata:0x81615B40; // type:object size:0x268 scope:local
csPaneNameToControlKey__Q39textinput8keyboard10signwindow = .rodata:0x81615DA8; // type:object size:0x48 scope:local
@@ -17535,20 +17535,20 @@ __vt__Q39textinput12candidatebox4Base = .data:0x8165DFA8; // type:object size:0x
__vt__Q39textinput12candidatebox18CandidateBoxCaller = .data:0x8165DFFC; // type:object size:0x1C
__vt__Q39textinput11nw4rmanager11AnmObserver = .data:0x8165E018; // type:object size:0x4C
__vt__Q39textinput4util12AnimObserver = .data:0x8165E064; // type:object size:0xC
lbl_8165E070 = .data:0x8165E070; // type:object size:0xC data:string
lbl_8165E080 = .data:0x8165E080; // type:object size:0x10 data:string
lbl_8165E090 = .data:0x8165E090; // type:object size:0xD data:string
lbl_8165E0A0 = .data:0x8165E0A0; // type:object size:0xC data:string
@6142 = .data:0x8165E070; // type:object size:0xC scope:local data:string
@6143 = .data:0x8165E080; // type:object size:0x10 scope:local data:string
@6144 = .data:0x8165E090; // type:object size:0xD scope:local data:string
@6145 = .data:0x8165E0A0; // type:object size:0xC scope:local data:string
csPaneToAnimation__Q29textinput7toolbar = .data:0x8165E0B0; // type:object size:0x100
lbl_8165E1B0 = .data:0x8165E1B0; // type:object size:0xD data:string
lbl_8165E1C0 = .data:0x8165E1C0; // type:object size:0xC data:string
lbl_8165E1CC = .data:0x8165E1CC; // type:object size:0xD data:string
lbl_8165E1DC = .data:0x8165E1DC; // type:object size:0xC data:string
lbl_8165E1E8 = .data:0x8165E1E8; // type:object size:0xC data:string
lbl_8165E1F8 = .data:0x8165E1F8; // type:object size:0x10 data:string
jumptable_8165E208 = .data:0x8165E208; // type:object size:0x30 scope:local
lbl_8165E238 = .data:0x8165E238; // type:object size:0xC data:string
jumptable_8165E244 = .data:0x8165E244; // type:object size:0x1C scope:local
@6802 = .data:0x8165E1B0; // type:object size:0xD scope:local data:string
@6805 = .data:0x8165E1C0; // type:object size:0xC scope:local data:string
@6808 = .data:0x8165E1CC; // type:object size:0xD scope:local data:string
@6812 = .data:0x8165E1DC; // type:object size:0xC scope:local data:string
@6816 = .data:0x8165E1E8; // type:object size:0xC scope:local data:string
@6817 = .data:0x8165E1F8; // type:object size:0x10 scope:local data:string
@6837 = .data:0x8165E208; // type:object size:0x30 scope:local
@6894 = .data:0x8165E238; // type:object size:0xC scope:local data:string
@6937 = .data:0x8165E244; // type:object size:0x1C scope:local
__vt__Q39textinput7toolbar19ToggleButtonAnmPane = .data:0x8165E260; // type:object size:0x2C
__vt__Q39textinput7toolbar19NormalButtonAnmPane = .data:0x8165E28C; // type:object size:0x2C
__vt__Q39textinput7toolbar7AnmPane = .data:0x8165E2B8; // type:object size:0x2C
@@ -22266,10 +22266,10 @@ lbl_816973C4 = .sdata:0x816973C4; // type:object size:0x4 data:4byte
lbl_816973C8 = .sdata:0x816973C8; // type:object size:0x8
lbl_816973D0 = .sdata:0x816973D0; // type:object size:0x8 data:string
lbl_816973D8 = .sdata:0x816973D8; // type:object size:0x8 data:string
lbl_816973E0 = .sdata:0x816973E0; // type:object size:0x4 data:4byte
lbl_816973E4 = .sdata:0x816973E4; // type:object size:0x4 data:4byte
lbl_816973E8 = .sdata:0x816973E8; // type:object size:0x5 data:string
lbl_816973F0 = .sdata:0x816973F0; // type:object size:0x7 data:string
COMMON_BUTTON_ANIM__Q29textinput7toolbar = .sdata:0x816973E0; // type:object size:0x4 scope:local data:4byte
COMMON_CHG_ANIM__Q29textinput7toolbar = .sdata:0x816973E4; // type:object size:0x4 scope:local data:4byte
@6901 = .sdata:0x816973E8; // type:object size:0x5 scope:local data:string
@6908 = .sdata:0x816973F0; // type:object size:0x7 scope:local data:string
lbl_816973F8 = .sdata:0x816973F8; // type:object size:0x4 data:4byte
lbl_81697400 = .sdata:0x81697400; // type:object size:0x4 data:4byte
lbl_81697404 = .sdata:0x81697404; // type:object size:0x4 data:4byte
@@ -23523,7 +23523,7 @@ s_fatalVFFlag = .sbss:0x81698D7C; // type:object size:0x4 scope:local data:4byte
CDBPrintDebugLevel = .sbss:0x81698D80; // type:object size:0x4 data:4byte
s_lastNANDError = .sbss:0x81698D84; // type:object size:0x4 scope:local data:4byte
s_lastVFError = .sbss:0x81698D88; // type:object size:0x4 scope:local data:4byte
lbl_81698D8C = .sbss:0x81698D8C; // type:object size:0x4 scope:local data:4byte
CDBDatabaseWorkBuf = .sbss:0x81698D8C; // type:object size:0x4 data:4byte
s_recordPool = .sbss:0x81698D90; // type:object size:0x4 scope:local data:4byte
s_databasePool = .sbss:0x81698D94; // type:object size:0x4 scope:local data:4byte
lbl_81698D98 = .sbss:0x81698D98; // type:object size:0x4 data:4byte

View File

@@ -671,7 +671,7 @@ config.libs = [
Object(Matching, "utility/iplTVRCUtils.cpp"),
Object(Matching, "utility/iplTree.cpp"),
Object(Matching, "utility/iplFrameController.cpp"),
Object(Equivalent, "utility/iplGraphics.cpp"),
Object(Matching, "utility/iplGraphics.cpp"),
Object(Matching, "utility/iplCapture.cpp"),
Object(Matching, "utility/iplUtility.cpp"),
Object(Matching, "utility/iplThread.cpp"),
@@ -704,7 +704,7 @@ config.libs = [
]
),
IPLSection("homebutton", [
Object(Equivalent, "homebutton/HBMBase.cpp"),
Object(Matching, "homebutton/HBMBase.cpp"),
Object(Matching, "homebutton/HBMAnmController.cpp"),
Object(Matching, "homebutton/HBMController.cpp"),
Object(Matching, "homebutton/HBMFrameController.cpp"),
@@ -788,7 +788,7 @@ config.libs = [
]
),
IPLSection("letterWriter", [
Object(Equivalent, "scene/letterWriter/iplLetterWriter.cpp"),
Object(Matching, "scene/letterWriter/iplLetterWriter.cpp"),
]
),
IPLSection("limitOver", [
@@ -911,8 +911,8 @@ config.libs = [
Object(NonMatching, "keyboard/tiCellPhone.cpp", extra_cflags=["-O4,p"]),
Object(NonMatching, "keyboard/tiInputForm.cpp", extra_cflags=["-O4,p"]),
Object(NonMatching, "keyboard/tiCandidateBox.cpp", extra_cflags=["-O4,p"]),
Object(NonMatching, "keyboard/tiToolBar.cpp", extra_cflags=["-O4,p"]),
Object(NonMatching, "keyboard/tiPredictLang.cpp", extra_cflags=["-O4,p"]),
Object(Matching, "keyboard/tiToolBar.cpp", extra_cflags=["-O4,p"]),
Object(Matching, "keyboard/tiPredictLang.cpp", extra_cflags=["-O4,p"]),
Object(NonMatching, "keyboard/tiSignWindow.cpp", extra_cflags=["-O4,p"]),
Object(NonMatching, "keyboard/tiString.cpp", extra_cflags=["-O4,p"]),
Object(NonMatching, "keyboard/tiAtokString.cpp", extra_cflags=["-O4,p"]), # for 4.3J
@@ -1025,8 +1025,8 @@ config.libs = [
Object(Matching, "cdb/CDBRecordFile.c"),
Object(Matching, "cdb/CDBRecordKey.c"),
Object(NonMatching, "cdb/CDBIntArray.c"),
Object(NonMatching, "cdb/CDBSystem.c"),
Object(Equivalent, "cdb/CDBAttr.c"),
Object(Matching, "cdb/CDBSystem.c"),
Object(Matching, "cdb/CDBAttr.c"),
Object(Matching, "cdb/CDBFBridge.c"),
Object(Matching, "cdb/CDBFBridgeVF.c"),
Object(Matching, "cdb/CDBFBridgeSD.c"),
@@ -1035,7 +1035,7 @@ config.libs = [
]
),
RevoEXLib("ncd", [
Object(NonMatching, "ncd/ncdsystem.c"),
Object(Matching, "ncd/ncdsystem.c"),
Object(NonMatching, "ncd/ncdsleep.c"),
]
),
@@ -1163,7 +1163,7 @@ config.libs = [
Object(Matching, "vf/develop/d_hash.c"),
Object(Matching, "vf/develop/d_time.c"),
Object(Matching, "vf/develop/d_common.c"),
Object(NonMatching, "vf/develop/nand_drv.c"),
Object(Matching, "vf/develop/nand_drv.c"),
Object(Matching, "vf/develop/sd_drv.c"),
]
),

View File

@@ -272,20 +272,20 @@ namespace homebutton {
f32 mFadeOutSeTime; // 0x798
private:
static const int scSoundHeapSize_but2;
static const int scSoundHeapSize_but3;
static const int scSoundThreadPrio;
static const int scDvdThreadPrio;
static const int scSoundHeapSize_but2 = 0x60000;
static const int scSoundHeapSize_but3 = 0x6f800;
static const int scSoundThreadPrio = 4;
static const int scDvdThreadPrio = 3;
static const int scReConnectTime;
static const int scReConnectTime2;
static const int scPadDrawWaitTime;
static const int scGetPadInfoTime;
static const int scForcusSEWaitTime;
static const int scReConnectTime = 3600;
static const int scReConnectTime2 = 3570;
static const int scPadDrawWaitTime = 5;
static const int scGetPadInfoTime = 100;
static const int scForcusSEWaitTime = 2;
static const f32 scOnPaneVibTime;
static const f32 scOnPaneVibWaitTime;
static const int scWaitStopMotorTime;
static const int scWaitDisConnectTime;
static const int scWaitStopMotorTime = 30;
static const int scWaitDisConnectTime = 180;
static const char* scCursorLytName[res::eCursorLyt_Max];
static const char* scCursorPaneName;

View File

@@ -14,6 +14,10 @@ namespace textinput {
class Base : public CommandSender {
public:
#ifdef TI_PREDICTLANG_SAMPLE_CLASS
Base(Manager* manager) : mePredictMode(inputform::Base::PM_USEn), mpAllocator(NULL), mpManager(manager) {}
#endif
virtual void create(MEMAllocator* allocator) override { mpAllocator = allocator; }
virtual void setPredictMode(inputform::Base::PredictMode mode) { mePredictMode = mode; }
@@ -28,6 +32,12 @@ namespace textinput {
class LayoutByNW4R : public Base, public nw4rmanager::Layout, public nw4rmanager::AnmObserver {
public:
#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) {}
#endif
virtual ~LayoutByNW4R();
virtual void create(MEMAllocator* allocator) override;
virtual void init() override;
@@ -58,6 +68,15 @@ namespace textinput {
keyboard::KeyboardBase* mpCaller; // 0xD4
};
#ifdef TI_PREDICTLANG_SAMPLE_CLASS
class Sample : public LayoutByNW4R {
public:
Sample(Manager* manager, nw4r::lyt::MultiArcResourceAccessor* resAccessor, EventObserver* observer)
: LayoutByNW4R(manager, resAccessor, observer) {}
virtual ~Sample() {}
};
#endif
class EventHandler : public nw4rmanager::TiEventHandler {
public:
EventHandler(LayoutByNW4R* layout) : mpLayoutByNW4R(layout) {}

View File

@@ -10,6 +10,10 @@ namespace textinput {
namespace toolbar {
class Base {
public:
#ifdef TI_TOOLBAR_SAMPLE_CLASS
Base(Manager* manager) : mQwerty(true), meLanguage(USA), mpAllocator(NULL), mpManager(manager) {}
#endif
virtual void create(MEMAllocator* allocator) { mpAllocator = allocator; }
virtual void init() {}
virtual bool isQwerty() const { return mQwerty; }
@@ -31,6 +35,12 @@ namespace textinput {
class LayoutByNW4R : public Base, public nw4rmanager::Layout {
public:
#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) {}
#endif
virtual ~LayoutByNW4R();
virtual void create(MEMAllocator* allocator) override;
virtual void init() override;
@@ -107,7 +117,16 @@ namespace textinput {
KeyType meKeyType; // 0x30
};
#ifdef TI_TOOLBAR_SAMPLE_CLASS
class Sample : public LayoutByNW4R {
public:
Sample(Manager* manager, nw4r::lyt::MultiArcResourceAccessor* resAccessor, EventObserver* observer)
: LayoutByNW4R(manager, resAccessor, observer) {}
virtual ~Sample() {}
};
#else
class Sample {};
#endif
class NormalButtonAnmPane : public AnmPane {
public:

View File

@@ -50,7 +50,7 @@ namespace ipl {
static BOOL IsLastTicketExpired(ESTitleId* titleId);
static void DeleteExpiredFlagFile();
static void DeleteUnauthorizedData(EGG::Heap* heap);
static s32 DeleteUnauthorizedData(EGG::Heap* heap);
static u32 CheckTmdCountryCode(ESTmdView* tmdView);
static u32 CheckTmdParentalControl(ESTmdView* tmdView);

View File

@@ -133,7 +133,7 @@ void RFLiEndWorking(RFLErrcode errcode) {
RFLiEndWorkingReason(errcode, 0);
}
NANDCommandBlock* RFLiSetCommandBlock(RFLiFileType type, RFLiAsyncTag tag) {
inline NANDCommandBlock* RFLiSetCommandBlock(RFLiFileType type, RFLiAsyncTag tag) {
NANDCommandBlock* block = &RFLiGetAccInfo(type)->commandBlock;
RFLiCallbackTag* store = &RFLiGetAccInfo(type)->callbackTag;
@@ -147,7 +147,7 @@ NANDCommandBlock* RFLiSetCommandBlock(RFLiFileType type, RFLiAsyncTag tag) {
return block;
}
RFLiAsyncTag RFLiGetTag(NANDCommandBlock* block) {
inline RFLiAsyncTag RFLiGetTag(NANDCommandBlock* block) {
RFLiCallbackTag* stored;
RFLi_ASSERTLINE_NULL(block, 312);
@@ -159,7 +159,7 @@ RFLiAsyncTag RFLiGetTag(NANDCommandBlock* block) {
return stored->tag;
}
RFLiFileType RFLiGetType(NANDCommandBlock* block) {
inline RFLiFileType RFLiGetType(NANDCommandBlock* block) {
RFLiCallbackTag* stored;
RFLi_ASSERTLINE_NULL(block, 335);
@@ -171,7 +171,7 @@ RFLiFileType RFLiGetType(NANDCommandBlock* block) {
return stored->type;
}
NANDFileInfo* RFLiGetWorkingFile(RFLiFileType type) {
inline NANDFileInfo* RFLiGetWorkingFile(RFLiFileType type) {
RFLi_ASSERTLINE_RANGE(type, RFLiFileType_Database, RFLiFileType_Max, 356);
if (!RFLAvailable()) {

View File

@@ -0,0 +1,534 @@
#include <zi8clib/zierror.h>
extern ziU16 Zi8GetTableCount(ziU8 lang, ziU8 tableIdx ZI_NEED_WORK);
extern ziU32 Zi8GetTableAddress(ziU8 lang, ziU8 tableIdx ZI_NEED_WORK);
ziU32 Zi8_8148302C(ziU16 key, ziU8* table ZI_NEED_WORK) {
ziU32 value;
ziU16 count;
ziU32 i;
count = Zi8GetTableCount(ZI8_LANG_KO, 9, ZI_WORK);
for (i = 0; (ziU16)i < count; i++) {
value = (ziU16)(((ziU16)table[((i & 0xFFFF) << 3) + (i & 0xFFFF) + 7] << 8) |
table[((i & 0xFFFF) << 3) + (i & 0xFFFF) + 8]);
if (key == value) {
Zi8LogError(0x64, ZI_WORK);
return i;
}
}
Zi8LogError(0x96A, ZI_WORK);
return 0xFFFF;
}
void Zi8_81483118(ziGetParam* param, ziU8* output) {
ziU8 i;
for (i = 0; i < 5; i++) {
output[i] = 0;
}
switch (param->elementCount) {
case 9:
output[4] |= (ziU8)((param->elements[8] & 0xF) << 4);
case 8:
output[3] = param->elements[7] & 0xF;
case 7:
output[3] |= (ziU8)((param->elements[6] & 0xF) << 4);
case 6:
output[2] = param->elements[5] & 0xF;
case 5:
output[2] |= (ziU8)((param->elements[4] & 0xF) << 4);
case 4:
output[1] = param->elements[3] & 0xF;
case 3:
output[1] |= (ziU8)((param->elements[2] & 0xF) << 4);
case 2:
output[0] = param->elements[1] & 0xF;
case 1:
output[0] |= (ziU8)((param->elements[0] & 0xF) << 4);
case 0:
break;
}
}
ziU32 Zi8_81483264(const ziGetParam* param ZI_NEED_WORK) {
ziU8 i;
if (param->scratch == ZI8_NULL) {
Zi8LogError(0x164, ZI_WORK);
return 1;
}
for (i = 0; i < param->maxCandidates; i++) {
((ziU16*)param->scratch)[i] = 0;
}
Zi8LogError(0x64, ZI_WORK);
return 0;
}
ziU32 Zi8_81483308(ziGetParam* param, ziU16 key, ziU8* count ZI_NEED_WORK) {
ziU8 i;
Zi8LogError(0x64, ZI_WORK);
if (param->scratch == ZI8_NULL) {
Zi8ReplaceLastError(0x164, ZI_WORK);
return 1;
}
for (i = 0; i < param->maxCandidates; i++) {
if (key == ((ziU16*)param->scratch)[i]) {
return 1;
}
}
((ziU16*)param->scratch)[*count] = key;
if (++*count >= param->maxCandidates) {
*count = 0;
}
return 0;
}
ziBool Zi8_814833F0(const ziGetParam* param, ziU16 key ZI_NEED_WORK) {
ziU8 i;
Zi8LogError(0x64, ZI_WORK);
if (param->scratch == ZI8_NULL) {
Zi8ReplaceLastError(0x164, ZI_WORK);
return 0;
}
for (i = 0; i < param->maxCandidates; i++) {
if (key == ((ziU16*)param->scratch)[i]) {
return 1;
}
}
return 0;
}
ziU32 Zi8_814834AC(ziGetParam* param, ziU16* remaining, ziU8* count,
ziU8* inserted ZI_NEED_WORK) {
ziBool matches;
ziS32 entry;
ziS32 tableA;
ziS32 tableB;
ziU16 tableCount;
ziU8 matched;
ziU32 j;
ziS32 i;
ziU8 candidateIndex;
union {
ziU32 words[13];
ziU8 bytes[52];
} local;
matched = 0;
local.words[0] = 0;
local.bytes[4] = 0;
Zi8LogError(0x64, ZI_WORK);
if (param->elementCount == 0) {
if (*remaining >= *count) {
for (i = 0; i < *count; i++) {
Zi8_81483308(param, param->candidates[i], inserted, ZI_WORK);
}
*remaining = *remaining - *count;
*count = 0;
} else {
for (i = 0; i < *remaining; i++) {
Zi8_81483308(param, param->candidates[i], inserted, ZI_WORK);
}
for (i = 0; i < ((ziS32)*count - (ziS32)*remaining); i++) {
param->candidates[i] = param->candidates[(ziU32)*remaining + i];
}
*count = *count - (ziU8)*remaining;
*remaining = 0;
}
return 1;
} else if (param->elementCount <= 9) {
tableA = Zi8GetTableAddress(param->language, 9, ZI_WORK);
tableB = Zi8GetTableAddress(param->language, 10, ZI_WORK);
if (tableA == 0) {
Zi8ReplaceLastError(0x76C, ZI_WORK);
return 0;
} else if (tableB == 0) {
Zi8ReplaceLastError(0x776, ZI_WORK);
return 0;
} else {
tableCount = Zi8GetTableCount(ZI8_LANG_KO, 9, ZI_WORK);
Zi8_81483118(param, local.bytes);
i = 0;
while (i < tableCount && matched < *count) {
matches = ZI8_TRUE;
entry = (i << 3) + tableA + i;
j = 0;
if (param->elementCount > 1) {
for (j = 0; (j & 0xFF) < (ziU32)(param->elementCount >> 1); j++) {
if (local.bytes[j & 0xFF] != *((ziU8*)entry + (j & 0xFF))) {
matches = ZI8_FALSE;
break;
}
}
}
if (matches && (param->elementCount & 1) != 0 &&
((local.bytes[j & 0xFF] & 0xF0) != (*((ziU8*)entry + (j & 0xFF)) & 0xF0))) {
matches = ZI8_FALSE;
}
if (matches) {
for (candidateIndex = 0; candidateIndex < *count; candidateIndex++) {
if (param->candidates[candidateIndex] ==
(ziU16)((*((ziU8*)entry + 7) << 8) | *((ziU8*)entry + 8))) {
matched++;
param->candidates[candidateIndex] =
param->candidates[candidateIndex] & 0x7FFF;
break;
}
}
}
i++;
}
if ((ziU16)matched >= *remaining) {
matched = *count;
*count = 0;
for (i = 0; i < matched; i++) {
if ((param->candidates[i] & 0x8000) == 0) {
param->candidates[i] = param->candidates[i] | 0x8000;
if (*remaining == 0) {
if (*count != i) {
param->candidates[*count] = param->candidates[i];
}
*count = *count + 1;
} else {
*remaining = *remaining - 1;
Zi8_81483308(param, param->candidates[i], inserted, ZI_WORK);
}
}
}
*remaining = 0;
} else {
for (i = 0; i < *count; i++) {
if ((param->candidates[i] & 0x8000) == 0) {
param->candidates[i] = param->candidates[i] | 0x8000;
Zi8_81483308(param, param->candidates[i], inserted, ZI_WORK);
}
}
*remaining = *remaining - (ziU16)matched;
*count = 0;
}
}
} else {
*count = 0;
return 0;
}
return 0;
}
ziU32 Zi8GetKOcandidates(ziGetParam* param, ziU8* options ZI_NEED_WORK) {
ziBool bVar1;
ziU8 bVar2;
ziS32 iVar4;
ziU32 uVar6;
ziU8* pbVar7;
union {
ziU32 words[10];
ziU8 bytes[40];
} local_28;
ziU8 local_57;
ziU8 local_56;
ziU8 local_55;
ziU8 local_54;
ziU8 local_53;
ziS8 local_52;
ziU16 local_50;
ziU16 local_4E;
ziU16 local_4C;
ziU16 local_4A;
ziU16 local_48;
ziS32 local_44;
ziS32 local_2C;
ziS32 local_30;
ziU32 local_34;
ziU32 local_38;
ziU32 local_3C;
ziU32 local_40;
local_4E = 0xFFFF;
local_34 = 0;
local_28.words[0] = 0;
local_28.bytes[4] = 0;
local_52 = 0;
local_53 = 0;
local_54 = 0;
local_55 = 0;
local_50 = param->firstCandidate;
local_3C = 0;
local_40 = 0;
local_57 = 0;
Zi8LogError(100, ZI_WORK);
Zi8_81483264(param, ZI_WORK);
iVar4 = Zi8GetTableAddress(ZI8_LANG_KO, 9, ZI_WORK);
local_2C = Zi8GetTableAddress(ZI8_LANG_KO, 10, ZI_WORK);
if (iVar4 == 0) {
Zi8ReplaceLastError(0x76C, ZI_WORK);
uVar6 = 0;
} else {
if (local_2C == 0) {
Zi8ReplaceLastError(0x776, ZI_WORK);
uVar6 = 0;
goto LAB_000114C4;
}
if (*options == 0) {
param->letters = 0;
param->count = 0;
param->candidates[0] = 0;
}
Zi8LogError(100, ZI_WORK);
if (param->wordCharCount != 0) {
local_48 = Zi8_8148302C(param->currentWord[0], (ziU8*)iVar4, ZI_WORK);
if ((local_48 != 0xFFFF) &&
((((ziU8*)iVar4)[((ziU32)local_48 * 9) + 4] & 8) != 0)) {
local_38 = (ziU32)((ziU8*)iVar4)[((ziU32)local_48 * 9) + 6] |
((ziU32)((ziU8*)iVar4)[((ziU32)local_48 * 9) + 4] & 3) << 16 |
(ziU32)((ziU8*)iVar4)[((ziU32)local_48 * 9) + 5] << 8;
local_52 = param->wordCharCount - 1;
local_53 = 1;
pbVar7 = (ziU8*)(local_2C + local_38);
LAB_00010D44:
if (local_52 != 0) {
local_48 = Zi8_8148302C(param->currentWord[local_53], (ziU8*)iVar4, ZI_WORK);
if (local_48 == (ziU16)((*pbVar7 & 0x1F) << 8 | pbVar7[1])) {
local_52 = local_52 - 1;
local_53 = local_53 + 1;
if ((*pbVar7 & 0x40) == 0) {
pbVar7 = pbVar7 + 2;
goto LAB_00010D44;
}
local_52 = param->wordCharCount - 1;
local_53 = 1;
} else {
local_53 = 1;
local_52 = param->wordCharCount - 1;
}
}
if (local_52 == 0) {
local_48 = (*pbVar7 & 0x1F) << 8 | pbVar7[1];
local_4C = (ziU16)(((ziU8*)((ziU32)local_48 * 9 + (ziU32)local_48 + (ziU32)iVar4))[7] << 8 |
((ziU8*)((ziU32)local_48 * 9 + (ziU32)local_48 + (ziU32)iVar4))[8]);
if (param->wordCharCount == 1) {
if (local_48 == local_4E) {
for (; (*pbVar7 & 0x40) == 0; pbVar7 = pbVar7 + 2) {
}
local_52 = param->wordCharCount;
goto LAB_00011114;
}
local_4E = local_48;
if (param->elementCount == 0) {
if (local_50 == 0) {
if (*options != 0) {
local_3C = local_3C + 1;
if ((ziS32)local_3C < *(ziS32*)(options + 0xC)) {
goto LAB_000110E8;
}
uVar6 = *(ziU32*)(options + 0xC);
goto LAB_000114C4;
}
param->candidates[local_54] = local_4C;
local_54 = local_54 + 1;
param->count = param->count + 1;
bVar2 = param->letters + 1;
param->letters = bVar2;
if (param->maxCandidates <= bVar2) {
uVar6 = param->letters;
goto LAB_000114C4;
}
} else {
local_50 = local_50 + -1;
}
} else {
param->candidates[local_54] = local_4C;
local_54 = local_54 + 1;
param->count = param->count + 1;
bVar2 = param->letters + 1;
param->letters = bVar2;
if (param->maxCandidates <= bVar2) {
Zi8_814834AC(param, &local_50, &local_54, &local_57, ZI_WORK);
param->count = local_54;
param->letters = local_54;
if (param->maxCandidates <= local_54) {
if (*options == 0) {
uVar6 = local_54;
goto LAB_000114C4;
}
local_3C = local_3C + local_54;
if (*(ziS32*)(options + 0xC) <= (ziS32)local_3C) {
uVar6 = *(ziU32*)(options + 0xC);
goto LAB_000114C4;
}
param->count = 0;
param->letters = 0;
local_54 = 0;
}
}
}
} else {
for (local_40 = 0;
(local_40 < local_54 &&
(local_4C != param->candidates[local_40]));
local_40 = local_40 + 1) {
}
if ((local_40 == local_54) &&
(Zi8_814833F0(param, local_4C, ZI_WORK) == 0)) {
param->candidates[local_54] = local_4C;
local_54 = local_54 + 1;
param->count = param->count + 1;
bVar2 = param->letters + 1;
param->letters = bVar2;
if (bVar2 < param->maxCandidates) {
goto LAB_000110E8;
}
Zi8_814834AC(param, &local_50, &local_54, &local_57, ZI_WORK);
param->count = local_54;
param->letters = local_54;
if (param->maxCandidates <= local_54) {
if (*options == 0) {
uVar6 = local_54;
goto LAB_000114C4;
}
local_3C = local_3C + local_54;
if (*(ziS32*)(options + 0xC) <= (ziS32)local_3C) {
uVar6 = *(ziU32*)(options + 0xC);
goto LAB_000114C4;
}
param->count = 0;
param->letters = 0;
local_54 = 0;
}
}
}
}
LAB_000110E8:
for (; (*pbVar7 & 0x40) == 0; pbVar7 = pbVar7 + 2) {
}
local_52 = param->wordCharCount;
LAB_00011114:
local_52 = local_52 + -1;
local_53 = 1;
pbVar7 = pbVar7 + 2;
if ((*pbVar7 & 0x80) != 0) {
goto LAB_00011124;
}
goto LAB_00010D44;
}
}
LAB_00011124:
local_34 = local_3C;
if (local_54 != 0) {
Zi8_814834AC(param, &local_50, &local_54, &local_57, ZI_WORK);
uVar6 = local_34;
if ((*options != 0) &&
(local_3C = local_3C + local_54, uVar6 = local_3C,
*(ziS32*)(options + 0xC) <= (ziS32)local_3C)) {
uVar6 = *(ziU32*)(options + 0xC);
goto LAB_000114C4;
}
local_34 = uVar6;
param->count = local_54;
param->letters = local_54;
}
if (param->elementCount < 10) {
if ((param->elementCount == 0) || (*options != 0)) {
local_56 = 1;
} else {
local_56 = 0;
}
local_4A = Zi8GetTableCount(ZI8_LANG_KO, 9, ZI_WORK);
Zi8_81483118(param, local_28.bytes);
do {
for (local_30 = 0; local_30 < (ziS32)(ziU32)local_4A; local_30 = local_30 + 1) {
bVar1 = ZI8_TRUE;
local_44 = iVar4 + local_30 * 9;
local_55 = 0;
if (1 < param->elementCount) {
for (local_55 = 0;
(ziU32)local_55 < (ziU32)((ziS32)(ziU32)param->elementCount >> 1);
local_55 = local_55 + 1) {
if (local_28.bytes[local_55] != *(ziU8*)(local_44 + local_55)) {
bVar1 = ZI8_FALSE;
break;
}
}
}
if ((bVar1 && ((param->elementCount & 1) != 0)) &&
((local_28.bytes[local_55] & 0xF0) !=
(*(ziU8*)(local_44 + local_55) & 0xF0))) {
bVar1 = ZI8_FALSE;
}
if (bVar1) {
bVar2 = local_56;
if ((param->elementCount & 1) == 0) {
if ((*(ziU8*)(local_44 + local_55) & 0xF0) == 0) {
if (local_56 == 0) {
goto LAB_000113B0;
}
bVar2 = *options;
}
if (bVar2 == 0) {
goto LAB_00011478;
}
} else {
if ((*(ziU8*)(local_44 + local_55) & 0xF) != 0) {
goto LAB_000113AC;
}
if (local_56 != 0) {
bVar2 = *options;
goto LAB_000113AC;
}
}
LAB_000113AC:
if (bVar2 == 0) {
goto LAB_00011478;
}
LAB_000113B0:
if (local_50 == 0) {
if (*options == 0) {
param->candidates[local_54] =
(ziU16)((*(ziU8*)(local_30 * 9 + iVar4 + 7) << 8) |
*(ziU8*)(local_30 * 9 + iVar4 + 8));
local_54 = local_54 + 1;
bVar2 = param->letters + 1;
param->letters = bVar2;
if (param->maxCandidates <= bVar2) {
uVar6 = param->letters;
goto LAB_000114C4;
}
} else {
local_34 = local_34 + 1;
if (*(ziS32*)(options + 0xC) <= (ziS32)local_34) {
uVar6 = *(ziU32*)(options + 0xC);
goto LAB_000114C4;
}
}
} else {
local_50 = local_50 + -1;
}
}
LAB_00011478:
;
}
local_56 = local_56 + 1;
} while (local_56 < 2);
uVar6 = local_34;
if (*options == 0) {
uVar6 = param->letters;
}
} else {
param->letters = 0;
uVar6 = 0;
}
}
LAB_000114C4:
return uVar6;
}

View File

@@ -11,9 +11,7 @@ static char CDB_ATTR_MAGIC[] = "CDBFILE";
static const u32 CDB_ATTR_VERSION = 0x02000000;
static const u32 CDB_ATTR_VERSION_PADDING = 0;
static u32 s_seed = 0;
u32 CDBAttrGetDescOffset(CDBAttr* attr) {
static u32 CDBAttrGetDescOffset(CDBAttr* attr) {
return attr->buf.version == 1 ? 0x0D : offsetof(CDBAttrBuf, descLength);
}
@@ -171,28 +169,18 @@ void CDBAttrGetKeyStr(CDBAttr* attr, char* keyString) {
memcpy(keyString, attr->buf.keyString, CDB_ATTR_BUF_KEY_STRING_LEN);
}
u32 CDBAttrSetIV(CDBAttr* attr, u32 seed);
void CDBAttrInitIV(CDBAttr* attr) {
int i, j;
u32 seed;
static u32 s_seed = 0;
int i;
if (s_seed == 0) {
s_seed = OSGetTick();
}
s_seed = CDBAttrSetIV(attr, s_seed);
}
u32 CDBAttrSetIV(CDBAttr* attr, u32 seed) {
int i, j;
for (i = 0; i < 2; i++) {
for (j = 0; j < 8; j++) {
seed = 1566083941 * seed + 2531011;
attr->buf.iv[(i * 8) + j] = (s8)(seed >> 16);
}
for (i = 0; i < CDB_ATTR_BUF_KEY_IV_LEN; i++) {
s_seed = 1566083941 * s_seed + 2531011;
attr->buf.iv[i] = (s8)(s_seed >> 16);
}
return seed;
}
void CDBAttrGetIV(CDBAttr* attr, u8* iv) {

View File

@@ -62,7 +62,7 @@ extern void _restgpr_25();
extern void _restgpr_26();
extern int atoi();
#pragma section sdata_type ".sdata"
extern u32 lbl_81698D8C;
extern u32 CDBDatabaseWorkBuf;
extern char lbl_8166B528[];
extern char lbl_8166B550[];
extern char lbl_8166B57C[];
@@ -834,7 +834,7 @@ asm CDBErr CDBDatabaseSearchRecordLayer() {
stw r0, 0x124(r1)
addi r11, r1, 0x120
bl _savegpr_14
lwz r11, lbl_81698D8C(r0)
lwz r11, CDBDatabaseWorkBuf(r0)
mr r20, r5
mr r22, r7
mr r24, r9
@@ -855,7 +855,7 @@ asm CDBErr CDBDatabaseSearchRecordLayer() {
bl CDBConvDirStrToCDBDate
lwz r0, 0x18(r19)
mr r31, r3
lwz r25, lbl_81698D8C(r0)
lwz r25, CDBDatabaseWorkBuf(r0)
addi r26, r3, 0x3b
cmpwi r0, 0x0
addi r0, r25, 0x994
@@ -1327,7 +1327,7 @@ asm CDBErr CDBDatabaseSearchMinuteLayer() {
stw r0, 0x174(r1)
addi r11, r1, 0x170
bl _savegpr_17
lwz r10, lbl_81698D8C(r0)
lwz r10, CDBDatabaseWorkBuf(r0)
mr r21, r5
mr r19, r3
mr r20, r4
@@ -1589,7 +1589,7 @@ asm CDBErr CDBDatabaseSearchHourLayer() {
stw r0, 0xb4(r1)
addi r11, r1, 0xb0
bl _savegpr_18
lwz r9, lbl_81698D8C(r0)
lwz r9, CDBDatabaseWorkBuf(r0)
mr r22, r5
mr r20, r3
mr r21, r4
@@ -1846,7 +1846,7 @@ asm CDBErr CDBDatabaseSearchDayLayer() {
stw r0, 0x104(r1)
addi r11, r1, 0x100
bl _savegpr_17
lwz r8, lbl_81698D8C(r0)
lwz r8, CDBDatabaseWorkBuf(r0)
mr r19, r5
mr r17, r3
mr r18, r4
@@ -2128,7 +2128,7 @@ asm CDBErr CDBDatabaseSearchMonthLayer() {
stw r0, 0xb4(r1)
addi r11, r1, 0xb0
bl _savegpr_19
lwz r7, lbl_81698D8C(r0)
lwz r7, CDBDatabaseWorkBuf(r0)
mr r23, r5
mr r21, r3
mr r22, r4
@@ -2398,7 +2398,7 @@ asm CDBErr CDBDatabaseSearchYearLayer() {
stw r0, 0x94(r1)
addi r11, r1, 0x90
bl _savegpr_22
lwz r6, lbl_81698D8C(r0)
lwz r6, CDBDatabaseWorkBuf(r0)
and. r0, r3, r4
mr r24, r3
mr r25, r4
@@ -2832,7 +2832,7 @@ asm CDBErr CDBDatabaseCleanUpEmptyDirectoriesRecord() {
stw r0, 0x134(r1)
addi r11, r1, 0x130
bl _savegpr_25
lwz r11, lbl_81698D8C(r0)
lwz r11, CDBDatabaseWorkBuf(r0)
mr r25, r4
lwz r29, 0x138(r1)
mr r26, r5
@@ -2912,7 +2912,7 @@ asm CDBErr CDBDatabaseCleanUpEmptyDirectoriesType() {
addi r11, r1, 0x140
bl _savegpr_22
li r0, 0x0
lwz r11, lbl_81698D8C(r0)
lwz r11, CDBDatabaseWorkBuf(r0)
stw r0, 0x10(r1)
mr r22, r3
lwz r30, 0x148(r1)
@@ -3010,7 +3010,7 @@ asm CDBErr CDBDatabaseCleanUpEmptyDirectoriesCode() {
stw r0, 0x144(r1)
addi r11, r1, 0x140
bl _savegpr_23
lwz r11, lbl_81698D8C(r0)
lwz r11, CDBDatabaseWorkBuf(r0)
li r0, 0x0
mr r23, r3
mr r24, r4
@@ -3105,7 +3105,7 @@ asm CDBErr CDBDatabaseCleanUpEmptyDirectoriesMinute() {
stw r0, 0x134(r1)
addi r11, r1, 0x130
bl _savegpr_24
lwz r10, lbl_81698D8C(r0)
lwz r10, CDBDatabaseWorkBuf(r0)
li r0, 0x0
mr r24, r3
mr r25, r4
@@ -3197,7 +3197,7 @@ asm CDBErr CDBDatabaseCleanUpEmptyDirectoriesHour() {
stw r0, 0x134(r1)
addi r11, r1, 0x130
bl _savegpr_25
lwz r9, lbl_81698D8C(r0)
lwz r9, CDBDatabaseWorkBuf(r0)
li r0, 0x0
mr r25, r3
mr r26, r4
@@ -3286,7 +3286,7 @@ asm CDBErr CDBDatabaseCleanUpEmptyDirectoriesDay() {
stw r0, 0x134(r1)
addi r11, r1, 0x130
bl _savegpr_26
lwz r8, lbl_81698D8C(r0)
lwz r8, CDBDatabaseWorkBuf(r0)
li r0, 0x0
mr r26, r3
mr r27, r4
@@ -3382,7 +3382,7 @@ asm CDBErr CDBDatabaseCleanUpEmptyDirectoriesMonth() {
mr r28, r3
mr r4, r28
addi r3, r1, 0x10
lwz r7, lbl_81698D8C(r0)
lwz r7, CDBDatabaseWorkBuf(r0)
stw r0, 0x8(r1)
addi r31, r7, 0x3a78
bl CDBConvYearStrToFullPath
@@ -3460,7 +3460,7 @@ asm CDBErr CDBDatabaseCleanUpEmptyDirectories(CDBDatabase* database, CDBRecordLo
stw r30, 0x18(r1)
stw r29, 0x14(r1)
mr r29, r4
lwz r5, lbl_81698D8C(r0)
lwz r5, CDBDatabaseWorkBuf(r0)
addi r30, r5, 0x430c
bne L_8148A13C
li r3, 0x1

View File

@@ -9,19 +9,32 @@
#include <revolution/dvd.h>
#include <revolution/os.h>
typedef struct {
u32 used;
u8 padding[0xC00C];
u32 flags;
u32 unk;
} CDBDatabaseInstanceWork;
static OSMutex s_mutex;
static BOOL s_mutexInitialized = FALSE;
static BOOL s_fatalVFFlag = FALSE;
// This was likely a local originally, but oh well!
s32 CDBPrintDebugLevel = CDB_VERBOSE_LEVEL_NONE;
static u8 s_cdbWiiId[OSRoundUp32B(CDB_WIIID_DAT_SIZE)] ALIGN32;
static CDBDatabaseInstanceWork* s_databasePool;
static u8* s_recordPool;
u8* CDBDatabaseWorkBuf;
static VFErr s_lastVFError;
static s32 s_lastNANDError;
static u8 s_cdbWiiId[OSRoundUp32B(CDB_WIIID_DAT_SIZE)] ALIGN32;
static u8* s_recordPool;
extern void CDBDatabaseInstanceInit(void* instance, int flag, CDBDatabase* database);
extern BOOL CDBDatabaseInstanceIsUsed(void* instance);
extern void CDBRecordInstanceInit(void* instance, CDBRecord* record, int flag);
extern BOOL CDBRecordInstanceIsUsed(void* instance);
extern BOOL CDBRecordKeyCompare(CDBRecordKey* recordKey1, CDBRecordKey* recordKey2);
void MutexInitialized() {
s_mutexInitialized = TRUE;
@@ -35,6 +48,216 @@ void CDBUnlock() {
OSUnlockMutex(&s_mutex);
}
void CDBDatabaseInstancePoolInit(void* work) {
u32* workPointer = (u32*)work;
s_databasePool = (CDBDatabaseInstanceWork*)workPointer;
s_databasePool[0].used = 0;
s_databasePool[1].used = 0;
if (((u32)(workPointer + 0x7880) & 0x3f) != 0) {
CDBReportWarn("割り当てられた領域が64バイトアライメントされていません(%d)\n", (u64)((u32)(workPointer + 0x7880) & 0x3f));
}
CDBCryptBufSysInit((CDBCryptBuf*)(workPointer + 0x7880));
if (!s_mutexInitialized) {
OSInitMutex(&s_mutex);
}
CDBDatabaseWorkBuf = (u8*)workPointer + 0x19660;
}
void CDBRecordPoolInit(void* work) {
int i;
s_recordPool = (u8*)work + 0x18030;
for (i = 0; i < 5; i++) {
*(u32*)(s_recordPool + i * 0x470 + 0x18) = 0;
if (!s_mutexInitialized) {
OSInitMutex((OSMutex*)(s_recordPool + i * 0x470));
}
}
}
CDBErr CDBDatabaseAllocate(CDBDatabase* database, u32 flag) {
CDBDatabaseInstanceWork* databaseInstance;
CDBDatabaseInstanceWork* requestedInstance;
u32 writeFlag;
int i;
if (s_recordPool == NULL) {
OSPanic(__FILE__, 0x185, "(CDB) error : CDBInit() is not called\n");
}
OSLockMutex(&s_mutex);
requestedInstance = database->instance;
if (requestedInstance != NULL) {
for (i = 0, databaseInstance = s_databasePool; i < 2; i++, databaseInstance++) {
if (requestedInstance == databaseInstance) {
if (requestedInstance->flags == 0) {
CDBReportFatal("CDBDatabaseAllocate system error\n");
OSUnlockMutex(&s_mutex);
return CDB_ERROR_FATAL_ERROR;
}
CDBReportError("database descripter has opened already\n");
OSUnlockMutex(&s_mutex);
return 0x1c;
}
}
CDBReportError("database descripter is not initialized\n");
OSUnlockMutex(&s_mutex);
return 0x18;
}
writeFlag = flag & CDB_RECORD_ALLOC_WRITE;
for (i = 0, databaseInstance = s_databasePool; i < 2; i++, databaseInstance++) {
if (databaseInstance->used != 0) {
if ((databaseInstance->flags & CDB_RECORD_ALLOC_WRITE) != 0) {
CDBReportError("can't open the database as WRITE mode; another database discripter opened the database as WRITE mode\n");
OSUnlockMutex(&s_mutex);
return 0x19;
}
if (writeFlag != 0) {
CDBReportError("can't open the database as WRITE mode; other database discripter(s) opened the database as READ mode\n");
OSUnlockMutex(&s_mutex);
return 0x19;
}
}
}
for (i = 0; i < 2; i++) {
if (s_databasePool[i].used == 0) {
CDBDatabaseInstanceInit(s_databasePool + i, flag, database);
database->instance = s_databasePool + i;
OSUnlockMutex(&s_mutex);
return CDB_ERROR_OK;
}
}
CDBReportError("can't open databases any more\n");
OSUnlockMutex(&s_mutex);
return CDB_ERROR_CRYPT_ALLOC_FAIL;
}
CDBErr CDBDatabaseFree(CDBDatabase* database) {
int offset;
int i;
u32* databaseInstance = database->instance;
BOOL hasOpenRecord = FALSE;
if (databaseInstance == NULL) {
return 0x1b;
}
OSLockMutex(&s_mutex);
for (i = 0, offset = 0; i < 5; i++, offset += 0x470) {
if (CDBRecordInstanceIsUsed(s_recordPool + offset) &&
*(CDBDatabase**)(s_recordPool + offset + 0x468) == database) {
CDBReportError("can't close database; record %s is opened\n", s_recordPool + offset + 0x438);
hasOpenRecord = TRUE;
}
}
if (hasOpenRecord) {
OSUnlockMutex(&s_mutex);
return 0x21;
}
databaseInstance[0] = 0;
database->instance = NULL;
OSUnlockMutex(&s_mutex);
return CDB_ERROR_OK;
}
CDBErr CDBDatabaseCheckOpenDatabase() {
int i;
BOOL hasOpenDatabase = FALSE;
OSLockMutex(&s_mutex);
for (i = 0; i < 2; i++) {
if (CDBDatabaseInstanceIsUsed(s_databasePool + i)) {
CDBReportError("database is opened\n");
hasOpenDatabase = TRUE;
}
}
OSUnlockMutex(&s_mutex);
if (hasOpenDatabase) {
return 0x22;
}
return CDB_ERROR_OK;
}
CDBErr CDBDatabaseCheckOpenRecord() {
int offset;
int i;
BOOL hasOpenRecord = FALSE;
OSLockMutex(&s_mutex);
for (i = 0, offset = 0; i < 5; i++, offset += 0x470) {
if (CDBRecordInstanceIsUsed(s_recordPool + offset)) {
CDBReportError("record %s is opened\n", s_recordPool + offset + 0x438);
hasOpenRecord = TRUE;
}
}
OSUnlockMutex(&s_mutex);
if (hasOpenRecord) {
return 0x21;
}
return CDB_ERROR_OK;
}
char s_recordOnSDMessage[] = "record %s on SD is opened\n";
CDBErr CDBRecordAllocate(CDBRecord* record, int flag) {
int writeFlag;
int offset;
int i;
CDBDatabaseInstanceWork* databaseInstance = ((CDBDatabase*)*(CDBDatabase**)record)->instance;
OSLockMutex(&s_mutex);
if (databaseInstance == NULL) {
CDBReportError("can't open the record; database is closed\n");
OSUnlockMutex(&s_mutex);
return 0x1b;
}
if ((databaseInstance->flags & CDB_RECORD_ALLOC_WRITE) == 0 && (flag & CDB_RECORD_ALLOC_WRITE) != 0) {
CDBReportError("can't open the record as WRITE mode; database is readonly mode\n");
OSUnlockMutex(&s_mutex);
return 0x1a;
}
writeFlag = flag & CDB_RECORD_ALLOC_WRITE;
for (i = 0, offset = 0; i < 5; i++, offset += 0x470) {
if (CDBRecordInstanceIsUsed(s_recordPool + offset) &&
CDBRecordKeyCompare(&record->key, (CDBRecordKey*)(s_recordPool + offset + 0x438)) == FALSE &&
*(s32*)((u8*)record + 0x30) == *(s32*)(s_recordPool + offset + 0x460)) {
if ((*(u32*)(s_recordPool + offset + 0x1c) & CDB_RECORD_ALLOC_WRITE) != 0) {
CDBReportError("can't open the record as WRITE mode; another record discripter opened the record as WRITE mode\n");
OSUnlockMutex(&s_mutex);
return 0x19;
}
if (writeFlag != 0) {
CDBReportError("can't open the record as WRITE mode; other record discripter(s) opened the record as READ mode \n");
OSUnlockMutex(&s_mutex);
return 0x19;
}
}
}
for (i = 0; i < 5; i++) {
if (!CDBRecordInstanceIsUsed(s_recordPool + i * 0x470)) {
offset = i * 0x470;
CDBRecordInstanceInit(s_recordPool + offset, record, flag);
record->file = s_recordPool + offset;
OSUnlockMutex(&s_mutex);
return CDB_ERROR_OK;
}
}
CDBReportError("can't open record any more\n");
OSUnlockMutex(&s_mutex);
return CDB_ERROR_CRYPT_ALLOC_FAIL;
}
CDBErr CDBRecordFree(CDBRecord* record) {
CDBRecordFile* recordFile = record->file;
@@ -73,18 +296,6 @@ void CDBSetFatalVFErrorFlag() {
s_fatalVFFlag = TRUE;
}
void CDBRecordPoolInit(void* work) {
int i;
s_recordPool = (u8*)work + 0x18030;
for (i = 0; i < 5; i++) {
*(u32*)(s_recordPool + i * 0x470 + 0x18) = 0;
if (!s_mutexInitialized) {
OSInitMutex((OSMutex*)(s_recordPool + i * 0x470));
}
}
}
void CDBTryToCreate_wiiiddat(u8* data) {
NANDFileInfo fileInfo;
u32 nandCheck;
@@ -92,7 +303,7 @@ void CDBTryToCreate_wiiiddat(u8* data) {
// Requires 1 NAND block and 1 NAND node
s32 ret = NANDCheck(1, 1, &nandCheck);
if (ret != NAND_RESULT_OK) {
CDBReportError("failed NANDCheck\n");
CDBReportFatal("failed NANDCheck\n");
return;
}
@@ -327,6 +538,29 @@ void CDBCheckMakerCodeStr(char* makerCodeStr) {
}
}
BOOL CDBRecordBelongedDBOpenedAsRW(CDBRecord* record) {
int i;
CDBDatabaseInstanceWork* databaseInstance = NULL;
CDBDatabaseInstanceWork* databasePool;
if (record == NULL) {
return FALSE;
}
databasePool = s_databasePool;
for (i = 0; i < 2; i++) {
if (databasePool[i].used != 0 && (databasePool[i].flags & CDB_RECORD_ALLOC_WRITE) != 0) {
databaseInstance = databasePool + i;
break;
}
}
if (databaseInstance == NULL) {
return FALSE;
}
return TRUE;
}
static int s_vfSync = 1;
CDBErr CDBSetVFSyncMode(int sync) {

View File

@@ -9,8 +9,8 @@
#define NCD_IPC_HEAP_SIZE 0x1B60
#define NCD_MAX_PROFILE 3
static u32 ncdInitialized;
static NCDConfig* ncdCommonBuffer;
static u32 ncdInitialized;
struct NCDMutex {
OSMutex mutex;
@@ -24,7 +24,7 @@ const char* __NCDUnofficialVersion = "<< RVL_SDK - NCD \trelease build: Dec 12 2
static void LockRight(void);
static NCDErr ExecConfigCommand(const char* name, NCDConfig* config, u32 command);
static NCDErr NCDiGetWirelessMacAddress(u8* macAddr);
NCDErr NCDiGetWirelessMacAddress(u8* macAddr);
NCDErr NCDReadConfig(NCDConfig* config) {
if (config == NULL) {
@@ -323,7 +323,7 @@ NCDErr NCDGetWirelessMacAddress(u8* macAddr) {
return NCDiGetWirelessMacAddress(macAddr);
}
static NCDErr NCDiGetWirelessMacAddress(u8* macAddr) {
NCDErr NCDiGetWirelessMacAddress(u8* macAddr) {
NCDErr err = 0;
s32 fd;

View File

@@ -53,8 +53,8 @@ static struct {
VFi_NANDDelete delete; // 0x0C
} l_nandFunc[PF_DRIVE_COUNT];
int VF_nand_retry_max;
int VF_nand_sleep_msec;
int VF_nand_retry_max;
#ifdef DEBUG
#define VFi_NANDPrint(...) printf(__VA_ARGS__)
@@ -130,7 +130,7 @@ s32 VFi_NandPrivateOpen(const char* path, NANDFileInfo* info, u8 accType) {
VFi_NANDFunction(NANDPrivateOpen(path, info, accType));
}
s32 VFi_NandWrite(NANDFileInfo* info, void* buf, u32 length) {
inline s32 VFi_NandWrite(NANDFileInfo* info, void* buf, u32 length) {
VFi_NANDFunction(NANDWrite(info, buf, length));
}
@@ -146,7 +146,7 @@ s32 VFi_NandPrivateCreateDir(const char* path, u8 perm, u8 attr) {
VFi_NANDFunction(NANDPrivateCreateDir(path, perm, attr));
}
s32 VFi_NandSeek(NANDFileInfo* info, s32 offset, s32 whence) {
inline s32 VFi_NandSeek(NANDFileInfo* info, s32 offset, s32 whence) {
VFi_NANDFunction(NANDSeek(info, offset, whence));
}
@@ -177,12 +177,12 @@ static u8 _MakePermitForRVL(u8 i_perm) {
return perm;
}
s32 VFi_NandCreateSp(const char* path, u8 i_perm, u8 attr, u32 i_handleIdx) {
inline s32 VFi_NandCreateSp(const char* path, u8 i_perm, u8 attr, u32 i_handleIdx) {
u8 perm = _MakePermitForRVL(i_perm);
if (i_handleIdx < PF_DRIVE_COUNT) {
VFi_NANDCreate tmpCreate;
tmpCreate = l_nandFunc[i_handleIdx].create;
if (tmpCreate != NULL) {
if (tmpCreate) {
return tmpCreate(path, perm, attr);
}
return VFi_NandCreate(path, perm, attr);
@@ -197,7 +197,7 @@ s32 VFi_NandOpenSp(const char* path, void* info, u8 accType, u32 i_handleIdx) {
NANDFileInfo* info_p = info;
if (i_handleIdx < PF_DRIVE_COUNT) {
VFi_NANDOpen tmpOpen = l_nandFunc[i_handleIdx].open;
if (tmpOpen != NULL) {
if (tmpOpen) {
return tmpOpen(path, info_p, accType);
}
return VFi_NandOpen(path, info_p, accType);
@@ -208,10 +208,10 @@ s32 VFi_NandOpenSp(const char* path, void* info, u8 accType, u32 i_handleIdx) {
return VFi_NandPrivateOpen(path, info_p, accType);
}
s32 VFi_NandDeleteSp(const char* path, u32 i_handleIdx) {
inline s32 VFi_NandDeleteSp(const char* path, u32 i_handleIdx) {
if (i_handleIdx < PF_DRIVE_COUNT) {
VFi_NANDDelete tmpDelete = l_nandFunc[i_handleIdx].delete;
if (tmpDelete != NULL) {
if (tmpDelete) {
return tmpDelete(path);
}
return VFi_NandDelete(path);

View File

@@ -34,7 +34,9 @@ static MEMAllocator sAllocator;
static MEMAllocator* spAllocator = &sAllocator;
void* HBMAllocMem(u32 size) {
return MEMAllocFromAllocator(spAllocator, size);
void* addr = MEMAllocFromAllocator(spAllocator, size);
return addr;
}
void HBMFreeMem(void* pBlock) {
@@ -124,17 +126,6 @@ BOOL HBMIsReassignedControllers() {
/* THE LOGIC */
extern const f32 lbl_816946D8;
extern const f32 lbl_81694748;
extern const f32 lbl_81694744;
extern const f32 lbl_816946DC;
extern const f32 lbl_81694754;
extern volatile const f32 lbl_8169474C;
extern volatile const f32 lbl_81694750;
extern const f32 lbl_81694714;
extern const f32 lbl_81694710;
namespace homebutton {
static void SimpleSyncCallback(s32 result, s32 num);
@@ -156,16 +147,6 @@ namespace homebutton {
HomeButton* HomeButton::spHomeButtonObj = NULL;
const int HomeButton::scReConnectTime = 3600;
const int HomeButton::scReConnectTime2 = 3570;
const int HomeButton::scPadDrawWaitTime = 5;
const int HomeButton::scGetPadInfoTime = 100;
const int HomeButton::scForcusSEWaitTime = 2;
const f32 HomeButton::scOnPaneVibTime = 3.0f;
const f32 HomeButton::scOnPaneVibWaitTime = 9.0f;
const int HomeButton::scWaitStopMotorTime = 30;
const int HomeButton::scWaitDisConnectTime = 180;
const char* HomeButton::scCursorLytName[res::eCursorLyt_Max] = {
"P1_Def.brlyt",
"P2_Def.brlyt",
@@ -616,8 +597,8 @@ namespace homebutton {
mpController[i]->initCallback();
mpController[i]->initSound();
mOnPaneVibFrame[i] = ::lbl_816946D8;
mOnPaneVibWaitFrame[i] = ::lbl_816946D8;
mOnPaneVibFrame[i] = 0.0f;
mOnPaneVibWaitFrame[i] = 0.0f;
}
}
@@ -638,7 +619,7 @@ namespace homebutton {
if (mpSoundArchivePlayer != NULL) {
for (i = 0; i < mpSoundArchivePlayer->GetSoundPlayerCount(); i++) {
mpSoundArchivePlayer->GetSoundPlayer(i).SetVolume(::lbl_816946DC);
mpSoundArchivePlayer->GetSoundPlayer(i).SetVolume(1.0f);
}
}
@@ -798,7 +779,7 @@ namespace homebutton {
if (mOnPaneVibFrame[i] <= 0.0f || mState == 17) {
getController(i)->stopMotor();
mOnPaneVibFrame[i] = 0.0f;
mOnPaneVibWaitFrame[i] = scOnPaneVibWaitTime;
mOnPaneVibWaitFrame[i] = 9.0f;
}
}
} else if (mOnPaneVibWaitFrame[i] > 0.0f) {
@@ -1271,20 +1252,6 @@ namespace homebutton {
}
}
void HomeButton::calc_letter() {
if (mLetterFlag && !mpPairGroupAnmController[res::ePairAnm_ltrIcn_on]->isPlaying()) {
mpLayout->GetRootPane()->FindPaneByName(scFuncPaneName[res::eFuncPane_let_icn_00], true)->SetVisible(true);
mpPairGroupAnmController[res::ePairAnm_ltrIcn_on]->setAnmType(ANIM_TYPE_LOOP);
mpPairGroupAnmController[res::ePairAnm_ltrIcn_on]->play();
} else if (!mLetterFlag) {
mpLayout->GetRootPane()->FindPaneByName(scFuncPaneName[res::eFuncPane_let_icn_00], true)->SetVisible(false);
mpPairGroupAnmController[res::ePairAnm_ltrIcn_on]->stop();
}
}
void HomeButton::calc_battery(int chan) {
for (int i = 0; i < res::eBatteryPane_Max; i++) {
if (i < mWpadInfo[chan].battery) {
@@ -1311,6 +1278,20 @@ namespace homebutton {
getController(chan)->clrBatteryFlag();
}
void HomeButton::calc_letter() {
if (mLetterFlag && !mpPairGroupAnmController[res::ePairAnm_ltrIcn_on]->isPlaying()) {
mpLayout->GetRootPane()->FindPaneByName(scFuncPaneName[res::eFuncPane_let_icn_00], true)->SetVisible(true);
mpPairGroupAnmController[res::ePairAnm_ltrIcn_on]->setAnmType(ANIM_TYPE_LOOP);
mpPairGroupAnmController[res::ePairAnm_ltrIcn_on]->play();
} else if (!mLetterFlag) {
mpLayout->GetRootPane()->FindPaneByName(scFuncPaneName[res::eFuncPane_let_icn_00], true)->SetVisible(false);
mpPairGroupAnmController[res::ePairAnm_ltrIcn_on]->stop();
}
}
void HomeButton::draw() {
mpLayout->Draw(mDrawInfo);
@@ -1475,13 +1456,12 @@ namespace homebutton {
nw4r::math::VEC3 vec;
if (pController->wiiCon[i].use_devtype == WPAD_DEV_CLASSIC && pController->wiiCon[i].kpad->dev_type == WPAD_DEV_CLASSIC) {
vec = nw4r::math::VEC3(lbl_816946D8, lbl_816946D8,
*((volatile const f32*)&lbl_81694710));
vec = nw4r::math::VEC3(0.0f, 0.0f, 15.0f);
} else {
Vec2 v = pController->wiiCon[i].kpad->horizon;
f32 rad = nw4r::math::Atan2FIdx(-v.y, v.x) * lbl_81694714;
f32 rad = nw4r::math::Atan2FIdx(-v.y, v.x) * 1.40625f;
vec = nw4r::math::VEC3(lbl_816946D8, lbl_816946D8, rad);
vec = nw4r::math::VEC3(0.0f, 0.0f, rad);
}
if (!mpHBInfo->cursor) {
@@ -1933,8 +1913,8 @@ namespace homebutton {
}
if (onFlag && pController != NULL) {
if (!getController(pController->chan)->isRumbling() && mOnPaneVibWaitFrame[pController->chan] <= ::lbl_816946D8) {
mOnPaneVibFrame[pController->chan] = ::lbl_81694744;
if (!getController(pController->chan)->isRumbling() && mOnPaneVibWaitFrame[pController->chan] <= 0.0f) {
mOnPaneVibFrame[pController->chan] = 3.0f;
getController(pController->chan)->startMotor();
}
}
@@ -2388,10 +2368,10 @@ namespace homebutton {
void HomeButton::reset_guiManager(int num) {
if (num < 0) {
for (int i = 0; i < 8; i++) {
mpPaneManager->update(i, ::lbl_81694748, ::lbl_81694748, 0, 0, 0, NULL);
mpPaneManager->update(i, -10000.0f, -10000.0f, 0, 0, 0, NULL);
}
} else {
mpPaneManager->update(num, ::lbl_81694748, ::lbl_81694748, 0, 0, 0, NULL);
mpPaneManager->update(num, -10000.0f, -10000.0f, 0, 0, 0, NULL);
}
}
@@ -2500,7 +2480,7 @@ namespace homebutton {
}
}
} else {
scale = nw4r::math::VEC2(::lbl_816946DC, ::lbl_816946DC);
scale = nw4r::math::VEC2(1.0f, 1.0f);
mpLayout->GetRootPane()->SetScale(scale);
if (!mpHBInfo->cursor) {
@@ -2645,14 +2625,9 @@ namespace homebutton {
initgx();
GXColor clr = {red_, green_, blue_, alpha};
drawBlackPlate(::lbl_8169474C, ::lbl_8169474C, ::lbl_81694750, ::lbl_81694750, clr);
drawBlackPlate(-1000.0f, -1000.0f, 1000.0f, 1000.0f, clr);
}
const int HomeButton::scSoundHeapSize_but2 = 0x60000;
const int HomeButton::scSoundHeapSize_but3 = 0x6f800;
const int HomeButton::scSoundThreadPrio = 4;
const int HomeButton::scDvdThreadPrio = 3;
void HomeButton::update_sound() {
if (mpSoundArchivePlayer != NULL) {
mpSoundArchivePlayer->Update();
@@ -2684,7 +2659,7 @@ namespace homebutton {
}
if (mEndInitSoundFlag) {
AXSetAuxAReturnVolume(lbl_81694754 * gain);
AXSetAuxAReturnVolume(32768.0f * gain);
}
if (mpSoundArchivePlayer != NULL) {

View File

@@ -1,4 +1,6 @@
#define TI_PREDICTLANG_SAMPLE_CLASS
#include "keyboard/tiPredictLang.h"
#undef TI_PREDICTLANG_SAMPLE_CLASS
#include "keyboard/tiLanguageIndependentData.h"
#include "keyboard/tiManager.h"

View File

@@ -1,4 +1,6 @@
#define TI_TOOLBAR_SAMPLE_CLASS
#include "keyboard/tiToolBar.h"
#undef TI_TOOLBAR_SAMPLE_CLASS
#include "keyboard/tiHKBManager.h"
#include "keyboard/tiLanguageIndependentData.h"
@@ -182,7 +184,7 @@ namespace textinput {
}
break;
}
case ANM_07:
case ANM_08:
case ANM_11: {
pane->changeAnimation(ANM_09);
break;

View File

@@ -197,55 +197,53 @@ namespace ipl {
mpLayoutBg->calc();
mpLayoutFocusBg->calc();
if (mState != STATE_TO_SETTINGS && mState != STATE_TERMINATE) {
if (mState == STATE_DONE) {
return;
if (mState == STATE_TO_SETTINGS || mState == STATE_TERMINATE || mState == STATE_DONE) {
return;
}
calc_board_object();
Button* button = get_button();
if (mbNewMsgAnimCount && button != NULL) {
/* Message count on button icon */
wchar_t numStr[3] = L"";
int index = 0;
int mailCount;
if (mMsgCount >= 0) {
mailCount = 99;
if (mMsgCount <= 99) {
mailCount = mMsgCount;
}
} else {
mailCount = 0;
}
calc_board_object();
if (mailCount >= 10) {
index = 1;
numStr[0] = scNumber[(mailCount / 10) % 10];
}
numStr[index++] = scNumber[mailCount % 10];
Button* button = get_button();
button->setText("T_BbsMark1", numStr);
if (mbNewMsgAnimCount && button != NULL) {
/* Message count on button icon */
// New mail animation
int index = 0;
wchar_t numStr[3] = L"";
int mailCount;
if (mMsgCount >= 0) {
mailCount = 99;
if (mMsgCount <= 99) {
mailCount = mMsgCount;
}
} else {
mailCount = 0;
}
if (mailCount >= 10) {
index = 1;
numStr[0] = scNumber[(mailCount / 10) % 10];
}
numStr[index++] = scNumber[mailCount % 10];
button->setText("T_BbsMark1", numStr);
// New mail animation
if (mailCount != 0) {
button->startMailNumAnm();
} else {
button->stopMailNumAnm();
}
mbNewMsgAnimCount = false;
if (mailCount != 0) {
button->startMailNumAnm();
} else {
button->stopMailNumAnm();
}
// Do SD process
if (System::getCdbManager() != NULL && mState != STATE_WAIT_INIT) {
mBoardSD.update();
}
mbNewMsgAnimCount = false;
}
// Do SD process
if (System::getCdbManager() != NULL && mState != STATE_WAIT_INIT) {
mBoardSD.update();
}
}
}
@@ -907,14 +905,16 @@ namespace ipl {
if (mState == STATE_NORMAL) {
for (int i = 0; i < WPAD_MAX_CONTROLLERS; i++) {
BoardObject* object = NULL;
FOREACH_OBJ_IN_LIST(object) {
BoardObject* nextObject = NULL;
while ((nextObject = mObjList.getNext(object)) != NULL) {
object = nextObject;
if ((mHoveredObjs[i] == NULL || mHoveredObjs[i] == object) && mState == STATE_NORMAL) {
object->update(i);
}
}
if (System::getController(i) == NULL && mHoveredObjs[i] != NULL) {
object->start_left_event(i);
mHoveredObjs[i]->start_left_event(i);
mHoveredObjs[i] = NULL;
}
}
@@ -1134,9 +1134,11 @@ namespace ipl {
bool result = mbDoReadTask == false;
BoardObject* object = NULL;
FOREACH_OBJ_IN_LIST(object) {
result = (result & (!object->mbRightWay && !object->mbLeftWay && !object->mMoveAnim.isPlaying() && object->mpLayout != NULL &&
!object->mpLayout->getAnim(BoardObject::ANIM_NEXT_PAGE)->isPlaying())) != false &&
object->mbModifiedPos == false;
bool stillMoving = (result & (!object->mbRightWay && !object->mbLeftWay && !object->mMoveAnim.isPlaying() &&
object->mpLayout != NULL &&
!object->mpLayout->getAnim(BoardObject::ANIM_NEXT_PAGE)->isPlaying())) != false;
bool modifiedPos = object->mbModifiedPos;
result = stillMoving & (modifiedPos == false);
}
if (result) {
@@ -1565,31 +1567,30 @@ namespace ipl {
void Board::edge_arrow() {
Button* button = get_button();
if (System::getScene(SCENE_CHANNEL_SELECT) == NULL && System::getReservedScene() == NULL) {
if (mState == STATE_WAIT_CHILD_CST) {
} else {
enable_licon();
enable_ricon();
if (System::getScene(SCENE_CHANNEL_SELECT) != NULL || System::getReservedScene() != NULL || mState == STATE_WAIT_CHILD_CST) {
return;
}
if (mCurrentDate == utility::Date::getMaxDate()) {
if (button->isArrowVisible(Button::ARROW_BTN_RIGHT) && mbRIconEnable != true) {
button->animation(Button::IDANIM_ARROW_RIGHT_DISAPPEAR);
}
if (!button->isArrowVisible(Button::ARROW_BTN_LEFT)) {
button->animation(Button::IDANIM_ARROW_LEFT_APPEAR);
}
} else {
if (mCurrentDate == utility::Date::getMinDate()) {
if (button->isArrowVisible(Button::ARROW_BTN_LEFT) && mbLIconEnable != true) {
button->animation(Button::IDANIM_ARROW_LEFT_DISAPPEAR);
}
if (!button->isArrowVisible(Button::ARROW_BTN_RIGHT)) {
button->animation(Button::IDANIM_ARROW_RIGHT_APPEAR);
}
} else {
appear_arrow();
}
enable_licon();
enable_ricon();
if (mCurrentDate == utility::Date::getMaxDate()) {
if (button->isArrowVisible(Button::ARROW_BTN_RIGHT) && mbRIconEnable != true) {
button->animation(Button::IDANIM_ARROW_RIGHT_DISAPPEAR);
}
if (!button->isArrowVisible(Button::ARROW_BTN_LEFT)) {
button->animation(Button::IDANIM_ARROW_LEFT_APPEAR);
}
} else {
if (mCurrentDate == utility::Date::getMinDate()) {
if (button->isArrowVisible(Button::ARROW_BTN_LEFT) && mbLIconEnable != true) {
button->animation(Button::IDANIM_ARROW_LEFT_DISAPPEAR);
}
if (!button->isArrowVisible(Button::ARROW_BTN_RIGHT)) {
button->animation(Button::IDANIM_ARROW_RIGHT_APPEAR);
}
} else {
appear_arrow();
}
}
}
@@ -1675,6 +1676,12 @@ namespace ipl {
return result;
}
static inline nw4r::math::VEC3 addTranslate(const nw4r::math::VEC3& a, const nw4r::math::VEC3& b) {
nw4r::math::VEC3 sum;
nw4r::math::VEC3Add(&sum, &a, &b);
return sum;
}
void Board::calc_board_object() {
nw4r::lyt::Pane* pane = mpLayoutBg->FindPaneByName("N_TopBack");
@@ -1682,8 +1689,7 @@ namespace ipl {
FOREACH_OBJ_IN_LIST(object) {
nw4r::lyt::Pane* posPane = mpLayoutBg->FindPaneByName(scScrollPane[get_date_label(object->mBoardDate)]);
math::VEC3 pos;
nw4r::math::VEC3Add(&pos, &pane->GetTranslate(), &posPane->GetTranslate());
math::VEC3 pos = addTranslate(pane->GetTranslate(), posPane->GetTranslate());
object->calc(math::VEC2(pos.x, pos.y));
}

View File

@@ -16,6 +16,48 @@
// #pragma sym on
namespace ipl {
namespace math {
static inline nw4r::math::VEC3 subHermitePoints(const VEC3& start, const VEC3& end) {
nw4r::math::VEC3 temp;
nw4r::math::VEC3Sub(&temp, &start, &end);
return temp;
}
template <>
VEC3 HermiteIntp<VEC3>::get() const {
f32 var_f27 = mFrame;
f32 var_f28 = 1.0f / mMaxFrame;
VEC3 r(subHermitePoints(
mStart * (1.0f + ((var_f28 * (var_f28 * (var_f28 * (var_f27 * (2.0f * var_f27 * var_f27))))) -
(var_f28 * (var_f28 * (3.0f * var_f27 * var_f27))))),
mEnd * ((var_f28 * (var_f28 * (var_f28 * (var_f27 * (2.0f * var_f27 * var_f27))))) -
(var_f28 * (var_f28 * (3.0f * var_f27 * var_f27))))));
f32 temp_f4 = var_f27 * var_f27;
f32 temp_f7 = var_f28 * (var_f28 * (var_f27 * temp_f4));
f32 temp_f3 = (unkVal0 * (var_f27 + (temp_f7 - (var_f28 * (2.0f * var_f27 * var_f27))))) +
(unkVal1 * (temp_f7 - (var_f28 * temp_f4)));
r.x += temp_f3;
r.y += temp_f3;
r.z += temp_f3;
return r;
}
template <>
f32 HermiteIntp<f32>::get() const {
f32 var_f27 = mFrame;
f32 var_f28 = 1.0f / mMaxFrame;
f32 r = (mStart * (1.0f + ((var_f28 * (var_f28 * (var_f28 * (var_f27 * (2.0f * var_f27 * var_f27))))) -
(var_f28 * (var_f28 * (3.0f * var_f27 * var_f27)))))) -
(mEnd * ((var_f28 * (var_f28 * (var_f28 * (var_f27 * (2.0f * var_f27 * var_f27))))) -
(var_f28 * (var_f28 * (3.0f * var_f27 * var_f27)))));
r += (unkVal0 * (var_f27 + ((var_f28 * (var_f28 * (var_f27 * (var_f27 * var_f27)))) - (var_f28 * (2.0f * var_f27 * var_f27))))) +
(unkVal1 * ((var_f28 * (var_f28 * (var_f27 * (var_f27 * var_f27)))) - (var_f28 * (var_f27 * var_f27))));
return r;
}
} // namespace math
} // namespace ipl
namespace ipl {
namespace scene {
extern "C" char smArg__Q23ipl6System;
@@ -368,20 +410,18 @@ namespace ipl {
#define FOREACH_CHANNEL_OBJ(chanObj) while (chanObj = (ChannelObj*)nw4r::ut::List_GetNext(&mChanList, chanObj), chanObj != NULL)
ChannelSelect::ChannelSelect(EGG::Heap* heap, int startup) : scene::FaderSceneBase(heap), mpDiskChanObj(NULL) {
mpButtonEvent = new CsChanSelButtonEventHandler(this);
mpSDMenuEvent = new CsChanSelSDMenuEventHandler(this);
mState = STATE_NONE;
mStartType = startup;
mChanThumbOff_X = cfChanThumbOfss[SCGetAspectRatio()][0];
mChanThumbOff_Y = cfChanThumbOfss[SCGetAspectRatio()][1];
mDiskState = DISK_STATE_READ;
mspDiskID = NULL;
mspDiskMaker = NULL;
ChannelSelect::ChannelSelect(EGG::Heap* heap, int startup)
: scene::FaderSceneBase(heap),
mpDiskChanObj(NULL),
mpButtonEvent(new CsChanSelButtonEventHandler(this)),
mpSDMenuEvent(new CsChanSelSDMenuEventHandler(this)),
mState(STATE_NONE),
mStartType(startup),
mChanThumbOff_X(cfChanThumbOfss[SCGetAspectRatio()][0]),
mChanThumbOff_Y(cfChanThumbOfss[SCGetAspectRatio()][1]),
mDiskState(DISK_STATE_READ),
mspDiskID(NULL),
mspDiskMaker(NULL) {
// mClock = clock();
@@ -2525,54 +2565,49 @@ calcNormalRestart_ChannelSelect_L7:
void ChannelSelect::setChannelScissor(const ChannelObj* channelObj) const {
nw4r::math::VEC3 vec(channelObj->getTranslate());
nw4r::ut::Rect projRect;
System::getProjectionRect(&projRect);
GXRenderModeObj* rMode = System::getRenderModeObj();
f32 var_f29;
f32 var_f30;
f32 var_f31;
f32 var_f1;
u16 var_r0;
u16 var_r3;
if (mState == STATE_NORMAL_FADE_ZOOM || mState == STATE_NORMAL_DONE_FADE_ZOOM || mState == STATE_NORMAL_RESTART) {
nw4r::math::MTX44 mtx;
f32 fVar1 = unk_0xE4.x;
f32 fVar2 = unk_0xE4.y;
f32 fVar3 = unk_0xD8.x;
f32 fVar4 = unk_0xD8.y;
MTXOrtho(mtx, fVar4 - projRect.top / fVar2, fVar4 - projRect.bottom / fVar2, fVar3 + projRect.left / fVar1,
fVar3 + projRect.right / fVar1, -100.0f, 100.0f);
nw4r::math::VEC4 vec4;
f32 rightScale = projRect.right / unk_0xE4.x;
f32 leftScale = projRect.left / unk_0xE4.x;
f32 topScale = projRect.top / unk_0xE4.y;
f32 bottomScale = projRect.bottom / unk_0xE4.y;
f32 bottom = unk_0xD8.y - bottomScale;
f32 right = unk_0xD8.x + rightScale;
f32 left = unk_0xD8.x + leftScale;
f32 top = unk_0xD8.y - topScale;
MTXOrtho(mtx, top, bottom, left, right, -100.0f, 100.0f);
nw4r::math::VEC4 vec4_in(vec.x, vec.y, 0.0f, 1.0f);
nw4r::math::VEC4 vec4;
nw4r::math::VEC4Transform(&vec4, &mtx, &vec4_in);
var_r0 = rMode->fbWidth;
var_r3 = rMode->efbHeight;
var_f29 = projRect.GetWidth();
var_f30 = (var_r3 - ((1.0f + vec4.y) * var_r3 / 2)) - (mChanThumbOff_Y * unk_0xE4.y);
f32 temp_f7_2 = var_r0 / var_f29;
var_f31 = ((1.0f + vec4.x) * var_r0 / 2) - ((mChanThumbOff_X * unk_0xE4.x) * (temp_f7_2));
var_f29 = 2.0f * (mChanThumbOff_X * unk_0xE4.x) * (var_r0 / var_f29);
var_f1 = 2.0f * (mChanThumbOff_Y * unk_0xE4.y);
var_f30 = (var_r3 - ((1.0f + vec4.y) * var_r3 / 2)) - (mChanThumbOff_Y * unk_0xE4.y);
var_f31 = ((1.0f + vec4.x) * var_r0 / 2) - ((mChanThumbOff_X * unk_0xE4.x) * (temp_f7_2));
} else {
var_r0 = rMode->fbWidth;
var_r3 = rMode->efbHeight;
var_f29 = 2.0f * mChanThumbOff_X * (var_r0 / projRect.GetWidth());
var_f30 = (((f32)var_r3 / 2) - vec.y) - mChanThumbOff_Y;
var_f31 = ((f32)var_r0 / 2) + ((vec.x - mChanThumbOff_X) * (var_r0 / projRect.GetWidth()));
var_f30 = (((f32)var_r3 / 2) - vec.y) - mChanThumbOff_Y;
var_f29 = 2.0f * mChanThumbOff_X * (var_r0 / projRect.GetWidth());
var_f1 = 2.0f * mChanThumbOff_Y;
}
var_f31 -= 1.0f;
var_f30 -= 1.0f;
var_f29 += 2.0f;
var_f1 += 2.0f;
if (var_f31 >= var_r0 || (var_f31 + var_f29) <= 0.0f || var_f30 >= var_r3 || (var_f30 + var_f1) <= 0.0f) {
GXSetScissor(0, 0, 0, 0);
} else {
@@ -2584,7 +2619,6 @@ calcNormalRestart_ChannelSelect_L7:
var_f1 += var_f30;
var_f30 = 0.0f;
}
if ((var_f31 + var_f29) > 1705.0f) {
var_f29 -= (var_f31 + var_f29) - 1705.0f;
}
@@ -2632,8 +2666,8 @@ calcNormalRestart_ChannelSelect_L7:
}
void ChannelSelect::setChanZoomOrtho() {
nw4r::math::VEC3 frames[4];
for (int i = 0; i < 4; i++) {
nw4r::math::VEC3 frames[3];
for (int i = 0; i < 3; i++) {
frames[i] = mpChanZoomParams[i]->get();
}
@@ -3174,14 +3208,17 @@ calcNormalMoveChanOut_ChannelSelect_L1:
mpMoveLytObject->GetRootPane()->SetTranslate(newPos);
mpMoveLytObject->calcMtx();
f32 speed = 0.0f;
f32 speed;
f32 newY = pos.y - mDragPos.y;
f32 newX = pos.x - mDragPos.x;
math::VEC2 delta;
delta.y = pos.y - mDragPos.y;
delta.x = pos.x - mDragPos.x;
f32 val = (newX * newX) + (newY * newY);
f32 val = (delta.x * delta.x) + (delta.y * delta.y);
if (val > 0.0f) {
if (val <= 0.0f) {
speed = 0.0f;
} else {
speed = (val * nw4r::math::FrSqrt(val));
}

View File

@@ -18,8 +18,6 @@ namespace ipl {
return caption;
}
extern "C" char lbl_81650380[0x19] = "my_IplTopBalloon_a.brlyt";
LetterWriter::LetterWriter(EGG::Heap* heap, int type)
: TextWriter(heap), mbToFriend(false), mLetterState(LETTER_STATE_NORMAL), mLetterType((textinput::extend::letter::InputForm::Type)type),
mpTextSubjectWork(NULL), mpCaptionString(NULL), mpCaptionAllocator(NULL), mNwc24ErrCountdown2(0) {
@@ -91,7 +89,7 @@ namespace ipl {
f32 f0 = 30.0f;
f32 f1 = 120.0f;
mpNigaoeBalloon =
new TextBalloon(getSceneHeap(), mpBalloonFile, "arc", lbl_81650380,
new TextBalloon(getSceneHeap(), mpBalloonFile, "arc", "my_IplTopBalloon_a.brlyt",
math::VEC3(0.0f, (f1 = 120.0f, 0.0f), (f0 = 30.0f, 0.0f)), f1, f0);
// Scroller
@@ -293,6 +291,10 @@ namespace ipl {
System::getKeyboard()->endMgr();
}
FaderSceneCommand LetterWriter::calcFadeout() {
return TextWriter::calcFadeout();
}
void LetterWriter::onEventDerived(u32 compId, u32 event, const controller::Interface* con) {
if (mState != STATE_SEL_FACE) {
if (getMemoManager()->getState()->getStateType() != textinput::extend::memo::Manager::ST_Appearing) {
@@ -378,30 +380,10 @@ namespace ipl {
}
}
FaderSceneCommand LetterWriter::calcFadeout() {
return TextWriter::calcFadeout();
}
extern "C" char lbl_816503BF[] = "WIPL_SE_DECIDE";
extern "C" char lbl_816503CE[0x12A] =
"\x91\x97\x90\x4D\x8E\xB8\x94\x73\n\0"
"NWC24InitMsgObj err\n\0"
"NWC24SetMsgToId err\n\0"
"[to]: %016llu\n\0"
"NWC24SetMsgText err\n\0"
"RFLSetOfficial2NWC24Msg err = %d\n\0"
"NWC24SetMsgMBNoReply err\n\0"
"setMsgCommand err\n\0"
"NWC24SetMsgAttached err\n\0"
"NWC24CommitMsg err\n\0"
"NWC24SetMsgToAddr err\n\0"
"[LetterWriter]: send to %s\n\0"
"setMsgSubjectAndTextPublic err\n\0";
void LetterWriter::onSend() {
Button* button = getButton();
snd::getSystem()->startSE(lbl_816503BF);
snd::getSystem()->startSE("WIPL_SE_DECIDE");
unk_0x7D = false;
@@ -417,7 +399,7 @@ namespace ipl {
}
if (sendMessageByNWC24(myUserId, mWCString) != 0) {
OSReport(lbl_816503CE);
OSReport("送信失敗\n"); // "Send failure"
} else {
PlayTimeLog::sendMsgLog((wchar_t*)mFriendInfo.attr.name);
getBoard()->reopen_log();
@@ -488,27 +470,26 @@ namespace ipl {
int LetterWriter::sendToWii(NWC24UserId userId, const wchar_t* wcString) {
NWC24MsgObj msgObj;
const char* report = lbl_81650380;
// Create message object
if (!System::getNwc24Manager()->initMsgObj(&msgObj, NWC24_MSGTYPE_WII_MENU)) {
OSReport(report + 0x58);
OSReport("NWC24InitMsgObj err\n");
return SEND_ERR_NWC24;
}
// Set message to ID (in this case, my user ID)
if (!System::getNwc24Manager()->setMsgToId(&msgObj, userId)) {
OSReport(report + 0x6D);
OSReport("NWC24SetMsgToId err\n");
return SEND_ERR_NWC24;
}
OSReport(report + 0x82, userId);
OSReport("[to]: %016llu\n", userId);
// Set letter contents
if (*wcString != 0) {
if (!System::getNwc24Manager()->setMsgText(&msgObj, (char*)wcString, wcslen(wcString) * sizeof(wchar_t), NWC24_UTF_16BE,
NWC24_ENC_BASE64)) {
OSReport(report + 0x91);
OSReport("NWC24SetMsgText err\n");
return SEND_ERR_NWC24;
}
} else {
@@ -518,7 +499,7 @@ namespace ipl {
if (!System::getNwc24Manager()->setMsgText(&msgObj, (char*)blank, wcslen(blank) * sizeof(wchar_t), NWC24_UTF_16BE,
NWC24_ENC_BASE64)) {
OSReport(report + 0x91);
OSReport("NWC24SetMsgText err\n");
return SEND_ERR_NWC24;
}
}
@@ -528,19 +509,19 @@ namespace ipl {
RFLCharData data;
RFLErrcode err = RFLiSetOfficial2NWC24Msg(&msgObj, &data, mSelectedFaceId);
if (err != RFLErrcode_Success) {
OSReport(report + 0xA6, err);
OSReport("RFLSetOfficial2NWC24Msg err = %d\n", err);
return SEND_ERR_RFL;
}
}
// Do not reply
if (!System::getNwc24Manager()->setMsgMBNoReply(&msgObj, false)) {
OSReport(report + 0xC8);
OSReport("NWC24SetMsgMBNoReply err\n");
return SEND_ERR_NWC24;
}
if (!System::getNwc24Manager()->setLedPattern(&msgObj)) {
OSReport(report + 0xE2);
OSReport("setMsgCommand err\n");
return SEND_ERR_NWC24;
}
@@ -549,14 +530,14 @@ namespace ipl {
u32 picLength = 0;
const void* picData = board->getPicture(&picLength);
if (NWC24SetMsgAttached(&msgObj, picData, picLength, NWC24_X_WII_PICTURE) != NWC24_OK) {
OSReport(report + 0xF5);
OSReport("NWC24SetMsgAttached err\n");
return SEND_ERR_NWC24;
}
}
// Send!
if (!System::getNwc24Manager()->commitMsg(&msgObj)) {
OSReport(report + 0x10E);
OSReport("NWC24CommitMsg err\n");
return SEND_ERR_NWC24;
}
@@ -565,33 +546,32 @@ namespace ipl {
int LetterWriter::sendToPC(NWC24UserId userId, const wchar_t* wcString) {
NWC24MsgObj msgObj;
const char* report = lbl_816503CE + 0x4E;
// Create message object
if (!System::getNwc24Manager()->initMsgObj(&msgObj, NWC24_MSGTYPE_PUBLIC)) {
OSReport(report + 0xA);
OSReport("NWC24InitMsgObj err\n");
return SEND_ERR_NWC24;
}
// Set message to ID (in this case, my user ID)
if (!System::getNwc24Manager()->setMsgToAddr(&msgObj, mFriendInfo.addr.mailAddr, strlen(mFriendInfo.addr.mailAddr))) {
OSReport(report + 0xD4);
OSReport("NWC24SetMsgToAddr err\n");
return SEND_ERR_NWC24;
}
OSReport(report + 0xEB, mFriendInfo.addr.mailAddr);
OSReport("[LetterWriter]: send to %s\n", mFriendInfo.addr.mailAddr);
// Set letter contents
const wchar_t* subject = System::getMessage(MESG_LETTERWRITER_EMAIL_SUBJECT);
if (!System::getNwc24Manager()->setMsgSubjectAndTextPublic(&msgObj, (u16*)subject, wcslen(subject), (u16*)wcString, wcslen(wcString),
mpTextSubjectWork, mTextSubjectWorkSize)) {
OSReport(report + 0x107);
OSReport("setMsgSubjectAndTextPublic err\n");
return SEND_ERR_NWC24;
}
// Send!
if (!System::getNwc24Manager()->commitMsg(&msgObj)) {
OSReport(report + 0xC0);
OSReport("NWC24CommitMsg err\n");
return SEND_ERR_NWC24;
}

View File

@@ -884,44 +884,51 @@ namespace ipl {
return ret;
}
void ESMisc::DeleteUnauthorizedData(EGG::Heap* heap) {
u32 titleCount = 0;
DECOMP_FORCE_ACTIVE(iplESMisc_cpp, "verifySavedataZD");
DECOMP_FORCE_ACTIVE(iplESMisc_cpp, "DeleteTicketsForce");
DECOMP_FORCE_ACTIVE(iplESMisc_cpp, "InitSavedata");
s32 ESMisc::DeleteUnauthorizedData(EGG::Heap* heap) {
ESTitleId* titleIds = NULL;
char path[88];
NANDFileInfo fileInfo ALIGN32;
u8 ticketViews[0xe0] ALIGN32;
u32 titleCount = 0;
u32 ticketViewCount;
ESTicketView* ticketViewList;
char path[88];
NANDFileInfo fileInfo;
u8 ticketViews[0xe0] ALIGN32;
s32 result;
s32 ret = ES_ListTitlesOnCard(NULL, &titleCount);
if (ret == ES_ERR_OK) {
titleIds = (ESTitleId*)heap->alloc(OSRoundUp32B(titleCount * sizeof(ESTitleId)), -DEFAULT_ALIGN);
if (titleIds == NULL) {
OSReport("%s::%s: Unable to allocate\n", __FILE__, "InitSavedata");
if (ret != ES_ERR_OK) {
OSReport("%s::%s: Failed to ES_ListTitlesOnCard1: %d\n", __FILE__, "InitSavedata", ret);
} else {
ret = ES_ListTitlesOnCard(titleIds, &titleCount);
if (ret == ES_ERR_OK) {
titleIds = (ESTitleId*)heap->alloc(OSRoundUp32B(titleCount * sizeof(ESTitleId)), -DEFAULT_ALIGN);
if (titleIds == NULL) {
OSReport("%s::%s: Unable to allocate\n", __FILE__, "InitSavedata");
} else {
ret = ES_ListTitlesOnCard(titleIds, &titleCount);
if (ret != ES_ERR_OK) {
OSReport("%s::%s: Failed to ES_ListTitlesOnCard2: %d\n", __FILE__, "InitSavedata", ret);
} else {
ESTicketView* ticketView = (ESTicketView*)ticketViews;
u32 i = 0;
for (u32 titleIdOffset = 0; i < titleCount; titleIdOffset += 8, i++) {
ESTitleId titleId = *(ESTitleId*)((u8*)titleIds + titleIdOffset);
u32 titleIdOffset = 0;
for (u32 i = 0; i < titleCount; i++) {
u32 titleIdHi = *(u32*)((u8*)titleIds + titleIdOffset);
u32 titleIdLo = *(u32*)((u8*)titleIds + titleIdOffset + 4);
if ((titleIdLo & 0xffffff00) == 0x525a4400 && titleIdHi == 0x10000) {
if ((titleId & 0xffffffffffffff00ULL) == 0x00010000525a4400ULL) {
u8* saveData = NULL;
BOOL fileOpen = FALSE;
BOOL deleteSaveData = FALSE;
sprintf(path - 8, "/title/%08x/%08x/data/%s", titleIdHi & 0xffffff, titleIdLo, "zeldaTp.dat");
if (!ChangeUid(((ESTitleId)titleIdHi << 32) | titleIdLo)) {
sprintf(path, "/title/%08x/%08x/data/%s", (u32)((titleId >> 32) & 0xffffff), (u32)(titleId & 0xffffffff), "zeldaTp.dat");
if (!ChangeUid(titleId)) {
OSReport("%s::%s: ChangeUid failed\n", __FILE__, "verifySavedataZD");
DeleteTitle(heap, ((ESTitleId)titleIdHi << 32) | titleIdLo);
DeleteTitle(heap, titleId);
} else {
ret = NANDPrivateOpen(path - 8, (NANDFileInfo*)((u8*)&fileInfo - 0x20), NAND_ACCESS_READ);
if (ret == NAND_RESULT_NOEXISTS) {
OSReport("%s::%s: Does not exist %s: %d\n", __FILE__, "verifySavedataZD", path - 8, ret);
} else if (ret != NAND_RESULT_OK) {
OSReport("%s::%s: Open save data file failed: %d\n", __FILE__, "verifySavedataZD", ret);
result = NANDPrivateOpen(path, &fileInfo, NAND_ACCESS_READ);
if (result == NAND_RESULT_NOEXISTS) {
OSReport("%s::%s: Does not exist %s: %d\n", __FILE__, "verifySavedataZD", path, result);
} else if (result != NAND_RESULT_OK) {
OSReport("%s::%s: Open save data file failed: %d\n", __FILE__, "verifySavedataZD", result);
} else {
fileOpen = TRUE;
saveData = (u8*)heap->alloc(0x4000, -DEFAULT_ALIGN);
@@ -929,11 +936,11 @@ namespace ipl {
OSReport("%s::%s: Alloc failed: %d\n", __FILE__, "verifySavedataZD", -2);
} else {
memset(saveData, 0, 0x4000);
ret = NANDRead((NANDFileInfo*)((u8*)&fileInfo - 0x20), saveData, 0x4000);
if (ret < 0) {
OSReport("%s::%s: Read file failed: %d\n", __FILE__, "verifySavedataZD", ret);
} else if (ret != 0x4000) {
OSReport("%s::%s: File size is not correct: %d\n", __FILE__, "verifySavedataZD", ret);
result = NANDRead(&fileInfo, saveData, 0x4000);
if (result < 0) {
OSReport("%s::%s: Read file failed: %d\n", __FILE__, "verifySavedataZD", result);
} else if (result != 0x4000) {
OSReport("%s::%s: File size is not correct: %d\n", __FILE__, "verifySavedataZD", result);
deleteSaveData = TRUE;
} else {
u32 offset = 8;
@@ -974,15 +981,15 @@ namespace ipl {
if (!valid) {
OSReport("%s::%s: Verify failed for %016llx\n", __FILE__, "verifySavedataZD",
((ESTitleId)titleIdHi << 32) | titleIdLo);
titleId);
deleteSaveData = TRUE;
}
}
NANDClose((NANDFileInfo*)((u8*)&fileInfo - 0x20));
NANDClose(&fileInfo);
fileOpen = FALSE;
if (deleteSaveData) {
DeleteSavedata(((ESTitleId)titleIdHi << 32) | titleIdLo, heap);
DeleteSavedata(titleId, heap);
}
}
}
@@ -992,64 +999,87 @@ namespace ipl {
heap->free(saveData);
}
if (fileOpen) {
NANDClose((NANDFileInfo*)((u8*)&fileInfo - 0x20));
NANDClose(&fileInfo);
}
ChangeUid(SYSMENU_TITLE_ID);
continue;
}
if ((((ESTitleId)titleIdHi << 32) | titleIdLo) == 0x0001000844495343ULL ||
((((ESTitleId)titleIdHi << 32) | titleIdLo) < 0x0001000844495343ULL &&
((((ESTitleId)titleIdHi << 32) | titleIdLo) == 0x000100014a4f4449ULL ||
((((ESTitleId)titleIdHi << 32) | titleIdLo) > 0x000100014a4f4449ULL &&
(((ESTitleId)titleIdHi << 32) | titleIdLo) == 0x0001000148415858ULL))) ||
((((ESTitleId)titleIdHi << 32) | titleIdLo) > 0x0001000844495343ULL &&
((((ESTitleId)titleIdHi << 32) | titleIdLo) == 0x0001000844564458ULL ||
((((ESTitleId)titleIdHi << 32) | titleIdLo) > 0x0001000844564458ULL &&
(((ESTitleId)titleIdHi << 32) | titleIdLo) == 0x000100084449534bULL)))) {
ESTitleId titleId = *(ESTitleId*)((u8*)titleIds + titleIdOffset);
ES_DeleteTitle(titleId);
if (titleId == 0x0001000844495343ULL) {
goto delete_title;
}
if (titleId < 0x0001000844495343ULL) {
if (titleId == 0x000100014a4f4449ULL) {
goto delete_title;
}
if (titleId < 0x000100014a4f4449ULL) {
if (titleId == 0x0001000148415858ULL) {
goto delete_title;
}
continue;
}
continue;
} else {
if (titleId == 0x0001000844564458ULL) {
goto delete_title;
}
if (titleId < 0x0001000844564458ULL) {
if (titleId == 0x000100084449534bULL) {
goto delete_title;
}
continue;
}
continue;
}
goto delete_title_end;
delete_title:
{
ES_DeleteTitle(*(ESTitleId*)((u8*)titleIds + titleIdOffset));
ESTitleId delTitleId = *(ESTitleId*)((u8*)titleIds + titleIdOffset);
ESTicketView* ticketViewList;
ticketViewList = NULL;
memset(ticketViews, 0, sizeof(ticketViews));
ret = ES_GetTicketViews(titleId, NULL, &ticketViewCount);
if (ret != ES_ERR_OK) {
OSReport("%s::%s: ES_GetTicketViews failed: %d for %016llx\n", __FILE__, "DeleteTicketsForce", ret, titleId);
} else if (ticketViewCount != 0) {
ticketViewList = (ESTicketView*)heap->alloc(ticketViewCount * 0xe0, -DEFAULT_ALIGN);
ret = ES_GetTicketViews(titleId, ticketViewList, &ticketViewCount);
if (ret != ES_ERR_OK) {
OSReport("%s::%s: ES_GetTicketViews failed: %d for %016llx\n", __FILE__, "DeleteTicketsForce", ret, titleId);
} else {
for (u32 j = 0; j < ticketViewCount; j++) {
memcpy(ticketViews, (u8*)ticketViewList + j * sizeof(ESTicketView), 0xd8);
ret = ES_DeleteTicket((ESTicketView*)ticketViews);
if (ret != ES_ERR_OK) {
OSReport("%s::%s: ES_DeleteTicket failed: %d for %016llx\n", __FILE__, "DeleteTicketsForce", ret,
((ESTicketView*)ticketViews)->ticketId);
memset(ticketView, 0, sizeof(ticketViews));
result = ES_GetTicketViews(delTitleId, NULL, &ticketViewCount);
if (result != ES_ERR_OK) {
OSReport("%s::%s: ES_GetTicketViews failed: %d for %016llx\n", __FILE__, "DeleteTicketsForce", result, delTitleId);
} else {
if (ticketViewCount != 0) {
goto has_tickets;
}
goto delete_title_end;
has_tickets:
{
ticketViewList = (ESTicketView*)heap->alloc(ticketViewCount * 0xe0, -DEFAULT_ALIGN);
result = ES_GetTicketViews(delTitleId, ticketViewList, &ticketViewCount);
if (result != ES_ERR_OK) {
OSReport("%s::%s: ES_GetTicketViews failed: %d for %016llx\n", __FILE__, "DeleteTicketsForce", result, delTitleId);
} else {
for (u32 j = 0; j < ticketViewCount; j++) {
memcpy(ticketView, (u8*)ticketViewList + j * sizeof(ESTicketView), 0xd8);
result = ES_DeleteTicket(ticketView);
if (result != ES_ERR_OK) {
OSReport("%s::%s: ES_DeleteTicket failed: %d for %016llx\n", __FILE__, "DeleteTicketsForce", result,
ticketView->ticketId);
}
}
}
}
}
if (ticketViewList != NULL) {
heap->free(ticketViewList);
}
}
titleIdOffset += 8;
delete_title_end:
;
}
} else {
OSReport("%s::%s: Failed to ES_ListTitlesOnCard2: %d\n", __FILE__, "InitSavedata", ret);
}
}
}
} else {
OSReport("%s::%s: Failed to ES_ListTitlesOnCard1: %d\n", __FILE__, "InitSavedata", ret);
}
if (titleIds != NULL) {
heap->free(titleIds);
}
return;
return ret;
}
BOOL checkForNullTermination(char* str, u32 len) {

View File

@@ -33,20 +33,25 @@ namespace ipl {
}
void Graphics::setOrthoProjection(const math::VEC3& translate, const math::VEC2& scale) {
nw4r::ut::Rect projRect(0, 0, 0, 0);
nw4r::ut::Rect projRect;
System::getProjectionRect(&projRect);
f32 temp_f9 = projRect.right / scale.x;
f32 temp_f7 = projRect.left / scale.x;
MTXOrtho(mArg.mProjMtx, translate.y - (projRect.top / scale.y), translate.y - (projRect.bottom / scale.y), translate.x + temp_f7,
translate.x + temp_f9, -100.0f, 100.0f);
f32 right = translate.x + projRect.right / scale.x;
f32 left = translate.x + projRect.left / scale.x;
f32 bottom = translate.y - (projRect.bottom / scale.y);
f32 top = translate.y - (projRect.top / scale.y);
MTXOrtho(mArg.mProjMtx, top, bottom, left, right, -100.0f, 100.0f);
GXSetProjection(mArg.mProjMtx, GX_ORTHOGRAPHIC);
}
void Graphics::setOrthoProjection(u32 id) {
GXRenderModeObj* rMode = System::getRenderModeObj();
MTXOrtho(mArg.mProjMtx, rMode->efbHeight / 2, -rMode->efbHeight / 2, -rMode->fbWidth / 2, rMode->fbWidth / 2, -100.0f, 100.0f);
f32 widthHalf = rMode->fbWidth / 2;
f32 negativeWidthHalf = -rMode->fbWidth / 2;
f32 negativeHeightHalf = -rMode->efbHeight / 2;
f32 heightHalf = rMode->efbHeight / 2;
MTXOrtho(mArg.mProjMtx, heightHalf, negativeHeightHalf, negativeWidthHalf, widthHalf, -100.0f, 100.0f);
GXSetProjection(mArg.mProjMtx, GX_ORTHOGRAPHIC);
calcOrthoCamera();