Compare commits
29 Commits
agent/w101
...
agent/w101
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
574ebe9452 | ||
|
|
6a71232197 | ||
|
|
a19380ae3e | ||
|
|
fe17055a57 | ||
|
|
4e469fa6aa | ||
|
|
a7fe51469a | ||
|
|
62416538d4 | ||
|
|
eb055e0751 | ||
|
|
5811b98eb2 | ||
|
|
198e76f235 | ||
|
|
def2f7a924 | ||
|
|
144e69c5da | ||
|
|
a543d4461d | ||
|
|
1bfa5a573e | ||
|
|
1b4ed24c8c | ||
|
|
dcf9db3972 | ||
|
|
75c27c1500 | ||
|
|
46baf9b6e8 | ||
|
|
aae707a35a | ||
|
|
99d2a15e2d | ||
|
|
4630f24f89 | ||
|
|
0d918086b9 | ||
|
|
e8b6a4e1a9 | ||
|
|
b1cd6ccdb4 | ||
|
|
635627fea8 | ||
|
|
06cbb45542 | ||
|
|
4359557455 | ||
|
|
70ac2abb86 | ||
|
|
c2bbf076cb |
@@ -42,7 +42,7 @@ AppLoaderHdr = .bss:0x810ABF40; // type:object size:0x20 align:32 data:4byte
|
||||
bi2 = .bss:0x810ABF60; // type:object size:0x2000 align:32 data:4byte
|
||||
UpdateDiskID = .bss:0x810ADF60; // type:object size:0x20 align:32 data:4byte
|
||||
TicketViewsBuf = .bss:0x810ADF80; // type:object size:0x3600 scope:local align:32
|
||||
Flags0 = .bss:0x810B1580; // type:object size:0x800 scope:local
|
||||
Flags0$1129 = .bss:0x810B1580; // type:object size:0x800 scope:local
|
||||
Flags1 = .bss:0x810B1D80; // type:object size:0x800 scope:local
|
||||
Thread = .bss:0x810B2580; // type:object size:0x318 scope:local
|
||||
UpdateHeader0 = .bss:0x810B38A0; // type:object size:0x20 scope:local
|
||||
@@ -4584,11 +4584,11 @@ enqueueLoadNotice__Q33ipl5scene15SDChannelSelectFv = .text:0x813DB308; // type:f
|
||||
enqueuePageNotice__Q33ipl5scene15SDChannelSelectFv = .text:0x813DB364; // type:function size:0x5C
|
||||
enqueueResultNotice__Q33ipl5scene15SDChannelSelectFUl = .text:0x813DB3C0; // type:function size:0x5C
|
||||
enqueueChannelNotice__Q33ipl5scene15SDChannelSelectFUxUl = .text:0x813DB41C; // type:function size:0x5C
|
||||
enqueueMoveNotice__Q33ipl5scene15SDChannelSelectFUlUlUl = .text:0x813DB478; // type:function size:0x5C
|
||||
enqueueMoveNotice__Q33ipl5scene15SDChannelSelectFUx = .text:0x813DB478; // type:function size:0x5C
|
||||
enqueueStateNotice__Q33ipl5scene15SDChannelSelectFUxUl = .text:0x813DB4D4; // type:function size:0x5C
|
||||
enqueueErrorNotice__Q33ipl5scene15SDChannelSelectFUlUl = .text:0x813DB530; // type:function size:0x5C
|
||||
enqueueCommandNotice__Q33ipl5scene15SDChannelSelectFUlUlUl = .text:0x813DB58C; // type:function size:0x60
|
||||
enqueueDeleteNotice__Q33ipl5scene15SDChannelSelectFUlUlUl = .text:0x813DB5EC; // type:function size:0x60
|
||||
enqueueErrorNotice__Q33ipl5scene15SDChannelSelectFPQ33ipl12NandSDWorker11TitleIdListPQ33ipl12NandSDWorker11TitleIdList = .text:0x813DB530; // type:function size:0x5C
|
||||
enqueueCommandNotice__Q33ipl5scene15SDChannelSelectFPQ33ipl12NandSDWorker11TitleIdListPQ33ipl12NandSDWorker11TitleIdListPQ33ipl12NandSDWorker11TitleIdList = .text:0x813DB58C; // type:function size:0x60
|
||||
enqueueDeleteNotice__Q33ipl5scene15SDChannelSelectFUx = .text:0x813DB5EC; // type:function size:0x60
|
||||
clearCommandQueue__Q33ipl5scene15SDChannelSelectFv = .text:0x813DB64C; // type:function size:0x40
|
||||
clearNoticeQueue__Q33ipl5scene15SDChannelSelectFv = .text:0x813DB68C; // type:function size:0x40
|
||||
processWorkerCommands__Q33ipl5scene15SDChannelSelectFv = .text:0x813DB6CC; // type:function size:0x518
|
||||
@@ -4617,11 +4617,11 @@ updateDialogAnimation__Q33ipl5scene15SDChannelSelectFv = .text:0x813DCAC4; // ty
|
||||
setDialogMessage__Q33ipl5scene15SDChannelSelectFUlUl = .text:0x813DCEF0; // type:function size:0x24
|
||||
isCurrentTitleUsageEnough__Q33ipl5scene15SDChannelSelectCFPCl = .text:0x813DCF14; // type:function size:0xCC
|
||||
getCurrentTitleUsage__Q33ipl5scene15SDChannelSelectCFPlPl = .text:0x813DCFE0; // type:function size:0xCC
|
||||
collectTitlesByUsage__Q33ipl5scene15SDChannelSelectFPlPlPUxPcPUl = .text:0x813DD0AC; // type:function size:0x194
|
||||
collectTitlesFromNandUsage__Q33ipl5scene15SDChannelSelectFPlPlPUxPcPUl = .text:0x813DD240; // type:function size:0x198
|
||||
collectTitlesByChannelOrder__Q33ipl5scene15SDChannelSelectFPlPlPUxPcPUl = .text:0x813DD3D8; // type:function size:0x1F8
|
||||
collectTitlesBySpecialChannels__Q33ipl5scene15SDChannelSelectFPlPlPUxPcPUl = .text:0x813DD5D0; // type:function size:0x5A4
|
||||
collectTitlesForMode__Q33ipl5scene15SDChannelSelectFPlPlPUxPcPUli = .text:0x813DDB74; // type:function size:0x40
|
||||
collectTitlesByUsage__Q33ipl5scene15SDChannelSelectFPlPlPUxPA21_wPUl = .text:0x813DD0AC; // type:function size:0x194
|
||||
collectTitlesFromNandUsage__Q33ipl5scene15SDChannelSelectFPlPlPUxPA21_wPUl = .text:0x813DD240; // type:function size:0x198
|
||||
collectTitlesByChannelOrder__Q33ipl5scene15SDChannelSelectFPlPlPUxPA21_wPUl = .text:0x813DD3D8; // type:function size:0x1F8
|
||||
collectTitlesBySpecialChannels__Q33ipl5scene15SDChannelSelectFPlPlPUxPA21_wPUl = .text:0x813DD5D0; // type:function size:0x5A4
|
||||
collectTitlesForMode__Q33ipl5scene15SDChannelSelectFPlPlPUxPA21_wPUli = .text:0x813DDB74; // type:function size:0x40
|
||||
findAdjacentChannel__Q33ipl5scene15SDChannelSelectCFiPiPi = .text:0x813DDBB4; // type:function size:0xB4
|
||||
setCurrentPageAndRefresh__Q33ipl5scene15SDChannelSelectFiiPQ33ipl5scene12SDChannelObj = .text:0x813DDC68; // type:function size:0x18
|
||||
handleFourPageDialog__Q33ipl5scene15SDChannelSelectFv = .text:0x813DDC80; // type:function size:0x58
|
||||
@@ -4762,7 +4762,7 @@ iplSDChannelTitle_updateParentalResult = .text:0x813E69B4; // type:function size
|
||||
iplSDChannelTitle_updateDialogResult = .text:0x813E6B88; // type:function size:0x144
|
||||
iplSDChannelTitle_startCopyProgress = .text:0x813E6CCC; // type:function size:0x158
|
||||
iplSDChannelTitle_updateCopyPrepare = .text:0x813E6E24; // type:function size:0x17C
|
||||
iplSDChannelTitle_copyTitleRange = .text:0x813E6FA0; // type:function size:0x14
|
||||
__as__Q43ipl5scene8SDMemory10TitleRangeFRCQ43ipl5scene8SDMemory10TitleRange = .text:0x813E6FA0; // type:function size:0x14 scope:weak
|
||||
iplSDChannelTitle_updateMemoryCalc = .text:0x813E6FB4; // type:function size:0xC0
|
||||
iplSDChannelTitle_updateCopyStart = .text:0x813E7074; // type:function size:0x130
|
||||
iplSDChannelTitle_updateAfterClearTmp = .text:0x813E71A4; // type:function size:0xA8
|
||||
@@ -4900,8 +4900,8 @@ onDialogState23__Q33ipl5scene8SDMemoryFv = .text:0x813EEDF8; // type:function si
|
||||
onDialogState24__Q33ipl5scene8SDMemoryFv = .text:0x813EEE70; // type:function size:0xC0
|
||||
draw__Q33ipl5scene8SDMemoryFv = .text:0x813EEF30; // type:function size:0x88
|
||||
drawTransferTitles__Q33ipl5scene8SDMemoryFv = .text:0x813EEFB8; // type:function size:0x70C
|
||||
writeFourFlagBytes__Q23ipl5sceneFPUcUcUcUcUc = .text:0x813EF6C4; // type:function size:0x14
|
||||
setTitleRowColors__Q23ipl5sceneFPQ34nw4r3lyt7TextBoxRCQ34nw4r2ut5ColorRCQ34nw4r2ut5Color = .text:0x813EF6D8; // type:function size:0x48
|
||||
__ct__Q34nw4r2ut5ColorFiiii = .text:0x813EF6C4; // type:function size:0x14
|
||||
SetTextColor__Q34nw4r3lyt7TextBoxFQ34nw4r2ut5ColorQ34nw4r2ut5Color = .text:0x813EF6D8; // type:function size:0x48
|
||||
GetBeginIter__Q34nw4r2ut28LinkList<Q34nw4r3lyt4Pane,4>Fv = .text:0x813EF720; // type:function size:0x8
|
||||
GetEndIter__Q34nw4r2ut28LinkList<Q34nw4r3lyt4Pane,4>Fv = .text:0x813EF728; // type:function size:0x8
|
||||
__ne__Q24nw4r2utFQ44nw4r2ut28LinkList<Q34nw4r3lyt4Pane,4>8IteratorQ44nw4r2ut28LinkList<Q34nw4r3lyt4Pane,4>8Iterator = .text:0x813EF730; // type:function size:0x18
|
||||
@@ -17727,7 +17727,7 @@ __vt__Q39textinput4util9Animation = .data:0x8165D258; // type:object size:0x24
|
||||
@STRING@GetTextColor__Q34nw4r3lyt7TextBoxCFUl = .data:0x8165D28C; // type:object size:0x41 data:string
|
||||
scT_prdc_Text_00 = .data:0x8165D2D0; // type:object size:0xF data:string
|
||||
scP_prdc_scrl_Left = .data:0x8165D2E0; // type:object size:0x11 data:string
|
||||
scCandidatePaneData = .data:0x8165D2F8; // type:object size:0x680
|
||||
csPaneToAnimation__Q29textinput12candidatebox = .data:0x8165D2F8; // type:object size:0x680 scope:local
|
||||
@9934 = .data:0x8165D978; // type:object size:0x9 scope:local data:string
|
||||
@9935 = .data:0x8165D984; // type:object size:0x9 scope:local data:string
|
||||
@9936 = .data:0x8165D990; // type:object size:0xB scope:local data:string
|
||||
@@ -23681,8 +23681,8 @@ RegionValid = .sbss:0x81698A48; // type:object size:0x4 data:4byte
|
||||
NandPending = .sbss:0x81698A4C; // type:object size:0x4 scope:local data:4byte
|
||||
CancelNand = .sbss:0x81698A50; // type:object size:0x4 scope:local data:4byte
|
||||
LowReadResult = .sbss:0x81698A54; // type:object size:0x4 scope:local data:4byte
|
||||
CacheCommandComplete = .sbss:0x81698A58; // type:object size:0x4 scope:local data:4byte
|
||||
AudioBufferUnconfigured = .sbss:0x81698A5C; // type:object size:0x4 scope:local data:4byte
|
||||
CacheCommandComplete$1963 = .sbss:0x81698A58; // type:object size:0x4 scope:local data:4byte
|
||||
AudioBufferUnconfigured$2065 = .sbss:0x81698A5C; // type:object size:0x4 scope:local data:4byte
|
||||
ResetTime = .sbss:0x81698A60; // type:object size:0x8 scope:local data:4byte
|
||||
SpinupDeadline = .sbss:0x81698A68; // type:object size:0x8 scope:local data:4byte
|
||||
CoverPollTime = .sbss:0x81698A70; // type:object size:0x8 data:4byte
|
||||
@@ -23690,15 +23690,13 @@ DriveWasReset = .sbss:0x81698A78; // type:object size:0x4 data:4byte
|
||||
TitleTicketView = .sbss:0x81698A7C; // type:object size:0x4 scope:local data:4byte
|
||||
CurrentTmd = .sbss:0x81698A80; // type:object size:0x4 scope:local data:4byte
|
||||
TitleCode = .sbss:0x81698A84; // type:object size:0x4 data:4byte
|
||||
RequiredIosHigh = .sbss:0x81698A88; // type:object size:0x4 data:4byte
|
||||
RequiredIosLow = .sbss:0x81698A8C; // type:object size:0x4 data:4byte
|
||||
RequiredIos = .sbss:0x81698A88; // type:object size:0x8 data:4byte
|
||||
GamePartition = .sbss:0x81698A90; // type:object size:0x4 data:4byte
|
||||
UpdatePartition = .sbss:0x81698A94; // type:object size:0x4 data:4byte
|
||||
PartitionCursor = .sbss:0x81698A98; // type:object size:0x4 data:4byte
|
||||
DataToc = .sbss:0x81698A9C; // type:object size:0x4 data:4byte
|
||||
GameToc = .sbss:0x81698AA0; // type:object size:0x8 data:4byte
|
||||
CoverOpenTimeHigh = .sbss:0x81698AA8; // type:object size:0x4 data:4byte
|
||||
CoverOpenTimeLow = .sbss:0x81698AAC; // type:object size:0x4 data:4byte
|
||||
CoverOpenTime = .sbss:0x81698AA8; // type:object size:0x8 data:4byte
|
||||
NandTransferred = .sbss:0x81698AB0; // type:object size:0x4 data:4byte
|
||||
NandLength = .sbss:0x81698AB4; // type:object size:0x4 data:4byte
|
||||
NandBuffer = .sbss:0x81698AB8; // type:object size:0x4 data:4byte
|
||||
|
||||
18
configure.py
18
configure.py
@@ -658,7 +658,7 @@ config.libs = [
|
||||
Object(Matching, "system/iplChannelRsoThread.cpp"),
|
||||
Object(Matching, "system/RsoSystem.cpp"),
|
||||
Object(Matching, "system/iplCdbBackup.cpp"),
|
||||
Object(NonMatching, "system/odh.cpp"),
|
||||
Object(Matching, "system/odh.cpp"),
|
||||
Object(Matching, "system/iplSDVFWorker.cpp"),
|
||||
Object(Matching, "system/iplNandWrapper.cpp"),
|
||||
Object(Matching, "system/main.cpp"),
|
||||
@@ -718,8 +718,8 @@ config.libs = [
|
||||
Object(Matching, "BS2/BS2Entry.c"),
|
||||
Object(Matching, "BS2/BS2.c"),
|
||||
Object(Matching, "BS2/BS2Init.c"),
|
||||
Object(NonMatching, "BS2/BS2Mach.c"),
|
||||
Object(NonMatching, "BS2/BS2Update.c"),
|
||||
Object(Matching, "BS2/BS2Mach.c"),
|
||||
Object(Matching, "BS2/BS2Update.c"),
|
||||
Object(Matching, "BS2/BS2ParentalControl.c"),
|
||||
Object(Matching, "BS2/BS2BringUp.c"),
|
||||
Object(Matching, "BS2/BS2Reset.c"),
|
||||
@@ -814,7 +814,7 @@ config.libs = [
|
||||
IPLSection("memoryCard", [
|
||||
Object(Matching, "scene/memoryCard/iplMemoryCard.cpp"),
|
||||
Object(Matching, "scene/memoryCard/iplMemoryCardBase.cpp"),
|
||||
Object(NonMatching, "scene/memoryCard/iplMemoryCardManager.cpp"),
|
||||
Object(Matching, "scene/memoryCard/iplMemoryCardManager.cpp"),
|
||||
Object(Matching, "scene/memoryCard/iplGCSaveData.cpp"),
|
||||
Object(Matching, "scene/memoryCard/iplGCWindow.cpp"),
|
||||
]
|
||||
@@ -864,7 +864,7 @@ config.libs = [
|
||||
]
|
||||
),
|
||||
IPLSection("sdChannelMemory", [
|
||||
Object(NonMatching, "scene/sdChannelMemory/iplSDMemory.cpp"),
|
||||
Object(Matching, "scene/sdChannelMemory/iplSDMemory.cpp"),
|
||||
]
|
||||
),
|
||||
IPLSection("setting", [
|
||||
@@ -880,7 +880,7 @@ config.libs = [
|
||||
Object(Matching, "scene/setting/iplRakuRakuThread.cpp"),
|
||||
Object(NonMatching, "scene/setting/AOSS.c", extra_cflags=["-O4,p", "-inline off"]),
|
||||
Object(Matching, "scene/setting/AOSSData.c"),
|
||||
Object(NonMatching, "scene/setting/ATERM.c", extra_cflags=["-O4,p", "-inline on"]),
|
||||
Object(NonMatching, "scene/setting/ATERM.c", mw_version="GC/3.0a5", extra_cflags=["-O4,p", "-inline on"]),
|
||||
]
|
||||
),
|
||||
IPLSection("settingSelect", [
|
||||
@@ -912,7 +912,7 @@ config.libs = [
|
||||
Object(Matching, "keyboard/tiPcKeyboard.cpp", extra_cflags=["-O4,p"]),
|
||||
Object(Matching, "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(Matching, "keyboard/tiCandidateBox.cpp", extra_cflags=["-O4,p"]),
|
||||
Object(Matching, "keyboard/tiToolBar.cpp", extra_cflags=["-O4,p"]),
|
||||
Object(Matching, "keyboard/tiPredictLang.cpp", extra_cflags=["-O4,p"]),
|
||||
Object(Matching, "keyboard/tiSignWindow.cpp", extra_cflags=["-O4,p"]),
|
||||
@@ -1049,7 +1049,7 @@ config.libs = [
|
||||
Object(Matching, "net/hmac.c"),
|
||||
Object(Matching, "net/neterrorcode.c"),
|
||||
Object(Matching, "net/NETVersion.c"),
|
||||
Object(NonMatching, "net/aes.c"),
|
||||
Object(Matching, "net/aes.c"),
|
||||
Object(Matching, "net/wireless_macaddr.c"),
|
||||
]
|
||||
),
|
||||
@@ -1886,7 +1886,7 @@ config.libs = [
|
||||
]
|
||||
),
|
||||
RVLSDKLib("kbd", [
|
||||
Object(NonMatching, "kbd/kbd_lib.c"),
|
||||
Object(Matching, "kbd/kbd_lib.c"),
|
||||
Object(NonMatching, "kbd/kbd_lib_map_jp.c"),
|
||||
Object(Matching, "kbd/kbd_lib_map_us.c"),
|
||||
Object(NonMatching, "kbd/kbd_lib_map_eu.c"),
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef CHANSVmObjHdr* (*VmConvertFunc)(CHANSVm*, CHANSVmObjType, CHANSVmObjHdr*);
|
||||
typedef CHANSVmObjHdr* (*VmConvertFunc)(CHANSVm*, CHANSVmObjType, const CHANSVmObjHdr*);
|
||||
|
||||
typedef struct VmConvertEntry {
|
||||
VmConvertFunc convFunc[6]; // 0x00
|
||||
|
||||
@@ -12,6 +12,7 @@ extern void __sync();
|
||||
extern unsigned int __cntlzw(unsigned int value);
|
||||
extern void __memclr(void* buffer, int len);
|
||||
extern unsigned int __rlwimi(unsigned int a, unsigned int b, unsigned int c, unsigned int d, unsigned int e);
|
||||
extern unsigned int __rlwinm(unsigned int value, unsigned int shift, unsigned int maskBegin, unsigned int maskEnd);
|
||||
extern void* __alloca(unsigned int blockSize);
|
||||
extern int __abs(int n);
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ namespace textinput {
|
||||
|
||||
class Base : public CommandSender {
|
||||
public:
|
||||
#ifdef TIMANAGER_IMPLEMENTATION
|
||||
#if defined(TIMANAGER_IMPLEMENTATION) || defined(TI_CANDIDATEBOX_SAMPLE_CLASS)
|
||||
Base(Manager* manager) : mpCandidates(NULL), mpAllocator(NULL), mbOn(false), mbInvalid(true), meLanguage(USA), mpManager(manager) {}
|
||||
#endif
|
||||
virtual ~Base();
|
||||
@@ -114,7 +114,7 @@ namespace textinput {
|
||||
|
||||
class EventHandler : public nw4rmanager::TiEventHandler {
|
||||
public:
|
||||
#ifdef TIMANAGER_IMPLEMENTATION
|
||||
#if defined(TIMANAGER_IMPLEMENTATION) || defined(TI_CANDIDATEBOX_SAMPLE_CLASS)
|
||||
EventHandler(LayoutByNW4R* layout) : mpLayoutByNW4R(layout) {}
|
||||
#endif
|
||||
virtual void onTiEvent(gui::PaneComponent* paneComponent, u32 event, Input* input) override; // 0x18
|
||||
@@ -302,7 +302,7 @@ namespace textinput {
|
||||
// TODO
|
||||
class LayoutByNW4R : public Base, public nw4rmanager::Layout, public UIObj::Listener {
|
||||
public:
|
||||
#ifdef TIMANAGER_IMPLEMENTATION
|
||||
#if defined(TIMANAGER_IMPLEMENTATION) || defined(TI_CANDIDATEBOX_SAMPLE_CLASS)
|
||||
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),
|
||||
@@ -371,6 +371,15 @@ namespace textinput {
|
||||
bool mbActive;
|
||||
};
|
||||
|
||||
#ifdef TI_CANDIDATEBOX_SAMPLE_CLASS
|
||||
class Sample : public LayoutByNW4R {
|
||||
public:
|
||||
Sample(Manager* manager, nw4r::lyt::MultiArcResourceAccessor* accessor, EventObserver* observer, const char* layoutName)
|
||||
: LayoutByNW4R(manager, accessor, observer, layoutName) {}
|
||||
virtual ~Sample() {}
|
||||
};
|
||||
#endif
|
||||
|
||||
class CandidateTextAnmPane : public nw4rmanager::AnmPane {
|
||||
public:
|
||||
CandidateTextAnmPane(nw4r::lyt::Pane* pane, nw4rmanager::AnmObserver* observer)
|
||||
|
||||
@@ -166,11 +166,11 @@ namespace ipl {
|
||||
void update_file_array(u8 slot);
|
||||
void update_change_cardstate(u8 slot);
|
||||
|
||||
GXTexObj* create_icon(u8 slot, s16 index);
|
||||
GXTexObj* create_icon(u8 slot, s16 index, long start);
|
||||
GXTexObj* _create_icon(u8 slot, s16 fileNo, long start);
|
||||
const GXTexObj* create_icon(u8 slot, s16 index);
|
||||
const GXTexObj* create_icon(u8 slot, s16 index, long start);
|
||||
const GXTexObj* _create_icon(u8 slot, s16 fileNo, long start);
|
||||
const wchar_t* getComment(u8 slot, s16 index, int which);
|
||||
GXTexObj* create_banner(u8 slot, s16 index);
|
||||
const GXTexObj* create_banner(u8 slot, s16 index);
|
||||
#ifdef IPL_GC_WINDOW_CPP
|
||||
u32 getBlocks(u8 slot, s16 index);
|
||||
#else
|
||||
@@ -187,7 +187,7 @@ namespace ipl {
|
||||
}
|
||||
|
||||
private:
|
||||
GXTexObj* initBannerTexture(u8 slot, s32 file, void* data) {
|
||||
const GXTexObj* initBannerTexture(u8 slot, s32 file, void* data) {
|
||||
GXInitTexObj(&mFileCell[slot][file].banner, data, CARD_BANNER_WIDTH, CARD_BANNER_HEIGHT,
|
||||
GX_TF_RGB5A3, GX_CLAMP, GX_CLAMP, GX_FALSE);
|
||||
return &mFileCell[slot][file].banner;
|
||||
@@ -203,6 +203,22 @@ namespace ipl {
|
||||
return &mFileCell[slot][file].bannerTlut;
|
||||
}
|
||||
|
||||
const GXTexObj* initIconTexture(u8 slot, s32 file, void* data) {
|
||||
GXInitTexObj(&mFileCell[slot][file].icon, data, CARD_ICON_WIDTH, CARD_ICON_HEIGHT,
|
||||
GX_TF_RGB5A3, GX_CLAMP, GX_CLAMP, GX_FALSE);
|
||||
return &mFileCell[slot][file].icon;
|
||||
}
|
||||
|
||||
void initIconTextureCI(u8 slot, s32 file, void* data) {
|
||||
GXInitTexObjCI(&mFileCell[slot][file].icon, data, CARD_ICON_WIDTH, CARD_ICON_HEIGHT,
|
||||
GX_TF_C8, GX_CLAMP, GX_CLAMP, GX_FALSE, GX_TLUT0);
|
||||
}
|
||||
|
||||
GXTlutObj* initIconPalette(u8 slot, s32 file, void* data) {
|
||||
GXInitTlutObj(&mFileCell[slot][file].iconTlut, data, GX_TL_RGB5A3, 0x100);
|
||||
return &mFileCell[slot][file].iconTlut;
|
||||
}
|
||||
|
||||
u32 reserved; // 0x00004
|
||||
MCFile mFile[2][CARD_MAX_FILE]; // 0x00008
|
||||
MCFileCell mFileCell[2][CARD_MAX_FILE]; // 0x00FE8
|
||||
|
||||
@@ -142,14 +142,9 @@ namespace ipl {
|
||||
u32 mTransferStatus;
|
||||
u64 mTransferStartTime;
|
||||
s32 mTransferFrame;
|
||||
struct TitleListState {
|
||||
ESTitleId* mpTitles;
|
||||
u32 mCount;
|
||||
ESTitleId* mpSecondaryTitles;
|
||||
u32 mSecondaryCount;
|
||||
ESTitleId* mpNames;
|
||||
u32 mNameCount;
|
||||
} mTitleListState;
|
||||
NandSDWorker::TitleIdList mTitleList;
|
||||
NandSDWorker::TitleIdList mNandTitleList;
|
||||
NandSDWorker::TitleIdList mSDTitleList;
|
||||
scroller mScroller;
|
||||
s32 mButtonState;
|
||||
u8 mControllerFlags[4];
|
||||
|
||||
@@ -178,7 +178,7 @@ namespace ipl {
|
||||
BOOL onEventDerived(const char* paneName, u32 event,
|
||||
controller::Interface* controller);
|
||||
bool collectTitlesByUsage(s32* firstUsage, s32* secondUsage,
|
||||
ESTitleId* titleIds, char* titleNames,
|
||||
ESTitleId* titleIds, wchar_t (*titleNames)[21],
|
||||
u32* titleCount);
|
||||
|
||||
static const char* mscChannelPaneNames[PAGE_COUNT][MAX_CHANNEL_INDEX];
|
||||
@@ -197,6 +197,8 @@ namespace ipl {
|
||||
friend class SDChannelSelectEventHandler;
|
||||
friend class SDChannelSelectButtonEventHandler;
|
||||
#endif
|
||||
friend class SDMemory;
|
||||
|
||||
void enqueueStartNotice();
|
||||
bool enqueueFinishNotice();
|
||||
bool enqueueNotice(u32 highTitleId, u32 lowTitleId, u32 result);
|
||||
@@ -204,11 +206,14 @@ namespace ipl {
|
||||
bool enqueuePageNotice();
|
||||
bool enqueueResultNotice(u32 result);
|
||||
bool enqueueChannelNotice(u64 titleId, u32 value);
|
||||
bool enqueueMoveNotice(u32 controller, u32 page, u32 index);
|
||||
bool enqueueMoveNotice(ESTitleId titleId);
|
||||
bool enqueueStateNotice(u64 titleId, u32 state);
|
||||
bool enqueueErrorNotice(u32 page, u32 index);
|
||||
bool enqueueCommandNotice(u32 page, u32 index, u32 command);
|
||||
bool enqueueDeleteNotice(u32 controller, u32 page, u32 index);
|
||||
bool enqueueErrorNotice(NandSDWorker::TitleIdList* newTitles,
|
||||
NandSDWorker::TitleIdList* replacingTitles);
|
||||
bool enqueueCommandNotice(NandSDWorker::TitleIdList* titles,
|
||||
NandSDWorker::TitleIdList* foundTitles,
|
||||
NandSDWorker::TitleIdList* badTitles);
|
||||
bool enqueueDeleteNotice(ESTitleId titleId);
|
||||
void clearCommandQueue();
|
||||
void clearNoticeQueue();
|
||||
void calcChannelObjects();
|
||||
@@ -233,16 +238,16 @@ namespace ipl {
|
||||
bool isCurrentTitleUsageEnough(const s32* usage) const;
|
||||
void getCurrentTitleUsage(s32* bytes, s32* blocks) const;
|
||||
bool collectTitlesByChannelOrder(s32* firstUsage, s32* secondUsage,
|
||||
ESTitleId* titleIds, char* titleNames,
|
||||
ESTitleId* titleIds, wchar_t (*titleNames)[21],
|
||||
u32* titleCount);
|
||||
bool collectTitlesFromNandUsage(s32* firstUsage, s32* secondUsage,
|
||||
ESTitleId* titleIds, char* titleNames,
|
||||
ESTitleId* titleIds, wchar_t (*titleNames)[21],
|
||||
u32* titleCount);
|
||||
bool collectTitlesBySpecialChannels(s32* firstUsage, s32* secondUsage,
|
||||
ESTitleId* titleIds, char* titleNames,
|
||||
ESTitleId* titleIds, wchar_t (*titleNames)[21],
|
||||
u32* titleCount);
|
||||
bool collectTitlesForMode(s32* firstUsage, s32* secondUsage,
|
||||
ESTitleId* titleIds, char* titleNames,
|
||||
ESTitleId* titleIds, wchar_t (*titleNames)[21],
|
||||
u32* titleCount, int searchMode);
|
||||
bool findAdjacentChannel(int direction, int* page, int* index) const;
|
||||
void setStateAndPlaySelectSound(int state) NO_INLINE;
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace ipl {
|
||||
Manager(EGG::Heap* heap);
|
||||
|
||||
/** @return The message data in use. */
|
||||
const wchar_t* getMessage(u32 id) const { return mpMessage->getMessage(id); }
|
||||
wchar_t* getMessage(u32 id) const { return mpMessage->getMessage(id); }
|
||||
void setResource(u8* msgData) const { mpMessage->setResource(msgData); }
|
||||
|
||||
private:
|
||||
|
||||
@@ -302,7 +302,7 @@ namespace ipl {
|
||||
}
|
||||
|
||||
/** @return The Message ID as a Wide-string. */
|
||||
static const wchar_t* getMessage(u32 id) { return smArg.mpMessageMgr->getMessage(id); }
|
||||
static wchar_t* getMessage(u32 id) { return smArg.mpMessageMgr->getMessage(id); }
|
||||
static message::Manager* getMessageManager() { return smArg.mpMessageMgr; }
|
||||
|
||||
static void* getFont();
|
||||
|
||||
@@ -27,7 +27,11 @@ wchar_t* wcscat(wchar_t* dest, const wchar_t* src);
|
||||
wchar_t* wcsncat(wchar_t* dest, const wchar_t* src, size_t num);
|
||||
int wcsncmp(const wchar_t* s1, const wchar_t* s2, size_t num);
|
||||
wchar_t* wcschr(wchar_t* ws, wchar_t wc);
|
||||
#ifndef __cplusplus
|
||||
wchar_t* wcsstr(const wchar_t* s1, const wchar_t* s2);
|
||||
#else
|
||||
const wchar_t* wcsstr(const wchar_t* s1, const wchar_t* s2);
|
||||
#endif
|
||||
|
||||
int swprintf(wchar_t* ws, size_t len, const wchar_t* format, ...);
|
||||
int vswprintf(wchar_t* ws, size_t len, const wchar_t* format, va_list arg);
|
||||
@@ -36,6 +40,12 @@ int wcsnicmp(const char* dst, const char* src, size_t num);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
extern "C++" {
|
||||
inline wchar_t* wcsstr(wchar_t* s1, const wchar_t* s2) {
|
||||
return const_cast<wchar_t*>(wcsstr(static_cast<const wchar_t*>(s1), s2));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // MSL_WCHAR_H
|
||||
|
||||
@@ -123,7 +123,7 @@ namespace nw4r {
|
||||
const math::MTX34& GetMtx() const { return mMtx; }
|
||||
void SetMtx(const math::MTX34& mtx) { mMtx = mtx; }
|
||||
|
||||
u8 GetAlpha() { return mAlpha; }
|
||||
u8 GetAlpha() const { return mAlpha; }
|
||||
void SetAlpha(u8 alpha) { mAlpha = alpha; }
|
||||
|
||||
const char* GetName() const { return mName; }
|
||||
|
||||
@@ -55,16 +55,14 @@ namespace nw4r {
|
||||
NW4R_ASSERT(type < TEXTCOLOR_MAX);
|
||||
return mTextColors[type];
|
||||
}
|
||||
#ifdef IPL_SDMEMORY_SET_TEXT_COLORS
|
||||
void SetTextColors(const ut::Color& first, const ut::Color& second) {
|
||||
mTextColors[0] = first;
|
||||
mTextColors[1] = second;
|
||||
}
|
||||
#endif
|
||||
void SetTextColor(u32 type, ut::Color value) {
|
||||
NW4R_ASSERT(type < TEXTCOLOR_MAX);
|
||||
mTextColors[type] = value;
|
||||
}
|
||||
void SetTextColor(ut::Color top, ut::Color bottom) {
|
||||
mTextColors[0] = top;
|
||||
mTextColors[1] = bottom;
|
||||
}
|
||||
|
||||
void SetTextPositionH(u8 pos) { detail::SetHorizontalPosition(&mTextPosition, pos); }
|
||||
void SetTextPositionV(u8 pos) { detail::SetVerticalPosition(&mTextPosition, pos); }
|
||||
|
||||
@@ -33,391 +33,417 @@ static s32 scalingClampU8(s32 value) {
|
||||
|
||||
void TMCJPEGDEC_IdctBlock_Lumi(s32* block, u8* conv_row_ptr, u16 pitch, s32 zigzag) {
|
||||
s32 workspace[64];
|
||||
s32* workspaceCursor;
|
||||
s32 evenBaseSum;
|
||||
s32 evenRotation;
|
||||
s32 pitch4;
|
||||
s32* dst;
|
||||
s32* src;
|
||||
s32 pitch7;
|
||||
s32 rowCount;
|
||||
s32 pitch6;
|
||||
s32 pitch5;
|
||||
s32 pitch3;
|
||||
s32 pitch2;
|
||||
s32 processed;
|
||||
s32 column;
|
||||
s32 evenOutput3;
|
||||
s32 coefficient2;
|
||||
s32 coefficient1;
|
||||
s32 coefficient4;
|
||||
s32 coefficient5;
|
||||
s32 coefficient6;
|
||||
s32 coefficient7;
|
||||
s32 oddOutput0;
|
||||
s32 m;
|
||||
s32 evenBaseDifference;
|
||||
s32 processedCoefficients;
|
||||
s32 z;
|
||||
s32 evenOutput1;
|
||||
s32 oddOutput3;
|
||||
s32 oddLowRotation;
|
||||
s32 oddHighRotation;
|
||||
s32 evenRotationSum;
|
||||
s32 r;
|
||||
s32 oddOutput1;
|
||||
s32 oddSumRotation;
|
||||
s32 oddSumDifference;
|
||||
s32 oddDifferenceSum;
|
||||
s32 columnsRemaining;
|
||||
s32 oddOutput2;
|
||||
s32 evenOutput0;
|
||||
s32 evenOutput2;
|
||||
s32 coefficient3;
|
||||
|
||||
r = (zigzag >> 4) * 8;
|
||||
workspaceCursor = workspace;
|
||||
processedCoefficients = 0;
|
||||
{
|
||||
for (; processedCoefficients < r; processedCoefficients += 8) {
|
||||
u32 acBits;
|
||||
coefficient4 = block[4];
|
||||
coefficient6 = block[6];
|
||||
coefficient2 = block[2];
|
||||
coefficient1 = block[1];
|
||||
coefficient7 = block[7];
|
||||
coefficient5 = block[5];
|
||||
coefficient3 = block[3];
|
||||
|
||||
acBits = (u32)coefficient4;
|
||||
acBits |= (u32)coefficient6;
|
||||
acBits |= (u32)coefficient2;
|
||||
acBits |= (u32)coefficient1;
|
||||
acBits |= (u32)coefficient7;
|
||||
acBits |= (u32)coefficient5;
|
||||
acBits |= (u32)coefficient3;
|
||||
if (acBits == 0) {
|
||||
s32 sample = block[0];
|
||||
workspaceCursor[7] = sample;
|
||||
workspaceCursor[6] = sample;
|
||||
workspaceCursor[5] = sample;
|
||||
workspaceCursor[4] = sample;
|
||||
workspaceCursor[3] = sample;
|
||||
workspaceCursor[2] = sample;
|
||||
workspaceCursor[1] = sample;
|
||||
workspaceCursor[0] = sample;
|
||||
} else {
|
||||
s32 oddLowSum;
|
||||
s32 oddHighSum;
|
||||
s32 oddLowDifference;
|
||||
s32 oddHighDifference;
|
||||
s32 dcValue;
|
||||
|
||||
evenRotation = coefficient2 - coefficient6;
|
||||
oddLowSum = coefficient5 + coefficient3;
|
||||
oddLowDifference = coefficient5 - coefficient3;
|
||||
oddHighSum = coefficient1 + coefficient7;
|
||||
oddHighDifference = coefficient1 - coefficient7;
|
||||
evenRotationSum = coefficient6 + coefficient2;
|
||||
evenRotation = evenRotation * 0xB5 >> 8;
|
||||
oddSumDifference = oddHighSum - oddLowSum;
|
||||
oddDifferenceSum = oddLowDifference + oddHighDifference;
|
||||
dcValue = block[0];
|
||||
evenBaseDifference = dcValue - coefficient4;
|
||||
oddSumRotation = oddSumDifference * 0xB5 >> 8;
|
||||
evenBaseSum = dcValue + coefficient4;
|
||||
evenRotationSum = evenRotation + evenRotationSum;
|
||||
evenOutput1 = evenBaseDifference + evenRotation;
|
||||
z = oddDifferenceSum * 0x62 >> 8;
|
||||
evenOutput0 = evenBaseSum + evenRotationSum;
|
||||
evenOutput3 = evenBaseSum - evenRotationSum;
|
||||
oddHighRotation = oddHighDifference * 0x14E >> 8;
|
||||
evenOutput2 = evenBaseDifference - evenRotation;
|
||||
m = oddHighRotation - z;
|
||||
oddLowSum += m;
|
||||
oddOutput0 = oddHighSum + oddLowSum;
|
||||
oddOutput1 = oddSumRotation + m;
|
||||
workspaceCursor[0] = evenOutput0 + oddOutput0;
|
||||
oddLowRotation = oddLowDifference * 0x8B;
|
||||
workspaceCursor[7] = evenOutput0 - oddOutput0;
|
||||
oddLowRotation >>= 8;
|
||||
workspaceCursor[1] = evenOutput1 + oddOutput1;
|
||||
oddOutput3 = z + oddLowRotation;
|
||||
oddOutput2 = oddOutput3 + oddSumRotation;
|
||||
workspaceCursor[6] = evenOutput1 - oddOutput1;
|
||||
workspaceCursor[2] = evenOutput2 + oddOutput2;
|
||||
workspaceCursor[5] = evenOutput2 - oddOutput2;
|
||||
workspaceCursor[3] = evenOutput3 + oddOutput3;
|
||||
workspaceCursor[4] = evenOutput3 - oddOutput3;
|
||||
}
|
||||
block += 8;
|
||||
workspaceCursor += 8;
|
||||
rowCount = (zigzag >> 4) * 8;
|
||||
dst = workspace;
|
||||
for (processed = 0; processed < rowCount; processed += 8) {
|
||||
s32 c1;
|
||||
s32 c2;
|
||||
int acBits;
|
||||
s32 c7;
|
||||
s32 c5;
|
||||
s32 c4;
|
||||
s32 c3;
|
||||
s32 c6;
|
||||
c4 = block[4];
|
||||
c6 = block[6];
|
||||
c2 = block[2];
|
||||
c1 = block[1];
|
||||
c7 = block[7];
|
||||
c5 = block[5];
|
||||
c3 = block[3];
|
||||
acBits = c4 | c6;
|
||||
acBits = c2 | acBits;
|
||||
acBits = c1 | acBits;
|
||||
acBits = c7 | acBits;
|
||||
acBits = c5 | acBits;
|
||||
acBits = c3 | acBits;
|
||||
if (acBits == 0) {
|
||||
s32 dc = block[0];
|
||||
dst[7] = dc;
|
||||
dst[6] = dc;
|
||||
dst[5] = dc;
|
||||
dst[4] = dc;
|
||||
dst[3] = dc;
|
||||
dst[2] = dc;
|
||||
dst[1] = dc;
|
||||
dst[0] = dc;
|
||||
} else {
|
||||
s32 dc;
|
||||
s32 evenSum;
|
||||
s32 oddSumRotation;
|
||||
s32 oddOutput0;
|
||||
s32 evenRotationSum;
|
||||
s32 evenRotation;
|
||||
s32 oddLowDifference;
|
||||
s32 oddDifferenceRotation;
|
||||
s32 evenOutput3;
|
||||
s32 oddOutput1;
|
||||
s32 oddHighSum;
|
||||
s32 oddOutput2;
|
||||
s32 evenBaseSum;
|
||||
s32 evenOutput0;
|
||||
s32 oddDifferenceSum;
|
||||
s32 evenOutput2;
|
||||
s32 oddMix;
|
||||
s32 oddLowRotation;
|
||||
s32 oddOutput3;
|
||||
s32 evenOutput1;
|
||||
s32 oddHighRotation;
|
||||
s32 oddLowSum;
|
||||
s32 oddSumDifference;
|
||||
s32 evenBaseDifference;
|
||||
s32 oddHighDifference;
|
||||
oddHighSum = c1 + c7;
|
||||
dc = block[0];
|
||||
evenSum = c6 + c2;
|
||||
oddLowDifference = c5 - c3;
|
||||
oddHighDifference = c1 - c7;
|
||||
evenRotation = c2 - c6;
|
||||
c2 = evenRotation * 0xB5 >> 8;
|
||||
evenBaseDifference = dc - c4;
|
||||
oddLowSum = c5 + c3;
|
||||
oddSumDifference = oddHighSum - oddLowSum;
|
||||
oddSumRotation = oddSumDifference * 0xB5 >> 8;
|
||||
oddDifferenceSum = oddLowDifference + oddHighDifference;
|
||||
oddDifferenceRotation = oddDifferenceSum * 0x62 >> 8;
|
||||
oddLowRotation = oddLowDifference * 0x8B;
|
||||
oddHighRotation = oddHighDifference * 0x14E >> 8;
|
||||
evenRotationSum = c2 + evenSum;
|
||||
evenOutput1 = evenBaseDifference + c2;
|
||||
oddLowRotation >>= 8;
|
||||
evenBaseSum = dc + c4;
|
||||
oddMix = oddHighRotation - oddDifferenceRotation;
|
||||
evenOutput2 = evenBaseDifference - c2;
|
||||
oddOutput1 = oddSumRotation + oddMix;
|
||||
evenOutput3 = evenBaseSum - evenRotationSum;
|
||||
oddLowSum += oddMix;
|
||||
evenOutput0 = evenBaseSum + evenRotationSum;
|
||||
oddOutput0 = oddHighSum + oddLowSum;
|
||||
oddOutput3 = oddDifferenceRotation + oddLowRotation;
|
||||
oddOutput2 = oddOutput3 + oddSumRotation;
|
||||
dst[0] = evenOutput0 + oddOutput0;
|
||||
dst[7] = evenOutput0 - oddOutput0;
|
||||
dst[1] = evenOutput1 + oddOutput1;
|
||||
dst[6] = evenOutput1 - oddOutput1;
|
||||
dst[2] = evenOutput2 + oddOutput2;
|
||||
dst[5] = evenOutput2 - oddOutput2;
|
||||
dst[3] = evenOutput3 + oddOutput3;
|
||||
dst[4] = evenOutput3 - oddOutput3;
|
||||
}
|
||||
block += 8;
|
||||
dst += 8;
|
||||
}
|
||||
|
||||
workspaceCursor = workspace + processedCoefficients;
|
||||
for (; processedCoefficients <= 0x38; processedCoefficients += 8) {
|
||||
memset(workspaceCursor, 0, 0x20);
|
||||
workspaceCursor += 8;
|
||||
dst = workspace + processed;
|
||||
for (; processed <= 56; processed += 8) {
|
||||
memset(dst, 0, 32);
|
||||
dst += 8;
|
||||
}
|
||||
|
||||
r = pitch * 8 - pitch;
|
||||
z = pitch * 4;
|
||||
m = pitch * 2;
|
||||
workspaceCursor = workspace + 7;
|
||||
for (columnsRemaining = 8, column = 7; columnsRemaining > 0; columnsRemaining--, column--) {
|
||||
u32 acBits;
|
||||
src = workspace + 7;
|
||||
pitch4 = pitch * 4;
|
||||
pitch5 = pitch4 + pitch;
|
||||
pitch3 = pitch4 - pitch;
|
||||
pitch2 = pitch * 2;
|
||||
pitch6 = pitch * 6;
|
||||
pitch7 = pitch * 8 - pitch;
|
||||
for (column = 7; column >= 0; column--) {
|
||||
s32 c1;
|
||||
s32 c2;
|
||||
s32 c5;
|
||||
s32 c3;
|
||||
s32 c6;
|
||||
s32 c4;
|
||||
s32 c7;
|
||||
int acBits;
|
||||
u8* output;
|
||||
|
||||
coefficient4 = workspaceCursor[0x20];
|
||||
coefficient6 = workspaceCursor[0x30];
|
||||
coefficient2 = workspaceCursor[0x10];
|
||||
coefficient1 = workspaceCursor[8];
|
||||
coefficient7 = workspaceCursor[0x38];
|
||||
coefficient5 = workspaceCursor[0x28];
|
||||
coefficient3 = workspaceCursor[0x18];
|
||||
|
||||
acBits = (u32)coefficient4;
|
||||
acBits |= (u32)coefficient6;
|
||||
acBits |= (u32)coefficient2;
|
||||
acBits |= (u32)coefficient1;
|
||||
acBits |= (u32)coefficient7;
|
||||
acBits |= (u32)coefficient5;
|
||||
acBits |= (u32)coefficient3;
|
||||
c4 = src[32];
|
||||
c6 = src[48];
|
||||
c2 = src[16];
|
||||
c1 = src[8];
|
||||
c7 = src[56];
|
||||
c5 = src[40];
|
||||
c3 = src[24];
|
||||
acBits = c4 | c6;
|
||||
acBits = c2 | acBits;
|
||||
acBits = c1 | acBits;
|
||||
acBits = c7 | acBits;
|
||||
acBits = c5 | acBits;
|
||||
acBits = c3 | acBits;
|
||||
output = conv_row_ptr + column;
|
||||
if (acBits == 0) {
|
||||
u8 sample = clampU8((*workspaceCursor >> 11) + 0x80);
|
||||
output[r] = sample;
|
||||
output[pitch * 6] = sample;
|
||||
output[z + pitch] = sample;
|
||||
output[z] = sample;
|
||||
output[z - pitch] = sample;
|
||||
output[m] = sample;
|
||||
u8 sample = clampU8((*src >> 11) + 0x80);
|
||||
output[pitch7] = sample;
|
||||
output[pitch6] = sample;
|
||||
output[pitch5] = sample;
|
||||
output[pitch4] = sample;
|
||||
output[pitch3] = sample;
|
||||
output[pitch2] = sample;
|
||||
output[pitch] = sample;
|
||||
output[0] = sample;
|
||||
} else {
|
||||
s32 oddDifferenceSum;
|
||||
s32 oddSumRotation;
|
||||
s32 evenBaseSum;
|
||||
s32 evenOutput2;
|
||||
s32 dc;
|
||||
s32 evenBaseDifference;
|
||||
s32 evenOutput0;
|
||||
s32 evenOutput1;
|
||||
s32 evenOutput3;
|
||||
s32 oddHighRotation;
|
||||
s32 oddMix;
|
||||
s32 oddHighDifference;
|
||||
s32 oddLowSum;
|
||||
s32 oddLowRotation;
|
||||
s32 evenRotation;
|
||||
s32 oddLowDifference;
|
||||
s32 oddSumDifference;
|
||||
s32 oddHighSum;
|
||||
s32 dcValue;
|
||||
|
||||
evenRotation = coefficient2 - coefficient6;
|
||||
oddLowSum = coefficient5 + coefficient3;
|
||||
coefficient5 = coefficient5 - coefficient3;
|
||||
oddHighSum = coefficient1 + coefficient7;
|
||||
coefficient1 = coefficient1 - coefficient7;
|
||||
evenRotationSum = coefficient6 + coefficient2;
|
||||
coefficient2 = evenRotation * 0xB5 >> 8;
|
||||
s32 evenRotationSum;
|
||||
s32 oddOutput0;
|
||||
s32 evenSum;
|
||||
s32 oddOutput2;
|
||||
s32 oddDifferenceRotation;
|
||||
s32 oddOutput1;
|
||||
s32 oddOutput3;
|
||||
evenSum = c6 + c2;
|
||||
evenRotation = c2 - c6;
|
||||
oddLowSum = c5 + c3;
|
||||
oddHighDifference = c1 - c7;
|
||||
oddLowDifference = c5 - c3;
|
||||
oddHighSum = c1 + c7;
|
||||
c2 = evenRotation * 0xB5 >> 8;
|
||||
dc = *src + 0x40000;
|
||||
oddDifferenceSum = oddLowDifference + oddHighDifference;
|
||||
oddSumDifference = oddHighSum - oddLowSum;
|
||||
oddDifferenceSum = coefficient5 + coefficient1;
|
||||
dcValue = *workspaceCursor + 0x40000;
|
||||
evenBaseDifference = dcValue - coefficient4;
|
||||
oddSumRotation = oddSumDifference * 0xB5 >> 8;
|
||||
evenBaseSum = dcValue + coefficient4;
|
||||
evenRotationSum = coefficient2 + evenRotationSum;
|
||||
evenOutput1 = evenBaseDifference + coefficient2;
|
||||
oddDifferenceSum = oddDifferenceSum * 0x62 >> 8;
|
||||
evenBaseSum = dc + c4;
|
||||
oddDifferenceRotation = oddDifferenceSum * 0x62 >> 8;
|
||||
oddHighRotation = oddHighDifference * 0x14E >> 8;
|
||||
evenRotationSum = c2 + evenSum;
|
||||
oddMix = oddHighRotation - oddDifferenceRotation;
|
||||
oddLowSum += oddMix;
|
||||
evenOutput0 = evenBaseSum + evenRotationSum;
|
||||
evenBaseDifference = dc - c4;
|
||||
evenOutput3 = evenBaseSum - evenRotationSum;
|
||||
oddHighRotation = coefficient1 * 0x14E >> 8;
|
||||
evenOutput2 = evenBaseDifference - coefficient2;
|
||||
oddHighRotation = oddHighRotation - oddDifferenceSum;
|
||||
oddLowSum += oddHighRotation;
|
||||
evenOutput1 = evenBaseDifference + c2;
|
||||
oddOutput0 = oddHighSum + oddLowSum;
|
||||
oddOutput1 = oddSumRotation + oddHighRotation;
|
||||
oddLowRotation = coefficient5 * 0x8B >> 8;
|
||||
oddOutput3 = oddDifferenceSum + oddLowRotation;
|
||||
oddLowRotation = oddLowDifference * 0x8B >> 8;
|
||||
oddOutput3 = oddDifferenceRotation + oddLowRotation;
|
||||
evenOutput2 = evenBaseDifference - c2;
|
||||
oddOutput2 = oddOutput3 + oddSumRotation;
|
||||
oddOutput1 = oddSumRotation + oddMix;
|
||||
output[0] = scalingClampU8(evenOutput0 + oddOutput0);
|
||||
output[r] = scalingClampU8(evenOutput0 - oddOutput0);
|
||||
output[pitch7] = scalingClampU8(evenOutput0 - oddOutput0);
|
||||
output[pitch] = scalingClampU8(evenOutput1 + oddOutput1);
|
||||
output[pitch * 6] = scalingClampU8(evenOutput1 - oddOutput1);
|
||||
output[m] = scalingClampU8(evenOutput2 + oddOutput2);
|
||||
output[z + pitch] = scalingClampU8(evenOutput2 - oddOutput2);
|
||||
output[z - pitch] = scalingClampU8(evenOutput3 + oddOutput3);
|
||||
output[z] = scalingClampU8(evenOutput3 - oddOutput3);
|
||||
output[pitch6] = scalingClampU8(evenOutput1 - oddOutput1);
|
||||
output[pitch2] = scalingClampU8(evenOutput2 + oddOutput2);
|
||||
output[pitch5] = scalingClampU8(evenOutput2 - oddOutput2);
|
||||
output[pitch3] = scalingClampU8(evenOutput3 + oddOutput3);
|
||||
output[pitch4] = scalingClampU8(evenOutput3 - oddOutput3);
|
||||
}
|
||||
workspaceCursor--;
|
||||
src--;
|
||||
}
|
||||
}
|
||||
|
||||
void TMCJPEGDEC_IdctBlock_Col(s32* block, u8* conv_row_ptr, u16 pitch, s32 zigzag) {
|
||||
s32 workspace[64];
|
||||
s32* workspaceCursor;
|
||||
s32 evenBaseDifference;
|
||||
s32 columnsRemaining;
|
||||
s32 evenBaseSum;
|
||||
s32 coefficient1;
|
||||
s32 coefficient2;
|
||||
s32 coefficient3;
|
||||
s32 coefficient4;
|
||||
s32 coefficient5;
|
||||
s32 coefficient6;
|
||||
s32 coefficient7;
|
||||
s32 v;
|
||||
s32 rowCoefficientCount;
|
||||
s32 processedCoefficients;
|
||||
s32* src;
|
||||
s32 column;
|
||||
s32 m;
|
||||
s32 n;
|
||||
s32 oddOutput1;
|
||||
s32 oddSumRotation;
|
||||
s32 oddOutput2;
|
||||
s32 evenOutput2;
|
||||
s32 u;
|
||||
s32 evenOutput0;
|
||||
s32 oddOutput3;
|
||||
s32 rotation45;
|
||||
s32 z;
|
||||
s32 oddSumDifference;
|
||||
s32 oddDifferenceSum;
|
||||
s32 oddHighRotation;
|
||||
s32 oddLowRotation;
|
||||
s32 evenOutput3;
|
||||
s32 rowCount;
|
||||
s32 processed;
|
||||
s32* dst;
|
||||
|
||||
if (zigzag == 0x11) {
|
||||
s32 sample;
|
||||
sample = clampS8(block[0] >> 11);
|
||||
memset(conv_row_ptr, (s8)sample, 0x40);
|
||||
s32 dc = block[0];
|
||||
s32 sample = clampS8(dc >> 11);
|
||||
memset(conv_row_ptr, (s8)sample, 64);
|
||||
return;
|
||||
}
|
||||
|
||||
rowCoefficientCount = (zigzag >> 4) * 8;
|
||||
if ((zigzag & 0xF) > 2) {
|
||||
goto fullRowTransform;
|
||||
}
|
||||
|
||||
workspaceCursor = workspace;
|
||||
processedCoefficients = 0;
|
||||
for (; processedCoefficients < rowCoefficientCount; processedCoefficients += 8) {
|
||||
s32 dcValue;
|
||||
s32 oddCoefficient;
|
||||
|
||||
oddCoefficient = block[1];
|
||||
dcValue = block[0];
|
||||
rotation45 = oddCoefficient * 0xB5 >> 8;
|
||||
v = oddCoefficient * 0x62 >> 8;
|
||||
u = v + rotation45;
|
||||
z = (oddCoefficient * 0x14E >> 8) - v;
|
||||
m = oddCoefficient + z;
|
||||
n = rotation45 + z;
|
||||
workspaceCursor[0] = dcValue + m;
|
||||
workspaceCursor[7] = dcValue - m;
|
||||
workspaceCursor[1] = dcValue + n;
|
||||
workspaceCursor[6] = dcValue - n;
|
||||
workspaceCursor[2] = dcValue + u;
|
||||
workspaceCursor[5] = dcValue - u;
|
||||
workspaceCursor[3] = dcValue + v;
|
||||
workspaceCursor[4] = dcValue - v;
|
||||
workspaceCursor += 8;
|
||||
block += 8;
|
||||
}
|
||||
workspaceCursor = workspace + processedCoefficients;
|
||||
for (; processedCoefficients <= 0x38; processedCoefficients += 8) {
|
||||
memset(workspaceCursor, 0, 0x20);
|
||||
workspaceCursor += 8;
|
||||
}
|
||||
goto columnTransform;
|
||||
|
||||
fullRowTransform:
|
||||
workspaceCursor = workspace;
|
||||
processedCoefficients = 0;
|
||||
for (; processedCoefficients < rowCoefficientCount; processedCoefficients += 8) {
|
||||
u32 acBits;
|
||||
coefficient4 = block[4];
|
||||
coefficient6 = block[6];
|
||||
coefficient2 = block[2];
|
||||
coefficient1 = block[1];
|
||||
coefficient7 = block[7];
|
||||
coefficient5 = block[5];
|
||||
coefficient3 = block[3];
|
||||
|
||||
acBits = (u32)coefficient4;
|
||||
acBits |= (u32)coefficient6;
|
||||
acBits |= (u32)coefficient2;
|
||||
acBits |= (u32)coefficient1;
|
||||
acBits |= (u32)coefficient7;
|
||||
acBits |= (u32)coefficient5;
|
||||
acBits |= (u32)coefficient3;
|
||||
rowCount = (zigzag >> 4) * 8;
|
||||
if ((zigzag & 0xF) <= 2) {
|
||||
dst = workspace;
|
||||
for (processed = 0; processed < rowCount; processed += 8) {
|
||||
s32 mid;
|
||||
s32 odd;
|
||||
s32 outer;
|
||||
s32 dc;
|
||||
s32 inner;
|
||||
s32 rotation;
|
||||
s32 lowRotation;
|
||||
s32 mix;
|
||||
odd = block[1];
|
||||
rotation = odd * 0xB5 >> 8;
|
||||
lowRotation = odd * 0x62 >> 8;
|
||||
dc = block[0];
|
||||
mix = (odd * 0x14E >> 8) - lowRotation;
|
||||
outer = odd + mix;
|
||||
dst[0] = dc + outer;
|
||||
inner = rotation + mix;
|
||||
dst[7] = dc - outer;
|
||||
dst[1] = dc + inner;
|
||||
mid = lowRotation + rotation;
|
||||
dst[6] = dc - inner;
|
||||
dst[2] = dc + mid;
|
||||
dst[5] = dc - mid;
|
||||
dst[3] = dc + lowRotation;
|
||||
dst[4] = dc - lowRotation;
|
||||
dst += 8;
|
||||
block += 8;
|
||||
}
|
||||
dst = workspace + processed;
|
||||
for (; processed <= 56; processed += 8) {
|
||||
memset(dst, 0, 32);
|
||||
dst += 8;
|
||||
}
|
||||
} else {
|
||||
dst = workspace;
|
||||
for (processed = 0; processed < rowCount; processed += 8) {
|
||||
s32 c2;
|
||||
s32 c7;
|
||||
s32 c3;
|
||||
s32 c5;
|
||||
s32 c1;
|
||||
s32 c6;
|
||||
int acBits;
|
||||
s32 c4;
|
||||
c4 = block[4];
|
||||
c6 = block[6];
|
||||
c2 = block[2];
|
||||
c1 = block[1];
|
||||
c7 = block[7];
|
||||
c5 = block[5];
|
||||
c3 = block[3];
|
||||
acBits = c4 | c6;
|
||||
acBits = c2 | acBits;
|
||||
acBits = c1 | acBits;
|
||||
acBits = c7 | acBits;
|
||||
acBits = c5 | acBits;
|
||||
acBits = c3 | acBits;
|
||||
if (acBits == 0) {
|
||||
s32 sample;
|
||||
sample = block[0];
|
||||
workspaceCursor[7] = sample;
|
||||
workspaceCursor[6] = sample;
|
||||
workspaceCursor[5] = sample;
|
||||
workspaceCursor[4] = sample;
|
||||
workspaceCursor[3] = sample;
|
||||
workspaceCursor[2] = sample;
|
||||
workspaceCursor[1] = sample;
|
||||
workspaceCursor[0] = sample;
|
||||
s32 dc = block[0];
|
||||
dst[7] = dc;
|
||||
dst[6] = dc;
|
||||
dst[5] = dc;
|
||||
dst[4] = dc;
|
||||
dst[3] = dc;
|
||||
dst[2] = dc;
|
||||
dst[1] = dc;
|
||||
dst[0] = dc;
|
||||
} else {
|
||||
s32 evenBaseDifference;
|
||||
s32 oddOutput3;
|
||||
s32 oddMix;
|
||||
s32 evenOutput1;
|
||||
s32 evenOutput2;
|
||||
s32 oddDifferenceRotation;
|
||||
s32 oddLowRotation;
|
||||
s32 oddDifferenceSum;
|
||||
s32 evenSum;
|
||||
s32 oddLowSum;
|
||||
s32 dc;
|
||||
s32 oddSumDifference;
|
||||
s32 oddLowDifference;
|
||||
s32 oddHighSum;
|
||||
s32 evenBaseSum;
|
||||
s32 oddSumRotation;
|
||||
s32 evenRotationSum;
|
||||
s32 evenRotation;
|
||||
s32 evenOutput0;
|
||||
s32 oddOutput1;
|
||||
s32 oddHighDifference;
|
||||
s32 dcValue;
|
||||
|
||||
rotation45 = coefficient2 - coefficient6;
|
||||
oddLowSum = coefficient5 + coefficient3;
|
||||
oddLowDifference = coefficient5 - coefficient3;
|
||||
oddHighSum = coefficient1 + coefficient7;
|
||||
oddHighDifference = coefficient1 - coefficient7;
|
||||
u = coefficient6 + coefficient2;
|
||||
rotation45 = rotation45 * 0xB5 >> 8;
|
||||
s32 oddOutput0;
|
||||
s32 evenOutput3;
|
||||
s32 oddHighSum;
|
||||
s32 oddOutput2;
|
||||
s32 oddHighRotation;
|
||||
oddHighDifference = c1 - c7;
|
||||
oddLowSum = c5 + c3;
|
||||
evenSum = c6 + c2;
|
||||
oddHighSum = c1 + c7;
|
||||
evenRotation = c2 - c6;
|
||||
dc = block[0];
|
||||
evenBaseDifference = dc - c4;
|
||||
c2 = evenRotation * 0xB5 >> 8;
|
||||
oddSumDifference = oddHighSum - oddLowSum;
|
||||
oddDifferenceSum = oddLowDifference + oddHighDifference;
|
||||
dcValue = block[0];
|
||||
evenBaseDifference = dcValue - coefficient4;
|
||||
oddLowDifference = c5 - c3;
|
||||
oddSumRotation = oddSumDifference * 0xB5 >> 8;
|
||||
evenBaseSum = dcValue + coefficient4;
|
||||
u = rotation45 + u;
|
||||
v = evenBaseDifference + rotation45;
|
||||
z = oddDifferenceSum * 0x62 >> 8;
|
||||
evenOutput0 = evenBaseSum + u;
|
||||
evenOutput3 = evenBaseSum - u;
|
||||
evenBaseSum = dc + c4;
|
||||
oddHighRotation = oddHighDifference * 0x14E >> 8;
|
||||
evenOutput2 = evenBaseDifference - rotation45;
|
||||
m = oddHighRotation - z;
|
||||
oddLowSum += m;
|
||||
n = oddHighSum + oddLowSum;
|
||||
oddOutput1 = oddSumRotation + m;
|
||||
workspaceCursor[0] = evenOutput0 + n;
|
||||
oddDifferenceSum = oddLowDifference + oddHighDifference;
|
||||
oddDifferenceRotation = oddDifferenceSum * 0x62 >> 8;
|
||||
evenRotationSum = c2 + evenSum;
|
||||
oddMix = oddHighRotation - oddDifferenceRotation;
|
||||
oddOutput1 = oddSumRotation + oddMix;
|
||||
evenOutput1 = evenBaseDifference + c2;
|
||||
oddLowRotation = oddLowDifference * 0x8B;
|
||||
workspaceCursor[7] = evenOutput0 - n;
|
||||
oddLowSum += oddMix;
|
||||
evenOutput3 = evenBaseSum - evenRotationSum;
|
||||
evenOutput0 = evenBaseSum + evenRotationSum;
|
||||
oddLowRotation >>= 8;
|
||||
workspaceCursor[1] = v + oddOutput1;
|
||||
oddOutput3 = z + oddLowRotation;
|
||||
oddOutput3 = oddDifferenceRotation + oddLowRotation;
|
||||
evenOutput2 = evenBaseDifference - c2;
|
||||
oddOutput0 = oddHighSum + oddLowSum;
|
||||
dst[0] = evenOutput0 + oddOutput0;
|
||||
dst[7] = evenOutput0 - oddOutput0;
|
||||
dst[1] = evenOutput1 + oddOutput1;
|
||||
oddOutput2 = oddOutput3 + oddSumRotation;
|
||||
workspaceCursor[6] = v - oddOutput1;
|
||||
workspaceCursor[2] = evenOutput2 + oddOutput2;
|
||||
workspaceCursor[5] = evenOutput2 - oddOutput2;
|
||||
workspaceCursor[3] = evenOutput3 + oddOutput3;
|
||||
workspaceCursor[4] = evenOutput3 - oddOutput3;
|
||||
dst[6] = evenOutput1 - oddOutput1;
|
||||
dst[2] = evenOutput2 + oddOutput2;
|
||||
dst[5] = evenOutput2 - oddOutput2;
|
||||
dst[3] = evenOutput3 + oddOutput3;
|
||||
dst[4] = evenOutput3 - oddOutput3;
|
||||
}
|
||||
block += 8;
|
||||
workspaceCursor += 8;
|
||||
dst += 8;
|
||||
}
|
||||
dst = workspace + processed;
|
||||
for (; processed <= 56; processed += 8) {
|
||||
memset(dst, 0, 32);
|
||||
dst += 8;
|
||||
}
|
||||
}
|
||||
|
||||
workspaceCursor = workspace + processedCoefficients;
|
||||
for (; processedCoefficients <= 0x38; processedCoefficients += 8) {
|
||||
memset(workspaceCursor, 0, 0x20);
|
||||
workspaceCursor += 8;
|
||||
}
|
||||
|
||||
columnTransform:
|
||||
|
||||
workspaceCursor = workspace + 7;
|
||||
for (columnsRemaining = 8, column = 7; columnsRemaining > 0; columnsRemaining--, column--) {
|
||||
u32 acBits;
|
||||
src = workspace + 7;
|
||||
for (column = 7; column >= 0; column--) {
|
||||
s32 c1;
|
||||
s32 c3;
|
||||
int acBits;
|
||||
s32 c7;
|
||||
s32 c2;
|
||||
s32 c5;
|
||||
u8* output;
|
||||
coefficient4 = workspaceCursor[0x20];
|
||||
s32 c6;
|
||||
s32 c4;
|
||||
c4 = src[32];
|
||||
output = conv_row_ptr + column;
|
||||
coefficient6 = workspaceCursor[0x30];
|
||||
coefficient2 = workspaceCursor[0x10];
|
||||
coefficient1 = workspaceCursor[8];
|
||||
coefficient7 = workspaceCursor[0x38];
|
||||
coefficient5 = workspaceCursor[0x28];
|
||||
coefficient3 = workspaceCursor[0x18];
|
||||
|
||||
acBits = (u32)coefficient4;
|
||||
acBits |= (u32)coefficient6;
|
||||
acBits |= (u32)coefficient2;
|
||||
acBits |= (u32)coefficient1;
|
||||
acBits |= (u32)coefficient7;
|
||||
acBits |= (u32)coefficient5;
|
||||
acBits |= (u32)coefficient3;
|
||||
c6 = src[48];
|
||||
c2 = src[16];
|
||||
c1 = src[8];
|
||||
c7 = src[56];
|
||||
c5 = src[40];
|
||||
c3 = src[24];
|
||||
acBits = c4 | c6;
|
||||
acBits = c2 | acBits;
|
||||
acBits = c1 | acBits;
|
||||
acBits = c7 | acBits;
|
||||
acBits = c5 | acBits;
|
||||
acBits = c3 | acBits;
|
||||
if (acBits == 0) {
|
||||
s32 sample;
|
||||
sample = clampS8(*workspaceCursor >> 11);
|
||||
s32 sample = clampS8(*src >> 11);
|
||||
output[56] = (u8)sample;
|
||||
output[48] = (u8)sample;
|
||||
output[40] = (u8)sample;
|
||||
@@ -427,48 +453,68 @@ columnTransform:
|
||||
output[8] = (u8)sample;
|
||||
output[0] = (u8)sample;
|
||||
} else {
|
||||
s32 oddLowSum;
|
||||
s32 oddLowDifference;
|
||||
s32 evenSum;
|
||||
s32 evenOutput2;
|
||||
s32 oddOutput0;
|
||||
s32 oddMix;
|
||||
s32 evenBaseSum;
|
||||
s32 oddHighRotation;
|
||||
s32 evenRotationSum;
|
||||
s32 oddSumDifference;
|
||||
s32 evenOutput1;
|
||||
s32 oddHighSum;
|
||||
s32 evenOutput0;
|
||||
s32 oddOutput1;
|
||||
s32 oddDifferenceSum;
|
||||
s32 oddLowSum;
|
||||
s32 oddOutput3;
|
||||
s32 evenBaseDifference;
|
||||
s32 oddHighDifference;
|
||||
s32 dcValue;
|
||||
|
||||
rotation45 = coefficient2 - coefficient6;
|
||||
oddLowSum = coefficient5 + coefficient3;
|
||||
oddLowDifference = coefficient5 - coefficient3;
|
||||
oddHighSum = coefficient1 + coefficient7;
|
||||
oddHighDifference = coefficient1 - coefficient7;
|
||||
u = coefficient6 + coefficient2;
|
||||
rotation45 = rotation45 * 0xB5 >> 8;
|
||||
s32 oddOutput2;
|
||||
s32 dc;
|
||||
s32 oddLowDifference;
|
||||
s32 evenOutput3;
|
||||
s32 oddDifferenceRotation;
|
||||
s32 oddLowRotation;
|
||||
s32 evenRotation;
|
||||
s32 oddSumRotation;
|
||||
oddHighSum = c1 + c7;
|
||||
evenRotation = c2 - c6;
|
||||
oddLowSum = c5 + c3;
|
||||
oddSumDifference = oddHighSum - oddLowSum;
|
||||
oddDifferenceSum = oddLowDifference + oddHighDifference;
|
||||
dcValue = *workspaceCursor;
|
||||
evenBaseDifference = dcValue - coefficient4;
|
||||
evenSum = c6 + c2;
|
||||
oddLowDifference = c5 - c3;
|
||||
c2 = evenRotation * 0xB5 >> 8;
|
||||
oddHighDifference = c1 - c7;
|
||||
dc = *src;
|
||||
evenRotationSum = c2 + evenSum;
|
||||
oddSumRotation = oddSumDifference * 0xB5 >> 8;
|
||||
evenBaseSum = dcValue + coefficient4;
|
||||
u = rotation45 + u;
|
||||
v = evenBaseDifference + rotation45;
|
||||
z = oddDifferenceSum * 0x62 >> 8;
|
||||
evenOutput0 = evenBaseSum + u;
|
||||
evenOutput3 = evenBaseSum - u;
|
||||
oddDifferenceSum = oddLowDifference + oddHighDifference;
|
||||
oddDifferenceRotation = oddDifferenceSum * 0x62 >> 8;
|
||||
evenBaseDifference = dc - c4;
|
||||
evenBaseSum = dc + c4;
|
||||
oddHighRotation = oddHighDifference * 0x14E >> 8;
|
||||
evenOutput2 = evenBaseDifference - rotation45;
|
||||
m = oddHighRotation - z;
|
||||
oddLowSum += m;
|
||||
n = oddHighSum + oddLowSum;
|
||||
oddOutput1 = oddSumRotation + m;
|
||||
oddMix = oddHighRotation - oddDifferenceRotation;
|
||||
evenOutput3 = evenBaseSum - evenRotationSum;
|
||||
evenOutput1 = evenBaseDifference + c2;
|
||||
evenOutput2 = evenBaseDifference - c2;
|
||||
evenOutput0 = evenBaseSum + evenRotationSum;
|
||||
oddLowRotation = oddLowDifference * 0x8B >> 8;
|
||||
oddOutput3 = z + oddLowRotation;
|
||||
oddOutput3 = oddDifferenceRotation + oddLowRotation;
|
||||
oddLowSum += oddMix;
|
||||
oddOutput1 = oddSumRotation + oddMix;
|
||||
oddOutput0 = oddHighSum + oddLowSum;
|
||||
oddOutput2 = oddOutput3 + oddSumRotation;
|
||||
output[0] = (u8)clampS8((evenOutput0 + n) >> 11);
|
||||
output[56] = (u8)clampS8((evenOutput0 - n) >> 11);
|
||||
output[8] = (u8)clampS8((v + oddOutput1) >> 11);
|
||||
output[48] = (u8)clampS8((v - oddOutput1) >> 11);
|
||||
output[0] = (u8)clampS8((evenOutput0 + oddOutput0) >> 11);
|
||||
output[56] = (u8)clampS8((evenOutput0 - oddOutput0) >> 11);
|
||||
output[8] = (u8)clampS8((evenOutput1 + oddOutput1) >> 11);
|
||||
output[48] = (u8)clampS8((evenOutput1 - oddOutput1) >> 11);
|
||||
output[16] = (u8)clampS8((evenOutput2 + oddOutput2) >> 11);
|
||||
output[40] = (u8)clampS8((evenOutput2 - oddOutput2) >> 11);
|
||||
output[24] = (u8)clampS8((evenOutput3 + oddOutput3) >> 11);
|
||||
output[32] = (u8)clampS8((evenOutput3 - oddOutput3) >> 11);
|
||||
}
|
||||
workspaceCursor--;
|
||||
src--;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ struct DVDCommandBlock {
|
||||
DVDCommandBlock* prev; // 0x04
|
||||
|
||||
u32 command; // 0x08
|
||||
volatile s32 state;
|
||||
s32 state; // 0x0C
|
||||
|
||||
u32 offset; // 0x10
|
||||
u32 length; // 0x14
|
||||
|
||||
@@ -14,7 +14,7 @@ typedef GXTlutRegion* (*GXTlutRegionCallback)(u32 idx);
|
||||
|
||||
u32 GXGetTexBufferSize(u16 width, u16 height, u32 format, u8 mipmap, u8 max_lod);
|
||||
|
||||
void GXInitTexObj(const GXTexObj* obj, void* image_ptr, u16 width, u16 height, GXTexFmt format, GXTexWrapMode wrap_s, GXTexWrapMode wrap_t,
|
||||
void GXInitTexObj(GXTexObj* obj, void* image_ptr, u16 width, u16 height, GXTexFmt format, GXTexWrapMode wrap_s, GXTexWrapMode wrap_t,
|
||||
u8 mipmap);
|
||||
void GXInitTexObjCI(GXTexObj* obj, void* image_ptr, u16 width, u16 height, GXCITexFmt format, GXTexWrapMode wrap_s, GXTexWrapMode wrap_t, u8 mipmap,
|
||||
u32 tlut_name);
|
||||
|
||||
@@ -1894,7 +1894,7 @@ s32 DVDGetCommandBlockStatus(const DVDCommandBlock* block) {
|
||||
|
||||
if (block->state == DVD_STATE_COVER_CLOSED) {
|
||||
retVal = DVD_STATE_BUSY;
|
||||
} else if (block->state == DVD_STATE_COVER_OPENED) {
|
||||
} else if (((volatile DVDCommandBlock*)block)->state == DVD_STATE_COVER_OPENED) {
|
||||
retVal = DVD_STATE_NO_DISK;
|
||||
} else if (executing == &__DVDStopMotorCommandBlock) {
|
||||
next = __DVDGetNextWaitingQueue();
|
||||
@@ -1912,7 +1912,7 @@ s32 DVDGetCommandBlockStatus(const DVDCommandBlock* block) {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
retVal = block->state;
|
||||
retVal = ((volatile DVDCommandBlock*)block)->state;
|
||||
}
|
||||
|
||||
OSRestoreInterrupts(enabled);
|
||||
|
||||
@@ -8,11 +8,6 @@ static inline pf_u16 read_boot_u16(pf_u8* buf, pf_u32 offset) {
|
||||
return PF_SWAP_16(*(pf_u16*)&buf[(offset + 1) & ~1]);
|
||||
}
|
||||
|
||||
static inline pf_u32 read_partition_u32(const pf_u8* buf, pf_u32 offset) {
|
||||
return (((pf_u32)buf[offset + 2] << 16) + buf[offset]) +
|
||||
(((pf_u32)buf[offset + 3] << 24) + ((pf_u32)buf[offset + 1] << 8));
|
||||
}
|
||||
|
||||
pf_s32 pdm_part_is_master_boot_sector(pf_u8* buf, pf_u32 total, pf_bool* p_is_mbr) {
|
||||
pf_u32* p_start;
|
||||
pf_u32* p_count;
|
||||
@@ -25,8 +20,8 @@ pf_s32 pdm_part_is_master_boot_sector(pf_u8* buf, pf_u32 total, pf_bool* p_is_mb
|
||||
p_count = count;
|
||||
for (index = 0; index < 4; index++) {
|
||||
*p_start = 0;
|
||||
*p_start = read_partition_u32(buf, 454);
|
||||
*p_count = read_partition_u32(buf, 458);
|
||||
*p_start = MBR_WORD(buf, 454);
|
||||
*p_count = MBR_WORD(buf, 458);
|
||||
if (*p_start != 0 && *p_count != 0) {
|
||||
if (index == 0) { *p_is_mbr = 1; }
|
||||
} else {
|
||||
@@ -36,15 +31,11 @@ pf_s32 pdm_part_is_master_boot_sector(pf_u8* buf, pf_u32 total, pf_bool* p_is_mb
|
||||
p_count++;
|
||||
buf += 16;
|
||||
}
|
||||
p_start = start;
|
||||
p_count = count;
|
||||
for (index = 0; index < 4; index++) {
|
||||
if (*p_start + *p_count > total) {
|
||||
if (start[index] + count[index] > total) {
|
||||
if (index == 0) { *p_is_mbr = 0; }
|
||||
return 2;
|
||||
}
|
||||
p_start++;
|
||||
p_count++;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ void __GetImageTileCount(GXTexFmt fmt, u16 wd, u16 ht, u32* rowTiles, u32* colTi
|
||||
*cmpTiles = (fmt == GX_TF_RGBA8 || fmt == GX_TF_Z24X8) ? 2 : 1;
|
||||
}
|
||||
|
||||
void GXInitTexObj(const GXTexObj* obj, void* image_ptr, u16 width, u16 height, GXTexFmt format, GXTexWrapMode wrap_s, GXTexWrapMode wrap_t,
|
||||
void GXInitTexObj(GXTexObj* obj, void* image_ptr, u16 width, u16 height, GXTexFmt format, GXTexWrapMode wrap_s, GXTexWrapMode wrap_t,
|
||||
GXBool mipmap) {
|
||||
u32 imageBase;
|
||||
u32 maxLOD;
|
||||
|
||||
@@ -396,6 +396,8 @@ static void kbdProcKey(u32 key, u32 pressed, u32 channel) {
|
||||
kbdSendKey(&event);
|
||||
}
|
||||
|
||||
#pragma push
|
||||
#pragma opt_propagation off
|
||||
static void kbdProcMod(u32 key, u32 pressed, u32 channel) {
|
||||
KBDChannel* data;
|
||||
u32 modState;
|
||||
@@ -524,6 +526,7 @@ static void kbdProcMod(u32 key, u32 pressed, u32 channel) {
|
||||
finalState = modState | 0x1000;
|
||||
KBDSetModState(channel, finalState);
|
||||
}
|
||||
#pragma pop
|
||||
|
||||
static void kbdSendKey(KBDKeyEventData* event) {
|
||||
KBDChannel* data;
|
||||
|
||||
@@ -168,72 +168,86 @@ static const u32 AESiDecryptTable[] = {
|
||||
0xa8017139, 0xcb3de08, 0xb4e49cd8, 0x56c19064, 0xcb84617b, 0x32b670d5, 0x6c5c7448, 0xb85742d0
|
||||
};
|
||||
|
||||
#define ROTATE(x,n) (((x) << (n)) | ((x) >> (32 - (n))))
|
||||
#define ENCRYPT(state0,state1,state2,state3) (((ROTATE(AESiEncryptTable[((state1)>>16)&255],16) ^ ROTATE(AESiEncryptTable[(state0)>>24],24)) ^ AESiEncryptTable[(state3)&255]) ^ ROTATE(AESiEncryptTable[((state2)>>8)&255],8))
|
||||
#define DECRYPT(state0,state1,state2,state3) (((ROTATE(AESiDecryptTable[((state1)>>16)&255],16) ^ AESiDecryptTable[(state3)&255]) ^ ROTATE(AESiDecryptTable[(state0)>>24],24)) ^ ROTATE(AESiDecryptTable[((state2)>>8)&255],8))
|
||||
#define SUBSTITUTE(table,state0,state1,state2,state3) ((((u32)table[(state0)>>24]<<24) | table[(state3)&255]) | (((u32)table[((state1)>>16)&255]<<16) | ((u32)table[((state2)>>8)&255]<<8)))
|
||||
|
||||
#define DECRYPT_FINAL(table,state0,state1,state2,state3,key) ((table[(state3)&255] ^ ((u32)table[((state2)>>8)&255]<<8)) ^ (((u32)table[((state1)>>16)&255]<<16) ^ ((key) ^ ((u32)table[(state0)>>24]<<24))))
|
||||
#define ROTATE(x, n) __rlwinm((x), (n), 0, 31)
|
||||
#define ROUND_WORD(table, a, b, c, d) (ROTATE(table[(a) >> 24], 24) ^ ROTATE(table[((b) >> 16) & 255], 16) ^ ROTATE(table[((c) >> 8) & 255], 8) ^ table[(d) & 255])
|
||||
#define SUBSTITUTE_WORD(table, a, b, c, d) (((u32)table[(a) >> 24] << 24) | ((u32)table[((b) >> 16) & 255] << 16) | ((u32)table[((c) >> 8) & 255] << 8) | table[(d) & 255])
|
||||
#define DOUBLE_BYTES(x) ((((x) & 0x7f7f7f7f) << 1) ^ ((((x) & 0x80808080) >> 7) * 0x1b))
|
||||
|
||||
void AESiEncryptBlock(AESContext* context, u32* output, const u32* input) {
|
||||
const u32* key = context->keys;
|
||||
u32 rounds = context->rounds;
|
||||
const u32* key = context->keys + 4;
|
||||
u32 state0=input[0]^context->keys[0], state1=input[1]^context->keys[1], state2=input[2]^context->keys[2], state3=input[3]^context->keys[3];
|
||||
u32 state0 = input[0];
|
||||
u32 state1 = input[1];
|
||||
u32 state2 = input[2];
|
||||
u32 state3 = input[3];
|
||||
state0 ^= key[0];
|
||||
state1 ^= key[1];
|
||||
state2 ^= key[2];
|
||||
state3 ^= key[3];
|
||||
key += 4;
|
||||
while (--rounds != 0) {
|
||||
u32 nextState0=ENCRYPT(state0,state1,state2,state3);
|
||||
u32 nextState1=ENCRYPT(state1,state2,state3,state0);
|
||||
u32 nextState2=ENCRYPT(state2,state3,state0,state1);
|
||||
u32 nextState3=ENCRYPT(state3,state0,state1,state2);
|
||||
state0=nextState0^key[0]; state1=nextState1^key[1]; state2=nextState2^key[2]; state3=nextState3^key[3];
|
||||
u32 next0 = ROUND_WORD(AESiEncryptTable, state0, state1, state2, state3);
|
||||
u32 next1 = ROUND_WORD(AESiEncryptTable, state1, state2, state3, state0);
|
||||
u32 next2 = ROUND_WORD(AESiEncryptTable, state2, state3, state0, state1);
|
||||
u32 next3 = ROUND_WORD(AESiEncryptTable, state3, state0, state1, state2);
|
||||
state0 = next0 ^ key[0];
|
||||
state1 = next1 ^ key[1];
|
||||
state2 = next2 ^ key[2];
|
||||
state3 = next3 ^ key[3];
|
||||
key += 4;
|
||||
}
|
||||
output[0] = SUBSTITUTE(AESiSubShiftTable,state0,state1,state2,state3)^key[0];
|
||||
output[1] = SUBSTITUTE(AESiSubShiftTable,state1,state2,state3,state0)^key[1];
|
||||
output[2] = SUBSTITUTE(AESiSubShiftTable,state2,state3,state0,state1)^key[2];
|
||||
output[3] = SUBSTITUTE(AESiSubShiftTable,state3,state0,state1,state2)^key[3];
|
||||
output[0] = SUBSTITUTE_WORD(AESiSubShiftTable, state0, state1, state2, state3) ^ key[0];
|
||||
output[1] = SUBSTITUTE_WORD(AESiSubShiftTable, state1, state2, state3, state0) ^ key[1];
|
||||
output[2] = SUBSTITUTE_WORD(AESiSubShiftTable, state2, state3, state0, state1) ^ key[2];
|
||||
output[3] = SUBSTITUTE_WORD(AESiSubShiftTable, state3, state0, state1, state2) ^ key[3];
|
||||
}
|
||||
|
||||
#define DOUBLE_BYTES(x) ((((x)&0x7f7f7f7f)<<1) ^ ((((x)&0x80808080)>>7)*0x1b))
|
||||
static inline void AESiInvMixColumn(u32* word) {
|
||||
u32 value = *word;
|
||||
u32 timesTwo = DOUBLE_BYTES(value);
|
||||
u32 timesFour = DOUBLE_BYTES(timesTwo);
|
||||
u32 mixed = DOUBLE_BYTES(timesFour) ^ value;
|
||||
mixed ^= timesFour ^ ROTATE(mixed, 8);
|
||||
mixed ^= timesTwo ^ ROTATE(mixed, 8);
|
||||
mixed ^= value ^ ROTATE(mixed, 8);
|
||||
*word = mixed;
|
||||
}
|
||||
|
||||
void AESiDecryptBlock(AESContext* context, u32* output, const u32* input) {
|
||||
u32 rounds=context->rounds;
|
||||
u32* key=context->keys;
|
||||
u32 state1;
|
||||
u32 state0;
|
||||
u32 state2;
|
||||
u32 state3;
|
||||
key += rounds*4;
|
||||
u32* key = context->keys;
|
||||
u32 rounds = context->rounds;
|
||||
u32 state0, state1, state2, state3;
|
||||
key += rounds * 4;
|
||||
if (context->needsTransform) {
|
||||
u32 round;
|
||||
for (round=1; round<context->rounds; ++round) {
|
||||
for (round = 1; round < context->rounds; round++) {
|
||||
u32 word;
|
||||
for (word=0; word<4; ++word) {
|
||||
u32 value=context->keys[round*4 + word];
|
||||
u32 timesTwo=DOUBLE_BYTES(value);
|
||||
u32 timesFour=DOUBLE_BYTES(timesTwo);
|
||||
u32 timesNine=DOUBLE_BYTES(timesFour)^value;
|
||||
u32 mixed=(ROTATE(timesNine,8) ^ (timesNine ^ timesFour));
|
||||
mixed=(ROTATE(mixed,8) ^ (mixed ^ timesTwo));
|
||||
mixed=(ROTATE(mixed,8) ^ (mixed ^ value));
|
||||
context->keys[round*4 + word]=mixed;
|
||||
for (word = 0; word < 4; word++) {
|
||||
AESiInvMixColumn(&context->keys[round * 4 + word]);
|
||||
}
|
||||
}
|
||||
context->needsTransform=0;
|
||||
context->needsTransform = 0;
|
||||
}
|
||||
state0=input[0]^key[0]; state1=input[1]^key[1]; state2=input[2]^key[2]; state3=input[3]^key[3];
|
||||
key-=4;
|
||||
state0 = input[0] ^ key[0];
|
||||
state1 = input[1] ^ key[1];
|
||||
state2 = input[2] ^ key[2];
|
||||
state3 = input[3] ^ key[3];
|
||||
key -= 4;
|
||||
while (--rounds != 0) {
|
||||
u32 nextState0=DECRYPT(state0,state3,state2,state1);
|
||||
u32 nextState1=DECRYPT(state1,state0,state3,state2);
|
||||
u32 nextState2=DECRYPT(state2,state1,state0,state3);
|
||||
u32 nextState3=DECRYPT(state3,state2,state1,state0);
|
||||
state0=nextState0^key[0]; state1=nextState1^key[1]; state2=nextState2^key[2]; state3=nextState3^key[3];
|
||||
key-=4;
|
||||
u32 next0 = ROUND_WORD(AESiDecryptTable, state0, state3, state2, state1);
|
||||
u32 next1 = ROUND_WORD(AESiDecryptTable, state1, state0, state3, state2);
|
||||
u32 next2 = ROUND_WORD(AESiDecryptTable, state2, state1, state0, state3);
|
||||
u32 next3 = ROUND_WORD(AESiDecryptTable, state3, state2, state1, state0);
|
||||
state0 = next0 ^ key[0];
|
||||
state1 = next1 ^ key[1];
|
||||
state2 = next2 ^ key[2];
|
||||
state3 = next3 ^ key[3];
|
||||
key -= 4;
|
||||
}
|
||||
output[0]=DECRYPT_FINAL(AESiInvSubShiftTable,state0,state3,state2,state1,key[0]);
|
||||
output[1]=DECRYPT_FINAL(AESiInvSubShiftTable,state1,state0,state3,state2,key[1]);
|
||||
output[2]=DECRYPT_FINAL(AESiInvSubShiftTable,state2,state1,state0,state3,key[2]);
|
||||
output[3]=DECRYPT_FINAL(AESiInvSubShiftTable,state3,state2,state1,state0,key[3]);
|
||||
output[0] = key[0] ^ ((u32)AESiInvSubShiftTable[state0 >> 24] << 24) ^ ((u32)AESiInvSubShiftTable[(state3 >> 16) & 255] << 16) ^ ((u32)AESiInvSubShiftTable[(state2 >> 8) & 255] << 8) ^ AESiInvSubShiftTable[state1 & 255];
|
||||
output[1] = key[1] ^ ((u32)AESiInvSubShiftTable[state1 >> 24] << 24) ^ ((u32)AESiInvSubShiftTable[(state0 >> 16) & 255] << 16) ^ ((u32)AESiInvSubShiftTable[(state3 >> 8) & 255] << 8) ^ AESiInvSubShiftTable[state2 & 255];
|
||||
output[2] = key[2] ^ ((u32)AESiInvSubShiftTable[state2 >> 24] << 24) ^ ((u32)AESiInvSubShiftTable[(state1 >> 16) & 255] << 16) ^ ((u32)AESiInvSubShiftTable[(state0 >> 8) & 255] << 8) ^ AESiInvSubShiftTable[state3 & 255];
|
||||
output[3] = key[3] ^ ((u32)AESiInvSubShiftTable[state3 >> 24] << 24) ^ ((u32)AESiInvSubShiftTable[(state2 >> 16) & 255] << 16) ^ ((u32)AESiInvSubShiftTable[(state1 >> 8) & 255] << 8) ^ AESiInvSubShiftTable[state0 & 255];
|
||||
}
|
||||
|
||||
BOOL NETAESCreateEx(AESContext* context, const void* key, u32 keyLength, const void* iv, const AESBlockMode* mode) {
|
||||
|
||||
@@ -54,54 +54,50 @@ static u32 BannerBuffer = 0;
|
||||
static u32 BannerAvailable = 0;
|
||||
static u32 Allocator = 0;
|
||||
volatile BOOL StartingGame = FALSE;
|
||||
static u32 RestartRequested = 0;
|
||||
static u32 PartitionOpen = 0;
|
||||
static vu32 RestartRequested = 0;
|
||||
static vu32 PartitionOpen = 0;
|
||||
static u32 CacheSeekComplete = 0;
|
||||
static u32 LoadingTitle = 0;
|
||||
BOOL FatalErrorFlag = FALSE;
|
||||
static vu32 LoadingTitle = 0;
|
||||
volatile BOOL FatalErrorFlag = FALSE;
|
||||
BOOL RetryErrorFlag = FALSE;
|
||||
BOOL UpdateErrorFlag = FALSE;
|
||||
BOOL AbortFlag = FALSE;
|
||||
volatile BOOL AbortFlag = FALSE;
|
||||
volatile int CacheFailed = 0;
|
||||
volatile int RegionValid = 0;
|
||||
static volatile int NandPending = 0;
|
||||
static vu32 CancelNand = 0;
|
||||
static vu32 LowReadResult = 0;
|
||||
static u32 CacheCommandComplete = 0;
|
||||
static u32 AudioBufferUnconfigured = 0;
|
||||
static u64 ResetTime = 0;
|
||||
static u64 SpinupDeadline = 0;
|
||||
u64 CoverPollTime = 0;
|
||||
u32 DriveWasReset = 0;
|
||||
static u32 TitleTicketView = 0;
|
||||
static u32 CurrentTmd = 0;
|
||||
u32 TitleCode = 0;
|
||||
u32 RequiredIosHigh = 0;
|
||||
u32 RequiredIosLow = 0;
|
||||
u32 GamePartition = 0;
|
||||
u32 UpdatePartition = 0;
|
||||
u32 PartitionCursor = 0;
|
||||
u32 DataToc = 0;
|
||||
u64 GameToc = 0;
|
||||
u32 CoverOpenTimeHigh = 0;
|
||||
u32 CoverOpenTimeLow = 0;
|
||||
vu32 NandTransferred = 0;
|
||||
vu32 NandLength = 0;
|
||||
u8 *NandBuffer = NULL;
|
||||
NANDFileInfo *NandFile = NULL;
|
||||
vu32 NandOperation = 0;
|
||||
volatile NANDCallback NandCompletion = NULL;
|
||||
u32 LoaderOffset = 0;
|
||||
vu32 LoaderLength = 0;
|
||||
u32 LoaderAddress = 0;
|
||||
vu32 CacheLength = 0;
|
||||
static vu32 BannerLength = 0;
|
||||
static vu32 DvdTransferLength = 0;
|
||||
static vu32 DvdTransferred = 0;
|
||||
static u32 *DvdProgress = 0;
|
||||
static u32 LoaderClose = 0;
|
||||
static u32 LoaderMain = 0;
|
||||
static u32 LoaderInit = 0;
|
||||
static u32 LoaderInit;
|
||||
static u32 LoaderMain;
|
||||
static u32 LoaderClose;
|
||||
static u32 *DvdProgress;
|
||||
static vu32 DvdTransferred;
|
||||
static vu32 DvdTransferLength;
|
||||
static vu32 BannerLength;
|
||||
vu32 CacheLength;
|
||||
u32 LoaderAddress;
|
||||
vu32 LoaderLength;
|
||||
u32 LoaderOffset;
|
||||
volatile NANDCallback NandCompletion;
|
||||
vu32 NandOperation;
|
||||
NANDFileInfo *NandFile;
|
||||
u8 *NandBuffer;
|
||||
vu32 NandLength;
|
||||
vu32 NandTransferred;
|
||||
OSTime CoverOpenTime;
|
||||
u64 GameToc;
|
||||
u32 DataToc;
|
||||
u32 PartitionCursor;
|
||||
u32 UpdatePartition;
|
||||
u32 GamePartition;
|
||||
u64 RequiredIos;
|
||||
u32 TitleCode;
|
||||
static u32 CurrentTmd;
|
||||
static u32 TitleTicketView;
|
||||
u32 DriveWasReset;
|
||||
u64 CoverPollTime;
|
||||
static u64 SpinupDeadline;
|
||||
static u64 ResetTime;
|
||||
|
||||
|
||||
void BS2Report(const char *msg, ...) {
|
||||
@@ -623,7 +619,7 @@ void BS2StartGame() {
|
||||
u32 (*entry)(void);
|
||||
|
||||
StartingGame = TRUE;
|
||||
while (CoverBlock.state != DVD_STATE_IDLE) {
|
||||
while (((volatile DVDCommandBlock *)&CoverBlock)->state != DVD_STATE_IDLE) {
|
||||
}
|
||||
|
||||
BS2Report("BS2StartGame(1)\n");
|
||||
@@ -667,8 +663,8 @@ void BS2StartGame() {
|
||||
__OSWriteStateFlags(&stateFlags);
|
||||
__OSClearRTCFlags();
|
||||
|
||||
titleType = RequiredIosHigh;
|
||||
titleCode = RequiredIosLow;
|
||||
titleType = (u32)(RequiredIos >> 32);
|
||||
titleCode = (u32)RequiredIos;
|
||||
ticketCount = 1;
|
||||
ticketViews = TicketViews;
|
||||
if ((titleCode | titleType) == 0) {
|
||||
@@ -854,7 +850,7 @@ void BS2StartGCGame() {
|
||||
OSTime time;
|
||||
|
||||
StartingGame = TRUE;
|
||||
while (CoverBlock.state != DVD_STATE_IDLE) {
|
||||
while (((volatile DVDCommandBlock *)&CoverBlock)->state != DVD_STATE_IDLE) {
|
||||
}
|
||||
|
||||
soundMode = SCGetSoundMode();
|
||||
@@ -982,9 +978,7 @@ static BOOL CheckDVDCommandStatus(DVDCommandBlock *block) {
|
||||
case 4:
|
||||
case 5:
|
||||
if (State == 7 || State == 9 || State == 10) {
|
||||
u64 systemTime = __OSGetSystemTime();
|
||||
CoverOpenTimeLow = (u32)systemTime;
|
||||
CoverOpenTimeHigh = (u32)(systemTime >> 32);
|
||||
CoverOpenTime = __OSGetSystemTime();
|
||||
State = BS2_STT_66;
|
||||
} else {
|
||||
State = BS2_STT_NO_DISK;
|
||||
@@ -1099,6 +1093,8 @@ static void BS2NANDDivideWriteAsync(NANDFileInfo *info, const void *buffer, u32
|
||||
}
|
||||
|
||||
static BOOL CheckBS2CommandStatus() {
|
||||
static u32 CacheCommandComplete = 0;
|
||||
|
||||
if (CheckDVDCommandStatus(&Block) == 0) {
|
||||
BS2Report("DVD command is issuing\n");
|
||||
return 0;
|
||||
@@ -1181,8 +1177,8 @@ static BOOL CheckBS2CommandStatus() {
|
||||
if (BS2BootCaching != 0) {
|
||||
BS2Report("Write partition ifno\n");
|
||||
NandPending = 1;
|
||||
CacheLength += OSRoundUp32B(((DVDGameTOC *)DataToc)->partitionCount * sizeof(DVDPartitionInfo)) + 32;
|
||||
CacheCommandComplete = 1;
|
||||
CacheLength += OSRoundUp32B(((DVDGameTOC *)DataToc)->partitionCount * sizeof(DVDPartitionInfo)) + 32;
|
||||
if ((unsigned int)CacheLength > 0xb00000) {
|
||||
BS2NANDCallback(-1, NULL);
|
||||
return 1;
|
||||
@@ -1324,6 +1320,7 @@ static void BS2ReadDiskID(void *buffer, s32 length, u32 offset) {
|
||||
}
|
||||
|
||||
BS2State BS2Tick() {
|
||||
static u32 AudioBufferUnconfigured;
|
||||
u32 interruptsEnabled = OSDisableInterrupts();
|
||||
u32 loaderAddress;
|
||||
u32 loaderLength;
|
||||
@@ -1338,7 +1335,6 @@ BS2State BS2Tick() {
|
||||
u64 currentTime;
|
||||
BOOL regionMatches;
|
||||
char productRegion;
|
||||
u32 iosHigh;
|
||||
char *ticketByte;
|
||||
u32 entryCount;
|
||||
DVDGameTOC *dataToc;
|
||||
@@ -1351,17 +1347,16 @@ BS2State BS2Tick() {
|
||||
BS2Report("Drive Reset : %d\n", BS2DriveReset);
|
||||
BS2Report("Wait Spinup : %d\n", BS2WaitSpinup);
|
||||
BS2Report("Boot From Cache : %d\n", BS2BootFromCache);
|
||||
DvdProgress = (u32 *)&(*(u32 *)0x800030d4);
|
||||
DvdProgress = (u32 *)0x800030d4;
|
||||
PartitionParams.numTmdBytes = 0;
|
||||
PartitionParams.numCertBytes = 0;
|
||||
PartitionParams.dataWordOffset = 0;
|
||||
(*(u32 *)0x800030d4) = 0;
|
||||
*DvdProgress = 0;
|
||||
DvdTransferred = 0;
|
||||
DvdTransferLength = 0;
|
||||
status = BS2NoDisk;
|
||||
AudioBufferUnconfigured = 1;
|
||||
CoverBlock.state = 0;
|
||||
if (status != 0)
|
||||
if (BS2NoDisk != 0)
|
||||
State = BS2_STT_NO_DISK;
|
||||
else if (BS2DriveReset != 0)
|
||||
State = BS2_STT_2;
|
||||
@@ -1440,13 +1435,14 @@ BS2State BS2Tick() {
|
||||
case 5:
|
||||
status = CheckBS2CommandStatus();
|
||||
if (status != 0) {
|
||||
if ((((const OSBootInfo *)0x80000000)->consoleType & 0xf0000000) == 0) {
|
||||
OSBootInfo *bootInfo = (OSBootInfo *)OSPhysicalToCached(OS_ADDR_BOOT_INFO);
|
||||
|
||||
if ((bootInfo->consoleType & 0xf0000000) == 0) {
|
||||
__OSDeviceCode = 0x8002;
|
||||
State = BS2_STT_8;
|
||||
} else {
|
||||
__OSDeviceCode = DriveInfo.deviceCode | 0x8000;
|
||||
State = BS2_STT_8;
|
||||
}
|
||||
State = BS2_STT_8;
|
||||
}
|
||||
break;
|
||||
case 6:
|
||||
@@ -1882,9 +1878,7 @@ invalidRvlRegion:
|
||||
(u32)((ESTitleMeta *)CurrentTmd)->head.sysVersion);
|
||||
BS2Report("Title ID ... 0x%08X%08X\n", (u32)(((ESTitleMeta *)CurrentTmd)->head.titleId >> 32),
|
||||
(u32)((ESTitleMeta *)CurrentTmd)->head.titleId);
|
||||
iosHigh = (u32)(((ESTitleMeta *)CurrentTmd)->head.sysVersion >> 32);
|
||||
RequiredIosLow = (u32)((ESTitleMeta *)CurrentTmd)->head.sysVersion;
|
||||
RequiredIosHigh = iosHigh;
|
||||
RequiredIos = ((ESTitleMeta *)CurrentTmd)->head.sysVersion;
|
||||
titleCode = (u32)((ESTitleMeta *)CurrentTmd)->head.titleId;
|
||||
TitleCode = titleCode;
|
||||
if (((ESTitleMeta *)CurrentTmd)->head.sysVersion == 0x0000000100000010ULL) {
|
||||
@@ -2072,7 +2066,8 @@ invalidRvlRegion:
|
||||
} else {
|
||||
if ((BannerBuffer != 0) && (BannerLength != 0)) {
|
||||
if (BannerLength < ((bannerFile.length + 0x1fU) & 0xffffffe0))
|
||||
OSPanic("BS2Mach.c", 0x12d3, "BS2 ERROR >>> Banner buffer is not enough to load banner file (0x%08x)");
|
||||
OSPanic("BS2Mach.c", 0x12d3, "BS2 ERROR >>> Banner buffer is not enough to load banner file (0x%08x)",
|
||||
bannerFile.length);
|
||||
BS2Report("BannerBufferAddr : %08X\n", BannerBuffer);
|
||||
} else
|
||||
OSPanic("BS2Mach.c", 0x12da, "BS2 ERROR >>> MEMAllocator and banner buffer is not set");
|
||||
@@ -2176,7 +2171,7 @@ invalidRvlRegion:
|
||||
BS2BootFromCache = 0;
|
||||
BS2BootCaching = 1;
|
||||
LoadingTitle = 0;
|
||||
switch (Block.state) {
|
||||
switch (((volatile DVDCommandBlock *)&Block)->state) {
|
||||
case 4:
|
||||
case 5:
|
||||
CheckDVDCommandStatus(&Block);
|
||||
@@ -2321,7 +2316,7 @@ invalidRvlRegion:
|
||||
break;
|
||||
case 0x42:
|
||||
currentTime = __OSGetSystemTime();
|
||||
if ((OSTime)(currentTime - (((u64)CoverOpenTimeHigh << 32) | CoverOpenTimeLow)) < OSMillisecondsToTicks((OSTime)350))
|
||||
if ((OSTime)(currentTime - CoverOpenTime) < OSMillisecondsToTicks((OSTime)350))
|
||||
break;
|
||||
currentTime = __OSGetSystemTime();
|
||||
CoverPollTime = currentTime;
|
||||
|
||||
@@ -9,12 +9,11 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
static u32 Flags0[BS2_UPDATE_ENTRY_COUNT] = {0};
|
||||
static u32 Flags1[BS2_UPDATE_ENTRY_COUNT] = {0};
|
||||
static OSThread Thread = {0};
|
||||
static u8 ThreadStack[4096] = {0};
|
||||
static BS2UpdateHeader UpdateHeader0 ALIGN32 = {0};
|
||||
static BS2UpdateHeader UpdateHeader1 ALIGN32 = {0};
|
||||
static u32 Flags1[BS2_UPDATE_ENTRY_COUNT];
|
||||
static OSThread Thread;
|
||||
static u8 ThreadStack[4096];
|
||||
static BS2UpdateHeader UpdateHeader0 ALIGN32;
|
||||
static BS2UpdateHeader UpdateHeader1 ALIGN32;
|
||||
|
||||
BS2UpdateEntry DiscEntries[BS2_UPDATE_ENTRY_COUNT] ADDRESS(0x80480000);
|
||||
|
||||
@@ -50,32 +49,8 @@ char* getSuffix(const char* path) {
|
||||
return suffix;
|
||||
}
|
||||
|
||||
static void* UpdateThread(void* argument);
|
||||
|
||||
void BS2UpdateInit(void* allocator) {
|
||||
BS2Report("initialize BS2Update\n");
|
||||
ConsoleType = OSGetConsoleType();
|
||||
VersionES = __OSGetHollywoodRev();
|
||||
VersionMEM2 = OSGetPhysicalMem2Size();
|
||||
__OSGetIOSRev((OSIOSRev*)&VersionIOS);
|
||||
BS2Report("Console Type : %08X\n", ConsoleType);
|
||||
BS2Report("Hollywood Rev : %08X\n", VersionES);
|
||||
BS2Report("MEM2 Size : %08X\n", VersionMEM2);
|
||||
MemAllocator = allocator;
|
||||
State = 0;
|
||||
CurrentEntry = NULL;
|
||||
pEntries = NULL;
|
||||
EntriesCount = 0;
|
||||
memset(DiscEntries, 0, 0x40000);
|
||||
memset(EntriesToImport, 0, 0x40000);
|
||||
memset(Flags1, 0, sizeof(Flags1));
|
||||
BS2Report("Create update thread\n");
|
||||
OSCreateThread(&Thread, UpdateThread, NULL, ThreadStack + sizeof(ThreadStack),
|
||||
sizeof(ThreadStack), 31, OS_THREAD_ATTR_DETACH);
|
||||
OSResumeThread(&Thread);
|
||||
}
|
||||
|
||||
static inline u32 BS2SelectUpdateEntries(void) {
|
||||
static u32 Flags0[BS2_UPDATE_ENTRY_COUNT];
|
||||
BOOL missingFile;
|
||||
u32 index;
|
||||
u32 selectedCount;
|
||||
@@ -418,6 +393,31 @@ selection_complete:
|
||||
return selectedCount;
|
||||
}
|
||||
|
||||
static void* UpdateThread(void* argument);
|
||||
|
||||
void BS2UpdateInit(void* allocator) {
|
||||
BS2Report("initialize BS2Update\n");
|
||||
ConsoleType = OSGetConsoleType();
|
||||
VersionES = __OSGetHollywoodRev();
|
||||
VersionMEM2 = OSGetPhysicalMem2Size();
|
||||
__OSGetIOSRev((OSIOSRev*)&VersionIOS);
|
||||
BS2Report("Console Type : %08X\n", ConsoleType);
|
||||
BS2Report("Hollywood Rev : %08X\n", VersionES);
|
||||
BS2Report("MEM2 Size : %08X\n", VersionMEM2);
|
||||
MemAllocator = allocator;
|
||||
State = 0;
|
||||
CurrentEntry = NULL;
|
||||
pEntries = NULL;
|
||||
EntriesCount = 0;
|
||||
memset(DiscEntries, 0, 0x40000);
|
||||
memset(EntriesToImport, 0, 0x40000);
|
||||
memset(Flags1, 0, sizeof(Flags1));
|
||||
BS2Report("Create update thread\n");
|
||||
OSCreateThread(&Thread, UpdateThread, NULL, ThreadStack + sizeof(ThreadStack),
|
||||
sizeof(ThreadStack), 31, OS_THREAD_ATTR_DETACH);
|
||||
OSResumeThread(&Thread);
|
||||
}
|
||||
|
||||
static void* UpdateThread(void* argument) {
|
||||
u32 index;
|
||||
s32 importResult;
|
||||
|
||||
@@ -647,7 +647,7 @@ static s32 CHANSVmParseInt(const CHANSVmObjHdr* obj, s32 base, u64* out) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
CHANSVmObjHdr* CHANSVmConvertToIntFromFloat(CHANSVm* vm, CHANSVmObjType type, CHANSVmObjHdr* object) {
|
||||
CHANSVmObjHdr* CHANSVmConvertToIntFromFloat(CHANSVm* vm, CHANSVmObjType type, const CHANSVmObjHdr* object) {
|
||||
// Convert to int from float
|
||||
CHANSVmObjHdr* newObj = CHANSVmNewObject(vm, vmFalse, vmNull, CHANS_VM_OBJ_TYPE_INTEGER, 0);
|
||||
if (newObj != vmNull) {
|
||||
@@ -660,7 +660,7 @@ CHANSVmObjHdr* CHANSVmConvertToIntFromFloat(CHANSVm* vm, CHANSVmObjType type, CH
|
||||
return newObj;
|
||||
}
|
||||
|
||||
CHANSVmObjHdr* CHANSVmConvertToIntFromStr(CHANSVm* vm, CHANSVmObjType type, CHANSVmObjHdr* object) {
|
||||
CHANSVmObjHdr* CHANSVmConvertToIntFromStr(CHANSVm* vm, CHANSVmObjType type, const CHANSVmObjHdr* object) {
|
||||
CHANSVmObjHdr* newObj = CHANSVmNewObject(vm, vmFalse, vmNull, CHANS_VM_OBJ_TYPE_INTEGER, 0);
|
||||
if (newObj != vmNull && !CHANSVmParseInt(object, 0, (u64*)&newObj->value.int_v)) {
|
||||
newObj = vmNull;
|
||||
@@ -668,11 +668,11 @@ CHANSVmObjHdr* CHANSVmConvertToIntFromStr(CHANSVm* vm, CHANSVmObjType type, CHAN
|
||||
return newObj;
|
||||
}
|
||||
|
||||
CHANSVmObjHdr* CHANSVmConvertToIntFromArray(CHANSVm* vm, CHANSVmObjType type, CHANSVmObjHdr* object) {
|
||||
CHANSVmObjHdr* CHANSVmConvertToIntFromArray(CHANSVm* vm, CHANSVmObjType type, const CHANSVmObjHdr* object) {
|
||||
return vmNull;
|
||||
}
|
||||
|
||||
CHANSVmObjHdr* CHANSVmConvertToFloatFromUndefined(CHANSVm* vm, CHANSVmObjType type, CHANSVmObjHdr* object) {
|
||||
CHANSVmObjHdr* CHANSVmConvertToFloatFromUndefined(CHANSVm* vm, CHANSVmObjType type, const CHANSVmObjHdr* object) {
|
||||
CHANSVmObjHdr* result = CHANSVmNewObject(vm, vmFalse, vmNull, CHANS_VM_OBJ_TYPE_FLOAT, 0);
|
||||
if (result != vmNull) {
|
||||
result->value.float_v = VM_NAN;
|
||||
@@ -680,7 +680,7 @@ CHANSVmObjHdr* CHANSVmConvertToFloatFromUndefined(CHANSVm* vm, CHANSVmObjType ty
|
||||
return result;
|
||||
}
|
||||
|
||||
CHANSVmObjHdr* CHANSVmConvertToFloatFromInt(CHANSVm* vm, CHANSVmObjType type, CHANSVmObjHdr* intObj) {
|
||||
CHANSVmObjHdr* CHANSVmConvertToFloatFromInt(CHANSVm* vm, CHANSVmObjType type, const CHANSVmObjHdr* intObj) {
|
||||
CHANSVmObjHdr* result = CHANSVmNewObject(vm, vmFalse, vmNull, CHANS_VM_OBJ_TYPE_FLOAT, 0);
|
||||
if (result != vmNull) {
|
||||
result->value.float_v = VmIntToFloat(intObj->value.int_v);
|
||||
@@ -716,7 +716,7 @@ const CHANSVmFloatConstantList scFloatConstantList[] = {
|
||||
char scFloatPrintfFmt[] = "%.16lg";
|
||||
// clang-format on
|
||||
|
||||
static inline s32 CHANSVmParseFloat(CHANSVmObjHdr* obj, f64* out) {
|
||||
static inline s32 CHANSVmParseFloat(const CHANSVmObjHdr* obj, f64* out) {
|
||||
u8 type = obj->type;
|
||||
u32 stringLength;
|
||||
u32 charCount;
|
||||
@@ -768,7 +768,7 @@ static inline s32 CHANSVmParseFloat(CHANSVmObjHdr* obj, f64* out) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
CHANSVmObjHdr* CHANSVmConvertToFloatFromStr(CHANSVm* vm, CHANSVmObjType type, CHANSVmObjHdr* object) {
|
||||
CHANSVmObjHdr* CHANSVmConvertToFloatFromStr(CHANSVm* vm, CHANSVmObjType type, const CHANSVmObjHdr* object) {
|
||||
// Convert string keyword into float value
|
||||
CHANSVmObjHdr* newObj = CHANSVmNewObject(vm, vmFalse, vmNull, CHANS_VM_OBJ_TYPE_FLOAT, 0);
|
||||
|
||||
@@ -778,7 +778,7 @@ CHANSVmObjHdr* CHANSVmConvertToFloatFromStr(CHANSVm* vm, CHANSVmObjType type, CH
|
||||
return newObj;
|
||||
}
|
||||
|
||||
CHANSVmObjHdr* CHANSVmConvertToStrFromUndefined(CHANSVm* vm, CHANSVmObjType type, CHANSVmObjHdr* object) {
|
||||
CHANSVmObjHdr* CHANSVmConvertToStrFromUndefined(CHANSVm* vm, CHANSVmObjType type, const CHANSVmObjHdr* object) {
|
||||
return (CHANSVmObjHdr*)CHANSVmConstStringObjectUndefined_;
|
||||
}
|
||||
|
||||
@@ -796,7 +796,7 @@ static int VmToStrFromInt(vmWString output, vmSize length, vmInteger integer) {
|
||||
return len;
|
||||
}
|
||||
|
||||
CHANSVmObjHdr* CHANSVmConvertToStrFromInt(CHANSVm* vm, CHANSVmObjType type, CHANSVmObjHdr* object) {
|
||||
CHANSVmObjHdr* CHANSVmConvertToStrFromInt(CHANSVm* vm, CHANSVmObjType type, const CHANSVmObjHdr* object) {
|
||||
CHANSVmObjHdr* newObject = CHANSVmNewObject(vm, vmFalse, vmNull, CHANS_VM_OBJ_TYPE_STRING, VM_STR_LENGTH(64));
|
||||
if (newObject) {
|
||||
vmS32 len = VmToStrFromInt(newObject->value.wstring_v->spData, 64, object->value.int_v);
|
||||
@@ -812,7 +812,7 @@ error:
|
||||
return vmNull;
|
||||
}
|
||||
|
||||
CHANSVmObjHdr* CHANSVmConvertToStrFromFloat(CHANSVm* vm, CHANSVmObjType type, CHANSVmObjHdr* value) {
|
||||
CHANSVmObjHdr* CHANSVmConvertToStrFromFloat(CHANSVm* vm, CHANSVmObjType type, const CHANSVmObjHdr* value) {
|
||||
const CHANSVmObjHdr* base;
|
||||
CHANSVmObjHdr* newObj;
|
||||
s32 result;
|
||||
@@ -843,13 +843,13 @@ error:
|
||||
return vmNull;
|
||||
}
|
||||
|
||||
static CHANSVmObjHdr* VmArrayJoinCommon(CHANSVm* vm, u32 retObjAddr, CHANSVmObjHdr* object, u32 separatorAddr, u32 separatorLen);
|
||||
static CHANSVmObjHdr* VmArrayJoinCommon(CHANSVm* vm, u32 retObjAddr, const CHANSVmObjHdr* object, u32 separatorAddr, u32 separatorLen);
|
||||
|
||||
CHANSVmObjHdr* CHANSVmConvertToStrFromArray(CHANSVm* vm, CHANSVmObjType type, CHANSVmObjHdr* object) {
|
||||
CHANSVmObjHdr* CHANSVmConvertToStrFromArray(CHANSVm* vm, CHANSVmObjType type, const CHANSVmObjHdr* object) {
|
||||
return VmArrayJoinCommon(vm, 0, object, 0, 0);
|
||||
}
|
||||
|
||||
CHANSVmObjHdr* CHANSVmConvertObjectTypeError(CHANSVm* vm, CHANSVmObjType type, CHANSVmObjHdr* object) {
|
||||
CHANSVmObjHdr* CHANSVmConvertObjectTypeError(CHANSVm* vm, CHANSVmObjType type, const CHANSVmObjHdr* object) {
|
||||
CHANS_VM_PRINTF(1176, ", type to %d from %d\n", type, object->type);
|
||||
return vmNull;
|
||||
}
|
||||
@@ -1962,7 +1962,7 @@ error:
|
||||
return vmFalse;
|
||||
}
|
||||
|
||||
static ArrayChunk* VmArraySeekTop(CHANSVmObjHdr* array) {
|
||||
static ArrayChunk* VmArraySeekTop(const CHANSVmObjHdr* array) {
|
||||
ArrayChunk* cur = vmNull;
|
||||
if (array != vmNull) {
|
||||
cur = *array->value.ptr_v;
|
||||
@@ -2089,7 +2089,7 @@ u32 CHANSVmGetArrayLength(CHANSVm* vm, CHANSVmObjHdr* array) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static u32 VmArrayJoinEstimateStrSize(CHANSVmObjHdr* object, u32 sepLen) {
|
||||
static u32 VmArrayJoinEstimateStrSize(const CHANSVmObjHdr* object, u32 sepLen) {
|
||||
ArrayChunk* chunk;
|
||||
u32 total;
|
||||
u32 countInChunk;
|
||||
@@ -2137,7 +2137,7 @@ error:
|
||||
return 0;
|
||||
}
|
||||
|
||||
static u32 VmArrayJoinSub(CHANSVmObjHdr* obj, CHANSVmObjHdr* array, wchar_t* separator, u32 sepLen, u32 bufSize, u32 offset) {
|
||||
static u32 VmArrayJoinSub(CHANSVmObjHdr* obj, const CHANSVmObjHdr* array, wchar_t* separator, u32 sepLen, u32 bufSize, u32 offset) {
|
||||
ArrayChunk* chunk;
|
||||
u32 countInChunk;
|
||||
u32 savedOffset;
|
||||
@@ -2216,7 +2216,7 @@ error:
|
||||
return 0;
|
||||
}
|
||||
|
||||
CHANSVmObjHdr* VmArrayJoinCommon(CHANSVm* vm, u32 retObjAddr, CHANSVmObjHdr* object, u32 separatorAddr, u32 separatorLen) {
|
||||
CHANSVmObjHdr* VmArrayJoinCommon(CHANSVm* vm, u32 retObjAddr, const CHANSVmObjHdr* object, u32 separatorAddr, u32 separatorLen) {
|
||||
CHANSVmObjHdr* result;
|
||||
u32 estSize;
|
||||
u32 actualLen;
|
||||
@@ -2581,10 +2581,9 @@ VmCtorDefine(Date) {
|
||||
|
||||
#define RANGE(val, min, max) ((val) >= (min) && (val) <= (max))
|
||||
|
||||
const char* VmDateDayTbl[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
|
||||
const char* VmDateMonthTbl[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
|
||||
|
||||
VmDtorDefine(Date) {
|
||||
static const char* VmDateDayTbl[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
|
||||
static const char* VmDateMonthTbl[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
|
||||
char buffer[32];
|
||||
unsigned int uv;
|
||||
OSCalendarTime date;
|
||||
@@ -4294,22 +4293,15 @@ VmMethodDefine(Blob, GetHexString) {
|
||||
|
||||
if (CHANSVmBlobHasSpace(blob, count) && CHANSVmNewObject(VmInst, vmFalse, VmReturnObj, CHANS_VM_OBJ_TYPE_STRING, count * 4) != vmNull) {
|
||||
wchar_t* dest = (wchar_t*)VmGetStrFromObjHdr(VmReturnObj);
|
||||
u8* src = blob->pData;
|
||||
u32 offset = blob->offset;
|
||||
u32 destOff = 0;
|
||||
u32 i = 0;
|
||||
u8* src = blob->pData + blob->offset;
|
||||
char* hexTbl = scHexDigitsPtr;
|
||||
u32 byteIndex;
|
||||
|
||||
src += offset;
|
||||
|
||||
for (byteIndex = 0; byteIndex < count; byteIndex++) {
|
||||
u32 lowDigitIndex = i + 1;
|
||||
i += 2;
|
||||
dest[destOff] = (wchar_t)(s8)hexTbl[(u32)*src >> 4 & 0xF];
|
||||
destOff += 2;
|
||||
dest[lowDigitIndex] = (wchar_t)(s8)hexTbl[(u32)*src & 0xF];
|
||||
src++;
|
||||
int highDigitIndex = byteIndex * 2;
|
||||
int lowDigitIndex = byteIndex * 2 + 1;
|
||||
dest[highDigitIndex] = (wchar_t)(s8)hexTbl[(u32)src[byteIndex] >> 4 & 0xF];
|
||||
dest[lowDigitIndex] = (wchar_t)(s8)hexTbl[(u32)src[byteIndex] & 0xF];
|
||||
}
|
||||
blob->offset += count;
|
||||
return vmTrue;
|
||||
@@ -4974,50 +4966,52 @@ exit:
|
||||
return curPos;
|
||||
}
|
||||
|
||||
static inline void VmBlobCopyPadded(BlobHeader* parentBlob, const BlobHeader* srcBlob, s32 copySize) {
|
||||
u32 srcOff;
|
||||
u32 dataSize;
|
||||
u8* dest;
|
||||
|
||||
srcOff = srcBlob->offset;
|
||||
dataSize = srcBlob->size - srcOff;
|
||||
dest = parentBlob->pData + parentBlob->offset;
|
||||
if (dataSize > copySize) {
|
||||
dataSize = copySize;
|
||||
}
|
||||
memmove(dest, srcBlob->pData + srcOff, dataSize);
|
||||
if (dataSize < copySize) {
|
||||
memset(dest + dataSize, 0, copySize - dataSize);
|
||||
}
|
||||
parentBlob->offset += copySize;
|
||||
}
|
||||
|
||||
static vmBoolInt VmBlobPackCommon(CHANSVm* VmInst, CHANSVmObjHdr* VmParentObj, CHANSVmObjHdr* VmReturnObj, vmU32 flag) {
|
||||
u32 packBuf[2];
|
||||
s32 writeHexBufSize;
|
||||
u32 writeArgCount;
|
||||
CHANSVmObjHdr* measureStringObj;
|
||||
s32 measureBlobCount;
|
||||
u32 writeFmtPos;
|
||||
u32 writeHexI;
|
||||
BlobHeader* parentBlob;
|
||||
CHANSVmObjHdr* argStr;
|
||||
CHANSVmObjHdr* measureHexObj;
|
||||
CHANSVmObjHdr* writeStringStrObj;
|
||||
u32 writeIntegerValHigh;
|
||||
CHANSVmObjHdr* writeHexStrObj;
|
||||
u32 writeIntegerValLow;
|
||||
u8* writeStringDest;
|
||||
const wchar_t* fmtStr;
|
||||
u8* writeHexSrcData;
|
||||
u32 writeStringStrLen;
|
||||
u32 fmtLen;
|
||||
CHANSVmObjHdr* argArr;
|
||||
u8* writeHexDest;
|
||||
s32 measureHexCount;
|
||||
s32 writeIntegerCount;
|
||||
BlobHeader* measureBlobSrcBlob;
|
||||
u32 writeIntegerI;
|
||||
s32 writeStringCount;
|
||||
CHANSVmObjHdr* writeBlobObj;
|
||||
CHANSVmObjHdr* measureBlobObj;
|
||||
s32 writeBlobCopySize;
|
||||
s32 measureIntegerCount;
|
||||
u32 writeBlobSrcOff;
|
||||
u32 writeBlobDataSize;
|
||||
u8* writeBlobDest;
|
||||
CHANSVmObjHdr* writeIntegerIntObj;
|
||||
BlobHeader* writeBlobSrcBlob;
|
||||
u8* writeStringSrcData;
|
||||
u32 writeStringCharCount;
|
||||
u32 fmtPos;
|
||||
u32 argCount;
|
||||
u32 totalSize;
|
||||
s32 count;
|
||||
u32 i;
|
||||
CHANSVmObjHdr* obj;
|
||||
BlobHeader* srcBlob;
|
||||
s32 copySize;
|
||||
CHANSVmObjHdr* strObj;
|
||||
u8* srcData;
|
||||
u32 charCount;
|
||||
u32 strLen;
|
||||
CHANSVmObjHdr* intObj;
|
||||
u32 valLow;
|
||||
u32 valHigh;
|
||||
s32 bufSize;
|
||||
u8* dest;
|
||||
u32 ch;
|
||||
CHANSVmExecutionCtx* execCtx;
|
||||
u32 writeHexCh;
|
||||
s32 measureStringCount;
|
||||
s32 writeHexCount;
|
||||
CHANSVmExecutionCtx* measureIntegerExecCtx;
|
||||
CHANSVmExecutionCtx* writeIntegerExecCtx;
|
||||
|
||||
parentBlob = (BlobHeader*)VmGetStrFromObjHdr(VmParentObj);
|
||||
argStr = CHANSVmConvertObjectType(VmInst, CHANS_VM_OBJ_TYPE_STRING, CHANSVmGetArg(VmInst, 0));
|
||||
@@ -5057,26 +5051,26 @@ static vmBoolInt VmBlobPackCommon(CHANSVm* VmInst, CHANSVmObjHdr* VmParentObj, C
|
||||
case 4: {
|
||||
if (paramValue < 0) {
|
||||
if (argArr != vmNull) {
|
||||
obj = CHANSVmGetArrayElement(VmInst, argArr, argCount);
|
||||
measureBlobObj = CHANSVmGetArrayElement(VmInst, argArr, argCount);
|
||||
} else {
|
||||
obj = CHANSVmGetArg(VmInst, argCount + 1);
|
||||
measureBlobObj = CHANSVmGetArg(VmInst, argCount + 1);
|
||||
}
|
||||
if (CHANSVmCheckNativeInstance(obj, VmBlobClassName)) {
|
||||
srcBlob = (BlobHeader*)VmGetStrFromObjHdr(obj);
|
||||
if (CHANSVmCheckNativeInstance(measureBlobObj, VmBlobClassName)) {
|
||||
measureBlobSrcBlob = (BlobHeader*)VmGetStrFromObjHdr(measureBlobObj);
|
||||
} else {
|
||||
srcBlob = vmNull;
|
||||
measureBlobSrcBlob = vmNull;
|
||||
}
|
||||
if (srcBlob == vmNull) {
|
||||
if (measureBlobSrcBlob == vmNull) {
|
||||
goto error;
|
||||
}
|
||||
count = srcBlob->size - srcBlob->offset;
|
||||
measureBlobCount = measureBlobSrcBlob->size - measureBlobSrcBlob->offset;
|
||||
} else {
|
||||
count = paramValue;
|
||||
measureBlobCount = paramValue;
|
||||
}
|
||||
if (count < 0) {
|
||||
if (measureBlobCount < 0) {
|
||||
goto error;
|
||||
}
|
||||
totalSize += count;
|
||||
totalSize += measureBlobCount;
|
||||
argCount++;
|
||||
break;
|
||||
}
|
||||
@@ -5093,20 +5087,20 @@ static vmBoolInt VmBlobPackCommon(CHANSVm* VmInst, CHANSVmObjHdr* VmParentObj, C
|
||||
case 9: {
|
||||
if (paramValue < 0) {
|
||||
if (argArr != vmNull) {
|
||||
count = CHANSVmGetArrayLength(VmInst, argArr);
|
||||
count = count - argCount;
|
||||
measureIntegerCount = CHANSVmGetArrayLength(VmInst, argArr);
|
||||
measureIntegerCount = measureIntegerCount - argCount;
|
||||
} else {
|
||||
execCtx = ((CHANSVmPrivate*)VmInst)->pActiveCtx;
|
||||
count = execCtx->argc - argCount - 1;
|
||||
measureIntegerExecCtx = ((CHANSVmPrivate*)VmInst)->pActiveCtx;
|
||||
measureIntegerCount = measureIntegerExecCtx->argc - argCount - 1;
|
||||
}
|
||||
} else {
|
||||
count = paramValue;
|
||||
measureIntegerCount = paramValue;
|
||||
}
|
||||
if (count < 0) {
|
||||
if (measureIntegerCount < 0) {
|
||||
goto error;
|
||||
}
|
||||
argCount += count;
|
||||
totalSize += elemSize * count;
|
||||
argCount += measureIntegerCount;
|
||||
totalSize += elemSize * measureIntegerCount;
|
||||
break;
|
||||
}
|
||||
case 10:
|
||||
@@ -5115,47 +5109,47 @@ static vmBoolInt VmBlobPackCommon(CHANSVm* VmInst, CHANSVmObjHdr* VmParentObj, C
|
||||
case 13: {
|
||||
if (paramValue < 0) {
|
||||
if (argArr != vmNull) {
|
||||
obj = CHANSVmGetArrayElement(VmInst, argArr, argCount);
|
||||
obj = CHANSVmConvertObjectType(VmInst, CHANS_VM_OBJ_TYPE_STRING, obj);
|
||||
measureStringObj = CHANSVmGetArrayElement(VmInst, argArr, argCount);
|
||||
measureStringObj = CHANSVmConvertObjectType(VmInst, CHANS_VM_OBJ_TYPE_STRING, measureStringObj);
|
||||
} else {
|
||||
obj = CHANSVmGetArg(VmInst, argCount + 1);
|
||||
obj = CHANSVmConvertObjectType(VmInst, CHANS_VM_OBJ_TYPE_STRING, obj);
|
||||
measureStringObj = CHANSVmGetArg(VmInst, argCount + 1);
|
||||
measureStringObj = CHANSVmConvertObjectType(VmInst, CHANS_VM_OBJ_TYPE_STRING, measureStringObj);
|
||||
}
|
||||
if (obj == vmNull) {
|
||||
if (measureStringObj == vmNull) {
|
||||
goto error;
|
||||
}
|
||||
count = (u32)obj->value.int32_v->val >> 1;
|
||||
measureStringCount = (u32)measureStringObj->value.int32_v->val >> 1;
|
||||
} else {
|
||||
count = paramValue;
|
||||
measureStringCount = paramValue;
|
||||
}
|
||||
if (count < 0) {
|
||||
if (measureStringCount < 0) {
|
||||
goto error;
|
||||
}
|
||||
argCount++;
|
||||
totalSize += elemSize * count;
|
||||
totalSize += elemSize * measureStringCount;
|
||||
break;
|
||||
}
|
||||
case 14: {
|
||||
if (paramValue < 0) {
|
||||
if (argArr != vmNull) {
|
||||
obj = CHANSVmGetArrayElement(VmInst, argArr, argCount);
|
||||
obj = CHANSVmConvertObjectType(VmInst, CHANS_VM_OBJ_TYPE_STRING, obj);
|
||||
measureHexObj = CHANSVmGetArrayElement(VmInst, argArr, argCount);
|
||||
measureHexObj = CHANSVmConvertObjectType(VmInst, CHANS_VM_OBJ_TYPE_STRING, measureHexObj);
|
||||
} else {
|
||||
obj = CHANSVmGetArg(VmInst, argCount + 1);
|
||||
obj = CHANSVmConvertObjectType(VmInst, CHANS_VM_OBJ_TYPE_STRING, obj);
|
||||
measureHexObj = CHANSVmGetArg(VmInst, argCount + 1);
|
||||
measureHexObj = CHANSVmConvertObjectType(VmInst, CHANS_VM_OBJ_TYPE_STRING, measureHexObj);
|
||||
}
|
||||
if (obj == vmNull) {
|
||||
if (measureHexObj == vmNull) {
|
||||
goto error;
|
||||
}
|
||||
count = (u32)obj->value.int32_v->val >> 1;
|
||||
measureHexCount = (u32)measureHexObj->value.int32_v->val >> 1;
|
||||
} else {
|
||||
count = paramValue;
|
||||
measureHexCount = paramValue;
|
||||
}
|
||||
if (count < 0) {
|
||||
if (measureHexCount < 0) {
|
||||
goto error;
|
||||
}
|
||||
argCount++;
|
||||
totalSize += (s32)((u32)count + 1U) / 2;
|
||||
totalSize += (s32)((u32)measureHexCount + 1U) / 2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -5180,8 +5174,8 @@ static vmBoolInt VmBlobPackCommon(CHANSVm* VmInst, CHANSVmObjHdr* VmParentObj, C
|
||||
}
|
||||
}
|
||||
|
||||
argCount = 0;
|
||||
fmtPos = 0;
|
||||
writeArgCount = 0;
|
||||
writeFmtPos = 0;
|
||||
|
||||
while (vmTrue) {
|
||||
u32 nextPos = 0;
|
||||
@@ -5189,7 +5183,7 @@ static vmBoolInt VmBlobPackCommon(CHANSVm* VmInst, CHANSVmObjHdr* VmParentObj, C
|
||||
u32 elemSize = 1;
|
||||
s32 paramValue = 1;
|
||||
|
||||
fmtPos = vmBlobParsePackFormatString(&nextPos, &elemType, &elemSize, (void*)¶mValue, fmtStr, fmtLen, fmtPos);
|
||||
writeFmtPos = vmBlobParsePackFormatString(&nextPos, &elemType, &elemSize, (void*)¶mValue, fmtStr, fmtLen, writeFmtPos);
|
||||
|
||||
if (elemType == 1) {
|
||||
break;
|
||||
@@ -5202,33 +5196,43 @@ static vmBoolInt VmBlobPackCommon(CHANSVm* VmInst, CHANSVmObjHdr* VmParentObj, C
|
||||
switch (elemType) {
|
||||
case 4: {
|
||||
if (argArr != vmNull) {
|
||||
obj = CHANSVmGetArrayElement(VmInst, argArr, argCount);
|
||||
writeBlobObj = CHANSVmGetArrayElement(VmInst, argArr, writeArgCount);
|
||||
} else {
|
||||
obj = CHANSVmGetArg(VmInst, argCount + 1);
|
||||
writeBlobObj = CHANSVmGetArg(VmInst, writeArgCount + 1);
|
||||
}
|
||||
|
||||
if (CHANSVmCheckNativeInstance(obj, VmBlobClassName)) {
|
||||
srcBlob = (BlobHeader*)VmGetStrFromObjHdr(obj);
|
||||
if (CHANSVmCheckNativeInstance(writeBlobObj, VmBlobClassName)) {
|
||||
writeBlobSrcBlob = (BlobHeader*)VmGetStrFromObjHdr(writeBlobObj);
|
||||
} else {
|
||||
srcBlob = vmNull;
|
||||
writeBlobSrcBlob = vmNull;
|
||||
}
|
||||
argCount++;
|
||||
writeArgCount++;
|
||||
|
||||
if (srcBlob == vmNull) {
|
||||
if (writeBlobSrcBlob == vmNull) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (paramValue < 0) {
|
||||
copySize = srcBlob->size - srcBlob->offset;
|
||||
writeBlobCopySize = writeBlobSrcBlob->size - writeBlobSrcBlob->offset;
|
||||
} else {
|
||||
copySize = paramValue;
|
||||
writeBlobCopySize = paramValue;
|
||||
}
|
||||
|
||||
if (copySize < 0 || !CHANSVmBlobHasSpace(parentBlob, copySize)) {
|
||||
if (writeBlobCopySize < 0 || !CHANSVmBlobHasSpace(parentBlob, writeBlobCopySize)) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
VmBlobCopyPadded(parentBlob, srcBlob, copySize);
|
||||
writeBlobSrcOff = writeBlobSrcBlob->offset;
|
||||
writeBlobDataSize = writeBlobSrcBlob->size - writeBlobSrcOff;
|
||||
writeBlobDest = parentBlob->pData + parentBlob->offset;
|
||||
if (writeBlobDataSize > writeBlobCopySize) {
|
||||
writeBlobDataSize = writeBlobCopySize;
|
||||
}
|
||||
memmove(writeBlobDest, writeBlobSrcBlob->pData + writeBlobSrcOff, writeBlobDataSize);
|
||||
if (writeBlobDataSize < writeBlobCopySize) {
|
||||
memset(writeBlobDest + writeBlobDataSize, 0, writeBlobCopySize - writeBlobDataSize);
|
||||
}
|
||||
parentBlob->offset += writeBlobCopySize;
|
||||
break;
|
||||
}
|
||||
case 5: {
|
||||
@@ -5247,38 +5251,38 @@ static vmBoolInt VmBlobPackCommon(CHANSVm* VmInst, CHANSVmObjHdr* VmParentObj, C
|
||||
case 9: {
|
||||
if (paramValue < 0) {
|
||||
if (argArr != vmNull) {
|
||||
count = CHANSVmGetArrayLength(VmInst, argArr) - argCount;
|
||||
writeIntegerCount = CHANSVmGetArrayLength(VmInst, argArr) - writeArgCount;
|
||||
} else {
|
||||
execCtx = ((CHANSVmPrivate*)VmInst)->pActiveCtx;
|
||||
count = execCtx->argc - argCount - 1;
|
||||
writeIntegerExecCtx = ((CHANSVmPrivate*)VmInst)->pActiveCtx;
|
||||
writeIntegerCount = writeIntegerExecCtx->argc - writeArgCount - 1;
|
||||
}
|
||||
} else {
|
||||
count = paramValue;
|
||||
writeIntegerCount = paramValue;
|
||||
}
|
||||
if (count < 0) {
|
||||
if (writeIntegerCount < 0) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (!CHANSVmBlobHasSpace(parentBlob, elemSize * count)) {
|
||||
if (!CHANSVmBlobHasSpace(parentBlob, elemSize * writeIntegerCount)) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
for (writeIntegerI = 0; writeIntegerI < writeIntegerCount; writeIntegerI++) {
|
||||
packBuf[1] = 0;
|
||||
packBuf[0] = 0;
|
||||
if (argArr != vmNull) {
|
||||
intObj = CHANSVmGetArrayElement(VmInst, argArr, argCount);
|
||||
intObj = CHANSVmConvertObjectType(VmInst, CHANS_VM_OBJ_TYPE_INTEGER, intObj);
|
||||
writeIntegerIntObj = CHANSVmGetArrayElement(VmInst, argArr, writeArgCount);
|
||||
writeIntegerIntObj = CHANSVmConvertObjectType(VmInst, CHANS_VM_OBJ_TYPE_INTEGER, writeIntegerIntObj);
|
||||
} else {
|
||||
intObj = CHANSVmGetArg(VmInst, argCount + 1);
|
||||
intObj = CHANSVmConvertObjectType(VmInst, CHANS_VM_OBJ_TYPE_INTEGER, intObj);
|
||||
writeIntegerIntObj = CHANSVmGetArg(VmInst, writeArgCount + 1);
|
||||
writeIntegerIntObj = CHANSVmConvertObjectType(VmInst, CHANS_VM_OBJ_TYPE_INTEGER, writeIntegerIntObj);
|
||||
}
|
||||
argCount++;
|
||||
if (intObj == vmNull) {
|
||||
writeArgCount++;
|
||||
if (writeIntegerIntObj == vmNull) {
|
||||
goto error;
|
||||
}
|
||||
valLow = (u32)intObj->value.int_v;
|
||||
valHigh = (u32)((u64)intObj->value.int_v >> 32);
|
||||
writeIntegerValLow = (u32)writeIntegerIntObj->value.int_v;
|
||||
writeIntegerValHigh = (u32)((u64)writeIntegerIntObj->value.int_v >> 32);
|
||||
|
||||
switch ((s32)elemType) {
|
||||
case 6:
|
||||
@@ -5286,20 +5290,20 @@ static vmBoolInt VmBlobPackCommon(CHANSVm* VmInst, CHANSVmObjHdr* VmParentObj, C
|
||||
// signed
|
||||
switch (elemSize) {
|
||||
case 1: {
|
||||
*(s8*)packBuf = (s8)valLow;
|
||||
*(s8*)packBuf = (s8)writeIntegerValLow;
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
*(s16*)packBuf = (s16)valLow;
|
||||
*(s16*)packBuf = (s16)writeIntegerValLow;
|
||||
break;
|
||||
}
|
||||
case 4: {
|
||||
packBuf[0] = valLow;
|
||||
*(s32*)packBuf = writeIntegerValLow;
|
||||
break;
|
||||
}
|
||||
case 8: {
|
||||
packBuf[1] = valLow;
|
||||
packBuf[0] = valHigh;
|
||||
((s32*)packBuf)[1] = writeIntegerValLow;
|
||||
*(s32*)packBuf = writeIntegerValHigh;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
@@ -5313,15 +5317,15 @@ static vmBoolInt VmBlobPackCommon(CHANSVm* VmInst, CHANSVmObjHdr* VmParentObj, C
|
||||
// unsigned
|
||||
switch (elemSize) {
|
||||
case 1: {
|
||||
*(u8*)packBuf = (u8)valLow;
|
||||
*(u8*)packBuf = (u8)writeIntegerValLow;
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
*(u16*)packBuf = (u16)valLow;
|
||||
*(u16*)packBuf = (u16)writeIntegerValLow;
|
||||
break;
|
||||
}
|
||||
case 4: {
|
||||
packBuf[0] = valLow;
|
||||
*(u32*)packBuf = writeIntegerValLow;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
@@ -5350,7 +5354,7 @@ static vmBoolInt VmBlobPackCommon(CHANSVm* VmInst, CHANSVmObjHdr* VmParentObj, C
|
||||
break;
|
||||
}
|
||||
case 4: {
|
||||
__stwbrx(packBuf[0], packBuf, 0);
|
||||
__stwbrx(*(u32*)packBuf, packBuf, 0);
|
||||
break;
|
||||
}
|
||||
case 8: {
|
||||
@@ -5371,100 +5375,100 @@ static vmBoolInt VmBlobPackCommon(CHANSVm* VmInst, CHANSVmObjHdr* VmParentObj, C
|
||||
case 12:
|
||||
case 13: {
|
||||
if (argArr != vmNull) {
|
||||
strObj = CHANSVmGetArrayElement(VmInst, argArr, argCount);
|
||||
strObj = CHANSVmConvertObjectType(VmInst, CHANS_VM_OBJ_TYPE_STRING, strObj);
|
||||
writeStringStrObj = CHANSVmGetArrayElement(VmInst, argArr, writeArgCount);
|
||||
writeStringStrObj = CHANSVmConvertObjectType(VmInst, CHANS_VM_OBJ_TYPE_STRING, writeStringStrObj);
|
||||
} else {
|
||||
strObj = CHANSVmGetArg(VmInst, argCount + 1);
|
||||
strObj = CHANSVmConvertObjectType(VmInst, CHANS_VM_OBJ_TYPE_STRING, strObj);
|
||||
writeStringStrObj = CHANSVmGetArg(VmInst, writeArgCount + 1);
|
||||
writeStringStrObj = CHANSVmConvertObjectType(VmInst, CHANS_VM_OBJ_TYPE_STRING, writeStringStrObj);
|
||||
}
|
||||
argCount++;
|
||||
if (strObj == vmNull) {
|
||||
writeArgCount++;
|
||||
if (writeStringStrObj == vmNull) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (paramValue < 0) {
|
||||
count = (u32)strObj->value.int32_v->val >> 1;
|
||||
writeStringCount = (u32)writeStringStrObj->value.int32_v->val >> 1;
|
||||
} else {
|
||||
count = paramValue;
|
||||
writeStringCount = paramValue;
|
||||
}
|
||||
if (count < 0) {
|
||||
if (writeStringCount < 0) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (!CHANSVmBlobHasSpace(parentBlob, elemSize * count)) {
|
||||
if (!CHANSVmBlobHasSpace(parentBlob, elemSize * writeStringCount)) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
srcData = (u8*)VmGetStrFromObjHdr(strObj);
|
||||
strLen = (u32)VmGetIntFromObjHdr(strObj) >> 1;
|
||||
charCount = strLen;
|
||||
dest = parentBlob->pData + parentBlob->offset;
|
||||
writeStringSrcData = (u8*)VmGetStrFromObjHdr(writeStringStrObj);
|
||||
writeStringStrLen = (u32)VmGetIntFromObjHdr(writeStringStrObj) >> 1;
|
||||
writeStringCharCount = writeStringStrLen;
|
||||
writeStringDest = parentBlob->pData + parentBlob->offset;
|
||||
|
||||
if (charCount > count) {
|
||||
charCount = count;
|
||||
if (writeStringCharCount > writeStringCount) {
|
||||
writeStringCharCount = writeStringCount;
|
||||
}
|
||||
|
||||
memset(dest, 0, elemSize * count);
|
||||
memset(writeStringDest, 0, elemSize * writeStringCount);
|
||||
if (elemSize == 1) {
|
||||
CHANSVmStrCpyToU8FromU16(dest, srcData, charCount);
|
||||
CHANSVmStrCpyToU8FromU16(writeStringDest, writeStringSrcData, writeStringCharCount);
|
||||
} else {
|
||||
memcpy(dest, srcData, elemSize * charCount);
|
||||
memcpy(writeStringDest, writeStringSrcData, elemSize * writeStringCharCount);
|
||||
}
|
||||
parentBlob->offset += elemSize * count;
|
||||
parentBlob->offset += elemSize * writeStringCount;
|
||||
break;
|
||||
}
|
||||
case 14: {
|
||||
if (argArr != vmNull) {
|
||||
strObj = CHANSVmGetArrayElement(VmInst, argArr, argCount);
|
||||
strObj = CHANSVmConvertObjectType(VmInst, CHANS_VM_OBJ_TYPE_STRING, strObj);
|
||||
writeHexStrObj = CHANSVmGetArrayElement(VmInst, argArr, writeArgCount);
|
||||
writeHexStrObj = CHANSVmConvertObjectType(VmInst, CHANS_VM_OBJ_TYPE_STRING, writeHexStrObj);
|
||||
} else {
|
||||
strObj = CHANSVmGetArg(VmInst, argCount + 1);
|
||||
strObj = CHANSVmConvertObjectType(VmInst, CHANS_VM_OBJ_TYPE_STRING, strObj);
|
||||
writeHexStrObj = CHANSVmGetArg(VmInst, writeArgCount + 1);
|
||||
writeHexStrObj = CHANSVmConvertObjectType(VmInst, CHANS_VM_OBJ_TYPE_STRING, writeHexStrObj);
|
||||
}
|
||||
argCount++;
|
||||
if (strObj == vmNull) {
|
||||
writeArgCount++;
|
||||
if (writeHexStrObj == vmNull) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (paramValue < 0) {
|
||||
count = (u32)strObj->value.int32_v->val >> 1;
|
||||
writeHexCount = (u32)writeHexStrObj->value.int32_v->val >> 1;
|
||||
} else {
|
||||
count = paramValue;
|
||||
writeHexCount = paramValue;
|
||||
}
|
||||
if (count < 0) {
|
||||
if (writeHexCount < 0) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
bufSize = (s32)((u32)count + 1U) / 2;
|
||||
if (!CHANSVmBlobHasSpace(parentBlob, bufSize)) {
|
||||
writeHexBufSize = (s32)((u32)writeHexCount + 1U) / 2;
|
||||
if (!CHANSVmBlobHasSpace(parentBlob, writeHexBufSize)) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
srcData = (u8*)VmGetStrFromObjHdr(strObj);
|
||||
strLen = (u32)VmGetIntFromObjHdr(strObj) >> 1;
|
||||
dest = parentBlob->pData + parentBlob->offset;
|
||||
memset(dest, 0, bufSize);
|
||||
writeHexSrcData = (u8*)VmGetStrFromObjHdr(writeHexStrObj);
|
||||
VmGetIntFromObjHdr(writeHexStrObj);
|
||||
writeHexDest = parentBlob->pData + parentBlob->offset;
|
||||
memset(writeHexDest, 0, writeHexBufSize);
|
||||
|
||||
for (i = 0; (s32)i < count; i++) {
|
||||
ch = ((const u16*)srcData)[i];
|
||||
if (ch >= 0x30 && ch <= 0x39) {
|
||||
ch -= 0x30;
|
||||
} else if (ch >= 0x61 && ch <= 0x66) {
|
||||
ch -= 0x57;
|
||||
} else if (ch >= 0x41 && ch <= 0x46) {
|
||||
ch -= 0x37;
|
||||
for (writeHexI = 0; (s32)writeHexI < writeHexCount; writeHexI++) {
|
||||
writeHexCh = ((const u16*)writeHexSrcData)[writeHexI];
|
||||
if (writeHexCh >= 0x30 && writeHexCh <= 0x39) {
|
||||
writeHexCh -= 0x30;
|
||||
} else if (writeHexCh >= 0x61 && writeHexCh <= 0x66) {
|
||||
writeHexCh -= 0x57;
|
||||
} else if (writeHexCh >= 0x41 && writeHexCh <= 0x46) {
|
||||
writeHexCh -= 0x37;
|
||||
} else {
|
||||
ch = 0;
|
||||
writeHexCh = 0;
|
||||
}
|
||||
if ((i & 1) == 0) {
|
||||
ch *= 16;
|
||||
if ((writeHexI & 1) == 0) {
|
||||
writeHexCh *= 16;
|
||||
}
|
||||
*dest |= ch & 0xFF;
|
||||
if (i & 1) {
|
||||
dest++;
|
||||
*writeHexDest |= writeHexCh & 0xFF;
|
||||
if (writeHexI & 1) {
|
||||
writeHexDest++;
|
||||
}
|
||||
}
|
||||
parentBlob->offset += bufSize;
|
||||
parentBlob->offset += writeHexBufSize;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
@@ -6109,38 +6113,42 @@ const CHANSVmPropertyList VmImagePropertyTbl[] = {
|
||||
{"format", VmImageFormat, vmNull},
|
||||
};
|
||||
|
||||
static vmBoolInt VmWinEmuWrite(CHANSVm* vm, CHANSVmObjHdr* parent, CHANSVmObjHdr* ret) {
|
||||
CHANSVmObjHdr* strObj;
|
||||
static inline void VmWinEmuPrintString(CHANSVmObjHdr* strObj) {
|
||||
u32 offset;
|
||||
u32 totalLength;
|
||||
u8 buf[VM_STRING_SIZE];
|
||||
s32 outLen;
|
||||
s32 inLen;
|
||||
s32 outLen;
|
||||
s32 result;
|
||||
u32 remaining;
|
||||
|
||||
strObj = CHANSVmConvertObjectType(vm, CHANS_VM_OBJ_TYPE_STRING, CHANSVmGetArg(vm, 0));
|
||||
if (strObj != vmNull && strObj->type == CHANS_VM_OBJ_TYPE_STRING) {
|
||||
offset = 0;
|
||||
totalLength = strObj->value.wstring_v->len & ~1;
|
||||
offset = 0;
|
||||
totalLength = strObj->value.wstring_v->len & ~1;
|
||||
|
||||
while (offset < totalLength) {
|
||||
remaining = totalLength - offset;
|
||||
outLen = VM_STRING_SIZE;
|
||||
inLen = (remaining < VM_STRING_SIZE ? remaining : VM_STRING_SIZE) / 2;
|
||||
while (offset < totalLength) {
|
||||
remaining = totalLength - offset;
|
||||
outLen = VM_STRING_SIZE;
|
||||
inLen = (remaining < VM_STRING_SIZE ? remaining : VM_STRING_SIZE) / 2;
|
||||
|
||||
result = ENCConvertStringUnicodeToSjis(buf, &outLen, (u16*)((u8*)strObj->value.wstring_v->spData + offset), &inLen);
|
||||
if (result == ENC_OK) {
|
||||
buf[outLen] = 0;
|
||||
buf[outLen + 1] = 0;
|
||||
OSReport(VmReportFormat, buf);
|
||||
} else {
|
||||
OSReport("document.write(): conversion error (%d)\n", result);
|
||||
break;
|
||||
}
|
||||
|
||||
offset += VM_STRING_SIZE;
|
||||
result = ENCConvertStringUnicodeToSjis(buf, &outLen, (u16*)((u8*)strObj->value.wstring_v->spData + offset), &inLen);
|
||||
if (result == ENC_OK) {
|
||||
buf[outLen] = 0;
|
||||
buf[outLen + 1] = 0;
|
||||
OSReport(VmReportFormat, buf);
|
||||
} else {
|
||||
OSReport("document.write(): conversion error (%d)\n", result);
|
||||
break;
|
||||
}
|
||||
|
||||
offset += VM_STRING_SIZE;
|
||||
}
|
||||
}
|
||||
|
||||
static vmBoolInt VmWinEmuWrite(CHANSVm* vm, CHANSVmObjHdr* parent, CHANSVmObjHdr* ret) {
|
||||
CHANSVmObjHdr* strObj = CHANSVmGetArgString(vm, 0);
|
||||
|
||||
if (strObj != vmNull && strObj->type == CHANS_VM_OBJ_TYPE_STRING) {
|
||||
VmWinEmuPrintString(strObj);
|
||||
}
|
||||
return vmTrue;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#define TI_CANDIDATEBOX_IMPLEMENTATION
|
||||
#define TI_CANDIDATEBOX_SAMPLE_CLASS
|
||||
#include "keyboard/tiCandidateBox.h"
|
||||
#undef TI_CANDIDATEBOX_SAMPLE_CLASS
|
||||
|
||||
#include "keyboard/tiManager.h"
|
||||
|
||||
@@ -60,11 +62,7 @@ namespace textinput {
|
||||
{ANM_InvalidOff, "fs_VK_predictInput_a_invalidMode_OFF.brlan"},
|
||||
};
|
||||
|
||||
struct CandidatePaneData {
|
||||
PaneToAnimation panes[26];
|
||||
};
|
||||
|
||||
extern "C" const CandidatePaneData scCandidatePaneData __attribute__((aligned(8))) = {{
|
||||
static const PaneToAnimation csPaneToAnimation[] = {
|
||||
{KT_CandidateText, "N_predictInput", 1, NULL, {&csAninationFile[0]}},
|
||||
{KT_ScrollButton,
|
||||
"P_prdc_scrl_Left",
|
||||
@@ -195,7 +193,7 @@ namespace textinput {
|
||||
6,
|
||||
NULL,
|
||||
{&csAninationFile[0], &csAninationFile[8], &csAninationFile[9], &csAninationFile[10], &csAninationFile[11], &csAninationFile[12]}},
|
||||
}};
|
||||
};
|
||||
|
||||
void CandidateBoxCaller::Candidates::addCandidate(const wchar_t* wcString) {
|
||||
wcsncpy(szwcPredicted[mNumCandidate], wcString, ARRAY_LENGTH(szwcPredicted[0]));
|
||||
@@ -376,50 +374,44 @@ namespace textinput {
|
||||
}
|
||||
|
||||
void LayoutByNW4R::createAnmPane_(MEMAllocator* allocator) {
|
||||
u32 animationCount;
|
||||
const char* forceAddName;
|
||||
u16 i;
|
||||
for (i = 0; i < ARRAY_LENGTH(scCandidatePaneData.panes); i++) {
|
||||
const PaneToAnimation& p = scCandidatePaneData.panes[i];
|
||||
for (u16 i = 0; i < ARRAY_LENGTH(csPaneToAnimation); i++) {
|
||||
const PaneToAnimation& paneAnimations = csPaneToAnimation[i];
|
||||
CandidateTextAnmPane* pane = NULL;
|
||||
switch (p.type) {
|
||||
switch (paneAnimations.type) {
|
||||
case KT_ScrollButton: {
|
||||
void* pBtnBuf = MEMAllocFromAllocator(allocator, sizeof(CandidateScrollAnmPane));
|
||||
pane = new (pBtnBuf) CandidateScrollAnmPane(getPane(p.paneName), NULL);
|
||||
pane = new (pBtnBuf) CandidateScrollAnmPane(getPane(paneAnimations.paneName), NULL);
|
||||
break;
|
||||
}
|
||||
case KT_CandidateText: {
|
||||
void* pBtnBuf = MEMAllocFromAllocator(allocator, sizeof(CandidateTextAnmPane));
|
||||
pane = new (pBtnBuf) CandidateTextAnmPane(getPane(p.paneName), NULL);
|
||||
pane = new (pBtnBuf) CandidateTextAnmPane(getPane(paneAnimations.paneName), NULL);
|
||||
break;
|
||||
}
|
||||
case KT_OnOffButton: {
|
||||
void* pBtnBuf = MEMAllocFromAllocator(allocator, sizeof(OnOffAnmPane));
|
||||
pane = new (pBtnBuf) OnOffAnmPane(getPane(p.paneName), &mOnOffButton);
|
||||
pane = new (pBtnBuf) OnOffAnmPane(getPane(paneAnimations.paneName), &mOnOffButton);
|
||||
break;
|
||||
}
|
||||
|
||||
case KT_Window: {
|
||||
void* pBtnBuf = MEMAllocFromAllocator(allocator, sizeof(PredictWindow));
|
||||
pane = new (pBtnBuf) PredictWindow(getPane(p.paneName), &mTextWindow);
|
||||
pane = new (pBtnBuf) PredictWindow(getPane(paneAnimations.paneName), &mTextWindow);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
nw4r::ut::List_Append(&mAnmPanes, pane);
|
||||
|
||||
forceAddName = p.forceAddName;
|
||||
animationCount = p.count;
|
||||
for (u16 j = 0; j < animationCount; j++) {
|
||||
const AnimationFile* const& animation = p.pAnims[j];
|
||||
void* pResource = mpMultiArcResourceAccessor->GetResource(0, animation->fileName);
|
||||
for (u16 j = 0; j < paneAnimations.count; j++) {
|
||||
void* pResource = mpMultiArcResourceAccessor->GetResource(0, paneAnimations.pAnims[j]->fileName);
|
||||
AnimTransformPane* transform =
|
||||
static_cast<AnimTransformPane*>(getLayout()->CreateAnimTransform(pResource, mpMultiArcResourceAccessor));
|
||||
|
||||
if (forceAddName == NULL) {
|
||||
pane->addAnimation(allocator, animation->id, transform, false, true);
|
||||
if (paneAnimations.forceAddName == NULL) {
|
||||
pane->addAnimation(allocator, paneAnimations.pAnims[j]->id, transform, false, true);
|
||||
} else {
|
||||
pane->forceAddAnimation(allocator, animation->id, transform, forceAddName, false, true);
|
||||
pane->forceAddAnimation(allocator, paneAnimations.pAnims[j]->id, transform, paneAnimations.forceAddName, false, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -678,8 +670,8 @@ namespace textinput {
|
||||
}
|
||||
|
||||
void LayoutByNW4R::cancelStateFocusIn() {
|
||||
const PaneToAnimation* pane = scCandidatePaneData.panes;
|
||||
for (int i = 0; i < ARRAY_LENGTH(scCandidatePaneData.panes); i++) {
|
||||
const PaneToAnimation* pane = csPaneToAnimation;
|
||||
for (int i = 0; i < ARRAY_LENGTH(csPaneToAnimation); i++) {
|
||||
CandidateTextAnmPane* p = static_cast<CandidateTextAnmPane*>(searchAnmPane(pane->paneName));
|
||||
if (p != NULL) {
|
||||
switch (p->getKeyType()) {
|
||||
@@ -1766,3 +1758,48 @@ namespace textinput {
|
||||
|
||||
} // namespace candidatebox
|
||||
} // namespace textinput
|
||||
|
||||
inline void textinput::util::Animation::startAnm(AnimObserver* observer, f32 start, f32 end, f32 duration, void* data) {
|
||||
mfStartPoint = start;
|
||||
mfEndPoint = end;
|
||||
mfAnimationTime = duration;
|
||||
mfCurrentFrame = 0.0f;
|
||||
mbInAnimation = true;
|
||||
mpAnimObserver = observer;
|
||||
mpData = data;
|
||||
mbSE = false;
|
||||
if (observer) observer->onAnmEvent(AnimObserver::AE_0, data);
|
||||
}
|
||||
|
||||
inline void textinput::util::Animation::calc() {
|
||||
if (mbInAnimation) {
|
||||
if (mfCurrentFrame < mfAnimationTime) {
|
||||
mfCurrentFrame = 1.0f + mfCurrentFrame;
|
||||
} else {
|
||||
if (mbInAnimation && mpAnimObserver) {
|
||||
mpAnimObserver->onAnmEvent(AnimObserver::AE_1, mpData);
|
||||
}
|
||||
mbInAnimation = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline f32 textinput::util::Animation::getValue() {
|
||||
return hermiteInterporation(mfCurrentFrame, 0.0f, mfStartPoint, 0.0f, mfAnimationTime, mfEndPoint, 0.0f);
|
||||
}
|
||||
|
||||
inline bool textinput::util::Animation::isActive() {
|
||||
return mbInAnimation;
|
||||
}
|
||||
|
||||
inline void textinput::util::Animation::setSEFlag(bool flag) {
|
||||
mbSE = flag;
|
||||
}
|
||||
|
||||
inline bool textinput::util::Animation::isSEFlag() {
|
||||
return mbSE;
|
||||
}
|
||||
|
||||
inline void textinput::util::Animation::stop() {
|
||||
mbInAnimation = false;
|
||||
}
|
||||
|
||||
@@ -707,49 +707,75 @@ extern "C" void clearAllCardFileEntries(s32 slot) {
|
||||
} while (file < CARD_MAX_FILE);
|
||||
}
|
||||
|
||||
static inline void updateCardIconAnimation(s32 slot, s32 fileNo, CARDDir* dir) {
|
||||
s32 iconCount = 0;
|
||||
s32 shift = 0;
|
||||
s32 icon;
|
||||
sThread->icons[slot][fileNo].unk_0x02 = 0;
|
||||
sThread->icons[slot][fileNo].anmMax = 0;
|
||||
sThread->icons[slot][fileNo].anmFrameBits = dir->iconSpeed;
|
||||
sThread->icons[slot][fileNo].unk_0x06 =
|
||||
(dir->iconSpeed & CARD_STAT_SPEED_MASK) << 2;
|
||||
for (icon = 0; icon < CARD_ICON_MAX; ++icon) {
|
||||
s32 iconSpeed = (dir->iconSpeed >> shift) & CARD_STAT_SPEED_MASK;
|
||||
if (iconSpeed != 0) {
|
||||
sThread->icons[slot][fileNo].anmMax =
|
||||
sThread->icons[slot][fileNo].anmMax + (iconSpeed << 2);
|
||||
} else {
|
||||
sThread->icons[slot][fileNo].unk_0x07 =
|
||||
(u8)(((dir->iconSpeed >> ((iconCount - 1) * 2)) << 2) & 0xC);
|
||||
return;
|
||||
}
|
||||
iconCount = iconCount + 1;
|
||||
shift = shift + 2;
|
||||
static inline s32 readCardImages(s32 slot, s32 fileNo, CARDDir* dir, CARDFileInfo* fileInfo,
|
||||
u32 address, s32 offset, s32 imageSize) {
|
||||
s32 sectorSize;
|
||||
u32 transferSize = (imageSize + offset + 0x1FF) & 0xFFFFFE00;
|
||||
if (CARDGetSectorSize(slot, (u32*)§orSize) < CARD_RESULT_READY) {
|
||||
sThread->icons[slot][fileNo].bannerEnable = 0;
|
||||
sThread->icons[slot][fileNo].unk_0x01 = 0;
|
||||
return 0;
|
||||
}
|
||||
sThread->icons[slot][fileNo].unk_0x07 =
|
||||
(dir->iconSpeed >> 0xC) & 0xC;
|
||||
|
||||
u32 fileSize = (u32)dir->length * sectorSize;
|
||||
if (address > fileSize) {
|
||||
sThread->icons[slot][fileNo].bannerEnable = 0;
|
||||
sThread->icons[slot][fileNo].unk_0x01 = 0;
|
||||
return 0;
|
||||
}
|
||||
if (address + transferSize > fileSize) {
|
||||
sThread->icons[slot][fileNo].bannerEnable = 0;
|
||||
sThread->icons[slot][fileNo].unk_0x01 = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (imageSize > 0) {
|
||||
s32 result = CARDRead(fileInfo, sThread->imageReadBuffer, transferSize, address);
|
||||
if (result < CARD_RESULT_READY) {
|
||||
return result;
|
||||
}
|
||||
memcpy(sThread->images[slot][fileNo], sThread->imageReadBuffer + offset, imageSize);
|
||||
DCStoreRange(sThread->images[slot][fileNo], transferSize);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern "C" s32 loadCardFileIcons(s32 slot, s32 fileNo, CARDDir* dir) {
|
||||
static inline s32 readCardComment(s32 slot, s32 fileNo, CARDDir* dir, CARDFileInfo* fileInfo) {
|
||||
u32 address = dir->commentAddr;
|
||||
u32 base = address & 0xFFFFFE00;
|
||||
s32 offset = address - base;
|
||||
s32 readSize = ((address + 0x23F) & 0xFFFFFE00) - base;
|
||||
s32 sectorSize;
|
||||
s32 commentSectorSize;
|
||||
CARDFileInfo fileInfo;
|
||||
u32 iconAddressBase;
|
||||
s32 result;
|
||||
s32 iconAddressOffset;
|
||||
result = CARDFastOpen(slot, fileNo, &fileInfo);
|
||||
if (result < CARD_RESULT_READY) {
|
||||
return result;
|
||||
s32 result = CARDGetSectorSize(slot, (u32*)§orSize);
|
||||
if (result >= CARD_RESULT_READY) {
|
||||
u32 fileSize;
|
||||
if ((s32)base < 0 || base > (fileSize = (u32)dir->length * sectorSize)) {
|
||||
result = 0;
|
||||
} else {
|
||||
u32 end = base + readSize;
|
||||
if ((s32)end < 0 || end > fileSize) {
|
||||
result = 0;
|
||||
} else {
|
||||
result = CARDRead(fileInfo, sThread->commentBuffer, readSize, base);
|
||||
if (result >= CARD_RESULT_READY) {
|
||||
memset(sThread->comments[slot][fileNo], 0, CARD_COMMENT_SIZE);
|
||||
memcpy(sThread->comments[slot][fileNo], sThread->commentBuffer + offset,
|
||||
CARD_COMMENT_SIZE);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
memset(sThread->comments[slot][fileNo], 0, CARD_COMMENT_SIZE);
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline s32 loadCardIconImages(s32 slot, s32 fileNo, CARDDir* dir, CARDFileInfo* fileInfo) {
|
||||
s32 bannerImageSize = 0;
|
||||
u8 format = dir->bannerFormat & CARD_STAT_BANNER_MASK;
|
||||
u32 iconAddress = dir->iconAddr;
|
||||
iconAddressBase = iconAddress & 0xFFFFFE00;
|
||||
iconAddressOffset = iconAddress - iconAddressBase;
|
||||
s32 iconAddressOffset = iconAddress - (iconAddress & 0xFFFFFE00);
|
||||
|
||||
switch (format) {
|
||||
case CARD_STAT_BANNER_C8: {
|
||||
@@ -786,12 +812,33 @@ extern "C" s32 loadCardFileIcons(s32 slot, s32 fileNo, CARDDir* dir) {
|
||||
}
|
||||
}
|
||||
|
||||
s32 shift = 0;
|
||||
BOOL hasTlut = FALSE;
|
||||
s32 iconImageSize = 0;
|
||||
s32 shift;
|
||||
BOOL hasTlut;
|
||||
s32 iconImageSize;
|
||||
s32 icon;
|
||||
s32 iconCount = 0;
|
||||
updateCardIconAnimation(slot, fileNo, dir);
|
||||
s32 iconCount;
|
||||
shift = 0;
|
||||
iconCount = 0;
|
||||
hasTlut = FALSE;
|
||||
iconImageSize = 0;
|
||||
sThread->icons[slot][fileNo].unk_0x02 = 0;
|
||||
sThread->icons[slot][fileNo].anmMax = 0;
|
||||
sThread->icons[slot][fileNo].anmFrameBits = dir->iconSpeed;
|
||||
sThread->icons[slot][fileNo].unk_0x06 = (dir->iconSpeed & CARD_STAT_SPEED_MASK) << 2;
|
||||
for (icon = 0; icon < CARD_ICON_MAX; ++icon) {
|
||||
s32 iconSpeed = (dir->iconSpeed >> shift) & CARD_STAT_SPEED_MASK;
|
||||
if (iconSpeed != 0) {
|
||||
sThread->icons[slot][fileNo].anmMax = sThread->icons[slot][fileNo].anmMax + (iconSpeed << 2);
|
||||
} else {
|
||||
sThread->icons[slot][fileNo].unk_0x07 =
|
||||
(u8)(((dir->iconSpeed >> ((iconCount - 1) * 2)) << 2) & 0xC);
|
||||
goto animationDone;
|
||||
}
|
||||
iconCount = iconCount + 1;
|
||||
shift = shift + 2;
|
||||
}
|
||||
sThread->icons[slot][fileNo].unk_0x07 = (dir->iconSpeed >> 0xC) & 0xC;
|
||||
animationDone:
|
||||
if ((dir->iconSpeed & CARD_STAT_SPEED_MASK) == 0 || (dir->iconFormat & CARD_STAT_ICON_MASK) == 0) {
|
||||
sThread->icons[slot][fileNo].unk_0x01 = 0;
|
||||
iconImageSize = 0;
|
||||
@@ -801,7 +848,7 @@ extern "C" s32 loadCardFileIcons(s32 slot, s32 fileNo, CARDDir* dir) {
|
||||
for (icon = 0; icon < CARD_ICON_MAX; ++icon) {
|
||||
if (((dir->iconSpeed >> shift) & CARD_STAT_SPEED_MASK) != 0) {
|
||||
s32 iconFormat = (dir->iconFormat >> shift) & CARD_STAT_ICON_MASK;
|
||||
s32 paletteSize = 0;
|
||||
s32 paletteSize;
|
||||
switch (iconFormat) {
|
||||
case CARD_STAT_ICON_C8:
|
||||
paletteSize = 0x400;
|
||||
@@ -813,9 +860,9 @@ extern "C" s32 loadCardFileIcons(s32 slot, s32 fileNo, CARDDir* dir) {
|
||||
sThread->icons[slot][fileNo].iconFmt[iconCount] = GX_TF_RGB5A3;
|
||||
break;
|
||||
case CARD_STAT_ICON_NONE: {
|
||||
u8* iconPalette =
|
||||
&sThread->icons[slot][fileNo].iconFmt[iconCount];
|
||||
*iconPalette = iconPalette[-1];
|
||||
paletteSize = 0;
|
||||
u8* previous = &sThread->icons[slot][fileNo].iconFmt[iconCount - 1];
|
||||
sThread->icons[slot][fileNo].iconFmt[iconCount] = *previous;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@@ -847,79 +894,23 @@ extern "C" s32 loadCardFileIcons(s32 slot, s32 fileNo, CARDDir* dir) {
|
||||
sThread->icons[slot][fileNo].anmDelta = 1;
|
||||
}
|
||||
|
||||
s32 totalImageSize = iconImageSize + bannerImageSize;
|
||||
u32 transferSize = (totalImageSize + iconAddressOffset + 0x1FF) & 0xFFFFFE00;
|
||||
result = CARDGetSectorSize(slot, (u32*)§orSize);
|
||||
if (result < CARD_RESULT_READY) {
|
||||
result = 0;
|
||||
sThread->icons[slot][fileNo].bannerEnable = 0;
|
||||
sThread->icons[slot][fileNo].unk_0x01 = 0;
|
||||
} else {
|
||||
u32 fileSize = (u32)dir->length * sectorSize;
|
||||
if (iconAddressBase > fileSize) {
|
||||
result = 0;
|
||||
sThread->icons[slot][fileNo].bannerEnable = 0;
|
||||
sThread->icons[slot][fileNo].unk_0x01 = 0;
|
||||
} else if (iconAddressBase + transferSize > fileSize) {
|
||||
result = 0;
|
||||
sThread->icons[slot][fileNo].bannerEnable = 0;
|
||||
sThread->icons[slot][fileNo].unk_0x01 = 0;
|
||||
} else {
|
||||
if (totalImageSize > 0) {
|
||||
result = CARDRead(&fileInfo, sThread->imageReadBuffer,
|
||||
transferSize, iconAddressBase);
|
||||
if (result < CARD_RESULT_READY) {
|
||||
return result;
|
||||
}
|
||||
memcpy(sThread->images[slot][fileNo],
|
||||
sThread->imageReadBuffer + iconAddressOffset,
|
||||
totalImageSize);
|
||||
DCStoreRange(sThread->images[slot][fileNo], transferSize);
|
||||
}
|
||||
result = 0;
|
||||
}
|
||||
}
|
||||
return readCardImages(slot, fileNo, dir, fileInfo, iconAddress & 0xFFFFFE00, iconAddressOffset,
|
||||
bannerImageSize + iconImageSize);
|
||||
}
|
||||
|
||||
extern "C" s32 loadCardFileIcons(s32 slot, s32 fileNo, CARDDir* dir) {
|
||||
CARDFileInfo fileInfo;
|
||||
s32 result = CARDFastOpen(slot, fileNo, &fileInfo);
|
||||
if (result < CARD_RESULT_READY) {
|
||||
return result;
|
||||
}
|
||||
|
||||
iconAddress = dir->commentAddr;
|
||||
iconAddressBase = iconAddress & 0xFFFFFE00;
|
||||
s32 commentDataOffset = iconAddress - iconAddressBase;
|
||||
s32 imageSize = ((iconAddress + 0x23F) & 0xFFFFFE00) - iconAddressBase;
|
||||
result = CARDGetSectorSize(slot, (u32*)&commentSectorSize);
|
||||
result = loadCardIconImages(slot, fileNo, dir, &fileInfo);
|
||||
if (result < CARD_RESULT_READY) {
|
||||
goto clearComment;
|
||||
}
|
||||
{
|
||||
u32 fileSize;
|
||||
if ((s32)iconAddressBase < 0 ||
|
||||
iconAddressBase > (fileSize = (u32)dir->length * commentSectorSize)) {
|
||||
result = 0;
|
||||
} else {
|
||||
u32 endOffset = iconAddressBase + imageSize;
|
||||
if ((s32)endOffset < 0 || endOffset > fileSize) {
|
||||
result = 0;
|
||||
goto clearComment;
|
||||
}
|
||||
result = CARDRead(&fileInfo, sThread->commentBuffer, imageSize,
|
||||
iconAddressBase);
|
||||
if (result < CARD_RESULT_READY) {
|
||||
goto clearComment;
|
||||
}
|
||||
memset(sThread->comments[slot][fileNo], 0, CARD_COMMENT_SIZE);
|
||||
memcpy(sThread->comments[slot][fileNo],
|
||||
sThread->commentBuffer + commentDataOffset, CARD_COMMENT_SIZE);
|
||||
result = 0;
|
||||
goto commentDone;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
clearComment:
|
||||
memset(sThread->comments[slot][fileNo], 0, CARD_COMMENT_SIZE);
|
||||
|
||||
commentDone:
|
||||
result = readCardComment(slot, fileNo, dir, &fileInfo);
|
||||
if (result < CARD_RESULT_READY) {
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -194,7 +194,8 @@ namespace ipl {
|
||||
mpCaptionString->clear();
|
||||
mpCaptionString->set(System::getMessage(MESG_LETTERWRITER_LETTER_HEADER));
|
||||
|
||||
wchar_t* namePlaceholder = wcsstr(mpCaptionString->getWCString(), L"xxxxxxxxxx");
|
||||
wchar_t* caption = mpCaptionString->getWCString();
|
||||
wchar_t* namePlaceholder = wcsstr(caption, L"xxxxxxxxxx");
|
||||
|
||||
mpCaptionString->replace((namePlaceholder - mpCaptionString->getWCString()), RFL_NAME_LENGTH, headerCaption);
|
||||
return mpCaptionString->getWCString();
|
||||
|
||||
@@ -341,7 +341,7 @@ void MemoryCardManager::update_change_cardstate(u8 slot) {
|
||||
}
|
||||
}
|
||||
|
||||
GXTexObj* MemoryCardManager::create_icon(u8 slot, s16 index) {
|
||||
const GXTexObj* MemoryCardManager::create_icon(u8 slot, s16 index) {
|
||||
memorycard::IconState (*icons)[CARD_MAX_FILE] = reinterpret_cast<memorycard::IconState(*)[CARD_MAX_FILE]>(memorycard::getIconStateArray());
|
||||
int total = 0;
|
||||
s16 frame = 0;
|
||||
@@ -355,26 +355,24 @@ GXTexObj* MemoryCardManager::create_icon(u8 slot, s16 index) {
|
||||
return _create_icon(slot, file, frame - 1);
|
||||
}
|
||||
|
||||
GXTexObj* MemoryCardManager::create_icon(u8 slot, s16 index, long start) {
|
||||
const GXTexObj* MemoryCardManager::create_icon(u8 slot, s16 index, long start) {
|
||||
memorycard::getIconStateArray();
|
||||
u32 file = mFile[slot][index].fileNo;
|
||||
return _create_icon(slot, file, 0);
|
||||
}
|
||||
|
||||
GXTexObj* MemoryCardManager::_create_icon(u8 slot, s16 file, long start) {
|
||||
const GXTexObj* MemoryCardManager::_create_icon(u8 slot, s16 file, long start) {
|
||||
CardDirectory* dirs = reinterpret_cast<CardDirectory*>(memorycard::getCardDirState());
|
||||
if (dirs[slot][file].fileNo == 0) {
|
||||
return NULL;
|
||||
}
|
||||
CardIcons* icons = reinterpret_cast<CardIcons*>(memorycard::getIconStateArray());
|
||||
memorycard::IconState* icon = &icons[slot][file];
|
||||
if ((int)icon->iconFmt[start] == GX_TF_RGB5A3) {
|
||||
GXInitTexObj(&mFileCell[slot][file].icon, reinterpret_cast<u8*>(icon) + icon->iconOffset[start], CARD_ICON_WIDTH, CARD_ICON_HEIGHT, GX_TF_RGB5A3, GX_CLAMP, GX_CLAMP, GX_FALSE);
|
||||
GXLoadTexObj(&mFileCell[slot][file].icon, GX_TEXMAP0);
|
||||
} else if ((int)icon->iconFmt[start] == GX_TF_C8) {
|
||||
GXInitTexObjCI(&mFileCell[slot][file].icon, reinterpret_cast<u8*>(icon) + icon->iconOffset[start], CARD_ICON_WIDTH, CARD_ICON_HEIGHT, GX_TF_C8, GX_CLAMP, GX_CLAMP, GX_FALSE, GX_TLUT0);
|
||||
GXInitTlutObj(&mFileCell[slot][file].iconTlut, reinterpret_cast<u8*>(icon) + icons[slot][file].iconTlutOffset, GX_TL_RGB5A3, 0x100);
|
||||
GXLoadTlut(&mFileCell[slot][file].iconTlut, GX_TLUT0);
|
||||
if ((int)icons[slot][file].iconFmt[start] == GX_TF_RGB5A3) {
|
||||
GXLoadTexObj(initIconTexture(slot, file, reinterpret_cast<u8*>(&icons[slot][file]) + icons[slot][file].iconOffset[start]), GX_TEXMAP0);
|
||||
} else if ((int)icons[slot][file].iconFmt[start] == GX_TF_C8) {
|
||||
initIconTextureCI(slot, file, reinterpret_cast<u8*>(&icons[slot][file]) + icons[slot][file].iconOffset[start]);
|
||||
GXTlutObj* tlut = initIconPalette(slot, file, reinterpret_cast<u8*>(&icons[slot][file]) + icons[slot][file].iconTlutOffset);
|
||||
GXLoadTlut(tlut, GX_TLUT0);
|
||||
GXLoadTexObj(&mFileCell[slot][file].icon, GX_TEXMAP0);
|
||||
} else {
|
||||
return NULL;
|
||||
@@ -424,7 +422,7 @@ const wchar_t* MemoryCardManager::getComment(u8 slot, s16 index, int which) {
|
||||
return mFileCell[slot][file].comment[which];
|
||||
}
|
||||
|
||||
GXTexObj* MemoryCardManager::create_banner(u8 slot, s16 index) {
|
||||
const GXTexObj* MemoryCardManager::create_banner(u8 slot, s16 index) {
|
||||
CardDirectory* dirs = reinterpret_cast<CardDirectory*>(memorycard::getCardDirState());
|
||||
CardIcons* icons = reinterpret_cast<CardIcons*>(memorycard::getIconStateArray());
|
||||
u32 file = mFile[slot][index].fileNo;
|
||||
@@ -432,7 +430,7 @@ GXTexObj* MemoryCardManager::create_banner(u8 slot, s16 index) {
|
||||
return NULL;
|
||||
}
|
||||
if ((int)icons[slot][file].bannerType == GX_TF_RGB5A3) {
|
||||
GXTexObj* banner = initBannerTexture(slot, file,
|
||||
const GXTexObj* banner = initBannerTexture(slot, file,
|
||||
reinterpret_cast<u8*>(&icons[slot][file]) + icons[slot][file].bannerOffset);
|
||||
GXLoadTexObj(banner, GX_TEXMAP0);
|
||||
} else if ((int)icons[slot][file].bannerType == GX_TF_C8) {
|
||||
|
||||
@@ -7,13 +7,11 @@
|
||||
#define IPL_SDMEMORY_SD_CHANNEL_SELECT_LAYOUT
|
||||
#define IPL_SDMEMORY_COMPLETION_PCT_ACCESSOR
|
||||
#define IPL_SDMEMORY_DIALOG_PROGRESS_FRAME_ACCESSOR
|
||||
#define IPL_SDMEMORY_SET_TEXT_COLORS
|
||||
#define IPL_SDMEMORY_SCROLLER_STATE_ACCESSOR
|
||||
#include "system/iplDialogWindow.h"
|
||||
#undef IPL_SDMEMORY_DIALOG_PROGRESS_FRAME_ACCESSOR
|
||||
#include "scene/sdChannelMemory/iplSDMemory.h"
|
||||
#include "scene/sdChannelSelect/iplSDChannelSelect.h"
|
||||
#undef IPL_SDMEMORY_SET_TEXT_COLORS
|
||||
#undef IPL_SDMEMORY_SCROLLER_STATE_ACCESSOR
|
||||
#undef IPL_SDMEMORY_DIALOG_STATE_ACCESSOR
|
||||
#undef IPL_SDMEMORY_SET_TRANSLATE_OUT_OF_LINE
|
||||
@@ -28,34 +26,12 @@
|
||||
#include "utility/iplLayout.h"
|
||||
#include <revolution/os/OSTime.h>
|
||||
|
||||
extern "C" bool iplSDChannelSelect_813DDB74(ipl::scene::SDChannelSelect* channelSelect,
|
||||
ipl::scene::SDMemory::TitleRange* nandTitles,
|
||||
ipl::scene::SDMemory::TitleRange* sdTitles,
|
||||
ESTitleId* titleIds, wchar_t* titleNames, u32* titleCount,
|
||||
s32 state);
|
||||
extern "C" bool iplSDChannelSelect_813DB5EC(ipl::scene::SDChannelSelect* channelSelect,
|
||||
ESTitleId titleId);
|
||||
extern "C" bool iplSDChannelSelect_813DB4D4(ipl::scene::SDChannelSelect* channelSelect,
|
||||
ESTitleId titleId, u32 flags);
|
||||
extern "C" bool iplSDChannelSelect_813DB530(ipl::scene::SDChannelSelect* channelSelect,
|
||||
ESTitleId** titleNames, ESTitleId** secondaryTitles);
|
||||
extern "C" bool iplSDChannelSelect_813DB478(ipl::scene::SDChannelSelect* channelSelect,
|
||||
ESTitleId titleId);
|
||||
extern "C" bool iplSDChannelSelect_813DB58C(ipl::scene::SDChannelSelect* channelSelect,
|
||||
ESTitleId** titles, ESTitleId** secondaryTitles,
|
||||
ESTitleId** names);
|
||||
|
||||
namespace ipl {
|
||||
namespace scene {
|
||||
typedef ::gui::Component GuiComponent;
|
||||
typedef ::gui::PaneComponent GuiPaneComponent;
|
||||
typedef controller::Interface ControllerInterface;
|
||||
|
||||
void writeFourFlagBytes(u8* flags, u8 first, u8 second, u8 third, u8 fourth);
|
||||
|
||||
void setTitleRowColors(nw4r::lyt::TextBox* textBox, const nw4r::ut::Color& first,
|
||||
const nw4r::ut::Color& second) NO_INLINE;
|
||||
|
||||
static const char* sControlPaneNames[] = {
|
||||
"A", "B", "B_BtnA",
|
||||
};
|
||||
@@ -732,8 +708,8 @@ namespace ipl {
|
||||
if (!mpMainLayout->isPlaying(-1)) {
|
||||
switch (mProcessState) {
|
||||
case 0:
|
||||
if (iplSDChannelSelect_813DDB74(mpSDChannelSelect, &mNandTitleRange, &mSDTitleRange,
|
||||
mTitleIds, &mTitleNames[0][0], &mTitleCount, 2)) {
|
||||
if (mpSDChannelSelect->collectTitlesForMode(&mNandTitleRange.mByteSize, &mSDTitleRange.mByteSize,
|
||||
mTitleIds, mTitleNames, &mTitleCount, 2)) {
|
||||
mDialogState = 4;
|
||||
mpTitleLayout->getAnim(0)->initAnmFrame();
|
||||
mpTitleLayout->getAnim(0)->play();
|
||||
@@ -816,8 +792,8 @@ namespace ipl {
|
||||
|
||||
if (System::getDialog()->getLastResult() != -1) {
|
||||
if (mpSDChannelSelect->getWorker()->get_async_result() == NandSDWorker::RESULT_OK) {
|
||||
mNandTitleCount = mTitleListState.mSecondaryCount;
|
||||
mTitleNameCount = mTitleListState.mNameCount;
|
||||
mNandTitleCount = mNandTitleList.count;
|
||||
mTitleNameCount = mSDTitleList.count;
|
||||
} else {
|
||||
mNandTitleCount = 0;
|
||||
mTitleNameCount = 0;
|
||||
@@ -931,8 +907,7 @@ namespace ipl {
|
||||
return;
|
||||
}
|
||||
|
||||
if (iplSDChannelSelect_813DB530(mpSDChannelSelect, &mTitleListState.mpNames,
|
||||
&mTitleListState.mpSecondaryTitles)) {
|
||||
if (mpSDChannelSelect->enqueueErrorNotice(&mSDTitleList, &mNandTitleList)) {
|
||||
mDialogState = 19;
|
||||
mCurrentTitleName[0] = L'\0';
|
||||
mCurrentTitle = 0;
|
||||
@@ -1005,7 +980,7 @@ namespace ipl {
|
||||
if (iplSDMemory_containsTitleId(this, mTitleIds[mCurrentTitle], mSDTitleIds, mTitleNameCount) ||
|
||||
iplSDMemory_containsTitleId(this, mTitleIds[mCurrentTitle], mNandTitleIds, mNandTitleCount)) {
|
||||
ESTitleId titleId = mTitleIds[mCurrentTitle];
|
||||
if (iplSDChannelSelect_813DB478(mpSDChannelSelect, titleId)) {
|
||||
if (mpSDChannelSelect->enqueueMoveNotice(titleId)) {
|
||||
mDialogState = 14;
|
||||
} else {
|
||||
System::getDialog()->terminate();
|
||||
@@ -1055,7 +1030,7 @@ namespace ipl {
|
||||
|
||||
void SDMemory::onDialogState16() {
|
||||
if (mTitleCount > mCurrentTitle && System::isReceiveScheduleStopped()) {
|
||||
if (iplSDChannelSelect_813DB4D4(mpSDChannelSelect, mTitleIds[mCurrentTitle], 0)) {
|
||||
if (mpSDChannelSelect->enqueueStateNotice(mTitleIds[mCurrentTitle], 0)) {
|
||||
mDialogState = 16;
|
||||
} else {
|
||||
System::getDialog()->terminate();
|
||||
@@ -1110,7 +1085,7 @@ namespace ipl {
|
||||
System::getDialog()->setTitleForSDMemory(mCurrentTitleName);
|
||||
|
||||
const ESTitleId titleId = mTitleIds[mCurrentTitle];
|
||||
if (iplSDChannelSelect_813DB5EC(mpSDChannelSelect, titleId)) {
|
||||
if (mpSDChannelSelect->enqueueDeleteNotice(titleId)) {
|
||||
mDialogState = 18;
|
||||
} else {
|
||||
System::getDialog()->terminate();
|
||||
@@ -1269,10 +1244,6 @@ namespace ipl {
|
||||
}
|
||||
}
|
||||
|
||||
static inline void setChildrenAlpha(nw4r::lyt::Pane& pane, const u8 alpha);
|
||||
|
||||
#pragma push
|
||||
#pragma ppc_iro_level 1
|
||||
void SDMemory::drawTransferTitles() {
|
||||
f32 rowY;
|
||||
f32 rowTop;
|
||||
@@ -1289,16 +1260,13 @@ namespace ipl {
|
||||
nw4r::lyt::Pane* footerPane;
|
||||
u32 nandTitleIndex;
|
||||
u32 titleIndex;
|
||||
s32 visibleRows;
|
||||
s32 row;
|
||||
const wchar_t* messageForCount;
|
||||
wchar_t* messageForCount;
|
||||
s32 lineCount;
|
||||
const wchar_t* messageLine;
|
||||
s32 totalLines;
|
||||
s32 lineIndex;
|
||||
const wchar_t* lineEnd;
|
||||
u32 lineLength;
|
||||
wchar_t* messageLine;
|
||||
nw4r::lyt::TextBox* messageText;
|
||||
s32 lineIndex;
|
||||
wchar_t* lineEnd;
|
||||
u32 lineLength;
|
||||
const nw4r::math::VEC3& translation = mpDialogLayout->FindPaneByName("N_Memo")->GetTranslate();
|
||||
nw4r::math::VEC3 memoPosition;
|
||||
memoPosition.x = translation.x;
|
||||
@@ -1324,20 +1292,16 @@ namespace ipl {
|
||||
if (mNandTitleCount != 0) {
|
||||
messageForCount = System::getMessage(0xCB);
|
||||
lineCount = 0;
|
||||
const wchar_t* newline = wcsstr(messageForCount, L"\n");
|
||||
if (newline != NULL) {
|
||||
do {
|
||||
++lineCount;
|
||||
newline = wcsstr(newline + 1, L"\n");
|
||||
} while (newline != NULL);
|
||||
wchar_t* newline = wcsstr(messageForCount, L"\n");
|
||||
while (newline != NULL) {
|
||||
++lineCount;
|
||||
newline = wcsstr(newline + 1, L"\n");
|
||||
}
|
||||
|
||||
messageLine = System::getMessage(0xCB);
|
||||
messageText = static_cast<nw4r::lyt::TextBox*>(
|
||||
mpDialogLayout->FindPaneByName("T_Header_body"));
|
||||
totalLines = lineCount + 1;
|
||||
lineIndex = 0;
|
||||
for (; lineIndex < totalLines; ++lineIndex) {
|
||||
for (lineIndex = 0; lineIndex < lineCount + 1; ++lineIndex) {
|
||||
lineEnd = wcsstr(messageLine, L"\n");
|
||||
if (lineEnd == NULL) {
|
||||
utility::layout::set_string(messageText, messageLine);
|
||||
@@ -1366,7 +1330,11 @@ namespace ipl {
|
||||
|
||||
titleSizePane = mpDialogLayout->FindPaneByName("N_Body");
|
||||
rowHeight = titleSizePane->GetSize().height;
|
||||
setChildrenAlpha(*titleSizePane, alpha);
|
||||
nw4r::lyt::PaneList::Iterator bodyChild = titleSizePane->GetChildList().GetBeginIter();
|
||||
while (bodyChild != titleSizePane->GetChildList().GetEndIter()) {
|
||||
bodyChild->SetAlpha(alpha);
|
||||
++bodyChild;
|
||||
}
|
||||
|
||||
titleText = static_cast<nw4r::lyt::TextBox*>(
|
||||
mpDialogLayout->FindPaneByName("T_Letter"));
|
||||
@@ -1376,28 +1344,18 @@ namespace ipl {
|
||||
for (titleIndex = 0; titleIndex < mTitleCount; ++titleIndex) {
|
||||
utility::layout::set_string(titleText, mTitleNames[titleIndex]);
|
||||
if (nandTitleIndex < mNandTitleCount && mTitleIds[titleIndex] == mNandTitleIds[nandTitleIndex]) {
|
||||
GXColor gxActive;
|
||||
++nandTitleIndex;
|
||||
writeFourFlagBytes(&gxActive.r, 0x34, 0xBE, 0xED, 0xFF);
|
||||
GXColor activeColor = gxActive;
|
||||
GXColor activeTop = activeColor;
|
||||
GXColor activeBottom = activeColor;
|
||||
setTitleRowColors(titleText, *reinterpret_cast<const nw4r::ut::Color*>(&activeTop),
|
||||
*reinterpret_cast<const nw4r::ut::Color*>(&activeBottom));
|
||||
nw4r::ut::Color color(0x34, 0xBE, 0xED, 0xFF);
|
||||
titleText->SetTextColor(color, color);
|
||||
} else {
|
||||
GXColor gxInactive;
|
||||
writeFourFlagBytes(&gxInactive.r, 0x64, 0x64, 0x64, 0xFF);
|
||||
GXColor inactiveColor = gxInactive;
|
||||
GXColor inactiveTop = inactiveColor;
|
||||
GXColor inactiveBottom = inactiveColor;
|
||||
setTitleRowColors(titleText, *reinterpret_cast<const nw4r::ut::Color*>(&inactiveTop),
|
||||
*reinterpret_cast<const nw4r::ut::Color*>(&inactiveBottom));
|
||||
nw4r::ut::Color color(0x64, 0x64, 0x64, 0xFF);
|
||||
titleText->SetTextColor(color, color);
|
||||
}
|
||||
|
||||
nw4r::ut::Rect textRect = mpDialogLayout->getTextDrawRect("T_Letter");
|
||||
rowTop = textRect.bottom - textRect.top;
|
||||
visibleRows = static_cast<s32>(static_cast<f32>(ceil(-rowTop / titleSizePane->GetSize().height)));
|
||||
for (row = 0; row < visibleRows; ++row) {
|
||||
s32 visibleRows = static_cast<s32>(static_cast<f32>(ceil(-rowTop / titleSizePane->GetSize().height)));
|
||||
for (s32 row = 0; row < visibleRows; ++row) {
|
||||
rowY = bodyY + backgroundOffset;
|
||||
if (-500.0f < rowY && rowY < 500.0f) {
|
||||
nw4r::math::VEC2 translation(0.0f, backgroundOffset);
|
||||
@@ -1413,7 +1371,7 @@ namespace ipl {
|
||||
titleText->CalculateMtx(*mpDialogLayout->getDrawInfo());
|
||||
mpDialogLayout->draw(titleText);
|
||||
}
|
||||
titleOffset -= rowHeight * static_cast<f32>(visibleRows);
|
||||
titleOffset -= visibleRows * rowHeight;
|
||||
}
|
||||
|
||||
backgroundOffset += rowHeight;
|
||||
@@ -1435,27 +1393,6 @@ namespace ipl {
|
||||
mpDialogLayout->draw("N_Back");
|
||||
mpDialogLayout->draw("N_Move");
|
||||
}
|
||||
#pragma pop
|
||||
|
||||
static inline void setChildrenAlpha(nw4r::lyt::Pane& pane, const u8 alpha) {
|
||||
nw4r::lyt::PaneList::Iterator child = pane.GetChildList().GetBeginIter();
|
||||
while (child != pane.GetChildList().GetEndIter()) {
|
||||
child->SetAlpha(alpha);
|
||||
++child;
|
||||
}
|
||||
}
|
||||
|
||||
void writeFourFlagBytes(u8* flags, u8 first, u8 second, u8 third, u8 fourth) {
|
||||
flags[0] = first;
|
||||
flags[1] = second;
|
||||
flags[2] = third;
|
||||
flags[3] = fourth;
|
||||
}
|
||||
|
||||
void setTitleRowColors(nw4r::lyt::TextBox* textBox, const nw4r::ut::Color& first,
|
||||
const nw4r::ut::Color& second) NO_INLINE {
|
||||
textBox->SetTextColors(first, second);
|
||||
}
|
||||
|
||||
s32 SDMemory::getControlPaneIndex(const char* paneName) {
|
||||
s32 paneIndex = -1;
|
||||
@@ -1680,23 +1617,23 @@ namespace ipl {
|
||||
switch (paneIndex) {
|
||||
case 0:
|
||||
animator = mpTitleLayout->getAnim(7);
|
||||
iplSDChannelSelect_813DDB74(mpSDChannelSelect, &mNandTitleRange, &mSDTitleRange,
|
||||
mTitleIds, &mTitleNames[0][0], &mTitleCount, 0);
|
||||
mpSDChannelSelect->collectTitlesForMode(&mNandTitleRange.mByteSize, &mSDTitleRange.mByteSize,
|
||||
mTitleIds, mTitleNames, &mTitleCount, 0);
|
||||
break;
|
||||
case 1:
|
||||
animator = mpTitleLayout->getAnim(10);
|
||||
iplSDChannelSelect_813DDB74(mpSDChannelSelect, &mNandTitleRange, &mSDTitleRange,
|
||||
mTitleIds, &mTitleNames[0][0], &mTitleCount, 1);
|
||||
mpSDChannelSelect->collectTitlesForMode(&mNandTitleRange.mByteSize, &mSDTitleRange.mByteSize,
|
||||
mTitleIds, mTitleNames, &mTitleCount, 1);
|
||||
break;
|
||||
case 2:
|
||||
animator = mpTitleLayout->getAnim(13);
|
||||
iplSDChannelSelect_813DDB74(mpSDChannelSelect, &mNandTitleRange, &mSDTitleRange,
|
||||
mTitleIds, &mTitleNames[0][0], &mTitleCount, 2);
|
||||
mpSDChannelSelect->collectTitlesForMode(&mNandTitleRange.mByteSize, &mSDTitleRange.mByteSize,
|
||||
mTitleIds, mTitleNames, &mTitleCount, 2);
|
||||
break;
|
||||
case 3:
|
||||
animator = mpTitleLayout->getAnim(16);
|
||||
iplSDChannelSelect_813DDB74(mpSDChannelSelect, &mNandTitleRange, &mSDTitleRange,
|
||||
mTitleIds, &mTitleNames[0][0], &mTitleCount, 3);
|
||||
mpSDChannelSelect->collectTitlesForMode(&mNandTitleRange.mByteSize, &mSDTitleRange.mByteSize,
|
||||
mTitleIds, mTitleNames, &mTitleCount, 3);
|
||||
break;
|
||||
case 4:
|
||||
animator = mpTitleLayout->getAnim(4);
|
||||
@@ -1716,16 +1653,13 @@ namespace ipl {
|
||||
memset(mSDTitleIds, 0, sizeof(mSDTitleIds));
|
||||
mNandTitleCount = 0;
|
||||
mTitleNameCount = 0;
|
||||
mTitleListState.mpTitles = mTitleIds;
|
||||
mTitleListState.mCount = mTitleCount;
|
||||
mTitleListState.mpSecondaryTitles = mNandTitleIds;
|
||||
mTitleListState.mSecondaryCount = 0;
|
||||
mTitleListState.mpNames = mSDTitleIds;
|
||||
mTitleListState.mNameCount = 0;
|
||||
iplSDChannelSelect_813DB58C(mpSDChannelSelect,
|
||||
&mTitleListState.mpTitles,
|
||||
&mTitleListState.mpSecondaryTitles,
|
||||
&mTitleListState.mpNames);
|
||||
mTitleList.titleIds = mTitleIds;
|
||||
mTitleList.count = mTitleCount;
|
||||
mNandTitleList.titleIds = mNandTitleIds;
|
||||
mNandTitleList.count = 0;
|
||||
mSDTitleList.titleIds = mSDTitleIds;
|
||||
mSDTitleList.count = 0;
|
||||
mpSDChannelSelect->enqueueCommandNotice(&mTitleList, &mNandTitleList, &mSDTitleList);
|
||||
}
|
||||
|
||||
if (paneIndex == 4) {
|
||||
|
||||
@@ -352,7 +352,7 @@ namespace ipl {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SDChannelSelect::enqueueMoveNotice(u32 controller, u32 page, u32 index) {
|
||||
bool SDChannelSelect::enqueueMoveNotice(ESTitleId titleId) {
|
||||
if (mCurrentSDState != 6) {
|
||||
return false;
|
||||
}
|
||||
@@ -361,7 +361,7 @@ namespace ipl {
|
||||
command.type = 6;
|
||||
command.arguments.values[0] = 0;
|
||||
command.arguments.values[1] = 0;
|
||||
command.titleId = ((u64)page << 32) | index;
|
||||
command.titleId = titleId;
|
||||
mCommandQueue.push(command);
|
||||
return true;
|
||||
}
|
||||
@@ -380,36 +380,39 @@ namespace ipl {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SDChannelSelect::enqueueErrorNotice(u32 page, u32 index) {
|
||||
bool SDChannelSelect::enqueueErrorNotice(NandSDWorker::TitleIdList* newTitles,
|
||||
NandSDWorker::TitleIdList* replacingTitles) {
|
||||
if (mCurrentSDState != 6) {
|
||||
return false;
|
||||
}
|
||||
|
||||
SDChannelSelectCommand command;
|
||||
command.type = 11;
|
||||
command.arguments.values[0] = page;
|
||||
command.arguments.values[1] = index;
|
||||
command.arguments.titleLists[0] = newTitles;
|
||||
command.arguments.titleLists[1] = replacingTitles;
|
||||
command.titleId = 0;
|
||||
mCommandQueue.push(command);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SDChannelSelect::enqueueCommandNotice(u32 page, u32 index, u32 commandType) {
|
||||
bool SDChannelSelect::enqueueCommandNotice(NandSDWorker::TitleIdList* titles,
|
||||
NandSDWorker::TitleIdList* foundTitles,
|
||||
NandSDWorker::TitleIdList* badTitles) {
|
||||
if (mCurrentSDState != 6) {
|
||||
return false;
|
||||
}
|
||||
|
||||
SDChannelSelectCommand command;
|
||||
command.arguments.values[0] = page;
|
||||
command.arguments.titleLists[0] = titles;
|
||||
command.type = 12;
|
||||
command.arguments.values[1] = index;
|
||||
command.arguments.values[2] = commandType;
|
||||
command.arguments.titleLists[1] = foundTitles;
|
||||
command.arguments.titleLists[2] = badTitles;
|
||||
command.titleId = 0;
|
||||
mCommandQueue.push(command);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SDChannelSelect::enqueueDeleteNotice(u32 controller, u32 page, u32 index) {
|
||||
bool SDChannelSelect::enqueueDeleteNotice(ESTitleId titleId) {
|
||||
if (mCurrentSDState != 6) {
|
||||
return false;
|
||||
}
|
||||
@@ -419,7 +422,7 @@ namespace ipl {
|
||||
command.arguments.values[0] = 0;
|
||||
command.arguments.values[1] = 0;
|
||||
command.arguments.values[2] = 0;
|
||||
command.titleId = ((u64)page << 32) | index;
|
||||
command.titleId = titleId;
|
||||
mCommandQueue.push(command);
|
||||
return true;
|
||||
}
|
||||
@@ -1326,7 +1329,7 @@ namespace ipl {
|
||||
|
||||
bool SDChannelSelect::collectTitlesByUsage(
|
||||
s32* firstUsage, s32* secondUsage, ESTitleId* titleIds,
|
||||
char* titleNames, u32* titleCount) {
|
||||
wchar_t (*titleNames)[21], u32* titleCount) {
|
||||
s32 bytes;
|
||||
s32 blocks;
|
||||
getCurrentTitleUsage(&bytes, &blocks);
|
||||
@@ -1343,7 +1346,7 @@ namespace ipl {
|
||||
titleIds[*titleCount] = mpNandTitleInfo[index].curTitleId;
|
||||
wchar_t* titleName = System::getChannelManager()->getTitleName(
|
||||
page, channelIndex, 0);
|
||||
memcpy(titleNames + *titleCount * 0x2a, titleName, 0x2a);
|
||||
memcpy(titleNames[*titleCount], titleName, sizeof(*titleNames));
|
||||
++*titleCount;
|
||||
|
||||
if (bytes >= secondUsage[0] && blocks >= secondUsage[1]) {
|
||||
@@ -1361,7 +1364,7 @@ namespace ipl {
|
||||
|
||||
bool SDChannelSelect::collectTitlesFromNandUsage(
|
||||
s32* firstUsage, s32* secondUsage,
|
||||
ESTitleId* titleIds, char* titleNames, u32* titleCount) {
|
||||
ESTitleId* titleIds, wchar_t (*titleNames)[21], u32* titleCount) {
|
||||
s32 bytes;
|
||||
s32 blocks;
|
||||
getCurrentTitleUsage(&bytes, &blocks);
|
||||
@@ -1384,7 +1387,7 @@ namespace ipl {
|
||||
titleIds[*titleCount] = mpNandTitleInfo[index].curTitleId;
|
||||
wchar_t* titleName = System::getChannelManager()->getTitleName(
|
||||
page, channelIndex, 0);
|
||||
memcpy(titleNames + *titleCount * 0x2a, titleName, 0x2a);
|
||||
memcpy(titleNames[*titleCount], titleName, sizeof(*titleNames));
|
||||
++*titleCount;
|
||||
|
||||
if (bytes >= secondUsage[0] && blocks >= secondUsage[1]) {
|
||||
@@ -1400,7 +1403,7 @@ namespace ipl {
|
||||
|
||||
bool SDChannelSelect::collectTitlesByChannelOrder(
|
||||
s32* firstUsage, s32* secondUsage, ESTitleId* titleIds,
|
||||
char* titleNames, u32* titleCount) {
|
||||
wchar_t (*titleNames)[21], u32* titleCount) {
|
||||
static const int channelOrder[MAX_CHANNEL_INDEX] = {
|
||||
11, 7, 3, 10, 6, 2, 9, 5, 1, 8, 4, 0,
|
||||
};
|
||||
@@ -1427,7 +1430,7 @@ namespace ipl {
|
||||
titleIds[*titleCount] = mpNandTitleInfo[usageIndex].curTitleId;
|
||||
wchar_t* titleName =
|
||||
System::getChannelManager()->getTitleName(page, channelOrder[order], 0);
|
||||
memcpy(titleNames + *titleCount * 0x2a, titleName, 0x2a);
|
||||
memcpy(titleNames[*titleCount], titleName, sizeof(*titleNames));
|
||||
++*titleCount;
|
||||
|
||||
if (bytes >= secondUsage[0] && blocks >= secondUsage[1]) {
|
||||
@@ -1445,7 +1448,7 @@ namespace ipl {
|
||||
|
||||
bool SDChannelSelect::collectTitlesBySpecialChannels(
|
||||
s32* firstUsage, s32* secondUsage, ESTitleId* titleIds,
|
||||
char* titleNames, u32* titleCount) {
|
||||
wchar_t (*titleNames)[21], u32* titleCount) {
|
||||
s32 bytes;
|
||||
s32 blocks;
|
||||
getCurrentTitleUsage(&bytes, &blocks);
|
||||
@@ -1502,7 +1505,7 @@ namespace ipl {
|
||||
titleIds[*titleCount] = mpNandTitleInfo[usageIndex].curTitleId;
|
||||
wchar_t* titleName = System::getChannelManager()->getTitleName(
|
||||
page, channelIndex, 0);
|
||||
memcpy(titleNames + *titleCount * 0x2a, titleName, 0x2a);
|
||||
memcpy(titleNames[*titleCount], titleName, sizeof(*titleNames));
|
||||
++*titleCount;
|
||||
|
||||
if (bytes >= secondUsage[0] && blocks >= secondUsage[1]) {
|
||||
@@ -1528,7 +1531,7 @@ namespace ipl {
|
||||
titleIds[*titleCount] = mpNandTitleInfo[usageIndex].curTitleId;
|
||||
wchar_t* titleName = System::getChannelManager()->getTitleName(
|
||||
page, channelIndex, 0);
|
||||
memcpy(titleNames + *titleCount * 0x2a, titleName, 0x2a);
|
||||
memcpy(titleNames[*titleCount], titleName, sizeof(*titleNames));
|
||||
++*titleCount;
|
||||
|
||||
if (bytes >= secondUsage[0] && blocks >= secondUsage[1]) {
|
||||
@@ -1544,7 +1547,7 @@ namespace ipl {
|
||||
wchar_t* titleName =
|
||||
System::getChannelManager()->getTitleName(
|
||||
hadePage, hadeChannelIndex, 0);
|
||||
memcpy(titleNames + *titleCount * 0x2a, titleName, 0x2a);
|
||||
memcpy(titleNames[*titleCount], titleName, sizeof(*titleNames));
|
||||
++*titleCount;
|
||||
|
||||
if (bytes >= secondUsage[0] && blocks >= secondUsage[1]) {
|
||||
@@ -1559,7 +1562,7 @@ namespace ipl {
|
||||
wchar_t* titleName =
|
||||
System::getChannelManager()->getTitleName(
|
||||
hatePage, hateChannelIndex, 0);
|
||||
memcpy(titleNames + *titleCount * 0x2a, titleName, 0x2a);
|
||||
memcpy(titleNames[*titleCount], titleName, sizeof(*titleNames));
|
||||
++*titleCount;
|
||||
|
||||
if (bytes >= secondUsage[0] && blocks >= secondUsage[1]) {
|
||||
@@ -1575,7 +1578,7 @@ namespace ipl {
|
||||
|
||||
bool SDChannelSelect::collectTitlesForMode(
|
||||
s32* requiredBytes, s32* requiredBlocks,
|
||||
ESTitleId* titleIds, char* titleNames, u32* titleCount, int searchMode) {
|
||||
ESTitleId* titleIds, wchar_t (*titleNames)[21], u32* titleCount, int searchMode) {
|
||||
switch (searchMode) {
|
||||
case 0:
|
||||
return collectTitlesBySpecialChannels(
|
||||
|
||||
@@ -83,7 +83,6 @@ extern "C" void iplSDChannelTitle_setPageAndIndex(SDChannelTitle* scene, int pag
|
||||
extern "C" void iplSDChannelTitle_cleanupAndLeave(SDChannelTitle* scene);
|
||||
extern "C" void iplSDChannelTitle_confirmLeaveToSettings(SDChannelTitle* scene, bool settings);
|
||||
extern "C" void iplSDChannelTitle_flushSaveBeforeExit(SDChannelTitle* scene, int nextScene);
|
||||
extern "C" SDMemory::TitleRange* iplSDChannelTitle_copyTitleRange(SDMemory::TitleRange*, const SDMemory::TitleRange*);
|
||||
|
||||
static inline void setMemoryTitleLists(SDMemory* memory, SDMemory::TitleRange sdRange,
|
||||
SDMemory::TitleRange nandRange) {
|
||||
@@ -764,9 +763,9 @@ extern "C" void iplSDChannelTitle_updateCopyPrepare(SDChannelTitle* scene) {
|
||||
if (static_cast<u32>(scene->mTitleRange.mByteSize) < 0x3800000) {
|
||||
nandRange.mByteSize = 0x3800000;
|
||||
nandRange.mCount = scene->mTitleRange.mCount;
|
||||
iplSDChannelTitle_copyTitleRange(&sdRange, &scene->mTitleRange);
|
||||
sdRange = scene->mTitleRange;
|
||||
} else {
|
||||
iplSDChannelTitle_copyTitleRange(&nandRange, iplSDChannelTitle_copyTitleRange(&sdRange, &scene->mTitleRange));
|
||||
nandRange = sdRange = scene->mTitleRange;
|
||||
}
|
||||
SDMemory* memory = &scene->mMemory;
|
||||
setMemoryTitleLists(memory, sdRange, nandRange);
|
||||
@@ -788,14 +787,6 @@ extern "C" void iplSDChannelTitle_updateCopyPrepare(SDChannelTitle* scene) {
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" SDMemory::TitleRange* iplSDChannelTitle_copyTitleRange(
|
||||
SDMemory::TitleRange* target, const SDMemory::TitleRange* source) {
|
||||
s32 bytes = source->mByteSize;
|
||||
target->mCount = source->mCount;
|
||||
target->mByteSize = bytes;
|
||||
return target;
|
||||
}
|
||||
|
||||
extern "C" void iplSDChannelTitle_updateMemoryCalc(SDChannelTitle* scene) {
|
||||
if (!scene->mMemory.calc()) {
|
||||
return;
|
||||
|
||||
@@ -388,7 +388,7 @@ cleanup_done:
|
||||
|
||||
int AOSS_Init_old(AOSSInitInput* input)
|
||||
{
|
||||
s16 initialWait;
|
||||
short waitAttempt;
|
||||
AOSSReceiveBuffer* packetBuffer;
|
||||
AOSSPacketHeader* packetWords;
|
||||
u32 initialSleep;
|
||||
@@ -396,7 +396,7 @@ int AOSS_Init_old(AOSSInitInput* input)
|
||||
u32 resultCode;
|
||||
u32 flags;
|
||||
int state;
|
||||
int protocolState;
|
||||
int timeoutMilliseconds;
|
||||
u32 retryWait;
|
||||
u16 retryDelay;
|
||||
u32 delayStep;
|
||||
@@ -405,13 +405,13 @@ int AOSS_Init_old(AOSSInitInput* input)
|
||||
int requestResult;
|
||||
size_t manufacturerLength;
|
||||
int timeoutSeconds;
|
||||
int timeoutMilliseconds;
|
||||
int protocolState;
|
||||
int protocolResult;
|
||||
OSTime timeoutTicks;
|
||||
int initializationResult;
|
||||
short attemptCount;
|
||||
u16 remainingWait;
|
||||
short waitAttempt;
|
||||
s16 initialWait;
|
||||
u16 defaultConnection;
|
||||
u16 defaultResponse;
|
||||
union {
|
||||
@@ -624,7 +624,7 @@ int AOSS_Init_old(AOSSInitInput* input)
|
||||
goto finish_initialization;
|
||||
}
|
||||
s_accessPointConfig = (int *)AOSSi_Alloc(0x58);
|
||||
if (s_accessPointConfig == 0) {
|
||||
if ((int)s_accessPointConfig == 0) {
|
||||
input->status = 0xf;
|
||||
if (s_accessPointConfig) {
|
||||
AOSSi_Free(s_accessPointConfig);
|
||||
@@ -672,7 +672,7 @@ wait_for_initial_link:
|
||||
resultCode = 0xffffffff;
|
||||
goto finish_initialization;
|
||||
}
|
||||
if ((state == 0) && ((u32)*s_accessPointConfig == 1u)) goto handle_initial_link;
|
||||
if ((state == 0) && (*s_accessPointConfig == 1u)) goto handle_initial_link;
|
||||
remainingWait = (u16)waitIntervals.limits.response;
|
||||
for (; remainingWait != 0; remainingWait = (u16)(remainingWait - nextSleep)) {
|
||||
if (AOSSi_cancel_flag == 1) {
|
||||
@@ -878,7 +878,7 @@ request_socket_cleanup_complete:
|
||||
resultCode = 0xffffffff;
|
||||
goto finish_initialization;
|
||||
}
|
||||
if ((requestResult == 0) && (*s_accessPointConfig == 1)) break;
|
||||
if ((requestResult == 0) && ((u32)*s_accessPointConfig == 1u)) break;
|
||||
remainingWait = waitIntervals.limits.response;
|
||||
for (; remainingWait != 0; remainingWait -= initialSleep) {
|
||||
if (AOSSi_cancel_flag == 1) {
|
||||
@@ -1200,7 +1200,7 @@ wait_for_packet:
|
||||
goto finish_initialization;
|
||||
}
|
||||
s_accessPointConfig = (int *)AOSSi_Alloc(0x58);
|
||||
if (s_accessPointConfig == (int *)0x0) {
|
||||
if ((int)s_accessPointConfig == 0) {
|
||||
input->status = 0xf;
|
||||
if (s_accessPointConfig) {
|
||||
AOSSi_Free(s_accessPointConfig);
|
||||
@@ -1230,7 +1230,7 @@ wait_for_packet:
|
||||
resultCode = 0xffffffff;
|
||||
goto finish_initialization;
|
||||
}
|
||||
if ((state == 0) && (*s_accessPointConfig == 1)) break;
|
||||
if ((state == 0) && ((u32)*s_accessPointConfig == 1u)) break;
|
||||
remainingWait = waitIntervals.limits.response;
|
||||
for (; remainingWait != 0; remainingWait -= initialSleep) {
|
||||
if (AOSSi_cancel_flag == 1) {
|
||||
@@ -2510,6 +2510,8 @@ int AOSSXorBufferWithKey(void* packet, s32 length, char* key, int keyLength) {
|
||||
s32 index;
|
||||
int result = -1;
|
||||
u8* packetBytes;
|
||||
u8* mask;
|
||||
u8* output;
|
||||
|
||||
keyMask = (u8*)AOSSi_Alloc(halfLength);
|
||||
if (keyMask == 0) {
|
||||
@@ -2528,8 +2530,9 @@ int AOSSXorBufferWithKey(void* packet, s32 length, char* key, int keyLength) {
|
||||
for (round = 0; round < 2; round++) {
|
||||
keyIndex = round % keyLength;
|
||||
for (index = 0; index < halfLength; index++) {
|
||||
keyMask[index] = (u8)index;
|
||||
keyMask[index] = keyMask[index] ^ (u8)key[keyIndex];
|
||||
mask = &keyMask[index];
|
||||
*mask = (u8)index;
|
||||
*mask = *mask ^ (u8)key[keyIndex];
|
||||
keyIndex++;
|
||||
if (keyIndex >= keyLength) {
|
||||
keyIndex = 0;
|
||||
@@ -2537,9 +2540,9 @@ int AOSSXorBufferWithKey(void* packet, s32 length, char* key, int keyLength) {
|
||||
}
|
||||
|
||||
for (index = 0; index < halfLength; index++) {
|
||||
u8 inputByte = packetHalf[index];
|
||||
inputByte ^= keyMask[index];
|
||||
packetHalf[index] = inputByte;
|
||||
mask = &keyMask[index];
|
||||
output = &packetHalf[index];
|
||||
*output = *output ^ *mask;
|
||||
}
|
||||
|
||||
memcpy(temporary, packetHalf, halfLength);
|
||||
|
||||
@@ -127,15 +127,23 @@ int AOSSi_EndLocal(void) {
|
||||
}
|
||||
|
||||
int AOSSi_WLANGetBSSList(void** output) {
|
||||
int index;
|
||||
int driver;
|
||||
void* buffer;
|
||||
u8* scanBuffer;
|
||||
WDBssDesc* descriptor;
|
||||
int count;
|
||||
struct AOSSAccessPointList* list;
|
||||
int rate;
|
||||
int rateCount;
|
||||
int scanResult;
|
||||
int result = -1;
|
||||
int startupRetries = 0;
|
||||
int scanRetries = 0;
|
||||
int cleanupRetries = 0;
|
||||
int unlockRetries = 0;
|
||||
WDScanParam scan ATTRIBUTE_ALIGN(32);
|
||||
WD_Info info ATTRIBUTE_ALIGN(32);
|
||||
int unlockRetries = 0;
|
||||
int driver;
|
||||
u8* buffer;
|
||||
int cleanupRetries = 0;
|
||||
int scanRetries = 0;
|
||||
u8 macAddress[6];
|
||||
if (!allocateMemory || !releaseMemory) {
|
||||
return -1;
|
||||
@@ -159,6 +167,7 @@ startup:
|
||||
buffer = AOSSi_Alloc(0x3200);
|
||||
if (buffer) {
|
||||
memset(buffer, 0, 0x3200);
|
||||
scanBuffer = (u8*)buffer;
|
||||
scan.channelBit = info.enableChannel;
|
||||
scan.maxChannelTime = 40;
|
||||
memset(scan.bssid, 255, 6);
|
||||
@@ -167,15 +176,11 @@ startup:
|
||||
memset(scan.ssid, 0, 32);
|
||||
memset(scan.ssidMask, 255, 32);
|
||||
while (1) {
|
||||
int scanResult = WD_Scan(&scan, buffer, 0x3200);
|
||||
int count;
|
||||
struct AOSSAccessPointList* list;
|
||||
WDBssDesc* descriptor;
|
||||
int index;
|
||||
scanResult = WD_Scan(&scan, scanBuffer, 0x3200);
|
||||
if (scanResult != 0 && scanResult != WD_INTERNAL_ERR_4) {
|
||||
break;
|
||||
}
|
||||
count = *(u16*)buffer;
|
||||
count = *(u16*)scanBuffer;
|
||||
if (count != 0) {
|
||||
list = AOSSi_Alloc(sizeof(*list) + (count - 1) * sizeof(struct AOSSAccessPoint));
|
||||
if (!list) {
|
||||
@@ -183,10 +188,8 @@ startup:
|
||||
break;
|
||||
}
|
||||
list->count = count;
|
||||
descriptor = (WDBssDesc*)&buffer[2];
|
||||
descriptor = (WDBssDesc*)&scanBuffer[2];
|
||||
for (index = 0; index < count; ++index) {
|
||||
int rate;
|
||||
int rateCount;
|
||||
list->accessPoints[index].ssidLength = descriptor->ssidLength;
|
||||
memcpy(list->accessPoints[index].ssid, descriptor->ssid, 32);
|
||||
list->accessPoints[index].channel = descriptor->channel;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -892,68 +892,62 @@ s32 CArGBAOdh::cdj_c_colorConv(SArCDJ_OdhMaster* master, u8* sourceData, int for
|
||||
void CArGBAOdh::LineConv11(u8* source, u8* lumaOutput, u8* cbOutput, u8* crOutput, u16 width, u16 height,
|
||||
const long* conversionTable, int format) {
|
||||
u32 planeSize = (u32)width * (u32)height;
|
||||
const s32* table = conversionTable;
|
||||
u32 pixelIndex = 0;
|
||||
|
||||
for (int i = 0; i < width; i++) {
|
||||
s32 red;
|
||||
s32 green;
|
||||
s32 blue;
|
||||
s32 red;
|
||||
s32 green;
|
||||
s32 blue;
|
||||
s32 cbValue;
|
||||
s32 crValue;
|
||||
|
||||
if (format == ODH_FORMAT_RGB565) {
|
||||
u8* pixelSource = source + (pixelIndex & 0x1FFFFFFC) * 8 + (pixelIndex & 3) * 2;
|
||||
u16 pixel = pixelSource[1];
|
||||
pixel |= (u16)pixelSource[0] << 8;
|
||||
red = (pixel >> 11) & 0x1F;
|
||||
green = (pixel >> 6) & 0x1F;
|
||||
blue = pixel & 0x1F;
|
||||
} else if (format == ODH_FORMAT_RGBA8) {
|
||||
int blueOrPixelOffset = (pixelIndex & 0xFFFFFFFC) * 0x10 + (pixelIndex & 3) * 2;
|
||||
u8* pixel = source + blueOrPixelOffset;
|
||||
red = pixel[1] >> 3;
|
||||
green = pixel[0x20] >> 3;
|
||||
blue = pixel[0x21] >> 3;
|
||||
} else {
|
||||
int sourceOffset = (pixelIndex & 7) + (pixelIndex & 0x3FFFFFF8) * 4;
|
||||
float y = (float)source[sourceOffset] - colorConvert16;
|
||||
float cb = (float)source[planeSize + sourceOffset] - colorConvert128;
|
||||
float cr = (float)source[planeSize * 2 + sourceOffset] - colorConvert128;
|
||||
red = (int)(colorConvertY * y + colorConvertR * cr);
|
||||
green = (int)(colorConvertY * y - colorConvertG1 * cb - colorConvertG2 * cr);
|
||||
blue = (int)(colorConvertY * y + colorConvertB * cb);
|
||||
|
||||
if (red < 0) {
|
||||
red = 0;
|
||||
}
|
||||
if (0xFF < red) {
|
||||
red = 0xFF;
|
||||
}
|
||||
if (green < 0) {
|
||||
green = 0;
|
||||
}
|
||||
if (0xFF < green) {
|
||||
green = 0xFF;
|
||||
}
|
||||
if (blue < 0) {
|
||||
blue = 0;
|
||||
}
|
||||
if (0xFF < blue) {
|
||||
blue = 0xFF;
|
||||
}
|
||||
|
||||
red >>= 3;
|
||||
green >>= 3;
|
||||
blue >>= 3;
|
||||
if (format == ODH_FORMAT_RGB565) {
|
||||
int offset = (i & ~3) * 8 + (i & 3) * 2;
|
||||
u16 pixel = source[offset];
|
||||
pixel <<= 8;
|
||||
pixel |= source[offset + 1];
|
||||
red = (pixel >> 11) & 0x1F;
|
||||
green = (pixel >> 6) & 0x1F;
|
||||
blue = pixel & 0x1F;
|
||||
} else if (format == ODH_FORMAT_RGBA8) {
|
||||
int offset = (i & ~3) * 16 + (i & 3) * 2;
|
||||
red = source[offset + 1] >> 3;
|
||||
green = source[offset + 0x20] >> 3;
|
||||
blue = source[offset + 0x21] >> 3;
|
||||
} else {
|
||||
int offset = (i & 7) + (i & ~7) * 4;
|
||||
float y = source[offset] - colorConvert16;
|
||||
float cb = source[planeSize + offset] - colorConvert128;
|
||||
float cr = source[planeSize * 2 + offset] - colorConvert128;
|
||||
red = colorConvertY * y + colorConvertR * cr;
|
||||
green = colorConvertY * y - colorConvertG1 * cb - colorConvertG2 * cr;
|
||||
blue = colorConvertY * y + colorConvertB * cb;
|
||||
if (red < 0) {
|
||||
red = 0;
|
||||
}
|
||||
if (red > 0xFF) {
|
||||
red = 0xFF;
|
||||
}
|
||||
if (green < 0) {
|
||||
green = 0;
|
||||
}
|
||||
if (green > 0xFF) {
|
||||
green = 0xFF;
|
||||
}
|
||||
if (blue < 0) {
|
||||
blue = 0;
|
||||
}
|
||||
if (blue > 0xFF) {
|
||||
blue = 0xFF;
|
||||
}
|
||||
red >>= 3;
|
||||
green >>= 3;
|
||||
blue >>= 3;
|
||||
}
|
||||
|
||||
int cbValue = (table[red + 0x60] + table[green + 0x80] + table[blue + 0xA0]) >> 16;
|
||||
int crValue = (table[red + 0xC0] + table[green + 0xE0] + table[blue + 0x100]) >> 16;
|
||||
int luma = (table[red + 0] + table[green + 0x20] + table[blue + 0x40]) >> 16;
|
||||
|
||||
*lumaOutput++ = (u8)luma;
|
||||
*cbOutput++ = (u8)cbValue;
|
||||
*crOutput++ = (u8)crValue;
|
||||
pixelIndex++;
|
||||
cbValue = (conversionTable[red + 0x60] + conversionTable[green + 0x80] + conversionTable[blue + 0xA0]) >> 16;
|
||||
crValue = (conversionTable[red + 0xC0] + conversionTable[green + 0xE0] + conversionTable[blue + 0x100]) >> 16;
|
||||
*lumaOutput++ = (conversionTable[red] + conversionTable[green + 0x20] + conversionTable[blue + 0x40]) >> 16;
|
||||
*cbOutput++ = cbValue;
|
||||
*crOutput++ = crValue;
|
||||
}
|
||||
}
|
||||
void CArGBAOdh::fdct_fast(u32* coefficients, u8* samples, u32 stride, u32* quantizationTable) {
|
||||
@@ -2007,208 +2001,206 @@ void CArGBAOdh::LineDeconv22(u8* dest, u8* y, u8* cb, u8* cr, u16 width, u16 hei
|
||||
}
|
||||
|
||||
s32 CArGBAOdh::huffmanDecoder(u32* coefficientOutput, SArCDJ_HuffmanRequest* request, u16** huffmanTables, int component, u32 sourceLimit) {
|
||||
u32 bitBuffer;
|
||||
u32 tableCount;
|
||||
s32 decodeResult;
|
||||
int bitIndex;
|
||||
s32 maximumBitLength;
|
||||
int maxHuffmanBits;
|
||||
u16 tableEntry;
|
||||
s32 valueCategory;
|
||||
u32 tableIndex;
|
||||
u32 magnitudeMask;
|
||||
int bytesConsumed;
|
||||
u8* sourceCursor;
|
||||
u32 decodedSymbol;
|
||||
u32 bitCountAndMask;
|
||||
u32 bitOffset;
|
||||
int coefficient;
|
||||
s32 category;
|
||||
int bytesConsumed;
|
||||
u32 bitBuffer;
|
||||
int length;
|
||||
u32 tableIndex;
|
||||
int maxLength;
|
||||
u32 value;
|
||||
u32 mask;
|
||||
u32 leafIndex;
|
||||
u32 run;
|
||||
u32 i;
|
||||
|
||||
bytesConsumed = request->bytesConsumed;
|
||||
sourceCursor = request->bitstream;
|
||||
u32 bitOffset = *request->bitCount;
|
||||
bitOffset = *request->bitCount;
|
||||
|
||||
if ((u32)(bytesConsumed + 4) > sourceLimit) {
|
||||
decodeResult = ODH_ERROR_INVALID_BITSTREAM;
|
||||
} else {
|
||||
maximumBitLength = 0xB;
|
||||
bitBuffer = ((u32)*sourceCursor << 0x18) | ((u32)sourceCursor[1] << 0x10) | ((u32)sourceCursor[2] << 8) | sourceCursor[3];
|
||||
bitBuffer <<= bitOffset;
|
||||
if (component == 0) {
|
||||
maximumBitLength = 9;
|
||||
}
|
||||
bitIndex = 1;
|
||||
tableIndex = 0;
|
||||
maxHuffmanBits = (int)maximumBitLength;
|
||||
for (; bitIndex <= maxHuffmanBits; bitIndex++) {
|
||||
tableEntry = huffmanTables[0][tableIndex];
|
||||
decodedSymbol = (u32)tableEntry & 0x3FFF;
|
||||
if (((bitBuffer >> (0x20U - bitIndex)) & 1) == 0) {
|
||||
if ((tableEntry & 0x8000) != 0) {
|
||||
valueCategory = huffmanTables[0][tableIndex + decodedSymbol];
|
||||
break;
|
||||
}
|
||||
tableIndex = tableIndex + decodedSymbol;
|
||||
} else {
|
||||
if ((tableEntry & 0x4000) != 0) {
|
||||
u32 leafIndex = tableIndex + decodedSymbol + 1;
|
||||
valueCategory = huffmanTables[0][leafIndex];
|
||||
break;
|
||||
}
|
||||
tableIndex = tableIndex + decodedSymbol + 1;
|
||||
}
|
||||
}
|
||||
if (bitIndex > maxHuffmanBits) {
|
||||
decodeResult = ODH_ERROR_INVALID_BITSTREAM;
|
||||
return ODH_ERROR_INVALID_BITSTREAM;
|
||||
}
|
||||
|
||||
bitBuffer = ((u32)sourceCursor[0] << 24 | (u32)sourceCursor[1] << 16 | (u32)sourceCursor[2] << 8 | sourceCursor[3]) << bitOffset;
|
||||
maxLength = component == 0 ? 9 : 11;
|
||||
|
||||
length = 1;
|
||||
tableIndex = 0;
|
||||
for (; length <= maxLength; length++) {
|
||||
u32 branch;
|
||||
u16 node;
|
||||
|
||||
node = huffmanTables[0][tableIndex];
|
||||
branch = node & 0x3FFF;
|
||||
if (((bitBuffer >> (32 - length)) & 1) == 0) {
|
||||
if (node & 0x8000) {
|
||||
category = huffmanTables[0][tableIndex + branch];
|
||||
break;
|
||||
}
|
||||
tableIndex += branch;
|
||||
} else {
|
||||
if (valueCategory > 0) {
|
||||
bitCountAndMask = (1 << (valueCategory)) - 1;
|
||||
bitBuffer = bitCountAndMask & (bitBuffer >> ((0x20 - bitIndex) - valueCategory));
|
||||
if ((bitBuffer & (1 << (valueCategory - 1))) == 0) {
|
||||
bitBuffer = bitBuffer + 1 | ~bitCountAndMask;
|
||||
}
|
||||
} else {
|
||||
bitBuffer = 0;
|
||||
if (node & 0x4000) {
|
||||
leafIndex = tableIndex + branch + 1;
|
||||
category = huffmanTables[0][leafIndex];
|
||||
break;
|
||||
}
|
||||
u32** predictors = request->predictors;
|
||||
u32* predictor = predictors[component >> 1];
|
||||
bitCountAndMask = bitOffset + bitIndex + valueCategory;
|
||||
tableIndex = (bitCountAndMask >> 3);
|
||||
decodedSymbol = 1;
|
||||
bitIndex = (int)bitBuffer + *predictor;
|
||||
*coefficientOutput = bitIndex;
|
||||
*predictors[component >> 1] = bitIndex;
|
||||
while (bitCountAndMask >= 8) {
|
||||
sourceCursor++;
|
||||
bytesConsumed++;
|
||||
bitCountAndMask -= 8;
|
||||
}
|
||||
do {
|
||||
if ((u32)(bytesConsumed + 4) > sourceLimit) {
|
||||
decodeResult = ODH_ERROR_INVALID_BITSTREAM;
|
||||
goto finishDecode;
|
||||
}
|
||||
bitIndex = 1;
|
||||
tableIndex = 0;
|
||||
bitBuffer = ((u32)*sourceCursor << 0x18) | ((u32)sourceCursor[1] << 0x10) | ((u32)sourceCursor[2] << 8) | sourceCursor[3];
|
||||
bitBuffer <<= bitCountAndMask;
|
||||
maximumBitLength = 6;
|
||||
for (; maximumBitLength != 0; maximumBitLength--) {
|
||||
tableEntry = huffmanTables[1][tableIndex];
|
||||
tableCount = (u32)tableEntry & 0x3FFF;
|
||||
if (((bitBuffer >> (0x20U - bitIndex)) & 1) == 0) {
|
||||
if ((tableEntry & 0x8000) != 0) {
|
||||
valueCategory = huffmanTables[1][tableIndex + tableCount];
|
||||
break;
|
||||
}
|
||||
tableIndex = tableIndex + tableCount;
|
||||
} else {
|
||||
if ((tableEntry & 0x4000) != 0) {
|
||||
valueCategory = huffmanTables[1][tableIndex + tableCount + 1];
|
||||
break;
|
||||
}
|
||||
tableIndex = tableIndex + tableCount + 1;
|
||||
}
|
||||
bitIndex++;
|
||||
}
|
||||
if (bitIndex > 6) {
|
||||
decodeResult = ODH_ERROR_INVALID_BITSTREAM;
|
||||
goto finishDecode;
|
||||
}
|
||||
if (valueCategory == 7) {
|
||||
bitCountAndMask += bitIndex;
|
||||
tableIndex = (bitCountAndMask >> 3);
|
||||
while (bitCountAndMask >= 8) {
|
||||
sourceCursor++;
|
||||
bytesConsumed++;
|
||||
bitCountAndMask -= 8;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (valueCategory > 0) {
|
||||
tableIndex = (u32)(1 << (valueCategory)) - 1 &
|
||||
(bitBuffer >> ((0x20 - bitIndex) - valueCategory));
|
||||
if ((tableIndex & (u32)(1 << (valueCategory - 1))) == 0) {
|
||||
decodeResult = ODH_ERROR_INVALID_BITSTREAM;
|
||||
goto finishDecode;
|
||||
}
|
||||
} else {
|
||||
tableIndex = 0;
|
||||
}
|
||||
for (u32 zeroIndex = 0; zeroIndex < tableIndex; zeroIndex++) {
|
||||
coefficientOutput[decodedSymbol] = 0;
|
||||
decodedSymbol++;
|
||||
}
|
||||
bitCountAndMask = bitCountAndMask + bitIndex + valueCategory;
|
||||
tableIndex = (bitCountAndMask >> 3);
|
||||
while (bitCountAndMask >= 8) {
|
||||
sourceCursor++;
|
||||
bytesConsumed++;
|
||||
bitCountAndMask -= 8;
|
||||
}
|
||||
if ((u32)(bytesConsumed + 4) > sourceLimit) {
|
||||
decodeResult = ODH_ERROR_INVALID_BITSTREAM;
|
||||
goto finishDecode;
|
||||
}
|
||||
maximumBitLength = 0xB;
|
||||
bitBuffer = ((u32)*sourceCursor << 0x18) | ((u32)sourceCursor[1] << 0x10) | ((u32)sourceCursor[2] << 8) | sourceCursor[3];
|
||||
bitBuffer <<= bitCountAndMask;
|
||||
if (component == 0) {
|
||||
maximumBitLength = 9;
|
||||
}
|
||||
bitIndex = 1;
|
||||
tableIndex = 0;
|
||||
maxHuffmanBits = (int)maximumBitLength;
|
||||
for (; bitIndex <= maxHuffmanBits; bitIndex++) {
|
||||
tableEntry = huffmanTables[0][tableIndex];
|
||||
tableCount = (u32)tableEntry & 0x3FFF;
|
||||
if (((bitBuffer >> (0x20U - bitIndex)) & 1) == 0) {
|
||||
if ((tableEntry & 0x8000) != 0) {
|
||||
valueCategory = huffmanTables[0][tableIndex + tableCount];
|
||||
break;
|
||||
}
|
||||
tableIndex = tableIndex + tableCount;
|
||||
} else {
|
||||
if ((tableEntry & 0x4000) != 0) {
|
||||
valueCategory = huffmanTables[0][tableIndex + tableCount + 1];
|
||||
break;
|
||||
}
|
||||
tableIndex = tableIndex + tableCount + 1;
|
||||
}
|
||||
}
|
||||
if (bitIndex > maxHuffmanBits) {
|
||||
decodeResult = ODH_ERROR_INVALID_BITSTREAM;
|
||||
goto finishDecode;
|
||||
}
|
||||
if (valueCategory > 0) {
|
||||
magnitudeMask = (1 << (valueCategory)) - 1;
|
||||
bitBuffer = magnitudeMask & (bitBuffer >> ((0x20 - bitIndex) - valueCategory));
|
||||
if ((bitBuffer & (1 << (valueCategory - 1))) == 0) {
|
||||
bitBuffer = bitBuffer + 1 | ~magnitudeMask;
|
||||
}
|
||||
} else {
|
||||
bitBuffer = 0;
|
||||
}
|
||||
bitCountAndMask = bitCountAndMask + bitIndex + valueCategory;
|
||||
coefficientOutput[decodedSymbol] = bitBuffer;
|
||||
tableIndex = (bitCountAndMask >> 3);
|
||||
decodedSymbol = decodedSymbol + 1;
|
||||
while (bitCountAndMask >= 8) {
|
||||
sourceCursor++;
|
||||
bytesConsumed++;
|
||||
bitCountAndMask -= 8;
|
||||
}
|
||||
} while ((int)decodedSymbol < 0x40);
|
||||
for (; (int)decodedSymbol < 0x40; decodedSymbol++) {
|
||||
coefficientOutput[decodedSymbol] = 0;
|
||||
}
|
||||
request->bytesConsumed = bytesConsumed;
|
||||
decodeResult = 0;
|
||||
request->bitstream = sourceCursor;
|
||||
*request->bitCount = bitCountAndMask;
|
||||
tableIndex += branch + 1;
|
||||
}
|
||||
}
|
||||
finishDecode:
|
||||
return decodeResult;
|
||||
}
|
||||
|
||||
if (length > maxLength) {
|
||||
return ODH_ERROR_INVALID_BITSTREAM;
|
||||
}
|
||||
|
||||
if (category > 0) {
|
||||
mask = (1 << category) - 1;
|
||||
value = mask & (bitBuffer >> (32 - length - category));
|
||||
if ((value & (1 << (category - 1))) == 0) {
|
||||
value = (value + 1) | ~mask;
|
||||
}
|
||||
} else {
|
||||
value = 0;
|
||||
}
|
||||
|
||||
bitOffset += length + category;
|
||||
coefficient = 1;
|
||||
coefficientOutput[0] = value + *request->predictors[component >> 1];
|
||||
*request->predictors[component >> 1] = coefficientOutput[0];
|
||||
while (bitOffset >= 8) {
|
||||
sourceCursor++;
|
||||
bytesConsumed++;
|
||||
bitOffset -= 8;
|
||||
}
|
||||
|
||||
do {
|
||||
if ((u32)(bytesConsumed + 4) > sourceLimit) {
|
||||
return ODH_ERROR_INVALID_BITSTREAM;
|
||||
}
|
||||
|
||||
bitBuffer = ((u32)sourceCursor[0] << 24 | (u32)sourceCursor[1] << 16 | (u32)sourceCursor[2] << 8 | sourceCursor[3]) << bitOffset;
|
||||
length = 1;
|
||||
tableIndex = 0;
|
||||
for (; length <= 6; length++) {
|
||||
u32 branch;
|
||||
u16 node;
|
||||
|
||||
node = huffmanTables[1][tableIndex];
|
||||
branch = node & 0x3FFF;
|
||||
if (((bitBuffer >> (32 - length)) & 1) == 0) {
|
||||
if (node & 0x8000) {
|
||||
category = huffmanTables[1][tableIndex + branch];
|
||||
break;
|
||||
}
|
||||
tableIndex += branch;
|
||||
} else {
|
||||
if (node & 0x4000) {
|
||||
category = huffmanTables[1][tableIndex + branch + 1];
|
||||
break;
|
||||
}
|
||||
tableIndex += branch + 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (length > 6) {
|
||||
return ODH_ERROR_INVALID_BITSTREAM;
|
||||
}
|
||||
|
||||
if (category == 7) {
|
||||
bitOffset += length;
|
||||
while (bitOffset >= 8) {
|
||||
sourceCursor++;
|
||||
bytesConsumed++;
|
||||
bitOffset -= 8;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (category > 0) {
|
||||
run = ((1 << category) - 1) & (bitBuffer >> (32 - length - category));
|
||||
if ((run & (1 << (category - 1))) == 0) {
|
||||
return ODH_ERROR_INVALID_BITSTREAM;
|
||||
}
|
||||
} else {
|
||||
run = 0;
|
||||
}
|
||||
|
||||
for (i = 0; i < run; i++) {
|
||||
coefficientOutput[coefficient] = 0;
|
||||
coefficient++;
|
||||
}
|
||||
|
||||
bitOffset += length + category;
|
||||
while (bitOffset >= 8) {
|
||||
sourceCursor++;
|
||||
bytesConsumed++;
|
||||
bitOffset -= 8;
|
||||
}
|
||||
|
||||
if ((u32)(bytesConsumed + 4) > sourceLimit) {
|
||||
return ODH_ERROR_INVALID_BITSTREAM;
|
||||
}
|
||||
|
||||
bitBuffer = ((u32)sourceCursor[0] << 24 | (u32)sourceCursor[1] << 16 | (u32)sourceCursor[2] << 8 | sourceCursor[3]) << bitOffset;
|
||||
maxLength = component == 0 ? 9 : 11;
|
||||
|
||||
length = 1;
|
||||
tableIndex = 0;
|
||||
for (; length <= maxLength; length++) {
|
||||
u32 branch;
|
||||
u16 node;
|
||||
|
||||
node = huffmanTables[0][tableIndex];
|
||||
branch = node & 0x3FFF;
|
||||
if (((bitBuffer >> (32 - length)) & 1) == 0) {
|
||||
if (node & 0x8000) {
|
||||
category = huffmanTables[0][tableIndex + branch];
|
||||
break;
|
||||
}
|
||||
tableIndex += branch;
|
||||
} else {
|
||||
if (node & 0x4000) {
|
||||
category = huffmanTables[0][tableIndex + branch + 1];
|
||||
break;
|
||||
}
|
||||
tableIndex += branch + 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (length > maxLength) {
|
||||
return ODH_ERROR_INVALID_BITSTREAM;
|
||||
}
|
||||
|
||||
if (category > 0) {
|
||||
mask = (1 << category) - 1;
|
||||
value = mask & (bitBuffer >> (32 - length - category));
|
||||
if ((value & (1 << (category - 1))) == 0) {
|
||||
value = (value + 1) | ~mask;
|
||||
}
|
||||
} else {
|
||||
value = 0;
|
||||
}
|
||||
|
||||
coefficientOutput[coefficient++] = value;
|
||||
bitOffset += length + category;
|
||||
while (bitOffset >= 8) {
|
||||
sourceCursor++;
|
||||
bytesConsumed++;
|
||||
bitOffset -= 8;
|
||||
}
|
||||
} while (coefficient < 64);
|
||||
|
||||
for (; coefficient < 64; coefficient++) {
|
||||
coefficientOutput[coefficient] = 0;
|
||||
}
|
||||
|
||||
request->bytesConsumed = bytesConsumed;
|
||||
request->bitstream = sourceCursor;
|
||||
*request->bitCount = bitOffset;
|
||||
return 0;
|
||||
}
|
||||
void CArGBAOdh::idct_fast(const u8* rangeLimitTable, u32* coefficients, u32* quantizationTable, u8* destination, u32 stride) {
|
||||
int evenPart0, evenPart1, evenPart2, evenPart3, oddPart3, oddPart2, oddPart1, oddPart0;
|
||||
int butterflyTerm0, butterflyTerm1, butterflyTerm2, evenInnerSum;
|
||||
|
||||
58
tools/decomp-assist/CHANSVm-converter-const-20261009.md
Normal file
58
tools/decomp-assist/CHANSVm-converter-const-20261009.md
Normal file
@@ -0,0 +1,58 @@
|
||||
# CHANSVm converter input types
|
||||
|
||||
Base: `20cf9f9f25b13b8cd6910e07cc5eb71558845d4e`, target 43U only.
|
||||
|
||||
## Change and source review
|
||||
|
||||
`CHANSVmConvertToFloatFromStr` took a pointer-to-const source header while
|
||||
`VmConvertFunc` specified a mutable source header. The conversion table cast
|
||||
hid that incompatible function-pointer type at the indirect call.
|
||||
|
||||
Give all 11 converters and the callback typedef the same pointer-to-const
|
||||
source-header type, and remove the callback cast. All converters either read
|
||||
source values, ignore the source, or pass it through the read-only array-join
|
||||
path. They write only newly allocated result objects. Propagate the input type
|
||||
through `VmArrayJoinCommon`, `VmArrayJoinEstimateStrSize`, `VmArrayJoinSub`, and
|
||||
`VmArraySeekTop`, including the forward declaration. These helpers only read
|
||||
the source header; the join routines write the destination string and local
|
||||
state. `VmArraySeekTop` still returns a mutable chunk pointer because header
|
||||
constness is shallow and other callers can mutate array elements. No cast is
|
||||
needed at the array-join boundary.
|
||||
|
||||
The public `CHANSVmConvertObjectType` input remains mutable: its same-type fast
|
||||
path returns the original mutable object. Passing it to a const-source
|
||||
converter is valid. No executable expressions, flags, data or layout changed.
|
||||
|
||||
## Fresh leaf verification
|
||||
|
||||
Configured using the restored `wii-source-tools/build-43U.sh` tool paths and
|
||||
flags, with commands run in the isolated leaf instead of that script's fixed
|
||||
main directory. Baseline object was freshly compiled before editing.
|
||||
|
||||
- Entire CHANSVm object is byte-identical to that baseline, SHA256
|
||||
`11fa48261cd93668d133d5ef73efbf3c9109181730b21409153b78316189e063`.
|
||||
All 233 sibling function spans, allocated sections and relocations unchanged.
|
||||
- All 15 emitted converter/dispatch/join functions: exact-name objdiff 100.0,
|
||||
raw target function bytes and normalized relocation targets identical
|
||||
(86 code relocations). VmArraySeekTop is inlined.
|
||||
- All target data sections match including alignment padding: `.rodata` 1432,
|
||||
`.data` 4672, `.sdata2` 184, `.sdata` 600, `.sbss` 16 bytes;
|
||||
all 614 data relocations match by resolved section/function target.
|
||||
- Pool: 125/125 strings identical. Dispatch ctxdiff: 47/47 instructions, 0 diffs.
|
||||
FloatFromStr: 83/83 instructions, one textual symbol-alias difference
|
||||
(`VmNaN` versus `lbl_81694F08`); raw bytes and resolved relocation target are
|
||||
identical. This is not represented as a literal ctxdiff-zero result.
|
||||
- Fresh full 43U build, report and `build/43U/ok` pass. DOL SHA1:
|
||||
`26116613f624061ba99c8d1a299aaa6efa85670d`.
|
||||
- All 1028 unit measures/functions/sections and overall report measures are
|
||||
unchanged against the saved base report. All 22 workflow guards pass with
|
||||
no skips. `git diff --check` passes.
|
||||
|
||||
This is a binary-neutral type correction, not a new matching/linking gain.
|
||||
CHANSVm remains 229/233 exact, 45284/53564 exact code bytes, 6904/6904 matching
|
||||
data bytes, and unlinked. The completion assertion still fails on the existing
|
||||
project-wide incomplete code/link totals; no full-completion claim is made.
|
||||
|
||||
Local evidence: `../vm-converter-const-evidence/` contains baseline/candidate
|
||||
build logs, original baseline object/report, verification script/results,
|
||||
full-build/report/ok logs, pool and ctxdiff results, guards and completion logs.
|
||||
75
tools/decomp-assist/o2-aes-idct.attempts.md
Normal file
75
tools/decomp-assist/o2-aes-idct.attempts.md
Normal file
@@ -0,0 +1,75 @@
|
||||
# o2-aes-idct attempts
|
||||
|
||||
Worktree data-d11, branch agent/w1009/o2-aes-idct (from origin/main 20cf9f9f). 43U only.
|
||||
|
||||
## Unit-level checks
|
||||
|
||||
- Compiler sweep (all GC and Wii compilers; `-ipa file` dropped for GC < 3.0): aes GC/3.0a3 .. 3.0a5.2
|
||||
identical (7/9), older or Wii compilers worse. idct_block_var GC/3.0a3 .. 3.0a5.2 identical (0/2).
|
||||
Version is not the lever for either unit.
|
||||
- combosweep (single + pairwise pragmas): aes best 137 -> 135 (opt_propagation off), no lead.
|
||||
|
||||
## net/aes: AESiEncryptBlock 137 -> 0, AESiDecryptBlock 215 -> 0 (unit Matching, DOL OK)
|
||||
|
||||
Tooling: `tree.py` symbolically executes a function and compares the expression tree of every
|
||||
store against the target, independent of registers and scheduling. That separated "wrong
|
||||
dataflow" from "wrong allocation", which earlier rounds had mixed together.
|
||||
|
||||
Findings, in order:
|
||||
|
||||
1. The target round is plain rijndael-fst order `hi ^ m16 ^ m8 ^ lo`, then `^ key`. The target
|
||||
tree is `(lo ^ (m8 ^ (hi ^ m16))) ^ key`. At -O3/-O4 MWCC rebalances any 4-leaf XOR chain
|
||||
(tree height reduction): every one of the 120 shapes tried compiled to `(x^y)^(z^w)`. At
|
||||
optimization_level 2 it is not rebalanced, but level 2 cannot unroll the decrypt key loop,
|
||||
which the target does (mtctr 2), so the unit is O4.
|
||||
2. With the rotate written as the `__rlwinm(x, n, 0, 31)` intrinsic instead of the shift/or
|
||||
macro, O4 leaves the chain alone (intrinsic calls are not reassociated), and the natural
|
||||
expression gives exactly the target tree. It also removes the CSE temporaries the shift/or
|
||||
macro created for the table loads (x used twice), which is what had kept the allocation off.
|
||||
3. Final round: encrypt `(hi<<24 | m16<<16 | m8<<8 | lo) ^ key[i]`; decrypt is XOR-based with the
|
||||
key first, `key[i] ^ hi<<24 ^ m16<<16 ^ m8<<8 ^ lo` (O4 rebalances it the target way).
|
||||
4. Encrypt init: `state = input[i]; ... state ^= key[i]` with `key = context->keys` walked by
|
||||
`key += 4` (single-expression init put keys[i] in the state register; 9 diffs).
|
||||
5. Decrypt: `key = context->keys; key += rounds * 4;` (the one-expression form folds +16 into
|
||||
the loads). InvMixColumn as `static inline void AESiInvMixColumn(u32* word)` (pointer
|
||||
parameter) fixes the last r7/r8 swap between value and timesTwo; value-parameter helpers and
|
||||
all local declaration orders left 26+ diffs.
|
||||
|
||||
Rejected along the way: optimization_level 2 pragma (correct tree, wrong key loop), int/long
|
||||
casts between XOR stages (blocks rebalancing but unnatural).
|
||||
|
||||
`include/global/decomp/ide.h`: declared `__rlwinm` for non-MWCC tooling (guarded by
|
||||
`#ifndef __MWERKS__`, no build effect).
|
||||
|
||||
## buffer/idct_block_var: Lumi and Col (in progress)
|
||||
|
||||
Dataflow first (path-based symbolic execution of both objects, `ptree.py`):
|
||||
|
||||
1. Even part: the target computes `rot + (c6 + c2)` into a fresh variable. `x = rot + x` is
|
||||
rewritten by MWCC to `x += rot` (operand order `sum + rot`), and a single-use `evenSum`
|
||||
gets forward-substituted and reassociated (`c2 + (rot + c6)`). Fix: `evenSum = c6 + c2;
|
||||
c2 = evenRotation * 0xB5 >> 8; evenRotationSum = c2 + evenSum;` (the c2 reassignment
|
||||
blocks the substitution). Same in both passes of both functions.
|
||||
2. AC test: the target ORs leaf-first (`c2 | acc`). `acc |= c` or `acc = c | acc` with a u32/s32
|
||||
accumulator is canonicalised to acc-first, a single 7-way expression is rebalanced at O4.
|
||||
An `int` accumulator over `s32` coefficients (`acBits = c2 | acBits;`) keeps leaf-first
|
||||
(the long->int conversion stops the `|=` rewrite).
|
||||
3. Level 2 or 1 cannot be it: no CTR row loop at level 2 (274 vs 257 insns).
|
||||
|
||||
With 1-2, all store/call trees of Lumi (3 paths) and Col (4 paths) equal the target and the
|
||||
frame sizes match. Remaining differences are allocation and scheduling only.
|
||||
|
||||
Allocation findings (mwdbg + regsim, `wantmap.py` maps candidate vregs to target registers by
|
||||
symbolic value):
|
||||
|
||||
- Named locals are numbered per block in reverse declaration order, blocks top-down (function
|
||||
scope first), forward-substituted locals take no number; split webs and inline locals become
|
||||
`@` temps numbered after all named locals.
|
||||
- Column setup now matches exactly: `pitch4/7/6/5/3/2` as named locals assigned before the
|
||||
loop, a separate column cursor (`src`, not a split web of the row cursor), and
|
||||
`for (column = 7; column >= 0; column--)` (CTR trip count becomes a temp colored first).
|
||||
- Declaration-order search inside blocks on the captured graph tops out at 113/153 target
|
||||
registers, and a greedy order-feasibility check stalls on callee-saved claim order, so the
|
||||
column AC block still has a different pre-RA schedule (live ranges).
|
||||
- objdiff fuzzy is the gate metric and disagrees with positional diff counts; searches now
|
||||
score candidates with objdiff itself (`odfuzzy.py`, one-unit objdiff project per slot).
|
||||
84
tools/decomp-assist/o2-aoss.attempts.md
Normal file
84
tools/decomp-assist/o2-aoss.attempts.md
Normal file
@@ -0,0 +1,84 @@
|
||||
# o2-aoss attempts (2026-10-09)
|
||||
|
||||
Worktree data-d1, branch agent/w1009/o2-aoss at origin/main 20cf9f9f.
|
||||
Scratch compiles in /tmp/o2-aoss (same flags as ninja, ~0.2 s per unit).
|
||||
|
||||
## Findings that apply to both AOSSLink functions
|
||||
|
||||
- IRO is skipped for AOSSi_WLANGetBSSList and AOSSi_WLANConnect. Enabling
|
||||
MWCC's own IRO dump (flag byte 0x725e5c, log opened by 0x5ed500 in
|
||||
GC/3.0a5.2) shows both stop after IRO_BuildflowGraph. The cause is the
|
||||
check at 0x5bd060/0x5bd150: any EOBJREF to an object whose qualifiers carry
|
||||
alignment bits (0x1f000000) disables IRO for the whole function. Here that
|
||||
is `WD_Info info ATTRIBUTE_ALIGN(32)` (and `scan`). Removing the attribute
|
||||
makes IRO run, but it also drops the 32-byte frame alignment the target
|
||||
has. Type-level `ATTRIBUTE_ALIGN(32)` on the WD structs is ignored by this
|
||||
compiler (sizeof/alignof unchanged, no aligned frame), so the target also
|
||||
ran without IRO. Source shape maps almost 1:1 to PCode in these functions.
|
||||
- Ported MWCC's pre-RA list scheduler and the 750 machine model to Python
|
||||
(/tmp/o2-aoss/sched.py). It reproduces our B1/B14 of WLANConnect, the
|
||||
target B1, and our B19 of GetBSSList exactly. Facts it needed: stores to
|
||||
the same local at different offsets are independent; a store cannot issue
|
||||
while another store sits in LSU stage 2; ties go count -> height -> opcode
|
||||
rank (MR 0 < STH 1 < ADDI 2 < LHZ 3 < LI 4) -> program order.
|
||||
- With mwdbg extended with dump points before/after pre-RA scheduling and
|
||||
after each COptimizer level-4 pass (private copy, /tmp/o2-aoss/mwdbg2):
|
||||
the scheduler input for both blocks equals our final code minus nothing.
|
||||
Both target orders need one extra instruction in the block at scheduling
|
||||
time that is gone later (RA coalescing or post-schedule cleanup).
|
||||
|
||||
## AOSSi_WLANGetBSSList: 25 -> 3
|
||||
|
||||
regsim with the parameter pinned (/tmp/o2-aoss/ordanneal.py) found 1500
|
||||
declaration orders reaching all 11 target registers. Common constraints:
|
||||
index < driver < buffer < descriptor < count < cleanupRetries < unlockRetries
|
||||
and result < startupRetries < scanRetries. Declared C89-style at the top in
|
||||
that order (block-scoped declarations moved up): 25 -> 3, pool identical.
|
||||
|
||||
Remaining 3: block after `memset(buffer, 0, 0x3200)`, target issues
|
||||
`sth channelBit` before `li r5, 6` (so the lhz temp can be r5). Simulator:
|
||||
any one extra instruction in that block at scheduling time gives the target
|
||||
(dead VN copy, extra addi, ...). Tried, all still 3: `&scan.bssid`, scan
|
||||
pointer local, inline scan-param initializers (2 shapes), inline memset
|
||||
wrappers (void and returning), statement order permutations, unpacked WD
|
||||
structs (header override).
|
||||
|
||||
## AOSSi_WLANConnect: 2 (unchanged)
|
||||
|
||||
Second memset: target `li r4; li r5; mr r3, r27`, ours `li r4; mr r3; li r5`.
|
||||
Simulator: only an extra instruction on the address chain
|
||||
(lis -> addi -> X -> mr r3, X later coalesced) reproduces the target; no
|
||||
reordering of the block's inputs does, and a dead side copy does not.
|
||||
Explicit copies through a second local (i6, n3), inline helpers with a
|
||||
param or a cast local (m0/m1 x void/int x global/var), getter inline,
|
||||
NULL-initialised pointer, extern/global/static/struct-wrapped configs
|
||||
(struct gives `addi r27, r3, 0x160`: right order but one extra insn),
|
||||
array decay, casts: all removed by the COptimizer "pre" phase (peephole 0 +
|
||||
DCE) before scheduling, or by VN. 2 unchanged.
|
||||
|
||||
## AOSSi_WLANGetBSSList: 3 -> 0 (EXACT)
|
||||
|
||||
The missing instruction is a copy that lives until pre-RA scheduling and is
|
||||
coalesced by the allocator afterwards. A copy into a named local survives the
|
||||
COptimizer when its uses are in other blocks (the block-local peephole cannot
|
||||
rewrite them). A typed view of the scan buffer does exactly that:
|
||||
`void* buffer` for alloc/memset/free, `u8* scanBuffer = (u8*)buffer;` right
|
||||
after the memset, used by WD_Scan, the BSS count and the first descriptor.
|
||||
The copy sits in the scan-parameter block at scheduling time, so `sth` of
|
||||
channelBit issues before `li r5, 6` (target), then r24 holds both names.
|
||||
Variants that did not work: alias for the count pointer only (3), alias
|
||||
assigned before the memset (3).
|
||||
|
||||
## AOSSi_WLANConnect: more evidence (still 2)
|
||||
|
||||
- Pass tracing (dump after every COptimizer level-4 call): the in-block copy
|
||||
chain `addi vB; mr vC, vB; mr r3, vC` is collapsed by 0x596850 (block-local
|
||||
copy forwarding + DCE, pre phase); copies created later by value numbering
|
||||
(0x5976e0) get their uses canonicalised to the first holder. So a chain
|
||||
copy in the memset block cannot come from a plain second local.
|
||||
- Simulator searches: no input order, no 1-2 dead extra instructions
|
||||
(return copy, li, mr, addi, lis), no 1-2 side copies reproduce the target.
|
||||
Only (a) a copy on the address chain or (b) r4 and r5 both coming from
|
||||
register copies at scheduling time do.
|
||||
- Pragma sweep (15 single + all pairs, unit-wide, diagnostic): best is
|
||||
baseline 2; `peephole off` 11, `scheduling off` 50.
|
||||
105
tools/decomp-assist/o2-aterm.attempts.md
Normal file
105
tools/decomp-assist/o2-aterm.attempts.md
Normal file
@@ -0,0 +1,105 @@
|
||||
# o2-aterm attempts (ATERM, 2026-10-09)
|
||||
|
||||
Start (a6e74ad2): ATERM 22/26 exact; open: DiscoverAccessPoints 7, BuildEncryptedMessage 2,
|
||||
BuildAssociationRequest 28, RunConfigProtocol 294.
|
||||
End (2882435b): 25/26 exact; BuildEncryptedMessage 2 (scheduler tie-break, below). ATERM stays
|
||||
NonMatching.
|
||||
|
||||
## Prior art: the DS build of the same library
|
||||
|
||||
The DS DWC library ships the same NEC "AtermStation" code with its real static names
|
||||
(CacaBueno64/ie3ogres `lib/TwlDWC_dl/asm/util/atermset.s`, read-only). Name map:
|
||||
ScanAP = DiscoverAccessPoints, CheckAccessPoint = FindChangedApRecord, GetMacEncKey =
|
||||
BuildAssociationRequest, GetWLanSetElement = ParseAssociationResponse, AsciiToHex = ParseHexBytes,
|
||||
StoreNetParam = ApplyScanSecuritySettings, AutoConfigThreadEx = RunConfigProtocol,
|
||||
keywrap_encrypt/decrypt = AesKeyWrap/Unwrap, rijndael* = Aes*, MY_MD5Update = Md5Update,
|
||||
PutHex/PutMac = the hex and MAC formatters (non-inlined on DS, so their bodies are visible).
|
||||
|
||||
## MAC formatter (DiscoverAccessPoints 7 -> 0, BuildAssociationRequest 28 -> 0)
|
||||
|
||||
Cause: the register swap was input pointer r9 vs r5 and low nibble r5 vs r9. With the
|
||||
`nibbles[2]` array helper both nibbles are codegen temps, which are numbered above every inline
|
||||
variable and therefore colored first, so the low nibble always took r5 (array element types,
|
||||
declaration orders, 400 sampled formatter shapes, pragmas and compiler versions: no change).
|
||||
The DS PutHex keeps one nibble variable and rotates it: `h = (c & 0xF0) >> 4; for (2) { emit h;
|
||||
h = c & 0xF; }`. On MWCC the loop-invariant `c & 0xF` becomes an IR temp numbered below the
|
||||
inline locals, so it is colored last (r9), and PutMac's `*mac++` parameter takes r5. Both
|
||||
functions exact; ParseAssociationResponse (GetWLanSetElement calls PutHex on DS) stays exact with
|
||||
the same helper (`key += atermFormatHexByte(key, *optionValue++)`), so the separate straight-line
|
||||
atermEncodeHexByte is gone.
|
||||
|
||||
## Readability: scan buffer header
|
||||
|
||||
`(u16*)scanBuffer + 1` replaced by `((AtermScanBuffer*)scanBuffer)->descriptorWords`
|
||||
(count, then the descriptor word stream): 0 diffs. Typing the scanBuffer local itself as
|
||||
AtermScanBuffer* changes the alignment arithmetic (98 diffs, size 0x418).
|
||||
|
||||
## RunConfigProtocol (294 -> 2) = DS AutoConfigThreadEx
|
||||
|
||||
Rebuilt from the DS layout instead of the hand-inlined body: GetTickCount, Sleep (alarm), SendNotify,
|
||||
SendFrame -> SendBroadcast -> SendFrameViaInterface, GetFrameData/GetCommandElement,
|
||||
GetElementData/GetFirstElement, SetElementData/SetSingleElement/SetSearchRes, RFC 1321 MD5
|
||||
Init/Encode/Final/memset as static inlines, globals used directly (no request/packet/response/session
|
||||
pointer locals). Findings, each measured:
|
||||
- .bss order follows the first reference in the function IR. Passing a cast global address
|
||||
(`(u8*)&gAtermDecodedResponse`, `(u16*)buf`) into a static inline hoists it to the function entry
|
||||
and moves it first. The element buffer is a plain `u8[0x800]` in the original (like FrameData), so
|
||||
it is now one, with an AtermElementHeader view; that keeps the target order without pointer locals.
|
||||
- Inline helper uses of a global address get a hoisted register (r25/r31/r15) while direct call
|
||||
arguments rematerialize `addi rN, base, off`. This is plain MWCC behaviour, matching the target.
|
||||
- MD5: the exact RFC 1321 Encode/MD5_memset text (`unsigned int` lengths, `unsigned char` masks)
|
||||
keeps IRO from unrolling the Encode loops, so the PCode unroller produces the target's
|
||||
load/store order (u32 types: 35 diffs; RFC types: 0).
|
||||
- SetElementData must advance its own cursor parameter (`cursor += recordSize; return cursor;`)
|
||||
for the r16/r17 alternation; the value pointer as `cursor + sizeof(AtermOptionHeader)`.
|
||||
- GetFrameData returns `frame + sizeof(AtermFrameHeader)` (not `packet->payload`), declares
|
||||
`end` before `cursor` (inline locals number in reverse order); SetSingleElement writes through a
|
||||
header pointer local.
|
||||
Remaining 2 at 23addcb1: SetSearchRes' second element folds its value pointer to the first
|
||||
element's base (`addi r3, r16, 0xc`, target `addi r3, r17, 4`).
|
||||
|
||||
## RunConfigProtocol (2 -> 0): the DS SetElementData body with an int pad size
|
||||
|
||||
Found with IRO dumps. The compiler prints them once two dump flags are set: gdb breaks at
|
||||
0x5ed507 (log open) and writes 0x725e5c, then toggles 0x725e5c/0x70f24d per function at
|
||||
0x577716. That is o2-keyboard's /tmp/o2-keyboard/irodump1_gdb.py; the log is `<source>.log`. A
|
||||
copy that keeps its temporary source in this worktree is /tmp/o2-aterm/irod/run.sh. It drops
|
||||
the AES tables and the bodies after RunConfigProtocol, which leaves the function's code identical
|
||||
and takes about a minute.
|
||||
- Elements 1 and 2 share one IRO block. Block-local expression propagation chains element 2's
|
||||
cursor copies back to element 1's cursor temp, so element 2's `cursor + 4` reads element 1's
|
||||
temp. IRO_PropagateSelfAssignments (inc/dec propagation, 0x5f2150) then folds element 1's
|
||||
`+= 8` into it, giving base1 + 0xc. Elements 5 and 4 sit in their own blocks: global copy
|
||||
propagation reaches them one step at a time, so they fold onto the previous element's base,
|
||||
which is what the target does.
|
||||
- Inc/dec propagation is all-or-nothing per `+=` def. Every reached use must have that def as its
|
||||
only reaching definition. More than one use needs the helper at 0x5f24e0, which builds
|
||||
`var op const` and asks a backend predicate (0x56ac90).
|
||||
- The DS SetElementData does `p += sizeof(header); memset(p, 0, pad); memcpy(p, data, len);
|
||||
return p + pad`. A mid-body `+= 4` kills the copy before element 2's value uses. With
|
||||
`cursor += paddedLength; return cursor;` and an `int` (or unsigned int, u16, short) pad size, the
|
||||
first PropagateSelfAssignments round leaves those incs alone. Element 1's `+= 8` therefore
|
||||
reaches element 2's cursor copy (`@c2 = @c1 + 8`, no longer a copy) before any copy
|
||||
propagation reaches the value uses, and they stay `base2 + 4`. With `s32`/`u32` (long) pad
|
||||
sizes, the first round merges the `+= 4`. Second-pass copy propagation then rewrites the
|
||||
value uses to element 1's temp, and the fold comes back (2 diffs). A mini repro with `int`
|
||||
typedefs behaves like the `int` case, which is how the type dependence showed up. Measured
|
||||
variants: E4 (`+= pad; return cursor`) int/unsigned/u16/short: 0. E4 s32/u32: 2. E1 any type: 2.
|
||||
E3 (`return cursor + pad`) any type: 661.
|
||||
- Bisecting the full function (other switch cases, the loop condition, atermSleep, the
|
||||
epilogue) changed nothing. Only the helper text matters.
|
||||
|
||||
## BuildEncryptedMessage (2, unchanged): entry-block scheduler order
|
||||
|
||||
Target `mr r27,r5; mr r30,r3; mr r26,r4; mr r28,r6; mr r3,r27; mr r29,r7`; ours puts
|
||||
`mr r29,r7` before `mr r3,r27`. The mwdbg capture shows the entry block is list-scheduled before
|
||||
register allocation, with the program order r3..r7 parameter moves, `li checksum`, `mr r3,payload`,
|
||||
`li r4`, `li r5`, `bl memset`. The 750 model gives the memset call latency 0, and the GPR
|
||||
anti-dependency edges have latency 0. The call's operand list also clobbers r6 and r7. So the r6
|
||||
copy and the r7 copy have identical dependencies, unlocked-successor counts, heights,
|
||||
criticality and rank. Program order then always places both before `mr r3,payload`, but the
|
||||
target puts r6 before it and r7 after. Not reachable by:
|
||||
- K&R parameter declaration orders
|
||||
- every `#pragma scheduling` model (740/750/7400/altivec/on/reset: 2; others: 12-40)
|
||||
- key copies, extra param copies and inline wrappers (the earlier session)
|
||||
Recorded as a scheduler tie-break.
|
||||
112
tools/decomp-assist/o2-bs2mach.attempts.md
Normal file
112
tools/decomp-assist/o2-bs2mach.attempts.md
Normal file
@@ -0,0 +1,112 @@
|
||||
# o2-bs2mach attempts (BS2Mach: CheckBS2CommandStatus, BS2Tick)
|
||||
|
||||
Worktree data-d7, branch agent/w1009/o2-bs2mach, base 20cf9f9f (origin/main).
|
||||
Start: 27/29 exact, CheckBS2CommandStatus 2/406, BS2Tick 57/1940, data 158528/158528, pool 91/91.
|
||||
|
||||
## CheckBS2CommandStatus (lever 35)
|
||||
|
||||
Target case 0x12 issues `lwz count; stw CacheCommandComplete; slwi`: the completion
|
||||
store fills the load-latency slot, so it has no edge to the partition-count load
|
||||
through `DataToc`. A file-scope static may alias that pointer load, a
|
||||
function-local static whose address is never taken may not.
|
||||
|
||||
1. `static u32 CacheCommandComplete = 0;` inside CheckBS2CommandStatus (it is the
|
||||
only user), completion stored before the length update as in every other case:
|
||||
CheckBS2CommandStatus 0/406. Every other function unchanged, pool identical.
|
||||
The static lands at the end of .sbss (after LoaderInit) instead of 0x50.
|
||||
2. Compiler probe (same flags): initialized objects and function statics are
|
||||
emitted in parse order, tentative definitions after them in reverse definition
|
||||
order (`I1 I2 L$4 I3 T4 T3 T2 T1`).
|
||||
3. AudioBufferUnconfigured..LoaderInit made tentative (initializers dropped) and
|
||||
listed in reverse: .sbss order and offsets identical to the target, 28/29
|
||||
exact, data 158528/158528. Target symbol renamed `CacheCommandComplete$1964`
|
||||
in config/43U/symbols.txt (project convention for function statics).
|
||||
|
||||
## BS2Tick (57 at start)
|
||||
|
||||
4. Same lever in case 0: the target schedules `li 1` first and keeps the
|
||||
`AudioBufferUnconfigured = 1` store free of the absolute `*(u32 *)0x800030d4`
|
||||
store (unknown storage aliases every file-scope object, not a function static).
|
||||
AudioBufferUnconfigured, ResetTime and SpinupDeadline are only used by BS2Tick
|
||||
and sit right after CacheCommandComplete in .sbss. All three as BS2Tick
|
||||
statics: 57 -> 52; only AudioBufferUnconfigured as a static gives the same 52,
|
||||
so ResetTime/SpinupDeadline stay file-scope tentatives. Symbol renamed
|
||||
`AudioBufferUnconfigured$2066`. .sbss order identical.
|
||||
5. Store-before-load pairs the target keeps and we hoist (case 0x30
|
||||
`PartitionOpen = 0; if (RegionValid == 0)`, case 0x34/0x35
|
||||
`LoadingTitle = 0; switch (Block.state)`, case 0x40 `AbortFlag = 0;
|
||||
if (RestartRequested == 0)` and `RestartRequested = 0; if (FatalErrorFlag)`).
|
||||
Compiler probe with the unit's flags (/tmp/o2-bs2mach/probe/t2.c, t3.c): a
|
||||
store to one global followed by a load of another keeps its order only when
|
||||
BOTH are volatile; non-volatile/volatile, volatile/non-volatile, extern and
|
||||
address-taken globals are all reordered. So the target proves PartitionOpen,
|
||||
LoadingTitle, AbortFlag, RestartRequested and FatalErrorFlag volatile
|
||||
(RegionValid and DVDCommandBlock.state already are). AbortFlag is also read in
|
||||
BS2DVDCallback (interrupt context); RestartRequested/AbortFlag writers disable
|
||||
interrupts. One-at-a-time sweeps could not see the case-0x40 chain because it
|
||||
needs all three together. All five: 52 -> 42, other 28 functions unchanged.
|
||||
6. Device-code block (case 5): the initial PCode has a separate `lis 0x8000` per
|
||||
branch and backend value numbering merges them into the consoleType base. Per
|
||||
the MWCC decomp (ValueNumbering.c), `li`/`lis` are only value-numbered when the
|
||||
destination is a temporary inside the coalesce window; named locals never are.
|
||||
Reading consoleType through a named `OSBootInfo *bootInfo` and sharing the
|
||||
`State = BS2_STT_8` tail: 42 -> 28, block exact.
|
||||
7. Case 0: `DvdProgress = (u32 *)0x800030d4; ... *DvdProgress = 0;` (as case 2
|
||||
writes it) and testing `BS2NoDisk` directly: 28 -> 24 -> 12 together with 8.
|
||||
8. CoverOpenTimeHigh/Low are one 8-aligned big-endian OSTime: a single
|
||||
`OSTime CoverOpenTime` keeps CheckDVDCommandStatus exact (u64 store is low word
|
||||
first, as in the target) and makes the case-0x42 zero high word a later temp,
|
||||
fixing that whole register cluster (24 -> 14 at the time).
|
||||
9. Banner check: the target loads bannerFile.length straight into r6 because it is
|
||||
the 4th OSPanic argument; the format string has `(0x%08x)` and our call had no
|
||||
argument. Passing bannerFile.length fixes the cluster.
|
||||
10. RequiredIosHigh/Low are likewise one 8-aligned u64 (BS2StartGame reads it as a
|
||||
title ID with the `== 0 -> 1:3` default). `u64 RequiredIos` gives the target
|
||||
pair coloring (hi r0, lo r3, TMD r4) and keeps BS2StartGame exact.
|
||||
symbols.txt: CoverOpenTime and RequiredIos as size-8 objects (only BS2Mach
|
||||
referenced the halves; every relocation resolves to the same address).
|
||||
BS2Tick 4/1940 left: case 0 `CoverBlock.state = 0` is ordered before the
|
||||
volatile BS2NoDisk load (target: after).
|
||||
|
||||
### Volatile flags: per-flag evidence (current source, BS2Tick 4 diffs)
|
||||
Target pairs a store to one global with a later load of another and keeps that
|
||||
order; MWCC only does so when both are volatile (probe t2/t3: non-volatile,
|
||||
one-sided, extern and address-taken pairs are all reordered).
|
||||
- 0x3b04 case 0x30: `stw PartitionOpen; lwz RegionValid` (RegionValid volatile).
|
||||
- 0x3d68 case 0x34/0x35: `stw LoadingTitle; lwz Block.state` (state volatile).
|
||||
- 0x40a0 case 0x40: `stw AbortFlag; lwz RestartRequested`, then
|
||||
`stw RestartRequested; lwz FatalErrorFlag`.
|
||||
Dropping any single flag: PartitionOpen 4->7, LoadingTitle 4->6, AbortFlag 4->7,
|
||||
RestartRequested 4->9, FatalErrorFlag 4->6; no other function changes.
|
||||
|
||||
### Last 4 diffs: case 0 `CoverBlock.state = 0` vs the BS2NoDisk test
|
||||
Target: `lwz r0,BS2NoDisk; stw r4,AUC; cmpwi r0,0; stw r27,0xc(r3); beq`.
|
||||
Ours: the CoverBlock store precedes the load. Everything else in the block,
|
||||
including every register, already matches.
|
||||
- BS2NoDisk, DvdTransferred and DvdTransferLength are volatile (non-volatile
|
||||
BS2NoDisk hoists the load above both DvdTransfer stores; non-volatile
|
||||
DvdTransferred breaks BS2DVDCallback's order against DvdReadPending).
|
||||
- DVDCommandBlock.state reads are volatile in the target (BS2StartGame and
|
||||
BS2StartGCGame poll it with a re-read every iteration; case 0x34 above). With
|
||||
`state` non-volatile case 0 becomes exact but those break.
|
||||
- So the source reads BS2NoDisk before the store. Holding it in any variable
|
||||
(named, block-scoped, inline parameter/local, any same-width type) makes it a
|
||||
named/`@` local, numbered below statement temps and colored after the constant
|
||||
1: registers rotate (1 r0, BS2NoDisk r4, &PP r4, &0x800030d4 r5), 10 diffs.
|
||||
mwdbg capture o2-bs2mach-st + regsim what-if: coloring that holder first gives
|
||||
exactly the target (only those 4 nodes change). Narrow holders (u8/s8/u16/s16)
|
||||
force a statement temp and get everything right except `clrlwi.` vs `cmpwi`
|
||||
(1 diff). A 64-bit round trip is folded away.
|
||||
- Diagnostic only, both exact 29/29, both forbidden, not committed:
|
||||
`if ((BS2NoDisk | (CoverBlock.state = 0)) != 0)` (read then store in one
|
||||
expression) and `*(s32 *)&CoverBlock.state = 0;` (non-volatile store).
|
||||
No natural spelling found: hoisting a common leading store out of all three
|
||||
branches doesn't happen (size grows); statement order grid (84 builds),
|
||||
inline helpers, casts and holder types all stay at 4-10.
|
||||
- Pragma sweep (combosweep, single + pairwise): BS2Tick 4 -> 4.
|
||||
|
||||
### Tooling note
|
||||
`#pragma push / ppc_iro_level 0 / pop` tightly around BS2Tick (the last function
|
||||
in the file) leaves it byte-identical, which earlier rounds read as "IRO does not
|
||||
run on BS2Tick". A file-level `#pragma ppc_iro_level 0` changes BS2Tick in 1910
|
||||
instructions, so IRO does run; only the scoped placement is not honored for it.
|
||||
110
tools/decomp-assist/o2-cardseq-sdmem.attempts.md
Normal file
110
tools/decomp-assist/o2-cardseq-sdmem.attempts.md
Normal file
@@ -0,0 +1,110 @@
|
||||
# o2-cardseq-sdmem attempts
|
||||
|
||||
Branch `agent/w1009/o2-cardseq-sdmem` from `20cf9f9f`.
|
||||
|
||||
## iplSDMemory: SDMemory::drawTransferTitles (50 -> 0), unit linked
|
||||
|
||||
Start: 50/451 differing, register-only. Earlier Opus run (data-d9 `9b634499`) had brought it
|
||||
363 -> 50 with the MSL `wcsstr` overload and `TextBox::SetTextColor`.
|
||||
|
||||
### Diagnosis with mwdbg + regsim
|
||||
|
||||
Target vs ours, GPRs only:
|
||||
|
||||
- alpha r31 / string-pool base r30 / bodyPane, titleSizePane r29; ours r29 / r31 / r30.
|
||||
- line loop: lineCount r22, totalLines r23, `L"\n"` r24, messageLine r26, messageText r27,
|
||||
lineIndex r28; ours r19 / r19 / r23 / r20 / r26 / r24.
|
||||
|
||||
The capture shows vreg numbering = `this`, named locals (reverse declaration order), frontend
|
||||
temps (reverse creation order), then codegen vregs (string base r70 first). Coloring is reverse
|
||||
simplify order and picks the lowest free register, requesting saved registers from r31 down.
|
||||
Replaying the capture with relabelled vregs (`/tmp` wrapper around `regsim.simulate/color`)
|
||||
reproduced the whole target when:
|
||||
|
||||
1. alpha lives in a codegen vreg created after the string base (any number 71..150),
|
||||
2. totalLines sits between the third wcsstr's `s2` temp (v62) and lineEnd (v106/107),
|
||||
3. row and visibleRows are numbered below every line-loop local,
|
||||
4. messageText is numbered above lineIndex.
|
||||
|
||||
### Source changes that produce it
|
||||
|
||||
1. `nw4r::lyt::Pane::GetAlpha()` is `const` in real NW4R. With the const member the inline's
|
||||
result is a codegen value, not a frontend temp, and alpha moves above the string base.
|
||||
(An explicit `static_cast<u8>` around the call did the same; the const accessor is the real
|
||||
declaration, so that is what landed.) 50 -> 20.
|
||||
2. `visibleRows` / `row` declared in the title loop body (`s32 visibleRows = ...; for (s32 row = 0; ...)`). 20 -> 18.
|
||||
3. `messageText` declared before `lineIndex`. With 2: 13.
|
||||
4. No `totalLines` local: `for (lineIndex = 0; lineIndex < lineCount + 1; ++lineIndex)`.
|
||||
With 1-3: 0 differing.
|
||||
|
||||
Types of alpha tried first (u32, s32, int, u16): no change; s8/char: worse. A named
|
||||
`memoPane` local: no change.
|
||||
|
||||
### Linking the unit (Matching flip)
|
||||
|
||||
Flipping the unit failed to link: the source called six SDChannelSelect members through
|
||||
`extern "C" iplSDChannelSelect_813D....` placeholders. A temporary link with the existing
|
||||
mangled names linked but changed the DOL: one weak function survived dedup,
|
||||
`SDMemory::TitleRange::operator=`, because SDChannelTitle hand-wrote the same compiler-generated
|
||||
function as `extern "C" iplSDChannelTitle_copyTitleRange`. Fixes (all byte-identical where noted):
|
||||
|
||||
- SDChannelTitle: `sdRange = scene->mTitleRange;` / `nandRange = sdRange = scene->mTitleRange;`
|
||||
instead of the hand-written copy; symbols.txt names 0x813E6FA0
|
||||
`__as__Q43ipl5scene8SDMemory10TitleRangeFRCQ43ipl5scene8SDMemory10TitleRange` (scope:weak).
|
||||
The compiler emits it at the same place. Unit stays 69/69.
|
||||
- SDChannelSelect, real parameter types from the command dispatch and NandSDWorker:
|
||||
`enqueueMoveNotice(ESTitleId)` (type 6 -> copy_nand_app_to_sd_async), `enqueueDeleteNotice(ESTitleId)`
|
||||
(type 13), `enqueueErrorNotice(TitleIdList*, TitleIdList*)` (type 11 -> check_backup_fits_async),
|
||||
`enqueueCommandNotice(TitleIdList* x3)` (type 12; the worker casts paramA-C to TitleIdList*),
|
||||
collect* `titleNames` as `wchar_t (*)[21]`. Object bytes identical, only symbol names change
|
||||
(symbols.txt updated for the nine functions). `friend class SDMemory;` for the private members.
|
||||
- SDMemory: `TitleListState` was three `NandSDWorker::TitleIdList`s; it is now
|
||||
`mTitleList / mNandTitleList / mSDTitleList`, and the calls are member calls. Still 66/66.
|
||||
|
||||
Full build: DOL SHA1 26116613f624061ba99c8d1a299aaa6efa85670d with iplSDMemory Matching.
|
||||
gate.py (SDMemory, SDChannelSelect, SDChannelTitle) --quick: 0 regressions, GATE PASS.
|
||||
|
||||
## iplCardSequence: loadCardFileIcons (213 -> 135, equal size)
|
||||
|
||||
Kept (all functions of the unit otherwise unchanged, pool identical):
|
||||
|
||||
- Format-3 palette left uninitialized (lever 10). Asm proof: in the target icon loop r6 is
|
||||
paletteSize; its only writes are `li r6,0x400` (case 1), `li r6,0x800` (case 2) and `li r6,0`
|
||||
(case 0). Case 3 branches (`cmpwi r4,3; bge`) straight to the iconOffset update that reads r6
|
||||
(`add r22,r6,r22` / `add r21,r6,r21`) and `add r7,r7,r6`; no instruction writes r6 between
|
||||
function entry and the loop. Case 0 sets paletteSize to 0 itself. 213 -> 387 (511 insns) with
|
||||
the array form, -> 192 (512/512) with the existing `u8* iconPalette` pointer form.
|
||||
- Image read as `static inline s32 readCardImages(...)`: the target's CARDRead failure is
|
||||
`bge +8; b <check>` into the shared `if (result < 0)` test, the shape of an inlined early
|
||||
`return` (a goto folds to `blt`, a top-level return branches to the epilogue).
|
||||
- Comment read as `static inline s32 readCardComment(...)`: with only the image helper the two
|
||||
sector-size slots swapped (0x8/0xC); as a second inline its `sectorSize` gets 0x8 again, and
|
||||
its early `return 0` / final `return result` give the target's comment flow.
|
||||
- Banner/icon setup + image read as `loadCardIconImages(...)`, and the block base/offset split
|
||||
as `getCardBlockAddress(address, &offset)`: 231 -> 135, slot/fileNo/dir get r24/r25/r26.
|
||||
|
||||
Allocator analysis (mwdbg + regsim, a want-map derived by aligning backend-01/04 PCode with the
|
||||
target): remaining diffs are register-only. Target colors iconAddressBase r31, then the four
|
||||
CSE multipliers (fileNo*64 r30, slot*8128 r29, fileNo*4 r28, slot*508 r27), dir r26, fileNo r25,
|
||||
slot r24, iconAddressOffset r23; comment base r23 / offset r21 / readSize r22 / result r29.
|
||||
In the current capture iconAddressOffset sits in the last simplify scan (colored first, r31)
|
||||
and iconAddressBase leaves one scan earlier; no numbering of the existing temps fixes both.
|
||||
|
||||
### loadCardFileIcons 135 -> 126
|
||||
|
||||
- NONE case as `u8* previous = &...iconFmt[iconCount - 1]; ...iconFmt[iconCount] = *previous;`:
|
||||
gives the target's `add; lwz; addis; subi; add; lbz -1(p); stb 0(p)` shape (134). The array
|
||||
form and `p[-1]` forms keep the -0x6fb4 in the displacement instead.
|
||||
- Animation setup written in place with the icon loop's own `iconCount`/`shift`/`icon`, initialized
|
||||
`shift, iconCount, hasTlut, iconImageSize` in that order, early exit by `goto animationDone`.
|
||||
PCode value numbering reuses the first `li 0` of the block for the two zero stores; the target
|
||||
reuses the animation shift (r3), which only happens when shift is the first zero in that block.
|
||||
With the old helper the stores reused hasTlut. Anim region instruction order now matches.
|
||||
- Block base as the common subexpression `iconAddress & 0xFFFFFE00` (IRO CSE temp, numbered just
|
||||
above the CSE multipliers, as the simulator requires); offset `iconAddress - (iconAddress & ~0x1FF)`.
|
||||
Base, params and the four multipliers now get the target registers (126).
|
||||
|
||||
Tooling: private mwdbg copy on gdb port 9137 (/tmp/o2-cardseq-sdmem-mwdbg, retrowin32 rebuilt with
|
||||
the port patched) because the shared port queue timed out; IRO log via the known 2-byte patch of a
|
||||
/tmp copy of GC/3.0a5.2 (diagnosis only). Remaining in the simulator: transferSize must be numbered
|
||||
below the image offset, the comment base/offset/readSize above every other temp, result low.
|
||||
111
tools/decomp-assist/o2-chansvm.attempts.md
Normal file
111
tools/decomp-assist/o2-chansvm.attempts.md
Normal file
@@ -0,0 +1,111 @@
|
||||
# o2-chansvm: CHANSVm round 2 (WinEmuWrite, BlobGetHexString, BlobPackCommon, Step)
|
||||
|
||||
Worktree data-d2, branch agent/w1009/o2-chansvm, base 20cf9f9f. Start: WinEmuWrite 5, BlobGetHexString 14,
|
||||
BlobPackCommon 47, CHANSVmStep 262 (odiff differing instructions).
|
||||
Scratch: /tmp/o2-chansvm (score.py = whole-unit compile + per-function diff; t/ = one-function harness
|
||||
that reproduces the unit's codegen in under a second; tmw.sh = mwdbg on a harness file, ~8 s).
|
||||
|
||||
## VmWinEmuWrite: 5 -> 0 (exact)
|
||||
|
||||
Diff: strObj and totalLength swap r27/r29. mwdbg: every node is low-degree, so the color order is plain
|
||||
descending vreg number. Named locals are numbered first (reverse declaration order), then IR temps and
|
||||
inline locals (forward order), then codegen temps. The strObj value survived as the codegen temp of the
|
||||
call result (`mr r40, r3; mr r37, r40` -> r37 propagated away), so it always had the highest number of
|
||||
the loop values and took r29 first.
|
||||
|
||||
Copy-propagation probes on small functions (X1-X12 in t/x*.c): the backend replaces a named local by
|
||||
the call-result temp unless the named local has a copy use (`mr rX, local`). Load-base and compare uses
|
||||
do not block it; a copy use does (X8 vs X7). IRO removes plain `p = o` copies and inline parameters
|
||||
before the backend sees them (X11, X12).
|
||||
|
||||
`strObj = CHANSVmGetArgString(vm, 0)` (the real exported helper, inlined) leaves the inline's return
|
||||
temp (@1501, IR class) with a copy use, so that temp survives instead of the codegen temp. Moving the
|
||||
loop into a static inline helper numbers its locals after that temp, which gives the target order.
|
||||
|
||||
| attempt | Win | others |
|
||||
|---|---|---|
|
||||
| strObj assigned twice (GetArg, then Convert), 3 declaration orders | 5 / 8 / 8 | - |
|
||||
| for loop, guard clause, no `remaining`, if/else inLen, assign-in-if, nested if | 5 .. 54 | - |
|
||||
| GetArgString only | 5 | - |
|
||||
| loop in inline helper only (prior run) | 10 / 13 | - |
|
||||
| GetArgString + inline helper, locals offset, totalLength, buf, outLen, inLen | 5 (outLen/inLen slots swapped) | - |
|
||||
| GetArgString + inline helper, locals offset, totalLength, buf, inLen, outLen | 0 | no change, pool identical |
|
||||
|
||||
## VmBlobGetHexString: 14 -> 0 (exact)
|
||||
|
||||
Diff: loop registers. Target colors IV4 (byte offset +4) r4, the +2 counter r5, src r6, digit chain r7,
|
||||
hexTbl r8; ours had the counter and the digit chain swapped. The digit chain is codegen temps, so the
|
||||
counter and src must be numbered above it: both have to be strength-reduction IVs, created in the order
|
||||
src, counter, IV4.
|
||||
|
||||
Per-pass PCode dumps (private copy of mwdbg with a breakpoint after every pass call in the -O4 driver at
|
||||
0x5964c0, /tmp/o2-chansvm/mwdbgp) showed what each form does:
|
||||
- pass 10 (0x62be80) is strength reduction; pass 14 (0x62e8d0) the CTR conversion.
|
||||
- `src[byteIndex]` makes src an SR IV; `dest[byteIndex * 2]` gives IV4.
|
||||
- A separate +1 counter for the low index (`lowDigitIndex = i * 2 + 1; i++`) gives the target coloring,
|
||||
but SR rewrites i as `mr i, byteIndex`, which keeps byteIndex alive past the CTR conversion: two extra
|
||||
instructions (n=84).
|
||||
- `lowDigitIndex = byteIndex * 2 + 1` with matching signedness is folded by the front end into a
|
||||
displacement (`sth 2(rX)`, n=79).
|
||||
- A signed index variable fed from the unsigned counter blocks that fold: the low index stays
|
||||
`(cnt + 1) << 1` with cnt = SR(byteIndex << 1), created between src and IV4.
|
||||
|
||||
| attempt | Hex |
|
||||
|---|---|
|
||||
| 16 combinations of src (ptr/index) x high (destOff/byteIndex*2/i) x low index | 16 .. 48 |
|
||||
| byteIndex*2+1 low index forms (a1-a7), digitIndex++ forms (q1-q5), dest[j++] x2 (j1-j6) | 38 (n=79) |
|
||||
| separate +1 counter for the low index (m2, n1-n6, 24 declaration orders) | 50 (n=84) |
|
||||
| u32 counter, int/s32 low index (t_u32_int, c1, c5, c6) | 0 |
|
||||
| int highDigitIndex/lowDigitIndex from u32 byteIndex (c7, kept) | 0, no change elsewhere, pool identical |
|
||||
|
||||
## VmBlobPackCommon: 47 -> 0 (exact)
|
||||
|
||||
Diff: argArr (ours r23, target r18) and argCount/writeArgCount (ours r18, target r23). The allocator
|
||||
needs three simplify sweeps here, so sweep membership matters, not only numbering. A graph simulator
|
||||
(/tmp/o2-chansvm/packsim.py, built on regsim) traced remaining degrees per sweep:
|
||||
- Swapping the argArr/writeArgCount declaration slots alone fails: argArr reaches its sweep-2 scan
|
||||
with degree 29, one over the limit, and drags fmtLen/fmtStr/parentBlob into sweep 3.
|
||||
- With argArr one neighbour lighter at that point, the swap plus argCount declared between fmtPos and
|
||||
totalSize reproduces every target register.
|
||||
- Searching single-node renumberings found the neighbour: @10858, the `dataSize` local of the
|
||||
VmBlobCopyPadded inline. Inline locals are numbered after all declared locals; the target needs it
|
||||
in the declared range (ids 36..45), i.e. a local of PackCommon itself. srcOff and dest may sit
|
||||
anywhere (3855/4000 sampled placements hit).
|
||||
|
||||
Kept: the copy code written out in case 4 with writeBlobSrcOff/DataSize/Dest locals of the function,
|
||||
argArr and writeArgCount declarations swapped, argCount declared between fmtPos and totalSize.
|
||||
VmBlobCopyPadded (only used here) removed. Pool identical, no other function changed.
|
||||
|
||||
| attempt | Pack |
|
||||
|---|---|
|
||||
| shared argCount for both passes (merged node), all placements in the simulator | >= 28 misses |
|
||||
| shared counter, restricted declaration-order annealing (6 seeds) | 7 misses best |
|
||||
| simulator: swap only / swap + one edge cut / swap + merged loop constants | 3 / 2 / 0 misses |
|
||||
| simulator: swap + argCount slot + @10858 in declared range | 0 misses |
|
||||
| source: inline copy code with function-scope locals + two declaration moves | 0 |
|
||||
|
||||
## CHANSVmStep (in progress)
|
||||
|
||||
Structure first (opcode stream with registers masked, difflib-aligned; /tmp/o2-chansvm/opdiff.py),
|
||||
then allocation. Findings, each checked against the target object:
|
||||
- The target addresses VmResultTypeTbl and the constant objects off one .rodata base (r28 = .rodata+0,
|
||||
offsets 0x160.. and 0xa0). MWCC pools a section base only when a function references three or more
|
||||
distinct objects in it (/tmp/o2-chansvm/pool/p3.c: two objects never pool, three always do, global or
|
||||
static). VmResultTypeTbl (0xB4) has no relocation anywhere in the target: it is a dtk-inferred
|
||||
aggregate of five 6x6 tables (lever 13). Five separate tables give the pooled base.
|
||||
- `&CHANSVmConstStringObjectUndefined_[4]` takes two addis (array, then element); the target takes one
|
||||
(`addi r5, r28, 0xa0`), so those five 16-byte objects were separate too. With names, the `base[7]`
|
||||
hack in CHANSVmConvertToStrFromFloat goes away and that function stays exact.
|
||||
- `if (stepCount == 0) stepCount = 1;` plus `while (stepCount-- != 0)` (target enters the loop with a
|
||||
branch to the test at the bottom).
|
||||
- Stack: target 0x30 = object behind stackPtr (SET_INDEX), 0x40 = STORE_INDIRECT object, 0x50 load,
|
||||
0x60 operand. MWCC orders frame slots by size, ties in reverse declaration order (pool/s2.c), so
|
||||
`copies[2]` was two separate objects.
|
||||
- operandTypes filled through `&operandTypes[typeIdx]` (target keeps a +4 byte IV), not a walker.
|
||||
- BRANCH_CASE computes into a case-local result (target `li r3, ..` then `mr r14, r3` at the join)
|
||||
and stores the flag only on the OK path after the pop.
|
||||
- GET_PROPERTY_NAME: `foundEntry = 0` before the lookup, a one-case `switch (foundObj->type)` (target
|
||||
`beq +8; b far`), `shouldBranch = foundEntry` before `result = OK`, check reads shouldBranch.
|
||||
- BRANCH_CASE reads pObjStackTopBuf into stackTop before the stackDepth test.
|
||||
With these the opcode stream matches except three scheduling ties (511, 598, 836) that depend on
|
||||
registers; 297 register differences remain.
|
||||
67
tools/decomp-assist/o2-small.attempts.md
Normal file
67
tools/decomp-assist/o2-small.attempts.md
Normal file
@@ -0,0 +1,67 @@
|
||||
# o2-small attempts (2026-10-09)
|
||||
|
||||
Worktree `sol-low`, branch `agent/w1009/o2-mcm-pdm-nup`, base `20cf9f9f` (origin/main). Full build OK, DOL SHA1 `26116613…`.
|
||||
|
||||
## Compiler version check (all three units)
|
||||
|
||||
`/tmp/o2-small/ccsweep.py` compiles the unit with every GC and Wii compiler using the unit's exact flags (`-ipa file` dropped for GC/1.x-2.x, `NO_INLINE` stripped where those can't parse it) and counts instruction-exact functions.
|
||||
|
||||
| Unit | GC/1.x-2.7 | GC/3.0a3 … 3.0a5 | GC/3.0a5.2 | Wii 1.x |
|
||||
|---|---|---|---|---|
|
||||
| fa/pdm_partition | 5-7/20 | 19/20 (3.0a3 17/20 without NO_INLINE) | 19/20 | 15/20 |
|
||||
| nup/nup | 0/23 | 20-21/23 (GetAuditData 12) | 22/23 | 9-10/23 |
|
||||
| iplMemoryCardManager | does not compile | 25/26 (_create_icon 41) | 25/26 (_create_icon 37) | 22/26 |
|
||||
|
||||
All three stay on GC/3.0a5.2. `-proc` sweep for pdm (gekko, 750, 740, 7400, 7450, 603e, 604e, generic, 8xx, e300 …): gekko/750/740/7400 identical (19/20), every other model breaks other functions.
|
||||
|
||||
## Tooling built this round (all under /tmp/o2-small, not committed)
|
||||
|
||||
- `mwdbg/`: private copy of `_mwdbg` (shared lock) with extra PCode dump points: after backend optimizer (0x469383), around 0x596960(func,0) (0x4693a2/0x4693af, a no-op for scheduling), after the real first scheduling pass 0x5995c0(0) (0x4695dd), after 0x59a030 (store→load forwarding, 0x4695ee), before the second pass (0x469548).
|
||||
- `sim/sched750.py` + `model2.py`: the tw2004 (mitsevox/tw2004 tools/matching/sched750.py) GC/2.6 750 scheduler model, fixed for virtual CR fields (`cr10+` were not parsed) and record forms (`add. rD,…,cr0` defines cr0). GC/3.0a5.2's pick function (0x599920) and DAG builder (0x599ac0) were read from the binary: same rules as GC/2.6, except memory edges use the PCode alias objects (+0x1c, `0x5a0150`). Approximating that with "same base register" reproduces both scheduling passes of the pdm loop block exactly and 49/55 blocks over four pdm functions (the misses are blocks where one object is reached through two different base registers).
|
||||
|
||||
## libs/RVL_SDK/src/fa/pdm_partition: pdm_part_is_master_boot_sector (84/86 in repo)
|
||||
|
||||
- Plain-sum LE32 (`b0 + (b1<<8) + (b2<<16) + (b3<<24)`, same as the exact sibling's MBR_WORD) + indexed second loop: 21, equal size, exact add tree and loop 2. Only the first loop's byte-load schedule/registers differ.
|
||||
- First scheduling pass (0x5995c0(0)) input = initial code (the `*p_start` reload is still a `lwz`; 0x59a030 turns it into `mr` after the pass). Model reproduces our pass exactly: `s1` is picked over `s0` at cycle 2 because its shift makes one more successor ready.
|
||||
- Target register sharing (`s3`/`s1` in r9, `s0`/`s1<<8` in r11) needs a pre-allocation order with `s0` loaded before `s1` and `add (s2<<16)+s0` before `s1<<8`. Annealing over all register-consistent pre-allocation orders under the post-RA model: best 10 ('base' alias) / 8 (all memory ops ordered), never 0. Both residual spots are the same pattern: target issues the low byte load before a shift that frees the next load through an anti-dependence. So with these 24 instructions the target is unreachable; the original block had a different DAG (extra node or different alias edges).
|
||||
- Model experiments: an extra copy/zero-extend on `b0` in the first pass gives exactly the target load order (s3,s2,s0,s1 / c3,c2,c0,c1) but breaks the r11 sharing; keeping it through both passes (removed after) best 11.
|
||||
- Source variants tried this round (all 21 or worse): `& 0xFF`, `(pf_u8)`/`(pf_u16)` casts, `<< 0`, byte_at() helper, b0 local, u8-param make_u32 helper (all forms), u8 locals, pointer cursor, array-indexed first loop (24, same first-pass input), accumulator (43).
|
||||
|
||||
## libs/RVL_SDK/src/nup/nup: __nupParseServerInfo (66)
|
||||
|
||||
- Allocator: coloring order is descending vreg for these low-degree nodes; colour = lowest already-claimed callee-saved register that is free, else claim downward from r31 (regsim reproduces 162/162).
|
||||
- Per `__nupFindTag` expansion the vregs are: `start` = base, `endTag` = base+2, `startTag` = base+3, ret = base+4; `end` becomes a late temp (114, 120, …) because the backend copy propagation (0x596400) keeps the `strstr` result temp instead of the named `end` (declaring `end` first does not change that: it still becomes the temp).
|
||||
- Want-list for all 34 FindTag values built from the target. Arbitrary renumbering reaches 34/34 in regsim; constrained to in-block numbering also 34/34, but per-block orders differ: blocks 1-2 need (end < start < endTag < startTag), blocks 3-7 need (end < endTag < startTag < start). No single uniform order gets more than 26/34. Target block 2 claims r18 (end2) before blocks 3-7 reuse it.
|
||||
- Variants: end declared first 66, separate if-statements 469 (size).
|
||||
|
||||
## src/scene/memoryCard/iplMemoryCardManager: _create_icon (37)
|
||||
|
||||
- Callers (iplGCWindow) store the result in `const GXTexObj*`, and GXLoadTexObj takes `const GXTexObj*`. Declaring `create_icon`/`_create_icon` as returning `const GXTexObj*` (return type is not in the mangled name) with the banner-style helpers (`initIconTexture` returning `&cell.icon`, `initIconTextureCI`, `initIconPalette` with direct `&mFileCell[slot][file].iconTlut`) gives 11 with no casts. Address shapes all match; the only diff is the C8-path rotation slot*S r28/file*T r26/cellbase r27 (target r26/r27/r28).
|
||||
- regsim on the captured graph: either swapping the vreg numbers of the two IRO temps (file*T @2824 → r44, slot*S @2826 → r43) or adding the slot↔file*T interference that a `mulli`-before-`mullw` pre-allocation order would create gives the exact target colours.
|
||||
- IroCSE.c (rayanht/mwcc) shows temps are created in linear-IR order of each expression's first redundant occurrence (second loop of IRO_CommonSubs). Here that is the palette helper's address, where file*T is reached first. sol-r11's `cells` local fixes the order (3 diffs) but changes the TLUT address shape.
|
||||
- Variants tried (all ≥11): non-const `GXTexObj*` local 44, texture assigned before the palette 21, tlut local in helper 34, helper param types (u8/u16/u32/int/s16 × s32/u32/s16/u16/long) 11-91, `GXLoadTlut(initIconPalette(...))` 11, getter for the icon 44, `&(mFileCell[slot] + file)->…` 11 (same IR).
|
||||
|
||||
## Round 2 findings (same day)
|
||||
|
||||
### Landed locally
|
||||
- `6b6aeb4d` _create_icon 37 → 3: icon helpers mirroring the banner ones (palette helper walks `mFileCell[slot]`), `create_icon`/`_create_icon` return `const GXTexObj*` (iplGCWindow already stores the result as const; GXLoadTexObj takes const). No casts. Caller objects differ only in `.strtab`; DOL unchanged.
|
||||
- `7086ed4c` pdm_part_is_master_boot_sector 84 → 21: entries read with the file's existing `MBR_WORD` (same add tree as the exact pdm_part_get_start_sector), extent check indexed. Equal size; only the first loop's byte-load schedule differs.
|
||||
|
||||
### MWCC internals used (GC/3.0a5.2)
|
||||
- IRO dump: setting byte `[0x725e5c]` when the log is opened (bp at 0x5ed500) makes the compiler write `<source>.log` next to the source; also setting `[0x70f24d]` dumps the full linear IR after every IRO pass. Private mwdbg copy with its own gdb port (LD_PRELOAD bind remap) in /tmp/o2-small/mwdbg; run with `MWDBG_IRODUMP=full`. Delete the `.log` from the worktree afterwards.
|
||||
- IRO lowering order (rayanht/mwcc IrOptimizer.c): for a binary node the operand with the higher cost is lowered first, ties lower the RIGHT operand first; MUL behaves like cost+2. `&mFileCell[slot][file].x` becomes `((this + C) + slot*S) + file*T`, so file*T is serialized before slot*S.
|
||||
- IRO_CommonSubs mints a temp at the first redundant occurrence in that serialized order (IroCSE.c), and the backend numbers @temps in reverse creation order (earlier temp = higher vreg = coloured first).
|
||||
- IRO_SplitLifetimes renames a temp that is assigned on two exclusive paths: the later path's copy gets a new, late @temp (low vreg, coloured last).
|
||||
- PCode copy propagation (CopyPropagation.c) keeps a copy into a variable only if the variable is in the caller's initial named-object range or one of its uses is itself a move. This is why nup's helper `start` survives (`mr r3, start` feeds the second strstr) while `end` collapses into the late call-result temp.
|
||||
|
||||
### _create_icon status
|
||||
- The C8 rotation (slot*S r26 / file*T r27 / cellbase r28) needs slot*S coloured before file*T. Two sources were found that give it, neither complete:
|
||||
- `R2C2T2`: `GXLoadTexObj(initIconTexture(...))`, C8 `GXLoadTexObj(&mFileCell[slot][file].icon)`, `return &mFileCell[slot][file].icon` after the if/else. The join return makes the RGB and C8 file*T/cellbase temps one object; IRO_SplitLifetimes renames the C8 copies late → C8 exact. But the same join group merges the RGB GXInitTexObj argument with the post-call address (address kept across the call, r26), 8 diffs.
|
||||
- Row-pointer local in the palette helper (committed form): slot*S is minted first, but the TLUT address becomes `(row + file*T) + 0x112c` instead of `(row + 0x112c) + file*T`, 3 diffs.
|
||||
- Type experiments: with the original non-const return type, the RGB path recomputes after the call like the target (the const conversion of the GXInitTexObj argument keeps it out of the join group) but the C8 GXInitTexObjCI argument (non-const prototype) joins the group, 30. Making both GXInit prototypes match the real SDK (non-const) or both const: 27/33/46. SDK header restored each time; not changed.
|
||||
- Tiny-file probes (/tmp/o2-small/t): inner-index multiply is always minted first unless an earlier statement uses the bare row `cells[slot]`.
|
||||
- Function-scoped pragmas around _create_icon: wrapping alone changes size (+4), nothing below 34.
|
||||
|
||||
### nup
|
||||
- Pragma sweep (16 singles + all pairs, function-scoped) on __nupParseServerInfo: nothing below 66.
|
||||
- Literal-tag macro form: tag addresses are rematerialised each time (target keeps them in r22/r25-style registers), size 0x76c; per-block value/length locals: size 0x708. FindTag variants (end first, nested, result var, end+=, param order): 66 or worse.
|
||||
47
tools/decomp-assist/odh-source-integrity.attempts.md
Normal file
47
tools/decomp-assist/odh-source-integrity.attempts.md
Normal file
@@ -0,0 +1,47 @@
|
||||
# ODH source-integrity checks
|
||||
|
||||
Base: 3d7e767cf729de96ac1cd88ddbf5c18eaa08187d (43U only).
|
||||
|
||||
- Restored unsigned arithmetic in all three huffmanDecoder word refills by
|
||||
casting the shifted bytes to u32. The combined word and its bitOffset shift
|
||||
now remain unsigned, including input words with the high bit set.
|
||||
- Restored unsigned planeSize indexing in LineConv11. Chroma source pointers
|
||||
are only formed by accesses in the planar-format branch. The RGB565 caller
|
||||
passes a row-offset pointer into Capture's GXGetTexBufferSize allocation;
|
||||
for tile-aligned dimensions that allocation is exactly width*height*2 bytes.
|
||||
Unconditionally adding two planes to a nonzero row pointer could therefore
|
||||
form an out-of-bounds pointer even though RGB565 never dereferences it.
|
||||
- Reviewed the full huffmanDecoder rewrite against its preceding source.
|
||||
Other category shifts and caller/table preconditions were already present;
|
||||
no additional newly introduced arithmetic issue was identified in this pass.
|
||||
|
||||
One candidate, no compiler flags or other source changes. No debugger, compiler
|
||||
memory access, forced registers, assembly, uninitialized values, or online source
|
||||
references were used. Retail objects and disassembly remained local.
|
||||
|
||||
Validation:
|
||||
|
||||
- All allocated source-object sections, function spans, and resolved relocations
|
||||
are identical to the unmodified base object (debug metadata differs).
|
||||
- All 28 retail function spans are raw-byte exact: 14,684 bytes, with all 203
|
||||
relocations identical after resolving local symbols to actual section offsets
|
||||
and code symbols to function-relative targets.
|
||||
- Data matches: .rodata 5,856, .data 464, .sdata2 40 bytes. The source .data is
|
||||
459 bytes plus five zero alignment bytes in the split/link target.
|
||||
- Pool identical, 10/10 strings. huffmanDecoder ctxdiff: 306/306, zero diffs.
|
||||
LineConv11: 146/146; the strict-name local helper prints eight pre-existing
|
||||
label-name differences. Exact bytes, resolved relocation destinations, and
|
||||
referenced data independently match; none were ignored without resolution.
|
||||
- Official objdiff: ODH 28/28 functions; code, data, fuzzy and link all 100%.
|
||||
- Every measure, function and section in all 1,028 report units, plus all global
|
||||
measures, is unchanged from the base report.
|
||||
- Full 43U build and build/43U/ok pass. DOL SHA1:
|
||||
26116613f624061ba99c8d1a299aaa6efa85670d.
|
||||
- All 22 workflow-guard tests pass. A host UBSan refill test passes 524,288
|
||||
cases against a 64-bit oracle (every high byte, offsets 0..7).
|
||||
- The global completion checker still fails on pre-existing incomplete units;
|
||||
this change does not claim repository-wide completion.
|
||||
|
||||
Local reproducible evidence: ../odh-unsigned-refills-evidence/verify.py,
|
||||
verification.log, full-build.log, pool.log, guards.log, refill-test.cpp/log,
|
||||
completion.log, status.json and dol.sha1. No publication or merge performed.
|
||||
@@ -109,3 +109,35 @@ AOSS_Init_old 1306/1584, AOSSApplyAuthOptions 22/114, AOSSXorBufferWithKey 34/14
|
||||
AOSSData, 1128/1128). AOSS 18/21 exact (17 -> 18), code 7720 -> 8812/16192, ATERM 20/26 unchanged, pools
|
||||
identical, global matched code 97.12163 -> 97.15810, fuzzy 99.88565 -> 99.88839, data 100%, 0 forbidden, 0
|
||||
readability, DOL SHA1 OK.
|
||||
|
||||
# opus-aoss round 3 (2026-10-09): AOSSXorBufferWithKey, AOSS_Init_old
|
||||
|
||||
Worktree data-d1, branch agent/w1009/o-aoss at origin/main 72e9c8d6. Scratch
|
||||
compiles in /tmp/opus-aoss (same flags as ninja, 0.2 s per unit).
|
||||
|
||||
## AOSSXorBufferWithKey: 34 -> 0
|
||||
|
||||
mwdbg on the old forms (base, compound `^=`, `P = P ^ K`, `output` pointer)
|
||||
showed what decides the unrolled-loop registers. The second loop's index is
|
||||
an IRO temp split late, so it is numbered below the IRO CSE cursors
|
||||
(`packetHalf + index`, `keyMask + index`). With three per-copy values the
|
||||
cursors are high-degree and colored before the index, so the index never got
|
||||
r3. A function-scope `output` pointer (used for load and store) is a named
|
||||
local and survives; a single-use `mask` pointer inside only the second loop
|
||||
is propagated back into a CSE temp.
|
||||
|
||||
The fix is the same `mask` pointer used in both loops (the first loop writes
|
||||
the mask byte through it twice). Then both cursors stay named locals, the
|
||||
index temp is colored first (r3), mask (declared first) gets r4 and output
|
||||
r5, and `mask =` before `output =` gives the target add order.
|
||||
|
||||
| trial | differing |
|
||||
|---|---|
|
||||
| 14 loop-body spellings (compound, P^K, K^P, temps u8/u32/int, casts) | 37-57 |
|
||||
| 256-form sweep (P/K spellings x 16 bodies x shared/new index) | best 24 (`u8* output = &packetHalf[index]`) |
|
||||
| scoped pragma x every form above (15 pragmas) | best 24 |
|
||||
| `output`/`mask` function-scope, `mask` only in loop 2 | 24 |
|
||||
| `mask` in both loops, `output =` before `mask =` | 2 (add order) |
|
||||
| `mask` in both loops, `mask =` before `output =` | **0** |
|
||||
|
||||
Unit after: 20/21 exact, pool identical.
|
||||
|
||||
52
tools/decomp-assist/opus-aterm.attempts.md
Normal file
52
tools/decomp-assist/opus-aterm.attempts.md
Normal file
@@ -0,0 +1,52 @@
|
||||
# opus-aterm attempts (ATERM, 2026-10-09)
|
||||
|
||||
Baseline 72e9c8d6: ATERM 20/26 exact; open: BuildEncryptedMessage 2, AutoConfigThread 3,
|
||||
AesExpandEncryptKey 6, DiscoverAccessPoints 17, BuildAssociationRequest 28, RunConfigProtocol 294.
|
||||
|
||||
## Pragma sweep (combosweep, GC/3.0a5.2)
|
||||
|
||||
Single and pairwise pragmas: no function improves (BEST = base for all six).
|
||||
|
||||
## Compiler version (new finding)
|
||||
|
||||
Compiled the unchanged ATERM.c with every GC/Wii compiler that accepts the unit's flags:
|
||||
|
||||
| compiler | exact | total diffs | AutoConfigThread |
|
||||
| --- | ---: | ---: | ---: |
|
||||
| GC/3.0a3, 3.0a3.2, 3.0a3.3, 3.0a3.4, 3.0a5 | 21/26 | 347 | 0 |
|
||||
| GC/3.0a5.2 (previous) | 20/26 | 350 | 3 |
|
||||
| Wii/* | 7/26 | 1590+ | 5 |
|
||||
|
||||
GC/3.0a5 makes ATERMi_AutoConfigThread exact with no other function changing; pool identical,
|
||||
data 100%. The other third-party middleware in this project (Zi Corp eZiText, NHTTP, bte) is already
|
||||
built with GC/3.0a5. Set `mw_version="GC/3.0a5"` on ATERM.c.
|
||||
|
||||
## ATERMBuildEncryptedMessage (2: entry `mr r29,r7` / `mr r3,r27` swapped)
|
||||
|
||||
Read MWCC's scheduler (rayanht/mwcc decomp: Scheduler.c, MachineSimulation750.c) and wrote a model
|
||||
(/tmp/opus-aterm-sched/sim.py). It reproduces our entry block and six micro-tests exactly (count of
|
||||
unlocked successors, then height, then opcode rank mr < li, then program order; 2 IU slots).
|
||||
The entry block is scheduled once, before register allocation (block flag 8 stops the post-RA pass).
|
||||
Exhaustive search over that model: no order of the same ten PCode instructions with the parameter
|
||||
copies first gives the target, and no single extra/deleted instruction does either. The target order
|
||||
needs the copy of r7 to come after memset's first-argument move in the scheduler input.
|
||||
|
||||
## ATERMAesExpandEncryptKey (6 -> 0, EXACT)
|
||||
|
||||
The function is rijndaelKeySetupEnc from the public reference rijndael-alg-fst.c (Te4 = the
|
||||
substitution table, rcon = the round constants). Earlier forms (initialKey[] array + copy loop,
|
||||
hand-reassociated XOR trees) left the second key word's two XOR halves scheduled in the other order.
|
||||
Trials (all GC/3.0a5): array/scalar/direct stores x seven XOR associations: 9..268; reference
|
||||
GETU32 + reference loops verbatim: 3 (only cmplwi vs cmpwi); with the reference `int keyBits`: 0.
|
||||
|
||||
## ATERMDiscoverAccessPoints (17 -> 7)
|
||||
|
||||
mwdbg: callee-saved colors go r31 downward in decreasing vreg number. The three strength-reduced
|
||||
record pointers (entries[i].ssid, entries[i] base, entries[i].bssid) are compiler temps created in
|
||||
first-use order, so the target's increment order (ssid, base, bssid) means all three were indexed
|
||||
accesses, not named cursors. The descriptor start (scan buffer + 2) has r27 above them, so it is a
|
||||
loop-invariant expression hoisted after strength reduction, not a named local set before the loop.
|
||||
- indexed record fields, named firstDescriptor: 22 (increment order fixed, firstDescriptor r24)
|
||||
- descriptorWords = (u16*)scanBuffer + 1 inside the loop: 7; &((u16*)scanBuffer)[1]: 7;
|
||||
(u16*)(scanBuffer + 2) and (u16*)(scanBuffer + sizeof(u16)): 105 (size changes)
|
||||
Remaining 7: MAC formatter input pointer r9 vs target r5, low nibble r5 vs r9.
|
||||
44
tools/decomp-assist/opus-bs2update.attempts.md
Normal file
44
tools/decomp-assist/opus-bs2update.attempts.md
Normal file
@@ -0,0 +1,44 @@
|
||||
# opus-bs2update UpdateThread attempts
|
||||
|
||||
Worktree data-d10, branch agent/w1009/o-bs2update, base 72e9c8d6 (origin/main). Owned `src/BS2/BS2Update.c`; the fix also needs a one-line rename in `config/43U/symbols.txt` and the Matching flip in `configure.py`. Read opus-common, levers, the effort-policy entries, sol-x8, sol-y3 (`git show 4925fde2`) and sol-z1.
|
||||
|
||||
Start: UpdateThread 6/913 differing, equal size 0xe44. The other nine functions are exact. The remaining diffs are the three seat-loop scheduling swaps described by sol-x8, sol-y3 and sol-z1.
|
||||
|
||||
combosweep (single and pairwise allowed pragmas): `BEST src/BS2/BS2Update UpdateThread base 6 -> 6 []`. No pragma moves it.
|
||||
|
||||
## Diagnosis
|
||||
|
||||
The decompiled 1.2.5 scheduler (rayanht/mwcc `src/backend/Scheduler.c`, inspiredrobot/mwcc `docs/SCHEDULER.md`) adds a store-to-later-load edge for every memory pair the alias test cannot separate, with the store's latency. sol-y3's capture already showed that the seat loads carry a worst-case alias set that contains Flags0's bit, so `Flags0[index] = 0` wins the height race against the seat address `add`. The target schedules the `add` first. That is the order you get when no such edge exists.
|
||||
|
||||
I tested small probe functions with the unit's exact compiler flags: a loop that stores `FlagsX[i] = 0` and then tests `p[i].attr & 1`. The results:
|
||||
|
||||
| Seat entries come from | Flag array | Edge (store first)? |
|
||||
| --- | --- | --- |
|
||||
| absolute `T a[] : addr` (array, struct, single entry, const, static) | file-scope static | yes |
|
||||
| integer cast `(T*)0x80480000 + n` (folds to `addis`, wrong form anyway) | file-scope static | yes |
|
||||
| pointer parameter | file-scope static | yes |
|
||||
| normal relocated global array | file-scope static | no, but needs `lis/addi` with relocs (wrong form) |
|
||||
| absolute array (target's `lis r0,0x8048; add` form) | file-scope static, initialized or tentative, extern | yes |
|
||||
| absolute array | **function-local static** | **no** |
|
||||
| absolute array | global scalar / local stack array | no |
|
||||
|
||||
An unknown pointer (absolute storage counts as unknown) may alias every file-scope object, but not a function-local static whose address is never taken. The target keeps the absolute `lis r0, 0x8048; add` form and has no edge. So Flags0 was a function-local static of the selection code.
|
||||
|
||||
## .bss order
|
||||
|
||||
The target order is Flags0, Flags1, Thread, ThreadStack, UpdateHeader0, UpdateHeader1. Probes on the same compiler show the emission rules:
|
||||
- initialized objects are emitted where they are defined;
|
||||
- tentative definitions are emitted at their first use;
|
||||
- a function static is emitted when its function is parsed.
|
||||
|
||||
So the static has to come from a function parsed before BS2UpdateInit, and the other five arrays have to be tentative definitions. Init first uses Flags1, Thread and ThreadStack, and the inlined selection code first uses UpdateHeader0 and UpdateHeader1. That gives exactly the target order.
|
||||
|
||||
## Trials
|
||||
|
||||
1. `seatEntries = (BS2UpdateEntry*)0x80480000 + wadCount`: 549/912 (address folds into `addis`; the swaps stay). Rejected.
|
||||
2. `static u32 Flags0[...] = {0};` inside BS2SelectUpdateEntries, everything else unchanged: 18/913. All three swaps gone; the 18 left are .bss offsets because Flags0 lands after UpdateHeader1. Init 4 diffs from the same shift.
|
||||
3. As 2, but the Flags1/Thread/ThreadStack/UpdateHeader0/UpdateHeader1 definitions are tentative (the `= {0}` initializers dropped) and BS2SelectUpdateEntries is defined before BS2UpdateInit: **UpdateThread 0/913, all 10 functions exact**. .bss layout identical to the target, pool 55/55 identical.
|
||||
4. Rename the target symbol `Flags0` to the compiler's local-static name `Flags0$1129` in config/43U/symbols.txt. This is the project convention for function statics (144 `name$N` entries). Report: code 4052/4052, data 10488/10488, every section 100%, functions 10/10.
|
||||
5. Flip BS2Update to Matching and run the full build: DOL SHA1 26116613f624061ba99c8d1a299aaa6efa85670d. build.ninja links build/43U/src/src/BS2/BS2Update.o.
|
||||
|
||||
No pragma, asm, volatile change, carrier, padding or dummy is added. The source change is: the selection helper moves above BS2UpdateInit, Flags0 becomes its function static, and five `= {0}` initializers are removed.
|
||||
61
tools/decomp-assist/opus-candbox.attempts.md
Normal file
61
tools/decomp-assist/opus-candbox.attempts.md
Normal file
@@ -0,0 +1,61 @@
|
||||
# opus-candbox attempts
|
||||
|
||||
Worktree `sol-high`, branch `agent/w1009/o-candbox`, base `72e9c8d6`. Unit `src/keyboard/tiCandidateBox`, last open function `LayoutByNW4R::createAnmPane_` (6/216, count r23 and slot r31 swapped). Read opus-common.md, levers.md, effort-policy entries, sol-x9 log, sol-m4 log (branch `agent/w1009/candbox-max`), saved sol-r12/sol-y11 diffs.
|
||||
|
||||
Baseline: full build OK, DOL `26116613...`, odiff 6/216, pool identical 57/57. combosweep (single and pairwise pragmas): `base 6 -> 6`, no hit.
|
||||
|
||||
## Root cause
|
||||
|
||||
`tiPredictLang::create` is already exact and has the same inner loop with the same struct (`char paneName[20]`, `count`, `forceAddName`, `pAnims[8]`). Its target has count r31 and slot r23, which is what createAnmPane_ needs.
|
||||
|
||||
A private mwdbg trace of `tiPredictLang::create` (port 19931 copy of the launcher, shared tool unchanged) shows why. The slot base `p + j*4` is IRO CSE temp `@7026` (vreg r45) and forceAddName is IRO temp `@7028` (r44). Both are numbered after the named locals and before the hoisted constructor constants, so they simplify before the constants and color after them (slot r23). Count is a late anonymous load hoisted out of the loop condition (r131), so it colors first (r31).
|
||||
|
||||
The same natural loop inside tiCandidateBox (`j < paneAnimations.count`, `paneAnimations.pAnims[j]->` three times) gives 220 insns. No IRO temps are created, the slot is recomputed in each branch, and constant `2` survives pass-1 spilling.
|
||||
|
||||
Table declaration trials with that loop:
|
||||
|
||||
| trial | table | result |
|
||||
| --- | --- | --- |
|
||||
| 01 | `extern "C" const CandidatePaneData scCandidatePaneData` (struct wrapper, aligned(8)) | 158/220 |
|
||||
| 02 | `static const CandidatePaneData` (struct wrapper) | 158/220 |
|
||||
| 03 | `extern "C" const PaneToAnimation[]` (plain array) | 158/220 |
|
||||
| 04 | `static const PaneToAnimation[]` (plain array, no aligned) | **0/216** |
|
||||
|
||||
IRO only CSEs the table loads and addresses when the table is a static plain array, which is how every sibling unit declares it (`csPaneToAnimation`). The `CandidatePaneData` wrapper and `extern "C"` were decomp scaffolding. Without `aligned(8)` the table still lands at .data 0x28, size 0x680.
|
||||
|
||||
## Source changes
|
||||
|
||||
- Table: `static const PaneToAnimation csPaneToAnimation[]`, same name as tiToolBar/tiPredictLang/pctype. Removed the unused `CandidatePaneData` struct.
|
||||
- `createAnmPane_`: the tiPredictLang/tiToolBar loop form, with no count/forceAddName/animation locals.
|
||||
- symbols.txt: `scCandidatePaneData` -> `csPaneToAnimation__Q29textinput12candidatebox` (scope:local). Same address and size. Only tiCandidateBox referenced the old name.
|
||||
|
||||
Unit after this: 112/112 functions, code 100%, data 100%, all sections 100%, pool identical.
|
||||
|
||||
## Link (Matching flip)
|
||||
|
||||
First flip: DOL `8d444a7b...`. Two causes, both checked against the original objects:
|
||||
|
||||
1. Thunk order. Target `@36@__dt__` comes before `@36@setRootPaneScaleFor4x3..init`; ours put it last (already true on the old baseline). This is the "move to end on touch" thunk list (eggAudioExpMgr, lever 12). tiPredictLang/tiToolBar/tiCellPhone fix it with a header `Sample : public LayoutByNW4R` behind a `*_SAMPLE_CLASS` macro, and `__vt__Q39textinput12candidatebox6Sample` exists in the DOL. A Sample with only `virtual ~Sample() {}` does not move the thunks. It needs the inline constructor, so the Base/EventHandler/LayoutByNW4R constructor guards also accept `TI_CANDIDATEBOX_SAMPLE_CLASS`, as tiPredictLang.h does. After that, all 112 common functions are in target order. Proof it is required: removing it leaves the wrong thunk order and DOL `5507fb9e...`.
|
||||
2. Weak vtable hole. The target has 0x40 zero bytes between `__vt__...AnmObserver` (0xd48) and `__vt__Q39textinput4util12AnimObserver` (0xd94). Ours left only the deduplicated gui::EventHandler copy (0x18), so everything after shifted by -0x20/-0x24. util::Animation methods were inline in the original: they sit as scattered weak functions in tiInputForm's .text, and MyTiManager.cpp already defines them `inline`. UITextArea has a `util::Animation` member, so the original object also emitted a weak `__vt__Q39textinput4util9Animation` (0x24, kept from tiInputForm). EventHandler 0x18 at 0xd58 + Animation 0x24 at 0xd70 ends at 0xd94. I added the same inline definitions as MyTiManager.cpp at the end of tiCandidateBox.cpp, with startAnm in this TU's declared parameter order. Only virtual calls exist, so no code changes. .data is now 0xda0, the target size.
|
||||
|
||||
Flip with both: full build OK, `build/43U/main.dol` SHA1 `26116613f624061ba99c8d1a299aaa6efa85670d`.
|
||||
|
||||
Trial snapshots: `/tmp/opus-candbox/trials/`. Captures: `/tmp/opus-candbox-cap-predictlang`, `/tmp/opus-candbox-cap-f01`.
|
||||
|
||||
## Gate
|
||||
|
||||
```text
|
||||
full build: ok
|
||||
main.dol sha1: 26116613f624061ba99c8d1a299aaa6efa85670d
|
||||
[src/keyboard/tiCandidateBox] pool: IDENTICAL
|
||||
[src/keyboard/tiCandidateBox] objdiff: code 24000/24000 data 4652/4652 functions 112/112 fuzzy 100.0000 linked code 24000
|
||||
[src/keyboard/tiCandidateBox] instruction-exact functions: 112/112
|
||||
regressions vs baseline: 0
|
||||
global matched_code_percent: 98.14728 -> 98.17613
|
||||
global complete_code_percent: 91.22256 -> 92.02384
|
||||
forbidden patterns added (net, per file): 0
|
||||
readability warnings (net, per file; must be 0 in the final result): 0
|
||||
GATE PASS
|
||||
```
|
||||
|
||||
origin/main moved to `82783c6e` during the run (BS2Update lines in configure.py/symbols.txt only, no overlap). Not rebased.
|
||||
47
tools/decomp-assist/opus-chansvm.attempts.md
Normal file
47
tools/decomp-assist/opus-chansvm.attempts.md
Normal file
@@ -0,0 +1,47 @@
|
||||
# opus-chansvm: CHANSVm round (ConvertToFloatFromStr, WinEmuWrite, DateDtor, BlobGetHexString, BlobPackCommon, Step)
|
||||
|
||||
Worktree data-d2, branch agent/w1009/o-chansvm, base 72e9c8d6. Start: 227/233 exact.
|
||||
Scratch harness: /tmp/opus-chansvm (score.py compiles the unit with the Ninja flags and diffs every function).
|
||||
|
||||
## combosweep (single + pairwise pragmas, whole unit)
|
||||
|
||||
No setting improves any of the six functions (Float 2, Win 5, Date 7, Hex 14, Pack 47, Step 262).
|
||||
|
||||
## CHANSVmConvertToFloatFromStr: 2 -> 0 (exact)
|
||||
|
||||
Diff: target `lbz type; li 0; stw endPtr; cmplwi`, ours `... cmplwi; stw`.
|
||||
|
||||
Scheduler RE (mwcceppc 0x599ac0 builds the block graph bottom-up; 0x5a0150/0x5a0170 is Alias.c may_alias):
|
||||
a load gets an edge to every later store it may alias, with the load latency as delay. The `obj->type`
|
||||
load had the worst_case alias set, which contains the escaped local endPtr, so LBZ -> STW had delay 2
|
||||
and the compare won the cycle-2 tie. A load whose base register comes from a pointer-to-const (or
|
||||
restrict) variable gets a private pseudo-object alias instead (see zcanann/FFCC-Decomp
|
||||
tools/patch_compiler_rw.py notes), so the edge disappears and the store issues at cycle 1.
|
||||
|
||||
The inlined parser's `const` parameter is copy-propagated into the caller's `object`, so the const has
|
||||
to be on the caller's parameter. Small-harness check: const/restrict on the inline parameter alone keeps
|
||||
the old order; on the caller parameter it gives the target order.
|
||||
|
||||
| attempt | Float | others |
|
||||
|---|---|---|
|
||||
| `const CHANSVmObjHdr* object` on ConvertToFloatFromStr, `(VmConvertFunc)` cast at its table slot | 0 | no change |
|
||||
| VmConvertFunc typedef and all 11 converters take const, cast in StrFromArray | 0 | no change |
|
||||
| `#pragma opt_pointer_analysis on` (diagnostic) | compiler segfaults | - |
|
||||
|
||||
Kept the first (minimal) form. Same lever as CHANSVmParseInt (`const CHANSVmObjHdr* obj`).
|
||||
|
||||
## VmDateDtor: 7 -> 0 (exact)
|
||||
|
||||
Diff: target loads `MonthTbl[mon]` before the outgoing `year` stack-argument store; ours after it.
|
||||
Same mechanism: the stack-argument stores carry the worst_case alias, and global tables are members of
|
||||
it, so every store -> table-load edge had delay 2. The target object has no symbols for the two tables
|
||||
(0xb34, 0xb50 are unnamed local data), so they were never globals.
|
||||
|
||||
| attempt | Date | others |
|
||||
|---|---|---|
|
||||
| file-scope `static` on both tables | 7 | no change |
|
||||
| file-scope `static` on one table (each) | 7 | no change |
|
||||
| both tables as function-scope `static` inside VmDateDtor | 0 | no change, .data bytes identical |
|
||||
| plus direct `date.x` access instead of `datePtr` | 84 | - |
|
||||
|
||||
Kept function-scope statics with the datePtr form.
|
||||
68
tools/decomp-assist/opus-odh.attempts.md
Normal file
68
tools/decomp-assist/opus-odh.attempts.md
Normal file
@@ -0,0 +1,68 @@
|
||||
# opus-odh attempts (src/system/odh)
|
||||
|
||||
Worktree data-d6, branch agent/w1009/o-odh from origin/main 72e9c8d6. Read opus-common.md, sol-r4 and
|
||||
sol-m2 logs, effort-policy entries, levers.md, the mwdbg README and the allocator reference.
|
||||
|
||||
Baseline: LineConv11 12/146, huffmanDecoder 171/306, unit 26/28 exact, pool identical.
|
||||
|
||||
## combosweep (run first)
|
||||
|
||||
- main source: LineConv11 12 -> 12, huffmanDecoder 171 -> 166 (opt_propagation off). No exact.
|
||||
- sol-m2 seed: LineConv11 6 -> 6, huffmanDecoder 114 -> 114. No exact.
|
||||
|
||||
## LineConv11: EXACT
|
||||
|
||||
mwdbg capture of the seed: inside the loop r8 is the only free volatile GPR, so every other temp takes a
|
||||
saved register and the lowest claimed one wins. The packed RGB565 word (v68) was colored before the
|
||||
high byte (v66) and took r8. The target needs the high byte on r8, the pointer on r29, and the packed word
|
||||
colored after cbValue claims r25. So the packed word has to be a named local numbered below cbValue.
|
||||
|
||||
Petari's matching SMG source (SMGCommunity/Petari src/Game/Screen/odh.cpp, read-only) does exactly that:
|
||||
cbValue/crValue are declared with red/green/blue before the format chain, and `pixel` is built high byte
|
||||
first (`pixel = src[o]; pixel <<= 8; pixel |= src[o + 1];`) inside the RGB565 block. Ported as-is with
|
||||
this file's names: LineConv11 0/146, ctxdiff diffs 0, pool identical, no other function changes.
|
||||
|
||||
Lever isolation (each from the exact version):
|
||||
- cbValue/crValue declared at their assignment instead: 5 diffs.
|
||||
- pixel low byte first (`pixel = src[o + 1]; pixel |= src[o] << 8`): 6 diffs.
|
||||
- pixel as one expression `(src[o] << 8) | src[o + 1]`: 6 diffs.
|
||||
- planeSize indexing instead of cbSource/crSource pointers: 0 (either form works).
|
||||
|
||||
## huffmanDecoder: EXACT
|
||||
|
||||
Started from a fresh natural rewrite (early returns, `length`/`tableIndex`/`category` names, Petari-style
|
||||
tree walks) instead of the Ghidra-shaped seed: 170 diffs, same 306 instructions. Structural fixes first:
|
||||
- `coefficient = 1` before the first refill loop (the target sets it in the DC block): 163.
|
||||
- DC leaf through a named `leafIndex` (target keeps `(idx + off + 1) * 2` + lhzx only in the DC walk).
|
||||
- `length = 1;` before `tableIndex = 0;` in every walk (li order): 139, 0 structural left.
|
||||
|
||||
Then allocator work with mwdbg + a per-vreg want list built by aligning backend-04 PCode with the target
|
||||
object (/tmp/opus-odh-want.py), and an annealer over the numbering (/tmp/opus-odh-anneal.py):
|
||||
- A full renumbering (temps included) reached 1 miss and showed both maxLength values must be colored
|
||||
after their walk temps, i.e. behave as codegen temps. `maxLength = component == 0 ? 9 : 11;` gets
|
||||
copy-propagated into the ternary temp: 139 -> 80.
|
||||
- `dc` must be colored before the predictor-index temp, so no named `dc`:
|
||||
`coefficientOutput[0] = value + *pred; *pred = coefficientOutput[0];` (store forwarded, no reload): 68.
|
||||
- AC tail: target creates the store address before `length + category`:
|
||||
`coefficientOutput[coefficient++] = value; bitOffset += length + category;`: 66.
|
||||
- Remaining misses were named-local order only. Simulator: declare sourceCursor, bitOffset, coefficient,
|
||||
category before bytesConsumed (sourceCursor colors first and takes r12, bitOffset claims r31, then
|
||||
coefficient r30, category r29, bytesConsumed r28). C89 declarations at the top of the function: 9.
|
||||
- Last 9: the run walk needs `branch` numbered above `node` (declared first). Per-walk C89 blocks
|
||||
`u32 branch; u16 node;` then assignments: 0. Only the run walk needs it; using it in all three walks
|
||||
is also exact, so the final source is uniform.
|
||||
|
||||
Checked and rejected along the way: function-scope shared node/branch (always 9, any position);
|
||||
`value += *pred` (80); chained assignment for the predictor works (68) but the two-statement form reads
|
||||
better. maxLength/value/mask/leafIndex/run/i can sit anywhere in the top declaration list.
|
||||
|
||||
Final: huffmanDecoder 0/306, ctxdiff diffs 0, pool identical, unit 28/28, code 14684/14684, data 6360/6360.
|
||||
|
||||
## Link
|
||||
|
||||
Flipped system/odh.cpp to Matching. ODHEncodeRGBA8/ODHEncodeY8U8V8/ODHDecodeY8U8V8 are in the source but
|
||||
not in the split target (unreferenced, dead-stripped); the link output is unchanged.
|
||||
Full build: main.dol SHA1 26116613f624061ba99c8d1a299aaa6efa85670d, "system/odh.cpp: linked True".
|
||||
|
||||
Gate (`gate.py src/system/odh --quick`): GATE PASS, 28/28 instruction-exact, linked code 14684,
|
||||
0 regressions, 0 forbidden patterns, 0 readability warnings. Global matched code 98.14728 -> 98.20765.
|
||||
53
tools/decomp-assist/opus-sdmem.attempts.md
Normal file
53
tools/decomp-assist/opus-sdmem.attempts.md
Normal file
@@ -0,0 +1,53 @@
|
||||
# opus-sdmem attempts: SDMemory::drawTransferTitles
|
||||
|
||||
Unit `src/scene/sdChannelMemory/iplSDMemory`, branch `agent/w1009/o-sdmem` from `72e9c8d6`.
|
||||
Start: 363/451 differing, 447/451 instructions, 97.4102%. combosweep: no setting beats 363.
|
||||
|
||||
## Header loops: MSL's C++ `wcsstr` overload
|
||||
|
||||
The target's two guarded loops (`cmpwi; beq` / `addic.; ble`, then a preheader with
|
||||
`li rX, "\n"@sda21`, then `b test`) come from MWCC's `IRO_PullOutInvariantAssignments`
|
||||
(string `IRO_CopyLoopTestToLoopPreheaderAndBranchToSuccNode` in mwcceppc.exe). The pass
|
||||
needs a loop-invariant *assignment* inside the loop. A plain `wcsstr(p, L"\n")` has none,
|
||||
so no loop form, pragma, IRO level or `-O4,p` reproduces it in isolated tests.
|
||||
|
||||
Real MSL (`MSL_C/wstring.h`, see RushRE/SonicRushAdventure-Decomp tools/cw/include) declares,
|
||||
for non-embedded C++, `const wchar_t* wcsstr(const wchar_t*, const wchar_t*)` plus
|
||||
`inline wchar_t* wcsstr(wchar_t* s1, const wchar_t* s2)` calling the const one. Calling it
|
||||
with a `wchar_t*` inlines the wrapper; its parameter assignment `s2 = L"\n"` is the
|
||||
invariant assignment the IRO pass pulls into a guarded preheader. Isolated test reproduces
|
||||
the target sequence instruction for instruction.
|
||||
|
||||
`message::Message::getMessage` already returns `wchar_t*`; the `Manager`/`System` wrappers
|
||||
now return `wchar_t*` too, so message pointers in this function are non-const and use the
|
||||
overload. The scoped `ppc_iro_level 1` is removed (it suppresses the pass) and the newline
|
||||
counter is a plain `while` loop.
|
||||
|
||||
Result: 88/451 differing, 451/451 instructions, 99.28603%.
|
||||
|
||||
Side effect: `LetterWriter::makeHeaderCaption` passed a call result straight to `wcsstr`;
|
||||
with the overload the literal is evaluated before the virtual call (100 -> 94%). A named
|
||||
`caption` local restores the target order (three spellings tested, all exact). Full report
|
||||
otherwise unchanged vs `72e9c8d6`, DOL SHA1 unchanged.
|
||||
|
||||
## Title colors: real NW4R `TextBox::SetTextColor(ut::Color top, ut::Color bottom)`
|
||||
|
||||
The two helpers after drawTransferTitles were invented names (`iplSDMemory_813EF6C4/6D8`
|
||||
before #254). Their bodies and placement fit weak header inlines that this large function
|
||||
did not inline: `nw4r::ut::Color::Color(int, int, int, int)` (four `stb`) and NW4R's
|
||||
`TextBox::SetTextColor(ut::Color top, ut::Color bottom)` (by-value colors, two calls to the
|
||||
weak `Color::operator=`; same inline in hotlandsoftware/wii-news-channel, declared in Petari).
|
||||
By-value arguments explain the retail stack: the named color sits with the other named
|
||||
locals, the two argument copies are temporaries in source order, the snapshot comes last.
|
||||
`textBox.h` now has that overload instead of the `IPL_SDMEMORY_SET_TEXT_COLORS` hack, the
|
||||
source is `nw4r::ut::Color color(...); titleText->SetTextColor(color, color);`, and
|
||||
symbols.txt names the two functions `__ct__Q34nw4r2ut5ColorFiiii` and
|
||||
`SetTextColor__Q34nw4r3lyt7TextBoxFQ34nw4r2ut5ColorQ34nw4r2ut5Color` (both 100%).
|
||||
|
||||
The N_Body alpha loop is written in place like the header/footer loops: through the
|
||||
`setChildrenAlpha` inline its iterator temporaries were allocated after the footer's
|
||||
(inline expansion runs after parsing), retail has them in source order.
|
||||
`titleOffset -= visibleRows * rowHeight` fixes the `fmuls` operand order.
|
||||
|
||||
Result: 50/451 differing, register-blind identical apart from the renamed call targets,
|
||||
99.39024%. Pool and .data/.sdata/.sdata2 identical; full report unchanged otherwise; DOL OK.
|
||||
267
tools/decomp-assist/settingstruct.attempts.md
Normal file
267
tools/decomp-assist/settingstruct.attempts.md
Normal file
@@ -0,0 +1,267 @@
|
||||
# settingstruct leaf — attempt log
|
||||
|
||||
Scope: src/scene/setting/AOSS.c, src/scene/setting/AOSSLink.c, src/scene/address/iplAddressEdit.cpp
|
||||
Base: origin/main@9321a926. Lane-clear vs open PRs (only #1156 touches ATERM.c — dropped per orchestrator).
|
||||
Tools: ~/tools/fndiff.py (capstone normalized diff, register-renaming by first-appearance order; `--raw` = literal).
|
||||
|
||||
## Baseline
|
||||
- iplAddressEdit 99.55 — create 97.56 (3280B), get_friendinfo 88.04, update_friendinfo 99.42
|
||||
- AOSSLink 99.01 — AOSSi_WLANGetBSSList 98.48 (908B), AOSSi_WLANConnect 98.71 (620B)
|
||||
- AOSS 98.42 — AOSS_Init_old 96.19 (6336B), AOSSApplyAuthOptions 98.77 (456B), AOSSXorBufferWithKey 98.61
|
||||
- iplAOSSThread 100, AOSSData 100
|
||||
|
||||
## get_friendinfo (88.04, 584B) — text-ptr early-pin wall
|
||||
Orig materializes `addi r29,r28,0x2b4` (mName) and later `addi r29,r28,0x2cc` (mDisplayText)
|
||||
EARLY — inside the FindPaneByName marshal window of each `set_textbox` call — pinning the
|
||||
text-ptr web in callee reg r29 across `bctrl`. Mine remats `addi r5` at the marshal point.
|
||||
Same pattern appears in `create` (r25 pin before `stw` field store + FindPaneByName chain).
|
||||
|
||||
FAILED variants (5+, all documented): `const wchar_t* name` local (MWCC forwards
|
||||
single-use locals to marshal), `pane`+`name` locals, pane-only local, reused `text` local
|
||||
with statement-level assignment, text decl before setName. MWCC remats cheap `this+const`
|
||||
expressions regardless of def site; orig's early materialization requires the web's DAG
|
||||
birth to precede the pane-chain eval — no source lever found.
|
||||
|
||||
## update_friendinfo (99.42) — 2-insn marshal-order swap
|
||||
38=38 insns; only diff: orig marshals `addi r4,r30,0x2b4` (src) before `addi r3,r31,8`
|
||||
(dst) in the wcsncpy marshal; mine dst then src. Named-local and early-birth variants
|
||||
failed — MWCC emits marshal webs in its own ready order.
|
||||
|
||||
## create (97.56, 3280B) — 2 missing insns + pin/rotation
|
||||
808 vs 810 insns. Marshal shape identical L-to-R (`mr r3; addi r4; addi r5; li r6; li r7; bl`).
|
||||
Residual: same text-ptr pin (addi r25,r29,0x2b4 before `stw r0,0x14(r27)` and inside
|
||||
marshal windows) + wholesale callee-window rotation (r30↔r31 const-table vs boardFile
|
||||
pin, deep r25-r31 webs).
|
||||
|
||||
## AOSSi_WLANGetBSSList (98.48, 908B) — sth placement + IV rotation
|
||||
227=227 insns. Two-loop IV web-home rotation (r26/r20 swap) + one `sth r5,0x40(r1)`
|
||||
placement bound to the `lhz` operand web home. Retry webs all init'd (no uninit signature).
|
||||
|
||||
## AOSSi_WLANConnect (98.71, 620B) — single li-placement
|
||||
155=155 insns. Only diff: `li r5,0x7c4` hoisted one slot before `mr r3,r27` in the memset
|
||||
marshal (const-li vs move emission order). `u32 ifConfigSize` named local REGRESSED (4 diffs);
|
||||
reverted. r28/r31 webs verified init'd — no uninit-read signature.
|
||||
|
||||
## AOSSApplyAuthOptions (98.77, 456B) — arg-save order + rotation
|
||||
Two arg-web home swaps (r5-arg→r24 vs orig arg1→r27 first — emission order of `mr` saves
|
||||
at fn entry) + cursor/literal-base swap (r29↔r31). Also `s_responseTypeByState` symbol
|
||||
shows as orig `lbl_81697210` — naming artifact, reloc target identical.
|
||||
|
||||
## AOSSXorBufferWithKey (98.61) — XOR-loop pointer web swap
|
||||
147=147 insns. Loop webs swapped: mine `add r4,r28,r3`/`add r5,r26,r3` vs orig r26/r28;
|
||||
`xor r6` vs `xor r0` result reg. Decl-order swap of `temporaryHalf`/`packetHalf`
|
||||
REGRESSED (moved temp-pointer web homes); reverted.
|
||||
|
||||
## AOSS_Init_old (96.19, 6336B) — deep wall
|
||||
1581 vs 1584 insns (~3 short), 1213 normalized diffs — mass web rotation across the whole
|
||||
fn (different callee layout → different numbering). Per-site: prologue `sth r4,0x28`/li
|
||||
placement, a free-check block ordering (`cmpwi;beq;bl Free;stw` on two globals), one
|
||||
`bne` vs `lwz+cmplwi+beq` shape. No source lever found; prior wave documented the same.
|
||||
|
||||
## uninit-read lever (PR #1270) — checked, N/A
|
||||
Verified orig stores every compared callee reg before use on all paths: WLANConnect
|
||||
`li r28,0`/`li r28,-1` stores before each `cmpwi r28,0`; GetBSSList retry webs init'd;
|
||||
create/AddressEdit inits all present. No fn emits an extra init orig lacks or reaches a
|
||||
compare with a path-unset reg.
|
||||
|
||||
## ppc_iro_level results (post-#1276 lever)
|
||||
- **get_friendinfo → 100%**: `#pragma push` + `ppc_iro_level 0` + named text locals
|
||||
(`const wchar_t* name = mString.mName;`, `text = mString.mDisplayText;`). The named
|
||||
local's def site births the text-ptr web early; IRO-0 blocks the remat that previously
|
||||
folded it to the marshal — orig's `addi r29,r28,0x2b4` early-pin reproduces
|
||||
(`_savegpr_28`/`_restgpr_28` match; residual = bare `bl` reloc offsets). Neither the
|
||||
local alone (forwarded) nor IRO-0 alone (still remat) sufficed — both needed.
|
||||
- **create 97.56 → 98.73** with `ppc_iro_level 1` (friendText locals already present).
|
||||
Levels 0 and 1 produce identical output here. Residual = callee-window rotation.
|
||||
- FAILED: AOSSi_WLANConnect (identical at 1/2, explodes to 219 at 0 — marshal swap
|
||||
unaffected), AOSSi_WLANGetBSSList (46 diffs at 0/1 = baseline), AOSSApplyAuthOptions
|
||||
(IRO-1 drops fuzzy 98.77→97.94 despite fewer normalized diffs — reverted),
|
||||
AOSSXorBufferWithKey (61→154 at IRO — reverted), AOSS_Init_old (1213 diffs at 0/1 =
|
||||
baseline — pragma no effect), update_friendinfo (IRO regresses 2→11 — reverted).
|
||||
|
||||
## Status
|
||||
**get_friendinfo is a NEW 100% fn** — owner PR bar (≥1 new 100% + zero regressions) met
|
||||
for a source-only PR. create improved to 98.73. Remaining fns stay at documented ties;
|
||||
units stay NonMatching.
|
||||
|
||||
## Post-#1277 rebase (origin/main@c723136f)
|
||||
Owner merged get_friendinfo+update_friendinfo via #1277 (IRO-1 + named locals — same
|
||||
decode). Branch now keeps only create's `ppc_iro_level 1` (98.73) + this log.
|
||||
|
||||
## libs/RevoEX/src/net/aes.c (added to leaf)
|
||||
- AESiEncryptBlock 65.81 (158=158 insns): whole-body table-load issue-order interleave.
|
||||
Orig hoists all 16 byte-extract rlwinm webs to the loop top then interleaves
|
||||
lwzx/rotlwi/xor; next-round key loads land mid-body. TRIED: IRO-0 (195 diffs, worse
|
||||
than 183 baseline), IRO-1 (same 195), `nextState[4]` array (183 = scalarized
|
||||
identical), `state[4]`+`nextState[4]` arrays (180), fused key-XOR into nextState
|
||||
assignments (192, savegpr_20). All reverted — issue-order wall, no lever.
|
||||
- AESiDecryptBlock 78.96 (246=246 insns): IRO-0/IRO-1 both drop fuzzy to ~70 (+7 insns,
|
||||
266 normalized diffs vs 290 baseline — normalized counts mislead again). Reverted.
|
||||
Allhands exhaustive-decl-order docs predate IRO but the pragma is verified harmful
|
||||
here — remaining residual is the same table-load scheduler family.
|
||||
|
||||
## MWCC scheduling-pragmas sweep (post-#1296 orchestrator hint)
|
||||
|
||||
Target: AESiEncryptBlock/DecryptBlock table-load interleave (orig hoists ~11 rlwinm
|
||||
extracts before first lwzx; ours issues loads after ~4).
|
||||
|
||||
Per-fn pragma results (normalized diffs -> objdiff fuzzy):
|
||||
- `#pragma scheduling off` EncryptBlock 183->178 norm, fuzzy 65.81->36.20 (revert)
|
||||
- `#pragma scheduling once` EncryptBlock 183->179 norm, fuzzy ->40.54 (revert)
|
||||
- `#pragma scheduling twice` EncryptBlock 183 (no change), DecryptBlock 290 (no change)
|
||||
- `#pragma scheduling 600` rejected by MWCC 3.0a5.2 (CPU names only)
|
||||
- `#pragma scheduling 750`/`gekko` 183 (=default), `603`/`generic` 237 (worse)
|
||||
- `#pragma schedule_twice on`/`scheduling on`/`twice` 183 (no-ops)
|
||||
- `-opt schedule_twice` cflag: not a valid -opt for 3.0a5.2 (opts: prop,strength,dead,peep,schedule,display|dump)
|
||||
- `-schedule twice|twice,750|=twice` cflag: all rejected by 3.0a5.2 arg parser
|
||||
- `-opt schedule` cflag: 183 (no change)
|
||||
|
||||
Source restructures (all reverted, fuzzy-measured):
|
||||
- 16 named table-value temps (t0..t15): 149 norm but fuzzy 65.81->58.99
|
||||
- named index vars i0..i15 + 16 loads: 149 norm (index vars forwarded/CSE'd), fuzzy also down
|
||||
- column-order extraction (all >>24, then >>16, >>8, &255): 228 norm (worse)
|
||||
|
||||
Cross-check on AOSS fns:
|
||||
- AOSSi_WLANConnect `scheduling twice`: norm 28->2 (li r5,0x7c4/mr r3,r27 pair only)
|
||||
BUT fuzzy unchanged 98.71 - remaining residual is the same marshal-order operand tie.
|
||||
- AOSSi_WLANGetBSSList `once` 46->43 norm, fuzzy 98.48->93.53 (harmful); `twice` no-op; `off` 69
|
||||
- AOSSXorBufferWithKey `twice` 61 (no-op); `off` 142 (worse)
|
||||
- AOSS_Init_old `twice` 1263 (no-op)
|
||||
|
||||
Conclusion: the AES interleave is NOT a scheduling-pragma wall - MWCC's default
|
||||
gekko scheduler already matches orig's pass config; the residual is allocator
|
||||
web-lifetime/ready-set structure with no known source lever. `scheduling twice`
|
||||
is a real lever ONLY for instruction-issue-order residuals (marshal pairs), and
|
||||
even there fixes ordering without moving objdiff fuzzy.
|
||||
|
||||
## Round 2: structural decode attempts on AESiEncryptBlock (orchestrator hint)
|
||||
|
||||
Baseline macro form remains best (183 norm, fuzzy 65.81). All reverted:
|
||||
- key as `const u32 (*key)[4]` pointer-to-row (+key++): identical 183
|
||||
- state[4]/nextState[4] with strided (i+k)&3 indices + for-loops: 230
|
||||
- fused `nextStateN = ENCRYPT(...) ^ key[N]` (states assigned at end): 231
|
||||
- state copied to t0..t3 temps at loop top: 183 (CSE folds)
|
||||
- two-phase combines (all rotated-halves then all tail-halves): 231
|
||||
- xor tree rebalance `(A^B)^(C^D)` and raw-term-first reorder: 175 norm, fuzzy 60.0/60.3
|
||||
- TU cflags -O4,s: 263 norm (worse); -O3: 177 norm, fuzzy 60.3/70.2 (worse)
|
||||
- prologue emits `srwi` extract before the input xors complete in BOTH objects;
|
||||
158=158 insns, all residuals are regname + issue-order inside an identical op set
|
||||
- AOSSi_WLANConnect residual is 2 diffs (mr r3,r27 / li r5,0x7c4 marshal order);
|
||||
pointer-local decl moved adjacent to memset: no change (baseline was already 2);
|
||||
direct-global &AOSSi_NcdIfConfig form: 163 (the local web is required)
|
||||
|
||||
Conclusion: the AES loop-body interleave is an allocator ready-set artifact;
|
||||
the register-lifetime shape that produces orig's ordering is not expressible
|
||||
through these source levers. No scheduling/-O lever improves fuzzy.
|
||||
|
||||
## Round 3: fn-local static lever (swarm #1299 hint) + pragma combos
|
||||
|
||||
Refuted for this leaf:
|
||||
- Op-multiset check: EncryptBlock and DecryptBlock emit IDENTICAL opcode
|
||||
histograms vs orig (158=158, same op counts) — residual is pure
|
||||
issue-order + regname. Any memory-backed intermediate (static buffer)
|
||||
ADDS lwz/stw ops orig provably lacks.
|
||||
- No SDA/r13/r2-relative accesses in orig AESi*Block, WLANConnect,
|
||||
WLANGetBSSList, AOSS_Init_old — globals go through lis+addi.
|
||||
- `static u32 sbuf[4]/nbuf[4]` state buffers: 305 norm diffs (lwz/stw
|
||||
traffic), reverted.
|
||||
- Pragma combos: iro1+sched-twice 195, iro0+sched-twice 195, iro2+sched-twice
|
||||
177 (all worse than 183 baseline or no better), iro1 alone 195.
|
||||
- mw_version lever reported dead by orchestrator (swept, identical/worse).
|
||||
|
||||
Standing wall: AESiEncryptBlock/DecryptBlock = allocator ready-set ordering
|
||||
inside an identical instruction multiset. No scheduling/IRO/O-level/cflag/
|
||||
static/source-structure lever changes it in the right direction.
|
||||
AOSSi_WLANConnect: 2-insn marshal-order pair (mr r3,r27 vs li r5,0x7c4);
|
||||
all decl/static/source forms tried.
|
||||
|
||||
## Round 4: const-source + scoped-table hint (#1304) + Init_old op-diff decode
|
||||
|
||||
Post-#1296 rebase state: AOSSXorBufferWithKey landed by swarm (100). Remaining
|
||||
in leaf: AOSS_Init_old 96.62, AOSSi_WLANGetBSSList 98.48,
|
||||
AOSSi_WLANConnect 98.71, AESi*Block (stays as-is per orchestrator).
|
||||
|
||||
AOSS_Init_old op-histogram diffs (M=mine vs orig): add +1, b -1, bgt +1,
|
||||
ble -1, bne -3, cmplw +2, cmplwi -2, li -1, mr +1 — real structural gap:
|
||||
- Mine emits `cmplw r3,r27` at the two AOSSi_Alloc NULL checks (0xc94/0x154c)
|
||||
where orig emits `cmpwi r3,0` — the classic pinned-zero wall: MWCC shared
|
||||
one zero web in r27 across the fn's many li 0/cmpwi sites; orig
|
||||
rematerializes. All 4 pragma variants (iro 0/1/2, iro1+sched-twice) no-op.
|
||||
- Orig keeps 3 more `bne` and 2 more `cmplwi r0,1` (0xd60/0x1620 = likely
|
||||
AOSSi_cancel_flag==1 sites where mine fused differently).
|
||||
|
||||
Scoped-retry-counter attempt (move unlockRetries/cleanupRetries/scanRetries
|
||||
to uninit decls + assign before each loop — births webs later per the scoped-
|
||||
locals hint): GetBSSList 46->167 diffs, reverted.
|
||||
|
||||
WLANConnect memset(&AOSSi_NcdIfConfig) direct-global + memsetTarget alias
|
||||
forms: both still forward to the r27 web, 2 diffs unchanged.
|
||||
|
||||
const-table analysis: ipAddress/etc are non-const .data (written by
|
||||
AOSS_SetStaticIpConfig) — can't be const; supportedRates is .data non-const
|
||||
matching orig's sections (no .rodata in orig .o) — const would break data.
|
||||
|
||||
## Round 5: Init_old u32-deref decode (orchestrator's missing-checks lead)
|
||||
|
||||
Orchestrator hypothesized missing cancel_flag reads — refuted: 14 lwz
|
||||
AOSSi_cancel_flag sites in BOTH objects. Orig's extra cmplwi r0,1 at
|
||||
0xd60/0x1620 are `*s_accessPointConfig == 1` compares: MWCC emits cmplwi
|
||||
(unsigned) vs my cmpwi (signed) keyed off the COMPARE OPERAND's type —
|
||||
s_accessPointConfig stays `int*` (file is full of (int*)0x0 literal casts)
|
||||
but the deref needs an unsigned compare: `(u32)*s_accessPointConfig == 1u`
|
||||
at the two wait-loop break sites (lines 881/1233) matching line 675's
|
||||
existing pattern. All 3 sites now cmplwi r0,1; cmplwi count 17=17.
|
||||
Init_old 96.62 -> 96.69; fn now 1581 vs orig 1584 insns.
|
||||
|
||||
Remaining real gaps: pinned-zero cmplw r3,r27 at both AOSSi_Alloc NULL
|
||||
checks vs orig cmpwi r3,0 (all pragma forms no-op); bgt-vs-ble+b layout at
|
||||
the manufacturerLength<=0xd memcpy guard (goto form folds back to bgt —
|
||||
orig's 2-branch layout implies a merge/region structure source can't
|
||||
reproduce); net -3 insns somewhere in mass-rotation noise.
|
||||
|
||||
## Round 6: #1311 levers (declsearch, inline-helper, marshal forms) post-#1314
|
||||
|
||||
Post-rebase scope: GetBSSList matched by swarm #1314; aes Matching #1311
|
||||
(object rebuilds identical). Remaining: AOSS_Init_old 96.70,
|
||||
AOSSi_WLANConnect 98.71.
|
||||
|
||||
WLANConnect 2-insn marshal swap (li r5,0x7c4 vs mr r3,r27 order) refuted
|
||||
with ALL new levers: (void*)ipConfig, sizeof(AOSSi_NcdIpConfig), folded
|
||||
`memset(ipConfig = &...,...)` assignment form, and static-inline
|
||||
pointer-param helper AOSSi_ClearIpConfig — every form keeps the r27 web and
|
||||
MWCC emits mr-first. Pure marshal-order tie; declsearch found only the 2
|
||||
leading decls (no improvement).
|
||||
|
||||
Init_old: declsearch.py --lines 391 435 (45-decl block, 100 evals) found a
|
||||
marginally better order (waitAttempt front, initialWait later): kept,
|
||||
96.69 -> 96.70. Pinned-zero root located: `li r27,0`@0xb34 — ONE shared
|
||||
zero web pinned fn-wide (stw/sth stores + addc/adde + 2 cmplw) where orig
|
||||
pins `input` in r27 (addi r27,r4,0) and remats zero per-site. Orig's
|
||||
pinned-input vs pinned-zero callee choice is an allocator web-priority
|
||||
decision; source can't declare which constant webs win a callee reg.
|
||||
|
||||
## Round 7: cross-block-use copies (o2-aoss doc), Init_old pinned-zero crack
|
||||
|
||||
o2-aoss.attempts.md methodology applied. WLANConnect second-memset marshal:
|
||||
cross-block-use copy is refuted structurally — the ONLY post-copy use of an
|
||||
ipConfig alias is NCDSetIpConfig, which sits in the SAME block as the copy
|
||||
birth (the if-test IS the block terminator) — block-local copy forwarding
|
||||
(0x596850) kills it. Verified: configMem-as-takeover (all later uses),
|
||||
configMem-as-parallel-web (NCDSetIpConfig only), configMem = &AOSSi_NcdIpConfig
|
||||
(second materialization — CSE'd into r27 web), (u8*) typed view, void* view —
|
||||
all 2 diffs. No other-block use exists in the fn (field writes + call all in
|
||||
the memset block). Doc's alternatives already covered: struct-wrap gives
|
||||
right order +1 insn (addi r27,r3,0x160).
|
||||
|
||||
Init_old pinned-zero pair cracked for ONE site: `(int)s_accessPointConfig == 0`
|
||||
at line ~1203 gives orig's `cmpwi r3,0` at 0x154c (the pinned r27-zero web is
|
||||
not live there). Same cast at line 627 site (0xc94) stays `cmplw r3,r27` —
|
||||
the r27 web (born 0xb34) is live at that point so MWCC prefers reg-compare;
|
||||
named `allocCheck` local folds via VN canonicalization. 0xc18 `cmplw r3,r4`
|
||||
vs `r3,r0` is the u64 bound-check idiom, pure operand-name drift.
|
||||
|
||||
Allocator analysis: orig splits input's web (r15 early -> addi r27,r4,0 re-home
|
||||
at 0xb1c for the 0x14/0x10/0x18 field reads) and remats `li r0,0` at ~25 sites.
|
||||
Mine keeps input in r15 fn-wide and fuses all zeroes into the r27 web.
|
||||
The re-home is a backend web-split, not a source copy (copies die in COpt
|
||||
pre-phase). Remaining levers exhausted: declsearch r2 pending.
|
||||
144
tools/decomp-assist/sol-m12.attempts.md
Normal file
144
tools/decomp-assist/sol-m12.attempts.md
Normal file
@@ -0,0 +1,144 @@
|
||||
# sol-m12 CHANSVm big functions, MAX
|
||||
|
||||
Worktree data-d2, branch agent/w1009/chansvm-big, initial HEAD bbd98e1e. Requested full Ninja build passed before edits, required DOL SHA1 verified by the build. Source initially clean. Read sol-common, brief-v2, all levers, AGENTS.md, unslop, writing-for-agents, graphify query instructions, 11b01025:sol-m8, 50eb9be2:sol-c1, ef500621:sol-y4, archived and repository histories, and every CHANSVm effort-policy entry. History inventory and prior trial labels are /tmp/sol-m12-history.json and /tmp/sol-m12-prior-rows.json. Graph query resolved its ambiguous name to src/channelScript/CHANSVm.c::VmBlobPackCommon.
|
||||
|
||||
## Excluded repetitions
|
||||
|
||||
- No unchanged-graph declaration permutations. Prior 218-node Pack models prove the array/counter swap needs a changed interference graph.
|
||||
- No whole Pack measure/write wrappers, complete packing helper, element-size/format-specific writers, typed argument-selection wrappers, named remaining-count/format-length/blob-length getters, sequential generic argument reuse, or shared pass counters/format positions already tried.
|
||||
- No Step scratch carrier, out-parameters hoisting locals, dead locals, duplicated control flags, redundant conditions, raw offset casts, table-identity getters, previously tested late-table getters, readonly-view cleanup helpers, named immediate getters, instruction-union variants, or countdown normalization variants.
|
||||
- No compiler-version/unit-flag sweep or standalone scoped-setting repeat. No small-function work outside Pack and Step.
|
||||
|
||||
## Acceptance and method
|
||||
|
||||
Replay the saved Pack-only best, remove any unused local, and check equivalent behavior and all existing exact functions before retaining it. The task explicitly authorizes committing clean improvements below exactness; record them as partial results. Align opcode plus resolved-relocation streams with difflib, locate count differences first, then scheduling and allocation. For Step, map the switch table and inspect the least-different cases first. Preserve the pool, all data sections and existing exact functions. Run the requested final quick gate once. Keep all source experiments in this worktree and temporary files under /tmp/sol-m12-. No push, PR, merge, rebase, subagent or Matching flip without a fully exact unit.
|
||||
|
||||
## Measurements
|
||||
- {"label": "pack-clean-replay", "counts": {"VmBlobPackCommon": {"diff": 151, "insns": [666, 668]}, "CHANSVmStep": {"diff": 262, "insns": [1253, 1253]}}, "drops": [], "others": [], "data_changes": [], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "c18451afb381"} Removed unused hexadecimal length local and pure getter from historical best. All separated locals carry genuine pass-specific values.
|
||||
- {"label": "pack-clean-unused-result-call", "counts": {"VmBlobPackCommon": {"diff": 47, "insns": [668, 668]}, "CHANSVmStep": {"diff": 262, "insns": [1253, 1253]}}, "drops": [], "others": [], "data_changes": [], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "705ffdaec24d"} Target instruction 604 prepares writeHexStrObj and 605 calls VmGetIntFromObjHdr. Return is unused in the remaining hex block. Preserve that original call without a dead local.
|
||||
|
||||
Pack clean replay is 47/668 versus 230/668 at HEAD. All 47 aligned differences are the r18/r23 array-counter exchange. Target hex block explicitly calls VmGetIntFromObjHdr and discards its result, so the required source call is retained without declaring a dead local. The rest of the function keeps identical call order, branches, instruction count, all allocated data, and every other function. Unit report after replay: {"fuzzy_match_percent": 99.66164, "total_code": "53564", "matched_code": "44588", "matched_code_percent": 83.24248, "total_data": "6904", "matched_data": "6904", "matched_data_percent": 100.0, "total_functions": 233, "matched_functions": 227, "matched_functions_percent": 97.4249, "total_units": 1}. Task authorizes this partial checkpoint. No exact match claimed.
|
||||
- {"label": "pack-integer-store-words", "counts": {"VmBlobPackCommon": {"diff": 325, "insns": [677, 668]}, "CHANSVmStep": {"diff": 262, "insns": [1253, 1253]}}, "drops": [], "others": [], "data_changes": [], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "34b5f067b570"} Actual integer serialization or byte-swap helper writes the real packing buffer; no scratch carrier or hoisted local out-parameter.
|
||||
- {"label": "pack-integer-store-integer", "counts": {"VmBlobPackCommon": {"diff": 325, "insns": [677, 668]}, "CHANSVmStep": {"diff": 262, "insns": [1253, 1253]}}, "drops": [], "others": [], "data_changes": [], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "c75536b1e87b"} Actual integer serialization or byte-swap helper writes the real packing buffer; no scratch carrier or hoisted local out-parameter.
|
||||
- {"label": "pack-integer-store-integer-case-scope", "build": "FAIL"} Same new serialization boundary, with integer-loop values declared in their owning case.
|
||||
- {"label": "pack-integer-store-object", "counts": {"VmBlobPackCommon": {"diff": 321, "insns": [677, 668]}, "CHANSVmStep": {"diff": 262, "insns": [1253, 1253]}}, "drops": [], "others": [], "data_changes": [], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "b0afd352444d"} Actual integer serialization or byte-swap helper writes the real packing buffer; no scratch carrier or hoisted local out-parameter.
|
||||
- {"label": "pack-integer-store-object-case-scope", "build": "FAIL"} Same new serialization boundary, with integer-loop values declared in their owning case.
|
||||
- {"label": "pack-integer-swap-words", "counts": {"VmBlobPackCommon": {"diff": 56, "insns": [668, 668]}, "CHANSVmStep": {"diff": 262, "insns": [1253, 1253]}}, "drops": [], "others": [], "data_changes": [], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "434ff2985dbf"} Actual integer serialization or byte-swap helper writes the real packing buffer; no scratch carrier or hoisted local out-parameter.
|
||||
- {"label": "pack-integer-encode-words", "counts": {"VmBlobPackCommon": {"diff": 333, "insns": [675, 668]}, "CHANSVmStep": {"diff": 262, "insns": [1253, 1253]}}, "drops": [], "others": [], "data_changes": [], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "46cb1062b4df"} Actual integer serialization or byte-swap helper writes the real packing buffer; no scratch carrier or hoisted local out-parameter.
|
||||
- {"label": "pack-integer-encode-integer", "counts": {"VmBlobPackCommon": {"diff": 333, "insns": [675, 668]}, "CHANSVmStep": {"diff": 262, "insns": [1253, 1253]}}, "drops": [], "others": [], "data_changes": [], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "37020ec61736"} Actual integer serialization or byte-swap helper writes the real packing buffer; no scratch carrier or hoisted local out-parameter.
|
||||
- {"label": "pack-integer-encode-integer-case-scope", "counts": {"VmBlobPackCommon": {"diff": 334, "insns": [675, 668]}, "CHANSVmStep": {"diff": 262, "insns": [1253, 1253]}}, "drops": [], "others": [], "data_changes": [], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "1e8a9605e258"} Same new serialization boundary, with integer-loop values declared in their owning case.
|
||||
- {"label": "pack-integer-encode-object", "counts": {"VmBlobPackCommon": {"diff": 329, "insns": [675, 668]}, "CHANSVmStep": {"diff": 262, "insns": [1253, 1253]}}, "drops": [], "others": [], "data_changes": [], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "389b97208b09"} Actual integer serialization or byte-swap helper writes the real packing buffer; no scratch carrier or hoisted local out-parameter.
|
||||
- {"label": "pack-integer-encode-object-case-scope", "counts": {"VmBlobPackCommon": {"diff": 330, "insns": [675, 668]}, "CHANSVmStep": {"diff": 262, "insns": [1253, 1253]}}, "drops": [], "others": [], "data_changes": [], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "73d7c8ffa5e6"} Same new serialization boundary, with integer-loop values declared in their owning case.
|
||||
- {"label": "pack-restore-after-integer-helpers", "counts": {"VmBlobPackCommon": {"diff": 47, "insns": [668, 668]}, "CHANSVmStep": {"diff": 262, "insns": [1253, 1253]}}, "drops": [], "others": [], "data_changes": [], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "705ffdaec24d"} Restore the best reviewed packing shape after serialized helper trials.
|
||||
- {"label": "step-case-float-local", "counts": {"VmBlobPackCommon": {"diff": 47, "insns": [668, 668]}, "CHANSVmStep": {"diff": 266, "insns": [1253, 1253]}}, "drops": [], "others": [], "data_changes": [], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "5a5c1246d7a2"} Move only this case actual operand/index/literal into its owning scope, following the least-different case ordering. Independent objects, unchanged calls and operand sizes.
|
||||
- {"label": "step-case-string-index-local", "counts": {"VmBlobPackCommon": {"diff": 47, "insns": [668, 668]}, "CHANSVmStep": {"diff": 262, "insns": [1253, 1253]}}, "drops": [], "others": [], "data_changes": [], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "19ecec628150"} Move only this case actual operand/index/literal into its owning scope, following the least-different case ordering. Independent objects, unchanged calls and operand sizes.
|
||||
- {"label": "step-case-new-array-index-local", "counts": {"VmBlobPackCommon": {"diff": 47, "insns": [668, 668]}, "CHANSVmStep": {"diff": 262, "insns": [1253, 1253]}}, "drops": [], "others": [], "data_changes": [], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "c16b93768a1c"} Move only this case actual operand/index/literal into its owning scope, following the least-different case ordering. Independent objects, unchanged calls and operand sizes.
|
||||
- {"label": "step-case-call-operand-local", "counts": {"VmBlobPackCommon": {"diff": 47, "insns": [668, 668]}, "CHANSVmStep": {"diff": 262, "insns": [1253, 1253]}}, "drops": [], "others": [], "data_changes": [], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "52188babcf52"} Move only this case actual operand/index/literal into its owning scope, following the least-different case ordering. Independent objects, unchanged calls and operand sizes.
|
||||
- {"label": "step-single-function-scope-opSize", "counts": {"VmBlobPackCommon": {"diff": 47, "insns": [668, 668]}, "CHANSVmStep": {"diff": 262, "insns": [1253, 1253]}}, "drops": [], "others": [], "data_changes": [], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "0bcda653f75c"} One real cross-case interpreter local lives at function scope. Carrier-free baseline; this is not a declaration permutation of the previous carrier graph.
|
||||
- {"label": "step-single-function-scope-operandBuf", "counts": {"VmBlobPackCommon": {"diff": 47, "insns": [668, 668]}, "CHANSVmStep": {"diff": 262, "insns": [1253, 1253]}}, "drops": [], "others": [], "data_changes": [], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "70349864ce40"} One real cross-case interpreter local lives at function scope. Carrier-free baseline; this is not a declaration permutation of the previous carrier graph.
|
||||
- {"label": "step-single-function-scope-copyResult", "counts": {"VmBlobPackCommon": {"diff": 47, "insns": [668, 668]}, "CHANSVmStep": {"diff": 262, "insns": [1253, 1253]}}, "drops": [], "others": [], "data_changes": [], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "e302683194b4"} One real cross-case interpreter local lives at function scope. Carrier-free baseline; this is not a declaration permutation of the previous carrier graph.
|
||||
- {"label": "step-single-function-scope-foundObj", "counts": {"VmBlobPackCommon": {"diff": 47, "insns": [668, 668]}, "CHANSVmStep": {"diff": 262, "insns": [1253, 1253]}}, "drops": [], "others": [], "data_changes": [], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "c0c7872f13d2"} One real cross-case interpreter local lives at function scope. Carrier-free baseline; this is not a declaration permutation of the previous carrier graph.
|
||||
- {"label": "step-single-function-scope-result", "counts": {"VmBlobPackCommon": {"diff": 47, "insns": [668, 668]}, "CHANSVmStep": {"diff": 262, "insns": [1253, 1253]}}, "drops": [], "others": [], "data_changes": [], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "621e11cb0158"} One real cross-case interpreter local lives at function scope. Carrier-free baseline; this is not a declaration permutation of the previous carrier graph.
|
||||
- {"label": "step-single-function-scope-newPos", "counts": {"VmBlobPackCommon": {"diff": 47, "insns": [668, 668]}, "CHANSVmStep": {"diff": 262, "insns": [1253, 1253]}}, "drops": [], "others": [], "data_changes": [], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "72977265684a"} One real cross-case interpreter local lives at function scope. Carrier-free baseline; this is not a declaration permutation of the previous carrier graph.
|
||||
- {"label": "step-case-helper-VmLoadIndirect", "build": "FAIL"} Real opcode operation helper preserves its complete copy/delete/store or boolean operation and error propagation. Buffer parameter is the actual operation storage, not an allocator carrier.
|
||||
- {"label": "step-case-helper-VmDeleteIndirect", "counts": {"VmBlobPackCommon": {"diff": 47, "insns": [668, 668]}, "CHANSVmStep": {"diff": 262, "insns": [1253, 1253]}}, "drops": [], "others": [], "data_changes": [], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "a78209fb7d99"} Real opcode operation helper preserves its complete copy/delete/store or boolean operation and error propagation. Buffer parameter is the actual operation storage, not an allocator carrier.
|
||||
- {"label": "step-case-helper-VmLogicalNot", "counts": {"VmBlobPackCommon": {"diff": 47, "insns": [668, 668]}, "CHANSVmStep": {"diff": 262, "insns": [1253, 1253]}}, "drops": [], "others": [], "data_changes": [], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "78a1e07de24a"} Real opcode operation helper preserves its complete copy/delete/store or boolean operation and error propagation. Buffer parameter is the actual operation storage, not an allocator carrier.
|
||||
- {"label": "step-internal-readonly-VmResultTypeTbl", "counts": {"VmBlobPackCommon": {"diff": 47, "insns": [668, 668]}, "CHANSVmStep": {"diff": 262, "insns": [1253, 1253]}}, "drops": [], "others": [], "data_changes": [], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "d7acb65b18d2"} Diagnostic internal linkage on real TU-private readonly globals. Target shares the rodata base; retain only if every symbol user and relocation remain valid.
|
||||
- {"label": "step-internal-readonly-CHANSVmConstStringObjectUndefined_", "counts": {"VmBlobPackCommon": {"diff": 47, "insns": [668, 668]}, "CHANSVmStep": {"diff": 262, "insns": [1253, 1253]}}, "drops": [], "others": [], "data_changes": [], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "29f94ee37b0f"} Diagnostic internal linkage on real TU-private readonly globals. Target shares the rodata base; retain only if every symbol user and relocation remain valid.
|
||||
- {"label": "step-internal-readonly-both", "counts": {"VmBlobPackCommon": {"diff": 47, "insns": [668, 668]}, "CHANSVmStep": {"diff": 262, "insns": [1253, 1253]}}, "drops": [], "others": [], "data_changes": [], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "9ffa6e38abd1"} Diagnostic internal linkage on real TU-private readonly globals. Target shares the rodata base; retain only if every symbol user and relocation remain valid.
|
||||
- {"label": "step-restore-after-case-trials", "counts": {"VmBlobPackCommon": {"diff": 47, "insns": [668, 668]}, "CHANSVmStep": {"diff": 262, "insns": [1253, 1253]}}, "drops": [], "others": [], "data_changes": [], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "705ffdaec24d"} Restore best reviewed source after opcode and scope trials.
|
||||
- {"label": "pack-real-serialization-buffer-signed-words", "counts": {"VmBlobPackCommon": {"diff": 47, "insns": [668, 668]}, "CHANSVmStep": {"diff": 262, "insns": [1253, 1253]}}, "drops": [], "others": [], "data_changes": [], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "953ba41006c9"} Actual eight-byte serialization buffer has its natural byte, signed-word or integer representation; typed accesses preserve exactly the stored byte ranges and order.
|
||||
- {"label": "pack-real-serialization-buffer-bytes", "counts": {"VmBlobPackCommon": {"diff": 47, "insns": [668, 668]}, "CHANSVmStep": {"diff": 262, "insns": [1253, 1253]}}, "drops": [], "others": [], "data_changes": [], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "68bdeb48da60"} Actual eight-byte serialization buffer has its natural byte, signed-word or integer representation; typed accesses preserve exactly the stored byte ranges and order.
|
||||
- {"label": "pack-real-serialization-buffer-integer", "counts": {"VmBlobPackCommon": {"diff": 47, "insns": [668, 668]}, "CHANSVmStep": {"diff": 262, "insns": [1253, 1253]}}, "drops": [], "others": [], "data_changes": [], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "c817b37a562e"} Actual eight-byte serialization buffer has its natural byte, signed-word or integer representation; typed accesses preserve exactly the stored byte ranges and order.
|
||||
- {"label": "pack-hex-real-phase-indexed-vmBoolInt", "counts": {"VmBlobPackCommon": {"diff": 125, "insns": [669, 668]}, "CHANSVmStep": {"diff": 262, "insns": [1253, 1253]}}, "drops": [], "others": [], "data_changes": [], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "8037667d9caf"} Named consumed high/low nibble phase and a real index, remaining-count or input cursor. Ghidra shows alternating phase and two-byte source traversal; no artificial lifetime or extra VM call.
|
||||
- {"label": "pack-hex-real-phase-indexed-vmBool", "counts": {"VmBlobPackCommon": {"diff": 125, "insns": [669, 668]}, "CHANSVmStep": {"diff": 262, "insns": [1253, 1253]}}, "drops": [], "others": [], "data_changes": [], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "d10098e4f2c2"} Named consumed high/low nibble phase and a real index, remaining-count or input cursor. Ghidra shows alternating phase and two-byte source traversal; no artificial lifetime or extra VM call.
|
||||
- {"label": "pack-hex-real-phase-remaining-vmBoolInt", "counts": {"VmBlobPackCommon": {"diff": 235, "insns": [669, 668]}, "CHANSVmStep": {"diff": 262, "insns": [1253, 1253]}}, "drops": [], "others": [], "data_changes": [], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "51a8b18b0da5"} Named consumed high/low nibble phase and a real index, remaining-count or input cursor. Ghidra shows alternating phase and two-byte source traversal; no artificial lifetime or extra VM call.
|
||||
- {"label": "pack-hex-real-phase-remaining-vmBool", "counts": {"VmBlobPackCommon": {"diff": 235, "insns": [669, 668]}, "CHANSVmStep": {"diff": 262, "insns": [1253, 1253]}}, "drops": [], "others": [], "data_changes": [], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "25983a62b93c"} Named consumed high/low nibble phase and a real index, remaining-count or input cursor. Ghidra shows alternating phase and two-byte source traversal; no artificial lifetime or extra VM call.
|
||||
- {"label": "pack-hex-real-phase-pointer-end-vmBoolInt", "counts": {"VmBlobPackCommon": {"diff": 255, "insns": [673, 668]}, "CHANSVmStep": {"diff": 262, "insns": [1253, 1253]}}, "drops": [], "others": [], "data_changes": [], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "73d1cf266113"} Named consumed high/low nibble phase and a real index, remaining-count or input cursor. Ghidra shows alternating phase and two-byte source traversal; no artificial lifetime or extra VM call.
|
||||
- {"label": "pack-hex-real-phase-pointer-end-vmBool", "counts": {"VmBlobPackCommon": {"diff": 255, "insns": [673, 668]}, "CHANSVmStep": {"diff": 262, "insns": [1253, 1253]}}, "drops": [], "others": [], "data_changes": [], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "d1915f38ce30"} Named consumed high/low nibble phase and a real index, remaining-count or input cursor. Ghidra shows alternating phase and two-byte source traversal; no artificial lifetime or extra VM call.
|
||||
- {"label": "pack-restore-after-buffer-and-phase", "counts": {"VmBlobPackCommon": {"diff": 47, "insns": [668, 668]}, "CHANSVmStep": {"diff": 262, "insns": [1253, 1253]}}, "drops": [], "others": [], "data_changes": [], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "705ffdaec24d"} Restore best reviewed source after actual buffer and nibble traversal shapes.
|
||||
- {"label": "step-property-found-init-before-lookup", "counts": {"VmBlobPackCommon": {"diff": 47, "insns": [668, 668]}, "CHANSVmStep": {"diff": 1105, "insns": [1249, 1253]}}, "drops": [], "others": [], "data_changes": [".rela.data"], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "554f8359dc13"} Initialize the real found flag on entry and remove unused arrayIdx assignments and the redundant non-array flag store. Same success, failure and branch conditions.
|
||||
- {"label": "step-property-found-init-after-lookup", "counts": {"VmBlobPackCommon": {"diff": 47, "insns": [668, 668]}, "CHANSVmStep": {"diff": 1105, "insns": [1249, 1253]}}, "drops": [], "others": [], "data_changes": [".rela.data"], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "1f0ce1b9b7c3"} Initialize the real found flag on entry and remove unused arrayIdx assignments and the redundant non-array flag store. Same success, failure and branch conditions.
|
||||
- {"label": "step-property-found-init-guard", "counts": {"VmBlobPackCommon": {"diff": 47, "insns": [668, 668]}, "CHANSVmStep": {"diff": 649, "insns": [1250, 1253]}}, "drops": [], "others": [], "data_changes": [".rela.data"], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "48ba164a012a"} Initialize the real found flag on entry and remove unused arrayIdx assignments and the redundant non-array flag store. Same success, failure and branch conditions.
|
||||
- {"label": "step-property-operation-output-last", "counts": {"VmBlobPackCommon": {"diff": 47, "insns": [668, 668]}, "CHANSVmStep": {"diff": 640, "insns": [1249, 1253]}}, "drops": [], "others": [], "data_changes": [".rela.data"], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "49695948b8e6"} Real property lookup operation returns CHANSVmErr and an actual found result, like CHANSVmGetBoolean. The output controls the bytecode branch and does not hoist helper temporaries.
|
||||
- {"label": "step-property-operation-output-last-format-scope", "counts": {"VmBlobPackCommon": {"diff": 47, "insns": [668, 668]}, "CHANSVmStep": {"diff": 640, "insns": [1249, 1253]}}, "drops": [], "others": [], "data_changes": [".rela.data"], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "b23ec141e9bc"} Same property operation, with formatting temporaries in their actual owning scope. Original 64-bit snprintf argument is preserved.
|
||||
- {"label": "step-property-operation-output-first", "counts": {"VmBlobPackCommon": {"diff": 47, "insns": [668, 668]}, "CHANSVmStep": {"diff": 640, "insns": [1249, 1253]}}, "drops": [], "others": [], "data_changes": [".rela.data"], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "0d4424248f8e"} Real property lookup operation returns CHANSVmErr and an actual found result, like CHANSVmGetBoolean. The output controls the bytecode branch and does not hoist helper temporaries.
|
||||
- {"label": "step-property-operation-output-first-format-scope", "counts": {"VmBlobPackCommon": {"diff": 47, "insns": [668, 668]}, "CHANSVmStep": {"diff": 640, "insns": [1249, 1253]}}, "drops": [], "others": [], "data_changes": [".rela.data"], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "b94e4670e35e"} Same property operation, with formatting temporaries in their actual owning scope. Original 64-bit snprintf argument is preserved.
|
||||
- {"label": "step-operation-helper-VmLoadStringConstant", "build": "FAIL"} Complete actual opcode operation behind a normal helper. Operand buffers are genuine input and storage used for VM object operations; no scratch carrier or artificial dependency.
|
||||
- {"label": "step-operation-helper-VmCreateArrayOpcode", "build": "FAIL"} Complete actual opcode operation behind a normal helper. Operand buffers are genuine input and storage used for VM object operations; no scratch carrier or artificial dependency.
|
||||
- {"label": "step-operation-helper-VmStoreIndirect", "counts": {"VmBlobPackCommon": {"diff": 47, "insns": [668, 668]}, "CHANSVmStep": {"diff": 262, "insns": [1253, 1253]}}, "drops": [], "others": [], "data_changes": [], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "1eb11d802892"} Complete actual opcode operation behind a normal helper. Operand buffers are genuine input and storage used for VM object operations; no scratch carrier or artificial dependency.
|
||||
- {"label": "step-operation-helper-VmLoadIndirect", "counts": {"VmBlobPackCommon": {"diff": 47, "insns": [668, 668]}, "CHANSVmStep": {"diff": 262, "insns": [1253, 1253]}}, "drops": [], "others": [], "data_changes": [], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "bd99a82f2c25"} Complete actual opcode operation behind a normal helper. Operand buffers are genuine input and storage used for VM object operations; no scratch carrier or artificial dependency.
|
||||
- {"label": "step-restore-after-property-operation", "counts": {"VmBlobPackCommon": {"diff": 47, "insns": [668, 668]}, "CHANSVmStep": {"diff": 262, "insns": [1253, 1253]}}, "drops": [], "others": [], "data_changes": [], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "705ffdaec24d"} Restore best source after new property and object-operation boundaries.
|
||||
- {"label": "pack-consume-argument-advance-call-Blob", "counts": {"VmBlobPackCommon": {"diff": 450, "insns": [670, 668]}, "CHANSVmStep": {"diff": 262, "insns": [1253, 1253]}}, "drops": [], "others": [], "data_changes": [], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "b559537f4f93"} A real next-argument expression advances the cursor at its lookup. Argument indexes and call order stay unchanged, and no counter address escapes. Nested conversion keeps the same two calls.
|
||||
- {"label": "pack-consume-argument-advance-call-Integer", "counts": {"VmBlobPackCommon": {"diff": 354, "insns": [670, 668]}, "CHANSVmStep": {"diff": 262, "insns": [1253, 1253]}}, "drops": [], "others": [], "data_changes": [], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "f660f73ecb6a"} A real next-argument expression advances the cursor at its lookup. Argument indexes and call order stay unchanged, and no counter address escapes. Nested conversion keeps the same two calls.
|
||||
- {"label": "pack-consume-argument-advance-call-String", "counts": {"VmBlobPackCommon": {"diff": 253, "insns": [670, 668]}, "CHANSVmStep": {"diff": 262, "insns": [1253, 1253]}}, "drops": [], "others": [], "data_changes": [], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "08ba492b44e7"} A real next-argument expression advances the cursor at its lookup. Argument indexes and call order stay unchanged, and no counter address escapes. Nested conversion keeps the same two calls.
|
||||
- {"label": "pack-consume-argument-advance-call-Hex", "counts": {"VmBlobPackCommon": {"diff": 187, "insns": [670, 668]}, "CHANSVmStep": {"diff": 262, "insns": [1253, 1253]}}, "drops": [], "others": [], "data_changes": [], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "390460abe825"} A real next-argument expression advances the cursor at its lookup. Argument indexes and call order stay unchanged, and no counter address escapes. Nested conversion keeps the same two calls.
|
||||
- {"label": "pack-consume-argument-advance-call-Integer-String", "counts": {"VmBlobPackCommon": {"diff": 350, "insns": [672, 668]}, "CHANSVmStep": {"diff": 262, "insns": [1253, 1253]}}, "drops": [], "others": [], "data_changes": [], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "ca6636c2679e"} A real next-argument expression advances the cursor at its lookup. Argument indexes and call order stay unchanged, and no counter address escapes. Nested conversion keeps the same two calls.
|
||||
- {"label": "pack-consume-argument-advance-call-String-Hex", "counts": {"VmBlobPackCommon": {"diff": 253, "insns": [672, 668]}, "CHANSVmStep": {"diff": 262, "insns": [1253, 1253]}}, "drops": [], "others": [], "data_changes": [], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "83e444dc541f"} A real next-argument expression advances the cursor at its lookup. Argument indexes and call order stay unchanged, and no counter address escapes. Nested conversion keeps the same two calls.
|
||||
- {"label": "pack-consume-argument-advance-call-Blob-Integer-String-Hex", "counts": {"VmBlobPackCommon": {"diff": 450, "insns": [676, 668]}, "CHANSVmStep": {"diff": 262, "insns": [1253, 1253]}}, "drops": [], "others": [], "data_changes": [], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "365e81430a1d"} A real next-argument expression advances the cursor at its lookup. Argument indexes and call order stay unchanged, and no counter address escapes. Nested conversion keeps the same two calls.
|
||||
- {"label": "pack-consume-argument-nested-conversion-Blob", "counts": {"VmBlobPackCommon": {"diff": 450, "insns": [670, 668]}, "CHANSVmStep": {"diff": 262, "insns": [1253, 1253]}}, "drops": [], "others": [], "data_changes": [], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "b559537f4f93"} A real next-argument expression advances the cursor at its lookup. Argument indexes and call order stay unchanged, and no counter address escapes. Nested conversion keeps the same two calls.
|
||||
- {"label": "pack-consume-argument-nested-conversion-Integer", "counts": {"VmBlobPackCommon": {"diff": 354, "insns": [670, 668]}, "CHANSVmStep": {"diff": 262, "insns": [1253, 1253]}}, "drops": [], "others": [], "data_changes": [], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "75618b2bc41c"} A real next-argument expression advances the cursor at its lookup. Argument indexes and call order stay unchanged, and no counter address escapes. Nested conversion keeps the same two calls.
|
||||
- {"label": "pack-consume-argument-nested-conversion-String", "counts": {"VmBlobPackCommon": {"diff": 251, "insns": [669, 668]}, "CHANSVmStep": {"diff": 262, "insns": [1253, 1253]}}, "drops": [], "others": [], "data_changes": [], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "49deaae31879"} A real next-argument expression advances the cursor at its lookup. Argument indexes and call order stay unchanged, and no counter address escapes. Nested conversion keeps the same two calls.
|
||||
- {"label": "pack-consume-argument-nested-conversion-Hex", "counts": {"VmBlobPackCommon": {"diff": 250, "insns": [669, 668]}, "CHANSVmStep": {"diff": 262, "insns": [1253, 1253]}}, "drops": [], "others": [], "data_changes": [], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "04cbe5619579"} A real next-argument expression advances the cursor at its lookup. Argument indexes and call order stay unchanged, and no counter address escapes. Nested conversion keeps the same two calls.
|
||||
- {"label": "pack-consume-argument-nested-conversion-Integer-String", "counts": {"VmBlobPackCommon": {"diff": 350, "insns": [671, 668]}, "CHANSVmStep": {"diff": 262, "insns": [1253, 1253]}}, "drops": [], "others": [], "data_changes": [], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "67e5b3e35451"} A real next-argument expression advances the cursor at its lookup. Argument indexes and call order stay unchanged, and no counter address escapes. Nested conversion keeps the same two calls.
|
||||
- {"label": "pack-consume-argument-nested-conversion-String-Hex", "counts": {"VmBlobPackCommon": {"diff": 303, "insns": [670, 668]}, "CHANSVmStep": {"diff": 262, "insns": [1253, 1253]}}, "drops": [], "others": [], "data_changes": [], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "f4f5cef096fa"} A real next-argument expression advances the cursor at its lookup. Argument indexes and call order stay unchanged, and no counter address escapes. Nested conversion keeps the same two calls.
|
||||
- {"label": "pack-consume-argument-nested-conversion-Blob-Integer-String-Hex", "counts": {"VmBlobPackCommon": {"diff": 463, "insns": [674, 668]}, "CHANSVmStep": {"diff": 262, "insns": [1253, 1253]}}, "drops": [], "others": [], "data_changes": [], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "3cce13c8aeff"} A real next-argument expression advances the cursor at its lookup. Argument indexes and call order stay unchanged, and no counter address escapes. Nested conversion keeps the same two calls.
|
||||
- {"label": "pack-measure-count-after-size-Integer", "counts": {"VmBlobPackCommon": {"diff": 47, "insns": [668, 668]}, "CHANSVmStep": {"diff": 262, "insns": [1253, 1253]}}, "drops": [], "others": [], "data_changes": [], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "c92bdc893fbe"} Accumulate the format element byte size before advancing its argument cursor. These local updates commute and retain all overflow/conversion rules.
|
||||
- {"label": "pack-measure-count-after-size-String", "counts": {"VmBlobPackCommon": {"diff": 47, "insns": [668, 668]}, "CHANSVmStep": {"diff": 262, "insns": [1253, 1253]}}, "drops": [], "others": [], "data_changes": [], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "0055b2fe1791"} Accumulate the format element byte size before advancing its argument cursor. These local updates commute and retain all overflow/conversion rules.
|
||||
- {"label": "pack-measure-count-after-size-Hex", "counts": {"VmBlobPackCommon": {"diff": 47, "insns": [668, 668]}, "CHANSVmStep": {"diff": 262, "insns": [1253, 1253]}}, "drops": [], "others": [], "data_changes": [], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "a7e4638108c1"} Accumulate the format element byte size before advancing its argument cursor. These local updates commute and retain all overflow/conversion rules.
|
||||
- {"label": "pack-measure-count-after-size-all", "counts": {"VmBlobPackCommon": {"diff": 47, "insns": [668, 668]}, "CHANSVmStep": {"diff": 262, "insns": [1253, 1253]}}, "drops": [], "others": [], "data_changes": [], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "30d118739d6f"} Accumulate the format element byte size before advancing its argument cursor. These local updates commute and retain all overflow/conversion rules.
|
||||
- {"label": "pack-restore-after-argument-shapes", "counts": {"VmBlobPackCommon": {"diff": 47, "insns": [668, 668]}, "CHANSVmStep": {"diff": 262, "insns": [1253, 1253]}}, "drops": [], "others": [], "data_changes": [], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "705ffdaec24d"} Restore best source after actual cursor lifetime changes.
|
||||
|
||||
## Fresh backend evidence
|
||||
|
||||
Pack capture /tmp/sol-m12-pack-capture has executable bytes, resolved text relocations and every allocated data section identical to the ordinary Ninja object. Simulator reproduces 218/218, and the manually checked array/counter want-list reaches only 2/3. All 47 baseline differences are the r18/r23 exchange. Step capture /tmp/sol-m12-step-capture likewise equals normal compilation in all allocated sections and resolved relocations and reproduces 491/491. The 10-name diagnostic reaches 8/10, but the stock search can reorder compiler @ aliases and parameters, so it is not a writable source order and no proposed ordering is applied. Maps are /tmp/sol-m12-pack-vmap.txt and /tmp/sol-m12-step-vmap.txt.
|
||||
|
||||
Opcode/relocation alignment includes HA/LO relocations stored at instruction offset +2. It identifies Step target shared rodata base 0, source separate bases 352 and 96; early count normalization and pretest branch; stack object locations; enum indexing; property flag/output stack stores; and later branch cleanup. The source jump tables currently match all 121 relocation destinations. Case priority is /tmp/sol-m12-step-case-priority.json. POP, IS_CLASS, DELETE_INDIRECT, LOG_NOT and BIT_NOT bodies already match; the first positive-difference cases differ by the shared instruction-size register. Property lookup has 92 differing positions in its 134-instruction block. Internal linkage on the real readonly globals changes no instructions. No fake common-base aggregate or cross-object pointer arithmetic is introduced.
|
||||
- {"label": "step-operation-helper-VmLoadStringConstant-fixed", "counts": {"VmBlobPackCommon": {"diff": 47, "insns": [668, 668]}, "CHANSVmStep": {"diff": 262, "insns": [1253, 1253]}}, "drops": [], "others": [], "data_changes": [], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "6282fff9aa19"} Corrected helper generator retains original case declarations. Same opcode operation boundary and original call order, without hoisted local outputs.
|
||||
- {"label": "step-operation-helper-VmLoadStringConstant-decoded-input", "counts": {"VmBlobPackCommon": {"diff": 47, "insns": [668, 668]}, "CHANSVmStep": {"diff": 695, "insns": [1252, 1253]}}, "drops": [], "others": [], "data_changes": [".rela.data"], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "550e55657ba8"} Actual decoded string index or array extent is the operation input; keep decoding at the caller and object creation inside the helper.
|
||||
- {"label": "step-operation-helper-VmCreateArrayOpcode-fixed", "counts": {"VmBlobPackCommon": {"diff": 47, "insns": [668, 668]}, "CHANSVmStep": {"diff": 262, "insns": [1253, 1253]}}, "drops": [], "others": [], "data_changes": [], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "f3e3f9a42c40"} Corrected helper generator retains original case declarations. Same opcode operation boundary and original call order, without hoisted local outputs.
|
||||
- {"label": "step-operation-helper-VmCreateArrayOpcode-decoded-input", "counts": {"VmBlobPackCommon": {"diff": 47, "insns": [668, 668]}, "CHANSVmStep": {"diff": 262, "insns": [1253, 1253]}}, "drops": [], "others": [], "data_changes": [], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "6b1fff6c9d84"} Actual decoded string index or array extent is the operation input; keep decoding at the caller and object creation inside the helper.
|
||||
- {"label": "step-property-output-last-pretest", "counts": {"VmBlobPackCommon": {"diff": 47, "insns": [668, 668]}, "CHANSVmStep": {"diff": 1227, "insns": [1251, 1253]}}, "drops": [], "others": [], "data_changes": [".rela.data"], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "7d34bf2d9d62"} Combine new real property operation with assembly-proven pretest countdown or indexed operand-type output. Old standalone controls are not counted as new ideas.
|
||||
- {"label": "step-property-output-last-indexed-types", "counts": {"VmBlobPackCommon": {"diff": 47, "insns": [668, 668]}, "CHANSVmStep": {"diff": 1099, "insns": [1250, 1253]}}, "drops": [], "others": [], "data_changes": [".rela.data"], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "2cb470409b7e"} Combine new real property operation with assembly-proven pretest countdown or indexed operand-type output. Old standalone controls are not counted as new ideas.
|
||||
- {"label": "step-property-output-last-pretest-indexed-types", "counts": {"VmBlobPackCommon": {"diff": 47, "insns": [668, 668]}, "CHANSVmStep": {"diff": 1222, "insns": [1252, 1253]}}, "drops": [], "others": [], "data_changes": [".rela.data"], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "59a1cb761b4e"} Combine new real property operation with assembly-proven pretest countdown or indexed operand-type output. Old standalone controls are not counted as new ideas.
|
||||
- {"label": "step-property-output-first-pretest", "counts": {"VmBlobPackCommon": {"diff": 47, "insns": [668, 668]}, "CHANSVmStep": {"diff": 1227, "insns": [1251, 1253]}}, "drops": [], "others": [], "data_changes": [".rela.data"], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "23cf3deee40e"} Combine new real property operation with assembly-proven pretest countdown or indexed operand-type output. Old standalone controls are not counted as new ideas.
|
||||
- {"label": "step-property-output-first-indexed-types", "counts": {"VmBlobPackCommon": {"diff": 47, "insns": [668, 668]}, "CHANSVmStep": {"diff": 1099, "insns": [1250, 1253]}}, "drops": [], "others": [], "data_changes": [".rela.data"], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "bff9685e9c39"} Combine new real property operation with assembly-proven pretest countdown or indexed operand-type output. Old standalone controls are not counted as new ideas.
|
||||
- {"label": "step-property-output-first-pretest-indexed-types", "counts": {"VmBlobPackCommon": {"diff": 47, "insns": [668, 668]}, "CHANSVmStep": {"diff": 1222, "insns": [1252, 1253]}}, "drops": [], "others": [], "data_changes": [".rela.data"], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "11b5acc54f47"} Combine new real property operation with assembly-proven pretest countdown or indexed operand-type output. Old standalone controls are not counted as new ideas.
|
||||
- {"label": "step-case-property-object-values", "counts": {"VmBlobPackCommon": {"diff": 47, "insns": [668, 668]}, "CHANSVmStep": {"diff": 262, "insns": [1253, 1253]}}, "drops": [], "others": [], "data_changes": [], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "06ad45705671"} The large opcode case owns its actual object handles or decoded operands. Separate per-case values remove cross-case source reuse without a carrier or any added operation.
|
||||
- {"label": "step-case-property-operand-values", "counts": {"VmBlobPackCommon": {"diff": 47, "insns": [668, 668]}, "CHANSVmStep": {"diff": 614, "insns": [1251, 1253]}}, "drops": [], "others": [], "data_changes": [".rela.data"], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "17f609f5347f"} The large opcode case owns its actual object handles or decoded operands. Separate per-case values remove cross-case source reuse without a carrier or any added operation.
|
||||
- {"label": "step-case-index-object-values", "counts": {"VmBlobPackCommon": {"diff": 47, "insns": [668, 668]}, "CHANSVmStep": {"diff": 262, "insns": [1253, 1253]}}, "drops": [], "others": [], "data_changes": [], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "d5a261278a30"} The large opcode case owns its actual object handles or decoded operands. Separate per-case values remove cross-case source reuse without a carrier or any added operation.
|
||||
- {"label": "step-case-index-operand-values", "counts": {"VmBlobPackCommon": {"diff": 47, "insns": [668, 668]}, "CHANSVmStep": {"diff": 703, "insns": [1251, 1253]}}, "drops": [], "others": [], "data_changes": [".rela.data"], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "bdd38f3134bd"} The large opcode case owns its actual object handles or decoded operands. Separate per-case values remove cross-case source reuse without a carrier or any added operation.
|
||||
- {"label": "step-restore-final-best", "counts": {"VmBlobPackCommon": {"diff": 47, "insns": [668, 668]}, "CHANSVmStep": {"diff": 262, "insns": [1253, 1253]}}, "drops": [], "others": [], "data_changes": [], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "705ffdaec24d"} Restore best source after combined operation and indexed-operand shapes.
|
||||
- {"label": "pack-integer-store-integer-case-scope-fixed", "counts": {"VmBlobPackCommon": {"diff": 326, "insns": [677, 668]}, "CHANSVmStep": {"diff": 262, "insns": [1253, 1253]}}, "drops": [], "others": [], "data_changes": [], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "0b8f526b806a"} Corrected generator identifies the outer format case with an anchored pattern. Real loop index and converted argument are owned by that case.
|
||||
- {"label": "pack-integer-store-object-case-scope-fixed", "counts": {"VmBlobPackCommon": {"diff": 322, "insns": [677, 668]}, "CHANSVmStep": {"diff": 262, "insns": [1253, 1253]}}, "drops": [], "others": [], "data_changes": [], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "4278fbf87ee4"} Corrected generator identifies the outer format case with an anchored pattern. Real loop index and converted argument are owned by that case.
|
||||
- {"label": "step-case-property-real-operands", "counts": {"VmBlobPackCommon": {"diff": 47, "insns": [668, 668]}, "CHANSVmStep": {"diff": 614, "insns": [1251, 1253]}}, "drops": [], "others": [], "data_changes": [".rela.data"], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "9bdcba724a96"} Remove the generated unused per-case array-index local. Keep only real operand buffer and decoded index values; reject if target count or table offsets differ.
|
||||
- {"label": "final-retained-checkpoint", "counts": {"VmBlobPackCommon": {"diff": 47, "insns": [668, 668]}, "CHANSVmStep": {"diff": 262, "insns": [1253, 1253]}}, "drops": [], "others": [], "data_changes": [], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "705ffdaec24d"} Retain only the committed clean Pack replay; all new non-exact experiments are rejected.
|
||||
- {"label": "pack-typed-buffer-index", "counts": {"VmBlobPackCommon": {"diff": 47, "insns": [668, 668]}, "CHANSVmStep": {"diff": 262, "insns": [1253, 1253]}}, "drops": [], "others": [], "data_changes": [], "pool": "POOL IDENTICAL up to 125 (mine=125 base=125)", "sha": "a0f7d087c354"} The source scan flags cast-plus-offset spelling in the replay. Use actual typed array indexing for the known eight-byte serialization buffer; store width and order remain identical. The measurement completed successfully; an unquoted separator in its trailing shell note then attempted an unrelated command and returned 127. The later independent final checks below pass.
|
||||
|
||||
## Final result and handoff
|
||||
|
||||
The log contains 92 measurement rows: 87 successful compilations/checkpoints and five generator failures. After the cleaned replay, there are 38 compiled Pack variants (37 distinct source hashes) and 39 Step variants. These are measured variations, not 77 independent ideas: parameter orders, unchanged-code controls and the composed pretest/indexing controls are labeled above. The failed generators were corrected. The generated property-operand trial with an unused array-index local was rejected and corrected to use only real operands. Every follow-up source experiment was restored.
|
||||
|
||||
Retain the inherited Pack replay from sol-c1, with the unused hexadecimal length local removed and the signed word store written as typed array indexing. The target's explicit unused-result getter call remains. Pack improves from 230 to 47 differences, 668/668 instructions, fuzzy 98.0988 to 99.588326. There is no new exact function. The remaining 47 differences exchange the argument-array and argument-counter registers r18/r23; their opcode and resolved-relocation streams align without insertions or deletions. Fresh backend evidence reproduces the allocator, but does not supply an honest source change that fixes the exchange.
|
||||
|
||||
Step remains 262 differences, 1253/1253 instructions, fuzzy 97.23225. Its function text equals the initial bbd98e1e function exactly. The smallest differing opcode bodies mostly inherit the shared opSize register. Full property-operation boundaries, genuine case-owned inputs and object handles, readonly linkage, and operand-type/pretest compositions either preserve the original differences or change instruction counts and jump-table relocations. The target common readonly base, operand storage, property flag and loop control remain unresolved; none justifies a scratch carrier or fabricated object layout. All 121 data-table relocation destinations and every previously exact sibling are preserved in the retained object.
|
||||
|
||||
Final source SHA256: a0f7d087c354b113fcdbc456fa90f651a739af74353db4673aadac3cfc9f395c. Changed repository paths are src/channelScript/CHANSVm.c and this log. Source checkpoint ae3810af contains the clean replay; the final checkpoint also contains the typed-index spelling and this audit. The focused source diff is saved as /mnt/drive2/projects/wii-ipl-workers/_luna-runs/best/sol-m12.CHANSVm.diff.
|
||||
|
||||
Ran the requested final gate exactly once:
|
||||
|
||||
```
|
||||
python3 /mnt/drive2/projects/wii-ipl-workers/_restore0928-tools/gate.py src/channelScript/CHANSVm --quick
|
||||
full build: ok
|
||||
main.dol sha1: 26116613f624061ba99c8d1a299aaa6efa85670d
|
||||
pool: IDENTICAL
|
||||
objdiff: code 44588/53564 data 6904/6904 functions 227/233 fuzzy 99.66164 linked code 0
|
||||
instruction-exact functions: 227/233
|
||||
all five allocated data sections: 100.0
|
||||
regressions vs baseline: 0
|
||||
forbidden patterns added: 0
|
||||
readability warnings: 0
|
||||
GATE PASS
|
||||
```
|
||||
|
||||
The gate baseline is bbd98e1e, unit fuzzy 99.58733. Final live report was regenerated with Ninja progress and build/43U/report.json. Independent final ctxdiff reports Pack 47 and Step 262; pool_diff reports 125/125 identical; git diff --check passes. Direct executable-byte and resolved-relocation comparison against the initial object finds no changed sibling, exact-function drop or allocated-data change. Final evidence is /tmp/sol-m12-gate.txt, /tmp/sol-m12-final-VmBlobPackCommon.ctxdiff.txt, /tmp/sol-m12-final-CHANSVmStep.ctxdiff.txt and /tmp/sol-m12-final-pool.txt. This is a validated partial replay, with the unit still NonMatching and unlinked.
|
||||
Reference in New Issue
Block a user