Compare commits
87 Commits
agent/fix/
...
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 | ||
|
|
f67d537e0b | ||
|
|
2d169c59cf | ||
|
|
bbd98e1e4a | ||
|
|
838b6cb941 | ||
|
|
9936f0a9ed | ||
|
|
a0659667d9 | ||
|
|
e6837211c1 | ||
|
|
ebf00fbce2 | ||
|
|
a2bc1d564a | ||
|
|
da1c3b7ff8 | ||
|
|
710174c707 | ||
|
|
b66bd1ed67 | ||
|
|
ca6529e656 | ||
|
|
44dea2d510 | ||
|
|
f034087510 | ||
|
|
fa8632368e | ||
|
|
dc7725eb2d | ||
|
|
0b67e647ba | ||
|
|
b1e911808f | ||
|
|
c723136fb4 | ||
|
|
a65cd4cb73 | ||
|
|
2ca94fe4d3 | ||
|
|
d558bb14ca | ||
|
|
6604f7319c | ||
|
|
426c03386e | ||
|
|
7152b04d83 | ||
|
|
0155de3e71 | ||
|
|
9321a926cf | ||
|
|
22e6bbed24 | ||
|
|
f49f337c6b | ||
|
|
c3cad09b66 | ||
|
|
11dd7f505a | ||
|
|
52c9ea4b70 | ||
|
|
eef15925f4 | ||
|
|
46baf56e38 | ||
|
|
23b77a337c | ||
|
|
77cf359837 | ||
|
|
af7146a850 | ||
|
|
16023905ce | ||
|
|
f9ebd2f4cc | ||
|
|
ca98b14ad6 | ||
|
|
58a1da1cb3 | ||
|
|
8a0436a92f | ||
|
|
52f4e19325 | ||
|
|
77314b30e0 | ||
|
|
a3f8fc2779 | ||
|
|
2df2f8d6c7 | ||
|
|
6a82485817 | ||
|
|
6d67bbb6eb | ||
|
|
c3dbaf8c8e | ||
|
|
7c6393f96c | ||
|
|
1fd0970728 | ||
|
|
712bd2fc11 | ||
|
|
75c5997851 | ||
|
|
3b9b5e081c | ||
|
|
e75d7024ab | ||
|
|
7c064bc18b | ||
|
|
fe7381b4bc |
@@ -11,6 +11,9 @@ splits: 'config/43U/splits.txt'
|
||||
ldscript_template: 'config/ldscript_ipl2.lcf'
|
||||
|
||||
force_active:
|
||||
- SORead
|
||||
- SOFcntl
|
||||
- SOInetPtoN
|
||||
- SOGetSockOpt
|
||||
- SOSetInterfaceOpt
|
||||
- fprintf
|
||||
|
||||
@@ -897,13 +897,16 @@ src/scene/setting/iplRakuRakuThread.cpp:
|
||||
.sbss start:0x81698C60 end:0x81698C70
|
||||
|
||||
src/scene/setting/AOSS.c:
|
||||
.bss start:0x810BDEF8 end:0x810BECA0
|
||||
.bss start:0x810BDEF8 end:0x810BE838
|
||||
.text start:0x813FE27C end:0x814021BC
|
||||
.data start:0x81657C48 end:0x81657DB8
|
||||
.sdata2 start:0x81694C78 end:0x81694C80
|
||||
.sdata start:0x81697200 end:0x81697218
|
||||
.sbss start:0x81698C70 end:0x81698C90
|
||||
|
||||
src/scene/setting/AOSSData.c:
|
||||
.bss start:0x810BE838 end:0x810BECA0
|
||||
|
||||
src/scene/setting/ATERM.c:
|
||||
.bss start:0x810BECA0 end:0x810C0C80
|
||||
.text start:0x814021BC end:0x81406CC0
|
||||
|
||||
@@ -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
|
||||
@@ -93,8 +93,8 @@ sRakuMsgQueue = .bss:0x810BDED4; // type:object size:0x20
|
||||
AOSS_810BDEF8 = .bss:0x810BDEF8; // type:object size:0x20 data:4byte
|
||||
AOSS_810BDF18 = .bss:0x810BDF18; // type:object size:0x6A0
|
||||
AOSS_810BE5B8 = .bss:0x810BE5B8; // type:object size:0x280
|
||||
AOSS_810BE838 = .bss:0x810BE838; // type:object size:0x68
|
||||
AOSS_810BE8A0 = .bss:0x810BE8A0; // type:object size:0x400
|
||||
s_packetState = .bss:0x810BE838; // type:object size:0x68
|
||||
s_crcTable = .bss:0x810BE8A0; // type:object size:0x400
|
||||
gAtermIpConfig = .bss:0x810BECA0; // type:object size:0x7C4 data:4byte
|
||||
gAtermIfConfig = .bss:0x810BF464; // type:object size:0x15E
|
||||
ATERM_810BF5C4 = .bss:0x810BF5C4; // type:object size:0x24
|
||||
@@ -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__Q33ipl5scene15SDChannelSelectFPClPClPUxPcPUl = .text:0x813DD0AC; // type:function size:0x194
|
||||
collectTitlesFromNandUsage__Q33ipl5scene15SDChannelSelectFPClPClPUxPcPUl = .text:0x813DD240; // type:function size:0x198
|
||||
collectTitlesByChannelOrder__Q33ipl5scene15SDChannelSelectFPClPClPUxPcPUl = .text:0x813DD3D8; // type:function size:0x1F8
|
||||
collectTitlesBySpecialChannels__Q33ipl5scene15SDChannelSelectFPClPClPUxPcPUl = .text:0x813DD5D0; // type:function size:0x5A4
|
||||
collectTitlesForMode__Q33ipl5scene15SDChannelSelectFPClPClPUxPcPUli = .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
|
||||
@@ -13963,7 +13963,7 @@ lbl_816152D0 = .rodata:0x816152D0; // type:object size:0x10 scope:local data:4by
|
||||
csAninationFile__Q29textinput12candidatebox = .rodata:0x816152E0; // type:object size:0x374 scope:local
|
||||
lbl_81615658 = .rodata:0x81615658; // type:object size:0xA0 scope:local data:4byte
|
||||
csAninationFile__Q29textinput7toolbar = .rodata:0x816156F8; // type:object size:0x1DC scope:local data:4byte
|
||||
csAninationFile__Q29textinput11predictlang = .rodata:0x816158D8; // type:object size:0x268 scope:local
|
||||
csAninationFile__Q29textinput11predictlang = .rodata:0x816158D8; // type:object size:0x264 scope:local
|
||||
csAninationFileForSign__Q39textinput8keyboard10signwindow = .rodata:0x81615B40; // type:object size:0x268 scope:local
|
||||
csPaneNameToControlKey__Q39textinput8keyboard10signwindow = .rodata:0x81615DA8; // type:object size:0x48 scope:local
|
||||
csLanguageDependencyData__Q39textinput8keyboard10signwindow = .rodata:0x81615DF0; // type:object size:0x50 scope:local
|
||||
@@ -17727,12 +17727,20 @@ __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:0x68C
|
||||
scPaneNameTable = .data:0x8165D984; // type:object size:0x84
|
||||
scW_predictWindow = .data:0x8165DA08; // type:object size:0x10 data:string
|
||||
scN_predictInput = .data:0x8165DA18; // type:object size:0xF data:string
|
||||
scW_OnOff_Area = .data:0x8165DA28; // type:object size:0xD data:string
|
||||
scN_prdc_Texts = .data:0x8165DA38; // type:object size:0xD data:string
|
||||
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
|
||||
@9937 = .data:0x8165D99C; // type:object size:0xB scope:local data:string
|
||||
@9938 = .data:0x8165D9A8; // type:object size:0xA scope:local data:string
|
||||
@9939 = .data:0x8165D9B4; // type:object size:0x11 scope:local data:string
|
||||
@9940 = .data:0x8165D9C8; // type:object size:0x11 scope:local data:string
|
||||
@9941 = .data:0x8165D9DC; // type:object size:0x11 scope:local data:string
|
||||
@9942 = .data:0x8165D9F0; // type:object size:0x11 scope:local data:string
|
||||
@9943 = .data:0x8165DA08; // type:object size:0x10 scope:local data:string
|
||||
@10036 = .data:0x8165DA18; // type:object size:0xF scope:local data:string
|
||||
@10037 = .data:0x8165DA28; // type:object size:0xD scope:local data:string
|
||||
@10041 = .data:0x8165DA38; // type:object size:0xD scope:local data:string
|
||||
@10530 = .data:0x8165DA48; // type:object size:0x1C scope:local
|
||||
@6761 = .data:0x8165DA64; // type:object size:0xF scope:local data:string
|
||||
@6762 = .data:0x8165DA74; // type:object size:0xF scope:local data:string
|
||||
@@ -22774,10 +22782,7 @@ lbl_81697824 = .sdata:0x81697824; // type:object size:0x8 data:string
|
||||
lbl_8169782C = .sdata:0x8169782C; // type:object size:0x8 data:string
|
||||
lbl_81697834 = .sdata:0x81697834; // type:object size:0x8 data:string
|
||||
lbl_8169783C = .sdata:0x8169783C; // type:object size:0x8 data:string
|
||||
scCsFatalColorR = .sdata:0x81697844; // type:object size:0x1 data:byte
|
||||
scCsFatalColorG = .sdata:0x81697845; // type:object size:0x1 data:byte
|
||||
scCsFatalColorB = .sdata:0x81697846; // type:object size:0x1 data:byte
|
||||
scCsFatalColorA = .sdata:0x81697847; // type:object size:0x1 data:byte
|
||||
scCsFatalColor = .sdata:0x81697844; // type:object size:0x4 data:byte
|
||||
lbl_81697848 = .sdata:0x81697848; // type:object size:0x8 data:string
|
||||
lbl_81697850 = .sdata:0x81697850; // type:object size:0x6 data:string
|
||||
lbl_81697858 = .sdata:0x81697858; // type:object size:0x6 data:string
|
||||
@@ -23676,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
|
||||
@@ -23685,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
|
||||
|
||||
53
configure.py
53
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"),
|
||||
@@ -678,7 +678,7 @@ config.libs = [
|
||||
Object(Matching, "utility/iplThread.cpp"),
|
||||
Object(Matching, "utility/iplMessageBase.cpp"),
|
||||
Object(Matching, "utility/iplJpegDecoder.cpp"),
|
||||
Object(NonMatching, "utility/iplESMisc.cpp"),
|
||||
Object(Matching, "utility/iplESMisc.cpp"),
|
||||
Object(Matching, "utility/iplCSFlags.cpp"),
|
||||
]
|
||||
),
|
||||
@@ -700,7 +700,7 @@ config.libs = [
|
||||
Object(Matching, "iplwww/www_print.cpp"),
|
||||
Object(Matching, "iplwww/www_window.cpp"),
|
||||
Object(Matching, "iplwww/www_trasition.cpp"),
|
||||
Object(Equivalent, "iplwww/www_wiisetting.cpp"),
|
||||
Object(Matching, "iplwww/www_wiisetting.cpp"),
|
||||
Object(Matching, "iplwww/www_arcreader.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"),
|
||||
@@ -729,7 +729,7 @@ config.libs = [
|
||||
IPLSection("address", [
|
||||
Object(Matching, "scene/address/iplAddress.cpp"),
|
||||
Object(Matching, "scene/address/iplAddressAddSel.cpp"),
|
||||
Object(NonMatching, "scene/address/iplAddressEdit.cpp"),
|
||||
Object(Matching, "scene/address/iplAddressEdit.cpp"),
|
||||
]
|
||||
),
|
||||
IPLSection("backMenu", [
|
||||
@@ -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"),
|
||||
]
|
||||
@@ -849,12 +849,12 @@ config.libs = [
|
||||
]
|
||||
),
|
||||
IPLSection("sdChannelSelect", [
|
||||
Object(NonMatching, "scene/sdChannelSelect/iplSDChannelSelect.cpp"),
|
||||
Object(Matching, "scene/sdChannelSelect/iplSDChannelSelect.cpp"),
|
||||
Object(Matching, "scene/sdChannelSelect/iplSDChannelObj.cpp"),
|
||||
]
|
||||
),
|
||||
IPLSection("sdChannelTitle", [
|
||||
Object(NonMatching, "scene/sdChannelTitle/iplSDChannelTitle.cpp"),
|
||||
Object(Matching, "scene/sdChannelTitle/iplSDChannelTitle.cpp"),
|
||||
]
|
||||
),
|
||||
IPLSection("sdButton", [
|
||||
@@ -864,11 +864,11 @@ config.libs = [
|
||||
]
|
||||
),
|
||||
IPLSection("sdChannelMemory", [
|
||||
Object(NonMatching, "scene/sdChannelMemory/iplSDMemory.cpp"),
|
||||
Object(Matching, "scene/sdChannelMemory/iplSDMemory.cpp"),
|
||||
]
|
||||
),
|
||||
IPLSection("setting", [
|
||||
Object(NonMatching, "scene/setting/iplSetting.cpp"),
|
||||
Object(Matching, "scene/setting/iplSetting.cpp"),
|
||||
Object(Matching, "scene/setting/iplSensitivity.cpp"),
|
||||
Object(Matching, "scene/setting/iplNCDSetting.cpp"),
|
||||
Object(Matching, "scene/setting/iplParental.cpp"),
|
||||
@@ -879,7 +879,8 @@ config.libs = [
|
||||
Object(NonMatching, "scene/setting/AOSSLink.c"),
|
||||
Object(Matching, "scene/setting/iplRakuRakuThread.cpp"),
|
||||
Object(NonMatching, "scene/setting/AOSS.c", extra_cflags=["-O4,p", "-inline off"]),
|
||||
Object(NonMatching, "scene/setting/ATERM.c", extra_cflags=["-O4,p", "-inline on"]),
|
||||
Object(Matching, "scene/setting/AOSSData.c"),
|
||||
Object(NonMatching, "scene/setting/ATERM.c", mw_version="GC/3.0a5", extra_cflags=["-O4,p", "-inline on"]),
|
||||
]
|
||||
),
|
||||
IPLSection("settingSelect", [
|
||||
@@ -911,13 +912,13 @@ 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"]),
|
||||
Object(NonMatching, "keyboard/tiString.cpp", extra_cflags=["-O4,p"]),
|
||||
Object(NonMatching, "keyboard/tiAtokString.cpp", extra_cflags=["-O4,p"]), # for 4.3J
|
||||
Object(NonMatching, "keyboard/tiZiString.cpp", extra_cflags=["-O4,p"]), # for 4.3U and 4.3E
|
||||
Object(Matching, "keyboard/tiZiString.cpp", extra_cflags=["-O4,p"]), # for 4.3U and 4.3E
|
||||
Object(Matching, "keyboard/tiTextDrawer.cpp", extra_cflags=["-O4,p"]),
|
||||
Object(Matching, "keyboard/tiNw4rManager.cpp", extra_cflags=["-O4,p"]),
|
||||
Object(Matching, "keyboard/tiKeyboard.cpp", extra_cflags=["-O4,p"]),
|
||||
@@ -984,7 +985,7 @@ config.libs = [
|
||||
Object(Matching, "clib/zaddress.c"),
|
||||
Object(Matching, "clib/zconvert.c"),
|
||||
Object(Matching, "clib/zi81key.c"),
|
||||
Object(NonMatching, "clib/zi8alpha.c"),
|
||||
Object(Matching, "clib/zi8alpha.c"),
|
||||
Object(Matching, "clib/zi8alts.c"),
|
||||
Object(Matching, "clib/zi8cgetc.c"),
|
||||
Object(Matching, "clib/zi8cinfo.c"),
|
||||
@@ -1048,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"),
|
||||
]
|
||||
),
|
||||
@@ -1057,11 +1058,11 @@ config.libs = [
|
||||
Object(Matching, "nhttp/NHTTP_control.c"),
|
||||
Object(Matching, "nhttp/NHTTP_list.c"),
|
||||
Object(Matching, "nhttp/NHTTP_os_RVL.c"),
|
||||
Object(NonMatching, "nhttp/NHTTP_recvbuf.c"),
|
||||
Object(Matching, "nhttp/NHTTP_recvbuf.c", mw_version="GC/3.0a5"),
|
||||
Object(Matching, "nhttp/NHTTP_request.c"),
|
||||
Object(Matching, "nhttp/NHTTP_response.c"),
|
||||
Object(Matching, "nhttp/NHTTP_socket_RVL.c"),
|
||||
Object(NonMatching, "nhttp/NHTTP_stdlib_RVL.c"),
|
||||
Object(Matching, "nhttp/NHTTP_stdlib_RVL.c", mw_version="GC/3.0a5"),
|
||||
Object(Matching, "nhttp/NHTTP_thread.c"),
|
||||
Object(Matching, "nhttp/d_nhttp_private.c"),
|
||||
Object(Matching, "nhttp/d_nhttp.c"),
|
||||
@@ -1096,7 +1097,7 @@ config.libs = [
|
||||
),
|
||||
RevoEXLib("so", [
|
||||
Object(Matching, "so/SOCommon.c"),
|
||||
Object(NonMatching, "so/SOBasic.c"),
|
||||
Object(Matching, "so/SOBasic.c"),
|
||||
Object(Matching, "so/SOInformation.c"),
|
||||
Object(Matching, "so/SOOption.c"),
|
||||
]
|
||||
@@ -1209,14 +1210,14 @@ config.libs = [
|
||||
Object(Matching, "jpegdec/jdec_main.c"),
|
||||
Object(Matching, "jpegdec/jpformat.c"),
|
||||
|
||||
Object(NonMatching, "exif/exif_parse.c"),
|
||||
Object(Matching, "exif/exif_parse.c"),
|
||||
|
||||
Object(Matching, "reschange/iqdec_resolution_change_a3.c"),
|
||||
Object(Matching, "reschange/idct_resolution_change_var.c"),
|
||||
|
||||
Object(NonMatching, "texturecvtr/Texture_MCUtoY8U8V8.c"),
|
||||
Object(NonMatching, "texturecvtr/Texture_MCUtoRGB565.c"),
|
||||
Object(NonMatching, "texturecvtr/Texture_MCUtoRGBA8.c"),
|
||||
Object(Matching, "texturecvtr/Texture_MCUtoY8U8V8.c"),
|
||||
Object(Matching, "texturecvtr/Texture_MCUtoRGB565.c"),
|
||||
Object(Matching, "texturecvtr/Texture_MCUtoRGBA8.c"),
|
||||
|
||||
Object(Matching, "b65/iqdec_b65_frv32.c"),
|
||||
]
|
||||
@@ -1323,7 +1324,7 @@ config.libs = [
|
||||
Object(Matching, "lyt/lyt_layout.cpp"),
|
||||
Object(Matching, "lyt/lyt_picture.cpp"),
|
||||
Object(Matching, "lyt/lyt_textBox.cpp"),
|
||||
Object(Equivalent, "lyt/lyt_window.cpp"),
|
||||
Object(Matching, "lyt/lyt_window.cpp"),
|
||||
Object(Matching, "lyt/lyt_bounding.cpp"),
|
||||
Object(Matching, "lyt/lyt_material.cpp"),
|
||||
Object(Matching, "lyt/lyt_drawinfo.cpp"),
|
||||
@@ -1854,7 +1855,7 @@ config.libs = [
|
||||
Object(Matching, "fa/kernel/pfk_api.c"),
|
||||
|
||||
Object(Matching, "fa/driver/nand_drv.c"),
|
||||
Object(NonMatching, "fa/driver/sd_drv.c"),
|
||||
Object(Matching, "fa/driver/sd_drv.c"),
|
||||
Object(Matching, "fa/driver/pfd_cmn.c"),
|
||||
Object(Matching, "fa/driver/msc_drv.c"),
|
||||
|
||||
@@ -1885,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"),
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Assembly inventory
|
||||
|
||||
4.3U, 2026-10-05. 173 functions contain 175 assembly
|
||||
bodies/blocks: 162 ORIGINAL functions and 10 PLACEHOLDER functions.
|
||||
4.3U, 2026-10-08. 166 functions contain 168 assembly
|
||||
bodies/blocks: 162 ORIGINAL functions and 4 PLACEHOLDER functions.
|
||||
|
||||
Run `python3 tools/check_asm_inventory.py`. Completion requires exit 0, complete
|
||||
coverage and zero placeholders. The checker also rejects stale/duplicate rows,
|
||||
@@ -88,9 +88,7 @@ found. Historical logs absent from this branch have commit IDs and excerpts in
|
||||
| `libs/RVL_SDK/src/base/PPCArch.c` | `PPCSetFpIEEEMode` | ORIGINAL | Special-register or synchronization operation: `mtfsb0 FPSCR_NI_BIT`. |
|
||||
| `libs/RVL_SDK/src/base/PPCArch.c` | `PPCSetFpNonIEEEMode` | ORIGINAL | Special-register or synchronization operation: `mtfsb1 FPSCR_NI_BIT`. |
|
||||
| `libs/RVL_SDK/src/base/PPCArch.c` | `PPCMthid4` | ORIGINAL | Both branches write HID4 with mtspr; the fallback preserves the Broadway H4A bit. |
|
||||
| `libs/RVL_SDK/src/cntcache/cntcache.c` | `CNTCACHEClear` | PLACEHOLDER | NAND/token logic; best C 93.364235%, 147/151 instructions, four missing pool literals, [rx30][rx30]. |
|
||||
| `libs/RVL_SDK/src/cntcache/cntcache.c` | `_CNTCACHEIsTitleRemovable` | PLACEHOLDER | NAND/TMD checks; best diagnostic C 93.70731%, 82/82 instructions, status-register interference, [rx18][rx18]. |
|
||||
| `libs/RVL_SDK/src/cntcache/cntcache.c` | `_CNTCACHEDeleteContent` | PLACEHOLDER | Token parsing and ES deletion; best C 95.793106%, 143/145 instructions, missing reload/copy, [rx18][rx18]. |
|
||||
| `libs/RVL_SDK/src/cntcache/cntcache.c` | `CNTCACHEClear` | PLACEHOLDER | NAND/token logic; best C 47/151 differing, 149/151 instructions; pool solved with stripped writer literals, two post-delete compares missing, [rx30][rx30], [opus-cntc](../tools/decomp-assist/opus-cntc.attempts.md). |
|
||||
| `libs/RVL_SDK/src/db/db.c` | `__DBExceptionDestination` | ORIGINAL | mfmsr/mtmsr enable address translation before the exception-handler tail branch. |
|
||||
| `libs/RVL_SDK/src/gx/GXLight.c` | `PushLight` | ORIGINAL | psq_l/psq_st transfers paired-single values for the GX command stream. |
|
||||
| `libs/RVL_SDK/src/gx/GXTransform.c` | `WriteProjPS` | ORIGINAL | psq_l/psq_st transfers paired-single values for the GX command stream. |
|
||||
@@ -162,7 +160,6 @@ found. Historical logs absent from this branch have commit IDs and excerpts in
|
||||
| `libs/RVL_SDK/src/os/__ppc_eabi_init.cpp` | `__init_hardware` | ORIGINAL | Before normal C startup, mfmsr/mtmsr enables the FPU and r31 holds LR across init calls. |
|
||||
| `libs/RVL_SDK/src/os/__ppc_eabi_init.cpp` | `__flush_cache` | ORIGINAL | dcbst/sync/icbi/isync make freshly initialized code visible to instruction fetch. |
|
||||
| `libs/RVL_SDK/src/os/__ppc_eabi_init.cpp` | `__init_user` | ORIGINAL | fralloc/bl __init_cpp/frfree/blr matches the public [SDK startup assembly][sdk-init]. |
|
||||
| `libs/RevoEX/src/nwc24/NWC24UserId.c` | `getUnScrambleId` | PLACEHOLDER | Integer byte permutation; best C 76.27329%, 161/161 instructions, 97 register/scheduling differences, [rx30][rx30]. |
|
||||
| `libs/Runtime/src/Gecko_setjmp.c` | `__setjmp` | ORIGINAL | Saves or restores caller GPRs/FPRs, LR, CR, and stack state across nonlocal returns. |
|
||||
| `libs/Runtime/src/Gecko_setjmp.c` | `longjmp` | ORIGINAL | Saves or restores caller GPRs/FPRs, LR, CR, and stack state across nonlocal returns. |
|
||||
| `libs/Runtime/src/__init_cpp_exceptions.cpp` | `__exception_info_constants` | ORIGINAL | Reads the caller ABI TOC register r2 directly for exception registration. |
|
||||
@@ -189,10 +186,7 @@ found. Historical logs absent from this branch have commit IDs and excerpts in
|
||||
| `src/BS2/BS2Start.c` | `__start` | ORIGINAL | Runs before the C stack and ABI registers exist; constructs the initial stack. |
|
||||
| `src/BS2/BS2Start.c` | `__init_registers` | ORIGINAL | Initializes GPRs, r1, r2, and r13 for the C runtime. |
|
||||
| `src/scene/nakamuraTest/gamespy/common/gsPlatformUtil.c` | `GetTicks` | ORIGINAL | Inactive PS2 branch reads the CP0 Count register with mfc0 $9. |
|
||||
| `src/system/iplChannelManager.cpp` | `getTitleName__Q33ipl7channel7ManagerCFiii` | PLACEHOLDER | Channel-name copying; best C 99.57746%, 71/71 instructions, four address-order differences, [rx17][rx17]. |
|
||||
| `src/system/iplSaveDataManager.cpp` | `Manager::hasChannel` | PLACEHOLDER | Title-slot search; best C 98.87324%, 71/71 instructions, 14 mask/base register differences, [rx30][rx30]. |
|
||||
| `src/system/iplSaveDataManager.cpp` | `Manager::makePriorTitleIDList` | PLACEHOLDER | Title filtering; best recorded C 80.22556%, 124/133 instructions, address CSE, [da1](../tools/decomp-assist/da1.attempts.md); newer [rx17][rx17] 79.827065%. |
|
||||
| `src/system/iplSaveDataManager.cpp` | `Manager::doUpdateChanInfos` | PLACEHOLDER | Channel metadata updates; best C 93.35821%, 68/67 instructions, extra memset base, [rx17][rx17]. |
|
||||
| `src/system/iplSaveDataManager.cpp` | `Manager::hasChannel` | PLACEHOLDER | Title-slot search; best C 71/71 instructions, 12 mask/base register differences, [sol-ph1](../tools/decomp-assist/sol-ph1.attempts.md). |
|
||||
| `src/system/iplSystem.cpp` | `System::warning_run` | PLACEHOLDER | Scene/render calls; best C 98.66477%, 176/176 instructions, 47 saved-register differences, [rx17][rx17]. |
|
||||
| `src/system/rvl_dec.c` | `Rvl_decode` | ORIGINAL | Direct beq decoder entries preserve r3/r4 and LR; lis/ori builds the format signatures. |
|
||||
| `src/system/rvl_dec.c` | `Rvl_decode_szs` | ORIGINAL | Original SZS decoder convention: nofralloc, r0 retains output length, fixed r3..r10/CTR byte-copy pipeline. |
|
||||
@@ -200,7 +194,6 @@ found. Historical logs absent from this branch have commit IDs and excerpts in
|
||||
| `src/system/rvl_dec.c` | `Rvl_decode_asr` | ORIGINAL | nofralloc hand-built 0x40 frame saves r21..31 with stmw; work address uses lis @h/ori @l. |
|
||||
|
||||
[rx17]: ../tools/decomp-assist/rx36.attempts.md#rx17
|
||||
[rx18]: ../tools/decomp-assist/rx36.attempts.md#rx18
|
||||
[rx24]: ../tools/decomp-assist/rx36.attempts.md#rx24
|
||||
[rx30]: ../tools/decomp-assist/rx36.attempts.md#rx30
|
||||
[rx36-osinit]: ../tools/decomp-assist/rx36.attempts.md#osinit
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -129,7 +129,7 @@ namespace textinput {
|
||||
#ifdef TIHWKEYBOARD_IMPLEMENTATION
|
||||
EventObserver* getEventObserverForHardware() const { return mpEventObserver; }
|
||||
#endif
|
||||
#ifdef TISIGNWINDOW_IMPLEMENTATION
|
||||
#if defined(TISIGNWINDOW_IMPLEMENTATION) || defined(IPL_ADDRESS_EDIT_CPP)
|
||||
virtual InputForm* getInputForm();
|
||||
#else
|
||||
virtual InputForm* getInputForm() { return mpInputForm; }
|
||||
|
||||
@@ -105,7 +105,7 @@ namespace ipl {
|
||||
|
||||
#ifdef IPL_CHANNEL_TITLE_NOVTABLE
|
||||
template <typename T>
|
||||
class __declspec(novtable) HermiteIntp : public utility::FrameController {
|
||||
class HermiteIntp : public utility::FrameController {
|
||||
public:
|
||||
HermiteIntp() {}
|
||||
virtual ~HermiteIntp();
|
||||
@@ -296,45 +296,6 @@ namespace ipl {
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef IPL_SD_CHANNEL_SELECT_CPP
|
||||
} // namespace math
|
||||
} // namespace ipl
|
||||
#include "math/iplMathTypes.h"
|
||||
namespace ipl {
|
||||
namespace math {
|
||||
template <>
|
||||
class HermiteIntp<VEC3> : public utility::FrameController {
|
||||
public:
|
||||
HermiteIntp() {}
|
||||
virtual ~HermiteIntp();
|
||||
void init(const VEC3& start, const VEC3& end, f32 maxFrame, f32 startTangent, f32 endTangent, int playback = ANIM_TYPE_FORWARD, f32 speed = 1.0f);
|
||||
VEC3 get() const {
|
||||
f32 frame = mFrame;
|
||||
f32 inverseDuration = 1.0f / mMaxFrame;
|
||||
VEC3 result =
|
||||
(mStart * (1.0f + (inverseDuration * (inverseDuration *
|
||||
(inverseDuration * (frame * (2.0f * frame * frame)))) -
|
||||
inverseDuration * (inverseDuration * (3.0f * frame * frame))))) -
|
||||
(mEnd * (inverseDuration * (inverseDuration *
|
||||
(inverseDuration * (frame * (2.0f * frame * frame)))) -
|
||||
inverseDuration * (inverseDuration * (3.0f * frame * frame))));
|
||||
f32 frameSquared = frame * frame;
|
||||
f32 cubic = inverseDuration * (inverseDuration * (frame * frameSquared));
|
||||
f32 tangent = mStartTangent * (frame + (cubic -
|
||||
inverseDuration * (2.0f * frame * frame))) +
|
||||
mEndTangent * (cubic - inverseDuration * frameSquared);
|
||||
result.x += tangent;
|
||||
result.y += tangent;
|
||||
result.z += tangent;
|
||||
return result;
|
||||
}
|
||||
protected:
|
||||
VEC3 mStart;
|
||||
VEC3 mEnd;
|
||||
f32 mStartTangent;
|
||||
f32 mEndTangent;
|
||||
};
|
||||
#endif
|
||||
|
||||
} // namespace math
|
||||
} // namespace ipl
|
||||
|
||||
@@ -50,6 +50,7 @@ namespace ipl {
|
||||
void add_friendinfo();
|
||||
void delete_friendinfo();
|
||||
void set_textbox(nw4r::lyt::Pane*, const wchar_t*);
|
||||
void set_textbox(nw4r::lyt::Pane* pane, u32 msgId);
|
||||
void setDefaultTitleText(const wchar_t*, bool);
|
||||
static void wiiid_utf16(u64, wchar_t*);
|
||||
static void nigaoe_create_callback_add(ipl::nigaoe::Object*, void*);
|
||||
|
||||
@@ -180,6 +180,7 @@ namespace ipl {
|
||||
|
||||
BOOL is_url_end_code(wchar_t ch) const;
|
||||
BOOL is_url_protocol(const wchar_t* url) const;
|
||||
BOOL is_url_ext(const wchar_t* url) const;
|
||||
int get_url_end(const wchar_t* url) const;
|
||||
|
||||
BOOL is_buffer_over(const wchar_t* text, u32 textLen) const;
|
||||
|
||||
@@ -35,11 +35,7 @@ namespace ipl {
|
||||
MemoryBase* mpBase; // 0x0C
|
||||
};
|
||||
|
||||
#ifdef IPL_CHANNEL_TITLE_NOVTABLE
|
||||
class __declspec(novtable) MemoryBase {
|
||||
#else
|
||||
class MemoryBase {
|
||||
#endif
|
||||
public:
|
||||
class Anm {
|
||||
public:
|
||||
|
||||
@@ -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];
|
||||
|
||||
@@ -177,8 +177,8 @@ namespace ipl {
|
||||
const controller::Interface* controller);
|
||||
BOOL onEventDerived(const char* paneName, u32 event,
|
||||
controller::Interface* controller);
|
||||
bool collectTitlesByUsage(const s32* firstUsage, const s32* secondUsage,
|
||||
ESTitleId* titleIds, char* titleNames,
|
||||
bool collectTitlesByUsage(s32* firstUsage, s32* secondUsage,
|
||||
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();
|
||||
@@ -221,7 +226,7 @@ namespace ipl {
|
||||
int getCenterChannelIndex(const char* paneName) const;
|
||||
nw4r::lyt::Pane* getCenterChannelPane(int index) const;
|
||||
nw4r::lyt::Pane* getChannelPane(int index) const;
|
||||
static math::VEC3 getChannelPanePosition(SDChannelSelect* scene, int index);
|
||||
static nw4r::math::VEC3 getChannelPanePosition(SDChannelSelect* scene, int index);
|
||||
void calcPageAnimations();
|
||||
void processNormalInput();
|
||||
void updateArrowVisibility();
|
||||
@@ -232,17 +237,17 @@ namespace ipl {
|
||||
void setChannelScissor(const SDChannelObj* channel) const;
|
||||
bool isCurrentTitleUsageEnough(const s32* usage) const;
|
||||
void getCurrentTitleUsage(s32* bytes, s32* blocks) const;
|
||||
bool collectTitlesByChannelOrder(const s32* firstUsage, const s32* secondUsage,
|
||||
ESTitleId* titleIds, char* titleNames,
|
||||
bool collectTitlesByChannelOrder(s32* firstUsage, s32* secondUsage,
|
||||
ESTitleId* titleIds, wchar_t (*titleNames)[21],
|
||||
u32* titleCount);
|
||||
bool collectTitlesFromNandUsage(const s32* firstUsage, const s32* secondUsage,
|
||||
ESTitleId* titleIds, char* titleNames,
|
||||
bool collectTitlesFromNandUsage(s32* firstUsage, s32* secondUsage,
|
||||
ESTitleId* titleIds, wchar_t (*titleNames)[21],
|
||||
u32* titleCount);
|
||||
bool collectTitlesBySpecialChannels(const s32* firstUsage, const s32* secondUsage,
|
||||
ESTitleId* titleIds, char* titleNames,
|
||||
bool collectTitlesBySpecialChannels(s32* firstUsage, s32* secondUsage,
|
||||
ESTitleId* titleIds, wchar_t (*titleNames)[21],
|
||||
u32* titleCount);
|
||||
bool collectTitlesForMode(const s32* firstUsage, const s32* secondUsage,
|
||||
ESTitleId* titleIds, char* titleNames,
|
||||
bool collectTitlesForMode(s32* firstUsage, s32* secondUsage,
|
||||
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;
|
||||
|
||||
@@ -20,6 +20,19 @@ typedef struct AOSSInitInput {
|
||||
u8 result[0x154];
|
||||
} AOSSInitInput;
|
||||
|
||||
typedef struct AOSSKeyMaterial {
|
||||
u8 nonce[2];
|
||||
u8 address[8];
|
||||
} AOSSKeyMaterial;
|
||||
|
||||
typedef struct AOSSPacketState {
|
||||
AOSSKeyMaterial key;
|
||||
u8 payload[0x5e];
|
||||
} AOSSPacketState;
|
||||
|
||||
extern AOSSPacketState s_packetState;
|
||||
extern u32 s_crcTable[0x100];
|
||||
|
||||
int AOSSi_Init(AOSSInitInput* input);
|
||||
int AOSS_Init_old(AOSSInitInput* input);
|
||||
void* AOSSi_Alloc(u32 size);
|
||||
|
||||
@@ -50,6 +50,7 @@ namespace ipl {
|
||||
static void makeMasterkey();
|
||||
|
||||
static char* getRequestNum();
|
||||
static void dump();
|
||||
|
||||
private:
|
||||
static void _initRating();
|
||||
|
||||
@@ -18,6 +18,15 @@ namespace ipl {
|
||||
f32 margin16x9 = 120.0f, f32 margin4x3 = 30.0f);
|
||||
~TextBalloon();
|
||||
|
||||
static f32 getDefaultMargin16x9() {
|
||||
f32 margin = 120.0f;
|
||||
return margin;
|
||||
}
|
||||
static f32 getDefaultMargin4x3() {
|
||||
f32 margin = 30.0f;
|
||||
return margin;
|
||||
}
|
||||
|
||||
void calc();
|
||||
void draw();
|
||||
|
||||
|
||||
@@ -277,6 +277,9 @@ namespace ipl {
|
||||
/* SEntry */
|
||||
bool hasLoadedBnr(int page, int index) const { return mChannels[page][index].loadedBnr; }
|
||||
int getSceneID(int page, int index) const { return mChannels[page][index].loadedBnr ? mChannels[page][index].info.sceneID : 0; }
|
||||
ESTitleId getEntryTitleID(int page, int index) const {
|
||||
return mChannels[page][index].loadedBnr ? ES_TITLE_ID(mChannels[page][index].info.titleType, mChannels[page][index].info.titleCode) : 0;
|
||||
}
|
||||
|
||||
/* SMetaBlockHeader */
|
||||
u32 getIconRSOIdx(int page, int index) const {
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -47,6 +47,8 @@ namespace ipl {
|
||||
|
||||
static ESError GetValidTicketIndex(EGG::Heap* heap, ESTitleId titleId, ESTicketView* ticket = NULL, u32 ticketLength = 0);
|
||||
|
||||
static ESError DeleteSharedContent(EGG::Heap* heap);
|
||||
|
||||
static BOOL IsLastTicketExpired(ESTitleId* titleId);
|
||||
static void DeleteExpiredFlagFile();
|
||||
|
||||
|
||||
@@ -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); }
|
||||
|
||||
@@ -1,10 +1,21 @@
|
||||
#include <nw4r/db/assert.h>
|
||||
#include <nw4r/lyt/window.h>
|
||||
|
||||
#include <nw4r/lyt/common.h>
|
||||
#include <nw4r/lyt/layout.h>
|
||||
#include <nw4r/lyt/resources.h>
|
||||
#include <nw4r/lyt/types.h>
|
||||
|
||||
|
||||
#include <nw4r/math.h>
|
||||
|
||||
#include <new>
|
||||
|
||||
extern "C" const u8 scLytFatalColorR;
|
||||
extern "C" const u8 scLytFatalColorG;
|
||||
extern "C" const u8 scLytFatalColorB;
|
||||
extern "C" const u8 scLytFatalColorA;
|
||||
extern "C" char scLytFatalMsg[] = "Error#004\nAn error has occurred.\nThe system files are corrupted.";
|
||||
extern "C" char scLytFatalMsg[];
|
||||
|
||||
#undef NW4R_ASSERT
|
||||
#define NW4R_GLOBAL_ASSERT(x) \
|
||||
@@ -26,18 +37,6 @@ extern "C" char scLytFatalMsg[] = "Error#004\nAn error has occurred.\nThe system
|
||||
} \
|
||||
}
|
||||
|
||||
#include <nw4r/lyt/window.h>
|
||||
|
||||
#include <nw4r/lyt/common.h>
|
||||
#include <nw4r/lyt/layout.h>
|
||||
#include <nw4r/lyt/resources.h>
|
||||
#include <nw4r/lyt/types.h>
|
||||
|
||||
|
||||
#include <nw4r/math.h>
|
||||
|
||||
#include <new>
|
||||
|
||||
namespace nw4r {
|
||||
namespace lyt {
|
||||
NW4R_UT_GET_DERIVED_RUNTIME_TYPEINFO(Window, Pane);
|
||||
@@ -174,8 +173,22 @@ namespace {
|
||||
flipInfo.coords[VERTEXCOLOR_RB][iy] +
|
||||
polSize.height / ((flipInfo.coords[VERTEXCOLOR_RT][iy] - flipInfo.coords[VERTEXCOLOR_RB][iy]) * tSz[iy]);
|
||||
}
|
||||
|
||||
inline void SetFrameTexOrigin(math::VEC2* texCds, int corner, int ix, int iy, u8 originX, u8 originY) {
|
||||
texCds[corner][ix] = texCds[corner ^ 2][ix] = originX;
|
||||
texCds[corner][iy] = texCds[corner ^ 1][iy] = originY;
|
||||
}
|
||||
|
||||
inline void SetFrameTexExtent(math::VEC2* texCds, const Size& polSize, const Size& texSize, const TextureFlipInfo& flipInfo, int corner, int ix,
|
||||
int iy, u8 originX, u8 originY) {
|
||||
const math::VEC2 tSz(texSize.width, texSize.height);
|
||||
texCds[corner ^ 3][ix] = texCds[corner ^ 1][ix] = originX + polSize.width / ((flipInfo.coords[corner ^ 1][ix] - originX) * tSz[ix]);
|
||||
texCds[corner ^ 3][iy] = texCds[corner ^ 2][iy] = originY + polSize.height / ((flipInfo.coords[corner ^ 2][iy] - originY) * tSz[iy]);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
extern "C" char scLytFatalMsg[] = "Error#004\nAn error has occurred.\nThe system files are corrupted.";
|
||||
|
||||
namespace nw4r {
|
||||
namespace lyt {
|
||||
Window::Window(const res::Window* pBlock, const ResBlockSet& resBlockSet) : Pane(pBlock) {
|
||||
@@ -388,7 +401,17 @@ namespace nw4r {
|
||||
detail::DrawQuad(polPt, polSize, GX_TEXMAP1, texCds, bUseVtxCol ? vtxColors : NULL, alpha); \
|
||||
}
|
||||
|
||||
DRAW_QUAD_FOR_FRAME_1(LT, TEXTUREFLIP_NONE);
|
||||
GetLTFrameSize(&polPt, &polSize, basePt, mSize, frameSize);
|
||||
{
|
||||
TextureFlipInfo& flipInfo = GetTexutreFlipInfo(TEXTUREFLIP_NONE);
|
||||
int iy = flipInfo.idx[FLIPINDEX_Y];
|
||||
int ix = flipInfo.idx[FLIPINDEX_X];
|
||||
const u8 originX = flipInfo.coords[VERTEXCOLOR_LT][ix];
|
||||
const u8 originY = flipInfo.coords[VERTEXCOLOR_LT][iy];
|
||||
SetFrameTexOrigin(*texCds, VERTEXCOLOR_LT, ix, iy, originX, originY);
|
||||
SetFrameTexExtent(*texCds, polSize, texSize, flipInfo, VERTEXCOLOR_LT, ix, iy, originX, originY);
|
||||
}
|
||||
detail::DrawQuad(polPt, polSize, GX_TEXMAP1, texCds, bUseVtxCol ? vtxColors : NULL, alpha);
|
||||
DRAW_QUAD_FOR_FRAME_1(RT, TEXTUREFLIP_H);
|
||||
DRAW_QUAD_FOR_FRAME_1(RB, TEXTUREFLIP_180);
|
||||
DRAW_QUAD_FOR_FRAME_1(LB, TEXTUREFLIP_V);
|
||||
|
||||
@@ -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--;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,8 @@ enum TMCExifFormat {
|
||||
|
||||
enum TMCExifTag {
|
||||
TMC_EXIF_TAG_COMPRESSION = 0x0103,
|
||||
TMC_EXIF_TAG_MAKE = 0x010F,
|
||||
TMC_EXIF_TAG_MODEL = 0x0110,
|
||||
TMC_EXIF_TAG_STRIP_OFFSETS = 0x0111,
|
||||
TMC_EXIF_TAG_ORIENTATION = 0x0112,
|
||||
TMC_EXIF_TAG_X_RESOLUTION = 0x011A,
|
||||
@@ -69,6 +71,14 @@ static u32 readU32(const u8* p, u16 byteOrder) {
|
||||
return (raw >> 24) | ((raw >> 8) & 0xFF00) | ((raw & 0xFF00) << 8) | ((raw & 0xFF) << 24);
|
||||
}
|
||||
|
||||
static inline void convertExifWord(u32* result, u32 raw, u16 byteOrder) {
|
||||
if (byteOrder == TMC_EXIF_LITTLE_ENDIAN) {
|
||||
*result = raw;
|
||||
} else {
|
||||
*result = (raw >> 24) | ((raw >> 8) & 0xFF00) | ((raw & 0xFF00) << 8) | ((raw & 0xFF) << 24);
|
||||
}
|
||||
}
|
||||
|
||||
s32 TMCCJPEGDecGetOffsetEXIF(u32* pOffset, u32* pSize, TMCCJPEGDecInitParam* pParam) {
|
||||
TMCCJPEGDecWork* work;
|
||||
u16 segSize;
|
||||
@@ -388,9 +398,7 @@ static void TMCJPEGDEC_IFD0_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
|
||||
|
||||
switch (tag) {
|
||||
case TMC_EXIF_TAG_COMPRESSION:
|
||||
case TMC_EXIF_TAG_STRIP_OFFSETS:
|
||||
case TMC_EXIF_TAG_JPEG_INTERCHANGE_FORMAT:
|
||||
case TMC_EXIF_TAG_JPEG_INTERCHANGE_FORMAT_LENGTH: {
|
||||
case TMC_EXIF_TAG_STRIP_OFFSETS: {
|
||||
break;
|
||||
}
|
||||
case TMC_EXIF_TAG_ORIENTATION: {
|
||||
@@ -398,17 +406,27 @@ static void TMCJPEGDEC_IFD0_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
|
||||
return;
|
||||
}
|
||||
case TMC_EXIF_TAG_X_RESOLUTION: {
|
||||
u32 offset = readU32(entry->value, byteOrder);
|
||||
const u8* p = pInfo->thumbnailData + offset;
|
||||
const u8* base;
|
||||
const u8* p;
|
||||
u32 offsetRaw;
|
||||
u32 offset;
|
||||
u32 numeratorRaw;
|
||||
u32 value;
|
||||
offsetRaw = entry->value[1] << 8 | entry->value[0] | entry->value[2] << 16 | entry->value[3] << 24;
|
||||
convertExifWord(&offset, offsetRaw, byteOrder);
|
||||
p = pInfo->thumbnailData + offset;
|
||||
if (pInfo->thumbnailData > p) {
|
||||
return;
|
||||
}
|
||||
if (p > pInfo->dataEnd - sizeof(u32)) {
|
||||
return;
|
||||
}
|
||||
pInfo->xResNum = readU32(p, byteOrder);
|
||||
p = pInfo->thumbnailData + (offset + sizeof(u32));
|
||||
if (pInfo->thumbnailData > p) {
|
||||
numeratorRaw = p[1] << 8 | p[0] | p[2] << 16 | p[3] << 24;
|
||||
convertExifWord(&value, numeratorRaw, byteOrder);
|
||||
pInfo->xResNum = value;
|
||||
base = pInfo->thumbnailData;
|
||||
p = base + (offset + sizeof(u32));
|
||||
if (base > p) {
|
||||
return;
|
||||
}
|
||||
if (p > pInfo->dataEnd - sizeof(u32)) {
|
||||
@@ -418,17 +436,27 @@ static void TMCJPEGDEC_IFD0_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
|
||||
return;
|
||||
}
|
||||
case TMC_EXIF_TAG_Y_RESOLUTION: {
|
||||
u32 offset = readU32(entry->value, byteOrder);
|
||||
const u8* p = pInfo->thumbnailData + offset;
|
||||
const u8* base;
|
||||
const u8* p;
|
||||
u32 offsetRaw;
|
||||
u32 offset;
|
||||
u32 numeratorRaw;
|
||||
u32 value;
|
||||
offsetRaw = entry->value[1] << 8 | entry->value[0] | entry->value[2] << 16 | entry->value[3] << 24;
|
||||
convertExifWord(&offset, offsetRaw, byteOrder);
|
||||
p = pInfo->thumbnailData + offset;
|
||||
if (pInfo->thumbnailData > p) {
|
||||
return;
|
||||
}
|
||||
if (p > pInfo->dataEnd - sizeof(u32)) {
|
||||
return;
|
||||
}
|
||||
pInfo->yResNum = readU32(p, byteOrder);
|
||||
p = pInfo->thumbnailData + (offset + sizeof(u32));
|
||||
if (pInfo->thumbnailData > p) {
|
||||
numeratorRaw = p[1] << 8 | p[0] | p[2] << 16 | p[3] << 24;
|
||||
convertExifWord(&value, numeratorRaw, byteOrder);
|
||||
pInfo->yResNum = value;
|
||||
base = pInfo->thumbnailData;
|
||||
p = base + (offset + sizeof(u32));
|
||||
if (base > p) {
|
||||
return;
|
||||
}
|
||||
if (p > pInfo->dataEnd - sizeof(u32)) {
|
||||
@@ -525,6 +553,12 @@ static void TMCJPEGDEC_IFD0_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
|
||||
} else if (type == TMC_EXIF_TYPE_LONG) {
|
||||
pInfo->pixelYDim = readU32(entry->value, byteOrder);
|
||||
}
|
||||
}
|
||||
case TMC_EXIF_TAG_MAKE:
|
||||
case TMC_EXIF_TAG_MODEL:
|
||||
case TMC_EXIF_TAG_JPEG_INTERCHANGE_FORMAT:
|
||||
case TMC_EXIF_TAG_JPEG_INTERCHANGE_FORMAT_LENGTH:
|
||||
default: {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -534,25 +568,18 @@ static void TMCJPEGDEC_IFD1_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
|
||||
s32 tag = readU16(entry->tag, byteOrder);
|
||||
|
||||
switch (tag) {
|
||||
case TMC_EXIF_TAG_DATE_TIME:
|
||||
case TMC_EXIF_TAG_STRIP_OFFSETS:
|
||||
case TMC_EXIF_TAG_ORIENTATION:
|
||||
case TMC_EXIF_TAG_TRANSFER_FUNCTION:
|
||||
case TMC_EXIF_TAG_YCBCR_POSITIONING:
|
||||
case TMC_EXIF_TAG_EXIF_IFD:
|
||||
case TMC_EXIF_TAG_EXIF_VERSION:
|
||||
case TMC_EXIF_TAG_COMPONENTS_CONFIGURATION:
|
||||
case TMC_EXIF_TAG_PLANAR_CONFIGURATION:
|
||||
case TMC_EXIF_TAG_FLASHPIX_VERSION:
|
||||
case TMC_EXIF_TAG_COLOR_SPACE:
|
||||
case TMC_EXIF_TAG_PIXEL_X_DIMENSION:
|
||||
case TMC_EXIF_TAG_PIXEL_Y_DIMENSION: {
|
||||
case TMC_EXIF_TAG_STRIP_OFFSETS: {
|
||||
break;
|
||||
}
|
||||
case TMC_EXIF_TAG_X_RESOLUTION: {
|
||||
u32 offset;
|
||||
const u8* base;
|
||||
const u8* p;
|
||||
offset = readU32(entry->value, byteOrder);
|
||||
u32 offsetRaw;
|
||||
u32 offset;
|
||||
u32 numeratorRaw;
|
||||
u32 value;
|
||||
offsetRaw = entry->value[1] << 8 | entry->value[0] | entry->value[2] << 16 | entry->value[3] << 24;
|
||||
convertExifWord(&offset, offsetRaw, byteOrder);
|
||||
p = pInfo->thumbnailData + offset;
|
||||
if (pInfo->thumbnailData > p) {
|
||||
return;
|
||||
@@ -560,9 +587,12 @@ static void TMCJPEGDEC_IFD1_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
|
||||
if (p > pInfo->dataEnd - sizeof(u32)) {
|
||||
return;
|
||||
}
|
||||
pInfo->xResNumIfd1 = readU32(p, byteOrder);
|
||||
p = pInfo->thumbnailData + (offset + sizeof(u32));
|
||||
if (pInfo->thumbnailData > p) {
|
||||
numeratorRaw = p[1] << 8 | p[0] | p[2] << 16 | p[3] << 24;
|
||||
convertExifWord(&value, numeratorRaw, byteOrder);
|
||||
pInfo->xResNumIfd1 = value;
|
||||
base = pInfo->thumbnailData;
|
||||
p = base + (offset + sizeof(u32));
|
||||
if (base > p) {
|
||||
return;
|
||||
}
|
||||
if (p > pInfo->dataEnd - sizeof(u32)) {
|
||||
@@ -572,9 +602,14 @@ static void TMCJPEGDEC_IFD1_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
|
||||
return;
|
||||
}
|
||||
case TMC_EXIF_TAG_Y_RESOLUTION: {
|
||||
u32 offset;
|
||||
const u8* base;
|
||||
const u8* p;
|
||||
offset = readU32(entry->value, byteOrder);
|
||||
u32 offsetRaw;
|
||||
u32 offset;
|
||||
u32 numeratorRaw;
|
||||
u32 value;
|
||||
offsetRaw = entry->value[1] << 8 | entry->value[0] | entry->value[2] << 16 | entry->value[3] << 24;
|
||||
convertExifWord(&offset, offsetRaw, byteOrder);
|
||||
p = pInfo->thumbnailData + offset;
|
||||
if (pInfo->thumbnailData > p) {
|
||||
return;
|
||||
@@ -582,9 +617,12 @@ static void TMCJPEGDEC_IFD1_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
|
||||
if (p > pInfo->dataEnd - sizeof(u32)) {
|
||||
return;
|
||||
}
|
||||
pInfo->planarConfigIfd1 = readU32(p, byteOrder);
|
||||
p = pInfo->thumbnailData + (offset + sizeof(u32));
|
||||
if (pInfo->thumbnailData > p) {
|
||||
numeratorRaw = p[1] << 8 | p[0] | p[2] << 16 | p[3] << 24;
|
||||
convertExifWord(&value, numeratorRaw, byteOrder);
|
||||
pInfo->planarConfigIfd1 = value;
|
||||
base = pInfo->thumbnailData;
|
||||
p = base + (offset + sizeof(u32));
|
||||
if (base > p) {
|
||||
return;
|
||||
}
|
||||
if (p > pInfo->dataEnd - sizeof(u32)) {
|
||||
@@ -607,6 +645,21 @@ static void TMCJPEGDEC_IFD1_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
|
||||
}
|
||||
case TMC_EXIF_TAG_JPEG_INTERCHANGE_FORMAT_LENGTH: {
|
||||
pInfo->thumbnailLength = readU32(entry->value, byteOrder);
|
||||
}
|
||||
case TMC_EXIF_TAG_DATE_TIME:
|
||||
case TMC_EXIF_TAG_ORIENTATION:
|
||||
case TMC_EXIF_TAG_TRANSFER_FUNCTION:
|
||||
case TMC_EXIF_TAG_YCBCR_POSITIONING:
|
||||
case TMC_EXIF_TAG_EXIF_IFD:
|
||||
case TMC_EXIF_TAG_EXIF_VERSION:
|
||||
case TMC_EXIF_TAG_COMPONENTS_CONFIGURATION:
|
||||
case TMC_EXIF_TAG_FLASHPIX_VERSION:
|
||||
case TMC_EXIF_TAG_COLOR_SPACE:
|
||||
case TMC_EXIF_TAG_PIXEL_X_DIMENSION:
|
||||
case TMC_EXIF_TAG_PIXEL_Y_DIMENSION:
|
||||
case TMC_EXIF_TAG_MAKE:
|
||||
case TMC_EXIF_TAG_MODEL:
|
||||
default: {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,37 @@ static void TMCJPEGDEC_converterYUV444toRGB565edge(TMCCJPEGDecWork*, s32, s32);
|
||||
static void TMCJPEGDEC_converterYUV400toRGB565(TMCCJPEGDecWork*, s32, s32);
|
||||
static void TMCJPEGDEC_converterYUV400toRGB565edge(TMCCJPEGDecWork*, s32, s32);
|
||||
|
||||
#pragma push
|
||||
#pragma optimization_level 1
|
||||
s32 TMCJPEGDEC_set_converterRGB565(TMCCJPEGDecWork* work) {
|
||||
u8 mode411;
|
||||
u8* crBlock411;
|
||||
u8* cbBlock411;
|
||||
u8* fourthRow411;
|
||||
u8* thirdRow411;
|
||||
u8* secondRow411;
|
||||
u8* firstRow411;
|
||||
TMCConverterFunc* edgeConverter411;
|
||||
TMCConverterFunc* converter411;
|
||||
|
||||
u8 mode422;
|
||||
u8* crBlock422;
|
||||
u8* cbBlock422;
|
||||
u8* secondRow422;
|
||||
u8* firstRow422;
|
||||
TMCConverterFunc* edgeConverter422;
|
||||
TMCConverterFunc* converter422;
|
||||
|
||||
u8 mode420;
|
||||
u8* crBlock420;
|
||||
u8* cbBlock420;
|
||||
u8* fourthRow420;
|
||||
u8* thirdRow420;
|
||||
u8* secondRow420;
|
||||
u8* firstRow420;
|
||||
TMCConverterFunc* edgeConverter420;
|
||||
TMCConverterFunc* converter420;
|
||||
|
||||
u8* buffer;
|
||||
s32 componentCount;
|
||||
TMCCJPEGDecState* state;
|
||||
@@ -25,97 +55,84 @@ s32 TMCJPEGDEC_set_converterRGB565(TMCCJPEGDecWork* work) {
|
||||
|
||||
switch (componentCount) {
|
||||
case 0: {
|
||||
u8 mode;
|
||||
u8* firstRow;
|
||||
u8* secondRow;
|
||||
u8* thirdRow;
|
||||
u8* fourthRow;
|
||||
u8* cbBlock;
|
||||
u8* crBlock;
|
||||
|
||||
mode = work->idctMode;
|
||||
firstRow = buffer + 4;
|
||||
work->pConverterFunc = TMCJPEGDEC_converterYUV411toRGB565;
|
||||
work->pConverterFuncEdge = TMCJPEGDEC_converterYUV411toRGB565edge;
|
||||
secondRow = firstRow + mode;
|
||||
thirdRow = secondRow + mode;
|
||||
fourthRow = thirdRow + mode;
|
||||
cbBlock = buffer + 260;
|
||||
crBlock = buffer + 324;
|
||||
work->pConvRowPtrs[0] = firstRow;
|
||||
work->pConvRowPtrs[1] = secondRow;
|
||||
work->pConvRowPtrs[2] = thirdRow;
|
||||
work->pConvRowPtrs[3] = fourthRow;
|
||||
work->pConvRowPtrs[5] = cbBlock;
|
||||
work->pConvRowPtrs[6] = crBlock;
|
||||
mode411 = work->idctMode;
|
||||
firstRow411 = buffer + 4;
|
||||
converter411 = TMCJPEGDEC_converterYUV411toRGB565;
|
||||
edgeConverter411 = TMCJPEGDEC_converterYUV411toRGB565edge;
|
||||
secondRow411 = firstRow411 + mode411;
|
||||
thirdRow411 = secondRow411 + mode411;
|
||||
fourthRow411 = thirdRow411 + mode411;
|
||||
cbBlock411 = buffer + 260;
|
||||
crBlock411 = buffer + 324;
|
||||
work->pConverterFunc = converter411;
|
||||
work->pConverterFuncEdge = edgeConverter411;
|
||||
work->pConvRowPtrs[0] = firstRow411;
|
||||
work->pConvRowPtrs[1] = secondRow411;
|
||||
work->pConvRowPtrs[2] = thirdRow411;
|
||||
work->pConvRowPtrs[3] = fourthRow411;
|
||||
work->pConvRowPtrs[5] = cbBlock411;
|
||||
work->pConvRowPtrs[6] = crBlock411;
|
||||
work->pitch = 32;
|
||||
work->converterFlags = 0;
|
||||
break;
|
||||
}
|
||||
case 1: {
|
||||
u8 mode;
|
||||
u8* firstRow;
|
||||
u8* secondRow;
|
||||
u8* cbBlock;
|
||||
u8* crBlock;
|
||||
|
||||
mode = work->idctMode;
|
||||
firstRow = buffer + 4;
|
||||
work->pConverterFunc = TMCJPEGDEC_converterYUV422toRGB565;
|
||||
work->pConverterFuncEdge = TMCJPEGDEC_converterYUV422toRGB565edge;
|
||||
secondRow = firstRow + mode;
|
||||
cbBlock = buffer + 132;
|
||||
crBlock = buffer + 196;
|
||||
work->pConvRowPtrs[0] = firstRow;
|
||||
work->pConvRowPtrs[1] = secondRow;
|
||||
work->pConvRowPtrs[5] = cbBlock;
|
||||
work->pConvRowPtrs[6] = crBlock;
|
||||
mode422 = work->idctMode;
|
||||
firstRow422 = buffer + 4;
|
||||
converter422 = TMCJPEGDEC_converterYUV422toRGB565;
|
||||
edgeConverter422 = TMCJPEGDEC_converterYUV422toRGB565edge;
|
||||
secondRow422 = firstRow422 + mode422;
|
||||
cbBlock422 = buffer + 132;
|
||||
crBlock422 = buffer + 196;
|
||||
work->pConverterFunc = converter422;
|
||||
work->pConverterFuncEdge = edgeConverter422;
|
||||
work->pConvRowPtrs[0] = firstRow422;
|
||||
work->pConvRowPtrs[1] = secondRow422;
|
||||
work->pConvRowPtrs[5] = cbBlock422;
|
||||
work->pConvRowPtrs[6] = crBlock422;
|
||||
work->pitch = 16;
|
||||
work->converterFlags = 0;
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
u8 mode;
|
||||
u8* firstRow;
|
||||
u8* secondRow;
|
||||
u8* thirdRow;
|
||||
u8* fourthRow;
|
||||
u8* cbBlock;
|
||||
u8* crBlock;
|
||||
|
||||
mode = work->idctMode;
|
||||
firstRow = buffer + 4;
|
||||
work->pConverterFunc = TMCJPEGDEC_converterYUV420toRGB565;
|
||||
work->pConverterFuncEdge = TMCJPEGDEC_converterYUV420toRGB565edge;
|
||||
secondRow = firstRow + mode;
|
||||
thirdRow = firstRow + mode * 16;
|
||||
fourthRow = thirdRow + mode;
|
||||
cbBlock = buffer + 260;
|
||||
crBlock = buffer + 324;
|
||||
work->pConvRowPtrs[0] = firstRow;
|
||||
work->pConvRowPtrs[1] = secondRow;
|
||||
work->pConvRowPtrs[2] = thirdRow;
|
||||
work->pConvRowPtrs[3] = fourthRow;
|
||||
work->pConvRowPtrs[5] = cbBlock;
|
||||
work->pConvRowPtrs[6] = crBlock;
|
||||
mode420 = work->idctMode;
|
||||
firstRow420 = buffer + 4;
|
||||
converter420 = TMCJPEGDEC_converterYUV420toRGB565;
|
||||
edgeConverter420 = TMCJPEGDEC_converterYUV420toRGB565edge;
|
||||
secondRow420 = firstRow420 + mode420;
|
||||
thirdRow420 = firstRow420 + mode420 * 16;
|
||||
fourthRow420 = thirdRow420 + mode420;
|
||||
cbBlock420 = buffer + 260;
|
||||
crBlock420 = buffer + 324;
|
||||
work->pConverterFunc = converter420;
|
||||
work->pConverterFuncEdge = edgeConverter420;
|
||||
work->pConvRowPtrs[0] = firstRow420;
|
||||
work->pConvRowPtrs[1] = secondRow420;
|
||||
work->pConvRowPtrs[2] = thirdRow420;
|
||||
work->pConvRowPtrs[3] = fourthRow420;
|
||||
work->pConvRowPtrs[5] = cbBlock420;
|
||||
work->pConvRowPtrs[6] = crBlock420;
|
||||
work->pitch = 16;
|
||||
work->converterFlags = 0;
|
||||
break;
|
||||
}
|
||||
case 3: {
|
||||
u8 mode;
|
||||
u8* firstRow;
|
||||
u8* secondRow;
|
||||
u8* cbBlock;
|
||||
u32 mode;
|
||||
u8* crBlock;
|
||||
|
||||
u8* cbBlock;
|
||||
u8* secondRow;
|
||||
u8* firstRow;
|
||||
TMCConverterFunc* edgeConverter;
|
||||
TMCConverterFunc* converter;
|
||||
mode = work->idctMode;
|
||||
firstRow = buffer + 4;
|
||||
work->pConverterFunc = TMCJPEGDEC_converterYUV211toRGB565;
|
||||
work->pConverterFuncEdge = TMCJPEGDEC_converterYUV211toRGB565edge;
|
||||
converter = TMCJPEGDEC_converterYUV211toRGB565;
|
||||
edgeConverter = TMCJPEGDEC_converterYUV211toRGB565edge;
|
||||
secondRow = firstRow + mode * 8;
|
||||
cbBlock = buffer + 132;
|
||||
crBlock = buffer + 196;
|
||||
work->pConverterFunc = converter;
|
||||
work->pConverterFuncEdge = edgeConverter;
|
||||
work->pConvRowPtrs[0] = firstRow;
|
||||
work->pConvRowPtrs[1] = secondRow;
|
||||
work->pConvRowPtrs[5] = cbBlock;
|
||||
@@ -125,27 +142,27 @@ s32 TMCJPEGDEC_set_converterRGB565(TMCCJPEGDecWork* work) {
|
||||
break;
|
||||
}
|
||||
case 4: {
|
||||
TMCConverterFunc* converter;
|
||||
TMCConverterFunc* edgeConverter;
|
||||
TMCConverterFunc* converter;
|
||||
converter = TMCJPEGDEC_converterYUV444toRGB565;
|
||||
edgeConverter = TMCJPEGDEC_converterYUV444toRGB565edge;
|
||||
work->pConverterFunc = converter;
|
||||
work->pConverterFuncEdge = edgeConverter;
|
||||
work->pConvRowPtrs[0] = buffer + 4;
|
||||
work->pConvRowPtrs[5] = buffer + 0x44;
|
||||
work->pConvRowPtrs[6] = buffer + 0x84;
|
||||
work->pConverterFunc = converter;
|
||||
work->pConverterFuncEdge = edgeConverter;
|
||||
work->pitch = 0x08;
|
||||
work->converterFlags = 0;
|
||||
break;
|
||||
}
|
||||
case 5: {
|
||||
TMCConverterFunc* converter;
|
||||
TMCConverterFunc* edgeConverter;
|
||||
TMCConverterFunc* converter;
|
||||
converter = TMCJPEGDEC_converterYUV400toRGB565;
|
||||
edgeConverter = TMCJPEGDEC_converterYUV400toRGB565edge;
|
||||
work->pConvRowPtrs[0] = buffer + 4;
|
||||
work->pConverterFunc = converter;
|
||||
work->pConverterFuncEdge = edgeConverter;
|
||||
work->pConvRowPtrs[0] = buffer + 4;
|
||||
work->pitch = 0x08;
|
||||
work->converterFlags = 0;
|
||||
break;
|
||||
@@ -158,13 +175,19 @@ s32 TMCJPEGDEC_set_converterRGB565(TMCCJPEGDecWork* work) {
|
||||
{
|
||||
s32 width = state->jpegWidth;
|
||||
s32 height = state->jpegHeight;
|
||||
state->convWidth = ((u32)width / 4 + (width % 4 != 0)) * 4;
|
||||
state->convHeight = ((u32)height / 4 + (height % 4 != 0)) * 4;
|
||||
s32 roundedWidth;
|
||||
s32 heightPadding;
|
||||
|
||||
roundedWidth = (u32)width / 4 + (width % 4 != 0);
|
||||
heightPadding = height % 4 != 0;
|
||||
state->convWidth = roundedWidth * 4;
|
||||
state->convHeight = ((u32)height / 4 + heightPadding) * 4;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#pragma pop
|
||||
|
||||
static void TMCJPEGDEC_converterYUV411toRGB565(TMCCJPEGDecWork* work, s32 x, s32 y) {
|
||||
s32 tileColumn;
|
||||
s32 red;
|
||||
|
||||
@@ -14,7 +14,37 @@ static void TMCJPEGDEC_converterYUV444toRGBA8edge(TMCCJPEGDecWork*, s32, s32);
|
||||
static void TMCJPEGDEC_converterYUV400toRGBA8(TMCCJPEGDecWork*, s32, s32);
|
||||
static void TMCJPEGDEC_converterYUV400toRGBA8edge(TMCCJPEGDecWork*, s32, s32);
|
||||
|
||||
#pragma push
|
||||
#pragma optimization_level 1
|
||||
s32 TMCJPEGDEC_set_converterRGBA8(TMCCJPEGDecWork* work) {
|
||||
u8 mode411;
|
||||
u8* crBlock411;
|
||||
u8* cbBlock411;
|
||||
u8* fourthRow411;
|
||||
u8* thirdRow411;
|
||||
u8* secondRow411;
|
||||
u8* firstRow411;
|
||||
TMCConverterFunc* edgeConverter411;
|
||||
TMCConverterFunc* converter411;
|
||||
|
||||
u8 mode422;
|
||||
u8* crBlock422;
|
||||
u8* cbBlock422;
|
||||
u8* secondRow422;
|
||||
u8* firstRow422;
|
||||
TMCConverterFunc* edgeConverter422;
|
||||
TMCConverterFunc* converter422;
|
||||
|
||||
u8 mode420;
|
||||
u8* crBlock420;
|
||||
u8* cbBlock420;
|
||||
u8* fourthRow420;
|
||||
u8* thirdRow420;
|
||||
u8* secondRow420;
|
||||
u8* firstRow420;
|
||||
TMCConverterFunc* edgeConverter420;
|
||||
TMCConverterFunc* converter420;
|
||||
|
||||
u8* buffer;
|
||||
s32 componentCount;
|
||||
TMCCJPEGDecState* state;
|
||||
@@ -25,97 +55,84 @@ s32 TMCJPEGDEC_set_converterRGBA8(TMCCJPEGDecWork* work) {
|
||||
|
||||
switch (componentCount) {
|
||||
case 0: {
|
||||
u8 mode;
|
||||
u8* firstRow;
|
||||
u8* secondRow;
|
||||
u8* thirdRow;
|
||||
u8* fourthRow;
|
||||
u8* cbBlock;
|
||||
u8* crBlock;
|
||||
|
||||
mode = work->idctMode;
|
||||
firstRow = buffer + 4;
|
||||
work->pConverterFunc = TMCJPEGDEC_converterYUV411toRGBA8;
|
||||
work->pConverterFuncEdge = TMCJPEGDEC_converterYUV411toRGBA8edge;
|
||||
secondRow = firstRow + mode;
|
||||
thirdRow = secondRow + mode;
|
||||
fourthRow = thirdRow + mode;
|
||||
cbBlock = buffer + 260;
|
||||
crBlock = buffer + 324;
|
||||
work->pConvRowPtrs[0] = firstRow;
|
||||
work->pConvRowPtrs[1] = secondRow;
|
||||
work->pConvRowPtrs[2] = thirdRow;
|
||||
work->pConvRowPtrs[3] = fourthRow;
|
||||
work->pConvRowPtrs[5] = cbBlock;
|
||||
work->pConvRowPtrs[6] = crBlock;
|
||||
mode411 = work->idctMode;
|
||||
firstRow411 = buffer + 4;
|
||||
converter411 = TMCJPEGDEC_converterYUV411toRGBA8;
|
||||
edgeConverter411 = TMCJPEGDEC_converterYUV411toRGBA8edge;
|
||||
secondRow411 = firstRow411 + mode411;
|
||||
thirdRow411 = secondRow411 + mode411;
|
||||
fourthRow411 = thirdRow411 + mode411;
|
||||
cbBlock411 = buffer + 260;
|
||||
crBlock411 = buffer + 324;
|
||||
work->pConverterFunc = converter411;
|
||||
work->pConverterFuncEdge = edgeConverter411;
|
||||
work->pConvRowPtrs[0] = firstRow411;
|
||||
work->pConvRowPtrs[1] = secondRow411;
|
||||
work->pConvRowPtrs[2] = thirdRow411;
|
||||
work->pConvRowPtrs[3] = fourthRow411;
|
||||
work->pConvRowPtrs[5] = cbBlock411;
|
||||
work->pConvRowPtrs[6] = crBlock411;
|
||||
work->pitch = 32;
|
||||
work->converterFlags = 0;
|
||||
break;
|
||||
}
|
||||
case 1: {
|
||||
u8 mode;
|
||||
u8* firstRow;
|
||||
u8* secondRow;
|
||||
u8* cbBlock;
|
||||
u8* crBlock;
|
||||
|
||||
mode = work->idctMode;
|
||||
firstRow = buffer + 4;
|
||||
work->pConverterFunc = TMCJPEGDEC_converterYUV422toRGBA8;
|
||||
work->pConverterFuncEdge = TMCJPEGDEC_converterYUV422toRGBA8edge;
|
||||
secondRow = firstRow + mode;
|
||||
cbBlock = buffer + 132;
|
||||
crBlock = buffer + 196;
|
||||
work->pConvRowPtrs[0] = firstRow;
|
||||
work->pConvRowPtrs[1] = secondRow;
|
||||
work->pConvRowPtrs[5] = cbBlock;
|
||||
work->pConvRowPtrs[6] = crBlock;
|
||||
mode422 = work->idctMode;
|
||||
firstRow422 = buffer + 4;
|
||||
converter422 = TMCJPEGDEC_converterYUV422toRGBA8;
|
||||
edgeConverter422 = TMCJPEGDEC_converterYUV422toRGBA8edge;
|
||||
secondRow422 = firstRow422 + mode422;
|
||||
cbBlock422 = buffer + 132;
|
||||
crBlock422 = buffer + 196;
|
||||
work->pConverterFunc = converter422;
|
||||
work->pConverterFuncEdge = edgeConverter422;
|
||||
work->pConvRowPtrs[0] = firstRow422;
|
||||
work->pConvRowPtrs[1] = secondRow422;
|
||||
work->pConvRowPtrs[5] = cbBlock422;
|
||||
work->pConvRowPtrs[6] = crBlock422;
|
||||
work->pitch = 16;
|
||||
work->converterFlags = 0;
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
u8 mode;
|
||||
u8* firstRow;
|
||||
u8* secondRow;
|
||||
u8* thirdRow;
|
||||
u8* fourthRow;
|
||||
u8* cbBlock;
|
||||
u8* crBlock;
|
||||
|
||||
mode = work->idctMode;
|
||||
firstRow = buffer + 4;
|
||||
work->pConverterFunc = TMCJPEGDEC_converterYUV420toRGBA8;
|
||||
work->pConverterFuncEdge = TMCJPEGDEC_converterYUV420toRGBA8edge;
|
||||
secondRow = firstRow + mode;
|
||||
thirdRow = firstRow + mode * 16;
|
||||
fourthRow = thirdRow + mode;
|
||||
cbBlock = buffer + 260;
|
||||
crBlock = buffer + 324;
|
||||
work->pConvRowPtrs[0] = firstRow;
|
||||
work->pConvRowPtrs[1] = secondRow;
|
||||
work->pConvRowPtrs[2] = thirdRow;
|
||||
work->pConvRowPtrs[3] = fourthRow;
|
||||
work->pConvRowPtrs[5] = cbBlock;
|
||||
work->pConvRowPtrs[6] = crBlock;
|
||||
mode420 = work->idctMode;
|
||||
firstRow420 = buffer + 4;
|
||||
converter420 = TMCJPEGDEC_converterYUV420toRGBA8;
|
||||
edgeConverter420 = TMCJPEGDEC_converterYUV420toRGBA8edge;
|
||||
secondRow420 = firstRow420 + mode420;
|
||||
thirdRow420 = firstRow420 + mode420 * 16;
|
||||
fourthRow420 = thirdRow420 + mode420;
|
||||
cbBlock420 = buffer + 260;
|
||||
crBlock420 = buffer + 324;
|
||||
work->pConverterFunc = converter420;
|
||||
work->pConverterFuncEdge = edgeConverter420;
|
||||
work->pConvRowPtrs[0] = firstRow420;
|
||||
work->pConvRowPtrs[1] = secondRow420;
|
||||
work->pConvRowPtrs[2] = thirdRow420;
|
||||
work->pConvRowPtrs[3] = fourthRow420;
|
||||
work->pConvRowPtrs[5] = cbBlock420;
|
||||
work->pConvRowPtrs[6] = crBlock420;
|
||||
work->pitch = 16;
|
||||
work->converterFlags = 0;
|
||||
break;
|
||||
}
|
||||
case 3: {
|
||||
u8 mode;
|
||||
u8* firstRow;
|
||||
u8* secondRow;
|
||||
u8* cbBlock;
|
||||
u32 mode;
|
||||
u8* crBlock;
|
||||
|
||||
u8* cbBlock;
|
||||
u8* secondRow;
|
||||
u8* firstRow;
|
||||
TMCConverterFunc* edgeConverter;
|
||||
TMCConverterFunc* converter;
|
||||
mode = work->idctMode;
|
||||
firstRow = buffer + 4;
|
||||
work->pConverterFunc = TMCJPEGDEC_converterYUV211toRGBA8;
|
||||
work->pConverterFuncEdge = TMCJPEGDEC_converterYUV211toRGBA8edge;
|
||||
converter = TMCJPEGDEC_converterYUV211toRGBA8;
|
||||
edgeConverter = TMCJPEGDEC_converterYUV211toRGBA8edge;
|
||||
secondRow = firstRow + mode * 8;
|
||||
cbBlock = buffer + 132;
|
||||
crBlock = buffer + 196;
|
||||
work->pConverterFunc = converter;
|
||||
work->pConverterFuncEdge = edgeConverter;
|
||||
work->pConvRowPtrs[0] = firstRow;
|
||||
work->pConvRowPtrs[1] = secondRow;
|
||||
work->pConvRowPtrs[5] = cbBlock;
|
||||
@@ -125,27 +142,27 @@ s32 TMCJPEGDEC_set_converterRGBA8(TMCCJPEGDecWork* work) {
|
||||
break;
|
||||
}
|
||||
case 4: {
|
||||
TMCConverterFunc* converter;
|
||||
TMCConverterFunc* edgeConverter;
|
||||
TMCConverterFunc* converter;
|
||||
converter = TMCJPEGDEC_converterYUV444toRGBA8;
|
||||
edgeConverter = TMCJPEGDEC_converterYUV444toRGBA8edge;
|
||||
work->pConverterFunc = converter;
|
||||
work->pConverterFuncEdge = edgeConverter;
|
||||
work->pConvRowPtrs[0] = buffer + 4;
|
||||
work->pConvRowPtrs[5] = buffer + 0x44;
|
||||
work->pConvRowPtrs[6] = buffer + 0x84;
|
||||
work->pConverterFunc = converter;
|
||||
work->pConverterFuncEdge = edgeConverter;
|
||||
work->pitch = 0x08;
|
||||
work->converterFlags = 0;
|
||||
break;
|
||||
}
|
||||
case 5: {
|
||||
TMCConverterFunc* converter;
|
||||
TMCConverterFunc* edgeConverter;
|
||||
TMCConverterFunc* converter;
|
||||
converter = TMCJPEGDEC_converterYUV400toRGBA8;
|
||||
edgeConverter = TMCJPEGDEC_converterYUV400toRGBA8edge;
|
||||
work->pConvRowPtrs[0] = buffer + 4;
|
||||
work->pConverterFunc = converter;
|
||||
work->pConverterFuncEdge = edgeConverter;
|
||||
work->pConvRowPtrs[0] = buffer + 4;
|
||||
work->pitch = 0x08;
|
||||
work->converterFlags = 0;
|
||||
break;
|
||||
@@ -158,129 +175,127 @@ s32 TMCJPEGDEC_set_converterRGBA8(TMCCJPEGDecWork* work) {
|
||||
{
|
||||
s32 width = state->jpegWidth;
|
||||
s32 height = state->jpegHeight;
|
||||
state->convWidth = ((u32)width / 4 + (width % 4 != 0)) * 4;
|
||||
state->convHeight = ((u32)height / 4 + (height % 4 != 0)) * 4;
|
||||
s32 roundedWidth;
|
||||
s32 heightPadding;
|
||||
|
||||
roundedWidth = (u32)width / 4 + (width % 4 != 0);
|
||||
heightPadding = height % 4 != 0;
|
||||
state->convWidth = roundedWidth * 4;
|
||||
state->convHeight = ((u32)height / 4 + heightPadding) * 4;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#pragma pop
|
||||
|
||||
static void TMCJPEGDEC_converterYUV411toRGBA8(TMCCJPEGDecWork* work, s32 x, s32 y) {
|
||||
u16* output;
|
||||
s32 tileRow;
|
||||
s32 secondGreen;
|
||||
s32 thirdGreen;
|
||||
s32 fourthBlue;
|
||||
s32 columnInTile;
|
||||
s32 secondColumnInTile;
|
||||
s32 thirdColumnInTile;
|
||||
s32 fourthColumnInTile;
|
||||
s32 red;
|
||||
s32 secondBlue;
|
||||
s32 thirdBlue;
|
||||
s32 fourthGreen;
|
||||
s32 green;
|
||||
s32 secondRed;
|
||||
s32 thirdRed;
|
||||
s32 fourthRed;
|
||||
u8* texture;
|
||||
u8* luminance;
|
||||
u8* cb;
|
||||
u8* cr;
|
||||
TMCCJPEGDecState* state;
|
||||
u8* texture;
|
||||
s32 height;
|
||||
s32 column;
|
||||
s32 xEnd;
|
||||
s32 green;
|
||||
s32 yEnd;
|
||||
s32 tileWidth;
|
||||
s32 blueOffset;
|
||||
s32 greenOffset;
|
||||
s32 tileRow;
|
||||
s32 lumaSkip;
|
||||
s8 crValue;
|
||||
s32 chromaSkip;
|
||||
s32 width;
|
||||
s32 cbValue;
|
||||
u8 value;
|
||||
s32 row;
|
||||
u16* output;
|
||||
s32 redOffset;
|
||||
s32 greenOffset;
|
||||
s32 blueOffset;
|
||||
s32 blue;
|
||||
s32 value;
|
||||
TMCCJPEGDecState* state;
|
||||
s32 width;
|
||||
s32 height;
|
||||
s8 crValue;
|
||||
s32 cbValue;
|
||||
|
||||
luminance = work->convBuf + 4;
|
||||
cb = work->convBuf + 260;
|
||||
cr = work->convBuf + 324;
|
||||
cb = &work->convBuf[260];
|
||||
cr = &work->convBuf[324];
|
||||
state = work->pState;
|
||||
tileWidth = (state->convWidth >> 2) << 1;
|
||||
texture = state->pTexBuffer;
|
||||
|
||||
width = 32 / state->scaleFactor;
|
||||
height = 8 / state->scaleFactor;
|
||||
{
|
||||
yEnd = y + height;
|
||||
xEnd = x + width;
|
||||
lumaSkip = 32 - width;
|
||||
chromaSkip = lumaSkip >> 2;
|
||||
for (row = y; row < yEnd; row++) {
|
||||
output = (u16*)(texture + ((row & 3) << 3));
|
||||
tileRow = (row >> 2) * tileWidth;
|
||||
|
||||
for (column = x; column < xEnd; column += 4) {
|
||||
|
||||
{
|
||||
cbValue = (s8)*cb++;
|
||||
crValue = (s8)*cr++;
|
||||
redOffset = (crValue * 359) >> 8;
|
||||
greenOffset = -(crValue * 183 + cbValue * 88) >> 8;
|
||||
blueOffset = (cbValue * 454) >> 8;
|
||||
}
|
||||
{
|
||||
value = *luminance++;
|
||||
green = value + greenOffset;
|
||||
red = value + redOffset;
|
||||
blue = value + blueOffset;
|
||||
if ((red | green | blue) >> 8) {
|
||||
blue = blue > 255 ? 255 : blue < 0 ? 0 : blue;
|
||||
green = green > 255 ? 255 : green < 0 ? 0 : green;
|
||||
red = red > 255 ? 255 : red < 0 ? 0 : red;
|
||||
}
|
||||
red = (u8)red + 0x10000 - 0x100;
|
||||
output[(column & 3) + (((((column) >> 2) << 1) + tileRow) << 4)] = red;
|
||||
output[(column & 3) + (((((column) >> 2) << 1) + tileRow + 1) << 4)] = ((green & 255) << 8) + (blue & 255);
|
||||
}
|
||||
{
|
||||
value = *luminance++;
|
||||
green = value + greenOffset;
|
||||
red = value + redOffset;
|
||||
blue = value + blueOffset;
|
||||
if ((red | green | blue) >> 8) {
|
||||
blue = blue > 255 ? 255 : blue < 0 ? 0 : blue;
|
||||
green = green > 255 ? 255 : green < 0 ? 0 : green;
|
||||
red = red > 255 ? 255 : red < 0 ? 0 : red;
|
||||
}
|
||||
red = (u8)red + 0x10000 - 0x100;
|
||||
output[(column + 1 & 3) + (((((column + 1) >> 2) << 1) + tileRow) << 4)] = red;
|
||||
output[(column + 1 & 3) + (((((column + 1) >> 2) << 1) + tileRow + 1) << 4)] = ((green & 255) << 8) + (blue & 255);
|
||||
}
|
||||
{
|
||||
value = *luminance++;
|
||||
green = value + greenOffset;
|
||||
red = value + redOffset;
|
||||
blue = value + blueOffset;
|
||||
if ((red | green | blue) >> 8) {
|
||||
blue = blue > 255 ? 255 : blue < 0 ? 0 : blue;
|
||||
green = green > 255 ? 255 : green < 0 ? 0 : green;
|
||||
red = red > 255 ? 255 : red < 0 ? 0 : red;
|
||||
}
|
||||
red = (u8)red + 0x10000 - 0x100;
|
||||
output[(column + 2 & 3) + (((((column + 2) >> 2) << 1) + tileRow) << 4)] = red;
|
||||
output[(column + 2 & 3) + (((((column + 2) >> 2) << 1) + tileRow + 1) << 4)] = ((green & 255) << 8) + (blue & 255);
|
||||
}
|
||||
{
|
||||
value = *luminance++;
|
||||
green = value + greenOffset;
|
||||
red = value + redOffset;
|
||||
blue = value + blueOffset;
|
||||
if ((red | green | blue) >> 8) {
|
||||
blue = blue > 255 ? 255 : blue < 0 ? 0 : blue;
|
||||
green = green > 255 ? 255 : green < 0 ? 0 : green;
|
||||
red = red > 255 ? 255 : red < 0 ? 0 : red;
|
||||
}
|
||||
red = (u8)red + 0x10000 - 0x100;
|
||||
output[(column + 3 & 3) + (((((column + 3) >> 2) << 1) + tileRow) << 4)] = red;
|
||||
output[(column + 3 & 3) + (((((column + 3) >> 2) << 1) + tileRow + 1) << 4)] = ((green & 255) << 8) + (blue & 255);
|
||||
}
|
||||
|
||||
xEnd = x + width;
|
||||
yEnd = y + height;
|
||||
for (; y < yEnd; y++) {
|
||||
for (column = x; column < xEnd; column += 4) {
|
||||
cbValue = (s8)*cb++;
|
||||
crValue = (s8)*cr++;
|
||||
redOffset = (crValue * 359) >> 8;
|
||||
greenOffset = -(cbValue * 88 + crValue * 183) >> 8;
|
||||
blueOffset = (cbValue * 454) >> 8;
|
||||
value = *luminance++;
|
||||
green = value + greenOffset;
|
||||
red = value + redOffset;
|
||||
blue = value + blueOffset;
|
||||
if ((red | green | blue) >> 8) {
|
||||
blue = blue > 255 ? 255 : blue < 0 ? 0 : blue;
|
||||
green = green > 255 ? 255 : green < 0 ? 0 : green;
|
||||
red = red > 255 ? 255 : red < 0 ? 0 : red;
|
||||
}
|
||||
luminance += lumaSkip;
|
||||
cb += chromaSkip;
|
||||
cr += chromaSkip;
|
||||
columnInTile = column & 3;
|
||||
(output = (u16*)(texture + ((y & 3) << 3)))[
|
||||
columnInTile + ((((column >> 2) << 1) +
|
||||
(tileRow = (y >> 2) * tileWidth)) << 4)] = (u8)red + 0x10000 - 0x100;
|
||||
output[columnInTile + ((((column >> 2) << 1) + (tileRow + 1)) << 4)] = ((green & 255) << 8) + (blue & 255);
|
||||
value = *luminance++;
|
||||
secondGreen = value + greenOffset;
|
||||
secondRed = value + redOffset;
|
||||
secondBlue = value + blueOffset;
|
||||
if ((secondRed | secondGreen | secondBlue) >> 8) {
|
||||
secondBlue = secondBlue > 255 ? 255 : secondBlue < 0 ? 0 : secondBlue;
|
||||
secondGreen = secondGreen > 255 ? 255 : secondGreen < 0 ? 0 : secondGreen;
|
||||
secondRed = secondRed > 255 ? 255 : secondRed < 0 ? 0 : secondRed;
|
||||
}
|
||||
secondColumnInTile = (column + 1) & 3;
|
||||
output[secondColumnInTile + (((((column + 1) >> 2) << 1) + tileRow) << 4)] = (u8)secondRed + 0x10000 - 0x100;
|
||||
output[secondColumnInTile + (((((column + 1) >> 2) << 1) + (tileRow + 1)) << 4)] = ((secondGreen & 255) << 8) + (secondBlue & 255);
|
||||
value = *luminance++;
|
||||
thirdGreen = value + greenOffset;
|
||||
thirdRed = value + redOffset;
|
||||
thirdBlue = value + blueOffset;
|
||||
if ((thirdRed | thirdGreen | thirdBlue) >> 8) {
|
||||
thirdBlue = thirdBlue > 255 ? 255 : thirdBlue < 0 ? 0 : thirdBlue;
|
||||
thirdGreen = thirdGreen > 255 ? 255 : thirdGreen < 0 ? 0 : thirdGreen;
|
||||
thirdRed = thirdRed > 255 ? 255 : thirdRed < 0 ? 0 : thirdRed;
|
||||
}
|
||||
thirdColumnInTile = (column + 2) & 3;
|
||||
output[thirdColumnInTile + (((((column + 2) >> 2) << 1) + tileRow) << 4)] = (u8)thirdRed + 0x10000 - 0x100;
|
||||
output[thirdColumnInTile + (((((column + 2) >> 2) << 1) + (tileRow + 1)) << 4)] = ((thirdGreen & 255) << 8) + (thirdBlue & 255);
|
||||
value = *luminance++;
|
||||
fourthGreen = value + greenOffset;
|
||||
fourthRed = value + redOffset;
|
||||
fourthBlue = value + blueOffset;
|
||||
if ((fourthRed | fourthGreen | fourthBlue) >> 8) {
|
||||
fourthBlue = fourthBlue > 255 ? 255 : fourthBlue < 0 ? 0 : fourthBlue;
|
||||
fourthGreen = fourthGreen > 255 ? 255 : fourthGreen < 0 ? 0 : fourthGreen;
|
||||
fourthRed = fourthRed > 255 ? 255 : fourthRed < 0 ? 0 : fourthRed;
|
||||
}
|
||||
fourthColumnInTile = (column + 3) & 3;
|
||||
output[fourthColumnInTile + (((((column + 3) >> 2) << 1) + tileRow) << 4)] = (u8)fourthRed + 0x10000 - 0x100;
|
||||
output[fourthColumnInTile + (((((column + 3) >> 2) << 1) + (tileRow + 1)) << 4)] = ((fourthGreen & 255) << 8) + (fourthBlue & 255);
|
||||
}
|
||||
luminance += (32 - width);
|
||||
cb += ((32 - width) >> 2);
|
||||
cr += ((32 - width) >> 2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,37 @@ static void TMCJPEG_814F32E4(TMCCJPEGDecWork*, s32, s32);
|
||||
static void TMCJPEG_814F34A4(TMCCJPEGDecWork*, s32, s32);
|
||||
static void TMCJPEG_814F372C(TMCCJPEGDecWork*, s32, s32);
|
||||
|
||||
#pragma push
|
||||
#pragma optimization_level 1
|
||||
s32 TMCJPEGDEC_set_converterY8U8V8(TMCCJPEGDecWork* work) {
|
||||
u8 mode411;
|
||||
u8* crBlock411;
|
||||
u8* cbBlock411;
|
||||
u8* fourthRow411;
|
||||
u8* thirdRow411;
|
||||
u8* secondRow411;
|
||||
u8* firstRow411;
|
||||
TMCConverterFunc* edgeConverter411;
|
||||
TMCConverterFunc* converter411;
|
||||
|
||||
u8 mode422;
|
||||
u8* crBlock422;
|
||||
u8* cbBlock422;
|
||||
u8* secondRow422;
|
||||
u8* firstRow422;
|
||||
TMCConverterFunc* edgeConverter422;
|
||||
TMCConverterFunc* converter422;
|
||||
|
||||
u8 mode420;
|
||||
u8* crBlock420;
|
||||
u8* cbBlock420;
|
||||
u8* fourthRow420;
|
||||
u8* thirdRow420;
|
||||
u8* secondRow420;
|
||||
u8* firstRow420;
|
||||
TMCConverterFunc* edgeConverter420;
|
||||
TMCConverterFunc* converter420;
|
||||
|
||||
u8* buffer;
|
||||
s32 componentCount;
|
||||
TMCCJPEGDecState* state;
|
||||
@@ -25,97 +55,84 @@ s32 TMCJPEGDEC_set_converterY8U8V8(TMCCJPEGDecWork* work) {
|
||||
|
||||
switch (componentCount) {
|
||||
case 0: {
|
||||
u8 mode;
|
||||
u8* firstRow;
|
||||
u8* secondRow;
|
||||
u8* thirdRow;
|
||||
u8* fourthRow;
|
||||
u8* cbBlock;
|
||||
u8* crBlock;
|
||||
|
||||
mode = work->idctMode;
|
||||
firstRow = buffer + 4;
|
||||
work->pConverterFunc = TMCJPEG_814EFEAC;
|
||||
work->pConverterFuncEdge = TMCJPEG_814F043C;
|
||||
secondRow = firstRow + mode;
|
||||
thirdRow = secondRow + mode;
|
||||
fourthRow = thirdRow + mode;
|
||||
cbBlock = buffer + 260;
|
||||
crBlock = buffer + 324;
|
||||
work->pConvRowPtrs[0] = firstRow;
|
||||
work->pConvRowPtrs[1] = secondRow;
|
||||
work->pConvRowPtrs[2] = thirdRow;
|
||||
work->pConvRowPtrs[3] = fourthRow;
|
||||
work->pConvRowPtrs[5] = cbBlock;
|
||||
work->pConvRowPtrs[6] = crBlock;
|
||||
mode411 = work->idctMode;
|
||||
firstRow411 = buffer + 4;
|
||||
converter411 = TMCJPEG_814EFEAC;
|
||||
edgeConverter411 = TMCJPEG_814F043C;
|
||||
secondRow411 = firstRow411 + mode411;
|
||||
thirdRow411 = secondRow411 + mode411;
|
||||
fourthRow411 = thirdRow411 + mode411;
|
||||
cbBlock411 = buffer + 260;
|
||||
crBlock411 = buffer + 324;
|
||||
work->pConverterFunc = converter411;
|
||||
work->pConverterFuncEdge = edgeConverter411;
|
||||
work->pConvRowPtrs[0] = firstRow411;
|
||||
work->pConvRowPtrs[1] = secondRow411;
|
||||
work->pConvRowPtrs[2] = thirdRow411;
|
||||
work->pConvRowPtrs[3] = fourthRow411;
|
||||
work->pConvRowPtrs[5] = cbBlock411;
|
||||
work->pConvRowPtrs[6] = crBlock411;
|
||||
work->pitch = 32;
|
||||
work->converterFlags = 0;
|
||||
break;
|
||||
}
|
||||
case 1: {
|
||||
u8 mode;
|
||||
u8* firstRow;
|
||||
u8* secondRow;
|
||||
u8* cbBlock;
|
||||
u8* crBlock;
|
||||
|
||||
mode = work->idctMode;
|
||||
firstRow = buffer + 4;
|
||||
work->pConverterFunc = TMCJPEG_814F0A58;
|
||||
work->pConverterFuncEdge = TMCJPEG_814F11C4;
|
||||
secondRow = firstRow + mode;
|
||||
cbBlock = buffer + 132;
|
||||
crBlock = buffer + 196;
|
||||
work->pConvRowPtrs[0] = firstRow;
|
||||
work->pConvRowPtrs[1] = secondRow;
|
||||
work->pConvRowPtrs[5] = cbBlock;
|
||||
work->pConvRowPtrs[6] = crBlock;
|
||||
mode422 = work->idctMode;
|
||||
firstRow422 = buffer + 4;
|
||||
converter422 = TMCJPEG_814F0A58;
|
||||
edgeConverter422 = TMCJPEG_814F11C4;
|
||||
secondRow422 = firstRow422 + mode422;
|
||||
cbBlock422 = buffer + 132;
|
||||
crBlock422 = buffer + 196;
|
||||
work->pConverterFunc = converter422;
|
||||
work->pConverterFuncEdge = edgeConverter422;
|
||||
work->pConvRowPtrs[0] = firstRow422;
|
||||
work->pConvRowPtrs[1] = secondRow422;
|
||||
work->pConvRowPtrs[5] = cbBlock422;
|
||||
work->pConvRowPtrs[6] = crBlock422;
|
||||
work->pitch = 16;
|
||||
work->converterFlags = 0;
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
u8 mode;
|
||||
u8* firstRow;
|
||||
u8* secondRow;
|
||||
u8* thirdRow;
|
||||
u8* fourthRow;
|
||||
u8* cbBlock;
|
||||
u8* crBlock;
|
||||
|
||||
mode = work->idctMode;
|
||||
firstRow = buffer + 4;
|
||||
work->pConverterFunc = TMCJPEG_814F17E0;
|
||||
work->pConverterFuncEdge = TMCJPEG_814F1F48;
|
||||
secondRow = firstRow + mode;
|
||||
thirdRow = firstRow + mode * 16;
|
||||
fourthRow = thirdRow + mode;
|
||||
cbBlock = buffer + 260;
|
||||
crBlock = buffer + 324;
|
||||
work->pConvRowPtrs[0] = firstRow;
|
||||
work->pConvRowPtrs[1] = secondRow;
|
||||
work->pConvRowPtrs[2] = thirdRow;
|
||||
work->pConvRowPtrs[3] = fourthRow;
|
||||
work->pConvRowPtrs[5] = cbBlock;
|
||||
work->pConvRowPtrs[6] = crBlock;
|
||||
mode420 = work->idctMode;
|
||||
firstRow420 = buffer + 4;
|
||||
converter420 = TMCJPEG_814F17E0;
|
||||
edgeConverter420 = TMCJPEG_814F1F48;
|
||||
secondRow420 = firstRow420 + mode420;
|
||||
thirdRow420 = firstRow420 + mode420 * 16;
|
||||
fourthRow420 = thirdRow420 + mode420;
|
||||
cbBlock420 = buffer + 260;
|
||||
crBlock420 = buffer + 324;
|
||||
work->pConverterFunc = converter420;
|
||||
work->pConverterFuncEdge = edgeConverter420;
|
||||
work->pConvRowPtrs[0] = firstRow420;
|
||||
work->pConvRowPtrs[1] = secondRow420;
|
||||
work->pConvRowPtrs[2] = thirdRow420;
|
||||
work->pConvRowPtrs[3] = fourthRow420;
|
||||
work->pConvRowPtrs[5] = cbBlock420;
|
||||
work->pConvRowPtrs[6] = crBlock420;
|
||||
work->pitch = 16;
|
||||
work->converterFlags = 0;
|
||||
break;
|
||||
}
|
||||
case 3: {
|
||||
u8 mode;
|
||||
u8* firstRow;
|
||||
u8* secondRow;
|
||||
u8* cbBlock;
|
||||
u32 mode;
|
||||
u8* crBlock;
|
||||
|
||||
u8* cbBlock;
|
||||
u8* secondRow;
|
||||
u8* firstRow;
|
||||
TMCConverterFunc* edgeConverter;
|
||||
TMCConverterFunc* converter;
|
||||
mode = work->idctMode;
|
||||
firstRow = buffer + 4;
|
||||
work->pConverterFunc = TMCJPEG_814F2570;
|
||||
work->pConverterFuncEdge = TMCJPEG_814F2B50;
|
||||
converter = TMCJPEG_814F2570;
|
||||
edgeConverter = TMCJPEG_814F2B50;
|
||||
secondRow = firstRow + mode * 8;
|
||||
cbBlock = buffer + 132;
|
||||
crBlock = buffer + 196;
|
||||
work->pConverterFunc = converter;
|
||||
work->pConverterFuncEdge = edgeConverter;
|
||||
work->pConvRowPtrs[0] = firstRow;
|
||||
work->pConvRowPtrs[1] = secondRow;
|
||||
work->pConvRowPtrs[5] = cbBlock;
|
||||
@@ -125,27 +142,27 @@ s32 TMCJPEGDEC_set_converterY8U8V8(TMCCJPEGDecWork* work) {
|
||||
break;
|
||||
}
|
||||
case 4: {
|
||||
TMCConverterFunc* converter;
|
||||
TMCConverterFunc* edgeConverter;
|
||||
TMCConverterFunc* converter;
|
||||
converter = TMCJPEG_814F3158;
|
||||
edgeConverter = TMCJPEG_814F32E4;
|
||||
work->pConverterFunc = converter;
|
||||
work->pConverterFuncEdge = edgeConverter;
|
||||
work->pConvRowPtrs[0] = buffer + 4;
|
||||
work->pConvRowPtrs[5] = buffer + 0x44;
|
||||
work->pConvRowPtrs[6] = buffer + 0x84;
|
||||
work->pConverterFunc = converter;
|
||||
work->pConverterFuncEdge = edgeConverter;
|
||||
work->pitch = 0x08;
|
||||
work->converterFlags = 0;
|
||||
break;
|
||||
}
|
||||
case 5: {
|
||||
TMCConverterFunc* converter;
|
||||
TMCConverterFunc* edgeConverter;
|
||||
TMCConverterFunc* converter;
|
||||
converter = TMCJPEG_814F34A4;
|
||||
edgeConverter = TMCJPEG_814F372C;
|
||||
work->pConvRowPtrs[0] = buffer + 4;
|
||||
work->pConverterFunc = converter;
|
||||
work->pConverterFuncEdge = edgeConverter;
|
||||
work->pConvRowPtrs[0] = buffer + 4;
|
||||
work->pitch = 0x08;
|
||||
work->converterFlags = 0;
|
||||
break;
|
||||
@@ -158,16 +175,25 @@ s32 TMCJPEGDEC_set_converterY8U8V8(TMCCJPEGDecWork* work) {
|
||||
{
|
||||
s32 width = state->jpegWidth;
|
||||
s32 height = state->jpegHeight;
|
||||
state->convWidth = ((u32)width / 8 + (width % 8 != 0)) * 8;
|
||||
state->convHeight = ((u32)height / 4 + (height % 4 != 0)) * 4;
|
||||
s32 roundedWidth;
|
||||
s32 heightPadding;
|
||||
|
||||
roundedWidth = (u32)width / 8 + (width % 8 != 0);
|
||||
heightPadding = height % 4 != 0;
|
||||
state->convWidth = roundedWidth * 8;
|
||||
state->convHeight = ((u32)height / 4 + heightPadding) * 4;
|
||||
width = state->outputWidth;
|
||||
height = state->outputHeight;
|
||||
state->chromaWidth = ((u32)width / 8 + (width % 8 != 0)) * 8;
|
||||
state->chromaHeight = ((u32)height / 4 + (height % 4 != 0)) * 4;
|
||||
roundedWidth = (u32)width / 8 + (width % 8 != 0);
|
||||
heightPadding = height % 4 != 0;
|
||||
state->chromaWidth = roundedWidth * 8;
|
||||
state->chromaHeight = ((u32)height / 4 + heightPadding) * 4;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#pragma pop
|
||||
|
||||
static void TMCJPEG_814EFEAC(TMCCJPEGDecWork* work, s32 x, s32 y) {
|
||||
s32 rowSkip;
|
||||
u8* output;
|
||||
|
||||
@@ -295,7 +295,7 @@ void Zi8ChangeWordCase(ziWChar* word, ziU8 language, ZiAlphaWork* work) {
|
||||
while (*word != 0) Zi8ChangeCharCase(upper, word++, language, work);
|
||||
}
|
||||
|
||||
ziU32 Zi8DeTokenization(ziWChar* word, ziU32 length, ziU16 capacity, ziU16 language);
|
||||
ziU16 Zi8DeTokenization(ziWChar* word, ziU16 length, ziU16 capacity, ziU16 language);
|
||||
ziU32 Zi8GetTableAddress(ziU8 language, ziU8 table, ziPtr work);
|
||||
ziU16 Zi8GetTableCount(ziU8 language, ziU8 table, ziPtr work);
|
||||
void Zi8InitDupWordBuf(ziPtr work);
|
||||
@@ -306,7 +306,7 @@ ziU8 Zi8MatchOEMdata(ziWChar* elements, ziU8 count, ziU8 language, ziWChar* word
|
||||
ziU8 Zi8MatchPUDdata(ziWChar* elements, ziU8 count, ziU8 language, ziWChar* word, ziU16 capacity, ziU8 mode, ziU8 status, ziPtr work);
|
||||
ziU8 Zi8MatchROMdata(ziWChar* elements, ziU8 count, ziU8 language, ziWChar* word, ziU16 capacity, ziU8 mode, ziU8 status, ziBool reservedMode, ziBool exactLength, ziPtr work);
|
||||
ziU8 Zi8MatchUWDdata(ziWChar* elements, ziU8 count, ziWChar* currentWord, ziU16 currentLength, ziU8 language, ziWChar* word, ziU16 capacity, ziU8 mode, ziU8 status, ziPtr work);
|
||||
void Zi8Memset(ziPtr destination, ziU32 value, ziU32 count);
|
||||
ziPtr Zi8Memset(ziPtr destination, ziU32 value, ziS32 count);
|
||||
ziU16 Zi8WCharCount(ziWChar* word, ziPtr work);
|
||||
ziBool Zi8ZHCheckSpelling(ziWChar* word, ziWChar* elements, ziU8 count, ziPtr work);
|
||||
ziU8 Zi8getKeyLayout(ziU8 language, ziWChar key, ziWChar* characters, ziU8 capacity, ziPtr work);
|
||||
@@ -550,7 +550,6 @@ int Zi8AlphaGetCandidates(ziGetParam* parameters, ziPtr optionData, ziPtr workDa
|
||||
secondaryCompletionAllowed = 0;
|
||||
}
|
||||
Zi8InitDupWordBuf(workData);
|
||||
dictionaryIndex = 0;
|
||||
if ((((((ZiAlphaOptions*)optionData)->lookupMode == '\0') && (!phoneticInput)) && (!phoneticSeparator)) &&
|
||||
((((parameters->getOptions & 0xfd) != 0x80 && (parameters->elementCount != 0)) &&
|
||||
((parameters->elements[parameters->elementCount - 1] != 0xEFF1 &&
|
||||
@@ -559,8 +558,7 @@ int Zi8AlphaGetCandidates(ziGetParam* parameters, ziPtr optionData, ziPtr workDa
|
||||
if (((ZiAlphaWork*)workData)->highlightedWord[elementIndex] != parameters->elements[elementIndex]) break;
|
||||
wordCursor[elementIndex] = ((ZiAlphaWork*)workData)->highlightedWord[elementIndex];
|
||||
}
|
||||
wordCursor[elementIndex] = parameters->elements[elementIndex];
|
||||
elementIndex++;
|
||||
wordCursor[elementIndex++] = parameters->elements[elementIndex];
|
||||
if (parameters->elementCount == 1) ((ZiAlphaWork*)workData)->singleCharacter = *wordCursor;
|
||||
if (elementIndex == parameters->elementCount &&
|
||||
(firstCandidate == 0 || ((ZiAlphaWork*)workData)->reuseHighlightedWord != 0)) {
|
||||
@@ -654,7 +652,7 @@ foundHighlightedDictionary:
|
||||
}
|
||||
goto prepareDictionaryOrder;
|
||||
preparePrefix:
|
||||
prefixMode = ((ZiAlphaWork*)workData)->suffixMode;
|
||||
prefixMode = (ziU8)((ZiAlphaWork*)workData)->suffixMode;
|
||||
prefixTableFlags = Zi8GetTableCount(language,0x1f,workData);
|
||||
prefixVowelFlags = prefixTableFlags & 0x10;
|
||||
if (((((language == 0x3f) || (language == 4)) ||
|
||||
@@ -900,19 +898,19 @@ selectDictionary:
|
||||
}
|
||||
else {
|
||||
if (alternateSingleCharacter != 2) {
|
||||
wordLength = Zi8MatchROMdata(elements,elementCount & 0xff,language,wordCursor,
|
||||
wordCapacity & 0xffff,matchMode,
|
||||
dictionaryStatus[dictionaryKind] & 0xff,0,exactLengthOnly,workData);
|
||||
wordLength = Zi8MatchROMdata(elements,elementCount,language,wordCursor,
|
||||
wordCapacity,matchMode,
|
||||
dictionaryStatus[dictionaryKind],0,exactLengthOnly,workData);
|
||||
}
|
||||
if ((alternateSingleCharacter != 0) && ((wordLength == 0 || (*wordCursor == *elements)))) {
|
||||
if (alternateSingleCharacter == 1) {
|
||||
alternateSingleCharacter = 2;
|
||||
wordLength = Zi8MatchROMdata(elements,elementCount & 0xff,parameters->subLanguage,wordCursor,
|
||||
wordCapacity & 0xffff,1,0,0,exactLengthOnly,workData);
|
||||
wordLength = Zi8MatchROMdata(elements,elementCount,parameters->subLanguage,wordCursor,
|
||||
wordCapacity,1,0,0,exactLengthOnly,workData);
|
||||
}
|
||||
else {
|
||||
wordLength = Zi8MatchROMdata(elements,elementCount & 0xff,parameters->subLanguage,wordCursor,
|
||||
wordCapacity & 0xffff,1,1,0,exactLengthOnly,workData);
|
||||
wordLength = Zi8MatchROMdata(elements,elementCount,parameters->subLanguage,wordCursor,
|
||||
wordCapacity,1,1,0,exactLengthOnly,workData);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -922,27 +920,24 @@ selectDictionary:
|
||||
if ((((wordLength == 0) && (*punctuationCursor != 0)) && (dictionaryExact != 0)) &&
|
||||
((((ZiAlphaWork*)workData)->singleCharacter != 0 && (parameters->elementCount == 2)))) {
|
||||
*wordCursor = ((ZiAlphaWork*)workData)->singleCharacter;
|
||||
wordCursor[2] = 0;
|
||||
wordCursor[1] = *punctuationCursor++;
|
||||
wordCursor[2] = 0;
|
||||
wordLength = 2;
|
||||
}
|
||||
if (((apostropheIndex != 0) && (wordLength != 0)) && (elementCount == parameters->elementCount)) {
|
||||
if (language == 0x2f) {
|
||||
index = Zi8ITspecialExclusion
|
||||
(wordCursor + apostropheIndex,apostropheIndex,wordLength - apostropheIndex);
|
||||
if (index != '\0') {
|
||||
if (Zi8ITspecialExclusion
|
||||
(wordCursor + apostropheIndex,apostropheIndex,wordLength - apostropheIndex) != 0) {
|
||||
wordLength = 0;
|
||||
}
|
||||
}
|
||||
else if (language == 0x58) {
|
||||
index = Zi8_814659E8(wordCursor + apostropheIndex,apostropheIndex,wordLength - apostropheIndex);
|
||||
if (index != '\0') {
|
||||
if (Zi8_814659E8(wordCursor + apostropheIndex,apostropheIndex,wordLength - apostropheIndex) != 0) {
|
||||
wordLength = 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
index = Zi8IsVowel(language,wordCursor[apostropheIndex]);
|
||||
if (index == '\0') {
|
||||
if (Zi8IsVowel(language,wordCursor[apostropheIndex]) == 0) {
|
||||
wordLength = 0;
|
||||
}
|
||||
}
|
||||
@@ -961,20 +956,17 @@ filterVowelCandidate:
|
||||
goto finishDictionaryPass;
|
||||
}
|
||||
if (language == 0x2f) {
|
||||
index = Zi8ITspecialExclusion(wordCursor,prefixCount,wordLength);
|
||||
if (index != '\0') {
|
||||
if (Zi8ITspecialExclusion(wordCursor,prefixCount,wordLength) != 0) {
|
||||
wordLength = 0;
|
||||
}
|
||||
}
|
||||
else if (language == 0x58) {
|
||||
index = Zi8_814659E8(wordCursor,prefixCount,wordLength);
|
||||
if (index != '\0') {
|
||||
if (Zi8_814659E8(wordCursor,prefixCount,wordLength) != 0) {
|
||||
wordLength = 0;
|
||||
}
|
||||
}
|
||||
else {
|
||||
index = Zi8IsVowel(language,*wordCursor);
|
||||
if (index == '\0') {
|
||||
if (Zi8IsVowel(language,*wordCursor) == 0) {
|
||||
wordLength = 0;
|
||||
}
|
||||
}
|
||||
@@ -998,9 +990,9 @@ filterVowelCandidate:
|
||||
case 2:
|
||||
case 6:
|
||||
if (elementCount != 0) {
|
||||
wordLength = Zi8MatchPUDdata(elements,elementCount & 0xff,language,wordCursor,
|
||||
wordCapacity & 0xffff,dictionaryExact,
|
||||
dictionaryStatus[dictionaryKind] & 0xff,workData);
|
||||
wordLength = Zi8MatchPUDdata(elements,elementCount,language,wordCursor,
|
||||
wordCapacity,dictionaryExact,
|
||||
dictionaryStatus[dictionaryKind],workData);
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
@@ -1008,8 +1000,8 @@ filterVowelCandidate:
|
||||
while( ZI8_TRUE ) {
|
||||
wordLength = Zi8MatchUWDdata(elements,elementCount,
|
||||
parameters->currentWord,parameters->wordCharCount,
|
||||
language,wordCursor,wordCapacity & 0xffff,dictionaryExact,
|
||||
dictionaryStatus[dictionaryKind] & 0xff,workData);
|
||||
language,wordCursor,wordCapacity,dictionaryExact,
|
||||
dictionaryStatus[dictionaryKind],workData);
|
||||
if (((elementCount != 0) || (wordLength != 1)) || (*wordCursor != 0x20)) break;
|
||||
dictionaryStatus[dictionaryKind] = 1;
|
||||
}
|
||||
@@ -1019,7 +1011,7 @@ filterVowelCandidate:
|
||||
if (elementCount != 0) {
|
||||
wordLength = Zi8MatchOEMdata(elements,elementCount,language,wordCursor,
|
||||
wordCapacity,dictionaryExact,
|
||||
dictionaryStatus[dictionaryKind] & 0xff,workData);
|
||||
dictionaryStatus[dictionaryKind],workData);
|
||||
}
|
||||
break;
|
||||
case 10:
|
||||
@@ -1074,8 +1066,12 @@ filterVowelCandidate:
|
||||
(((ZiAlphaOptions*)optionData)->lookupMode == '\0')) &&
|
||||
(((ZiAlphaWork*)workData)->dictionaries[language] == 0)))))) {
|
||||
if (language != ((ZiAlphaWork*)workData)->language) break;
|
||||
index = ((ZiAlphaWork*)workData)->dictionaryKinds[dictionaryIndex + 1];
|
||||
if (index == 0xc || (index < 9 && index >= 5)) {
|
||||
switch (((ZiAlphaWork*)workData)->dictionaryKinds[dictionaryIndex + 1]) {
|
||||
case 5:
|
||||
case 6:
|
||||
case 7:
|
||||
case 8:
|
||||
case 12:
|
||||
if (Zi8getKeyLayout(language,0xeff1,&punctuationBuffer[0],1,workData) == 0) {
|
||||
punctuationBuffer[0] = 0;
|
||||
}
|
||||
@@ -1094,8 +1090,17 @@ filterVowelCandidate:
|
||||
(((((ZiAlphaWork*)workData)->rememberedWord[0] == 0 || (((ZiAlphaOptions*)optionData)->lookupMode != '\0')) ||
|
||||
(((ZiAlphaWork*)workData)->dictionaries[language] != 0)))))) ||
|
||||
(languagePassCount == 2)))) break;
|
||||
index = ((ZiAlphaWork*)workData)->dictionaryKinds[dictionaryIndex + 1];
|
||||
if ((index != 0xc) && (((0xb < index || (8 < index)) || (index < 5)))) break;
|
||||
switch (((ZiAlphaWork*)workData)->dictionaryKinds[dictionaryIndex + 1]) {
|
||||
case 5:
|
||||
case 6:
|
||||
case 7:
|
||||
case 8:
|
||||
case 12:
|
||||
goto prepareRememberedPunctuation;
|
||||
default:
|
||||
goto finishDictionaryPass;
|
||||
}
|
||||
prepareRememberedPunctuation:
|
||||
if (Zi8getKeyLayout(language,0xeff1,&punctuationBuffer[0],1,workData) == 0) {
|
||||
punctuationBuffer[0] = 0;
|
||||
}
|
||||
@@ -1127,8 +1132,8 @@ prepareCandidate:
|
||||
wordLength = elementCount;
|
||||
wordCursor[wordLength] = 0;
|
||||
}
|
||||
wordLength = (ziU16)Zi8DeTokenization(wordCursor,wordLength & 0xffff,wordCapacity & 0xffff,language);
|
||||
if (((phoneticInput) && ((unsigned int)parameters->elementCount < (wordLength & 0xff))) &&
|
||||
wordLength = Zi8DeTokenization(wordCursor,wordLength,wordCapacity,language);
|
||||
if (((phoneticInput) && ((ziU8)parameters->elementCount < (wordLength & 0xffU))) &&
|
||||
((wordCursor[wordLength - 1] == 0xf360 || (wordCursor[wordLength - 1] == 0x27)))) {
|
||||
wordLength = wordLength - 1;
|
||||
wordCursor[wordLength] = 0;
|
||||
@@ -1145,7 +1150,7 @@ prepareCandidate:
|
||||
wordCursor[wordLength] = 0;
|
||||
}
|
||||
if (((int)((ZiAlphaOptions*)optionData)->maxWordLength < (int)(wordLength + prefixCount)) ||
|
||||
((Zi8IsDupWordW(wordCursor - prefixCount,wordLength + prefixCount & 0xff,
|
||||
((Zi8IsDupWordW(wordCursor - prefixCount,wordLength + prefixCount,
|
||||
workData)) != '\0')) {
|
||||
if ((prefixCount != 0) && (((ZiAlphaOptions*)optionData)->maxWordLength <= prefixCount)) break;
|
||||
}
|
||||
@@ -1163,7 +1168,7 @@ checkKeyLayout:
|
||||
candidateCharacterCount = wordLength + prefixCount;
|
||||
for (index = 0; (int)index < (int)(unsigned int)keyLayoutCount; index = index + 1) {
|
||||
if (*keyLayoutCursor < candidateCharacterCount) {
|
||||
keyLayoutCursor = keyLayoutCursor + *keyLayoutCursor + 1;
|
||||
keyLayoutCursor += *keyLayoutCursor + 1;
|
||||
} else {
|
||||
if (*keyLayoutCursor++ > candidateCharacterCount) {
|
||||
index = (unsigned int)keyLayoutCount;
|
||||
@@ -1541,8 +1546,7 @@ checkPrefixPunctuation:
|
||||
((ZiAlphaWork*)workData)->letterHyphen = 0x2e;
|
||||
}
|
||||
if (elements[((ZiAlphaWork*)workData)->prefixCount] != 0xEFF1 && Zi8IsAlphaPunct(elements[((ZiAlphaWork*)workData)->prefixCount]) != 0) {
|
||||
((ZiAlphaWork*)workData)->prefix[((ZiAlphaWork*)workData)->prefixCount] = elements[((ZiAlphaWork*)workData)->prefixCount];
|
||||
((ZiAlphaWork*)workData)->prefixCount++;
|
||||
((ZiAlphaWork*)workData)->prefix[((ZiAlphaWork*)workData)->prefixCount++] = elements[((ZiAlphaWork*)workData)->prefixCount];
|
||||
} else {
|
||||
((ZiAlphaWork*)workData)->prefix[((ZiAlphaWork*)workData)->prefixCount++] = ((ZiAlphaWork*)workData)->letterHyphen;
|
||||
}
|
||||
@@ -1637,7 +1641,7 @@ finishCandidates:
|
||||
|
||||
|
||||
|
||||
ziU32 Zi8DeTokenization(ziWChar* word, ziU32 length, ziU16 capacity, ziU16 language) {
|
||||
ziU16 Zi8DeTokenization(ziWChar* word, ziU16 length, ziU16 capacity, ziU16 language) {
|
||||
ziU16 index;
|
||||
ziBool changed = ZI8_FALSE;
|
||||
ziU16 outputCount = 0;
|
||||
|
||||
@@ -113,18 +113,16 @@ ziU32 Zi8SecMatchChar(ziU8* nodeAddress, ziU8* dictionaryAddress, ziMatchParam*
|
||||
ziU16 matchCode;
|
||||
ziU8* data;
|
||||
ziU8 value;
|
||||
struct {
|
||||
ziU8 remaining;
|
||||
ziU8 dataIndex;
|
||||
ziU16 targetCode;
|
||||
} state;
|
||||
ziU16 targetCode;
|
||||
ziU8 dataIndex;
|
||||
ziU8 remaining;
|
||||
|
||||
if (match->componentIndex != 0) {
|
||||
state.targetCode = match->componentIndex;
|
||||
targetCode = match->componentIndex;
|
||||
matchCode = ((ziU16)(nodeAddress[4] & 3) << 8) | nodeAddress[5];
|
||||
value = 0;
|
||||
while (value++ < 6) {
|
||||
if (state.targetCode == matchCode) {
|
||||
if (targetCode == matchCode) {
|
||||
break;
|
||||
}
|
||||
matchCode = ((ziU16)(*(dictionaryAddress + matchCode * 8 + 6) & 3) << 8) | *(dictionaryAddress + matchCode * 8 + 7);
|
||||
@@ -132,7 +130,7 @@ ziU32 Zi8SecMatchChar(ziU8* nodeAddress, ziU8* dictionaryAddress, ziMatchParam*
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (state.targetCode != matchCode) {
|
||||
if (targetCode != matchCode) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -206,9 +204,9 @@ ziU32 Zi8SecMatchChar(ziU8* nodeAddress, ziU8* dictionaryAddress, ziMatchParam*
|
||||
}
|
||||
}
|
||||
|
||||
state.dataIndex = 4;
|
||||
state.remaining = ((match->length + 1) >> 1) - 4;
|
||||
if ((value + 1) < state.remaining) {
|
||||
dataIndex = 4;
|
||||
remaining = ((match->length + 1) >> 1) - 4;
|
||||
if ((value + 1) < remaining) {
|
||||
return 0;
|
||||
}
|
||||
if ((match->length & 1) != 0) {
|
||||
@@ -221,12 +219,12 @@ ziU32 Zi8SecMatchChar(ziU8* nodeAddress, ziU8* dictionaryAddress, ziMatchParam*
|
||||
}
|
||||
}
|
||||
if (match->count == 0) {
|
||||
while (state.remaining != 0) {
|
||||
if ((data[0] & match->recordMasks[state.dataIndex]) != match->recordValues[state.dataIndex]) {
|
||||
while (remaining != 0) {
|
||||
if ((data[0] & match->recordMasks[dataIndex]) != match->recordValues[dataIndex]) {
|
||||
return 0;
|
||||
}
|
||||
state.dataIndex++;
|
||||
state.remaining--;
|
||||
dataIndex++;
|
||||
remaining--;
|
||||
data++;
|
||||
}
|
||||
}
|
||||
@@ -290,17 +288,15 @@ extern ziU16 Zi8MatchAltSound(ziPtr soundTable, ziU16 soundCode, ziPtr pCodeTabl
|
||||
ziU16 Zi8GetPCode(ziU8* table, ziU8* node);
|
||||
|
||||
ziBool Zi8MatchPhonetic(ziU8* pCodeTable, ziU8* dictionary, ziPtr soundTable, ziU16 soundCode, ziU32 tableAddress, ziU8* node, ziU16* masks, ziU16* values, ziU16* count, ziU8** resultNode, ziU8** stringOffset, ziU8 partialMode, ziU8 strictMode, ziU8 numParts, ziU16 partMask, ziU16 partValue, ziU8 flag, ziU8 altMode, ziU16 initialCode, ziU16* resultCode, ziU8 lastMode ZI_NEED_WORK) {
|
||||
struct {
|
||||
ziBool hasString;
|
||||
ziU8 partIndex;
|
||||
ziU8 partCount;
|
||||
ziU8 nextCode;
|
||||
ziU8 matchedParts;
|
||||
ziU16 dictionaryIndex;
|
||||
ziU16 soundIndex;
|
||||
ziU16 remaining;
|
||||
ziU16 code;
|
||||
} traversal;
|
||||
ziU16 code;
|
||||
ziU16 remaining;
|
||||
ziU16 soundIndex;
|
||||
ziU16 dictionaryIndex;
|
||||
ziU8 matchedParts;
|
||||
ziU8 nextCode;
|
||||
ziU8 partCount;
|
||||
ziU8 partIndex;
|
||||
ziBool hasString;
|
||||
ziU8* sound;
|
||||
typedef struct {
|
||||
ziU8 header;
|
||||
@@ -308,42 +304,42 @@ ziBool Zi8MatchPhonetic(ziU8* pCodeTable, ziU8* dictionary, ziPtr soundTable, zi
|
||||
} DictionaryNode;
|
||||
|
||||
if (*stringOffset != 0) {
|
||||
traversal.hasString = 1;
|
||||
hasString = 1;
|
||||
} else {
|
||||
traversal.hasString = 0;
|
||||
hasString = 0;
|
||||
}
|
||||
if (*count != 0) {
|
||||
traversal.remaining = *count;
|
||||
remaining = *count;
|
||||
} else {
|
||||
traversal.remaining = 1;
|
||||
remaining = 1;
|
||||
}
|
||||
traversal.matchedParts = 0;
|
||||
matchedParts = 0;
|
||||
if ((lastMode != 0) && (numParts > 1)) {
|
||||
altMode = 1;
|
||||
}
|
||||
while (traversal.remaining-- != 0) {
|
||||
while (remaining-- != 0) {
|
||||
if ((node[0] & flag) != 0) goto decode_node;
|
||||
next_node:
|
||||
node += 0xC;
|
||||
continue;
|
||||
decode_node:
|
||||
traversal.code = Zi8GetPCode(pCodeTable, node);
|
||||
if ((*values != (traversal.code & *masks)) && (altMode == 0) && ((node[0] & 0x80) != 0)) {
|
||||
code = Zi8GetPCode(pCodeTable, node);
|
||||
if ((*values != (code & *masks)) && (altMode == 0) && ((node[0] & 0x80) != 0)) {
|
||||
if (*count != 0) {
|
||||
traversal.soundIndex = (initialCode - traversal.remaining) - 1;
|
||||
soundIndex = (initialCode - remaining) - 1;
|
||||
} else {
|
||||
traversal.soundIndex = initialCode;
|
||||
soundIndex = initialCode;
|
||||
}
|
||||
traversal.code = Zi8MatchAltSound(soundTable, soundCode, pCodeTable, traversal.soundIndex, *masks, *values, flag, ZI_WORK);
|
||||
code = Zi8MatchAltSound(soundTable, soundCode, pCodeTable, soundIndex, *masks, *values, flag, ZI_WORK);
|
||||
}
|
||||
goto check_code;
|
||||
match_code:
|
||||
if (partValue == (traversal.code & partMask)) goto next_node;
|
||||
traversal.matchedParts = 1;
|
||||
if (partValue == (code & partMask)) goto next_node;
|
||||
matchedParts = 1;
|
||||
if (*count != 0) {
|
||||
traversal.soundIndex = (initialCode - traversal.remaining) - 1;
|
||||
soundIndex = (initialCode - remaining) - 1;
|
||||
} else {
|
||||
traversal.soundIndex = initialCode;
|
||||
soundIndex = initialCode;
|
||||
}
|
||||
sound = (ziU8*)(tableAddress + ((node[9] & 0xF) * 0x10000 + (node[0xB] + node[0xA] * 0x100)));
|
||||
if (ZI_WORK->cangjieEnabled != 0) {
|
||||
@@ -368,46 +364,46 @@ match_code:
|
||||
} else if (numParts > 1) {
|
||||
goto next_node;
|
||||
}
|
||||
if (((ziU8)traversal.matchedParts == numParts) || (numParts == 0)) {
|
||||
if (((ziU8)matchedParts == numParts) || (numParts == 0)) {
|
||||
*resultNode = node;
|
||||
*resultCode = ((ziU16)node[6] << 8) + node[7];
|
||||
*count = traversal.remaining;
|
||||
*count = remaining;
|
||||
return 1;
|
||||
}
|
||||
next_group:
|
||||
{
|
||||
traversal.nextCode = *sound++;
|
||||
traversal.partCount = traversal.nextCode & 0xF;
|
||||
if ((traversal.nextCode & flag) == 0) {
|
||||
for (; traversal.partCount != 0; traversal.partCount--) {
|
||||
nextCode = *sound++;
|
||||
partCount = nextCode & 0xF;
|
||||
if ((nextCode & flag) == 0) {
|
||||
for (; partCount != 0; partCount--) {
|
||||
for (sound++; (*sound & 0x80) == 0; sound += 2) {
|
||||
}
|
||||
sound++;
|
||||
}
|
||||
}
|
||||
for (; traversal.partCount != 0; traversal.partCount--) {
|
||||
traversal.partIndex = 1;
|
||||
if (traversal.hasString && (sound > *stringOffset)) {
|
||||
traversal.hasString = 0;
|
||||
for (; partCount != 0; partCount--) {
|
||||
partIndex = 1;
|
||||
if (hasString && (sound > *stringOffset)) {
|
||||
hasString = 0;
|
||||
}
|
||||
if (!traversal.hasString) {
|
||||
if (!hasString) {
|
||||
*stringOffset = sound;
|
||||
}
|
||||
do {
|
||||
traversal.dictionaryIndex = sound[0] | ((ziU16)sound[1] << 8);
|
||||
dictionaryIndex = sound[0] | ((ziU16)sound[1] << 8);
|
||||
sound += 2;
|
||||
if (traversal.hasString) {
|
||||
if (hasString) {
|
||||
goto phonetic_skip;
|
||||
}
|
||||
traversal.code = Zi8GetPCode(pCodeTable, dictionary + (traversal.dictionaryIndex & 0x7FFF) * sizeof(DictionaryNode));
|
||||
if (((traversal.code & masks[traversal.partIndex]) != values[traversal.partIndex]) && (altMode == 0) && (dictionary[(traversal.dictionaryIndex & 0x7FFF) * sizeof(DictionaryNode)] & 0x80) != 0) {
|
||||
traversal.code = Zi8MatchAltSound(soundTable, soundCode, pCodeTable, traversal.dictionaryIndex & 0x7FFF, masks[traversal.partIndex], values[traversal.partIndex], flag, ZI_WORK);
|
||||
code = Zi8GetPCode(pCodeTable, dictionary + (dictionaryIndex & 0x7FFF) * sizeof(DictionaryNode));
|
||||
if (((code & masks[partIndex]) != values[partIndex]) && (altMode == 0) && (dictionary[(dictionaryIndex & 0x7FFF) * sizeof(DictionaryNode)] & 0x80) != 0) {
|
||||
code = Zi8MatchAltSound(soundTable, soundCode, pCodeTable, dictionaryIndex & 0x7FFF, masks[partIndex], values[partIndex], flag, ZI_WORK);
|
||||
}
|
||||
if ((traversal.code & masks[traversal.partIndex]) == values[traversal.partIndex]) {
|
||||
if ((code & masks[partIndex]) == values[partIndex]) {
|
||||
goto phonetic_matched;
|
||||
}
|
||||
phonetic_skip:
|
||||
if ((traversal.dictionaryIndex & 0x8000) == 0) {
|
||||
if ((dictionaryIndex & 0x8000) == 0) {
|
||||
sound++;
|
||||
while ((*sound & 0x80) == 0) {
|
||||
sound += 2;
|
||||
@@ -416,23 +412,23 @@ phonetic_skip:
|
||||
}
|
||||
break;
|
||||
phonetic_matched:
|
||||
if (++traversal.partIndex == numParts) {
|
||||
if (++partIndex == numParts) {
|
||||
if (partialMode != 0) {
|
||||
if (strictMode == 0 && (traversal.dictionaryIndex & 0x8000) != 0) goto phonetic_skip;
|
||||
if (strictMode != 0 && (traversal.dictionaryIndex & 0x8000) == 0) goto phonetic_skip;
|
||||
if (strictMode == 0 && (dictionaryIndex & 0x8000) != 0) goto phonetic_skip;
|
||||
if (strictMode != 0 && (dictionaryIndex & 0x8000) == 0) goto phonetic_skip;
|
||||
}
|
||||
*resultNode = node;
|
||||
*resultCode = ((ziU16)node[6] << 8) + node[7];
|
||||
*count = traversal.remaining;
|
||||
*count = remaining;
|
||||
return 1;
|
||||
}
|
||||
} while ((traversal.dictionaryIndex & 0x8000) == 0);
|
||||
} while ((dictionaryIndex & 0x8000) == 0);
|
||||
}
|
||||
}
|
||||
if ((traversal.nextCode & 0x80) != 0) goto next_node;
|
||||
if ((nextCode & 0x80) != 0) goto next_node;
|
||||
goto next_group;
|
||||
check_code:
|
||||
if (*values == (traversal.code & *masks)) goto match_code;
|
||||
if (*values == (code & *masks)) goto match_code;
|
||||
goto next_node;
|
||||
}
|
||||
return 0;
|
||||
|
||||
@@ -27,31 +27,29 @@ ziU8 Zi8MatchKoreanSequence(ziU16* resultIndex, ziU16* input, ziU8 type, ziU16 c
|
||||
|
||||
ziU32 Zi8GetKoreanCandidates(ziGetParam* params, ziU8* argument,
|
||||
struct __zi8_work_data_s* workData) {
|
||||
struct {
|
||||
ziU8 characterIndex;
|
||||
ziU8 matched;
|
||||
ziU8 elementIndex;
|
||||
ziU16 index;
|
||||
ziU16 currentCandidate;
|
||||
ziU16 inputIndex;
|
||||
ziU16 nextIndex;
|
||||
ziU16 tableCount31;
|
||||
ziU16 tableCount6;
|
||||
ziU16 tableCount3;
|
||||
ziU16 tableCount0;
|
||||
ziU8* table31;
|
||||
ziU8* table2;
|
||||
ziU8* table1;
|
||||
} state;
|
||||
ziU8* table1;
|
||||
ziU8* table2;
|
||||
ziU8* table31;
|
||||
ziU16 tableCount0;
|
||||
ziU16 tableCount3;
|
||||
ziU16 tableCount6;
|
||||
ziU16 tableCount31;
|
||||
ziU16 nextIndex;
|
||||
ziU16 inputIndex;
|
||||
ziU16 currentCandidate;
|
||||
ziU16 index;
|
||||
ziU8 elementIndex;
|
||||
ziU8 matched;
|
||||
ziU8 characterIndex;
|
||||
ziU16 buffer[100];
|
||||
ziU8 result;
|
||||
ziU16 currentCharacter;
|
||||
ziU8* selectedTable;
|
||||
|
||||
state.nextIndex = 0;
|
||||
nextIndex = 0;
|
||||
result = 0;
|
||||
state.characterIndex = 0xFF;
|
||||
state.currentCandidate = params->firstCandidate;
|
||||
characterIndex = 0xFF;
|
||||
currentCandidate = params->firstCandidate;
|
||||
params->letters = params->completion = params->count = 0;
|
||||
if ((argument != 0) && (*argument != 0)) {
|
||||
Zi8LogError(0x7D0, workData);
|
||||
@@ -63,31 +61,31 @@ ziU32 Zi8GetKoreanCandidates(ziGetParam* params, ziU8* argument,
|
||||
}
|
||||
|
||||
selectedTable = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 4, workData);
|
||||
state.table1 = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 1, workData);
|
||||
state.table2 = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 2, workData);
|
||||
state.table31 = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0x31, workData);
|
||||
state.tableCount0 = Zi8GetTableCount(ZI8_LANG_KO, 0, workData);
|
||||
state.tableCount3 = Zi8GetTableCount(ZI8_LANG_KO, 3, workData);
|
||||
state.tableCount6 = Zi8GetTableCount(ZI8_LANG_KO, 6, workData);
|
||||
state.tableCount31 = Zi8GetTableCount(ZI8_LANG_KO, 0x31, workData);
|
||||
table1 = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 1, workData);
|
||||
table2 = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 2, workData);
|
||||
table31 = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0x31, workData);
|
||||
tableCount0 = Zi8GetTableCount(ZI8_LANG_KO, 0, workData);
|
||||
tableCount3 = Zi8GetTableCount(ZI8_LANG_KO, 3, workData);
|
||||
tableCount6 = Zi8GetTableCount(ZI8_LANG_KO, 6, workData);
|
||||
tableCount31 = Zi8GetTableCount(ZI8_LANG_KO, 0x31, workData);
|
||||
|
||||
for (state.elementIndex = 0; state.elementIndex < params->elementCount;
|
||||
state.elementIndex++) {
|
||||
currentCharacter = params->elements[state.elementIndex];
|
||||
for (elementIndex = 0; elementIndex < params->elementCount;
|
||||
elementIndex++) {
|
||||
currentCharacter = params->elements[elementIndex];
|
||||
|
||||
if ((currentCharacter >= 0x61) && (currentCharacter <= 0x7A)) {
|
||||
buffer[state.elementIndex] = state.table1[(currentCharacter - 0x61) * 2];
|
||||
buffer[elementIndex] = table1[(currentCharacter - 0x61) * 2];
|
||||
} else if ((currentCharacter >= 0x41) && (currentCharacter <= 0x5A)) {
|
||||
buffer[state.elementIndex] = (state.table1 + (currentCharacter - 0x41) * 2)[1];
|
||||
buffer[elementIndex] = (table1 + (currentCharacter - 0x41) * 2)[1];
|
||||
} else {
|
||||
state.matched = 0;
|
||||
for (; state.table2[state.matched * 3] != 0; state.matched++) {
|
||||
if (currentCharacter == state.table2[state.matched * 3]) break;
|
||||
matched = 0;
|
||||
for (; table2[matched * 3] != 0; matched++) {
|
||||
if (currentCharacter == table2[matched * 3]) break;
|
||||
}
|
||||
if (state.table2[state.matched * 3] != 0) {
|
||||
buffer[state.elementIndex] =
|
||||
((ziU16)(state.table2 + state.matched * 3)[1] << 8) |
|
||||
(state.table2 + state.matched * 3)[2];
|
||||
if (table2[matched * 3] != 0) {
|
||||
buffer[elementIndex] =
|
||||
((ziU16)(table2 + matched * 3)[1] << 8) |
|
||||
(table2 + matched * 3)[2];
|
||||
} else {
|
||||
Zi8LogError(0x161, workData);
|
||||
return 0;
|
||||
@@ -96,16 +94,16 @@ ziU32 Zi8GetKoreanCandidates(ziGetParam* params, ziU8* argument,
|
||||
}
|
||||
|
||||
result = 0;
|
||||
for (currentCharacter = 0; currentCharacter < state.elementIndex; currentCharacter++) {
|
||||
if (Zi8LookupKoreanChar(buffer[currentCharacter], &state.characterIndex,
|
||||
&state.inputIndex, workData) != 0) {
|
||||
state.matched = Zi8MatchKoreanSequence(&state.nextIndex,
|
||||
for (currentCharacter = 0; currentCharacter < elementIndex; currentCharacter++) {
|
||||
if (Zi8LookupKoreanChar(buffer[currentCharacter], &characterIndex,
|
||||
&inputIndex, workData) != 0) {
|
||||
matched = Zi8MatchKoreanSequence(&nextIndex,
|
||||
buffer + currentCharacter + 1,
|
||||
state.characterIndex,
|
||||
(state.elementIndex - currentCharacter) - 1,
|
||||
characterIndex,
|
||||
(elementIndex - currentCharacter) - 1,
|
||||
workData);
|
||||
if (workData->koAltTables == 1) {
|
||||
switch (state.characterIndex) {
|
||||
switch (characterIndex) {
|
||||
case 1:
|
||||
selectedTable = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0x1E, workData);
|
||||
break;
|
||||
@@ -168,59 +166,59 @@ ziU32 Zi8GetKoreanCandidates(ziGetParam* params, ziU8* argument,
|
||||
}
|
||||
}
|
||||
} else {
|
||||
state.matched = 0;
|
||||
matched = 0;
|
||||
}
|
||||
if (state.matched != 0) {
|
||||
if (state.tableCount6 == 0) {
|
||||
state.nextIndex += state.inputIndex * state.tableCount3;
|
||||
if (matched != 0) {
|
||||
if (tableCount6 == 0) {
|
||||
nextIndex += inputIndex * tableCount3;
|
||||
}
|
||||
if (state.currentCandidate != 0) {
|
||||
state.currentCandidate--;
|
||||
if (currentCandidate != 0) {
|
||||
currentCandidate--;
|
||||
} else {
|
||||
params->candidates[result] =
|
||||
((ziU16)selectedTable[state.nextIndex * 2] << 8) | (selectedTable + state.nextIndex * 2)[1];
|
||||
if ((state.tableCount6 != 0) && (workData->koAltTables == 0)) {
|
||||
params->candidates[result] += state.inputIndex * state.tableCount3;
|
||||
((ziU16)selectedTable[nextIndex * 2] << 8) | (selectedTable + nextIndex * 2)[1];
|
||||
if ((tableCount6 != 0) && (workData->koAltTables == 0)) {
|
||||
params->candidates[result] += inputIndex * tableCount3;
|
||||
}
|
||||
result++;
|
||||
}
|
||||
if (currentCharacter == 0) {
|
||||
params->completion = state.matched + 1;
|
||||
params->completion = matched + 1;
|
||||
}
|
||||
currentCharacter += state.matched;
|
||||
currentCharacter += matched;
|
||||
} else {
|
||||
if (state.currentCandidate != 0) {
|
||||
state.index = 0;
|
||||
for (; state.index < state.tableCount31; state.index++) {
|
||||
if (state.table31[state.index * 3] == buffer[currentCharacter] &&
|
||||
(state.table31 + state.index * 3)[1] == buffer[currentCharacter + 1]) break;
|
||||
if (currentCandidate != 0) {
|
||||
index = 0;
|
||||
for (; index < tableCount31; index++) {
|
||||
if (table31[index * 3] == buffer[currentCharacter] &&
|
||||
(table31 + index * 3)[1] == buffer[currentCharacter + 1]) break;
|
||||
}
|
||||
if (state.index == state.tableCount31) {
|
||||
state.currentCandidate--;
|
||||
if (index == tableCount31) {
|
||||
currentCandidate--;
|
||||
}
|
||||
if (currentCharacter == 0) {
|
||||
params->completion = 1;
|
||||
}
|
||||
} else {
|
||||
for (state.index = 0; state.index < state.tableCount31; state.index++) {
|
||||
if ((state.table31[(state.index * 3)] == buffer[currentCharacter]) &&
|
||||
((state.table31 + state.index * 3)[1] == buffer[currentCharacter + 1])) {
|
||||
for (index = 0; index < tableCount31; index++) {
|
||||
if ((table31[(index * 3)] == buffer[currentCharacter]) &&
|
||||
((table31 + index * 3)[1] == buffer[currentCharacter + 1])) {
|
||||
if (currentCharacter == 0) {
|
||||
params->completion = 1;
|
||||
}
|
||||
params->candidates[result] =
|
||||
state.tableCount0 + (state.table31 + state.index * 3)[2];
|
||||
tableCount0 + (table31 + index * 3)[2];
|
||||
result++;
|
||||
currentCharacter++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (state.index == state.tableCount31) {
|
||||
if (index == tableCount31) {
|
||||
if ((params->candidates[result] = buffer[currentCharacter]) < 0xFF) {
|
||||
if (currentCharacter == 0) {
|
||||
params->completion = 1;
|
||||
}
|
||||
params->candidates[result] += state.tableCount0;
|
||||
params->candidates[result] += tableCount0;
|
||||
result++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -11,9 +11,27 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
DECOMP_FORCE_ACTIVE(cnt_c, "<< RVL_SDK - CNT \trelease build: Apr 20 2010 11:21:37 (0x4199_60831) >>");
|
||||
DECOMP_FORCE_ACTIVE(cnt_c, "/content%d");
|
||||
DECOMP_FORCE_ACTIVE(cnt_c, "Warning: CNTInitHandle(): directory '%s' is not found under '/'\n");
|
||||
void CNTInit(void) {
|
||||
const char* __CNTVersion = "<< RVL_SDK - CNT \trelease build: Apr 20 2010 11:21:37 (0x4199_60831) >>";
|
||||
OSRegisterVersion(__CNTVersion);
|
||||
}
|
||||
|
||||
s32 CNTInitHandle(u32 contentId, CNTHandleDVD* cntHandle, MEMAllocator* allocator) {
|
||||
char path[32];
|
||||
s32 entryNum;
|
||||
|
||||
sprintf(path, "/content%d", contentId);
|
||||
entryNum = DVDConvertPathToEntrynum(path);
|
||||
if (entryNum < 0) {
|
||||
OSReport("Warning: CNTInitHandle(): directory '%s' is not found under '/'\n", path);
|
||||
return CNT_RESULT_INVALID;
|
||||
}
|
||||
|
||||
cntHandle->index = contentId;
|
||||
cntHandle->rootDir = entryNum;
|
||||
cntHandle->currDir = entryNum;
|
||||
return CNT_RESULT_OK;
|
||||
}
|
||||
|
||||
typedef struct FSTEntry {
|
||||
u32 isDirAndStringOff; // 0x00
|
||||
|
||||
@@ -31,8 +31,6 @@ char scCntCacheSpaceNl[3] = {0x20, 0x0a, 0x00};
|
||||
|
||||
extern void _savegpr_23();
|
||||
extern void _restgpr_23();
|
||||
extern void _savegpr_26();
|
||||
extern void _restgpr_26();
|
||||
|
||||
OSMutex _CNTCACHEMutex;
|
||||
long long _CNTCACHEUnused816997A8;
|
||||
@@ -263,254 +261,102 @@ void _CNTCACHEDeleteTitle() {
|
||||
}
|
||||
}
|
||||
|
||||
asm int _CNTCACHEIsTitleRemovable(ESTitleId titleId) {
|
||||
clrlwi r11, r1, 0x1b
|
||||
mr r12, r1
|
||||
subfic r11, r11, -0x2100
|
||||
stwux r1, r1, r11
|
||||
mflr r0
|
||||
lis r5, scCntCacheTitleDataFmt@ha
|
||||
stw r0, 4(r12)
|
||||
li r0, 1
|
||||
addi r5, r5, scCntCacheTitleDataFmt@l
|
||||
stw r31, -4(r12)
|
||||
stw r30, -8(r12)
|
||||
mr r30, r3
|
||||
addi r3, r1, 0x40
|
||||
stw r29, -0xc(r12)
|
||||
mr r29, r4
|
||||
li r4, -1
|
||||
stw r0, 0x20(r1)
|
||||
and r6, r30, r4
|
||||
and r7, r29, r4
|
||||
li r4, 0x40
|
||||
stw r0, 0x24(r1)
|
||||
crclr 4*cr1+eq
|
||||
bl snprintf
|
||||
addi r3, r1, 0x40
|
||||
addi r4, r1, 0x20
|
||||
addi r5, r1, 0x24
|
||||
bl NANDSecretGetUsage
|
||||
cmpwi r3, -0xc
|
||||
mr r4, r3
|
||||
bne L_418
|
||||
li r4, 2
|
||||
b L_444
|
||||
L_418:
|
||||
cmpwi r3, 0
|
||||
blt L_444
|
||||
lwz r0, 0x24(r1)
|
||||
cmplwi r0, 1
|
||||
bne L_440
|
||||
lwz r0, 0x20(r1)
|
||||
cmpwi r0, 0
|
||||
bne L_440
|
||||
li r4, 1
|
||||
b L_444
|
||||
L_440:
|
||||
li r4, 0
|
||||
L_444:
|
||||
cmpwi r4, 1
|
||||
bne L_4bc
|
||||
mr r4, r29
|
||||
mr r3, r30
|
||||
addi r31, r1, 0x80
|
||||
addi r6, r1, 0x28
|
||||
li r5, 0
|
||||
bl ES_GetTmdView
|
||||
cmpwi r3, 0
|
||||
beq L_470
|
||||
b L_4c0
|
||||
L_470:
|
||||
lwz r0, 0x28(r1)
|
||||
cmplwi r0, 0x2060
|
||||
ble L_484
|
||||
li r3, -0x400
|
||||
b L_4c0
|
||||
L_484:
|
||||
mr r4, r29
|
||||
mr r3, r30
|
||||
mr r5, r31
|
||||
addi r6, r1, 0x28
|
||||
bl ES_GetTmdView
|
||||
cmpwi r3, 0
|
||||
beq L_4a4
|
||||
b L_4c0
|
||||
L_4a4:
|
||||
lhz r0, 0xd8(r1)
|
||||
rlwinm. r0, r0, 0x18, 0x18, 0x1f
|
||||
bne L_4b8
|
||||
li r4, 1
|
||||
b L_4bc
|
||||
L_4b8:
|
||||
li r4, 0
|
||||
L_4bc:
|
||||
mr r3, r4
|
||||
L_4c0:
|
||||
lwz r10, 0(r1)
|
||||
lwz r0, 4(r10)
|
||||
lwz r31, -4(r10)
|
||||
lwz r30, -8(r10)
|
||||
lwz r29, -0xc(r10)
|
||||
mtlr r0
|
||||
mr r1, r10
|
||||
blr
|
||||
static s32 GetSaveDataUsage(ESTitleId titleId) {
|
||||
s32 ret = -1;
|
||||
char nandPath[64] ALIGN32;
|
||||
u32 usedBlocks = 1;
|
||||
u32 usedINodes = 1;
|
||||
|
||||
snprintf(nandPath, (int)sizeof(nandPath), scCntCacheTitleDataFmt, NANDTitleIdHi(titleId), NANDTitleIdLo(titleId));
|
||||
ret = NANDSecretGetUsage(nandPath, &usedBlocks, &usedINodes);
|
||||
|
||||
if (ret == NAND_RESULT_NOEXISTS) {
|
||||
ret = 2;
|
||||
} else if (ret >= NAND_RESULT_OK) {
|
||||
if (usedINodes == 1 && usedBlocks == 0) {
|
||||
ret = 1;
|
||||
} else {
|
||||
ret = 0;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
asm void _CNTCACHEDeleteContent() {
|
||||
clrlwi r11, r1, 0x1b
|
||||
mr r12, r1
|
||||
subfic r11, r11, -0x2100
|
||||
stwux r1, r1, r11
|
||||
mflr r0
|
||||
mr r11, r12
|
||||
stw r0, 4(r12)
|
||||
bl _savegpr_26
|
||||
li r3, 0
|
||||
la r4, scCntCacheSpaceNl
|
||||
bl strtok
|
||||
li r31, 0
|
||||
li r4, 0
|
||||
stw r31, errno(r0)
|
||||
li r5, 0x10
|
||||
bl strtoull
|
||||
lwz r0, errno(r0)
|
||||
mr r29, r4
|
||||
mr r30, r3
|
||||
cmpwi r0, 0
|
||||
bne L_708
|
||||
li r0, -1
|
||||
and r5, r3, r0
|
||||
addis r0, r5, -1
|
||||
cmplwi r0, 5
|
||||
bne L_708
|
||||
addi r28, r1, 0x80
|
||||
addi r6, r1, 0x28
|
||||
li r5, 0
|
||||
bl ES_GetTmdView
|
||||
cmpwi r3, -0x6a
|
||||
beq L_708
|
||||
cmpwi r3, 0
|
||||
bne L_708
|
||||
mr r4, r29
|
||||
mr r3, r30
|
||||
mr r5, r28
|
||||
addi r6, r1, 0x28
|
||||
bl ES_GetTmdView
|
||||
cmpwi r3, 0
|
||||
bne L_708
|
||||
lwz r3, 0x94(r1)
|
||||
rlwinm. r0, r3, 0, 0x1c, 0x1c
|
||||
beq L_6f0
|
||||
rlwinm. r0, r3, 0, 0x1b, 0x1b
|
||||
beq L_6f0
|
||||
li r3, 0
|
||||
la r4, scCntCacheSpaceNl
|
||||
bl strtok
|
||||
li r26, 1
|
||||
lis r27, scCntCacheTitleDataFmt@ha
|
||||
b L_6e8
|
||||
L_5b0:
|
||||
stw r31, errno(r0)
|
||||
li r4, 0
|
||||
li r5, 0xa
|
||||
bl strtoul
|
||||
lwz r0, errno(r0)
|
||||
cmpwi r0, 0
|
||||
bne L_6dc
|
||||
cmplwi r3, 0x1fe
|
||||
bgt L_6dc
|
||||
lhz r0, 0xda(r1)
|
||||
li r4, 0
|
||||
mtctr r0
|
||||
cmplwi r0, 0
|
||||
ble L_6dc
|
||||
L_5e8:
|
||||
add r5, r28, r4
|
||||
lhz r0, 0x60(r5)
|
||||
cmplw r3, r0
|
||||
bne L_6d4
|
||||
lhz r0, 0x62(r5)
|
||||
rlwinm. r0, r0, 0, 0x10, 0x10
|
||||
bne L_6dc
|
||||
lwz r5, 0x5c(r5)
|
||||
mr r4, r29
|
||||
mr r3, r30
|
||||
bl ES_DeleteContent
|
||||
cmpwi r3, 0
|
||||
bne L_6dc
|
||||
mr r4, r29
|
||||
mr r3, r30
|
||||
addi r6, r1, 0x2c
|
||||
li r5, 0
|
||||
bl ES_ListTitleContentsOnCard
|
||||
cmpwi r3, 0
|
||||
bne L_6dc
|
||||
lwz r0, 0x2c(r1)
|
||||
cmpwi r0, 0
|
||||
bne L_6dc
|
||||
li r0, -1
|
||||
stw r26, 0x20(r1)
|
||||
addi r3, r1, 0x40
|
||||
addi r5, r27, scCntCacheTitleDataFmt@l
|
||||
stw r26, 0x24(r1)
|
||||
and r6, r30, r0
|
||||
and r7, r29, r0
|
||||
li r4, 0x40
|
||||
crclr 4*cr1+eq
|
||||
bl snprintf
|
||||
addi r3, r1, 0x40
|
||||
addi r4, r1, 0x20
|
||||
addi r5, r1, 0x24
|
||||
bl NANDSecretGetUsage
|
||||
cmpwi r3, -0xc
|
||||
mr r0, r3
|
||||
bne L_690
|
||||
li r0, 2
|
||||
b L_6bc
|
||||
L_690:
|
||||
cmpwi r3, 0
|
||||
blt L_6bc
|
||||
lwz r0, 0x24(r1)
|
||||
cmplwi r0, 1
|
||||
bne L_6b8
|
||||
lwz r0, 0x20(r1)
|
||||
cmpwi r0, 0
|
||||
bne L_6b8
|
||||
li r0, 1
|
||||
b L_6bc
|
||||
L_6b8:
|
||||
li r0, 0
|
||||
L_6bc:
|
||||
cmpwi r0, 1
|
||||
bne L_6dc
|
||||
mr r4, r29
|
||||
mr r3, r30
|
||||
bl ES_DeleteTitle
|
||||
b L_6dc
|
||||
L_6d4:
|
||||
addi r4, r4, 0x10
|
||||
bdnz L_5e8
|
||||
L_6dc:
|
||||
li r3, 0
|
||||
la r4, scCntCacheSpaceNl
|
||||
bl strtok
|
||||
L_6e8:
|
||||
cmpwi r3, 0
|
||||
bne L_5b0
|
||||
L_6f0:
|
||||
lwz r5, 0x28(r1)
|
||||
addi r3, r1, 0x80
|
||||
li r4, 0
|
||||
addi r0, r5, 0x1f
|
||||
rlwinm r5, r0, 0, 0, 0x1a
|
||||
bl memset
|
||||
L_708:
|
||||
lwz r10, 0(r1)
|
||||
mr r11, r10
|
||||
bl _restgpr_26
|
||||
lwz r0, 4(r10)
|
||||
mtlr r0
|
||||
mr r1, r10
|
||||
blr
|
||||
BOOL _CNTCACHEIsTitleRemovable(ESTitleId titleId) {
|
||||
u8 tmdBuf[OSRoundUp32B(sizeof(ESTmdView))] ALIGN32;
|
||||
u32 tmdSize;
|
||||
ESTmdView* tmd;
|
||||
s32 ret;
|
||||
|
||||
ret = GetSaveDataUsage(titleId);
|
||||
if (ret == 1) {
|
||||
tmd = (ESTmdView*)tmdBuf;
|
||||
ret = ES_GetTmdView(titleId, NULL, &tmdSize);
|
||||
if (ret != ES_ERR_OK) {
|
||||
return ret;
|
||||
}
|
||||
if (tmdSize > sizeof(tmdBuf)) {
|
||||
return ES_ERR_MEMORY_ERROR;
|
||||
}
|
||||
ret = ES_GetTmdView(titleId, tmd, &tmdSize);
|
||||
if (ret != ES_ERR_OK) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (((tmd->head.titleVersion >> 8) & 0xFF) == 0) {
|
||||
ret = 1;
|
||||
} else {
|
||||
ret = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void _CNTCACHEDeleteContent() {
|
||||
u8 buf[OSRoundUp32B(sizeof(ESTmdView))] ALIGN32;
|
||||
u32 numOnCard;
|
||||
u32 size;
|
||||
ESTitleId titleId;
|
||||
ESTmdView* tmd;
|
||||
ESError result;
|
||||
char* token;
|
||||
|
||||
token = strtok(NULL, scCntCacheSpaceNl);
|
||||
errno = 0;
|
||||
titleId = strtoull(token, NULL, 16);
|
||||
if (errno == 0 && NANDTitleIdHi(titleId) == 0x00010005) {
|
||||
tmd = (ESTmdView*)buf;
|
||||
result = ES_GetTmdView(titleId, NULL, &size);
|
||||
if (result == ES_ERR_DONT_EXISTS) {
|
||||
return;
|
||||
}
|
||||
if (result == ES_ERR_OK && ES_GetTmdView(titleId, tmd, &size) == ES_ERR_OK) {
|
||||
if ((tmd->head.titleType & 8) && (tmd->head.titleType & 0x10)) {
|
||||
token = strtok(NULL, scCntCacheSpaceNl);
|
||||
while (token) {
|
||||
u32 index;
|
||||
u32 i;
|
||||
|
||||
errno = 0;
|
||||
index = strtoul(token, NULL, 10);
|
||||
if (errno == 0 && index <= 510) {
|
||||
for (i = 0; i < tmd->head.numContents; i++) {
|
||||
if (index == tmd->contents[i].index) {
|
||||
if (!(tmd->contents[i].type & 0x8000) &&
|
||||
ES_DeleteContent(titleId, tmd->contents[i].cid) == ES_ERR_OK &&
|
||||
ES_ListTitleContentsOnCard(titleId, NULL, &numOnCard) == ES_ERR_OK &&
|
||||
numOnCard == 0 && GetSaveDataUsage(titleId) == 1) {
|
||||
ES_DeleteTitle(titleId);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
token = strtok(NULL, scCntCacheSpaceNl);
|
||||
}
|
||||
}
|
||||
memset(buf, 0, OSRoundUp32B(size));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -29,13 +29,13 @@ typedef struct PFD_SDDRV_FORMAT_DATA {
|
||||
u32 total_sectors;
|
||||
} PFD_SDDRV_FORMAT_DATA;
|
||||
|
||||
PFD_SDDRV_INFO g_pfd_sddrv_info;
|
||||
PFD_SDDEV_STORAGE g_pfd_sddev;
|
||||
volatile PFD_SDDRV_INFO g_pfd_sddrv_info;
|
||||
PFD_SDDEV_STORAGE g_pfd_sddev ATTRIBUTE_ALIGN(32);
|
||||
u8 g_pfd_sddrv_buf[0x200];
|
||||
|
||||
static FAInsertCallback g_attach_func = 0;
|
||||
static FAEjectCallback g_detach_func = 0;
|
||||
u32 g_event;
|
||||
u32 g_event ATTRIBUTE_ALIGN(32);
|
||||
|
||||
extern u8 pfd_get_media_drv_char(FADisk*, s8*, u32);
|
||||
extern void pdm_disk_notify_media_insert(FADisk*);
|
||||
@@ -243,39 +243,23 @@ static inline void clear_mount_flag(void) {
|
||||
g_pfd_sddrv_info.flags &= ~2;
|
||||
}
|
||||
|
||||
static inline u32 pfd_sddrv_flags(const PFD_SDDRV_INFO* info) {
|
||||
return info->flags;
|
||||
}
|
||||
|
||||
static inline SDDev* pfd_sddrv_device(const PFD_SDDRV_INFO* info) {
|
||||
return info->device;
|
||||
}
|
||||
|
||||
static inline FADisk* pfd_sddrv_disk(const PFD_SDDRV_INFO* info) {
|
||||
return info->disk;
|
||||
}
|
||||
|
||||
static inline s8 pfd_sddrv_drive(const PFD_SDDRV_INFO* info) {
|
||||
return info->drive;
|
||||
}
|
||||
|
||||
s32 pfd_st_inter_callback(s32 status, void* data) {
|
||||
s32 result;
|
||||
|
||||
if ((status & 1) != 1) {
|
||||
return 0;
|
||||
}
|
||||
if (pfd_sddrv_device(&g_pfd_sddrv_info) != 0) {
|
||||
if (g_pfd_sddrv_info.device != 0) {
|
||||
g_event = 2;
|
||||
result = ISD_RegisterDeviceIntrHandler(g_pfd_sddrv_info.device, (SDDevIntrCallback)pfd_st_removal_callback, &g_event);
|
||||
if (result != 0) {
|
||||
OSReport("ERR:Failed to regist intr handler. pfd_st_inter_callback()\n");
|
||||
}
|
||||
}
|
||||
if (pfd_sddrv_disk(&g_pfd_sddrv_info) != 0) {
|
||||
if (g_pfd_sddrv_info.disk != 0) {
|
||||
update_media_drive();
|
||||
pdm_disk_notify_media_insert(g_pfd_sddrv_info.disk);
|
||||
if (pfd_sddrv_drive(&g_pfd_sddrv_info) != 0 && g_attach_func != 0) {
|
||||
if (g_pfd_sddrv_info.drive != 0 && g_attach_func != 0) {
|
||||
g_attach_func(g_pfd_sddrv_info.drive);
|
||||
}
|
||||
}
|
||||
@@ -291,36 +275,39 @@ s32 pfd_st_removal_callback(s32 status, void* data) {
|
||||
return 0;
|
||||
}
|
||||
g_pfd_sddrv_info.media_inserted = 0;
|
||||
if (g_pfd_sddrv_info.media_inserted == 0 && pfd_sddrv_device(&g_pfd_sddrv_info) != 0) {
|
||||
if (g_pfd_sddrv_info.device != 0) {
|
||||
g_event = 1;
|
||||
result = ISD_RegisterDeviceIntrHandler(g_pfd_sddrv_info.device, (SDDevIntrCallback)pfd_st_inter_callback, &g_event);
|
||||
if (result != 0) {
|
||||
OSReport("ERR:Failed to regist intr handler. pfd_st_removal_callback()\n");
|
||||
}
|
||||
}
|
||||
if (pfd_sddrv_disk(&g_pfd_sddrv_info) != 0) {
|
||||
if (g_pfd_sddrv_info.disk != 0) {
|
||||
update_media_drive();
|
||||
pdm_disk_notify_media_eject(g_pfd_sddrv_info.disk);
|
||||
if (pfd_sddrv_drive(&g_pfd_sddrv_info) != 0 && g_detach_func != 0) {
|
||||
if (g_pfd_sddrv_info.drive != 0 && g_detach_func != 0) {
|
||||
g_detach_func(g_pfd_sddrv_info.drive);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#pragma push
|
||||
#pragma ppc_iro_level 0
|
||||
s32 pfd_sddrv_init(FADisk* disk) {
|
||||
s32 sd_result;
|
||||
SDDev* device;
|
||||
u32 status;
|
||||
|
||||
if (disk == 0) {
|
||||
if (disk == NULL) {
|
||||
return -30;
|
||||
}
|
||||
if ((pfd_sddrv_flags(&g_pfd_sddrv_info) & 1) != 0) {
|
||||
if ((g_pfd_sddrv_info.flags & 1) != 0) {
|
||||
OSReport("INFO SD Card driver is already initialize. pfd_sddrv_init()\n");
|
||||
if (disk != g_pfd_sddrv_info.disk) {
|
||||
return -44;
|
||||
}
|
||||
return 0;
|
||||
} else {
|
||||
if ((g_pfd_sddrv_info.flags & 4) == 0) {
|
||||
g_pfd_sddrv_info.bytes_per_sector = 0x200;
|
||||
@@ -372,6 +359,7 @@ s32 pfd_sddrv_init(FADisk* disk) {
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#pragma pop
|
||||
|
||||
s32 pfd_sddrv_mount(FADisk* disk) {
|
||||
s32 result;
|
||||
@@ -473,7 +461,7 @@ s32 pfd_sddrv_unmount(FADisk* disk) {
|
||||
if (disk == 0) {
|
||||
return -30;
|
||||
}
|
||||
if ((pfd_sddrv_flags(&g_pfd_sddrv_info) & 2) != 0) {
|
||||
if ((g_pfd_sddrv_info.flags & 2) != 0) {
|
||||
clear_mount_flag();
|
||||
}
|
||||
return 0;
|
||||
@@ -485,7 +473,7 @@ s32 pfd_sddrv_finalize(FADisk* disk) {
|
||||
if (disk == 0) {
|
||||
return -30;
|
||||
}
|
||||
if ((pfd_sddrv_flags(&g_pfd_sddrv_info) & 2) != 0) {
|
||||
if ((g_pfd_sddrv_info.flags & 2) != 0) {
|
||||
clear_mount_flag();
|
||||
}
|
||||
if ((g_pfd_sddrv_info.flags & 1) != 0) {
|
||||
@@ -1371,22 +1359,24 @@ s32 pfd_sddrv_store_fat32_bpb_buf(PFD_SDDRV_FORMAT_DATA* format_data, u8* sector
|
||||
|
||||
static s32 pfd_sddrv_store_fat32_reserved_buf(u8* sector_buffer) {
|
||||
PFD_SDDRV_RESERVED_BOOT_SECTOR* reserved_boot_sector;
|
||||
s32 result = -30;
|
||||
|
||||
if (sector_buffer != 0) {
|
||||
pf_memset(sector_buffer, 0, 0x200);
|
||||
reserved_boot_sector = (PFD_SDDRV_RESERVED_BOOT_SECTOR*)sector_buffer;
|
||||
if (((u32)reserved_boot_sector->signature.bytes & 1) != 0) {
|
||||
reserved_boot_sector->signature.bytes[0] = 0x55;
|
||||
reserved_boot_sector->signature.bytes[1] = 0xaa;
|
||||
} else {
|
||||
reserved_boot_sector->signature.value = 0x55aa;
|
||||
}
|
||||
result = 0;
|
||||
pf_memset(sector_buffer, 0, 0x200);
|
||||
reserved_boot_sector = (PFD_SDDRV_RESERVED_BOOT_SECTOR*)sector_buffer;
|
||||
if (((u32)reserved_boot_sector->signature.bytes & 1) != 0) {
|
||||
reserved_boot_sector->signature.bytes[0] = 0x55;
|
||||
reserved_boot_sector->signature.bytes[1] = 0xaa;
|
||||
} else {
|
||||
reserved_boot_sector->signature.value = 0x55aa;
|
||||
}
|
||||
return result;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline s32 pfd_sddrv_write_sector(u32 sector) {
|
||||
return ISD_WriteBlock(g_pfd_sddrv_info.device, sector, g_pfd_sddrv_buf, 1);
|
||||
}
|
||||
|
||||
#pragma push
|
||||
#pragma ppc_iro_level 0
|
||||
s32 pfd_sddrv_build_fat32_mbr_bpb(u32 total_sectors) {
|
||||
PFD_SDDRV_FORMAT_DATA format_data;
|
||||
s32 result;
|
||||
@@ -1408,12 +1398,12 @@ s32 pfd_sddrv_build_fat32_mbr_bpb(u32 total_sectors) {
|
||||
if (g_pfd_sddrv_info.media_ejected != 0) {
|
||||
return -33;
|
||||
}
|
||||
result = ISD_WriteBlock(g_pfd_sddrv_info.device, format_data.partition_start_sector, g_pfd_sddrv_buf, 1);
|
||||
result = pfd_sddrv_write_sector(format_data.partition_start_sector);
|
||||
if (result != 0) {
|
||||
OSReport("ERR Failed to write BPB fields. ISD_WriteBlock()\n");
|
||||
return -36;
|
||||
}
|
||||
result = ISD_WriteBlock(g_pfd_sddrv_info.device, format_data.partition_start_sector + 6, g_pfd_sddrv_buf, 1);
|
||||
result = pfd_sddrv_write_sector(format_data.partition_start_sector + 6);
|
||||
if (result != 0) {
|
||||
OSReport("ERR Failed to write BPB fields. ISD_WriteBlock()\n");
|
||||
return -36;
|
||||
@@ -1429,12 +1419,12 @@ s32 pfd_sddrv_build_fat32_mbr_bpb(u32 total_sectors) {
|
||||
if (g_pfd_sddrv_info.media_ejected != 0) {
|
||||
return -33;
|
||||
}
|
||||
result = ISD_WriteBlock(g_pfd_sddrv_info.device, format_data.partition_start_sector + 1, g_pfd_sddrv_buf, 1);
|
||||
result = pfd_sddrv_write_sector(format_data.partition_start_sector + 1);
|
||||
if (result != 0) {
|
||||
OSReport("ERR Failed to write BPB fields. ISD_WriteBlock()\n");
|
||||
return -36;
|
||||
}
|
||||
result = ISD_WriteBlock(g_pfd_sddrv_info.device, format_data.partition_start_sector + 7, g_pfd_sddrv_buf, 1);
|
||||
result = pfd_sddrv_write_sector(format_data.partition_start_sector + 7);
|
||||
if (result != 0) {
|
||||
OSReport("ERR Failed to write BPB fields. ISD_WriteBlock()\n");
|
||||
return -36;
|
||||
@@ -1451,12 +1441,12 @@ s32 pfd_sddrv_build_fat32_mbr_bpb(u32 total_sectors) {
|
||||
if (g_pfd_sddrv_info.media_ejected != 0) {
|
||||
return -33;
|
||||
}
|
||||
result = ISD_WriteBlock(g_pfd_sddrv_info.device, format_data.partition_start_sector + 2, g_pfd_sddrv_buf, 1);
|
||||
result = pfd_sddrv_write_sector(format_data.partition_start_sector + 2);
|
||||
if (result != 0) {
|
||||
OSReport("ERR Failed to write BPB fields. ISD_WriteBlock()\n");
|
||||
return -36;
|
||||
}
|
||||
result = ISD_WriteBlock(g_pfd_sddrv_info.device, format_data.partition_start_sector + 8, g_pfd_sddrv_buf, 1);
|
||||
result = pfd_sddrv_write_sector(format_data.partition_start_sector + 8);
|
||||
if (result != 0) {
|
||||
OSReport("ERR Failed to write BPB fields. ISD_WriteBlock()\n");
|
||||
return -36;
|
||||
@@ -1472,13 +1462,14 @@ s32 pfd_sddrv_build_fat32_mbr_bpb(u32 total_sectors) {
|
||||
if (g_pfd_sddrv_info.media_ejected != 0) {
|
||||
return -33;
|
||||
}
|
||||
result = ISD_WriteBlock(g_pfd_sddrv_info.device, 0, g_pfd_sddrv_buf, 1);
|
||||
result = pfd_sddrv_write_sector(0);
|
||||
if (result != 0) {
|
||||
OSReport("ERR Failed to write MBR fields. ISD_WriteBlock()\n");
|
||||
return -36;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#pragma pop
|
||||
|
||||
s32 pfd_sddrv_full_format(void) {
|
||||
FADiskInfo geometry;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -173,72 +173,77 @@ pf_s32 PFFAT12_WriteFATEntryWithBuf(PF_VOLUME* p_vol, pf_s16 cluster, pf_u16 val
|
||||
#undef FLUSH_FAT_BUFFER
|
||||
}
|
||||
|
||||
pf_s32 PFFAT12_ReadFATEntryWithBuf(PF_VOLUME* p_vol , pf_u16 cluster , pf_u32* p_value ,
|
||||
PF_CACHE_PAGE* p_page ) {
|
||||
struct {
|
||||
pf_u32 sector;
|
||||
pf_u32 current_fat;
|
||||
pf_s32 err;
|
||||
pf_u32 offset;
|
||||
} state;
|
||||
static inline pf_s32 ReadFAT12WordWithBuf(PF_VOLUME* p_vol, pf_u32 offset, pf_u32* p_value, PF_CACHE_PAGE* p_page) {
|
||||
pf_u32 current_fat;
|
||||
pf_u32 sector;
|
||||
pf_s32 err;
|
||||
pf_s32 result;
|
||||
|
||||
#define LOAD_FAT_SECTOR(next_sector) \
|
||||
if (p_page->sector != state.sector + (next_sector)) { \
|
||||
if (p_page->sector != sector + (next_sector)) { \
|
||||
if (p_page->option == 1) { \
|
||||
for (state.err = 0; (pf_u16)state.err < p_vol->bpb.num_active_FATs; state.err++) { \
|
||||
VFiPFSEC_WriteFAT(p_vol, p_page->p_buf, p_page->sector + (pf_u16)state.err * p_vol->bpb.sectors_per_FAT, 0, p_vol->bpb.bytes_per_sector); \
|
||||
for (err = 0; (pf_u16)err < p_vol->bpb.num_active_FATs; err++) { \
|
||||
VFiPFSEC_WriteFAT(p_vol, p_page->p_buf, p_page->sector + (pf_u16)err * p_vol->bpb.sectors_per_FAT, 0, p_vol->bpb.bytes_per_sector); \
|
||||
} \
|
||||
} \
|
||||
state.err = VFiPFSEC_ReadFAT(p_vol, p_page->p_buf, state.sector + (next_sector), 0, p_vol->bpb.bytes_per_sector); \
|
||||
if (state.err != 0) { continue; } \
|
||||
p_page->sector = state.sector + (next_sector); \
|
||||
err = VFiPFSEC_ReadFAT(p_vol, p_page->p_buf, sector + (next_sector), 0, p_vol->bpb.bytes_per_sector); \
|
||||
if (err != 0) { continue; } \
|
||||
p_page->sector = sector + (next_sector); \
|
||||
}
|
||||
|
||||
state.offset = (pf_u16)(cluster + (cluster >> 1));
|
||||
state.sector = p_vol->bpb.active_FAT_sector + (state.offset >> p_vol->bpb.log2_bytes_per_sector) & 0xFFFF;
|
||||
sector = p_vol->bpb.active_FAT_sector + (offset >> p_vol->bpb.log2_bytes_per_sector) & 0xFFFF;
|
||||
if ((p_vol->bpb.ext_flags & 0x80) != 0) {
|
||||
state.current_fat = p_vol->bpb.ext_flags & (0x01 | 0x02 | 0x04);
|
||||
current_fat = p_vol->bpb.ext_flags & (0x01 | 0x02 | 0x04);
|
||||
} else {
|
||||
state.current_fat = 1;
|
||||
current_fat = 1;
|
||||
}
|
||||
state.err = 0;
|
||||
err = 0;
|
||||
while (PF_TRUE) {
|
||||
if (state.err == 0x1000 && p_vol->p_callback != PF_NULL) {
|
||||
if (err == 0x1000 && p_vol->p_callback != PF_NULL) {
|
||||
result = ((PF_VOLUME_CB)p_vol->p_callback)(p_vol->last_driver_error);
|
||||
if (result == 0) {
|
||||
state.err = 0;
|
||||
err = 0;
|
||||
continue;
|
||||
}
|
||||
if (result == 1 && p_vol->bpb.num_active_FATs >= 2 && state.current_fat < p_vol->bpb.num_active_FATs) {
|
||||
state.current_fat++;
|
||||
state.sector += p_vol->bpb.sectors_per_FAT;
|
||||
state.err = 0;
|
||||
if (result == 1 && p_vol->bpb.num_active_FATs >= 2 && current_fat < p_vol->bpb.num_active_FATs) {
|
||||
current_fat++;
|
||||
sector += p_vol->bpb.sectors_per_FAT;
|
||||
err = 0;
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
LOAD_FAT_SECTOR(0);
|
||||
state.offset &= p_vol->bpb.bytes_per_sector - 1;
|
||||
if (state.offset == (p_vol->bpb.bytes_per_sector - 1)) {
|
||||
*p_value = p_page->p_buf[state.offset];
|
||||
offset &= p_vol->bpb.bytes_per_sector - 1;
|
||||
if (offset == (p_vol->bpb.bytes_per_sector - 1)) {
|
||||
*p_value = p_page->p_buf[offset];
|
||||
if (p_page->option == 1) {
|
||||
for (state.err = 0; (pf_u16)state.err < p_vol->bpb.num_active_FATs; state.err++) {
|
||||
VFiPFSEC_WriteFAT(p_vol, p_page->p_buf, p_page->sector + (pf_u16)state.err * p_vol->bpb.sectors_per_FAT, 0, p_vol->bpb.bytes_per_sector);
|
||||
for (err = 0; (pf_u16)err < p_vol->bpb.num_active_FATs; err++) {
|
||||
VFiPFSEC_WriteFAT(p_vol, p_page->p_buf, p_page->sector + (pf_u16)err * p_vol->bpb.sectors_per_FAT, 0, p_vol->bpb.bytes_per_sector);
|
||||
}
|
||||
}
|
||||
state.err = VFiPFSEC_ReadFAT(p_vol, p_page->p_buf, state.sector + 1, 0, p_vol->bpb.bytes_per_sector);
|
||||
if (state.err != 0) { continue; }
|
||||
p_page->sector = state.sector + 1;
|
||||
err = VFiPFSEC_ReadFAT(p_vol, p_page->p_buf, sector + 1, 0, p_vol->bpb.bytes_per_sector);
|
||||
if (err != 0) { continue; }
|
||||
p_page->sector = sector + 1;
|
||||
*p_value += (pf_u16)(*p_page->p_buf) << 8;
|
||||
} else {
|
||||
*p_value = ((pf_u16)p_page->p_buf[state.offset + 1] << 8) + p_page->p_buf[state.offset];
|
||||
*p_value = ((pf_u16)p_page->p_buf[offset + 1] << 8) + p_page->p_buf[offset];
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (state.err != 0) {
|
||||
return err;
|
||||
|
||||
#undef LOAD_FAT_SECTOR
|
||||
}
|
||||
|
||||
pf_s32 PFFAT12_ReadFATEntryWithBuf(PF_VOLUME* p_vol, pf_u16 cluster, pf_u32* p_value,
|
||||
PF_CACHE_PAGE* p_page) {
|
||||
pf_s32 err;
|
||||
|
||||
err = ReadFAT12WordWithBuf(p_vol, (pf_u16)(cluster + (cluster >> 1)), p_value, p_page);
|
||||
if (err != 0) {
|
||||
*p_value = -1;
|
||||
return state.err;
|
||||
return err;
|
||||
}
|
||||
if ((cluster & 0x01) != 0) {
|
||||
*p_value = *p_value >> 4;
|
||||
@@ -246,6 +251,4 @@ pf_s32 PFFAT12_ReadFATEntryWithBuf(PF_VOLUME* p_vol , pf_u16 cluster , pf_u32* p
|
||||
*p_value &= 0xFFF;
|
||||
}
|
||||
return 0;
|
||||
|
||||
#undef LOAD_FAT_SECTOR
|
||||
}
|
||||
|
||||
@@ -1873,10 +1873,7 @@ pf_s32 PFFILE_fappend(PFFILE_FILE* file, pf_u32 size, pf_u32* size_appended) {
|
||||
pf_s32 PFFILE_fadjust(PFFILE_FILE* file) {
|
||||
PF_VOLUME* volume = file == PF_NULL ? PF_NULL : file->p_sfd->dir_entry.p_vol;
|
||||
PFFILE_CURSOR saved_cursor;
|
||||
struct {
|
||||
PF_FAT_HINT hint;
|
||||
pf_u32 last_access_chain_index;
|
||||
} saved_hint;
|
||||
PFFILE_FAT_HINT saved_hint;
|
||||
pf_u16 access_time;
|
||||
pf_s32 error;
|
||||
|
||||
@@ -1894,8 +1891,7 @@ pf_s32 PFFILE_fadjust(PFFILE_FILE* file) {
|
||||
}
|
||||
((PFFILE_VOLUME_DIRS*)volume)->cache_signature = file;
|
||||
saved_cursor = file->cursor;
|
||||
saved_hint.hint = file->hint;
|
||||
saved_hint.last_access_chain_index = file->last_access_data.last_access.chain_index;
|
||||
saved_hint = *(PFFILE_FAT_HINT*)&file->hint;
|
||||
if ((file->open_mode & 8) == 0 && (file->open_mode & 2) != 0) {
|
||||
error = 0x0A;
|
||||
} else if ((file->p_sfd->lock.mode & 3) != 0 &&
|
||||
@@ -1907,8 +1903,7 @@ pf_s32 PFFILE_fadjust(PFFILE_FILE* file) {
|
||||
error &= (-error | error) >> 31;
|
||||
}
|
||||
file->cursor = saved_cursor;
|
||||
file->hint = saved_hint.hint;
|
||||
file->last_access_data.last_access.chain_index = saved_hint.last_access_chain_index;
|
||||
*(PFFILE_FAT_HINT*)&file->hint = saved_hint;
|
||||
((PFFILE_VOLUME_DIRS*)volume)->cache_signature = PF_NULL;
|
||||
if (error != 0) {
|
||||
pf_vol_set.last_error = error;
|
||||
@@ -1923,10 +1918,7 @@ pf_s32 PFFILE_fadjust(PFFILE_FILE* file) {
|
||||
pf_s32 PFFILE_finfo(PFFILE_FILE* file, PF_INFO* info) {
|
||||
PF_VOLUME* volume = file == PF_NULL ? PF_NULL : file->p_sfd->dir_entry.p_vol;
|
||||
PFFILE_CURSOR saved_cursor;
|
||||
struct {
|
||||
PF_FAT_HINT hint;
|
||||
pf_u32 last_access_chain_index;
|
||||
} saved_hint;
|
||||
PFFILE_FAT_HINT saved_hint;
|
||||
pf_s32 error;
|
||||
|
||||
error = PFVOL_CheckForRead(volume);
|
||||
@@ -1943,12 +1935,10 @@ pf_s32 PFFILE_finfo(PFFILE_FILE* file, PF_INFO* info) {
|
||||
}
|
||||
((PFFILE_VOLUME_DIRS*)volume)->cache_signature = file;
|
||||
saved_cursor = file->cursor;
|
||||
saved_hint.hint = file->hint;
|
||||
saved_hint.last_access_chain_index = file->last_access_data.last_access.chain_index;
|
||||
saved_hint = *(PFFILE_FAT_HINT*)&file->hint;
|
||||
error = PFFILE_p_finfo(file, info);
|
||||
file->cursor = saved_cursor;
|
||||
file->hint = saved_hint.hint;
|
||||
file->last_access_data.last_access.chain_index = saved_hint.last_access_chain_index;
|
||||
*(PFFILE_FAT_HINT*)&file->hint = saved_hint;
|
||||
((PFFILE_VOLUME_DIRS*)volume)->cache_signature = PF_NULL;
|
||||
if (error != 0) {
|
||||
pf_vol_set.last_error = error;
|
||||
|
||||
@@ -418,15 +418,13 @@ pf_s32 PFPATH_cmpNameUni(const pf_u16* name, PF_STR* pattern) {
|
||||
}
|
||||
|
||||
pf_s32 PFPATH_cmpName(const pf_s8* short_name, PF_STR* pattern, pf_u32 short_search) {
|
||||
struct {
|
||||
pf_u32 matched_end;
|
||||
pf_s8 name[0x10];
|
||||
} work;
|
||||
pf_s8* name = work.name;
|
||||
pf_s8 name_buffer[13];
|
||||
pf_u32 matched_end;
|
||||
pf_s8* name = name_buffer;
|
||||
pf_s8* name_end;
|
||||
const pf_s8* pattern_text;
|
||||
|
||||
work.matched_end = 0;
|
||||
matched_end = 0;
|
||||
pattern_text = PFSTR_GetStrPos(pattern, 3);
|
||||
pf_strcpy(name, short_name);
|
||||
if ((pf_vol_set.setting & 2) == 2 && PFSTR_GetCodeMode(pattern) == 2 && pf_strcmp(name, (const pf_s8*)".") != 0 &&
|
||||
@@ -450,7 +448,7 @@ pf_s32 PFPATH_cmpName(const pf_s8* short_name, PF_STR* pattern, pf_u32 short_sea
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return PFPATH_cmpNameImpl(work.name, pattern_text, &work.matched_end);
|
||||
return PFPATH_cmpNameImpl(name_buffer, pattern_text, &matched_end);
|
||||
}
|
||||
|
||||
pf_s32 PFPATH_cmpTailSFN(const pf_s8* sfn_name, const pf_s8* pattern) {
|
||||
|
||||
@@ -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;
|
||||
@@ -554,26 +557,24 @@ static void kbdSendKey(KBDKeyEventData* event) {
|
||||
}
|
||||
}
|
||||
|
||||
#pragma push
|
||||
#pragma ppc_iro_level 0
|
||||
static void kbd_led_handler(BOOL success, void* callbackArg) {
|
||||
const KBDLEDCallbackData* callback;
|
||||
s32 index;
|
||||
u32 err;
|
||||
index = (s32)callbackArg;
|
||||
callback = &kbdLCBuf[index];
|
||||
u32 index;
|
||||
USBKBDErr err;
|
||||
index = (u32)callbackArg;
|
||||
kbdCmdBuf[index].device = 0;
|
||||
if (callback->callbackAddress == (USBKBDCmdLEDCallback)(u32)kbdCmdBuf[(u32)callbackArg].device) {
|
||||
if (kbdLCBuf[index].callbackAddress == NULL) {
|
||||
return;
|
||||
}
|
||||
switch (success) {
|
||||
default:
|
||||
err = 7;
|
||||
break;
|
||||
case TRUE:
|
||||
if (success == TRUE) {
|
||||
err = 0;
|
||||
break;
|
||||
} else {
|
||||
err = 7;
|
||||
}
|
||||
kbdLCBuf[(u32)callbackArg].callbackAddress(err, kbdLCBuf[(u32)callbackArg].callbackArg);
|
||||
kbdLCBuf[index].callbackAddress(err, kbdLCBuf[index].callbackArg);
|
||||
}
|
||||
#pragma pop
|
||||
|
||||
USBKBDErr KBDSetLedsAsync(u32 channel, u32 leds, USBKBDCmdLEDCallback callback, void* callbackArg) {
|
||||
u8 ledBits;
|
||||
@@ -823,6 +824,8 @@ USBKBDErr KBDSetLockProcessing(u32 channel, u32 value) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#pragma push
|
||||
#pragma ppc_iro_level 1
|
||||
USBKBDErr KBDSetModState(u32 channel, u32 value) {
|
||||
if (!kbdInitialized) {
|
||||
return 2;
|
||||
@@ -839,12 +842,13 @@ USBKBDErr KBDSetModState(u32 channel, u32 value) {
|
||||
interrupts = OSDisableInterrupts();
|
||||
newState.value = value & 0xfc0;
|
||||
oldState.value = kbdData[channel].modState;
|
||||
newState.bits.physical = oldState.bits.physical;
|
||||
newState.bits.physical = oldState.value;
|
||||
kbdData[channel].modState = newState.value;
|
||||
OSRestoreInterrupts(interrupts);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#pragma pop
|
||||
|
||||
u16 KBDTranslateHidCode(u32 keyCode, u32 modifiers, s32 country) {
|
||||
s32 mask;
|
||||
|
||||
@@ -20,13 +20,221 @@
|
||||
|
||||
/* some string pooling (the first one is used but is just pooled first...)*/
|
||||
static char execFailure[] = "\nOSExec(): Failed to exec %d in %d\n";
|
||||
DECOMP_FORCE_ACTIVE(OSExec_c, "\nOSExec(): The specified game doesn't exist in the disc\n");
|
||||
|
||||
extern BOOL __OSInIPL;
|
||||
extern BOOL __OSInNandBoot;
|
||||
|
||||
BOOL __OSInReboot;
|
||||
|
||||
static volatile u32 DVDLowIntType;
|
||||
static u32 DesiredPartitionType;
|
||||
|
||||
extern void IPCReInit(void);
|
||||
extern s32 IPCCltReInit(void);
|
||||
|
||||
static void ExecLowCallback(u32 intType) {
|
||||
DVDLowIntType = intType;
|
||||
}
|
||||
|
||||
static BOOL ExecLowOk(u32 line) {
|
||||
while (DVDLowIntType == 0) {
|
||||
}
|
||||
|
||||
if (DVDLowIntType != DVD_INTTYPE_TC) {
|
||||
OSReport(execFailure, DVDLowIntType, line);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
DVDLowIntType = 0;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void __OSLaunchNextFirmware(void) {
|
||||
u8 i;
|
||||
s32 rc = -1;
|
||||
u32 ticketCnt = 1;
|
||||
ESTicketView* ticket;
|
||||
ESTicketView* diTicket;
|
||||
ESTitleId version = 0x0000000100000003;
|
||||
u32 mem2Size;
|
||||
u32 mem2End;
|
||||
DVDGameTOC* gameToc;
|
||||
DVDPartitionInfo* partInfo;
|
||||
DVDPartitionInfo* bootPart;
|
||||
DVDPartitionInfo* partPtr;
|
||||
ESTitleMeta* tmd;
|
||||
u32 numTmdBytes = 0;
|
||||
|
||||
gameToc = (DVDGameTOC*)OSAllocFromMEM1ArenaLo(OSRoundUp32B(sizeof(DVDGameTOC)), DEFAULT_ALIGN);
|
||||
partInfo = (DVDPartitionInfo*)OSAllocFromMEM1ArenaLo(OSRoundUp32B(sizeof(DVDPartitionInfo) * 256), DEFAULT_ALIGN);
|
||||
tmd = (ESTitleMeta*)OSAllocFromMEM1ArenaLo(OSRoundUp32B(sizeof(ESTitleMeta)), 64);
|
||||
diTicket = (ESTicketView*)OSAllocFromMEM1ArenaLo(OSRoundUp32B(sizeof(ESTicketView)), DEFAULT_ALIGN);
|
||||
|
||||
if (DesiredPartitionType == __OSLaunchPartitionType && *(u32*)OSPhysicalToCached(OS_ADDR_BOOT_PART_OFFSET) != 0) {
|
||||
rc = ESP_InitLib();
|
||||
if (rc == ES_ERR_OK) {
|
||||
rc = ESP_DiGetTicketView(NULL, diTicket);
|
||||
}
|
||||
if (rc == ES_ERR_OK) {
|
||||
rc = ESP_DiGetTmd(NULL, &numTmdBytes);
|
||||
}
|
||||
if (rc == ES_ERR_OK) {
|
||||
rc = ESP_DiGetTmd(tmd, &numTmdBytes);
|
||||
}
|
||||
ESP_CloseLib();
|
||||
|
||||
{
|
||||
OSPlayTimeType playType = OS_PLAYTIME_PERMANENT;
|
||||
u32 remain = 0xFFFFFFFF;
|
||||
|
||||
if (__OSGetPlayTime(diTicket, &playType, &remain) == ES_ERR_OK && playType == OS_PLAYTIME_TIME_LIMIT && remain == 0) {
|
||||
__OSWriteExpiredFlag();
|
||||
__OSReturnToMenuForError();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (rc == ES_ERR_OK) {
|
||||
bootPart = partInfo;
|
||||
bootPart->partitionType = __OSLaunchPartitionType;
|
||||
bootPart->partition = (DVDGamePartition*)*(u32*)OSPhysicalToCached(OS_ADDR_BOOT_PART_OFFSET);
|
||||
} else {
|
||||
DVDLowIntType = 0;
|
||||
DVDLowClosePartition(ExecLowCallback);
|
||||
if (!ExecLowOk(0x378)) {
|
||||
__OSReturnToMenuForError();
|
||||
}
|
||||
|
||||
DVDLowUnencryptedRead(gameToc, OSRoundUp32B(sizeof(DVDGameTOC)), 0x40000 >> 2, ExecLowCallback);
|
||||
if (!ExecLowOk(0x382)) {
|
||||
__OSReturnToMenuForError();
|
||||
}
|
||||
|
||||
DVDLowUnencryptedRead(partInfo, OSRoundUp32B(sizeof(DVDPartitionInfo) * 256), (u32)gameToc->partitionInfo, ExecLowCallback);
|
||||
if (!ExecLowOk(0x38E)) {
|
||||
__OSReturnToMenuForError();
|
||||
}
|
||||
|
||||
bootPart = NULL;
|
||||
partPtr = partInfo;
|
||||
for (i = 0; i < gameToc->partitionCount; i++) {
|
||||
if (partPtr->partitionType == DesiredPartitionType) {
|
||||
bootPart = partPtr;
|
||||
}
|
||||
partPtr++;
|
||||
}
|
||||
|
||||
if (bootPart == NULL) {
|
||||
gameToc++;
|
||||
partPtr = partInfo + 4;
|
||||
for (i = 0; i < gameToc->partitionCount; i++) {
|
||||
if (partPtr->partitionType == DesiredPartitionType) {
|
||||
bootPart = partPtr;
|
||||
}
|
||||
partPtr++;
|
||||
}
|
||||
}
|
||||
|
||||
if (bootPart == NULL) {
|
||||
OSReport("\nOSExec(): The specified game doesn't exist in the disc\n");
|
||||
__OSReturnToMenuForError();
|
||||
}
|
||||
|
||||
__OSLaunchPartitionType = bootPart->partitionType;
|
||||
*(u32*)OSPhysicalToCached(OS_ADDR_BOOT_PART_OFFSET) = (u32)bootPart->partition;
|
||||
|
||||
DVDLowIntType = 0;
|
||||
if (__OSLockedAppType == OS_APP_TYPE_DVD) {
|
||||
DVDLowOpenPartitionWithTmdAndTicketView((u32)bootPart->partition, diTicket, numTmdBytes, tmd, 0, NULL, ExecLowCallback);
|
||||
} else {
|
||||
DVDLowOpenPartition((u32)bootPart->partition, NULL, 0, NULL, tmd, ExecLowCallback);
|
||||
}
|
||||
if (!ExecLowOk(0x3CB)) {
|
||||
__OSReturnToMenuForError();
|
||||
}
|
||||
|
||||
DVDLowClosePartition(ExecLowCallback);
|
||||
if (!ExecLowOk(0x3D5)) {
|
||||
__OSReturnToMenuForError();
|
||||
}
|
||||
}
|
||||
|
||||
version = tmd->head.sysVersion;
|
||||
|
||||
rc = ESP_InitLib();
|
||||
if (rc != ES_ERR_OK) {
|
||||
OSReport(execFailure, rc, 0x3E0);
|
||||
__OSHotResetForError();
|
||||
}
|
||||
|
||||
rc = ESP_GetTicketViews(version, NULL, &ticketCnt);
|
||||
if (ticketCnt != 1 || rc != ES_ERR_OK) {
|
||||
OSReport(execFailure, rc, 0x3E9);
|
||||
__OSHotResetForError();
|
||||
}
|
||||
|
||||
ticket = (ESTicketView*)OSAllocFromMEM1ArenaLo(OSRoundUp32B(sizeof(ESTicketView) * ticketCnt), DEFAULT_ALIGN);
|
||||
rc = ESP_GetTicketViews(version, ticket, &ticketCnt);
|
||||
if (rc != ES_ERR_OK) {
|
||||
OSReport(execFailure, rc, 0x3F2);
|
||||
__OSHotResetForError();
|
||||
}
|
||||
|
||||
DVDLowFinalize();
|
||||
|
||||
mem2Size = *(u32*)OSPhysicalToCached(OS_ADDR_SIMULATED_MEM2_SIZE);
|
||||
mem2End = *(u32*)OSPhysicalToCached(OS_ADDR_ACCESSIBLE_MEM2);
|
||||
DCStoreRange(OSPhysicalToCached(OS_ADDR_PHYSICAL_MEM1_SIZE), OS_ADDR_MEMORY_MAP_SIZE);
|
||||
|
||||
rc = ESP_LaunchTitle(version, ticket);
|
||||
if (rc != ES_ERR_OK) {
|
||||
OSReport(execFailure, rc, 0x402);
|
||||
__OSHotResetForError();
|
||||
}
|
||||
|
||||
ESP_CloseLib();
|
||||
DCInvalidateRange(OSPhysicalToCached(OS_ADDR_PHYSICAL_MEM1_SIZE), OS_ADDR_MEMORY_MAP_SIZE);
|
||||
|
||||
if (mem2Size < *(u32*)OSPhysicalToCached(OS_ADDR_SIMULATED_MEM2_SIZE)) {
|
||||
*(u32*)OSPhysicalToCached(OS_ADDR_ACCESSIBLE_MEM2) =
|
||||
mem2Size - (*(u32*)OSPhysicalToCached(OS_ADDR_SIMULATED_MEM2_SIZE) - *(u32*)OSPhysicalToCached(OS_ADDR_ACCESSIBLE_MEM2));
|
||||
*(u32*)OSPhysicalToCached(OS_ADDR_AVAILABLE_MEM2_END) =
|
||||
mem2Size - (*(u32*)OSPhysicalToCached(OS_ADDR_SIMULATED_MEM2_SIZE) - *(u32*)OSPhysicalToCached(OS_ADDR_AVAILABLE_MEM2_END));
|
||||
*(u32*)OSPhysicalToCached(OS_ADDR_IPC_BUFFER_START) =
|
||||
mem2Size - (*(u32*)OSPhysicalToCached(OS_ADDR_SIMULATED_MEM2_SIZE) - *(u32*)OSPhysicalToCached(OS_ADDR_IPC_BUFFER_START));
|
||||
*(u32*)OSPhysicalToCached(OS_ADDR_IPC_BUFFER_END) =
|
||||
mem2Size - (*(u32*)OSPhysicalToCached(OS_ADDR_SIMULATED_MEM2_SIZE) - *(u32*)OSPhysicalToCached(OS_ADDR_IPC_BUFFER_END));
|
||||
*(u32*)OSPhysicalToCached(OS_ADDR_SIMULATED_MEM2_SIZE) = mem2Size;
|
||||
}
|
||||
|
||||
if (mem2End < *(u32*)OSPhysicalToCached(OS_ADDR_ACCESSIBLE_MEM2)) {
|
||||
__OSInitMemoryProtection();
|
||||
}
|
||||
|
||||
__OSInitIPCBuffer();
|
||||
IPCReInit();
|
||||
IPCCltReInit();
|
||||
|
||||
DVDLowInit();
|
||||
DVDLowIntType = 0;
|
||||
{
|
||||
DVDDiskID diskId;
|
||||
DVDLowReadDiskID(&diskId, ExecLowCallback);
|
||||
}
|
||||
if (!ExecLowOk(0x42E)) {
|
||||
__OSReturnToMenuForError();
|
||||
}
|
||||
|
||||
if (__OSLockedAppType == OS_APP_TYPE_DVD) {
|
||||
DVDLowOpenPartitionWithTmdAndTicketView((u32)bootPart->partition, diTicket, numTmdBytes, tmd, 0, NULL, ExecLowCallback);
|
||||
} else {
|
||||
DVDLowOpenPartition((u32)bootPart->partition, NULL, 0, NULL, tmd, ExecLowCallback);
|
||||
}
|
||||
if (!ExecLowOk(0x445)) {
|
||||
__OSReturnToMenuForError();
|
||||
}
|
||||
}
|
||||
|
||||
#define BI2_ROUND(x, a) (((x) & ~((a) - 1)))
|
||||
|
||||
BOOL PackArgs(void* addr, int argc, char** argv) {
|
||||
@@ -493,11 +701,95 @@ void __OSReturnToMenul(u32 launchArg, const char* arg0, ...) {
|
||||
__OSReturnToMenuForError();
|
||||
}
|
||||
|
||||
/* more string pooling...*/
|
||||
DECOMP_FORCE_ACTIVE(OSExec_c, "OSLaunchDisk(): You can't call this API from DVD application. \n");
|
||||
DECOMP_FORCE_ACTIVE(OSExec_c, "OSLaunchDisk(): You must call DVDPrepareDisk before launching disc.\n");
|
||||
DECOMP_FORCE_ACTIVE(OSExec_c, "OSLaunchDisk(): Specified id is different from one specified to DVDPrepareDisk.\n");
|
||||
DECOMP_FORCE_ACTIVE(OSExec_c, "0000000000000000");
|
||||
DECOMP_FORCE_ACTIVE(OSExec_c, "2004/02/01");
|
||||
DECOMP_FORCE_ACTIVE(OSExec_c, "OSLaunchPartition(): You can't call this API from NAND application. \n");
|
||||
DECOMP_FORCE_ACTIVE(OSExec_c, "OSLaunchPartition(): Specified title ID is not DISC application. \n");
|
||||
static void OSLaunchDiskv(const DVDDiskID* id, u32 launchCode, const char** argv) {
|
||||
char idBuf[20];
|
||||
ESTitleId titleId ALIGN32;
|
||||
|
||||
if (OSGetAppType() == OS_APP_TYPE_DVD) {
|
||||
OSReport("OSLaunchDisk(): You can't call this API from DVD application. \n");
|
||||
__OSReturnToMenuForError();
|
||||
}
|
||||
|
||||
if (DVDGetCurrentDiskID()->gameName[0] == '\0') {
|
||||
OSReport("OSLaunchDisk(): You must call DVDPrepareDisk before launching disc.\n");
|
||||
__OSReturnToMenuForError();
|
||||
}
|
||||
|
||||
if (id != NULL && !DVDCompareDiskID(id, DVDGetCurrentDiskID())) {
|
||||
OSReport("OSLaunchDisk(): Specified id is different from one specified to DVDPrepareDisk.\n");
|
||||
__OSReturnToMenuForError();
|
||||
}
|
||||
|
||||
strcpy(idBuf, "0000000000000000");
|
||||
if (argv != NULL && argv[0] != NULL) {
|
||||
strncpy(idBuf, argv[0], 16);
|
||||
idBuf[16] = '\0';
|
||||
}
|
||||
if (launchCode == 0xA0000000 && ESP_GetTitleId(&titleId) == ES_ERR_OK) {
|
||||
sprintf(idBuf, "%016llx", titleId);
|
||||
}
|
||||
if (idBuf[0] == '\0') {
|
||||
__OSReturnToMenuForError();
|
||||
}
|
||||
|
||||
DesiredPartitionType = 0;
|
||||
__OSLaunchNextFirmware();
|
||||
}
|
||||
|
||||
void OSLaunchDisk(const DVDDiskID* id, u32 launchCode, const char* firstArg, ...) {
|
||||
char** argv;
|
||||
|
||||
__COPY_VA_ARGS_TO_ARRAY(firstArg, argv);
|
||||
OSLaunchDiskv(id, launchCode, (const char**)argv);
|
||||
}
|
||||
|
||||
BOOL IsNewApploader(const char* date) {
|
||||
if (strncmp(date, "2004/02/01", 10) > 0) {
|
||||
return TRUE;
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
static void OSLaunchPartitionv(ESTitleId titleId, u32 launchCode, const char** argv) {
|
||||
u8* bi2;
|
||||
int argc = 0;
|
||||
int i;
|
||||
char** argList;
|
||||
|
||||
if (OSGetAppType() != OS_APP_TYPE_DVD) {
|
||||
OSReport("OSLaunchPartition(): You can't call this API from NAND application. \n");
|
||||
__OSReturnToMenuForError();
|
||||
}
|
||||
|
||||
if (NANDTitleIdHi(titleId) != 0x00010000) {
|
||||
OSReport("OSLaunchPartition(): Specified title ID is not DISC application. \n");
|
||||
__OSReturnToMenuForError();
|
||||
}
|
||||
|
||||
if (argv != NULL) {
|
||||
while (argv[argc] != NULL) {
|
||||
argc++;
|
||||
}
|
||||
}
|
||||
|
||||
bi2 = (u8*)OSAllocFromMEM1ArenaLo(0x2000, 64);
|
||||
argList = (char**)OSAllocFromMEM1ArenaLo((argc + 1) * sizeof(char*), 1);
|
||||
for (i = 0; i < argc; i++) {
|
||||
argList[i] = (char*)argv[i];
|
||||
}
|
||||
argList[argc] = NULL;
|
||||
PackArgs(bi2, argc, argList);
|
||||
*(u32*)OSPhysicalToCached(OS_ADDR_NAND_TITLE_LAUNCH_CODE) = launchCode;
|
||||
*(u32*)OSPhysicalToCached(OS_ADDR_LAUNCH_EXEC_PARAMS) = (u32)bi2;
|
||||
|
||||
DesiredPartitionType = NANDTitleIdLo(titleId);
|
||||
__OSLaunchNextFirmware();
|
||||
}
|
||||
|
||||
void OSLaunchPartition(ESTitleId titleId, u32 launchCode, const char* firstArg, ...) {
|
||||
char** argv;
|
||||
|
||||
__COPY_VA_ARGS_TO_ARRAY(firstArg, argv);
|
||||
OSLaunchPartitionv(titleId, launchCode, (const char**)argv);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,23 @@
|
||||
#include <private/os.h>
|
||||
#include <revolution/os.h>
|
||||
#include <revolution/nwc24/NWC24Err.h>
|
||||
|
||||
NWC24Err NWC24iPrepareShutdown(void) NO_INLINE;
|
||||
s32 NWC24SuspendScheduler(void) NO_INLINE;
|
||||
s32 NWC24ResumeScheduler(void) NO_INLINE;
|
||||
|
||||
#include <private/nwc24.h>
|
||||
#include <revolution/nwc24.h>
|
||||
|
||||
static s32 nwc24ShtFd = -1;
|
||||
static s32 nwc24ShtRetryRest;
|
||||
static OSShutdownFunctionInfo ShutdownFuncInfo;
|
||||
|
||||
static NWC24Err CheckCallingStatus(const char* callerName) NO_INLINE;
|
||||
BOOL NWC24Shutdown_(BOOL final, u32 event) NO_INLINE;
|
||||
NWC24Err NWC24iRequestShutdown(u32 event, s32* result) NO_INLINE;
|
||||
NWC24Err NWC24iSetRtcCounter_(s32 rtc, BOOL save) NO_INLINE;
|
||||
|
||||
void __OSInitNet() {
|
||||
NWC24Err ret;
|
||||
OSIOSRev iosRev;
|
||||
@@ -38,11 +52,157 @@ s32 __OSSyncTimeWithNetRM() {
|
||||
return NWC24iSynchronizeRtcCounter(FALSE);
|
||||
}
|
||||
|
||||
DECOMP_FORCE_ACTIVE(OSNet_c, "NWC24iPrepareShutdown");
|
||||
DECOMP_FORCE_ACTIVE(OSNet_c, "/dev/net/kd/request");
|
||||
DECOMP_FORCE_ACTIVE(OSNet_c, "NWC24SuspendScheduler");
|
||||
DECOMP_FORCE_ACTIVE(OSNet_c, "NWC24ResumeScheduler");
|
||||
DECOMP_FORCE_ACTIVE(OSNet_c, "NWC24iRequestShutdown");
|
||||
DECOMP_FORCE_ACTIVE(OSNet_c, "NWC24Shutdown_: Give up!\n"); // Give up!
|
||||
DECOMP_FORCE_ACTIVE(OSNet_c, "NWC24iSetRtcCounter_");
|
||||
DECOMP_FORCE_ACTIVE(OSNet_c, "/dev/net/kd/time");
|
||||
static NWC24Err CheckCallingStatus(const char* callerName) NO_INLINE {
|
||||
if (OSGetCurrentThread() == 0) {
|
||||
return NWC24_ERR_FATAL;
|
||||
}
|
||||
|
||||
return NWC24_OK;
|
||||
}
|
||||
|
||||
DECL_WEAK NWC24Err NWC24iPrepareShutdown(void) NO_INLINE {
|
||||
NWC24Err result = NWC24_OK;
|
||||
|
||||
ShutdownFuncInfo.func = NWC24Shutdown_;
|
||||
ShutdownFuncInfo.priority = 110;
|
||||
OSRegisterShutdownFunction(&ShutdownFuncInfo);
|
||||
|
||||
if (nwc24ShtFd < 0) {
|
||||
result = NWC24iOpenResourceManager("NWC24iPrepareShutdown", "/dev/net/kd/request", &nwc24ShtFd, 1);
|
||||
}
|
||||
|
||||
nwc24ShtRetryRest = 5;
|
||||
|
||||
if (result == NWC24_OK) {
|
||||
result = 1;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
DECL_WEAK s32 NWC24SuspendScheduler(void) NO_INLINE {
|
||||
static u8 susResult[0x20] ALIGN32;
|
||||
NWC24Err result;
|
||||
NWC24Err closeResult;
|
||||
s32 fd;
|
||||
|
||||
result = CheckCallingStatus("NWC24SuspendScheduler");
|
||||
if (result < NWC24_OK) {
|
||||
return result;
|
||||
}
|
||||
|
||||
result = NWC24iOpenResourceManager("NWC24SuspendScheduler", "/dev/net/kd/request", &fd, 0);
|
||||
if (result >= NWC24_OK) {
|
||||
result = NWC24iIoctlResourceManager("NWC24SuspendScheduler", fd, NWC24_IOCTL_SUSPEND_SCHEDULER, NULL, 0, susResult, sizeof(susResult));
|
||||
if (result >= NWC24_OK) {
|
||||
result = *(NWC24Err*)susResult;
|
||||
}
|
||||
|
||||
closeResult = NWC24iCloseResourceManager("NWC24SuspendScheduler", fd);
|
||||
if (closeResult < NWC24_OK) {
|
||||
result = closeResult;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
DECL_WEAK s32 NWC24ResumeScheduler(void) NO_INLINE {
|
||||
static u8 resResult[0x20] ALIGN32;
|
||||
NWC24Err result;
|
||||
NWC24Err closeResult;
|
||||
s32 fd;
|
||||
|
||||
result = CheckCallingStatus("NWC24ResumeScheduler");
|
||||
if (result < NWC24_OK) {
|
||||
return result;
|
||||
}
|
||||
|
||||
result = NWC24iOpenResourceManager("NWC24ResumeScheduler", "/dev/net/kd/request", &fd, 0);
|
||||
if (result >= NWC24_OK) {
|
||||
result = NWC24iIoctlResourceManager("NWC24ResumeScheduler", fd, NWC24_IOCTL_RESUME_SCHEDULER, NULL, 0, resResult, sizeof(resResult));
|
||||
if (result >= NWC24_OK) {
|
||||
result = *(NWC24Err*)resResult;
|
||||
}
|
||||
|
||||
closeResult = NWC24iCloseResourceManager("NWC24ResumeScheduler", fd);
|
||||
if (closeResult < NWC24_OK) {
|
||||
result = closeResult;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
NWC24Err NWC24iRequestShutdown(u32 event, s32* result) NO_INLINE {
|
||||
static u32 shtBuffer[8] ALIGN32;
|
||||
static u32 shtResult[8] ALIGN32;
|
||||
|
||||
shtBuffer[0] = event;
|
||||
return NWC24iIoctlResourceManagerAsync("NWC24iRequestShutdown", nwc24ShtFd, NWC24_IOCTL_SHUTDOWN, shtBuffer, sizeof(shtBuffer), shtResult,
|
||||
sizeof(shtResult), result);
|
||||
}
|
||||
|
||||
BOOL NWC24Shutdown_(BOOL final, u32 event) NO_INLINE {
|
||||
static BOOL shuttingdown;
|
||||
static s32 result;
|
||||
|
||||
if (final) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (shuttingdown) {
|
||||
if (NWC24iIsAsyncRequestPending()) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (result >= 0) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (nwc24ShtRetryRest > 0) {
|
||||
shuttingdown = FALSE;
|
||||
nwc24ShtRetryRest--;
|
||||
} else {
|
||||
OSReport("NWC24Shutdown_: Give up!\n");
|
||||
return TRUE;
|
||||
}
|
||||
} else if (NWC24iRequestShutdown(event, &result) >= NWC24_OK) {
|
||||
shuttingdown = TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static u32 nwc24TimeCommonBuffer[8] ALIGN32;
|
||||
static u32 nwc24TimeCommonResult[8] ALIGN32;
|
||||
|
||||
NWC24Err NWC24iSetRtcCounter_(s32 rtc, BOOL save) NO_INLINE {
|
||||
NWC24Err result;
|
||||
NWC24Err closeResult;
|
||||
s32 fd;
|
||||
|
||||
result = CheckCallingStatus("NWC24iSetRtcCounter_");
|
||||
if (result < NWC24_OK) {
|
||||
return result;
|
||||
}
|
||||
|
||||
result = NWC24iOpenResourceManager("NWC24iSetRtcCounter_", "/dev/net/kd/time", &fd, 0);
|
||||
if (result >= NWC24_OK) {
|
||||
nwc24TimeCommonBuffer[0] = rtc;
|
||||
nwc24TimeCommonBuffer[1] = save;
|
||||
|
||||
result = NWC24iIoctlResourceManager("NWC24iSetRtcCounter_", fd, NWC24_IOCTL_SET_RTC_COUNTER, nwc24TimeCommonBuffer,
|
||||
sizeof(nwc24TimeCommonBuffer), nwc24TimeCommonResult, sizeof(nwc24TimeCommonResult));
|
||||
if (result >= NWC24_OK) {
|
||||
result = *(s32*)nwc24TimeCommonResult;
|
||||
}
|
||||
|
||||
closeResult = NWC24iCloseResourceManager("NWC24iSetRtcCounter_", fd);
|
||||
if (result >= NWC24_OK) {
|
||||
result = closeResult;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -66,8 +66,6 @@ vBOOL __OSIsReturnToIdle;
|
||||
static char resetSource[] = "OSReset.c";
|
||||
static char hotResetFailure[] = "__OSHotReset(): Falied to reset system.\n";
|
||||
|
||||
DECOMP_FORCE_ACTIVE(OSReset_c, "OSReturnToMenu(): Falied to boot system menu.\n");
|
||||
|
||||
void __OSReturnToMenu(u8 menuMode) {
|
||||
OSStateFlags state;
|
||||
|
||||
@@ -89,6 +87,11 @@ void __OSReturnToMenu(u8 menuMode) {
|
||||
__OSHotResetForError();
|
||||
}
|
||||
|
||||
DECL_WEAK void OSReturnToMenu(void) {
|
||||
__OSReturnToMenu(OS_STATE_FLAGS_MENUMODE_MENU);
|
||||
OSPanic(resetSource, __LINE__, "OSReturnToMenu(): Falied to boot system menu.\n");
|
||||
}
|
||||
|
||||
void OSReturnToDataManager(void) {
|
||||
__OSReturnToMenu(OS_STATE_FLAGS_MENUMODE_DATA_MANAGER);
|
||||
OSPanic(resetSource, __LINE__, "OSReturnToDataManager(): Falied to boot system menu.\n");
|
||||
|
||||
@@ -83,8 +83,10 @@ typedef struct WADFileHeader {
|
||||
u8 reserved_0x60[0x20];
|
||||
} WADFileHeader;
|
||||
|
||||
typedef struct WADBootImportParts {
|
||||
s32 headerInfo[2];
|
||||
typedef struct WADImportParts {
|
||||
s32 type;
|
||||
u16 cidxMode;
|
||||
u16 version;
|
||||
u32 certificateSize;
|
||||
void* certificates;
|
||||
u32 crlSize;
|
||||
@@ -93,7 +95,7 @@ typedef struct WADBootImportParts {
|
||||
void* ticket;
|
||||
u32 titleMetaSize;
|
||||
void* titleMeta;
|
||||
} WADBootImportParts;
|
||||
} WADImportParts;
|
||||
|
||||
typedef struct WADBackupFileHeader {
|
||||
u32 magic;
|
||||
@@ -3397,7 +3399,7 @@ static s32 _WADCleanTmpDir(MEMAllocator* allocator) {
|
||||
|
||||
s32 WADImportDVDForBS(const char* path, void* buffer, u32 bufferSize) {
|
||||
DVDFileInfo fileInfo;
|
||||
WADBootImportParts parts;
|
||||
WADImportParts parts;
|
||||
WADHeader* header;
|
||||
u8* readBuffer;
|
||||
BOOL fileOpened = FALSE;
|
||||
@@ -3433,14 +3435,14 @@ s32 WADImportDVDForBS(const char* path, void* buffer, u32 bufferSize) {
|
||||
|
||||
memset(&parts, 0, sizeof(parts));
|
||||
header = (WADHeader*)readBuffer;
|
||||
result = WAD_815C2F44(header, parts.headerInfo);
|
||||
result = WAD_815C2F44(header, &parts.type);
|
||||
if (result != 2) {
|
||||
OSReport("%s:%d Format should be iRD format: %s\n", __func__, 0x17D2,
|
||||
path);
|
||||
result = -3000;
|
||||
goto cleanup;
|
||||
}
|
||||
if (parts.headerInfo[0] == 3) {
|
||||
if (parts.type == 3) {
|
||||
sectionOffset = (header->hdrSize + 0x3F) & ~0x3F;
|
||||
if (header->certSize != 0) {
|
||||
parts.certificateSize = header->certSize;
|
||||
@@ -3496,19 +3498,7 @@ cleanup:
|
||||
s32 WADImportDVDExForBS(const char* path, void* buffer, u32 bufferSize) {
|
||||
WADHeader header ALIGN32;
|
||||
DVDFileInfo fileInfo;
|
||||
struct {
|
||||
s32 type;
|
||||
u16 cidxMode;
|
||||
u16 version;
|
||||
u32 certificateSize;
|
||||
void* certificates;
|
||||
u32 crlSize;
|
||||
void* crls;
|
||||
u32 ticketSize;
|
||||
void* ticket;
|
||||
u32 titleMetaSize;
|
||||
void* titleMeta;
|
||||
} parts;
|
||||
WADImportParts parts;
|
||||
BOOL fileOpened = FALSE;
|
||||
s32 result;
|
||||
u8* contentBuffer;
|
||||
|
||||
@@ -1628,7 +1628,11 @@ BOOL WUDStartSyncSpDevice(u8 type) {
|
||||
|
||||
return busy;
|
||||
}
|
||||
DECOMP_FORCE_ACTIVE(WUD_c2, "WUDCancelSyncDevice()\n");
|
||||
|
||||
BOOL WUDCancelSyncDevice(void) {
|
||||
WUD_DEBUGPrint("WUDCancelSyncDevice()\n");
|
||||
return StopSync();
|
||||
}
|
||||
|
||||
BOOL WUDStopSyncSimple() {
|
||||
return StopSync();
|
||||
|
||||
@@ -312,7 +312,9 @@ void CDBConvEpochValueToDate(CDBDate epoch, int* year, int* month, int* day, int
|
||||
|
||||
void CDBConvKeyStrToFullPath_(char* keyString, char* fullPath, CDBLocation location, u64* wiiId);
|
||||
|
||||
DECOMP_FORCE_ACTIVE(CDBConv_c, "%04d%02d%02d");
|
||||
void CDBConvDateValueToDateStr(char* dateStr, int year, int month, int day) {
|
||||
sprintf(dateStr, "%04d%02d%02d", year, month, day);
|
||||
}
|
||||
|
||||
CDBErr CDBConvKeyToFullPath(CDBRecordKey* recordKey, char* fullPath) {
|
||||
BOOL ret = CDBRecordKeyIsValid(recordKey);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include <private/cdb.h>
|
||||
#include <revolution/cdb.h>
|
||||
|
||||
#include <private/nand.h>
|
||||
#include <revolution/vf.h>
|
||||
|
||||
#include <string.h>
|
||||
@@ -10,13 +11,50 @@ char CDB_WIIID_DAT_PATH[NAND_MAX_PATH];
|
||||
char CDB_VFF_FILE_NAME[NAND_MAX_PATH];
|
||||
u32 CDB_VFF_FILE_SIZE;
|
||||
|
||||
// Left over unused logs
|
||||
DECOMP_FORCE_ACTIVE(CDBFileSystem_c, "NANDCreateDir %s\n");
|
||||
DECOMP_FORCE_ACTIVE(CDBFileSystem_c, "NANDCreateDir() error = %d\n");
|
||||
DECOMP_FORCE_ACTIVE(CDBFileSystem_c, "NANDPrivateGetStatus %s = %d\n");
|
||||
DECOMP_FORCE_ACTIVE(CDBFileSystem_c, "ownerId=%u, groupId=%u, attribute=%u, permission=");
|
||||
DECOMP_FORCE_ACTIVE(CDBFileSystem_c, "(other-group-owner)\n");
|
||||
DECOMP_FORCE_ACTIVE(CDBFileSystem_c, "nocopy/cdbwiiid.dat");
|
||||
s32 CDBFSCreateDirNAND(const char* path, u8 perm, u8 attr) {
|
||||
s32 result;
|
||||
|
||||
CDBReportInfo("NANDCreateDir %s\n", path);
|
||||
result = NANDCreateDir(path, perm, attr);
|
||||
if (result != NAND_RESULT_OK) {
|
||||
CDBReportInfo("NANDCreateDir() error = %d\n", result);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void CDBFSReportNANDPermission(u8 permission);
|
||||
|
||||
void CDBFSReportNANDStatus(const char* path) {
|
||||
NANDStatus status;
|
||||
s32 result;
|
||||
|
||||
result = NANDPrivateGetStatus(path, &status);
|
||||
CDBReportInfo("NANDPrivateGetStatus %s = %d\n", path, result);
|
||||
if (result != NAND_RESULT_OK) {
|
||||
return;
|
||||
}
|
||||
|
||||
CDBReportInfo("ownerId=%u, groupId=%u, attribute=%u, permission=", status.ownerId, status.groupId, status.attribute);
|
||||
CDBFSReportNANDPermission(status.permission);
|
||||
}
|
||||
|
||||
void CDBFSReportNANDPermission(u8 permission) {
|
||||
char text[7];
|
||||
|
||||
text[0] = (permission & NAND_PERM_BOTH_READ) ? 'r' : '-';
|
||||
text[1] = (permission & NAND_PERM_BOTH_WRITE) ? 'w' : '-';
|
||||
text[2] = (permission & NAND_PERM_GROUP_READ) ? 'r' : '-';
|
||||
text[3] = (permission & NAND_PERM_GROUP_WRITE) ? 'w' : '-';
|
||||
text[4] = (permission & NAND_PERM_USER_READ) ? 'r' : '-';
|
||||
text[5] = (permission & NAND_PERM_USER_WRITE) ? 'w' : '-';
|
||||
text[6] = '\0';
|
||||
CDBReportInfo(text);
|
||||
CDBReportInfo("(other-group-owner)\n");
|
||||
}
|
||||
|
||||
void CDBFSReportWiiIdDat(void) {
|
||||
CDBFSReportNANDStatus("nocopy/cdbwiiid.dat");
|
||||
}
|
||||
|
||||
// These ones are used but they are pooled somewhere else
|
||||
static char mountError[] = "VFMountDriveNANDFlashEx VFErr=%d(%s)\n";
|
||||
@@ -98,10 +136,15 @@ static inline CDBErr CDBFSInitVFFile(void* cacheBuffer, u32 cacheSize) {
|
||||
return CDBSetVFSyncMode(0);
|
||||
}
|
||||
|
||||
// More unused
|
||||
DECOMP_FORCE_ACTIVE(CDBFileSystem_c, "NANDPrivateDelete %s-->\n");
|
||||
DECOMP_FORCE_ACTIVE(CDBFileSystem_c, "NANDPrivateDelete=%d\n");
|
||||
DECOMP_FORCE_ACTIVE(CDBFileSystem_c, "<--NANDPrivateDelete\n");
|
||||
s32 CDBFSDeleteNAND(const char* path) {
|
||||
s32 result;
|
||||
|
||||
CDBReportInfo("NANDPrivateDelete %s-->\n", path);
|
||||
result = NANDPrivateDelete(path);
|
||||
CDBReportInfo("NANDPrivateDelete=%d\n", result);
|
||||
CDBReportInfo("<--NANDPrivateDelete\n");
|
||||
return result;
|
||||
}
|
||||
|
||||
CDBErr CDBFSInit(void* cacheBuffer, u32 cacheSize) {
|
||||
VFErr vfErr;
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
void* NHTTPi_memcpy(void*, const void*, u32);
|
||||
s32 NHTTPi_SocRecv(void*, NHTTPRequestInfo*, s32, void*, s32, s32);
|
||||
|
||||
#define NHTTPi_TOLOWER(c) ((((c) >= 'A') & ((c) <= 'Z')) ? (c) + ('a' - 'A') : (c))
|
||||
|
||||
static void FindHeaderBlock(const NHTTPResponseInfo* response, s32 position, NHTTPi_HDRBUFLIST** block, s32* offset) {
|
||||
if(position<NHTTP_HDRRECVBUF_INILEN) { *offset=position; *block=NULL; }
|
||||
else {
|
||||
@@ -22,10 +24,6 @@ static int ReadHeaderChar(const NHTTPResponseInfo* response, NHTTPi_HDRBUFLIST**
|
||||
return (*block)->block[(*offset)++];
|
||||
}
|
||||
|
||||
static int LowerCase(int character) {
|
||||
return ((character >= 'A') & (character <= 'Z')) ? character + ('a' - 'A') : character;
|
||||
}
|
||||
|
||||
s32 NHTTPi_findNextLineHdrRecvBuf(const NHTTPResponseInfo* response, s32 position, s32 limit, s32* colon, s32* newlineLength) {
|
||||
NHTTPi_HDRBUFLIST* block;
|
||||
s32 offset;
|
||||
@@ -75,16 +73,48 @@ s32 NHTTPi_skipSpaceHdrRecvBuf(const NHTTPResponseInfo* response, s32 position,
|
||||
s32 NHTTPi_compareTokenN_HdrRecvBuf(const NHTTPResponseInfo* response, s32 position, s32 limit, const char* token, s8 delimiter) {
|
||||
NHTTPi_HDRBUFLIST* block;
|
||||
s32 offset;
|
||||
int character;
|
||||
s32 i;
|
||||
s32 tokenChar;
|
||||
s32 character;
|
||||
|
||||
if (position < limit) {
|
||||
FindHeaderBlock(response, position, &block, &offset);
|
||||
character = ReadHeaderChar(response, &block, &offset);
|
||||
while (LowerCase((s8)character) == LowerCase(*token)) {
|
||||
if (*token == 0 || *token == ' ' || *token == delimiter || position == limit - 1) return 0;
|
||||
character = ReadHeaderChar(response, &block, &offset);
|
||||
++position;
|
||||
++token;
|
||||
|
||||
if (block == NULL) {
|
||||
if (offset < NHTTP_HDRRECVBUF_INILEN) {
|
||||
character = (s8)response->hdrBufFirst[offset++];
|
||||
goto compare_characters;
|
||||
}
|
||||
block = response->hdrBufBlock_p;
|
||||
offset = 0;
|
||||
} else if (offset == NHTTP_HDRRECVBUF_BLOCKLEN) {
|
||||
offset = 0;
|
||||
block = block->next_p;
|
||||
}
|
||||
character = block->block[offset++];
|
||||
|
||||
compare_characters:
|
||||
i = position;
|
||||
while (NHTTPi_TOLOWER((s8)character) == NHTTPi_TOLOWER((s8)*token)) {
|
||||
tokenChar = (s8)*token;
|
||||
if (tokenChar == '\0' || tokenChar == ' ' || tokenChar == delimiter || i == limit - 1) return 0;
|
||||
|
||||
if (block == NULL) {
|
||||
if (offset < NHTTP_HDRRECVBUF_INILEN) {
|
||||
character = (s8)response->hdrBufFirst[offset++];
|
||||
goto advance_token;
|
||||
}
|
||||
block = response->hdrBufBlock_p;
|
||||
offset = 0;
|
||||
} else if (offset == NHTTP_HDRRECVBUF_BLOCKLEN) {
|
||||
offset = 0;
|
||||
block = block->next_p;
|
||||
}
|
||||
character = block->block[offset++];
|
||||
|
||||
advance_token:
|
||||
i++;
|
||||
token++;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#include <revolution/types.h>
|
||||
#include <string.h>
|
||||
|
||||
#define NHTTPi_TOLOWER(c) ((((c) >= 'A') & ((c) <= 'Z')) ? (c) + ('a' - 'A') : (c))
|
||||
|
||||
void* NHTTPi_memcpy(void* destination, const void* source, u32 size)
|
||||
{
|
||||
return memcpy(destination, source, size);
|
||||
@@ -26,28 +28,33 @@ static int LowerCase(int character)
|
||||
return ((character >= 'A') & (character <= 'Z')) ? character + 32 : character;
|
||||
}
|
||||
|
||||
s32 NHTTPi_strnicmp(const char* left, const char* right, s32 length)
|
||||
s32 NHTTPi_strnicmp(const char* left, const char* right, s32 size)
|
||||
{
|
||||
while (length > 0)
|
||||
char leftChar;
|
||||
char rightChar;
|
||||
|
||||
while (size > 0)
|
||||
{
|
||||
int a = *left++, b = *right++;
|
||||
if (a == 0 || b == 0)
|
||||
leftChar = *left++;
|
||||
rightChar = *right++;
|
||||
|
||||
if (leftChar == '\0' || rightChar == '\0')
|
||||
{
|
||||
if (a == 0 && b == 0)
|
||||
if (leftChar == '\0' && rightChar == '\0')
|
||||
{
|
||||
length = 0;
|
||||
size = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
b = LowerCase(b);
|
||||
a = LowerCase(a);
|
||||
if (a != b)
|
||||
|
||||
if (NHTTPi_TOLOWER(leftChar) != NHTTPi_TOLOWER(rightChar))
|
||||
{
|
||||
break;
|
||||
}
|
||||
--length;
|
||||
size--;
|
||||
}
|
||||
return length;
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
static BOOL UrlPlain(int character)
|
||||
@@ -237,18 +244,18 @@ s32 NHTTPi_intToStr(char* destination, u32 value)
|
||||
return length + 1;
|
||||
}
|
||||
|
||||
s32 NHTTPi_compareToken(const char* left, const char* right)
|
||||
s32 NHTTPi_compareToken(const char* string, const char* token)
|
||||
{
|
||||
u32 rawLeft;
|
||||
while (LowerCase((s8)(rawLeft = *(const u8*)left)) == LowerCase((s8)*(const u8*)right))
|
||||
while (NHTTPi_TOLOWER(*string) == NHTTPi_TOLOWER(*token))
|
||||
{
|
||||
if ((s8)rawLeft == 0 || (s8)rawLeft == ' ')
|
||||
if (*string == '\0' || *string == ' ')
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
++left;
|
||||
++right;
|
||||
string++;
|
||||
token++;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include <revolution/nwc24.h>
|
||||
|
||||
static const u8 TtableInv[] = {13, 5, 9, 7, 0, 15, 10, 2, 12, 3, 14, 1, 8, 6, 11, 4};
|
||||
static const u8 ExcTable[] = {1, 5, 0, 4, 2, 3, 6, 7};
|
||||
extern void _savegpr_27(void);
|
||||
extern void _restgpr_27(void);
|
||||
extern void __shr2u(void);
|
||||
@@ -53,166 +54,34 @@ NWC24Err NWC24iCheckUserIdCRC(NWC24UserId id) {
|
||||
return NWC24_OK;
|
||||
}
|
||||
|
||||
static asm NWC24UserId getUnScrambleId(register NWC24UserId id) {
|
||||
li r9,-1
|
||||
lis r7,0x20
|
||||
lis r6,0x5e5e
|
||||
stwu r1,-0x20(r1)
|
||||
subi r7,r7,1
|
||||
and r8,r4,r9
|
||||
addi r0,r6,0x5e5e
|
||||
stw r31,0x1c(r1)
|
||||
and r3,r3,r7
|
||||
lis r5,-1
|
||||
xor r8,r8,r0
|
||||
stw r30,0x18(r1)
|
||||
and r8,r8,r9
|
||||
xori r3,r3,0x5e5e
|
||||
rlwinm r0,r8,0x15,0xa,0xa
|
||||
li r6,-0x100
|
||||
and r3,r3,r7
|
||||
rlwinm r8,r8,0x1f,0,0x1f
|
||||
or r3,r3,r0
|
||||
stw r29,0x14(r1)
|
||||
rlwimi r8,r3,0x1f,0,0
|
||||
lis r4,-0xff
|
||||
rlwinm r7,r3,0x1f,1,0x1f
|
||||
addi r5,r5,0xff
|
||||
rlwinm r30,r8,0x18,0,0x1f
|
||||
rlwinm r29,r3,0x17,0x18,0x1f
|
||||
and r12,r7,r9
|
||||
li r0,0
|
||||
rlwimi r30,r3,0x17,0,7
|
||||
and r31,r8,r6
|
||||
rlwimi r31,r30,0,0x18,0x1f
|
||||
rlwinm r11,r3,0x1f,0x10,0x17
|
||||
and r30,r31,r5
|
||||
and r12,r12,r9
|
||||
rlwimi r0,r29,8,0x18,0x1f
|
||||
subi r4,r4,1
|
||||
or r12,r12,r0
|
||||
or r11,r30,r11
|
||||
and r30,r11,r4
|
||||
rlwinm r31,r8,0,0x18,0x1f
|
||||
li r0,0
|
||||
rlwinm r11,r8,0x10,8,0xf
|
||||
lis r10,0x100
|
||||
and r12,r12,r9
|
||||
rlwimi r0,r31,0x10,0x10,0x1f
|
||||
or r30,r30,r11
|
||||
or r29,r12,r0
|
||||
rlwinm r12,r3,0x1f,0x18,0x1f
|
||||
subi r0,r10,1
|
||||
li r10,0
|
||||
rlwimi r10,r12,0x18,8,0x1f
|
||||
and r11,r29,r9
|
||||
and r12,r30,r0
|
||||
rlwinm r3,r3,0x17,0,7
|
||||
or r3,r12,r3
|
||||
or r12,r11,r10
|
||||
and r10,r3,r9
|
||||
lis r3,TtableInv@ha
|
||||
and r31,r10,r9
|
||||
rlwinm r30,r8,0x10,0,0x1f
|
||||
rlwinm r11,r31,0x1c,0x1c,0x1f
|
||||
addi r3,r3,TtableInv@l
|
||||
rlwimi r30,r7,0x10,0,0xf
|
||||
rlwinm r10,r31,0,0x1c,0x1f
|
||||
and r29,r12,r6
|
||||
rlwinm r12,r8,8,0,0x1f
|
||||
lbzx r11,r3,r11
|
||||
rlwimi r12,r7,8,0,0x17
|
||||
lbzx r7,r3,r10
|
||||
rlwimi r29,r30,0,0x18,0x1f
|
||||
rlwinm r8,r11,4,0,0x1b
|
||||
rlwinm r10,r12,8,0x10,0x17
|
||||
and r11,r29,r5
|
||||
or r10,r11,r10
|
||||
or r7,r8,r7
|
||||
and r11,r31,r6
|
||||
li r8,0
|
||||
rlwimi r11,r7,0,0x18,0x1f
|
||||
and r12,r10,r9
|
||||
rlwinm r10,r11,0x18,0,0x1f
|
||||
li r7,0
|
||||
rlwimi r10,r12,0x18,0,7
|
||||
and r31,r11,r5
|
||||
rlwinm r11,r10,0x1c,0x1c,0x1f
|
||||
and r12,r12,r9
|
||||
rlwinm r10,r10,0,0x1c,0x1f
|
||||
lbzx r11,r3,r11
|
||||
lbzx r10,r3,r10
|
||||
rlwinm r11,r11,4,0,0x1b
|
||||
or r10,r11,r10
|
||||
rlwinm r11,r10,0,0x18,0x1f
|
||||
rlwinm r10,r10,8,0x10,0x17
|
||||
rlwimi r8,r11,8,0x18,0x1f
|
||||
or r10,r31,r10
|
||||
or r8,r12,r8
|
||||
rlwinm r12,r10,0x10,0,0x1f
|
||||
and r11,r10,r4
|
||||
rlwimi r12,r8,0x10,0,0xf
|
||||
and r10,r8,r9
|
||||
rlwinm r8,r12,0x1c,0x1c,0x1f
|
||||
rlwinm r4,r12,0,0x1c,0x1f
|
||||
lbzx r8,r3,r8
|
||||
lbzx r4,r3,r4
|
||||
rlwinm r8,r8,4,0,0x1b
|
||||
or r4,r8,r4
|
||||
rlwinm r8,r4,0,0x18,0x1f
|
||||
rlwinm r4,r4,0x10,8,0xf
|
||||
or r29,r11,r4
|
||||
rlwimi r7,r8,0x10,0x10,0x1f
|
||||
or r11,r10,r7
|
||||
lis r4,1
|
||||
rlwinm r8,r29,8,0,0x1f
|
||||
and r31,r29,r0
|
||||
rlwimi r8,r11,8,0,0x17
|
||||
and r12,r11,r9
|
||||
rlwinm r10,r8,0x1c,0x1c,0x1f
|
||||
subi r0,r4,0x4c4d
|
||||
lbzx r11,r3,r10
|
||||
rlwinm r8,r8,0,0x1c,0x1f
|
||||
lbzx r10,r3,r8
|
||||
li r8,0
|
||||
rlwinm r11,r11,4,0,0x1b
|
||||
lis r7,-0x4c4c
|
||||
or r11,r11,r10
|
||||
rlwinm r10,r11,0,0x18,0x1f
|
||||
subi r7,r7,0x4c4d
|
||||
rlwimi r8,r10,0x18,8,0x1f
|
||||
rlwinm r4,r11,0x18,0,7
|
||||
or r10,r12,r8
|
||||
rlwinm r8,r10,0x1c,0x1c,0x1f
|
||||
or r12,r31,r4
|
||||
rlwinm r4,r10,0,0x1c,0x1f
|
||||
lbzx r8,r3,r8
|
||||
and r11,r10,r6
|
||||
lbzx r4,r3,r4
|
||||
rlwinm r6,r8,4,0,0x1b
|
||||
and r8,r12,r9
|
||||
or r4,r6,r4
|
||||
rlwimi r11,r4,0,0x18,0x1f
|
||||
and r10,r8,r9
|
||||
rlwinm r6,r11,0x14,0x1c,0x1f
|
||||
rlwinm r4,r11,0x18,0x1c,0x1f
|
||||
lbzx r6,r3,r6
|
||||
lbzx r3,r3,r4
|
||||
and r8,r11,r5
|
||||
rlwinm r5,r6,4,0,0x1b
|
||||
and r4,r10,r9
|
||||
or r3,r5,r3
|
||||
rlwinm r3,r3,8,0x10,0x17
|
||||
or r3,r8,r3
|
||||
rlwinm r5,r3,0xa,0xb,0x15
|
||||
rlwinm r3,r3,0x15,0x16,0x1f
|
||||
rlwimi r5,r4,0xa,0x16,0x1f
|
||||
rlwimi r3,r4,0xa,0,0x15
|
||||
xor r4,r3,r7
|
||||
xor r3,r5,r0
|
||||
lwz r31,0x1c(r1)
|
||||
lwz r30,0x18(r1)
|
||||
lwz r29,0x14(r1)
|
||||
addi r1,r1,0x20
|
||||
blr
|
||||
static u8 getByte(u64 value, u8 index) {
|
||||
return (value >> (index * 8)) & 0xFF;
|
||||
}
|
||||
|
||||
static u64 setByte(u64 value, u8 index, u8 byte) {
|
||||
return (value & ~(0xFFULL << ((u64)8 * index))) | ((u64)byte << ((u64)8 * index));
|
||||
}
|
||||
|
||||
static NWC24UserId getUnScrambleId(NWC24UserId id) {
|
||||
u64 copy;
|
||||
u8 i;
|
||||
|
||||
id &= 0x001FFFFFFFFFFFFFULL;
|
||||
id ^= 0x00005E5E5E5E5E5EULL;
|
||||
id &= 0x001FFFFFFFFFFFFFULL;
|
||||
id |= (((id & 0xFF) << 5) & 0x20) << 48;
|
||||
id >>= 1;
|
||||
|
||||
copy = id;
|
||||
for (i = 0; i < 6; ++i) {
|
||||
id = setByte(id, i, getByte(copy, ExcTable[i]));
|
||||
}
|
||||
|
||||
for (i = 0; i < 6; ++i) {
|
||||
id = setByte(id, i, (TtableInv[(getByte(id, i) >> 4) & 0xF] << 4) | TtableInv[getByte(id, i) & 0xF]);
|
||||
}
|
||||
|
||||
id = ((id & 0x7FFFFFFFFFFULL) << 10) | ((id >> 43) & 0x3FF);
|
||||
id ^= 0x0000B3B3B3B3B3B3ULL;
|
||||
return id;
|
||||
}
|
||||
|
||||
@@ -150,8 +150,8 @@ int SOGetSockName(int socket, void* address) {
|
||||
if(!request) result=-49;
|
||||
else {
|
||||
request->socket=socket;
|
||||
reply=&request->address;
|
||||
memcpy(reply,addr,addr->len);
|
||||
reply=(SOSockAddr*)(((u8*)request)+32);
|
||||
memcpy(((u8*)request)+32,addr,addr->len);
|
||||
result=IOS_Ioctl(rm,7,request,4,reply,addr->len);
|
||||
if(result>=0) memcpy(addr,reply,reply->len);
|
||||
SOiFree(12,request,size);
|
||||
|
||||
@@ -31,7 +31,7 @@ typedef struct AppLoaderHeader {
|
||||
u8 pad_0x1C[4];
|
||||
} AppLoaderHeader;
|
||||
|
||||
u8 TicketViewsBuf[OSRoundUp32B(sizeof(ESTicketView) * 64)] ALIGN32;
|
||||
static u8 TicketViewsBuf[OSRoundUp32B(sizeof(ESTicketView) * 64)] ALIGN32;
|
||||
ESTicketView *TicketViews = (ESTicketView *)TicketViewsBuf;
|
||||
DVDDiskID UpdateDiskID ALIGN32;
|
||||
OSBootInfo2 bi2 ALIGN32;
|
||||
@@ -39,69 +39,65 @@ AppLoaderHeader AppLoaderHdr ALIGN32;
|
||||
OSBootInfo3 bi3 ALIGN32;
|
||||
u8 GameTOCBuf[OSRoundUp32B(sizeof(DVDGameTOC))] ALIGN32;
|
||||
DVDDriveInfo DriveInfo ALIGN32;
|
||||
DVDDiskID DiskID ALIGN32;
|
||||
DVDPartitionParams PartitionParams ALIGN32;
|
||||
static DVDDiskID DiskID ALIGN32;
|
||||
static DVDPartitionParams PartitionParams ALIGN32;
|
||||
NANDCommandBlock BS2NandBlock;
|
||||
NANDFileInfo BS2CacheFileInfo;
|
||||
DVDCommandBlock CoverBlock;
|
||||
u8 PartitionInfoBuf[OSRoundUp32B(sizeof(DVDPartitionInfo) * 256)] ALIGN32;
|
||||
DVDCommandBlock Block;
|
||||
|
||||
BS2State State = BS2_STT_BEGIN;
|
||||
vu32 DvdReadPending = 0;
|
||||
u32 BannerAllocation = 0;
|
||||
u32 BannerBuffer = 0;
|
||||
u32 BannerAvailable = 0;
|
||||
u32 Allocator = 0;
|
||||
BOOL StartingGame = FALSE;
|
||||
u32 RestartRequested = 0;
|
||||
u32 PartitionOpen = 0;
|
||||
u32 CacheSeekComplete = 0;
|
||||
u32 LoadingTitle = 0;
|
||||
BOOL FatalErrorFlag = FALSE;
|
||||
static BS2State State = BS2_STT_BEGIN;
|
||||
static vu32 DvdReadPending = 0;
|
||||
static u32 BannerAllocation = 0;
|
||||
static u32 BannerBuffer = 0;
|
||||
static u32 BannerAvailable = 0;
|
||||
static u32 Allocator = 0;
|
||||
volatile BOOL StartingGame = FALSE;
|
||||
static vu32 RestartRequested = 0;
|
||||
static vu32 PartitionOpen = 0;
|
||||
static u32 CacheSeekComplete = 0;
|
||||
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;
|
||||
volatile int NandPending = 0;
|
||||
vu32 CancelNand = 0;
|
||||
vu32 LowReadResult = 0;
|
||||
u32 CacheCommandComplete = 0;
|
||||
u32 AudioBufferUnconfigured = 0;
|
||||
u64 ResetTime = 0;
|
||||
u64 SpinupDeadline = 0;
|
||||
u64 CoverPollTime = 0;
|
||||
u32 DriveWasReset = 0;
|
||||
u32 TitleTicketView = 0;
|
||||
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;
|
||||
vu32 BannerLength = 0;
|
||||
vu32 DvdTransferLength = 0;
|
||||
vu32 DvdTransferred = 0;
|
||||
u32 *DvdProgress = 0;
|
||||
u32 LoaderClose = 0;
|
||||
u32 LoaderMain = 0;
|
||||
u32 LoaderInit = 0;
|
||||
static volatile int NandPending = 0;
|
||||
static vu32 CancelNand = 0;
|
||||
static vu32 LowReadResult = 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, ...) {
|
||||
@@ -243,7 +239,7 @@ BOOL BS2IsDiagDisc() { return (u8)(*(u8 *)OSPhysicalToCached(OS_ADDR_BOOT_INFO)
|
||||
extern vu32 BS2VideoMode;
|
||||
extern vu32 __DVDLayoutFormat;
|
||||
|
||||
asm void Run(u32 entryPoint, void *start, u32 blockCount, u32 argument) {
|
||||
static asm void Run(u32 entryPoint, void *start, u32 blockCount, u32 argument) {
|
||||
// clang-format off
|
||||
#ifdef __MWERKS__
|
||||
nofralloc
|
||||
@@ -491,16 +487,13 @@ BOOL BS2StartLoadingTitle(ESTitleId titleId, ESTicketView *pTicketView) {
|
||||
|
||||
static void callback(u32 result) { LowReadResult = result; }
|
||||
|
||||
ESError BS2ESGetTicketViews(IOSFd *descriptor, ESTitleId titleId, ESTicketView *views, u32 *count) {
|
||||
struct {
|
||||
ESTitleId title[4];
|
||||
u32 count[56];
|
||||
} work ALIGN32;
|
||||
static ESError BS2ESGetTicketViews(IOSFd *descriptor, ESTitleId titleId, ESTicketView *views, u32 *count) {
|
||||
u8 work[256] ALIGN32;
|
||||
IOSIoVector vectors[4] ALIGN32;
|
||||
ESError result;
|
||||
IOSIoVector *request = vectors;
|
||||
ESTitleId *title = work.title;
|
||||
u32 *ticketCount = work.count;
|
||||
ESTitleId *title = (ESTitleId *)work;
|
||||
u32 *ticketCount = (u32 *)(work + 0x20);
|
||||
|
||||
if (*descriptor < 0 || !count) {
|
||||
return ES_ERR_INVALID;
|
||||
@@ -532,11 +525,9 @@ ESError BS2ESGetTicketViews(IOSFd *descriptor, ESTitleId titleId, ESTicketView *
|
||||
request[2].length = *count * sizeof(*views);
|
||||
return IOS_Ioctlv(*descriptor, 0x13, 2, 1, request);
|
||||
}
|
||||
void BS2Reboot(void) {
|
||||
static void BS2Reboot(void) {
|
||||
ESTicketView ticket ALIGN32;
|
||||
struct {
|
||||
ESTitleId title[32];
|
||||
} launchWork ALIGN32;
|
||||
u8 work[256] ALIGN32;
|
||||
OSStateFlags flags ALIGN32;
|
||||
IOSIoVector vectors[4] ALIGN32;
|
||||
IOSFd descriptor;
|
||||
@@ -583,7 +574,7 @@ void BS2Reboot(void) {
|
||||
{
|
||||
s32 launchResult;
|
||||
IOSIoVector *request = vectors;
|
||||
ESTitleId *title = launchWork.title;
|
||||
ESTitleId *title = (ESTitleId *)work;
|
||||
if (descriptor < 0) {
|
||||
launchResult = -0x3f9;
|
||||
} else if ((u32)&ticket % 32 != 0) {
|
||||
@@ -628,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");
|
||||
@@ -672,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) {
|
||||
@@ -811,16 +802,25 @@ partition_fatal:
|
||||
partition_done:
|
||||
BS2Report("DVDLowOpenPartition done\n");
|
||||
if (*(u8 *)0x8000315D != 0x80) {
|
||||
u32 diBits;
|
||||
u32 diValue;
|
||||
typedef union {
|
||||
u32 value;
|
||||
struct {
|
||||
u32 reserved : 29;
|
||||
u32 bit2 : 1;
|
||||
u32 bit1 : 1;
|
||||
u32 bit0 : 1;
|
||||
} bits;
|
||||
} DIControl;
|
||||
DIControl diBits;
|
||||
DIControl diValue;
|
||||
u32 *diAddr;
|
||||
|
||||
diAddr = (u32 *)0xCC003024;
|
||||
diBits = 2;
|
||||
diBits |= 4;
|
||||
diValue = *diAddr;
|
||||
diValue |= 1;
|
||||
*diAddr = diValue | diBits;
|
||||
diValue.value = *diAddr;
|
||||
diValue.bits.bit0 = 1;
|
||||
diBits.value = 2;
|
||||
diBits.bits.bit2 = 1;
|
||||
*diAddr = diValue.value | diBits.value;
|
||||
enableLegacyDI();
|
||||
}
|
||||
oldInterrupts = OSDisableInterrupts();
|
||||
@@ -839,9 +839,6 @@ void BS2StartGCGame() {
|
||||
static u8 gameCubeLanguages[] = {0, 0, 1, 2, 3, 4, 5};
|
||||
s32 ret;
|
||||
u32 rtc;
|
||||
u32 counterBias;
|
||||
u32 seconds;
|
||||
u32 timerFrequency;
|
||||
u32 soundMode;
|
||||
s8 productVideoMode;
|
||||
u8 progressiveMode;
|
||||
@@ -853,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();
|
||||
@@ -883,10 +880,7 @@ void BS2StartGCGame() {
|
||||
}
|
||||
|
||||
__OSGetRTC(&rtc);
|
||||
counterBias = SCGetCounterBias();
|
||||
seconds = rtc + counterBias;
|
||||
timerFrequency = OS_BUS_CLOCK >> 2;
|
||||
time = (OSTime)seconds * timerFrequency;
|
||||
time = OS_TIMER_CLOCK * (OSTime)(rtc + SCGetCounterBias());
|
||||
__OSSetTime(time);
|
||||
|
||||
sram = __OSLockSram();
|
||||
@@ -960,7 +954,7 @@ void BS2StartGCGame() {
|
||||
}
|
||||
}
|
||||
|
||||
BOOL CheckDVDCommandStatus(DVDCommandBlock *block) {
|
||||
static BOOL CheckDVDCommandStatus(DVDCommandBlock *block) {
|
||||
if (State == 0x3A) {
|
||||
return TRUE;
|
||||
}
|
||||
@@ -984,9 +978,7 @@ 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;
|
||||
@@ -1023,11 +1015,11 @@ BOOL CheckDVDCommandStatus(DVDCommandBlock *block) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void BS2NANDDivideCallback(s32 result, NANDCommandBlock *block);
|
||||
void BS2NANDDivideReadAsync(NANDFileInfo *info, void *buffer, u32 length, NANDCallback callback, NANDCommandBlock *block);
|
||||
void BS2NANDDivideWriteAsync(NANDFileInfo *info, const void *buffer, u32 length, NANDCallback callback, NANDCommandBlock *block);
|
||||
static void BS2NANDDivideCallback(s32 result, NANDCommandBlock *block);
|
||||
static void BS2NANDDivideReadAsync(NANDFileInfo *info, void *buffer, u32 length, NANDCallback callback, NANDCommandBlock *block);
|
||||
static void BS2NANDDivideWriteAsync(NANDFileInfo *info, const void *buffer, u32 length, NANDCallback callback, NANDCommandBlock *block);
|
||||
|
||||
void BS2NANDDivideCallback(s32 result, NANDCommandBlock *block) {
|
||||
static void BS2NANDDivideCallback(s32 result, NANDCommandBlock *block) {
|
||||
s32 ret;
|
||||
|
||||
if (CancelNand != 0) {
|
||||
@@ -1068,7 +1060,7 @@ void BS2NANDDivideCallback(s32 result, NANDCommandBlock *block) {
|
||||
}
|
||||
}
|
||||
|
||||
void BS2NANDDivideReadAsync(NANDFileInfo *info, void *buffer, u32 length, NANDCallback callback, NANDCommandBlock *block) {
|
||||
static void BS2NANDDivideReadAsync(NANDFileInfo *info, void *buffer, u32 length, NANDCallback callback, NANDCommandBlock *block) {
|
||||
NandCompletion = callback;
|
||||
NandOperation = 2;
|
||||
NandLength = length;
|
||||
@@ -1084,7 +1076,7 @@ void BS2NANDDivideReadAsync(NANDFileInfo *info, void *buffer, u32 length, NANDCa
|
||||
}
|
||||
}
|
||||
|
||||
void BS2NANDDivideWriteAsync(NANDFileInfo *info, const void *buffer, u32 length, NANDCallback callback, NANDCommandBlock *block) {
|
||||
static void BS2NANDDivideWriteAsync(NANDFileInfo *info, const void *buffer, u32 length, NANDCallback callback, NANDCommandBlock *block) {
|
||||
NandCompletion = callback;
|
||||
NandOperation = 1;
|
||||
NandLength = length;
|
||||
@@ -1100,7 +1092,9 @@ void BS2NANDDivideWriteAsync(NANDFileInfo *info, const void *buffer, u32 length,
|
||||
}
|
||||
}
|
||||
|
||||
BOOL CheckBS2CommandStatus() {
|
||||
static BOOL CheckBS2CommandStatus() {
|
||||
static u32 CacheCommandComplete = 0;
|
||||
|
||||
if (CheckDVDCommandStatus(&Block) == 0) {
|
||||
BS2Report("DVD command is issuing\n");
|
||||
return 0;
|
||||
@@ -1183,8 +1177,8 @@ 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;
|
||||
@@ -1304,7 +1298,7 @@ BOOL CheckBS2CommandStatus() {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void BS2InquiryAsync(void *buffer, s32 length, u32 offset) {
|
||||
static void BS2InquiryAsync(void *buffer, s32 length, u32 offset) {
|
||||
if (BS2BootFromCache) {
|
||||
BS2Report("Unencrypted read from cache.dat\n");
|
||||
NandPending = 1;
|
||||
@@ -1314,7 +1308,7 @@ void BS2InquiryAsync(void *buffer, s32 length, u32 offset) {
|
||||
}
|
||||
}
|
||||
|
||||
void BS2ReadDiskID(void *buffer, s32 length, u32 offset) {
|
||||
static void BS2ReadDiskID(void *buffer, s32 length, u32 offset) {
|
||||
if (BS2BootFromCache) {
|
||||
BS2Report("Read from cache.dat\n");
|
||||
NandPending = 1;
|
||||
@@ -1326,25 +1320,24 @@ void BS2ReadDiskID(void *buffer, s32 length, u32 offset) {
|
||||
}
|
||||
|
||||
BS2State BS2Tick() {
|
||||
static u32 AudioBufferUnconfigured;
|
||||
u32 interruptsEnabled = OSDisableInterrupts();
|
||||
u32 loaderAddress;
|
||||
u32 loaderLength;
|
||||
u32 loaderOffset;
|
||||
u32 titleCode;
|
||||
s32 titlePrefix;
|
||||
u8 titleCharacters[4];
|
||||
struct {
|
||||
u32 offset;
|
||||
u32 length;
|
||||
u32 address;
|
||||
} loaderRead;
|
||||
DVDFileInfo bannerFile;
|
||||
u32 bannerAddress;
|
||||
u32 discRegion;
|
||||
s32 status;
|
||||
u64 currentTime;
|
||||
BOOL regionMatches;
|
||||
char productRegion;
|
||||
u32 iosHigh;
|
||||
char *ticketByte;
|
||||
u32 entryCount;
|
||||
u32 readInterruptsEnabled;
|
||||
DVDGameTOC *dataToc;
|
||||
u32 readAddress;
|
||||
const char *discTitle;
|
||||
const DVDDiskID *bootDisc;
|
||||
@@ -1354,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;
|
||||
@@ -1443,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:
|
||||
@@ -1576,8 +1569,9 @@ invalidGcRegion:
|
||||
BS2Report("length ... 0x%08X\n", 0x20);
|
||||
BS2Report("numGamePartitions ... 0x%08X\n", (*(DVDGameTOC **)&GameToc)->partitionCount);
|
||||
BS2Report("partitionInfos ... 0x%08X\n", (u32)(*(DVDGameTOC **)&GameToc)->partitionInfo);
|
||||
DataToc = (u32)((DVDGameTOC *)GameTOCBuf + 1);
|
||||
BS2Report("numGamePartitions ... 0x%08X\n", ((DVDGameTOC *)GameTOCBuf)[1].partitionCount);
|
||||
dataToc = (DVDGameTOC *)GameTOCBuf + 1;
|
||||
DataToc = (u32)dataToc;
|
||||
BS2Report("numGamePartitions ... 0x%08X\n", dataToc->partitionCount);
|
||||
BS2Report("partitionInfos ... 0x%08X\n", ((DVDGameTOC *)DataToc)->partitionInfo);
|
||||
State = BS2_STT_17;
|
||||
case 0x11:
|
||||
@@ -1734,21 +1728,23 @@ invalidRvlRegion:
|
||||
((void (*)(void *))((*(void **)&LoaderInit)))((void *)BS2Report);
|
||||
BS2Report("\nApploader Initialized\n");
|
||||
State = BS2_STT_29;
|
||||
case 0x1d:
|
||||
status = ((int (*)(u32 *, u32 *, u32 *))((*(void **)&LoaderMain)))(&loaderRead.address, &loaderRead.length, &loaderRead.offset);
|
||||
case 0x1d: {
|
||||
u32 readInterruptsEnabled;
|
||||
status = ((int (*)(u32 *, u32 *, u32 *))((*(void **)&LoaderMain)))(&loaderAddress, &loaderLength, &loaderOffset);
|
||||
if (status != 0) {
|
||||
BS2Report("Addr [0x%x] length [0x%x] offset [0x%x]\n", loaderRead.address, loaderRead.length, loaderRead.offset);
|
||||
BS2Report("Addr [0x%x] length [0x%x] offset [0x%x]\n", loaderAddress, loaderLength, loaderOffset);
|
||||
readInterruptsEnabled = OSDisableInterrupts();
|
||||
DVDReadAbsAsyncForBS(&Block, (void *)loaderRead.address, loaderRead.length, loaderRead.offset >> __DVDLayoutFormat, BS2DVDCallback);
|
||||
DVDReadAbsAsyncForBS(&Block, (void *)loaderAddress, loaderLength, loaderOffset >> __DVDLayoutFormat, BS2DVDCallback);
|
||||
if (*(s32 *)DvdProgress != 0) {
|
||||
DvdReadPending = 1;
|
||||
DvdTransferLength = loaderRead.length;
|
||||
DvdTransferLength = loaderLength;
|
||||
}
|
||||
OSRestoreInterrupts(readInterruptsEnabled);
|
||||
State = BS2_STT_30;
|
||||
} else
|
||||
State = BS2_STT_31;
|
||||
break;
|
||||
}
|
||||
case 0x1e:
|
||||
status = CheckDVDCommandStatus(&Block);
|
||||
if (status != 0)
|
||||
@@ -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) {
|
||||
@@ -2022,25 +2016,27 @@ invalidRvlRegion:
|
||||
((void (*)(void *))((*(void **)&LoaderInit)))((void *)OSReport);
|
||||
BS2Report("\nApploader Initialized\n");
|
||||
State = BS2_STT_43;
|
||||
case 0x2b:
|
||||
status = ((int (*)(u32 *, u32 *, u32 *))((*(void **)&LoaderMain)))(&loaderRead.address, &loaderRead.length, &loaderRead.offset);
|
||||
case 0x2b: {
|
||||
u32 readInterruptsEnabled;
|
||||
status = ((int (*)(u32 *, u32 *, u32 *))((*(void **)&LoaderMain)))(&loaderAddress, &loaderLength, &loaderOffset);
|
||||
if (status != 0) {
|
||||
BS2Report("Addr [0x%x] length [0x%x] offset [0x%x]\n", loaderRead.address, loaderRead.length, loaderRead.offset);
|
||||
BS2Report("Addr [0x%x] length [0x%x] offset [0x%x]\n", loaderAddress, loaderLength, loaderOffset);
|
||||
readInterruptsEnabled = OSDisableInterrupts();
|
||||
BS2ReadDiskID((void *)loaderRead.address, loaderRead.length, loaderRead.offset >> __DVDLayoutFormat);
|
||||
readAddress = loaderRead.address;
|
||||
LoaderLength = loaderRead.length;
|
||||
BS2ReadDiskID((void *)loaderAddress, loaderLength, loaderOffset >> __DVDLayoutFormat);
|
||||
readAddress = loaderAddress;
|
||||
LoaderLength = loaderLength;
|
||||
LoaderAddress = readAddress;
|
||||
LoaderOffset = loaderRead.offset;
|
||||
LoaderOffset = loaderOffset;
|
||||
if ((*(s32 *)DvdProgress != 0) && (BS2BootFromCache == 0)) {
|
||||
DvdReadPending = 1;
|
||||
DvdTransferLength = loaderRead.length;
|
||||
DvdTransferLength = loaderLength;
|
||||
}
|
||||
OSRestoreInterrupts(readInterruptsEnabled);
|
||||
State = BS2_STT_44;
|
||||
} else
|
||||
State = BS2_STT_45;
|
||||
break;
|
||||
}
|
||||
case 0x2c:
|
||||
status = CheckBS2CommandStatus();
|
||||
if (status != 0)
|
||||
@@ -2063,13 +2059,15 @@ invalidRvlRegion:
|
||||
BannerAllocation = status;
|
||||
if (status == 0)
|
||||
OSPanic("BS2Mach.c", 0x12c8, "BS2 ERROR >>> Cannnot alloc 0x%08x from MEMAllocator", bannerFile.length);
|
||||
bannerAddress = BannerAllocation + 32 - BannerAllocation % 32;
|
||||
BannerLength = bannerFile.length;
|
||||
BannerBuffer = BannerAllocation + 32 - BannerAllocation % 32;
|
||||
BannerBuffer = bannerAddress;
|
||||
BS2Report("BannerBufferAddr : %08X\n", BannerBuffer);
|
||||
} 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");
|
||||
@@ -2173,7 +2171,7 @@ invalidRvlRegion:
|
||||
BS2BootFromCache = 0;
|
||||
BS2BootCaching = 1;
|
||||
LoadingTitle = 0;
|
||||
switch (Block.state) {
|
||||
switch (((volatile DVDCommandBlock *)&Block)->state) {
|
||||
case 4:
|
||||
case 5:
|
||||
CheckDVDCommandStatus(&Block);
|
||||
@@ -2318,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,14 +9,13 @@
|
||||
|
||||
#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;
|
||||
|
||||
#define UPDATE_DISC_ENTRIES ((BS2UpdateEntry*)0x80480000)
|
||||
BS2UpdateEntry DiscEntries[BS2_UPDATE_ENTRY_COUNT] ADDRESS(0x80480000);
|
||||
|
||||
s32 WADCheckImport(u64 titleId, u16 titleVersion);
|
||||
s32 WADImportDVDForBS(const char* path, void* buffer, u32 length);
|
||||
@@ -32,8 +31,8 @@ static u32 RebootRequired = 0;
|
||||
static BOOL ContainsSeatTitles = 0;
|
||||
static u32 UpdateImportState = 0;
|
||||
static u32 UpdateImportResult = 0;
|
||||
u32 StartUpdate = 0;
|
||||
u32 CancelUpdate = 0;
|
||||
volatile u32 StartUpdate = 0;
|
||||
volatile u32 CancelUpdate = 0;
|
||||
static u32 UpdateProgress = 0;
|
||||
static volatile s32 rc = 0;
|
||||
static u64 VersionIOS = 0;
|
||||
@@ -50,71 +49,44 @@ 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(UPDATE_DISC_ENTRIES, 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;
|
||||
u32 requiredBytes;
|
||||
u32 requiredInodes;
|
||||
u32 channelCount;
|
||||
u32 index;
|
||||
BS2UpdateEntry* seatEntries;
|
||||
BS2UpdateEntry* selectedSeats;
|
||||
u32 selectedSeatCount;
|
||||
BOOL regionValid;
|
||||
u32 titleRegion;
|
||||
struct {
|
||||
u32 freeChannels;
|
||||
u32 freeBlocks;
|
||||
u32 freeInodes;
|
||||
u32 ticketCount;
|
||||
char productArea[8];
|
||||
u64 titleId;
|
||||
char updatePath[32];
|
||||
char seatPath[32];
|
||||
DVDFileInfo file;
|
||||
} scratch;
|
||||
u32 freeChannels;
|
||||
u32 freeBlocks;
|
||||
u32 freeInodes;
|
||||
u32 ticketCount;
|
||||
char productArea[8];
|
||||
u64 titleId;
|
||||
char updatePath[32];
|
||||
char seatPath[32];
|
||||
DVDFileInfo file;
|
||||
|
||||
missingFile = FALSE;
|
||||
selectedCount = 0;
|
||||
requiredBytes = 0;
|
||||
requiredInodes = 0;
|
||||
channelCount = 0;
|
||||
scratch.freeChannels = 0;
|
||||
scratch.freeBlocks = 0;
|
||||
scratch.freeInodes = 0;
|
||||
freeChannels = 0;
|
||||
freeBlocks = 0;
|
||||
freeInodes = 0;
|
||||
selectedSeatCount = 0;
|
||||
State = 0;
|
||||
ContainsSeatTitles = FALSE;
|
||||
if (ES_GetTitleId(&scratch.titleId) != ES_ERR_OK) {
|
||||
if (ES_GetTitleId(&titleId) != ES_ERR_OK) {
|
||||
regionValid = FALSE;
|
||||
} else {
|
||||
titleRegion = (u8)scratch.titleId;
|
||||
titleRegion = (u8)titleId;
|
||||
switch (SCGetProductArea()) {
|
||||
case SC_PRODUCT_AREA_JPN:
|
||||
case SC_PRODUCT_AREA_TWN:
|
||||
@@ -159,23 +131,23 @@ product_region_checked:
|
||||
selectedCount = 0;
|
||||
goto selection_complete;
|
||||
}
|
||||
if (!SCGetProductAreaString(scratch.productArea, sizeof(scratch.productArea))) {
|
||||
if (!SCGetProductAreaString(productArea, sizeof(productArea))) {
|
||||
BS2Report("Error: failed to get product information.");
|
||||
selectedCount = 0;
|
||||
goto selection_complete;
|
||||
}
|
||||
strcpy(scratch.updatePath, "__update.inf");
|
||||
strcat(scratch.updatePath, ".");
|
||||
strcat(scratch.updatePath, scratch.productArea);
|
||||
if (DVDConvertPathToEntrynum(scratch.updatePath) < 0) {
|
||||
strcpy(updatePath, "__update.inf");
|
||||
strcat(updatePath, ".");
|
||||
strcat(updatePath, productArea);
|
||||
if (DVDConvertPathToEntrynum(updatePath) < 0) {
|
||||
switch (SCGetProductArea()) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
case 6:
|
||||
case 11:
|
||||
strcpy(scratch.updatePath, "__update.inf");
|
||||
if (DVDConvertPathToEntrynum(scratch.updatePath) < 0) {
|
||||
strcpy(updatePath, "__update.inf");
|
||||
if (DVDConvertPathToEntrynum(updatePath) < 0) {
|
||||
BS2Report("Error: update information file is not found.");
|
||||
selectedCount = 0;
|
||||
goto selection_complete;
|
||||
@@ -187,13 +159,13 @@ product_region_checked:
|
||||
goto selection_complete;
|
||||
}
|
||||
}
|
||||
BS2Report("%s is found.\n", scratch.updatePath);
|
||||
if (!DVDOpen(scratch.updatePath, &scratch.file)) {
|
||||
BS2Report("%s is found.\n", updatePath);
|
||||
if (!DVDOpen(updatePath, &file)) {
|
||||
BS2Report("Error: failed to open update information file.");
|
||||
selectedCount = 0;
|
||||
goto selection_complete;
|
||||
}
|
||||
if (DVDReadPrio(&scratch.file, &UpdateHeader0, sizeof(UpdateHeader0), 0, 2) < 0) {
|
||||
if (DVDReadPrio(&file, &UpdateHeader0, sizeof(UpdateHeader0), 0, 2) < 0) {
|
||||
BS2Report("Error: failed to read update information header.");
|
||||
selectedCount = 0;
|
||||
goto selection_complete;
|
||||
@@ -214,25 +186,24 @@ product_region_checked:
|
||||
selectedCount = 0;
|
||||
goto selection_complete;
|
||||
}
|
||||
if (DVDReadPrio(&scratch.file, UPDATE_DISC_ENTRIES, UpdateHeader0.wadCount * sizeof(BS2UpdateEntry), 32, 2) < 0) {
|
||||
if (DVDReadPrio(&file, DiscEntries, UpdateHeader0.wadCount * sizeof(BS2UpdateEntry), 32, 2) < 0) {
|
||||
BS2Report("Error: failed to read update information.");
|
||||
selectedCount = 0;
|
||||
goto selection_complete;
|
||||
}
|
||||
{
|
||||
BS2UpdateEntry *discEntries = UPDATE_DISC_ENTRIES;
|
||||
for (index = 0; index < UpdateHeader0.wadCount; index++) {
|
||||
if ((discEntries[index].attr & 1) == 0) {
|
||||
if ((DiscEntries[index].attr & 1) == 0) {
|
||||
continue;
|
||||
}
|
||||
switch (OSGetPhysicalMem2Size()) {
|
||||
case 0x4000000:
|
||||
if ((discEntries[index].depend & 1) == 0) {
|
||||
if ((DiscEntries[index].depend & 1) == 0) {
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
case 0x8000000:
|
||||
if ((discEntries[index].depend & 2) == 0) {
|
||||
if ((DiscEntries[index].depend & 2) == 0) {
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
@@ -242,37 +213,37 @@ product_region_checked:
|
||||
selectedCount = 0;
|
||||
goto selection_complete;
|
||||
}
|
||||
if (DVDOpen(discEntries[index].path, &scratch.file) < 0) {
|
||||
BS2Report("%s is not found\n", discEntries[index].path);
|
||||
if (DVDOpen(DiscEntries[index].path, &file) < 0) {
|
||||
BS2Report("%s is not found\n", DiscEntries[index].path);
|
||||
missingFile = TRUE;
|
||||
continue;
|
||||
}
|
||||
discEntries[index].size = scratch.file.length;
|
||||
if (discEntries[index].type == 0) {
|
||||
DiscEntries[index].size = file.length;
|
||||
if (DiscEntries[index].type == 0) {
|
||||
selectedCount++;
|
||||
} else if (WADCheckImport(discEntries[index].titleId, discEntries[index].titleVersion) == 0) {
|
||||
BS2Report("%s is already installed\n", discEntries[index].path);
|
||||
} else if (WADCheckImport(DiscEntries[index].titleId, DiscEntries[index].titleVersion) == 0) {
|
||||
BS2Report("%s is already installed\n", DiscEntries[index].path);
|
||||
Flags1[index] = 0;
|
||||
} else {
|
||||
BS2Report("%s\n", discEntries[index].path);
|
||||
memcpy(&EntriesToImport[selectedCount], &discEntries[index], sizeof(BS2UpdateEntry));
|
||||
BS2Report("%s\n", DiscEntries[index].path);
|
||||
memcpy(&EntriesToImport[selectedCount], &DiscEntries[index], sizeof(BS2UpdateEntry));
|
||||
selectedCount++;
|
||||
Flags1[index] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
strcpy(scratch.seatPath, "__seatholder.inf");
|
||||
strcat(scratch.seatPath, ".");
|
||||
strcat(scratch.seatPath, scratch.productArea);
|
||||
if (DVDConvertPathToEntrynum(scratch.seatPath) < 0) {
|
||||
strcpy(seatPath, "__seatholder.inf");
|
||||
strcat(seatPath, ".");
|
||||
strcat(seatPath, productArea);
|
||||
if (DVDConvertPathToEntrynum(seatPath) < 0) {
|
||||
switch (SCGetProductArea()) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
case 6:
|
||||
case 11:
|
||||
strcpy(scratch.seatPath, "__seatholder.inf");
|
||||
if (DVDConvertPathToEntrynum(scratch.seatPath) < 0) {
|
||||
strcpy(seatPath, "__seatholder.inf");
|
||||
if (DVDConvertPathToEntrynum(seatPath) < 0) {
|
||||
BS2Report("Error: update seatholder information file is not found.");
|
||||
goto seats_done;
|
||||
}
|
||||
@@ -282,12 +253,12 @@ product_region_checked:
|
||||
goto seats_done;
|
||||
}
|
||||
}
|
||||
BS2Report("%s is found.\n", scratch.seatPath);
|
||||
if (!DVDOpen(scratch.seatPath, &scratch.file)) {
|
||||
BS2Report("%s is found.\n", seatPath);
|
||||
if (!DVDOpen(seatPath, &file)) {
|
||||
BS2Report("Error: failed to open update information file.");
|
||||
goto seats_done;
|
||||
}
|
||||
if (DVDReadPrio(&scratch.file, &UpdateHeader1, sizeof(UpdateHeader1), 0, 2) < 0) {
|
||||
if (DVDReadPrio(&file, &UpdateHeader1, sizeof(UpdateHeader1), 0, 2) < 0) {
|
||||
BS2Report("Error: failed to read update information header.");
|
||||
goto seats_done;
|
||||
}
|
||||
@@ -300,11 +271,9 @@ product_region_checked:
|
||||
BS2Report("Error: found too many extra entries.");
|
||||
goto seats_done;
|
||||
}
|
||||
seatEntries = UPDATE_DISC_ENTRIES;
|
||||
seatEntries += UpdateHeader0.wadCount;
|
||||
selectedSeats = EntriesToImport;
|
||||
selectedSeats += selectedCount;
|
||||
if (DVDReadPrio(&scratch.file, seatEntries, UpdateHeader1.wadCount * sizeof(BS2UpdateEntry), 32, 2) < 0) {
|
||||
seatEntries = DiscEntries + UpdateHeader0.wadCount;
|
||||
selectedSeats = EntriesToImport + selectedCount;
|
||||
if (DVDReadPrio(&file, seatEntries, UpdateHeader1.wadCount * sizeof(BS2UpdateEntry), 32, 2) < 0) {
|
||||
BS2Report("Error: failed to read update information.");
|
||||
goto seats_done;
|
||||
}
|
||||
@@ -337,7 +306,7 @@ product_region_checked:
|
||||
State = 5;
|
||||
goto seats_done;
|
||||
}
|
||||
if (DVDOpen(seatEntries[index].path, &scratch.file) < 0) {
|
||||
if (DVDOpen(seatEntries[index].path, &file) < 0) {
|
||||
BS2Report("%s is not found\n", seatEntries[index].path);
|
||||
missingFile = TRUE;
|
||||
continue;
|
||||
@@ -345,11 +314,11 @@ product_region_checked:
|
||||
if (seatEntries[index].type != 7) {
|
||||
continue;
|
||||
}
|
||||
if (ES_GetTicketViews(seatEntries[index].titleId, NULL, &scratch.ticketCount) != ES_ERR_OK) {
|
||||
if (ES_GetTicketViews(seatEntries[index].titleId, NULL, &ticketCount) != ES_ERR_OK) {
|
||||
BS2Report("Faild to get eTicket views.\n");
|
||||
continue;
|
||||
}
|
||||
if (scratch.ticketCount != 0) {
|
||||
if (ticketCount != 0) {
|
||||
continue;
|
||||
}
|
||||
if (SCGetWwwRestriction() && ((u32)(seatEntries[index].titleId & 0xFFFFFFFFULL) & 0xFFFFFF00) == 0x48414400) {
|
||||
@@ -372,23 +341,23 @@ product_region_checked:
|
||||
requiredInodes += seatEntries[index].inodes;
|
||||
}
|
||||
if (channelCount != 0) {
|
||||
if (!SCGetFreeChannelAppCount(&scratch.freeChannels)) {
|
||||
if (!SCGetFreeChannelAppCount(&freeChannels)) {
|
||||
BS2Report("Error: cannot get channel count.");
|
||||
goto seats_done;
|
||||
}
|
||||
if (NANDSecretGetUserAvailableArea(&scratch.freeBlocks, &scratch.freeInodes) != NAND_RESULT_OK) {
|
||||
if (NANDSecretGetUserAvailableArea(&freeBlocks, &freeInodes) != NAND_RESULT_OK) {
|
||||
BS2Report("Error: cannot get free user blocks.");
|
||||
goto seats_done;
|
||||
}
|
||||
if ((scratch.freeBlocks << 14) < 0x1004000 || requiredBytes > (scratch.freeBlocks << 14) - 0x1004000) {
|
||||
if ((freeBlocks << 14) < 0x1004000 || requiredBytes > (freeBlocks << 14) - 0x1004000) {
|
||||
BS2Report("Sufficient user blocks doesn't exist.");
|
||||
goto seats_done;
|
||||
}
|
||||
if (scratch.freeInodes < requiredInodes + 36) {
|
||||
if (freeInodes < requiredInodes + 36) {
|
||||
BS2Report("Sufficient user inodes doesn't exist.");
|
||||
goto seats_done;
|
||||
}
|
||||
if (channelCount > scratch.freeChannels) {
|
||||
if (channelCount > freeChannels) {
|
||||
BS2Report("No enough blank channel.");
|
||||
goto seats_done;
|
||||
}
|
||||
@@ -410,14 +379,13 @@ seats_done:
|
||||
pEntries = EntriesToImport;
|
||||
pFlags = Flags1;
|
||||
{
|
||||
BS2UpdateEntry *discEntries = UPDATE_DISC_ENTRIES;
|
||||
for (index = 0; index < UpdateHeader0.wadCount; index++) {
|
||||
if (Flags1[index] == 1) {
|
||||
BS2Report("File: %s\n", discEntries[index].path);
|
||||
BS2Report("Name: %s\n", discEntries[index].dataName);
|
||||
BS2Report("Info: %s\n", discEntries[index].dataMeta);
|
||||
BS2Report("Attr: %s\n", (discEntries[index].attr & 1) ? "Critical" : "Non critical");
|
||||
BS2Report(" %s\n", (discEntries[index].attr & 2) ? "Reboot" : "Not reboot");
|
||||
BS2Report("File: %s\n", DiscEntries[index].path);
|
||||
BS2Report("Name: %s\n", DiscEntries[index].dataName);
|
||||
BS2Report("Info: %s\n", DiscEntries[index].dataMeta);
|
||||
BS2Report("Attr: %s\n", (DiscEntries[index].attr & 1) ? "Critical" : "Non critical");
|
||||
BS2Report(" %s\n", (DiscEntries[index].attr & 2) ? "Reboot" : "Not reboot");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -425,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;
|
||||
@@ -442,25 +435,24 @@ static void* UpdateThread(void* argument) {
|
||||
State = 1;
|
||||
UpdateProgress = 0;
|
||||
{
|
||||
BS2UpdateEntry *discEntries = UPDATE_DISC_ENTRIES;
|
||||
for (;;) {
|
||||
if (StartUpdate != 0) {
|
||||
if (UpdateProgress < UpdateHeader0.wadCount) {
|
||||
BS2Report("Progress : %d\n", UpdateProgress);
|
||||
if (Flags1[UpdateProgress] == 1) {
|
||||
const char* path = discEntries[UpdateProgress].path;
|
||||
const char* path = DiscEntries[UpdateProgress].path;
|
||||
BS2Report("Import : %s\n", path);
|
||||
State = 2;
|
||||
CurrentEntry = &discEntries[UpdateProgress];
|
||||
if (discEntries[UpdateProgress].type == 0) {
|
||||
CurrentEntry = &DiscEntries[UpdateProgress];
|
||||
if (DiscEntries[UpdateProgress].type == 0) {
|
||||
UpdateProgress++;
|
||||
continue;
|
||||
}
|
||||
if (((const BS2UpdateEntry *)discEntries)[UpdateProgress].type == 1) {
|
||||
if (((const BS2UpdateEntry *)DiscEntries)[UpdateProgress].type == 1) {
|
||||
BS2Report("BS2WADImportDVD : ");
|
||||
index = UpdateProgress;
|
||||
if (strcmp(getSuffix(discEntries[index].path), "wad") == 0) {
|
||||
importResult = WADImportDVDForBS(discEntries[index].path, (void*)BS2_UPDATE_ADDRESS, 0x80000);
|
||||
if (strcmp(getSuffix(DiscEntries[index].path), "wad") == 0) {
|
||||
importResult = WADImportDVDForBS(DiscEntries[index].path, (void*)BS2_UPDATE_ADDRESS, 0x80000);
|
||||
} else {
|
||||
importResult = 0;
|
||||
}
|
||||
@@ -468,20 +460,20 @@ static void* UpdateThread(void* argument) {
|
||||
BS2Report("rc = %d\n", rc);
|
||||
if (rc != 0) {
|
||||
NANDLoggingAddMessageAsync(NULL, "BS2 error. [%d] titleID: 0x%016llx %s line: %d",
|
||||
rc, discEntries[UpdateProgress].titleId, "BS2Update.c", 0x3F5);
|
||||
rc, DiscEntries[UpdateProgress].titleId, "BS2Update.c", 0x3F5);
|
||||
State = 5;
|
||||
UpdateProgress = UpdateHeader0.wadCount + 1;
|
||||
break;
|
||||
}
|
||||
if ((discEntries[UpdateProgress].attr & 2) != 0) {
|
||||
if ((DiscEntries[UpdateProgress].attr & 2) != 0) {
|
||||
RebootRequired = 1;
|
||||
}
|
||||
UpdateProgress++;
|
||||
} else {
|
||||
BS2Report("BS2WADImportDVDEx : ");
|
||||
index = UpdateProgress;
|
||||
if (strcmp(getSuffix(discEntries[index].path), "wad") == 0) {
|
||||
importResult = WADImportDVDExForBS(discEntries[index].path, (void*)BS2_UPDATE_ADDRESS, 0x80000);
|
||||
if (strcmp(getSuffix(DiscEntries[index].path), "wad") == 0) {
|
||||
importResult = WADImportDVDExForBS(DiscEntries[index].path, (void*)BS2_UPDATE_ADDRESS, 0x80000);
|
||||
} else {
|
||||
importResult = 0;
|
||||
}
|
||||
@@ -489,18 +481,18 @@ static void* UpdateThread(void* argument) {
|
||||
BS2Report("rc = %d\n", rc);
|
||||
if (rc != 0) {
|
||||
NANDLoggingAddMessageAsync(NULL, "BS2 error. [%d] titleID: 0x%016llx %s line: %d",
|
||||
rc, discEntries[UpdateProgress].titleId, "BS2Update.c", 0x40F);
|
||||
rc, DiscEntries[UpdateProgress].titleId, "BS2Update.c", 0x40F);
|
||||
State = 5;
|
||||
UpdateProgress = UpdateHeader0.wadCount + 1;
|
||||
break;
|
||||
}
|
||||
if ((discEntries[UpdateProgress].attr & 2) != 0) {
|
||||
if ((DiscEntries[UpdateProgress].attr & 2) != 0) {
|
||||
RebootRequired = 1;
|
||||
}
|
||||
UpdateProgress++;
|
||||
}
|
||||
} else {
|
||||
const char* path = discEntries[UpdateProgress].path;
|
||||
const char* path = DiscEntries[UpdateProgress].path;
|
||||
BS2Report("Not import : %s\n", path);
|
||||
UpdateProgress++;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -2,16 +2,13 @@
|
||||
#include <revolution/os/OSError.h>
|
||||
|
||||
extern "C" char scCsFatalMsg[];
|
||||
extern "C" const u8 scCsFatalColorR;
|
||||
extern "C" const u8 scCsFatalColorG;
|
||||
extern "C" const u8 scCsFatalColorB;
|
||||
extern "C" const u8 scCsFatalColorA;
|
||||
extern "C" GXColor scCsFatalColor;
|
||||
|
||||
#define NW4R_DB_ASSERT_H
|
||||
#define NW4R_ASSERT(x) \
|
||||
{ \
|
||||
if (!(x)) { \
|
||||
GXColor front = {scCsFatalColorR, scCsFatalColorG, scCsFatalColorB, scCsFatalColorA}; \
|
||||
GXColor front = scCsFatalColor; \
|
||||
GXColor back = {0, 0, 0, 0}; \
|
||||
OSFatal(front, back, scCsFatalMsg); \
|
||||
} \
|
||||
@@ -622,13 +619,7 @@ namespace ipl {
|
||||
namespace pane {
|
||||
extern "C" char scCsFatalMsg[] = "Error#004\nAn error has occurred.\nThe system files are corrupted.";
|
||||
|
||||
#pragma push
|
||||
#pragma section data_type ".sdata"
|
||||
extern "C" __declspec(section ".sdata") const u8 scCsFatalColorR = 0xff;
|
||||
extern "C" __declspec(section ".sdata") const u8 scCsFatalColorG = 0xff;
|
||||
extern "C" __declspec(section ".sdata") const u8 scCsFatalColorB = 0xff;
|
||||
extern "C" __declspec(section ".sdata") const u8 scCsFatalColorA = 0;
|
||||
#pragma pop
|
||||
extern "C" GXColor scCsFatalColor = {0xff, 0xff, 0xff, 0};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
int gDpdWaitFrm = 0;
|
||||
|
||||
#include "iplwww/www_wiisetting.h"
|
||||
|
||||
#include <string.h>
|
||||
@@ -9,16 +11,18 @@
|
||||
|
||||
#include "iplwww/www_browser.h"
|
||||
|
||||
int gDpdWaitFrm = 0;
|
||||
BOOL gEnableDpd = TRUE;
|
||||
|
||||
namespace www {
|
||||
namespace wiisetting {
|
||||
static const char emptyString[] = "";
|
||||
char MSG_TICK_TIMER_TAG[12] = "[TickTimer]";
|
||||
char MSG_WARNING_TAG[10] = "[Warning]";
|
||||
char MSG_EVENT_TAG[10] = "[[Event]]";
|
||||
const char* Message[] = {NULL, NULL, NULL, NULL, emptyString, NULL};
|
||||
struct ReportInfo {
|
||||
char tickTimerTag[12];
|
||||
char warningTag[10];
|
||||
char eventTag[10];
|
||||
const char* MessageArr[6];
|
||||
};
|
||||
|
||||
ReportInfo reportInfo = {"[TickTimer]", "[Warning]", "[[Event]]", {NULL, NULL, NULL, NULL, NULL, NULL}};
|
||||
|
||||
const u8 kbLangUsaLUT[][0x30] = {
|
||||
{
|
||||
@@ -150,8 +154,8 @@ namespace www {
|
||||
extern const char* strProps[FORM_ID_MAX];
|
||||
int getStringPropertyIdx(const char* targetStr) {
|
||||
const char* names[ARRAY_LENGTH(strProps)];
|
||||
const char** destinationName = names - 1;
|
||||
const char* const* sourceName = strProps - 1;
|
||||
const char** destinationName = names - 1;
|
||||
for (int i = 0; i < (ARRAY_LENGTH(names) >> 1); i++) {
|
||||
*(++destinationName) = *(++sourceName);
|
||||
*(++destinationName) = *(++sourceName);
|
||||
@@ -169,9 +173,19 @@ namespace www {
|
||||
return -1;
|
||||
}
|
||||
|
||||
static inline int getSettingProperty(const char* str, WWWJSPluginValue* val);
|
||||
|
||||
static inline void selectEuropeanKeyboardLanguage(u32& kbLang) {
|
||||
int i;
|
||||
for (i = 0; i < 0x3b; i++) {
|
||||
if (sWiiData.data[WB_ID_COUNTRY] == kbLangEurLUT[ipl::System::getLanguage() - 1][i] + 0x40) {
|
||||
kbLang = (u8)(i + 0x40);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int Getter_(WWWJSPluginObj* obj, const char* str, WWWJSPluginValue* val) {
|
||||
int retVal;
|
||||
int strPropIdx;
|
||||
if (strcmp(str, "CallOSReport") == 0) {
|
||||
int data;
|
||||
if (opera_callbacks->globalGet(obj, 0, 0, wiiOSReport, wiiOSReport, "", 0, (WWWJSPluginValueData*)&data) < 0) {
|
||||
@@ -191,6 +205,15 @@ namespace www {
|
||||
return 7;
|
||||
}
|
||||
}
|
||||
return getSettingProperty(str, val);
|
||||
}
|
||||
|
||||
static inline int getSettingProperty(const char* str, WWWJSPluginValue* val) {
|
||||
int privacyIndex;
|
||||
int retVal;
|
||||
SetStringBuf* strBuf;
|
||||
int maskLength;
|
||||
int strPropIdx;
|
||||
if (!(writeBackID == WB_ID_PROGRESSIVE || writeBackID == WB_ID_PAL || writeBackID == WB_ID_COUNTRY || writeBackID == WB_ID_LIGHT ||
|
||||
writeBackID == WB_ID_LANGUAGE || writeBackID == WB_ID_RATE)) {
|
||||
writeBackID = WB_ID_RESET;
|
||||
@@ -281,14 +304,13 @@ namespace www {
|
||||
memset(pString->asterisks, 0, sizeof(pString->asterisks));
|
||||
OSReport("mode %d %d\n", saveData, (u16)ipl::ncd::NCDSetting::getPrivacyMode());
|
||||
if (saveData == (u16)ipl::ncd::NCDSetting::getPrivacyMode()) {
|
||||
int i;
|
||||
OSReport("len ::: %d\n", ipl::ncd::NCDSetting::getPrivacyLen());
|
||||
for (i = 0; i < ipl::ncd::NCDSetting::getPrivacyLen(); i++) {
|
||||
pString->asterisks[i] = '*';
|
||||
for (privacyIndex = 0; privacyIndex < ipl::ncd::NCDSetting::getPrivacyLen(); privacyIndex++) {
|
||||
pString->asterisks[privacyIndex] = '*';
|
||||
}
|
||||
if (0x20 < i) {
|
||||
if (0x20 < privacyIndex) {
|
||||
pString->asterisks[0x20] = '\n';
|
||||
pString->asterisks[i] = '*';
|
||||
pString->asterisks[privacyIndex] = '*';
|
||||
}
|
||||
} else {
|
||||
memset(pString->securityKey, 0, sizeof(pString->securityKey));
|
||||
@@ -298,13 +320,11 @@ namespace www {
|
||||
}
|
||||
case FORM_ID_DUMMY_SECURITY_KEY: {
|
||||
memset(pString->asterisks, 0, sizeof(pString->asterisks));
|
||||
SetStringBuf* strBuf;
|
||||
int i;
|
||||
for (i = 0; i < strlen((strBuf = pString)->securityKey); strBuf->asterisks[i++] = '*') {
|
||||
for (maskLength = 0; maskLength < strlen((strBuf = pString)->securityKey); strBuf->asterisks[maskLength++] = '*') {
|
||||
}
|
||||
if (i > 0x20) {
|
||||
if (maskLength > 0x20) {
|
||||
pString->asterisks[0x20] = '\n';
|
||||
pString->asterisks[i] = '*';
|
||||
pString->asterisks[maskLength] = '*';
|
||||
}
|
||||
val->data.jsStr = pString->asterisks;
|
||||
break;
|
||||
@@ -522,12 +542,7 @@ namespace www {
|
||||
}
|
||||
}
|
||||
} else if ((u32)ipl::System::getRegion() == SC_PRODUCT_AREA_EUR) {
|
||||
for (int i = 0; i < 0x3b; i++) {
|
||||
if (sWiiData.data[WB_ID_COUNTRY] == kbLangEurLUT[ipl::System::getLanguage() - 1][i] + 0x40) {
|
||||
kbLang = (u8)(i + 0x40);
|
||||
break;
|
||||
}
|
||||
}
|
||||
selectEuropeanKeyboardLanguage(kbLang);
|
||||
}
|
||||
val->data.jsDouble = (u8)kbLang;
|
||||
}
|
||||
|
||||
@@ -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,12 +62,7 @@ namespace textinput {
|
||||
{ANM_InvalidOff, "fs_VK_predictInput_a_invalidMode_OFF.brlan"},
|
||||
};
|
||||
|
||||
struct CandidatePaneData {
|
||||
PaneToAnimation panes[26];
|
||||
char tail[12];
|
||||
};
|
||||
|
||||
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",
|
||||
@@ -196,22 +193,7 @@ namespace textinput {
|
||||
6,
|
||||
NULL,
|
||||
{&csAninationFile[0], &csAninationFile[8], &csAninationFile[9], &csAninationFile[10], &csAninationFile[11], &csAninationFile[12]}},
|
||||
}, {"P_OffBtn"}};
|
||||
|
||||
extern "C" char scPaneNameTable[132] =
|
||||
"B_OffBtn\0\0\0\0"
|
||||
"P_JPOffBtn\0\0"
|
||||
"P_CNOffBtn\0\0"
|
||||
"P_CNOnBtn\0\0\0"
|
||||
"B_prdc_scrl_Left\0\0\0\0"
|
||||
"P_prdc_scrl_Left\0\0\0\0"
|
||||
"B_prdc_scrl_Rght\0\0\0\0"
|
||||
"P_prdc_scrl_Rght\0\0\0\0"
|
||||
"\0\0\0";
|
||||
extern "C" char scW_predictWindow[16] = "W_predictWindow";
|
||||
extern "C" char scN_predictInput[15] = "N_predictInput";
|
||||
extern "C" char scW_OnOff_Area[13] = "W_OnOff_Area";
|
||||
extern "C" char scN_prdc_Texts[13] = "N_prdc_Texts";
|
||||
};
|
||||
|
||||
void CandidateBoxCaller::Candidates::addCandidate(const wchar_t* wcString) {
|
||||
wcsncpy(szwcPredicted[mNumCandidate], wcString, ARRAY_LENGTH(szwcPredicted[0]));
|
||||
@@ -383,72 +365,60 @@ namespace textinput {
|
||||
mTextArea.Init();
|
||||
mOnOffButton.Create(this);
|
||||
mOnOffButton.Init();
|
||||
const char* paneNames = scPaneNameTable;
|
||||
const char* leftScrollBoundName = paneNames + 48;
|
||||
const char* leftScrollPaneName = paneNames + 68;
|
||||
mLeftScroll.Create(this, leftScrollPaneName, leftScrollBoundName);
|
||||
const char* rightScrollBoundName = paneNames + 88;
|
||||
const char* rightScrollPaneName = paneNames + 108;
|
||||
mRightScroll.Create(this, rightScrollPaneName, rightScrollBoundName);
|
||||
mLeftScroll.Create(this, "P_prdc_scrl_Left", "B_prdc_scrl_Left");
|
||||
mRightScroll.Create(this, "P_prdc_scrl_Rght", "B_prdc_scrl_Rght");
|
||||
mLeftScroll.Init();
|
||||
mRightScroll.Init();
|
||||
const char* windowName = scW_predictWindow;
|
||||
mTextWindow.Create(this, windowName);
|
||||
mTextWindow.Create(this, "W_predictWindow");
|
||||
init();
|
||||
}
|
||||
|
||||
void LayoutByNW4R::createAnmPane_(MEMAllocator* allocator) {
|
||||
CandidateTextAnmPane* pane;
|
||||
u16 j;
|
||||
u16 i;
|
||||
for (i = 0; i < ARRAY_LENGTH(scCandidatePaneData.panes); i++) {
|
||||
pane = NULL;
|
||||
const PaneToAnimation& p = scCandidatePaneData.panes[i];
|
||||
switch (p.type) {
|
||||
for (u16 i = 0; i < ARRAY_LENGTH(csPaneToAnimation); i++) {
|
||||
const PaneToAnimation& paneAnimations = csPaneToAnimation[i];
|
||||
CandidateTextAnmPane* pane = NULL;
|
||||
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);
|
||||
|
||||
const char* forceAddName = p.forceAddName;
|
||||
u32 animationCount = p.count;
|
||||
for (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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LayoutByNW4R::init() {
|
||||
searchAnmPane(scN_predictInput)->changeAnimation(ANM_Normal);
|
||||
searchAnmPane("N_predictInput")->changeAnimation(ANM_Normal);
|
||||
Base::setInvalid(false);
|
||||
setActive(true);
|
||||
setOnOff(false);
|
||||
@@ -461,7 +431,7 @@ namespace textinput {
|
||||
mpLayout->CalculateMtx(mDrawInfo);
|
||||
if (meLanguage == KR) {
|
||||
mTextWindow.SetVisible(false);
|
||||
getPane(scW_OnOff_Area)->SetVisible(false);
|
||||
getPane("W_OnOff_Area")->SetVisible(false);
|
||||
} else if (meLanguage == CN) {
|
||||
setOnOff(true);
|
||||
mTextWindow.SetVisible(true);
|
||||
@@ -471,16 +441,16 @@ namespace textinput {
|
||||
} else {
|
||||
mTextWindow.ChangeAnimation(ANM_Normal);
|
||||
}
|
||||
getPane(scW_OnOff_Area)->SetVisible(false);
|
||||
getPane("W_OnOff_Area")->SetVisible(false);
|
||||
} else {
|
||||
getPane(scW_OnOff_Area)->SetVisible(true);
|
||||
getPane("W_OnOff_Area")->SetVisible(true);
|
||||
}
|
||||
}
|
||||
|
||||
void LayoutByNW4R::draw() {
|
||||
getPane(scN_prdc_Texts)->SetVisible(false);
|
||||
getPane("N_prdc_Texts")->SetVisible(false);
|
||||
nw4rmanager::Layout::draw();
|
||||
getPane(scN_prdc_Texts)->SetVisible(true);
|
||||
getPane("N_prdc_Texts")->SetVisible(true);
|
||||
if (!isInvalid()) {
|
||||
mTextArea.Draw(mDrawInfo);
|
||||
}
|
||||
@@ -490,8 +460,8 @@ namespace textinput {
|
||||
nw4rmanager::Layout::calc();
|
||||
mTextArea.Calc();
|
||||
if (mbAnimOn) {
|
||||
getPane(scN_prdc_Texts)->Animate(0);
|
||||
getPane(scN_prdc_Texts)->CalculateMtx(mDrawInfo);
|
||||
getPane("N_prdc_Texts")->Animate(0);
|
||||
getPane("N_prdc_Texts")->CalculateMtx(mDrawInfo);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -499,7 +469,7 @@ namespace textinput {
|
||||
Base::setLanguage(language);
|
||||
init();
|
||||
// Maybe inlines, maybe not
|
||||
nw4r::math::VEC3 pos = searchAnmPane(scW_predictWindow)->getPane()->GetTranslate();
|
||||
nw4r::math::VEC3 pos = searchAnmPane("W_predictWindow")->getPane()->GetTranslate();
|
||||
if (meLanguage == CN || meLanguage == KR) {
|
||||
Base::checkValidation();
|
||||
// Potentially an inline
|
||||
@@ -514,7 +484,7 @@ namespace textinput {
|
||||
pos.x = 202.0f;
|
||||
}
|
||||
|
||||
searchAnmPane(scW_predictWindow)->getPane()->SetTranslate(pos);
|
||||
searchAnmPane("W_predictWindow")->getPane()->SetTranslate(pos);
|
||||
if (meLanguage == CN) {
|
||||
mTextArea.ApplyFontScale(1.2f);
|
||||
} else if (meLanguage == KR) {
|
||||
@@ -631,7 +601,7 @@ namespace textinput {
|
||||
current = reinterpret_cast<CandidateBoxCaller::Candidates*>(reinterpret_cast<u8*>(current) + sizeof(current->szwcPredicted[0]));
|
||||
}
|
||||
}
|
||||
gui::PaneComponent* p = mpPaneManager->searchPaneComponent(isOn() ? scB_OnBtn : scPaneNameTable);
|
||||
gui::PaneComponent* p = mpPaneManager->searchPaneComponent(isOn() ? scB_OnBtn : "B_OffBtn");
|
||||
if (p != NULL) {
|
||||
p->lockInitialize(true);
|
||||
}
|
||||
@@ -700,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()) {
|
||||
@@ -1009,7 +979,7 @@ namespace textinput {
|
||||
mpBoundingPane[i]->setListener(this);
|
||||
}
|
||||
mpTextAreaPane = mgr->searchPaneComponent("N_prdcTextArea");
|
||||
mpTextsPane = mgr->searchPaneComponent(scN_prdc_Texts);
|
||||
mpTextsPane = mgr->searchPaneComponent("N_prdc_Texts");
|
||||
mSize = mpTextBoxPane[0]->getTextPane()->GetFontSize();
|
||||
mpTextAreaPane->setListener(this);
|
||||
}
|
||||
@@ -1494,7 +1464,7 @@ namespace textinput {
|
||||
if (mgr()->isInScroll() && event != gui::EventHandler::ON_LEFT && event != gui::EventHandler::ON_POINT) {
|
||||
return;
|
||||
}
|
||||
if (!mgr()->searchAnmPane(scW_predictWindow)->isInAnimation() || event == gui::EventHandler::ON_LEFT) {
|
||||
if (!mgr()->searchAnmPane("W_predictWindow")->isInAnimation() || event == gui::EventHandler::ON_LEFT) {
|
||||
if (!mgr()->isInvalid()) {
|
||||
switch (event) {
|
||||
case gui::EventHandler::ON_TRIG:
|
||||
@@ -1645,7 +1615,7 @@ namespace textinput {
|
||||
if (mgr()->isInScroll() && event != gui::EventHandler::ON_LEFT && event != gui::EventHandler::ON_POINT) {
|
||||
return;
|
||||
}
|
||||
if (!mgr()->searchAnmPane(scW_predictWindow)->isInAnimation() || event == gui::EventHandler::ON_LEFT) {
|
||||
if (!mgr()->searchAnmPane("W_predictWindow")->isInAnimation() || event == gui::EventHandler::ON_LEFT) {
|
||||
if (!mgr()->isInvalid()) {
|
||||
switch (event) {
|
||||
case gui::EventHandler::ON_TRIG:
|
||||
@@ -1691,15 +1661,15 @@ namespace textinput {
|
||||
mpOnPictPane = mgr->searchPaneComponent(scP_OnBtn);
|
||||
mpOnBoundPane = mgr->searchPaneComponent(scB_OnBtn);
|
||||
mpOnAnmPane = static_cast<OnOffAnmPane*>(layout->searchAnmPane(scP_OnBtn));
|
||||
mpOffPictPane = mgr->searchPaneComponent(scCandidatePaneData.tail);
|
||||
mpOffBoundPane = mgr->searchPaneComponent(scPaneNameTable);
|
||||
mpOffAnmPane = static_cast<OnOffAnmPane*>(layout->searchAnmPane(scCandidatePaneData.tail));
|
||||
mpOffPictPane = mgr->searchPaneComponent("P_OffBtn");
|
||||
mpOffBoundPane = mgr->searchPaneComponent("B_OffBtn");
|
||||
mpOffAnmPane = static_cast<OnOffAnmPane*>(layout->searchAnmPane("P_OffBtn"));
|
||||
|
||||
layout->getLayout()->GetRootPane()->FindPaneByName(scCandidatePaneData.tail)->GetMaterial()->GetTexture(&mOffTexDefault, 0);
|
||||
layout->getLayout()->GetRootPane()->FindPaneByName(scPaneNameTable + 12)->GetMaterial()->GetTexture(&mOffTexJP, 0);
|
||||
layout->getLayout()->GetRootPane()->FindPaneByName(scPaneNameTable + 24)->GetMaterial()->GetTexture(&mOffTexCN, 0);
|
||||
layout->getLayout()->GetRootPane()->FindPaneByName("P_OffBtn")->GetMaterial()->GetTexture(&mOffTexDefault, 0);
|
||||
layout->getLayout()->GetRootPane()->FindPaneByName("P_JPOffBtn")->GetMaterial()->GetTexture(&mOffTexJP, 0);
|
||||
layout->getLayout()->GetRootPane()->FindPaneByName("P_CNOffBtn")->GetMaterial()->GetTexture(&mOffTexCN, 0);
|
||||
layout->getLayout()->GetRootPane()->FindPaneByName(scP_OnBtn)->GetMaterial()->GetTexture(&mOnTexDefault, 0);
|
||||
layout->getLayout()->GetRootPane()->FindPaneByName(scPaneNameTable + 36)->GetMaterial()->GetTexture(&mOnTexCN, 0);
|
||||
layout->getLayout()->GetRootPane()->FindPaneByName("P_CNOnBtn")->GetMaterial()->GetTexture(&mOnTexCN, 0);
|
||||
|
||||
mpOffBoundPane->setListener(this);
|
||||
mpOnBoundPane->setListener(this);
|
||||
@@ -1755,7 +1725,7 @@ namespace textinput {
|
||||
if (mgr()->isInScroll() && event != gui::EventHandler::ON_LEFT && event != gui::EventHandler::ON_POINT) {
|
||||
return;
|
||||
}
|
||||
if (!mgr()->searchAnmPane(scW_predictWindow)->isInAnimation() || event == gui::EventHandler::ON_LEFT) {
|
||||
if (!mgr()->searchAnmPane("W_predictWindow")->isInAnimation() || event == gui::EventHandler::ON_LEFT) {
|
||||
OnOffAnmPane* p;
|
||||
if (&component == mpOnBoundPane) {
|
||||
p = mpOnAnmPane;
|
||||
@@ -1788,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;
|
||||
}
|
||||
|
||||
@@ -137,23 +137,20 @@ extern "C" asm void calc__Q39textinput9inputform4BaseFv();
|
||||
extern "C" asm void calc__Q39textinput11nw4rmanager6LayoutFv();
|
||||
extern "C" asm void draw__Q39textinput11nw4rmanager6LayoutFv();
|
||||
extern "C" asm void searchPaneComponent__Q39textinput3gui11PaneManagerFPCc();
|
||||
#pragma push
|
||||
#pragma section const_type ".data"
|
||||
extern "C" const char scP_txtScrll_UP[];
|
||||
extern "C" const char scP_txtScrll_DOWN[];
|
||||
extern "C" const char scN_JPNUSAEUR[];
|
||||
extern "C" const char scN_separateBarAll[];
|
||||
extern "C" const char scT_2l_TextBox[];
|
||||
extern "C" const char scT_title_textJPN[];
|
||||
extern "C" const char scN_separateBarKOR[];
|
||||
extern "C" const char scT_2l_TextBoxKOR[];
|
||||
extern "C" const char scT_title_textKOR[];
|
||||
extern "C" const char scN_separateBarCHN[];
|
||||
extern "C" const char scT_2l_TextBoxCHN[];
|
||||
extern "C" const char scT_title_textCHN[];
|
||||
extern "C" char scP_txtScrll_UP[];
|
||||
extern "C" char scP_txtScrll_DOWN[];
|
||||
extern "C" char scN_JPNUSAEUR[];
|
||||
extern "C" char scN_separateBarAll[];
|
||||
extern "C" char scT_2l_TextBox[];
|
||||
extern "C" char scT_title_textJPN[];
|
||||
extern "C" char scN_separateBarKOR[];
|
||||
extern "C" char scT_2l_TextBoxKOR[];
|
||||
extern "C" char scT_title_textKOR[];
|
||||
extern "C" char scN_separateBarCHN[];
|
||||
extern "C" char scT_2l_TextBoxCHN[];
|
||||
extern "C" char scT_title_textCHN[];
|
||||
extern "C" const char scN_KOR[];
|
||||
extern "C" const char scN_CHN[];
|
||||
#pragma pop
|
||||
extern "C" const f32 scInputFormZeroF;
|
||||
extern "C" void _savegpr_20();
|
||||
extern "C" void _restgpr_20();
|
||||
@@ -321,8 +318,6 @@ struct InputFormAnimationFile {
|
||||
char fileName[0x40];
|
||||
};
|
||||
|
||||
#pragma push
|
||||
#pragma section const_type ".rodata"
|
||||
extern "C" const InputFormAnimationFile csAninationFile__Q29textinput9inputform[8] = {
|
||||
{0, "fs_VK_textBox_a_normal.brlan"},
|
||||
{1, "fs_VK_textBox_a_Foucus_IN.brlan"},
|
||||
@@ -334,7 +329,6 @@ extern "C" const InputFormAnimationFile csAninationFile__Q29textinput9inputform[
|
||||
{7, "fs_VK_textBox_a_Off.brlan"},
|
||||
};
|
||||
|
||||
#pragma section data_type ".rodata"
|
||||
extern "C" const VisiblePanes csVisiblePaneUEJ__Q29textinput9inputform = {
|
||||
1, 2,
|
||||
{scN_JPNUSAEUR, NULL, NULL, NULL},
|
||||
@@ -347,7 +341,7 @@ extern "C" const VisiblePanes csVisiblePaneKOR__Q29textinput9inputform = {
|
||||
{"N_CHN", scN_JPNUSAEUR, NULL, NULL},
|
||||
};
|
||||
|
||||
extern "C" const void* csVisiblePaneCHN__Q29textinput9inputform[10] = {
|
||||
extern "C" const void* const csVisiblePaneCHN__Q29textinput9inputform[10] = {
|
||||
(const void*)0x00010002,
|
||||
"N_CHN",
|
||||
0,
|
||||
@@ -380,11 +374,9 @@ extern "C" const LanguagePaneData csLanguageDependencyDataCHN__Q29textinput9inpu
|
||||
scT_2l_TextBoxCHN,
|
||||
scT_title_textCHN,
|
||||
};
|
||||
#pragma section data_type ".data"
|
||||
|
||||
extern "C" const wchar_t pppURLCheck[2][10] = {L"http://", L"https://"};
|
||||
|
||||
#pragma pop
|
||||
|
||||
extern "C" const f32 scInputFormZeroF = 0.0f;
|
||||
extern "C" const f32 scInputForm640F = 640.0f;
|
||||
@@ -415,10 +407,8 @@ f32 sfColorPhase;
|
||||
|
||||
bool mbHyphen = true;
|
||||
|
||||
#pragma push
|
||||
#pragma section const_type ".data"
|
||||
extern "C" const char scP_txtScrll_UP[] = "P_txtScrll_UP";
|
||||
extern "C" const char scP_txtScrll_DOWN[] = "P_txtScrll_DOWN";
|
||||
extern "C" char scP_txtScrll_UP[] = "P_txtScrll_UP";
|
||||
extern "C" char scP_txtScrll_DOWN[] = "P_txtScrll_DOWN";
|
||||
struct ButtonAnimations {
|
||||
KeyType type;
|
||||
const char* paneName;
|
||||
@@ -427,7 +417,7 @@ struct ButtonAnimations {
|
||||
const InputFormAnimationFile* files[12];
|
||||
};
|
||||
|
||||
const ButtonAnimations csButtonAnimations[] = {
|
||||
ButtonAnimations csButtonAnimations[] = {
|
||||
{KT_NormalButton, scP_txtScrll_UP, 8, NULL, {
|
||||
&csAninationFile__Q29textinput9inputform[0], &csAninationFile__Q29textinput9inputform[1],
|
||||
&csAninationFile__Q29textinput9inputform[2], &csAninationFile__Q29textinput9inputform[3],
|
||||
@@ -439,18 +429,20 @@ const ButtonAnimations csButtonAnimations[] = {
|
||||
&csAninationFile__Q29textinput9inputform[4], &csAninationFile__Q29textinput9inputform[5],
|
||||
&csAninationFile__Q29textinput9inputform[6], &csAninationFile__Q29textinput9inputform[7]}}
|
||||
};
|
||||
extern "C" const char scN_JPNUSAEUR[] = "N_JPNUSAEUR";
|
||||
extern "C" const char scN_separateBarAll[] = "N_separateBarAll";
|
||||
extern "C" const char scT_2l_TextBox[] = "T_2l_TextBox";
|
||||
extern "C" const char scT_title_textJPN[] = "T_title_textJPN";
|
||||
extern "C" const char scN_separateBarKOR[] = "N_separateBarKOR";
|
||||
extern "C" const char scT_2l_TextBoxKOR[] = "T_2l_TextBoxKOR";
|
||||
extern "C" const char scT_title_textKOR[] = "T_title_textKOR";
|
||||
extern "C" const char scN_separateBarCHN[] = "N_separateBarCHN";
|
||||
extern "C" const char scT_2l_TextBoxCHN[] = "T_2l_TextBoxCHN";
|
||||
extern "C" const char scT_title_textCHN[] = "T_title_textCHN";
|
||||
extern "C" char scN_JPNUSAEUR[] = "N_JPNUSAEUR";
|
||||
extern "C" char scN_separateBarAll[] = "N_separateBarAll";
|
||||
extern "C" char scT_2l_TextBox[] = "T_2l_TextBox";
|
||||
extern "C" char scT_title_textJPN[] = "T_title_textJPN";
|
||||
extern "C" char scN_separateBarKOR[] = "N_separateBarKOR";
|
||||
extern "C" char scT_2l_TextBoxKOR[] = "T_2l_TextBoxKOR";
|
||||
extern "C" char scT_title_textKOR[] = "T_title_textKOR";
|
||||
extern "C" char scN_separateBarCHN[] = "N_separateBarCHN";
|
||||
extern "C" char scT_2l_TextBoxCHN[] = "T_2l_TextBoxCHN";
|
||||
extern "C" char scT_title_textCHN[] = "T_title_textCHN";
|
||||
bool DeadKeyStream::sbCompatibleFilterEnabled = true;
|
||||
|
||||
#pragma push
|
||||
#pragma section const_type ".data"
|
||||
inline bool DeadKeyStream::isCompatible(wchar_t character) {
|
||||
const wchar_t excluded[] = {
|
||||
0x00a4, 0x00ac, 0x00af, 0x00b2, 0x00b3, 0x00b6, 0x00b8, 0x00b9,
|
||||
@@ -462,6 +454,7 @@ inline bool DeadKeyStream::isCompatible(wchar_t character) {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
#pragma pop
|
||||
|
||||
inline wchar_t DeadKeyStream::getChar() {
|
||||
wchar_t character = KPRGetChar(&mKPRQueue);
|
||||
@@ -1349,7 +1342,6 @@ void LayoutByNW4R::onCommand(INPUT_COMMAND command, void* data) {
|
||||
}
|
||||
|
||||
|
||||
#pragma pop
|
||||
|
||||
void EventHandler::onTiEvent(gui::PaneComponent* component, u32 event, Input* input) {
|
||||
char animationName[17];
|
||||
|
||||
@@ -35,7 +35,6 @@ namespace textinput {
|
||||
{ANM_RollOver, "fs_prdicSelWidw_a_PRDC_Roll_over.brlan"}, {ANM_ToggleOff, "fs_prdicSelWidw_a_PRDC_toggle-OFF.brlan"},
|
||||
{ANM_ToggleOn, "fs_prdicSelWidw_a_PRDC_toggle-ON.brlan"}};
|
||||
|
||||
extern "C" __declspec(section ".rodata") const u32 tiPredictLang_rodata_pad = 0;
|
||||
|
||||
static const PaneToAnimation csPaneToAnimation[] = {
|
||||
{KT_Whole, "N_PRDCkeytop_all", 3, NULL, {&csAninationFile[0], &csAninationFile[4], &csAninationFile[5]}},
|
||||
|
||||
@@ -295,13 +295,40 @@ confirmLetters:
|
||||
update();
|
||||
}
|
||||
|
||||
static inline void CopyWordSuffix(u16* word, u32 length) {
|
||||
u32 wordLength;
|
||||
u32 copied;
|
||||
wordLength = wcslen((wchar_t*)word) & 0xff;
|
||||
for (copied = 0; copied < length; ++copied) {
|
||||
word[copied] = word[(wordLength - length) + copied];
|
||||
}
|
||||
word[copied] = 0;
|
||||
}
|
||||
|
||||
void WithZi::update() {
|
||||
u16* koreanOutput;
|
||||
u16* keyOutput;
|
||||
wchar_t* candidateOutput;
|
||||
u16* destination;
|
||||
u32 copyLength;
|
||||
u16 keyCharacter;
|
||||
u16* wordOutput;
|
||||
u16* letter;
|
||||
u32 count;
|
||||
s32 elementCount;
|
||||
u16* source;
|
||||
s32 keyIndex;
|
||||
s32 position;
|
||||
s32 candidateLength;
|
||||
u16 character;
|
||||
s32 index;
|
||||
|
||||
if (mbDictionaryOpen == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
mSelectedCandidate = 0;
|
||||
s32 elementCount = static_cast<u16>(setElementBuffer());
|
||||
elementCount = static_cast<u16>(setElementBuffer());
|
||||
mSearch.language = getPredictLanguage();
|
||||
mSearch.subLanguage = 7;
|
||||
mSearch.getMode = 0;
|
||||
@@ -339,24 +366,23 @@ void WithZi::update() {
|
||||
CandidatedWord[0] = L'>';
|
||||
CandidatedWord[1] = 0;
|
||||
mCandidateCount = 1;
|
||||
u16* output = CandidatedWord + 0x40;
|
||||
for (s32 keyIndex = 1; keyIndex < 16; ++keyIndex) {
|
||||
u16 candidate = static_cast<keyboard::cellphonetype::PaneNameToCharCode*>(mpHoldingKey)->wc[keyIndex - 1];
|
||||
if (candidate != 0) {
|
||||
output[0] = candidate;
|
||||
output[1] = 0;
|
||||
keyOutput = CandidatedWord;
|
||||
for (keyIndex = 1; keyIndex < 16; ++keyIndex) {
|
||||
keyCharacter = static_cast<keyboard::cellphonetype::PaneNameToCharCode*>(mpHoldingKey)->wc[keyIndex - 1];
|
||||
if (keyCharacter != 0) {
|
||||
keyOutput[keyIndex * 0x40] = keyCharacter;
|
||||
keyOutput[keyIndex * 0x40 + 1] = 0;
|
||||
++mCandidateCount;
|
||||
}
|
||||
output += 0x40;
|
||||
}
|
||||
EZTXGetCandidates(&mSearch, mpDictionaryWork);
|
||||
}
|
||||
else {
|
||||
memcpy(PredictionBuffer, CandidatesBuffer, 0x200);
|
||||
ChangeDictionaryLanguage(getPredictLanguage());
|
||||
u32 count = EZTXGetCandidates(&mSearch, mpDictionaryWork) & 0xff;
|
||||
count = EZTXGetCandidates(&mSearch, mpDictionaryWork) & 0xff;
|
||||
if (getPredictLanguage() == ZI8_LANG_ZH && count == 0x61) {
|
||||
wchar_t* candidateOutput = reinterpret_cast<wchar_t*>(PredictionBuffer);
|
||||
candidateOutput = reinterpret_cast<wchar_t*>(PredictionBuffer);
|
||||
mSearch.firstCandidate = 0x61;
|
||||
mSearch.candidates = candidateOutput + 0xC2;
|
||||
mSearch.maxCandidates = 199;
|
||||
@@ -369,13 +395,8 @@ void WithZi::update() {
|
||||
}
|
||||
if (getPredictLanguage() == ZI8_LANG_ZH && mbContextChanged != 0 &&
|
||||
(mbContextChanged = 0, mSearch.count == 0)) {
|
||||
u32 length = mCurrentWordLength;
|
||||
u32 wordLength = wcslen((wchar_t*)LatestWord) & 0xff;
|
||||
u32 copied;
|
||||
for (copied = 0; copied < length; ++copied) {
|
||||
LatestWord[copied] = LatestWord[(wordLength - length) + copied];
|
||||
}
|
||||
LatestWord[copied] = 0;
|
||||
copyLength = mCurrentWordLength;
|
||||
CopyWordSuffix(LatestWord, copyLength);
|
||||
mSearch.wordCharCount = wcslen((wchar_t*)LatestWord);
|
||||
count = EZTXGetCandidates(&mSearch, mpDictionaryWork) & 0xff;
|
||||
}
|
||||
@@ -392,28 +413,25 @@ void WithZi::update() {
|
||||
memset(CandidatedWord, 0, 0x1400);
|
||||
mCandidateCount = 0;
|
||||
if (elementCount != 0 || mSearch.wordCharCount != 0) {
|
||||
u16* source = reinterpret_cast<u16*>(mSearch.candidates);
|
||||
u16* destination = CandidatedWord;
|
||||
for (s32 index = 0; index < static_cast<s32>(count); index++) {
|
||||
source = reinterpret_cast<u16*>(mSearch.candidates);
|
||||
destination = CandidatedWord;
|
||||
for (index = 0; index < static_cast<s32>(count); index++) {
|
||||
if (getPredictLanguage() == ZI8_LANG_ZH) {
|
||||
u16* output;
|
||||
s32 length;
|
||||
length = 0;
|
||||
output = destination;
|
||||
candidateLength = 0;
|
||||
wordOutput = destination;
|
||||
for (; *source != L' ' && *source != 0; source++) {
|
||||
*output++ = *source;
|
||||
++length;
|
||||
*wordOutput++ = *source;
|
||||
++candidateLength;
|
||||
}
|
||||
++source;
|
||||
destination[length] = 0;
|
||||
destination[candidateLength] = 0;
|
||||
} else if (mPredictLanguage == PL_11) {
|
||||
*destination = *source++;
|
||||
destination[1] = 0;
|
||||
} else if (getPredictLanguage() == ZI8_LANG_KO) {
|
||||
u16* output = destination;
|
||||
u16 character;
|
||||
koreanOutput = destination;
|
||||
while ((character = *source) >= 0x100) {
|
||||
*output++ = character;
|
||||
*koreanOutput++ = character;
|
||||
++source;
|
||||
}
|
||||
} else if (EZTXCopy(reinterpret_cast<wchar_t*>(destination), &mSearch, index & 0xff, mpDictionaryWork) == 0) {
|
||||
@@ -421,20 +439,18 @@ void WithZi::update() {
|
||||
}
|
||||
++mCandidateCount;
|
||||
{
|
||||
u16* candidate;
|
||||
s32 position;
|
||||
position = 0;
|
||||
for (candidate = destination; *candidate != 0; ++candidate, ++position) {
|
||||
for (letter = destination; *letter != 0; ++letter, ++position) {
|
||||
switch (mLetterMode) {
|
||||
case LM_1:
|
||||
*candidate = util::toWLower(*candidate);
|
||||
*letter = util::toWLower(*letter);
|
||||
break;
|
||||
case LM_2:
|
||||
*candidate = util::toWUpper(*candidate);
|
||||
*letter = util::toWUpper(*letter);
|
||||
break;
|
||||
case LM_0:
|
||||
if (position == 0) *candidate = util::toWUpper(*candidate);
|
||||
else *candidate = util::toWLower(*candidate);
|
||||
if (position == 0) *letter = util::toWUpper(*letter);
|
||||
else *letter = util::toWLower(*letter);
|
||||
break;
|
||||
case LM_3:
|
||||
break;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1243,14 +1243,30 @@ namespace ipl {
|
||||
return result;
|
||||
}
|
||||
|
||||
DECOMP_FORCE_ACTIVE(iplFocusObject_cpp, L".html");
|
||||
DECOMP_FORCE_ACTIVE(iplFocusObject_cpp, L".htm");
|
||||
DECOMP_FORCE_ACTIVE(iplFocusObject_cpp, L".shtml");
|
||||
DECOMP_FORCE_ACTIVE(iplFocusObject_cpp, L".shtm");
|
||||
DECOMP_FORCE_ACTIVE(iplFocusObject_cpp, L".cgi");
|
||||
DECOMP_FORCE_ACTIVE(iplFocusObject_cpp, L".php");
|
||||
DECOMP_FORCE_ACTIVE(iplFocusObject_cpp, L".asp");
|
||||
DECOMP_FORCE_ACTIVE(iplFocusObject_cpp, L".jsp");
|
||||
BOOL focus_object::is_url_ext(const wchar_t* url) const {
|
||||
BOOL result = FALSE;
|
||||
u32 len = wcslen(url);
|
||||
const wchar_t* exts[8];
|
||||
int i;
|
||||
|
||||
exts[0] = L".html";
|
||||
exts[1] = L".htm";
|
||||
exts[2] = L".shtml";
|
||||
exts[3] = L".shtm";
|
||||
exts[4] = L".cgi";
|
||||
exts[5] = L".php";
|
||||
exts[6] = L".asp";
|
||||
exts[7] = L".jsp";
|
||||
|
||||
for (i = 0; i < 8; i++) {
|
||||
u32 extLen = wcslen(exts[i]);
|
||||
if (len >= extLen && wcsncmp(url + (len - extLen), exts[i], extLen) == 0) {
|
||||
result = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
int focus_object::get_url_end(const wchar_t* url) const {
|
||||
int i;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include "iplSystem.h"
|
||||
|
||||
__declspec(section ".sdata") extern char scPaneName_B_Stop[];
|
||||
extern char scPaneName_B_Stop[7];
|
||||
extern char scPaneName_T_Stop[];
|
||||
extern "C" BOOL push_button_queue(void*, const void*);
|
||||
|
||||
|
||||
@@ -403,43 +403,86 @@ static inline void sendValidityResponse(u32 command, u32 valid) {
|
||||
u32 value;
|
||||
struct { u32 upper : 16; u32 valid : 8; u32 command : 8; } fields;
|
||||
} reply;
|
||||
reply.value = command;
|
||||
reply.fields.valid = valid;
|
||||
reply.value = valid << 8;
|
||||
reply.fields.command = command;
|
||||
OSSendMessage(&sThread->responses, (OSMessage)reply.value, OS_MESSAGE_BLOCK);
|
||||
}
|
||||
|
||||
extern "C" void* cardThreadMain(void*) {
|
||||
struct CardThreadLocals {
|
||||
u8 compareName[6];
|
||||
u32 message;
|
||||
CARDDir freeDir;
|
||||
CARDDir mountDir;
|
||||
CARDDir listingDir;
|
||||
char fileName[33];
|
||||
} local;
|
||||
BOOL brokenFile;
|
||||
BOOL exitThread = FALSE;
|
||||
u32 validState = TRUE;
|
||||
u32 command;
|
||||
s16 fileNo;
|
||||
u8 slot;
|
||||
static inline u8 getCardCommandSlot(u32 message) {
|
||||
u8 slot = message >> 16;
|
||||
slot &= 1;
|
||||
return slot;
|
||||
}
|
||||
|
||||
static inline s32 countCardTitleBlocks(s32 slot, CARDDir* dir) {
|
||||
s32 fileNo;
|
||||
s32 result;
|
||||
s32 blocks;
|
||||
blocks = 0;
|
||||
for (fileNo = 0; fileNo < CARD_MAX_FILE; ++fileNo) {
|
||||
result = __CARDGetStatusEx(slot, fileNo, dir);
|
||||
if (result < CARD_RESULT_READY && result != CARD_RESULT_NOFILE) {
|
||||
blocks = -1;
|
||||
break;
|
||||
}
|
||||
if (result == CARD_RESULT_READY &&
|
||||
memcmp(dir->gameName, (void*)0x80000000, 4) == 0 &&
|
||||
memcmp(dir->company, (void*)0x80000004, 2) == 0) {
|
||||
blocks += dir->length;
|
||||
}
|
||||
}
|
||||
return blocks;
|
||||
}
|
||||
|
||||
static inline void listCardFiles(u8 slot, CARDDir& dir, char* fileName) {
|
||||
u32 fileNo;
|
||||
for (fileNo = 0; fileNo < CARD_MAX_FILE; ++fileNo) {
|
||||
if (__CARDGetStatusEx(slot, (u16)fileNo, &dir) == CARD_RESULT_READY) {
|
||||
memcpy(fileName, dir.fileName, CARD_FILENAME_MAX);
|
||||
fileName[CARD_FILENAME_MAX] = 0;
|
||||
OSReport("%d - %s: %d blocks\n", (u16)fileNo, fileName, dir.length);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static inline void deleteCardFile(u8 slot, s16 fileNo) {
|
||||
s32 result = CARDFastDelete(slot, fileNo);
|
||||
if (result < CARD_RESULT_READY) {
|
||||
reportCardThreadError(slot, 4, result);
|
||||
} else {
|
||||
clearCardFileEntry(slot, fileNo);
|
||||
refreshCardSlotInfo(slot);
|
||||
sendCardSlotState(slot, 4, (u8)fileNo);
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" void* cardThreadMain(void*) {
|
||||
char fileName[33];
|
||||
CARDDir listingDir;
|
||||
CARDDir mountDir;
|
||||
CARDDir freeDir;
|
||||
u32 message;
|
||||
s32 result;
|
||||
u8 slot;
|
||||
BOOL brokenFile;
|
||||
s32 scanResult;
|
||||
s32 file;
|
||||
u32 listingFile;
|
||||
s32 outerSlot;
|
||||
s32 freeFile;
|
||||
s32 freeBlocks;
|
||||
s32 outerSlot;
|
||||
u32 validState = TRUE;
|
||||
BOOL exitThread = FALSE;
|
||||
u32 command;
|
||||
|
||||
sThread->mounted[0] = 0;
|
||||
sThread->mounted[1] = 0;
|
||||
goto loopCheck;
|
||||
loopStart:
|
||||
OSReceiveMessage(&sThread->requests, (OSMessage*)&local.message, OS_MESSAGE_BLOCK);
|
||||
OSReport("CARD THREAD: Message received %d\n", (s8)(u8)local.message);
|
||||
OSReceiveMessage(&sThread->requests, (OSMessage*)&message, OS_MESSAGE_BLOCK);
|
||||
OSReport("CARD THREAD: Message received %d\n", (s8)(u8)message);
|
||||
if (validState != TRUE) {
|
||||
goto loopCheck;
|
||||
}
|
||||
command = local.message & 0xFF;
|
||||
command = message & 0xFF;
|
||||
|
||||
switch ((s8)command) {
|
||||
case 10:
|
||||
@@ -451,8 +494,8 @@ loopStart:
|
||||
exitThread = TRUE;
|
||||
break;
|
||||
case 0: {
|
||||
slot = (local.message >> 16) & 1;
|
||||
command = (local.message >> 14) & 4;
|
||||
slot = getCardCommandSlot(message);
|
||||
command = (message >> 14) & 4;
|
||||
result = CARDMount(slot, sThread->mountBuffers[command / 4], 0);
|
||||
if (result < CARD_RESULT_READY) {
|
||||
result = handleCardMountResult(slot, result);
|
||||
@@ -461,15 +504,15 @@ loopStart:
|
||||
}
|
||||
break;
|
||||
}
|
||||
result = CARDCheck(slot);
|
||||
if (result < CARD_RESULT_READY) {
|
||||
scanResult = CARDCheck(slot);
|
||||
if (scanResult < CARD_RESULT_READY) {
|
||||
goto mountError;
|
||||
}
|
||||
|
||||
mountContinue:
|
||||
clearAllCardFileEntries(slot);
|
||||
for (file = 0; file < CARD_MAX_FILE; ++file) {
|
||||
result = __CARDGetStatusEx(slot, (s16)file, &local.mountDir);
|
||||
result = __CARDGetStatusEx(slot, (s16)file, &mountDir);
|
||||
if (result < CARD_RESULT_READY) {
|
||||
result = handleCardMountResult(slot, result);
|
||||
if (result != CARD_RESULT_READY) {
|
||||
@@ -477,27 +520,29 @@ loopStart:
|
||||
}
|
||||
goto loopCheck;
|
||||
} else {
|
||||
local.compareName[0] = 0;
|
||||
local.compareName[1] = 0;
|
||||
local.compareName[2] = 0;
|
||||
local.compareName[3] = 0;
|
||||
local.compareName[4] = 0;
|
||||
local.compareName[5] = 0;
|
||||
if (strncmp((const char*)local.mountDir.fileName, "Broken File", 0xB) == 0 &&
|
||||
memcmp(local.mountDir.gameName, local.compareName + 2, 4) == 0 &&
|
||||
memcmp(local.mountDir.company, local.compareName, 2) == 0) {
|
||||
u8 company[2];
|
||||
u8 gameName[4];
|
||||
company[0] = 0;
|
||||
company[1] = 0;
|
||||
gameName[0] = 0;
|
||||
gameName[1] = 0;
|
||||
gameName[2] = 0;
|
||||
gameName[3] = 0;
|
||||
if (strncmp((const char*)mountDir.fileName, "Broken File", 0xB) == 0 &&
|
||||
memcmp(mountDir.gameName, gameName, 4) == 0 &&
|
||||
memcmp(mountDir.company, company, 2) == 0) {
|
||||
brokenFile = TRUE;
|
||||
} else {
|
||||
brokenFile = FALSE;
|
||||
}
|
||||
if (brokenFile) {
|
||||
result = CARDFastDelete(slot, (s16)file);
|
||||
if (result < CARD_RESULT_READY) {
|
||||
scanResult = CARDFastDelete(slot, (s16)file);
|
||||
if (scanResult < CARD_RESULT_READY) {
|
||||
goto mountError;
|
||||
}
|
||||
} else {
|
||||
result = loadCardFileIcons(slot, (s16)file, &local.mountDir);
|
||||
if (result < CARD_RESULT_READY) {
|
||||
scanResult = loadCardFileIcons(slot, (s16)file, &mountDir);
|
||||
if (scanResult < CARD_RESULT_READY) {
|
||||
goto mountError;
|
||||
}
|
||||
}
|
||||
@@ -507,26 +552,19 @@ loopStart:
|
||||
sThread->mounted[command / 4] = 1;
|
||||
sendCardSlotState(slot, 0, 0);
|
||||
OSReport("Slot %c\n", sCardSlotName[slot]);
|
||||
for (listingFile = 0; listingFile < CARD_MAX_FILE; ++listingFile) {
|
||||
if (__CARDGetStatusEx(slot, (u16)listingFile, &local.listingDir) == CARD_RESULT_READY) {
|
||||
memcpy(local.fileName, local.listingDir.fileName, CARD_FILENAME_MAX);
|
||||
local.fileName[CARD_FILENAME_MAX] = 0;
|
||||
OSReport("%d - %s: %d blocks\n", (u16)listingFile, local.fileName,
|
||||
local.listingDir.length);
|
||||
}
|
||||
}
|
||||
listCardFiles(slot, listingDir, fileName);
|
||||
break;
|
||||
|
||||
mountError:
|
||||
OSReport("MountError\n");
|
||||
reportCardThreadError(slot, 0, result);
|
||||
reportCardThreadError(slot, 0, scanResult);
|
||||
break;
|
||||
}
|
||||
case 9:
|
||||
reportCardThreadError((local.message >> 16) & 1, 9, CARD_RESULT_NOCARD);
|
||||
reportCardThreadError(getCardCommandSlot(message), 9, CARD_RESULT_NOCARD);
|
||||
break;
|
||||
case 1: {
|
||||
slot = (local.message >> 16) & 1;
|
||||
slot = getCardCommandSlot(message);
|
||||
result = CARDFormat(slot);
|
||||
if (result < CARD_RESULT_READY) {
|
||||
reportCardThreadError(slot, 1, result);
|
||||
@@ -538,44 +576,22 @@ loopStart:
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
runCardMoveOrCopy((local.message >> 16) & 1,
|
||||
(s16)(u8)(local.message >> 24), (s8)command);
|
||||
runCardMoveOrCopy(getCardCommandSlot(message),
|
||||
(s16)(u8)(message >> 24), (s8)command);
|
||||
break;
|
||||
case 3:
|
||||
runCardMoveOrCopy((local.message >> 16) & 1,
|
||||
(s16)(u8)(local.message >> 24), (s8)command);
|
||||
runCardMoveOrCopy(getCardCommandSlot(message),
|
||||
(s16)(u8)(message >> 24), (s8)command);
|
||||
break;
|
||||
case 4: {
|
||||
slot = (local.message >> 16) & 1;
|
||||
fileNo = (s16)(local.message >> 24);
|
||||
result = CARDFastDelete(slot, fileNo);
|
||||
if (result < CARD_RESULT_READY) {
|
||||
reportCardThreadError(slot, 4, result);
|
||||
} else {
|
||||
clearCardFileEntry(slot, fileNo);
|
||||
refreshCardSlotInfo(slot);
|
||||
sendCardSlotState(slot, 4, (u8)fileNo);
|
||||
}
|
||||
case 4:
|
||||
deleteCardFile(getCardCommandSlot(message), (s16)(message >> 24));
|
||||
break;
|
||||
}
|
||||
case 12:
|
||||
outerSlot = 0;
|
||||
|
||||
do {
|
||||
if (sThread->mounted[outerSlot] != 0) {
|
||||
freeBlocks = 0;
|
||||
for (freeFile = 0; freeFile < CARD_MAX_FILE; ++freeFile) {
|
||||
result = __CARDGetStatusEx(outerSlot, freeFile, &local.freeDir);
|
||||
if (result < CARD_RESULT_READY && result != CARD_RESULT_NOFILE) {
|
||||
freeBlocks = -1;
|
||||
break;
|
||||
}
|
||||
if (result == CARD_RESULT_READY &&
|
||||
memcmp(local.freeDir.gameName, (void*)0x80000000, 4) == 0 &&
|
||||
memcmp(local.freeDir.company, (void*)0x80000004, 2) == 0) {
|
||||
freeBlocks += local.freeDir.length;
|
||||
}
|
||||
}
|
||||
freeBlocks = countCardTitleBlocks(outerSlot, &freeDir);
|
||||
sThread->slots[outerSlot].unk_0x12 = freeBlocks;
|
||||
}
|
||||
++outerSlot;
|
||||
@@ -691,25 +707,75 @@ extern "C" void clearAllCardFileEntries(s32 slot) {
|
||||
} while (file < CARD_MAX_FILE);
|
||||
}
|
||||
|
||||
extern "C" s32 loadCardFileIcons(s32 slot, s32 fileNo, CARDDir* dir) {
|
||||
struct CardSequenceFileData {
|
||||
s32 commentSectorSize;
|
||||
s32 sectorSize;
|
||||
CARDFileInfo fileInfo;
|
||||
} local;
|
||||
s32 iconAddressOffset;
|
||||
u32 iconAddressBase;
|
||||
s32 result;
|
||||
result = CARDFastOpen(slot, fileNo, &local.fileInfo);
|
||||
if (result < CARD_RESULT_READY) {
|
||||
return result;
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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 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: {
|
||||
@@ -746,37 +812,37 @@ extern "C" s32 loadCardFileIcons(s32 slot, s32 fileNo, CARDDir* dir) {
|
||||
}
|
||||
}
|
||||
|
||||
s32 shift = 0;
|
||||
s32 iconImageSize = 0;
|
||||
s32 iconCount = 0;
|
||||
s32 shift;
|
||||
BOOL hasTlut;
|
||||
s32 iconImageSize;
|
||||
s32 icon;
|
||||
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;
|
||||
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);
|
||||
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 iconSpeedDone;
|
||||
goto animationDone;
|
||||
}
|
||||
iconCount = iconCount + 1;
|
||||
shift = shift + 2;
|
||||
}
|
||||
sThread->icons[slot][fileNo].unk_0x07 =
|
||||
(dir->iconSpeed >> 0xC) & 0xC;
|
||||
|
||||
iconSpeedDone:
|
||||
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) {
|
||||
iconImageSize = 0;
|
||||
sThread->icons[slot][fileNo].unk_0x01 = 0;
|
||||
iconImageSize = 0;
|
||||
} else {
|
||||
BOOL hasTlut = FALSE;
|
||||
iconCount = 0;
|
||||
shift = 0;
|
||||
for (icon = 0; icon < CARD_ICON_MAX; ++icon) {
|
||||
@@ -795,17 +861,15 @@ iconSpeedDone:
|
||||
break;
|
||||
case CARD_STAT_ICON_NONE: {
|
||||
paletteSize = 0;
|
||||
u8* iconPalette =
|
||||
&sThread->icons[slot][fileNo].iconFmt[iconCount];
|
||||
*iconPalette = iconPalette[-1];
|
||||
u8* previous = &sThread->icons[slot][fileNo].iconFmt[iconCount - 1];
|
||||
sThread->icons[slot][fileNo].iconFmt[iconCount] = *previous;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
paletteSize = 0;
|
||||
break;
|
||||
}
|
||||
if (iconCount < 7) {
|
||||
sThread->icons[slot][fileNo].iconOffset[iconCount + 1] =
|
||||
sThread->icons[slot][fileNo].iconOffset[(u32)(iconCount + 1)] =
|
||||
paletteSize + sThread->icons[slot][fileNo].iconOffset[iconCount];
|
||||
} else {
|
||||
sThread->icons[slot][fileNo].iconTlutOffset =
|
||||
@@ -830,85 +894,28 @@ iconSpeedDone:
|
||||
sThread->icons[slot][fileNo].anmDelta = 1;
|
||||
}
|
||||
|
||||
s32 totalImageSize = iconImageSize + bannerImageSize;
|
||||
u32 transferSize = (totalImageSize + iconAddressOffset + 0x1FF) & 0xFFFFFE00;
|
||||
result = CARDGetSectorSize(slot, (u32*)&local.sectorSize);
|
||||
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) {
|
||||
result = 0;
|
||||
sThread->icons[slot][fileNo].bannerEnable = 0;
|
||||
sThread->icons[slot][fileNo].unk_0x01 = 0;
|
||||
} else {
|
||||
u32 fileSize = (u32)dir->length * local.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(&local.fileInfo, sThread->imageReadBuffer,
|
||||
transferSize, iconAddressBase);
|
||||
if (result < CARD_RESULT_READY) {
|
||||
goto closeFile;
|
||||
}
|
||||
memcpy(sThread->images[slot][fileNo],
|
||||
sThread->imageReadBuffer + iconAddressOffset,
|
||||
totalImageSize);
|
||||
DCStoreRange(sThread->images[slot][fileNo], transferSize);
|
||||
result = 0;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
result = loadCardIconImages(slot, fileNo, dir, &fileInfo);
|
||||
if (result < CARD_RESULT_READY) {
|
||||
goto closeFile;
|
||||
return result;
|
||||
}
|
||||
|
||||
iconAddress = dir->commentAddr;
|
||||
iconAddressBase = iconAddress & 0xFFFFFE00;
|
||||
s32 commentDataOffset = iconAddress - iconAddressBase;
|
||||
s32 imageSize = ((iconAddress + 0x23F) & 0xFFFFFE00) - iconAddressBase;
|
||||
result = CARDGetSectorSize(slot, (u32*)&local.commentSectorSize);
|
||||
result = readCardComment(slot, fileNo, dir, &fileInfo);
|
||||
if (result < CARD_RESULT_READY) {
|
||||
goto clearComment;
|
||||
}
|
||||
{
|
||||
u32 fileSize;
|
||||
if ((s32)iconAddressBase < 0 ||
|
||||
iconAddressBase > (fileSize = (u32)dir->length * local.commentSectorSize)) {
|
||||
result = 0;
|
||||
} else {
|
||||
u32 endOffset = iconAddressBase + imageSize;
|
||||
if ((s32)endOffset < 0 || endOffset > fileSize) {
|
||||
result = 0;
|
||||
goto clearComment;
|
||||
}
|
||||
result = CARDRead(&local.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:
|
||||
if (result >= CARD_RESULT_READY) {
|
||||
goto closeFileSuccess;
|
||||
}
|
||||
closeFile:
|
||||
return result;
|
||||
|
||||
closeFileSuccess:
|
||||
result = CARDClose(&local.fileInfo);
|
||||
result = CARDClose(&fileInfo);
|
||||
if (result < CARD_RESULT_READY) {
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -87,11 +87,9 @@ namespace ipl {
|
||||
mNwc24ErrCountdown2 = 0;
|
||||
|
||||
// Text balloon for Mii face
|
||||
f32 f0 = 30.0f;
|
||||
f32 f1 = 120.0f;
|
||||
mpNigaoeBalloon =
|
||||
new TextBalloon(getSceneHeap(), mpBalloonFile, "arc", "my_IplTopBalloon_a.brlyt",
|
||||
math::VEC3(0.0f, (f1 = 120.0f, 0.0f), (f0 = 30.0f, 0.0f)), f1, f0);
|
||||
new TextBalloon(getSceneHeap(), mpBalloonFile, "arc", "my_IplTopBalloon_a.brlyt", math::VEC3(0.0f, 0.0f, 0.0f),
|
||||
TextBalloon::getDefaultMargin16x9(), TextBalloon::getDefaultMargin4x3());
|
||||
|
||||
// Scroller
|
||||
mpScroller = new utility::YoungBScroller();
|
||||
@@ -196,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",
|
||||
};
|
||||
@@ -68,6 +44,19 @@ namespace ipl {
|
||||
|
||||
SDMemory::~SDMemory() {}
|
||||
|
||||
static inline s32 countCachedTitles(const savedata::Manager* saveData) {
|
||||
s32 count = 0;
|
||||
for (s32 i = 0; i < 48; ++i) {
|
||||
if (saveData->getTitleCacheEntry(i) == 0) {
|
||||
break;
|
||||
}
|
||||
++count;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
#pragma push
|
||||
#pragma ppc_iro_level 1
|
||||
void SDMemory::create(EGG::Heap* heap, nand::LayoutFile* layoutFile, SDChannelSelect* channelSelect) {
|
||||
s32 cachedTitleCount;
|
||||
const savedata::Manager* saveData;
|
||||
@@ -151,13 +140,7 @@ namespace ipl {
|
||||
textBox->SetString(System::getMessage(0xBA));
|
||||
|
||||
saveData = System::getSaveData();
|
||||
cachedTitleCount = 0;
|
||||
for (s32 i = 0; i < 48; ++i) {
|
||||
if (saveData->getTitleCacheEntry(i) == 0) {
|
||||
break;
|
||||
}
|
||||
++cachedTitleCount;
|
||||
}
|
||||
cachedTitleCount = countCachedTitles(saveData);
|
||||
if (cachedTitleCount >= 5) {
|
||||
mpTitleLayout->FindPaneByName("N_Btn_3")->SetVisible(false);
|
||||
nw4r::lyt::Pane* expandedButton = mpTitleLayout->FindPaneByName("N_Btn_4");
|
||||
@@ -253,6 +236,8 @@ namespace ipl {
|
||||
mTransferFlags[0] = 1;
|
||||
}
|
||||
|
||||
#pragma pop
|
||||
|
||||
void SDMemory::setTitleLists(const TitleRange& nandTitles, const TitleRange& sdTitles) {
|
||||
mNandTitleRange = nandTitles;
|
||||
mSDTitleRange = sdTitles;
|
||||
@@ -723,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();
|
||||
@@ -807,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;
|
||||
@@ -922,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;
|
||||
@@ -996,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();
|
||||
@@ -1046,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();
|
||||
@@ -1101,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();
|
||||
@@ -1261,19 +1245,41 @@ namespace ipl {
|
||||
}
|
||||
|
||||
void SDMemory::drawTransferTitles() {
|
||||
f32 rowY;
|
||||
f32 rowTop;
|
||||
f32 backgroundOffset;
|
||||
f32 titleOffset;
|
||||
f32 rowHeight;
|
||||
f32 messageOffset;
|
||||
f32 bodyHeight;
|
||||
f32 bodyY;
|
||||
u8 alpha;
|
||||
nw4r::lyt::Pane* bodyPane;
|
||||
nw4r::lyt::Pane* titleSizePane;
|
||||
nw4r::lyt::TextBox* titleText;
|
||||
nw4r::lyt::Pane* footerPane;
|
||||
u32 nandTitleIndex;
|
||||
u32 titleIndex;
|
||||
wchar_t* messageForCount;
|
||||
s32 lineCount;
|
||||
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;
|
||||
memoPosition.y = translation.y;
|
||||
memoPosition.z = translation.z;
|
||||
f32 bodyY = memoPosition.y;
|
||||
bodyY = memoPosition.y;
|
||||
mpDialogLayout->FindPaneByName("header_header");
|
||||
nw4r::lyt::Pane* bodyPane = mpDialogLayout->FindPaneByName("header_body");
|
||||
bodyPane = mpDialogLayout->FindPaneByName("header_body");
|
||||
if (bodyY < 500.0f) {
|
||||
mpDialogLayout->draw("header_header");
|
||||
}
|
||||
|
||||
u8 alpha = mpDialogLayout->FindPaneByName("N_Memo")->GetAlpha();
|
||||
alpha = mpDialogLayout->FindPaneByName("N_Memo")->GetAlpha();
|
||||
nw4r::ut::LinkList<nw4r::lyt::Pane, offsetof(nw4r::lyt::detail::PaneBase, mLink)>::Iterator child =
|
||||
bodyPane->GetChildList().GetBeginIter();
|
||||
while (child != bodyPane->GetChildList().GetEndIter()) {
|
||||
@@ -1281,29 +1287,26 @@ namespace ipl {
|
||||
++child;
|
||||
}
|
||||
|
||||
f32 messageOffset = 0.0f;
|
||||
f32 bodyHeight = bodyPane->GetSize().height;
|
||||
messageOffset = 0.0f;
|
||||
bodyHeight = bodyPane->GetSize().height;
|
||||
if (mNandTitleCount != 0) {
|
||||
const wchar_t* messageForCount = System::getMessage(0xCB);
|
||||
s32 lineCount = 0;
|
||||
const wchar_t* newline = wcsstr(messageForCount, L"\n");
|
||||
messageForCount = System::getMessage(0xCB);
|
||||
lineCount = 0;
|
||||
wchar_t* newline = wcsstr(messageForCount, L"\n");
|
||||
while (newline != NULL) {
|
||||
++lineCount;
|
||||
newline = wcsstr(newline + 1, L"\n");
|
||||
}
|
||||
|
||||
const wchar_t* messageLine = System::getMessage(0xCB);
|
||||
nw4r::lyt::TextBox* messageText = static_cast<nw4r::lyt::TextBox*>(
|
||||
messageLine = System::getMessage(0xCB);
|
||||
messageText = static_cast<nw4r::lyt::TextBox*>(
|
||||
mpDialogLayout->FindPaneByName("T_Header_body"));
|
||||
s32 totalLines = lineCount + 1;
|
||||
s32 lineIndex = 0;
|
||||
if (lineIndex < totalLines) {
|
||||
do {
|
||||
const wchar_t* lineEnd = wcsstr(messageLine, L"\n");
|
||||
for (lineIndex = 0; lineIndex < lineCount + 1; ++lineIndex) {
|
||||
lineEnd = wcsstr(messageLine, L"\n");
|
||||
if (lineEnd == NULL) {
|
||||
utility::layout::set_string(messageText, messageLine);
|
||||
} else {
|
||||
u32 lineLength = static_cast<u32>(lineEnd - messageLine);
|
||||
lineLength = static_cast<u32>(lineEnd - messageLine);
|
||||
wcsncpy(mCurrentTitleName, messageLine, lineLength);
|
||||
mCurrentTitleName[lineLength] = L'\0';
|
||||
utility::layout::set_string(messageText, mCurrentTitleName);
|
||||
@@ -1318,52 +1321,42 @@ namespace ipl {
|
||||
}
|
||||
|
||||
messageOffset -= bodyHeight;
|
||||
++lineIndex;
|
||||
} while (lineIndex < totalLines);
|
||||
}
|
||||
}
|
||||
|
||||
messageOffset += bodyHeight;
|
||||
f32 backgroundOffset = 40.0f + messageOffset;
|
||||
f32 titleOffset = 79.5f + messageOffset;
|
||||
backgroundOffset = 40.0f + messageOffset;
|
||||
titleOffset = 79.5f + messageOffset;
|
||||
|
||||
nw4r::lyt::Pane* titleSizePane = mpDialogLayout->FindPaneByName("N_Body");
|
||||
f32 rowHeight = titleSizePane->GetSize().height;
|
||||
nw4r::lyt::PaneList::Iterator titleChild = titleSizePane->GetChildList().GetBeginIter();
|
||||
while (titleChild != titleSizePane->GetChildList().GetEndIter()) {
|
||||
titleChild->SetAlpha(alpha);
|
||||
++titleChild;
|
||||
titleSizePane = mpDialogLayout->FindPaneByName("N_Body");
|
||||
rowHeight = titleSizePane->GetSize().height;
|
||||
nw4r::lyt::PaneList::Iterator bodyChild = titleSizePane->GetChildList().GetBeginIter();
|
||||
while (bodyChild != titleSizePane->GetChildList().GetEndIter()) {
|
||||
bodyChild->SetAlpha(alpha);
|
||||
++bodyChild;
|
||||
}
|
||||
|
||||
nw4r::lyt::TextBox* titleText = static_cast<nw4r::lyt::TextBox*>(
|
||||
titleText = static_cast<nw4r::lyt::TextBox*>(
|
||||
mpDialogLayout->FindPaneByName("T_Letter"));
|
||||
titleText->SetAlpha(alpha);
|
||||
|
||||
u32 nandTitleIndex = 0;
|
||||
for (u32 titleIndex = 0; titleIndex < mTitleCount; ++titleIndex) {
|
||||
nandTitleIndex = 0;
|
||||
for (titleIndex = 0; titleIndex < mTitleCount; ++titleIndex) {
|
||||
utility::layout::set_string(titleText, mTitleNames[titleIndex]);
|
||||
if (nandTitleIndex < mNandTitleCount && mTitleIds[titleIndex] == mNandTitleIds[nandTitleIndex]) {
|
||||
GXColor gxActive;
|
||||
writeFourFlagBytes(&gxActive.r, 0x34, 0xBE, 0xED, 0xFF);
|
||||
++nandTitleIndex;
|
||||
nw4r::ut::Color active0 = *reinterpret_cast<const nw4r::ut::Color*>(&gxActive);
|
||||
setTitleRowColors(titleText,
|
||||
nw4r::ut::Color(*reinterpret_cast<const nw4r::ut::Color*>(&gxActive)),
|
||||
nw4r::ut::Color(*reinterpret_cast<const nw4r::ut::Color*>(&gxActive)));
|
||||
nw4r::ut::Color color(0x34, 0xBE, 0xED, 0xFF);
|
||||
titleText->SetTextColor(color, color);
|
||||
} else {
|
||||
GXColor gxInactive;
|
||||
writeFourFlagBytes(&gxInactive.r, 0x64, 0x64, 0x64, 0xFF);
|
||||
nw4r::ut::Color inactive0 = *reinterpret_cast<const nw4r::ut::Color*>(&gxInactive);
|
||||
setTitleRowColors(titleText,
|
||||
nw4r::ut::Color(*reinterpret_cast<const nw4r::ut::Color*>(&gxInactive)),
|
||||
nw4r::ut::Color(*reinterpret_cast<const nw4r::ut::Color*>(&gxInactive)));
|
||||
nw4r::ut::Color color(0x64, 0x64, 0x64, 0xFF);
|
||||
titleText->SetTextColor(color, color);
|
||||
}
|
||||
|
||||
nw4r::ut::Rect textRect = mpDialogLayout->getTextDrawRect("T_Letter");
|
||||
f32 rowTop = textRect.bottom - textRect.top;
|
||||
rowTop = textRect.bottom - textRect.top;
|
||||
s32 visibleRows = static_cast<s32>(static_cast<f32>(ceil(-rowTop / titleSizePane->GetSize().height)));
|
||||
for (s32 row = 0; row < visibleRows; ++row) {
|
||||
f32 rowY = bodyY + backgroundOffset;
|
||||
rowY = bodyY + backgroundOffset;
|
||||
if (-500.0f < rowY && rowY < 500.0f) {
|
||||
nw4r::math::VEC2 translation(0.0f, backgroundOffset);
|
||||
titleSizePane->SetTranslate(translation);
|
||||
@@ -1378,11 +1371,11 @@ namespace ipl {
|
||||
titleText->CalculateMtx(*mpDialogLayout->getDrawInfo());
|
||||
mpDialogLayout->draw(titleText);
|
||||
}
|
||||
titleOffset -= rowHeight * static_cast<f32>(visibleRows);
|
||||
titleOffset -= visibleRows * rowHeight;
|
||||
}
|
||||
|
||||
backgroundOffset += rowHeight;
|
||||
nw4r::lyt::Pane* footerPane = mpDialogLayout->FindPaneByName("N_Footer");
|
||||
footerPane = mpDialogLayout->FindPaneByName("N_Footer");
|
||||
nw4r::lyt::PaneList::Iterator footerChild = footerPane->GetChildList().GetBeginIter();
|
||||
while (footerChild != footerPane->GetChildList().GetEndIter()) {
|
||||
footerChild->SetAlpha(alpha);
|
||||
@@ -1401,18 +1394,6 @@ namespace ipl {
|
||||
mpDialogLayout->draw("N_Move");
|
||||
}
|
||||
|
||||
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;
|
||||
for (s32 i = 0; i < 3; i++) {
|
||||
@@ -1636,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);
|
||||
@@ -1672,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) {
|
||||
|
||||
@@ -212,6 +212,8 @@ namespace ipl {
|
||||
}
|
||||
}
|
||||
|
||||
#pragma push
|
||||
#pragma ppc_iro_level 0
|
||||
void SDChannelSelect::create() {
|
||||
mpSDWorker = new (System::getMem2App(), 4) NandSDWorker();
|
||||
mpWorkerHeap = (EGG::Heap*)System::getMem2App()->alloc(0x3EA60, 0x40);
|
||||
@@ -253,6 +255,7 @@ namespace ipl {
|
||||
utility::CSFlags::UpdateFlagsFile();
|
||||
}
|
||||
|
||||
#pragma pop
|
||||
void SDChannelSelect::enqueueStartNotice() {
|
||||
SDChannelSelectCommand command;
|
||||
command.type = 1;
|
||||
@@ -349,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;
|
||||
}
|
||||
@@ -358,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;
|
||||
}
|
||||
@@ -377,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;
|
||||
}
|
||||
@@ -416,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;
|
||||
}
|
||||
@@ -1322,8 +1328,8 @@ namespace ipl {
|
||||
}
|
||||
|
||||
bool SDChannelSelect::collectTitlesByUsage(
|
||||
const s32* firstUsage, const s32* secondUsage, ESTitleId* titleIds,
|
||||
char* titleNames, u32* titleCount) {
|
||||
s32* firstUsage, s32* secondUsage, ESTitleId* titleIds,
|
||||
wchar_t (*titleNames)[21], u32* titleCount) {
|
||||
s32 bytes;
|
||||
s32 blocks;
|
||||
getCurrentTitleUsage(&bytes, &blocks);
|
||||
@@ -1340,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]) {
|
||||
@@ -1357,8 +1363,8 @@ namespace ipl {
|
||||
}
|
||||
|
||||
bool SDChannelSelect::collectTitlesFromNandUsage(
|
||||
const s32* firstUsage, const s32* secondUsage,
|
||||
ESTitleId* titleIds, char* titleNames, u32* titleCount) {
|
||||
s32* firstUsage, s32* secondUsage,
|
||||
ESTitleId* titleIds, wchar_t (*titleNames)[21], u32* titleCount) {
|
||||
s32 bytes;
|
||||
s32 blocks;
|
||||
getCurrentTitleUsage(&bytes, &blocks);
|
||||
@@ -1381,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]) {
|
||||
@@ -1396,8 +1402,8 @@ namespace ipl {
|
||||
}
|
||||
|
||||
bool SDChannelSelect::collectTitlesByChannelOrder(
|
||||
const s32* firstUsage, const s32* secondUsage, ESTitleId* titleIds,
|
||||
char* titleNames, u32* titleCount) {
|
||||
s32* firstUsage, s32* secondUsage, ESTitleId* titleIds,
|
||||
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,
|
||||
};
|
||||
@@ -1406,17 +1412,10 @@ namespace ipl {
|
||||
getCurrentTitleUsage(&bytes, &blocks);
|
||||
*titleCount = 0;
|
||||
|
||||
ESTitleId titleId;
|
||||
for (int page = MAX_CHANNEL_PAGE - 1; page >= 0; --page) {
|
||||
for (int order = 0; order < MAX_CHANNEL_INDEX; ++order) {
|
||||
int channelIndex = channelOrder[order];
|
||||
const channel::SEntry& channelInfo =
|
||||
System::getChannelManager()->mChannels[page][channelIndex];
|
||||
if (channelInfo.loadedBnr) {
|
||||
titleId = ES_TITLE_ID(channelInfo.info.titleType, channelInfo.info.titleCode);
|
||||
} else {
|
||||
titleId = 0;
|
||||
}
|
||||
ESTitleId titleId =
|
||||
System::getChannelManager()->getEntryTitleID(page, channelOrder[order]);
|
||||
if (titleId == 0 || titleId == 0x48415A41) {
|
||||
continue;
|
||||
}
|
||||
@@ -1431,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]) {
|
||||
@@ -1448,8 +1447,8 @@ namespace ipl {
|
||||
}
|
||||
|
||||
bool SDChannelSelect::collectTitlesBySpecialChannels(
|
||||
const s32* firstUsage, const s32* secondUsage, ESTitleId* titleIds,
|
||||
char* titleNames, u32* titleCount) {
|
||||
s32* firstUsage, s32* secondUsage, ESTitleId* titleIds,
|
||||
wchar_t (*titleNames)[21], u32* titleCount) {
|
||||
s32 bytes;
|
||||
s32 blocks;
|
||||
getCurrentTitleUsage(&bytes, &blocks);
|
||||
@@ -1506,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]) {
|
||||
@@ -1532,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]) {
|
||||
@@ -1548,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]) {
|
||||
@@ -1563,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]) {
|
||||
@@ -1578,8 +1577,8 @@ namespace ipl {
|
||||
}
|
||||
|
||||
bool SDChannelSelect::collectTitlesForMode(
|
||||
const s32* requiredBytes, const s32* requiredBlocks,
|
||||
ESTitleId* titleIds, char* titleNames, u32* titleCount, int searchMode) {
|
||||
s32* requiredBytes, s32* requiredBlocks,
|
||||
ESTitleId* titleIds, wchar_t (*titleNames)[21], u32* titleCount, int searchMode) {
|
||||
switch (searchMode) {
|
||||
case 0:
|
||||
return collectTitlesBySpecialChannels(
|
||||
@@ -1647,6 +1646,8 @@ namespace ipl {
|
||||
}
|
||||
}
|
||||
|
||||
#pragma push
|
||||
#pragma ppc_iro_level 0
|
||||
void SDChannelSelect::flushSaveDataAndMountSD() {
|
||||
if (System::getDialog()->getLastResult() != DialogWindow::RESULT_NONE) {
|
||||
mpPointerLayout->getAnim(0)->initAnmFrame();
|
||||
@@ -1658,6 +1659,7 @@ namespace ipl {
|
||||
}
|
||||
}
|
||||
|
||||
#pragma pop
|
||||
void SDChannelSelect::handleThreePageDialog() {
|
||||
if (System::getDialog()->callBtn2Multi(sThreePageDialogPages, 3, 10)) {
|
||||
mState = 27;
|
||||
@@ -1902,7 +1904,7 @@ namespace ipl {
|
||||
pageText->SetString(pageNumber, 0);
|
||||
nw4r::lyt::Pane* clockPane = mpLayout->FindPaneByName(mscClockPaneNames[page]);
|
||||
nw4r::math::MTX34 paneMatrix = clockPane->GetGlobalMtx();
|
||||
nw4r::math::VEC3 position(0.0f, 0.0f, 0.0f);
|
||||
math::VEC3 position(0.0f, 0.0f, 0.0f);
|
||||
PSMTXMultVec(paneMatrix, position, position);
|
||||
mpDialogLayout->GetRootPane()->SetTranslate(position);
|
||||
mpDialogLayout->calcMtx();
|
||||
@@ -2699,8 +2701,8 @@ namespace ipl {
|
||||
return mpLayout->FindPaneByName(mscChannelPaneNames[2][index]);
|
||||
}
|
||||
|
||||
math::VEC3 SDChannelSelect::getChannelPanePosition(SDChannelSelect* scene, int index) {
|
||||
math::VEC3 position(0.0f, 0.0f, 0.0f);
|
||||
nw4r::math::VEC3 SDChannelSelect::getChannelPanePosition(SDChannelSelect* scene, int index) {
|
||||
nw4r::math::VEC3 position(0.0f, 0.0f, 0.0f);
|
||||
MTXMultVec(scene->getCenterChannelPane(index)->GetGlobalMtx(), position, position);
|
||||
return position;
|
||||
}
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
|
||||
#define IPL_CHANNEL_TITLE_NOVTABLE
|
||||
#include "math/iplInterporation.h"
|
||||
#undef IPL_CHANNEL_TITLE_NOVTABLE
|
||||
|
||||
#include "scene/sdChannelTitle/iplSDChannelTitle.h"
|
||||
#undef IPL_CHANNEL_TITLE_NOVTABLE
|
||||
#include "scene/sdChannelSelect/iplSDChannelSelect.h"
|
||||
#include "system/iplSystem.h"
|
||||
#include "sound/iplSound.h"
|
||||
@@ -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;
|
||||
@@ -1351,6 +1342,8 @@ extern "C" void iplSDChannelTitle_prepareSceneExit(SDChannelTitle* scene, int ne
|
||||
}
|
||||
}
|
||||
|
||||
#pragma push
|
||||
#pragma ppc_iro_level 0
|
||||
extern "C" void iplSDChannelTitle_flushSaveBeforeExit(SDChannelTitle* scene, int nextScene) {
|
||||
int page;
|
||||
int index;
|
||||
@@ -1358,10 +1351,10 @@ extern "C" void iplSDChannelTitle_flushSaveBeforeExit(SDChannelTitle* scene, int
|
||||
System::getSaveData()->pushTitleCache(scene->mTitleId);
|
||||
}
|
||||
System::getSaveData()->getSDPrevPage() = scene->mPage;
|
||||
EGG::Heap* saveHeap = System::getMem2App();
|
||||
scene->mpSaveFile = System::getSaveData()->flushAsync(saveHeap);
|
||||
scene->mpSaveFile = System::getSaveData()->flushAsync(System::getMem2App());
|
||||
__WPADReconnect(TRUE);
|
||||
}
|
||||
#pragma pop
|
||||
|
||||
extern "C" void iplSDChannelTitle_rebootSystem(SDChannelTitle*) {
|
||||
snd::getSystem()->stopAllSound(0);
|
||||
|
||||
@@ -167,11 +167,6 @@ typedef struct AOSSKeySchedule {
|
||||
u32 length;
|
||||
} AOSSKeySchedule;
|
||||
|
||||
typedef struct AOSSKeyMaterial {
|
||||
u8 nonce[2];
|
||||
u8 address[8];
|
||||
} AOSSKeyMaterial;
|
||||
|
||||
typedef struct AOSSReceiveBuffer {
|
||||
s32 socket;
|
||||
u32 length;
|
||||
@@ -261,11 +256,6 @@ typedef struct AOSSConfigData {
|
||||
static AOSSRuntimeState s_runtime;
|
||||
static AOSSConfigData s_configData;
|
||||
static u8 s_networkBuffer[0x280];
|
||||
static struct {
|
||||
AOSSKeyMaterial key;
|
||||
u8 payload[0x5e];
|
||||
} s_packetState;
|
||||
static u32 s_crcTable[0x100];
|
||||
|
||||
static s32 s_socket = -1;
|
||||
static char s_manufacturer[] = "MELCO";
|
||||
@@ -291,7 +281,7 @@ extern void AOSSi_Sleep(u32 duration);
|
||||
struct AOSSConnection;
|
||||
struct AOSSConnectionStatus;
|
||||
extern int AOSSi_WLANConnect(struct AOSSConnection* connection, struct AOSSConnectionStatus* status);
|
||||
extern int SOPoll(AOSSPollDescriptor* descriptors, int count, s32 timeoutHigh, s32 timeoutLow);
|
||||
extern int SOPoll(AOSSPollDescriptor* descriptors, int count, OSTime timeout);
|
||||
extern int SORecvFrom(int socket, void* buffer, int length, int flags, void* address);
|
||||
extern int SOSendTo(int socket, const void* buffer, int length, int flags, const void* address);
|
||||
extern int SOBind(int socket, const void* address);
|
||||
@@ -398,8 +388,7 @@ cleanup_done:
|
||||
|
||||
int AOSS_Init_old(AOSSInitInput* input)
|
||||
{
|
||||
s16 initialWait;
|
||||
u64 tickRemainder;
|
||||
short waitAttempt;
|
||||
AOSSReceiveBuffer* packetBuffer;
|
||||
AOSSPacketHeader* packetWords;
|
||||
u32 initialSleep;
|
||||
@@ -407,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;
|
||||
@@ -416,15 +405,13 @@ int AOSS_Init_old(AOSSInitInput* input)
|
||||
int requestResult;
|
||||
size_t manufacturerLength;
|
||||
int timeoutSeconds;
|
||||
int timeoutMilliseconds;
|
||||
int protocolState;
|
||||
int protocolResult;
|
||||
u32 responseSleep;
|
||||
u32 subnetMask;
|
||||
u64 timeoutTicks;
|
||||
OSTime timeoutTicks;
|
||||
int initializationResult;
|
||||
short attemptCount;
|
||||
u16 remainingWait;
|
||||
short waitAttempt;
|
||||
s16 initialWait;
|
||||
u16 defaultConnection;
|
||||
u16 defaultResponse;
|
||||
union {
|
||||
@@ -440,7 +427,6 @@ int AOSS_Init_old(AOSSInitInput* input)
|
||||
u8 messageIdentity[8];
|
||||
__declspec(align(32)) AOSSSocketAddress socketAddress;
|
||||
struct { int seconds; int microseconds; } pollTime;
|
||||
AOSSSocketAddress receivedAddress;
|
||||
u32 networkAddresses[5];
|
||||
AOSSPollDescriptor pollArguments[2];
|
||||
|
||||
@@ -638,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);
|
||||
@@ -686,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) {
|
||||
@@ -837,13 +823,15 @@ request_socket_cleanup_complete:
|
||||
resultCode = 0xffffffff;
|
||||
goto finish_initialization;
|
||||
}
|
||||
subnetMask = s_runtime.subnetMask;
|
||||
responseSleep = s_runtime.ipAddress & subnetMask;
|
||||
retryWait = responseSleep | (s_runtime.ipAddress & ~subnetMask) + 1;
|
||||
if (retryWait >= (responseSleep | ~subnetMask)) {
|
||||
retryWait = responseSleep | 1;
|
||||
{
|
||||
u32 mask = s_runtime.subnetMask;
|
||||
u32 networkAddress = s_runtime.ipAddress & mask;
|
||||
u32 localAddress = networkAddress | ((s_runtime.ipAddress & ~mask) + 1);
|
||||
if (localAddress >= (networkAddress | ~mask)) {
|
||||
localAddress = networkAddress | 1;
|
||||
}
|
||||
requestResult = AOSSi_SetNCDIPAddr(localAddress,s_runtime.subnetMask,s_runtime.ipAddress,0,0);
|
||||
}
|
||||
requestResult = AOSSi_SetNCDIPAddr(retryWait,s_runtime.subnetMask,s_runtime.ipAddress,0,0);
|
||||
if (requestResult != 0) {
|
||||
s_errorCode = 0xc;
|
||||
input->status = 0xf;
|
||||
@@ -890,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) {
|
||||
@@ -1039,10 +1027,9 @@ request_socket_cleanup_complete:
|
||||
pollArguments[1].returnedEvents = 0;
|
||||
pollArguments[1].events = 1;
|
||||
timeoutTicks = 0;
|
||||
timeoutTicks += (u32)(pollTime.seconds * (OS_BUS_CLOCK >> 2));
|
||||
tickRemainder = (u32)(pollTime.microseconds * ((OS_BUS_CLOCK >> 2) / 125000)) >> 3;
|
||||
timeoutTicks += tickRemainder;
|
||||
requestResult = SOPoll(pollArguments,1,(u32)(timeoutTicks >> 32),(int)timeoutTicks);
|
||||
timeoutTicks += (OSTime)(u32)OSSecondsToTicks(pollTime.seconds);
|
||||
timeoutTicks += (OSTime)(u32)OSMicrosecondsToTicks(pollTime.microseconds);
|
||||
requestResult = SOPoll(pollArguments,1,(OSTime)timeoutTicks);
|
||||
if (0 < requestResult) goto process_received_packet;
|
||||
receivedPackets = receivedPackets + 1;
|
||||
if (receivedPackets > attemptCount) {
|
||||
@@ -1104,8 +1091,12 @@ request_socket_cleanup_complete:
|
||||
}
|
||||
goto finish_initialization;
|
||||
process_received_packet:
|
||||
receivedAddress.length = 8;
|
||||
receivedLength = SORecvFrom(s_socket,&packetBuffer->message,0x5dc,0,&receivedAddress);
|
||||
{
|
||||
AOSSSocketAddress receivedAddress;
|
||||
u8 addressLength = sizeof(receivedAddress);
|
||||
receivedAddress.length = addressLength;
|
||||
receivedLength = SORecvFrom(s_socket,&packetBuffer->message,0x5dc,0,&receivedAddress);
|
||||
}
|
||||
packetBuffer->socket = s_socket;
|
||||
retryWait = SONtoHs(receivedLength);
|
||||
packetBuffer->length = retryWait & 0xffff;
|
||||
@@ -1209,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);
|
||||
@@ -1239,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) {
|
||||
@@ -2167,40 +2158,43 @@ int AOSSParsePskConfig(const AOSSOptionRecord* packet, AOSSStoredConfig* config)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#pragma push
|
||||
#pragma optimization_level 3
|
||||
int AOSSApplyAuthOptions(int state, const AOSSReplyOption* response, int responseLength, void* config, void* networkData) {
|
||||
u32 flags = 0;
|
||||
const AOSSReplyOption* responseRecord;
|
||||
const u8* responseTypes;
|
||||
AOSSConfigRecord* configRecord;
|
||||
AOSSStoredConfig* wep40Config;
|
||||
AOSSStoredConfig* wep104Config;
|
||||
AOSSStoredConfig* tkipConfig;
|
||||
AOSSStoredConfig* aesConfig;
|
||||
u8* networkSettings;
|
||||
const AOSSReplyOption* option;
|
||||
u32 length;
|
||||
s32 remainingLength = responseLength;
|
||||
int result;
|
||||
s32 optionRemaining;
|
||||
|
||||
if (remainingLength <= 0) {
|
||||
if (responseLength <= 0) {
|
||||
return -2;
|
||||
}
|
||||
|
||||
responseTypes = s_responseTypeByState;
|
||||
responseRecord = response;
|
||||
for (;;) {
|
||||
if (responseRecord->fields.type == s_responseTypeByState[state]) {
|
||||
if (responseRecord->fields.type == responseTypes[state]) {
|
||||
break;
|
||||
}
|
||||
length = SONtoHs(responseRecord->fields.length) + 4;
|
||||
remainingLength -= length;
|
||||
responseLength -= length;
|
||||
responseRecord = (const AOSSReplyOption*)&responseRecord->bytes[length];
|
||||
if (remainingLength <= 0) {
|
||||
if (responseLength <= 0) {
|
||||
return -4;
|
||||
}
|
||||
}
|
||||
|
||||
length = responseRecord->fields.length;
|
||||
option = (const AOSSReplyOption*)&responseRecord->bytes[4];
|
||||
remainingLength = SONtoHs((u16)length);
|
||||
responseRecord = (const AOSSReplyOption*)&responseRecord->bytes[4];
|
||||
optionRemaining = SONtoHs((u16)length);
|
||||
configRecord = &((AOSSConfigData*)config)->records[state];
|
||||
wep40Config = (AOSSStoredConfig*)&configRecord->reserved00[8];
|
||||
networkSettings = ((AOSSNetworkBufferRecord*)networkData)[state + 3].bytes;
|
||||
@@ -2209,31 +2203,31 @@ int AOSSApplyAuthOptions(int state, const AOSSReplyOption* response, int respons
|
||||
aesConfig = (AOSSStoredConfig*)&configRecord->reserved2d8[0];
|
||||
|
||||
do {
|
||||
switch (option->fields.type) {
|
||||
switch (responseRecord->fields.type) {
|
||||
case 3:
|
||||
result = AOSSParseWepConfig((const AOSSOptionRecord*)option, wep40Config);
|
||||
result = AOSSParseWepConfig((const AOSSOptionRecord*)responseRecord, wep40Config);
|
||||
flags |= 1;
|
||||
break;
|
||||
case 4:
|
||||
result = AOSSParseWepConfig((const AOSSOptionRecord*)option, wep104Config);
|
||||
result = AOSSParseWepConfig((const AOSSOptionRecord*)responseRecord, wep104Config);
|
||||
flags |= 2;
|
||||
break;
|
||||
case 5:
|
||||
result = AOSSParsePskConfig((const AOSSOptionRecord*)option, tkipConfig);
|
||||
result = AOSSParsePskConfig((const AOSSOptionRecord*)responseRecord, tkipConfig);
|
||||
flags |= 4;
|
||||
break;
|
||||
case 6:
|
||||
result = AOSSParsePskConfig((const AOSSOptionRecord*)option, aesConfig);
|
||||
result = AOSSParsePskConfig((const AOSSOptionRecord*)responseRecord, aesConfig);
|
||||
flags |= 8;
|
||||
break;
|
||||
case 10:
|
||||
length = SONtoHs(option->fields.payload.network.networkLength);
|
||||
length = SONtoHs(responseRecord->fields.payload.network.networkLength);
|
||||
if ((s32)length <= 0) {
|
||||
result = -1;
|
||||
} else if (option->fields.payload.network.networkType != 0x70) {
|
||||
} else if (responseRecord->fields.payload.network.networkType != 0x70) {
|
||||
result = -1;
|
||||
} else {
|
||||
memcpy(networkSettings, option->fields.payload.network.networkData, length);
|
||||
memcpy(networkSettings, responseRecord->fields.payload.network.networkData, length);
|
||||
result = 0;
|
||||
}
|
||||
break;
|
||||
@@ -2246,14 +2240,15 @@ int AOSSApplyAuthOptions(int state, const AOSSReplyOption* response, int respons
|
||||
return result;
|
||||
}
|
||||
|
||||
length = SONtoHs(option->fields.length) + 4;
|
||||
remainingLength -= length;
|
||||
option = (const AOSSReplyOption*)&option->bytes[length];
|
||||
} while (remainingLength > 0);
|
||||
length = SONtoHs(responseRecord->fields.length) + 4;
|
||||
optionRemaining -= length;
|
||||
responseRecord = (const AOSSReplyOption*)&responseRecord->bytes[length];
|
||||
} while (optionRemaining > 0);
|
||||
|
||||
s_runtime.state |= flags;
|
||||
return 0;
|
||||
}
|
||||
#pragma pop
|
||||
|
||||
int AOSSSendDiscoveryRequest(void* packet, AOSSRequestRecords* request, int socket) {
|
||||
u8* responsePayload;
|
||||
@@ -2324,16 +2319,16 @@ int AOSSSendDiscoveryRequest(void* packet, AOSSRequestRecords* request, int sock
|
||||
}
|
||||
|
||||
int AOSSSendHelloRequest(void* packet, void* request, int socket) {
|
||||
AOSSHelloPacket* response = (AOSSHelloPacket*)s_responseBuffer;
|
||||
AOSSHelloPayload* payload;
|
||||
AOSSRequestRecords* requestRecords = (AOSSRequestRecords*)request;
|
||||
struct {
|
||||
AOSSSocketAddress destination;
|
||||
AOSSHelloRecord hello;
|
||||
u8 accessPointName[8];
|
||||
AOSSKeySchedule schedule;
|
||||
} construction;
|
||||
u32 checksum;
|
||||
AOSSRequestRecords* requestRecords = (AOSSRequestRecords*)request;
|
||||
u8 accessPointName[8];
|
||||
AOSSHelloRecord hello;
|
||||
AOSSSocketAddress destination;
|
||||
AOSSKeySchedule schedule;
|
||||
int sequence;
|
||||
u32 crc;
|
||||
AOSSHelloPacket* response = (AOSSHelloPacket*)s_responseBuffer;
|
||||
u16 nonce;
|
||||
u32 stateLength;
|
||||
u32 index;
|
||||
@@ -2341,72 +2336,68 @@ int AOSSSendHelloRequest(void* packet, void* request, int socket) {
|
||||
u32 firstByte;
|
||||
u32 secondIndex;
|
||||
u8* state;
|
||||
u32 i;
|
||||
const u8* input;
|
||||
u8 value;
|
||||
u8 swap;
|
||||
s16 responseLength;
|
||||
s16 sendLength;
|
||||
int sequence;
|
||||
int encryptionResult;
|
||||
|
||||
checksum = 0;
|
||||
sequence = 0;
|
||||
memset(&construction.hello, 0, sizeof(construction.hello));
|
||||
memset(&hello, 0, sizeof(hello));
|
||||
memset(response, 0, 0x5dc);
|
||||
payload = &response->payload;
|
||||
construction.hello.data.fields.type = 2;
|
||||
construction.hello.data.fields.reserved01 = 0;
|
||||
construction.hello.data.fields.length = SOHtoNs(4);
|
||||
construction.hello.data.fields.supportedModes = s_runtime.flags;
|
||||
construction.hello.data.fields.supportedModes = SOHtoNl(construction.hello.data.fields.supportedModes);
|
||||
hello.data.fields.type = 2;
|
||||
hello.data.fields.reserved01 = 0;
|
||||
hello.data.fields.length = SOHtoNs(4);
|
||||
hello.data.fields.supportedModes = s_runtime.flags;
|
||||
hello.data.fields.supportedModes = SOHtoNl(hello.data.fields.supportedModes);
|
||||
responseLength = 8;
|
||||
|
||||
if ((s32)s_connectionState == 1) {
|
||||
const u32* crcTable;
|
||||
sequence = 1;
|
||||
checksum = 0xffffffff;
|
||||
crc = 0xffffffff;
|
||||
AOSSInitCrc32Table(0, s_crcTable);
|
||||
crcTable = s_crcTable;
|
||||
{
|
||||
u32 part;
|
||||
for (part = 0; part < 4; part++) {
|
||||
for (index = 0; index < 2; index++) {
|
||||
checksum = (checksum >> 8) ^ crcTable[(checksum ^ construction.hello.data.bytes[part * 2 + index]) & 0xff];
|
||||
}
|
||||
}
|
||||
index = 0;
|
||||
while (index < 8) {
|
||||
crc = (crc >> 8) ^ s_crcTable[(crc ^ hello.data.bytes[index++]) & 0xff];
|
||||
}
|
||||
checksum = (checksum ^ 0xffffffff) & 0xff;
|
||||
checksum = (crc ^ 0xffffffff) & 0xff;
|
||||
|
||||
construction.schedule.bytes = (u8*)AOSSi_Alloc(8);
|
||||
if (construction.schedule.bytes != 0) {
|
||||
schedule.bytes = (u8*)AOSSi_Alloc(8);
|
||||
if (schedule.bytes != 0) {
|
||||
nonce = (u16)rand();
|
||||
memcpy(&payload->encrypted.key.nonce, &nonce, 2);
|
||||
memcpy(s_packetState.key.nonce, payload->encrypted.key.nonceBytes, 2);
|
||||
memcpy(s_packetState.key.address, s_accessPointName, 8);
|
||||
AOSSInitKeySchedule(&construction.schedule, (const u8*)&s_packetState.key, sizeof(s_packetState.key), 8);
|
||||
for (index = 0; index < 8; index++) {
|
||||
state = construction.schedule.bytes;
|
||||
firstIndex = (construction.schedule.i + 1) % construction.schedule.length & 0xff;
|
||||
AOSSInitKeySchedule(&schedule, (const u8*)&s_packetState.key, sizeof(s_packetState.key), 8);
|
||||
input = hello.data.bytes;
|
||||
for (i = 0; i < 8; i++) {
|
||||
state = schedule.bytes;
|
||||
firstIndex = (schedule.i + 1) % schedule.length & 0xff;
|
||||
firstByte = state[firstIndex];
|
||||
secondIndex = (firstByte + construction.schedule.j) % construction.schedule.length & 0xff;
|
||||
secondIndex = (firstByte + schedule.j) % schedule.length & 0xff;
|
||||
swap = state[secondIndex];
|
||||
stateLength = firstByte + swap;
|
||||
construction.schedule.i = firstIndex;
|
||||
construction.schedule.j = secondIndex;
|
||||
schedule.i = firstIndex;
|
||||
schedule.j = secondIndex;
|
||||
state[secondIndex] = (u8)firstByte;
|
||||
state[firstIndex] = swap;
|
||||
value = state[stateLength % construction.schedule.length] ^ construction.hello.data.bytes[index];
|
||||
payload->bytes[index + 4] = value;
|
||||
value = state[stateLength % schedule.length];
|
||||
payload->bytes[i + 4] = value ^ *input++;
|
||||
}
|
||||
AOSSi_Free(construction.schedule.bytes);
|
||||
AOSSi_Free(schedule.bytes);
|
||||
}
|
||||
payload->encrypted.length = SOHtoNs(8);
|
||||
responseLength = 0x0c;
|
||||
} else {
|
||||
memcpy(payload->bytes, &construction.hello, 8);
|
||||
memcpy(payload->bytes, &hello, 8);
|
||||
}
|
||||
|
||||
memcpy(construction.accessPointName, &requestRecords->records[1], 8);
|
||||
encryptionResult = AOSSXorBufferWithKey(construction.accessPointName, 8, s_manufacturer, 6);
|
||||
memcpy(accessPointName, &requestRecords->records[1], 8);
|
||||
encryptionResult = AOSSXorBufferWithKey(accessPointName, 8, s_manufacturer, 6);
|
||||
if (encryptionResult != 0) {
|
||||
s_errorCode = 2;
|
||||
return -1;
|
||||
@@ -2421,17 +2412,17 @@ int AOSSSendHelloRequest(void* packet, void* request, int socket) {
|
||||
response->header.finalSequence = SOHtoNs(sequence);
|
||||
response->header.reserved = checksum;
|
||||
response->header.messageType = 0x11;
|
||||
memcpy(response->header.messageIdentity, construction.accessPointName, 8);
|
||||
memcpy(response->header.messageIdentity, accessPointName, 8);
|
||||
sendLength = (s16)(responseLength + 0x18);
|
||||
memset(&construction.destination, 0, sizeof(construction.destination));
|
||||
construction.destination.family = 2;
|
||||
construction.destination.port = SOHtoNs(0x5790);
|
||||
construction.destination.address = SOHtoNl(s_runtime.ipAddress);
|
||||
memset(&destination, 0, sizeof(destination));
|
||||
destination.family = 2;
|
||||
destination.port = SOHtoNs(0x5790);
|
||||
destination.address = SOHtoNl(s_runtime.ipAddress);
|
||||
if ((s8)s_runtime.active == 0) {
|
||||
construction.destination.address = 0xffffffff;
|
||||
destination.address = 0xffffffff;
|
||||
}
|
||||
construction.destination.length = 8;
|
||||
SOSendTo(socket, response, sendLength, 0, &construction.destination);
|
||||
destination.length = 8;
|
||||
SOSendTo(socket, response, sendLength, 0, &destination);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -2519,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) {
|
||||
@@ -2537,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;
|
||||
@@ -2546,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);
|
||||
|
||||
4
src/scene/setting/AOSSData.c
Normal file
4
src/scene/setting/AOSSData.c
Normal file
@@ -0,0 +1,4 @@
|
||||
#include "scene/setting/AOSS.h"
|
||||
|
||||
u32 s_crcTable[0x100];
|
||||
AOSSPacketState s_packetState;
|
||||
@@ -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
@@ -324,16 +324,18 @@ namespace ipl {
|
||||
return mRequestNum;
|
||||
}
|
||||
|
||||
DECOMP_FORCE_ACTIVE(iplParental_cpp, "flags:%d\n");
|
||||
DECOMP_FORCE_ACTIVE(iplParental_cpp, "rating:%d\n");
|
||||
DECOMP_FORCE_ACTIVE(iplParental_cpp, "password:%s\n");
|
||||
DECOMP_FORCE_ACTIVE(iplParental_cpp, "secretQuestion:%d\n");
|
||||
DECOMP_FORCE_ACTIVE(iplParental_cpp, "secretAnswer:%s\n");
|
||||
DECOMP_FORCE_ACTIVE(iplParental_cpp, "secretAnswerLength:%d\n");
|
||||
DECOMP_FORCE_ACTIVE(iplParental_cpp, "net contents restrictions:%02x\n");
|
||||
DECOMP_FORCE_ACTIVE(iplParental_cpp, "www channel restriction :%d\n");
|
||||
DECOMP_FORCE_ACTIVE(iplParental_cpp, "requestNum:%s\n");
|
||||
DECOMP_FORCE_ACTIVE(iplParental_cpp, "masterkey:%s\n");
|
||||
DECOMP_FORCE_ACTIVE(iplParental_cpp, "country: %d\n");
|
||||
void Parental::dump() {
|
||||
OSReport("flags:%d\n", m_sc.info.enable);
|
||||
OSReport("rating:%d\n", m_sc.info.rating);
|
||||
OSReport("password:%s\n", m_sc.info.password);
|
||||
OSReport("secretQuestion:%d\n", m_sc.info.secretQuestion);
|
||||
OSReport("secretAnswer:%s\n", m_sc.info.secretAnswer);
|
||||
OSReport("secretAnswerLength:%d\n", m_sc.info.secretAnswerLength);
|
||||
OSReport("net contents restrictions:%02x\n", SCGetNetContentRestrictions());
|
||||
OSReport("www channel restriction :%d\n", m_sc.wwwRestrict);
|
||||
OSReport("requestNum:%s\n", mRequestNum);
|
||||
OSReport("masterkey:%s\n", mMasterKey);
|
||||
OSReport("country: %d\n", getCountry());
|
||||
}
|
||||
} // namespace parental
|
||||
} // namespace ipl
|
||||
|
||||
@@ -2705,6 +2705,8 @@ namespace ipl {
|
||||
mUiStatus[2] = 0;
|
||||
}
|
||||
|
||||
#pragma push
|
||||
#pragma ppc_iro_level 1
|
||||
void Setting::scanAP() {
|
||||
BOOL playing = FALSE;
|
||||
switch (mAPScanState) {
|
||||
@@ -2753,9 +2755,8 @@ namespace ipl {
|
||||
mpPaneManager->update();
|
||||
break;
|
||||
case 6: {
|
||||
int animationIndex = mAPAnimationIndex;
|
||||
mInputDelayFrame = 1;
|
||||
playing |= mpMainLayout->getAnim(animationIndex)->isPlaying();
|
||||
playing |= mpMainLayout->getAnim(mAPAnimationIndex)->isPlaying();
|
||||
if (!playing) {
|
||||
mAPScanState = 5;
|
||||
setAPDraw();
|
||||
@@ -2780,9 +2781,8 @@ namespace ipl {
|
||||
break;
|
||||
}
|
||||
case 7: {
|
||||
int animationIndex = mAPAnimationIndex;
|
||||
mInputDelayFrame = 1;
|
||||
playing |= mpMainLayout->getAnim(animationIndex)->isPlaying();
|
||||
playing |= mpMainLayout->getAnim(mAPAnimationIndex)->isPlaying();
|
||||
if (!playing) {
|
||||
updateScroll();
|
||||
mAPScanState = 6;
|
||||
@@ -2806,6 +2806,7 @@ namespace ipl {
|
||||
break;
|
||||
}
|
||||
}
|
||||
#pragma pop
|
||||
|
||||
void Setting::initScroll() {
|
||||
if (mUiStatus[2] == 0) {
|
||||
|
||||
@@ -91,10 +91,8 @@ namespace ipl {
|
||||
mNwc24ErrCountdown = 0;
|
||||
|
||||
// Text balloon for Mii face
|
||||
f32 f0 = 30.0f;
|
||||
f32 f1 = 120.0f;
|
||||
mpNigaoeBalloon = new TextBalloon(getSceneHeap(), mpBalloonFile, "arc", "my_IplTopBalloon_a.brlyt",
|
||||
math::VEC3(0.0f, (f1 = 120.0f, 0.0f), (f0 = 30.0f, 0.0f)), f1, f0);
|
||||
mpNigaoeBalloon = new TextBalloon(getSceneHeap(), mpBalloonFile, "arc", "my_IplTopBalloon_a.brlyt", math::VEC3(0.0f, 0.0f, 0.0f),
|
||||
TextBalloon::getDefaultMargin16x9(), TextBalloon::getDefaultMargin4x3());
|
||||
|
||||
// Scroller
|
||||
mpScroller = new utility::YoungBScroller();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <revolution/gx/GXStruct.h>
|
||||
#include <revolution/os/OSError.h>
|
||||
|
||||
extern "C" const char scRsoFatalMsg[65];
|
||||
extern "C" char scRsoFatalMsg[];
|
||||
extern GXColor scRsoFatalColor;
|
||||
|
||||
#define NW4R_DB_ASSERT_H
|
||||
@@ -323,10 +323,6 @@ __declspec(export) void IplRso_symbolMaker() {
|
||||
|
||||
GXColor scRsoFatalColor = {255, 255, 255, 0};
|
||||
|
||||
extern "C" __declspec(section ".data") const char scRsoFatalMsg[65] = "Error#004\nAn error has occurred.\nThe system files are corrupted.";
|
||||
extern "C" char scRsoFatalMsg[] = "Error#004\nAn error has occurred.\nThe system files are corrupted.";
|
||||
|
||||
extern "C" __declspec(section ".data") __declspec(align(1)) const f32 rso_data_pad_f32 = 0.0f;
|
||||
extern "C" __declspec(section ".data") __declspec(align(1)) const u16 rso_data_pad_u16 = 0;
|
||||
extern "C" __declspec(section ".data") __declspec(align(1)) const u8 rso_data_pad_u8 = 0;
|
||||
|
||||
extern "C" __declspec(section ".sdata2") const f32 scRsoZeroF = 0.0f;
|
||||
extern "C" const f32 scRsoZeroF = 0.0f;
|
||||
|
||||
@@ -16,11 +16,6 @@
|
||||
#include <cstring>
|
||||
#include <cwchar>
|
||||
|
||||
extern "C" void _savegpr_27();
|
||||
extern "C" void _restgpr_27();
|
||||
extern "C" void getLanguage__Q23ipl6SystemFv();
|
||||
extern "C" void getRegion__Q23ipl6SystemFv();
|
||||
|
||||
namespace ipl {
|
||||
namespace channel {
|
||||
u32 Manager::mNumFinished;
|
||||
@@ -469,85 +464,34 @@ namespace ipl {
|
||||
System::getSaveData()->setChanInfo(page1, index1, blankInfo);
|
||||
}
|
||||
|
||||
extern "C" asm void getTitleName__Q33ipl7channel7ManagerCFiii() {
|
||||
nofralloc
|
||||
stwu r1, -0x20(r1)
|
||||
mflr r0
|
||||
stw r0, 0x24(r1)
|
||||
addi r11, r1, 0x20
|
||||
bl _savegpr_27
|
||||
mulli r28, r4, 0x540
|
||||
mr r27, r3
|
||||
mulli r29, r5, 0x70
|
||||
add r0, r3, r28
|
||||
add r31, r0, r29
|
||||
lbz r0, 0x24(r31)
|
||||
cmpwi r0, 0
|
||||
bne getTitleName_L1
|
||||
li r3, 0
|
||||
b getTitleName_L8
|
||||
getTitleName_L1:
|
||||
mulli r30, r6, 0x2a
|
||||
bl getLanguage__Q23ipl6SystemFv
|
||||
mulli r0, r3, 0x54
|
||||
lwz r3, 0x10(r31)
|
||||
add r0, r30, r0
|
||||
add r3, r3, r0
|
||||
lhz r0, 0x5c(r3)
|
||||
cmpwi r0, 0
|
||||
beq getTitleName_L3
|
||||
bl getLanguage__Q23ipl6SystemFv
|
||||
mulli r3, r3, 0x54
|
||||
lwz r0, 0x10(r31)
|
||||
add r0, r0, r3
|
||||
add r3, r0, r30
|
||||
addi r3, r3, 0x5c
|
||||
b getTitleName_L8
|
||||
getTitleName_L3:
|
||||
bl getRegion__Q23ipl6SystemFv
|
||||
lis r5, scLangLookup__Q23ipl7channel@ha
|
||||
add r4, r27, r28
|
||||
slwi r3, r3, 6
|
||||
li r0, 0x10
|
||||
addi r5, r5, scLangLookup__Q23ipl7channel@l
|
||||
add r6, r29, r4
|
||||
add r8, r5, r3
|
||||
li r3, 0
|
||||
mtctr r0
|
||||
getTitleName_L4:
|
||||
lwzx r7, r8, r3
|
||||
lwz r0, 0x10(r6)
|
||||
mulli r5, r7, 0x54
|
||||
add r0, r0, r30
|
||||
add r4, r5, r0
|
||||
lhz r0, 0x5c(r4)
|
||||
cmpwi r0, 0
|
||||
beq getTitleName_L6
|
||||
lwz r0, 0x10(r31)
|
||||
add r0, r0, r5
|
||||
add r3, r0, r30
|
||||
addi r3, r3, 0x5c
|
||||
b getTitleName_L8
|
||||
getTitleName_L6:
|
||||
addis r0, r7, 1
|
||||
cmplwi r0, 0xffff
|
||||
beq getTitleName_L7
|
||||
addi r3, r3, 4
|
||||
bdnz getTitleName_L4
|
||||
getTitleName_L7:
|
||||
lwz r0, 0(r8)
|
||||
lwz r3, 0x10(r31)
|
||||
mulli r0, r0, 0x54
|
||||
add r0, r3, r0
|
||||
add r3, r0, r30
|
||||
addi r3, r3, 0x5c
|
||||
getTitleName_L8:
|
||||
addi r11, r1, 0x20
|
||||
bl _restgpr_27
|
||||
lwz r0, 0x24(r1)
|
||||
mtlr r0
|
||||
addi r1, r1, 0x20
|
||||
blr
|
||||
wchar_t* Manager::getTitleName(int page, int index, int nameIndex) const {
|
||||
u32 language;
|
||||
const u32* languages;
|
||||
|
||||
if (!mChannels[page][index].loadedBnr) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const wchar_t* preferredName = (const wchar_t*)(
|
||||
(const u8*)mChannels[page][index].metaHdr +
|
||||
(nameIndex * (s32)sizeof(mChannels[page][index].metaHdr->names[0][0]) +
|
||||
System::getLanguage() * sizeof(mChannels[page][index].metaHdr->names[0])) +
|
||||
offsetof(SChanMgrMetaHeader, names));
|
||||
if (preferredName[0]) {
|
||||
return mChannels[page][index].metaHdr->names[System::getLanguage()][nameIndex];
|
||||
}
|
||||
|
||||
languages = scLangLookup[System::getRegion()];
|
||||
for (int i = 0; i < 16; i++) {
|
||||
language = languages[i];
|
||||
if (mChannels[page][index].metaHdr->names[(int)language][nameIndex][0]) {
|
||||
return mChannels[page][index].metaHdr->names[language][nameIndex];
|
||||
}
|
||||
if (language == -1) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return mChannels[page][index].metaHdr->names[languages[0]][nameIndex];
|
||||
}
|
||||
|
||||
BOOL Manager::checkNeedUpdate(int page, int index) const {
|
||||
|
||||
@@ -596,155 +596,47 @@ namespace ipl {
|
||||
extern "C" void makeTmpList__Q33ipl8savedata7ManagerFPUxUlPUxUl();
|
||||
extern "C" void moveTitleTmpToPrior__Q33ipl8savedata7ManagerFPUxPCUx();
|
||||
|
||||
asm void Manager::makePriorTitleIDList(register ESTitleId* titleIdsOut, register ESTitleId* titleIdsIn, register u32 titleCount) {
|
||||
nofralloc
|
||||
stwu r1, -0x50(r1)
|
||||
mflr r0
|
||||
stw r0, 0x54(r1)
|
||||
addi r11, r1, 0x50
|
||||
bl _savegpr_14
|
||||
mr r15, r3
|
||||
mr r16, r4
|
||||
mr r17, r5
|
||||
mr r18, r6
|
||||
li r23, 0
|
||||
li r31, 0
|
||||
li r30, 0
|
||||
lis r26, 0x4841
|
||||
li r14, -0x100
|
||||
li r27, 0
|
||||
makePriorTitleIDList_L1:
|
||||
add r25, r15, r31
|
||||
li r22, 0
|
||||
li r29, 0
|
||||
makePriorTitleIDList_L2:
|
||||
add r3, r25, r29
|
||||
lbz r0, 0x30(r3)
|
||||
cmplwi r0, 3
|
||||
bne makePriorTitleIDList_L8
|
||||
lwz r21, 0x38(r3)
|
||||
add r24, r22, r30
|
||||
lwz r20, 0x3c(r3)
|
||||
li r19, 0
|
||||
li r28, 0
|
||||
b makePriorTitleIDList_L7C
|
||||
makePriorTitleIDList_L3:
|
||||
add r3, r17, r28
|
||||
lwzx r0, r17, r28
|
||||
lwz r3, 4(r3)
|
||||
or. r0, r3, r0
|
||||
beq makePriorTitleIDList_L7
|
||||
slwi r0, r24, 3
|
||||
add r4, r16, r0
|
||||
lwzx r3, r16, r0
|
||||
lwz r4, 4(r4)
|
||||
or. r0, r4, r3
|
||||
beq makePriorTitleIDList_L4
|
||||
mr r21, r3
|
||||
mr r20, r4
|
||||
b makePriorTitleIDList_L6
|
||||
makePriorTitleIDList_L4:
|
||||
li r0, -1
|
||||
lis r4, 1
|
||||
and r3, r20, r14
|
||||
addi r5, r26, 0x4100
|
||||
and r0, r21, r0
|
||||
addi r6, r4, 2
|
||||
xor r5, r3, r5
|
||||
xor r4, r0, r6
|
||||
or. r4, r5, r4
|
||||
beq makePriorTitleIDList_L5
|
||||
addi r5, r26, 0x5900
|
||||
xor r4, r0, r6
|
||||
xor r5, r3, r5
|
||||
or. r4, r5, r4
|
||||
beq makePriorTitleIDList_L5
|
||||
addi r5, r26, 0x5a00
|
||||
xoris r4, r0, 1
|
||||
xor r5, r3, r5
|
||||
or. r4, r5, r4
|
||||
bne makePriorTitleIDList_L6
|
||||
makePriorTitleIDList_L5:
|
||||
lwz r4, 0x4f8(r15)
|
||||
lwz r5, 0x4fc(r15)
|
||||
xor r0, r0, r4
|
||||
xor r3, r3, r5
|
||||
or. r0, r3, r0
|
||||
beq makePriorTitleIDList_L6
|
||||
ori r20, r5, 0x41
|
||||
mr r21, r4
|
||||
makePriorTitleIDList_L6:
|
||||
add r4, r17, r28
|
||||
lwzx r7, r17, r28
|
||||
lwz r8, 4(r4)
|
||||
mr r3, r15
|
||||
mr r6, r20
|
||||
mr r5, r21
|
||||
bl isEqualChannel__Q33ipl8savedata7ManagerFUxUx
|
||||
cmpwi r3, -2
|
||||
beq makePriorTitleIDList_L6A
|
||||
cmpwi r3, 0
|
||||
bne makePriorTitleIDList_L6B
|
||||
makePriorTitleIDList_L6A:
|
||||
mr r3, r15
|
||||
mr r6, r20
|
||||
mr r5, r21
|
||||
bl checkValidApp__Q33ipl8savedata7ManagerFUx
|
||||
cmpwi r3, 0
|
||||
beq makePriorTitleIDList_L6C
|
||||
slwi r0, r24, 3
|
||||
add r3, r16, r0
|
||||
stw r20, 4(r3)
|
||||
stwx r21, r16, r0
|
||||
makePriorTitleIDList_L6C:
|
||||
add r3, r17, r28
|
||||
stw r27, 4(r3)
|
||||
stwx r27, r17, r28
|
||||
b makePriorTitleIDList_L7
|
||||
makePriorTitleIDList_L6B:
|
||||
cmpwi r3, 1
|
||||
bne makePriorTitleIDList_L7
|
||||
add r4, r17, r28
|
||||
lwzx r5, r17, r28
|
||||
lwz r6, 4(r4)
|
||||
mr r3, r15
|
||||
bl checkValidApp__Q33ipl8savedata7ManagerFUx
|
||||
cmpwi r3, 0
|
||||
beq makePriorTitleIDList_L6D
|
||||
slwi r0, r24, 3
|
||||
add r5, r17, r28
|
||||
add r3, r16, r0
|
||||
lwzx r4, r17, r28
|
||||
lwz r0, 4(r5)
|
||||
stw r0, 4(r3)
|
||||
stw r4, 0(r3)
|
||||
makePriorTitleIDList_L6D:
|
||||
add r3, r17, r28
|
||||
stw r27, 4(r3)
|
||||
stwx r27, r17, r28
|
||||
makePriorTitleIDList_L7:
|
||||
addi r19, r19, 1
|
||||
addi r28, r28, 8
|
||||
makePriorTitleIDList_L7C:
|
||||
cmplw r19, r18
|
||||
blt makePriorTitleIDList_L3
|
||||
makePriorTitleIDList_L8:
|
||||
addi r22, r22, 1
|
||||
addi r29, r29, 0x10
|
||||
cmpwi r22, 0xc
|
||||
blt makePriorTitleIDList_L2
|
||||
addi r23, r23, 1
|
||||
addi r30, r30, 0xc
|
||||
cmpwi r23, 4
|
||||
addi r31, r31, 0xc0
|
||||
blt makePriorTitleIDList_L1
|
||||
addi r11, r1, 0x50
|
||||
bl _restgpr_14
|
||||
lwz r0, 0x54(r1)
|
||||
mtlr r0
|
||||
addi r1, r1, 0x50
|
||||
blr
|
||||
#pragma push
|
||||
#pragma ppc_iro_level 0
|
||||
void Manager::makePriorTitleIDList(ESTitleId* titleIdsOut, ESTitleId* titleIdsIn, u32 titleCount) {
|
||||
int outputIndex;
|
||||
for (int page = 0; page < MAX_CHANNEL_PAGE; page++) {
|
||||
for (int index = 0; index < MAX_CHANNEL_INDEX; index++) {
|
||||
if (mData.chanInfo[page][index].primaryType == channel::PRIMARY_TYPE_CHANNEL) {
|
||||
outputIndex = index + page * MAX_CHANNEL_INDEX;
|
||||
ESTitleId titleId = ES_TITLE_ID(mData.chanInfo[page][index].titleType, mData.chanInfo[page][index].titleCode);
|
||||
for (u32 inputIndex = 0; inputIndex < titleCount; inputIndex++) {
|
||||
if (titleIdsIn[inputIndex] == TITLE_NULL) {
|
||||
continue;
|
||||
}
|
||||
if (titleIdsOut[outputIndex] != TITLE_NULL) {
|
||||
titleId = titleIdsOut[outputIndex];
|
||||
} else {
|
||||
ESTitleId titleCode = TITLE_NO_REGION(titleId);
|
||||
if (titleCode == TITLE_PHOTO || titleCode == TITLE_PHOTO_2 || titleCode == TITLE_PHOTO_2_CHECK) {
|
||||
if (titleCode != mPhotoId) {
|
||||
titleId = mPhotoId | TITLE_REGION_ALL;
|
||||
}
|
||||
}
|
||||
}
|
||||
int match = isEqualChannel(titleId, titleIdsIn[inputIndex]);
|
||||
if (match == -2 || match == 0) {
|
||||
if (checkValidApp(titleId)) {
|
||||
titleIdsOut[outputIndex] = titleId;
|
||||
}
|
||||
titleIdsIn[inputIndex] = TITLE_NULL;
|
||||
} else if (match == 1) {
|
||||
if (checkValidApp(titleIdsIn[inputIndex])) {
|
||||
titleIdsOut[outputIndex] = titleIdsIn[inputIndex];
|
||||
}
|
||||
titleIdsIn[inputIndex] = TITLE_NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#pragma pop
|
||||
|
||||
void Manager::integrateTitleIDList(ESTitleId* titleIdsOut, ESTitleId* titleIdsIn, u32 titleCount) {
|
||||
ESTitleId temporaryTitleIds[0x36] = {0};
|
||||
@@ -804,81 +696,35 @@ namespace ipl {
|
||||
}
|
||||
}
|
||||
|
||||
asm BOOL Manager::doUpdateChanInfos(register ESTitleId* titleIds) {
|
||||
nofralloc
|
||||
stwu r1, -0x40(r1)
|
||||
mflr r0
|
||||
stw r0, 0x44(r1)
|
||||
addi r11, r1, 0x40
|
||||
bl _savegpr_20
|
||||
mr r27, r3
|
||||
mr r28, r4
|
||||
li r3, 0
|
||||
li r30, 0
|
||||
li r26, 0
|
||||
li r25, 0
|
||||
li r20, 3
|
||||
li r21, 0
|
||||
li r22, 0xe
|
||||
li r23, -1
|
||||
doUpdateChanInfos_L1:
|
||||
add r31, r27, r26
|
||||
li r29, 0
|
||||
li r24, 0
|
||||
doUpdateChanInfos_L2:
|
||||
add r4, r31, r24
|
||||
lbz r0, 0x30(r4)
|
||||
cmplwi r0, 1
|
||||
beq doUpdateChanInfos_L5
|
||||
add r0, r29, r25
|
||||
lwz r9, 0x38(r4)
|
||||
slwi r0, r0, 3
|
||||
lwz r5, 0x3c(r4)
|
||||
add r8, r28, r0
|
||||
lwzx r6, r28, r0
|
||||
lwz r7, 4(r8)
|
||||
xor r0, r9, r6
|
||||
xor r5, r5, r7
|
||||
or. r0, r5, r0
|
||||
beq doUpdateChanInfos_L5
|
||||
or. r0, r7, r6
|
||||
bne doUpdateChanInfos_L4
|
||||
addi r3, r4, 0x30
|
||||
li r4, 0
|
||||
li r5, 0x10
|
||||
bl memset
|
||||
b doUpdateChanInfos_L6
|
||||
doUpdateChanInfos_L4:
|
||||
stb r20, 0x30(r4)
|
||||
stb r21, 0x31(r4)
|
||||
stb r21, 0x32(r4)
|
||||
stb r21, 0x33(r4)
|
||||
stw r22, 0x34(r4)
|
||||
lwz r0, 0(r8)
|
||||
and r0, r0, r23
|
||||
stw r0, 0x38(r4)
|
||||
lwz r0, 4(r8)
|
||||
and r0, r0, r23
|
||||
stw r0, 0x3c(r4)
|
||||
doUpdateChanInfos_L6:
|
||||
li r3, 1
|
||||
doUpdateChanInfos_L5:
|
||||
addi r29, r29, 1
|
||||
addi r24, r24, 0x10
|
||||
cmpwi r29, 0xc
|
||||
blt doUpdateChanInfos_L2
|
||||
addi r30, r30, 1
|
||||
addi r25, r25, 0xc
|
||||
cmpwi r30, 4
|
||||
addi r26, r26, 0xc0
|
||||
blt doUpdateChanInfos_L1
|
||||
addi r11, r1, 0x40
|
||||
bl _restgpr_20
|
||||
lwz r0, 0x44(r1)
|
||||
mtlr r0
|
||||
addi r1, r1, 0x40
|
||||
blr
|
||||
#pragma push
|
||||
#pragma ppc_iro_level 0
|
||||
BOOL Manager::doUpdateChanInfos(ESTitleId* titleIds) {
|
||||
BOOL changed = FALSE;
|
||||
for (int page = 0; page < MAX_CHANNEL_PAGE; page++) {
|
||||
for (int index = 0; index < MAX_CHANNEL_INDEX; index++) {
|
||||
if (mData.chanInfo[page][index].primaryType != channel::PRIMARY_TYPE_DISK) {
|
||||
ESTitleId titleId = ES_TITLE_ID(mData.chanInfo[page][index].titleType, mData.chanInfo[page][index].titleCode);
|
||||
int n = index + page * MAX_CHANNEL_INDEX;
|
||||
if (titleId != titleIds[n]) {
|
||||
if (titleIds[n] == TITLE_NULL) {
|
||||
memset(&mData.chanInfo[page][index], 0, sizeof(channel::SInfo));
|
||||
} else {
|
||||
mData.chanInfo[page][index].primaryType = channel::PRIMARY_TYPE_CHANNEL;
|
||||
mData.chanInfo[page][index].secondaryType = channel::SECONARY_TYPE_NORMAL;
|
||||
mData.chanInfo[page][index].reserved[0] = 0;
|
||||
mData.chanInfo[page][index].reserved[1] = 0;
|
||||
mData.chanInfo[page][index].sceneID = SCENE_NORMAL_CHANNEL;
|
||||
mData.chanInfo[page][index].titleType = ES_TITLE_TYPE(titleIds[n]);
|
||||
mData.chanInfo[page][index].titleCode = ES_TITLE_CODE(titleIds[n]);
|
||||
}
|
||||
changed = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
#pragma pop
|
||||
#endif
|
||||
|
||||
BOOL Manager::checkValidApp(ESTitleId titleId) {
|
||||
|
||||
@@ -527,11 +527,9 @@ namespace ipl {
|
||||
|
||||
// Default values for initial setup
|
||||
if (!SCGetConfigDoneFlag() && !SCGetConfigDoneFlag2()) {
|
||||
struct BlankNameStorage {
|
||||
SCOwnerNickname blankName;
|
||||
} blankNameStorage;
|
||||
memset(&blankNameStorage.blankName, 0, sizeof(blankNameStorage.blankName));
|
||||
SCSetOwnerNickName(&blankNameStorage.blankName);
|
||||
SCOwnerNickname blankName;
|
||||
memset(&blankName, 0, sizeof(blankName));
|
||||
SCSetOwnerNickName(&blankName);
|
||||
|
||||
SCSetAspectRatio(SC_ASPECT_RATIO_4x3);
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -361,17 +361,132 @@ namespace ipl {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// DeleteSharedContent did not survive
|
||||
DECOMP_FORCE_ACTIVE(iplESMisc_cpp, "DeleteSharedContent: MEMAllocate for TMD err\n");
|
||||
DECOMP_FORCE_ACTIVE(iplESMisc_cpp, "DeleteSharedContent: ES_ListSharedContents1 err %d\n");
|
||||
DECOMP_FORCE_ACTIVE(iplESMisc_cpp, "DeleteSharedContent: MEMAllocate for SHA-1 hash err\n");
|
||||
DECOMP_FORCE_ACTIVE(iplESMisc_cpp, "DeleteSharedContent: ES_ListSharedContents2 err %d\n");
|
||||
DECOMP_FORCE_ACTIVE(iplESMisc_cpp, "DeleteSharedContent: ES_ListTitlesOnCard1 err %d\n");
|
||||
DECOMP_FORCE_ACTIVE(iplESMisc_cpp, "DeleteSharedContent: MEMAllocate for Title List err\n");
|
||||
DECOMP_FORCE_ACTIVE(iplESMisc_cpp, "DeleteSharedContent: ES_ListTitlesOnCard2 err %d\n");
|
||||
DECOMP_FORCE_ACTIVE(iplESMisc_cpp, "DeleteSharedContent: ES_GetTmd1 err %d\n");
|
||||
DECOMP_FORCE_ACTIVE(iplESMisc_cpp, "DeleteSharedContent: ES_GetTmd2 err %d\n");
|
||||
DECOMP_FORCE_ACTIVE(iplESMisc_cpp, "DeleteSharedContent: ES_DeleteSharedContent err %d\n");
|
||||
extern "C" ESError ES_DeleteSharedContent(const u8* hash);
|
||||
|
||||
ESError ESMisc::DeleteSharedContent(EGG::Heap* heap) {
|
||||
ESTitleMeta* tmd = NULL;
|
||||
ESHash* hashes = NULL;
|
||||
u8* used = NULL;
|
||||
ESTitleId* titleIds = NULL;
|
||||
u32 numShared = 0;
|
||||
u32 numTitles = 0;
|
||||
ESError ret;
|
||||
|
||||
tmd = (ESTitleMeta*)heap->alloc(OSRoundUp32B(sizeof(ESTitleMeta)), -DEFAULT_ALIGN);
|
||||
if (tmd == NULL) {
|
||||
OSReport("DeleteSharedContent: MEMAllocate for TMD err\n");
|
||||
return ES_ERR_MEMORY_ERROR;
|
||||
}
|
||||
|
||||
ret = ES_ListSharedContents(&numShared, NULL);
|
||||
if (ret < ES_ERR_OK) {
|
||||
OSReport("DeleteSharedContent: ES_ListSharedContents1 err %d\n", ret);
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (numShared == 0) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
hashes = (ESHash*)heap->alloc(OSRoundUp32B(numShared * sizeof(ESHash)), -DEFAULT_ALIGN);
|
||||
if (hashes == NULL) {
|
||||
OSReport("DeleteSharedContent: MEMAllocate for SHA-1 hash err\n");
|
||||
ret = ES_ERR_MEMORY_ERROR;
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = ES_ListSharedContents(&numShared, hashes);
|
||||
if (ret < ES_ERR_OK) {
|
||||
OSReport("DeleteSharedContent: ES_ListSharedContents2 err %d\n", ret);
|
||||
goto out;
|
||||
}
|
||||
|
||||
used = (u8*)heap->alloc(OSRoundUp32B(numShared), -DEFAULT_ALIGN);
|
||||
if (used == NULL) {
|
||||
ret = ES_ERR_MEMORY_ERROR;
|
||||
goto out;
|
||||
}
|
||||
memset(used, 0, numShared);
|
||||
|
||||
ret = ES_ListTitlesOnCard(NULL, &numTitles);
|
||||
if (ret < ES_ERR_OK) {
|
||||
OSReport("DeleteSharedContent: ES_ListTitlesOnCard1 err %d\n", ret);
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (numTitles != 0) {
|
||||
titleIds = (ESTitleId*)heap->alloc(OSRoundUp32B(numTitles * sizeof(ESTitleId)), -DEFAULT_ALIGN);
|
||||
if (titleIds == NULL) {
|
||||
OSReport("DeleteSharedContent: MEMAllocate for Title List err\n");
|
||||
ret = ES_ERR_MEMORY_ERROR;
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = ES_ListTitlesOnCard(titleIds, &numTitles);
|
||||
if (ret < ES_ERR_OK) {
|
||||
OSReport("DeleteSharedContent: ES_ListTitlesOnCard2 err %d\n", ret);
|
||||
goto out;
|
||||
}
|
||||
|
||||
for (u32 i = 0; i < numTitles; i++) {
|
||||
u32 tmdSize = 0;
|
||||
|
||||
ret = ES_GetTmd(titleIds[i], NULL, &tmdSize);
|
||||
if (ret < ES_ERR_OK) {
|
||||
OSReport("DeleteSharedContent: ES_GetTmd1 err %d\n", ret);
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (tmdSize == 0 || tmdSize > sizeof(ESTitleMeta)) {
|
||||
ret = ES_ERR_INVALID;
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = ES_GetTmd(titleIds[i], tmd, &tmdSize);
|
||||
if (ret < ES_ERR_OK) {
|
||||
OSReport("DeleteSharedContent: ES_GetTmd2 err %d\n", ret);
|
||||
goto out;
|
||||
}
|
||||
|
||||
for (u16 c = 0; c < tmd->head.numContents; c++) {
|
||||
if ((tmd->contents[c].type & 0x8000) == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (u32 h = 0; h < numShared; h++) {
|
||||
if (memcmp(tmd->contents[c].hash, hashes[h], sizeof(ESHash)) == 0) {
|
||||
used[h] = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (u32 h = 0; h < numShared; h++) {
|
||||
if (used[h] != 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ret = ES_DeleteSharedContent(hashes[h]);
|
||||
if (ret < ES_ERR_OK) {
|
||||
OSReport("DeleteSharedContent: ES_DeleteSharedContent err %d\n", ret);
|
||||
}
|
||||
}
|
||||
|
||||
out:
|
||||
if (titleIds != NULL) {
|
||||
heap->free(titleIds);
|
||||
}
|
||||
if (used != NULL) {
|
||||
heap->free(used);
|
||||
}
|
||||
if (hashes != NULL) {
|
||||
heap->free(hashes);
|
||||
}
|
||||
heap->free(tmd);
|
||||
return ret;
|
||||
}
|
||||
|
||||
BOOL ESMisc::IsLastTicketExpired(ESTitleId* titleId) {
|
||||
s32 ret;
|
||||
@@ -883,12 +998,24 @@ namespace ipl {
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline void verifySavedataZD(EGG::Heap* heap, ESTitleId titleId, NANDFileInfo* fileInfo) {
|
||||
char path[NAND_MAX_PATH];
|
||||
static inline void verifySavedataZD(EGG::Heap* heap, ESTitleId requestedTitleId, NANDFileInfo* fileInfo) {
|
||||
ESTitleId titleId;
|
||||
u32 offset;
|
||||
u32 j;
|
||||
BOOL valid;
|
||||
BOOL fileOpen;
|
||||
u8* firstBlock;
|
||||
u8* secondBlock;
|
||||
BOOL deleteSaveData;
|
||||
s32 ret;
|
||||
u8* saveData = NULL;
|
||||
BOOL fileOpen = FALSE;
|
||||
BOOL deleteSaveData = FALSE;
|
||||
u8* saveData;
|
||||
titleId = requestedTitleId;
|
||||
|
||||
char path[NAND_MAX_PATH];
|
||||
|
||||
saveData = NULL;
|
||||
fileOpen = FALSE;
|
||||
deleteSaveData = FALSE;
|
||||
|
||||
sprintf(path, "/title/%08x/%08x/data/%s", (u32)((titleId & 0x00FFFFFFFFFFFFFFULL) >> 32), (u32)(titleId & 0x00FFFFFFFFFFFFFFULL), "zeldaTp.dat");
|
||||
if (!ESMisc::ChangeUid(titleId)) {
|
||||
@@ -915,17 +1042,17 @@ namespace ipl {
|
||||
OSReport("%s::%s: File size is not correct: %d\n", __FILE__, __FUNCTION__, ret);
|
||||
deleteSaveData = TRUE;
|
||||
} else {
|
||||
u32 offset = 8;
|
||||
u32 j = 0;
|
||||
BOOL valid = FALSE;
|
||||
offset = 8;
|
||||
valid = FALSE;
|
||||
j = 0;
|
||||
while (j < 3) {
|
||||
u8* block = saveData + offset;
|
||||
if (!checkForNullTermination((char*)block + 0x4e, 8) ||
|
||||
!checkForNullTermination((char*)block + 0x58, 8) ||
|
||||
!checkForNullTermination((char*)block + 0x72, 8) ||
|
||||
!checkForNullTermination((char*)block + 0x8e, 8) ||
|
||||
!checkForNullTermination((char*)block + 0x1b4, 0x11) ||
|
||||
!checkForNullTermination((char*)block + 0x1c5, 0x11)) {
|
||||
firstBlock = saveData + offset;
|
||||
if (!checkForNullTermination((char*)firstBlock + 0x4e, 8) ||
|
||||
!checkForNullTermination((char*)firstBlock + 0x58, 8) ||
|
||||
!checkForNullTermination((char*)firstBlock + 0x72, 8) ||
|
||||
!checkForNullTermination((char*)firstBlock + 0x8e, 8) ||
|
||||
!checkForNullTermination((char*)firstBlock + 0x1b4, 0x11) ||
|
||||
!checkForNullTermination((char*)firstBlock + 0x1c5, 0x11)) {
|
||||
goto verify_failed;
|
||||
}
|
||||
j++;
|
||||
@@ -935,13 +1062,13 @@ namespace ipl {
|
||||
offset = 0x2008;
|
||||
j = 0;
|
||||
while (j < 3) {
|
||||
u8* block = saveData + offset;
|
||||
if (!checkForNullTermination((char*)block + 0x4e, 8) ||
|
||||
!checkForNullTermination((char*)block + 0x58, 8) ||
|
||||
!checkForNullTermination((char*)block + 0x72, 8) ||
|
||||
!checkForNullTermination((char*)block + 0x8e, 8) ||
|
||||
!checkForNullTermination((char*)block + 0x1b4, 0x11) ||
|
||||
!checkForNullTermination((char*)block + 0x1c5, 0x11)) {
|
||||
secondBlock = saveData + offset;
|
||||
if (!checkForNullTermination((char*)secondBlock + 0x4e, 8) ||
|
||||
!checkForNullTermination((char*)secondBlock + 0x58, 8) ||
|
||||
!checkForNullTermination((char*)secondBlock + 0x72, 8) ||
|
||||
!checkForNullTermination((char*)secondBlock + 0x8e, 8) ||
|
||||
!checkForNullTermination((char*)secondBlock + 0x1b4, 0x11) ||
|
||||
!checkForNullTermination((char*)secondBlock + 0x1c5, 0x11)) {
|
||||
goto verify_failed;
|
||||
}
|
||||
j++;
|
||||
@@ -978,8 +1105,11 @@ namespace ipl {
|
||||
}
|
||||
|
||||
static inline s32 DeleteTicketsForce(EGG::Heap* heap, ESTitleId titleId, u8* ticketViews, u32* ticketViewCount) {
|
||||
ESTicketView* ticketViewList = NULL;
|
||||
s32 ret;
|
||||
u32 j;
|
||||
ESTicketView* ticketViewList;
|
||||
ticketViewList = NULL;
|
||||
|
||||
memset(ticketViews, 0, OSRoundUp32B(sizeof(ESTicketView)));
|
||||
ret = ES_GetTicketViews(titleId, NULL, ticketViewCount);
|
||||
if (ret != ES_ERR_OK) {
|
||||
@@ -995,7 +1125,7 @@ namespace ipl {
|
||||
OSReport("%s::%s: ES_GetTicketViews failed: %d for %016llx\n", __FILE__, __FUNCTION__, ret, titleId);
|
||||
goto cleanup;
|
||||
}
|
||||
for (u32 j = 0; j < *ticketViewCount; j++) {
|
||||
for (j = 0; j < *ticketViewCount; j++) {
|
||||
memcpy(ticketViews, &ticketViewList[j], sizeof(ESTicketView));
|
||||
ret = ES_DeleteTicket((ESTicketView*)ticketViews);
|
||||
if (ret != ES_ERR_OK) {
|
||||
@@ -1011,12 +1141,16 @@ namespace ipl {
|
||||
}
|
||||
|
||||
static inline s32 InitSavedata(EGG::Heap* heap) {
|
||||
u32 i;
|
||||
s32 ret;
|
||||
ESTitleId* titleIds;
|
||||
u8* ticketScratch;
|
||||
u8 ticketViews[OSRoundUp32B(sizeof(ESTicketView))] ALIGN32;
|
||||
NANDFileInfo fileInfo ALIGN32;
|
||||
u32 ticketViewCount;
|
||||
ESTitleId* titleIds = NULL;
|
||||
titleIds = NULL;
|
||||
u32 titleCount = 0;
|
||||
s32 ret = ES_ListTitlesOnCard(NULL, &titleCount);
|
||||
ret = ES_ListTitlesOnCard(NULL, &titleCount);
|
||||
|
||||
if (ret != ES_ERR_OK) {
|
||||
OSReport("%s::%s: Failed to ES_ListTitlesOnCard1: %d\n", __FILE__, __FUNCTION__, ret);
|
||||
@@ -1036,8 +1170,8 @@ namespace ipl {
|
||||
}
|
||||
|
||||
{
|
||||
u8* ticketScratch = ticketViews;
|
||||
for (u32 i = 0; i < titleCount; i++) {
|
||||
ticketScratch = ticketViews;
|
||||
for (i = 0; i < titleCount; i++) {
|
||||
if ((titleIds[i] & 0xFFFFFFFFFFFFFF00ULL) == 0x00010000525A4400ULL) {
|
||||
verifySavedataZD(heap, titleIds[i], &fileInfo);
|
||||
continue;
|
||||
@@ -1062,10 +1196,6 @@ namespace ipl {
|
||||
return ret;
|
||||
}
|
||||
|
||||
s32 ESMisc::DeleteUnauthorizedData(EGG::Heap* heap) {
|
||||
return InitSavedata(heap);
|
||||
}
|
||||
|
||||
BOOL checkForNullTermination(char* str, u32 len) {
|
||||
for (u32 i = 0; i < len; i++) {
|
||||
if (*str == 0) {
|
||||
@@ -1076,6 +1206,10 @@ namespace ipl {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
s32 ESMisc::DeleteUnauthorizedData(EGG::Heap* heap) {
|
||||
return InitSavedata(heap);
|
||||
}
|
||||
|
||||
TMDFile::TMDFile(EGG::Heap* heap) : mpHeap(heap), mbFileOpen(FALSE), mFileLength(0) {
|
||||
memset(&mFile, 0, sizeof(mFile));
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ from pathlib import Path
|
||||
|
||||
|
||||
EXPECTED_DOL_SHA1 = "26116613f624061ba99c8d1a299aaa6efa85670d"
|
||||
EXPECTED_TOTAL_UNITS = 1027
|
||||
EXPECTED_TOTAL_UNITS = 1028
|
||||
EXPECTED_TOTAL_CODE = 2995176
|
||||
EXPECTED_TOTAL_DATA = 1832684
|
||||
EXPECTED_TOTAL_FUNCTIONS = 12563
|
||||
|
||||
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.
|
||||
9
tools/decomp-assist/grok-cdbfs.attempts.md
Normal file
9
tools/decomp-assist/grok-cdbfs.attempts.md
Normal file
@@ -0,0 +1,9 @@
|
||||
# grok-cdbfs CDBFileSystem
|
||||
|
||||
Replaced DECOMP_FORCE_ACTIVE NAND logs with the helpers that owned those strings.
|
||||
|
||||
1. static helpers: compiler deleted them and the strings (pool 16 vs 25). differing n/a.
|
||||
2. global helpers: pool identical 25/25, every existing function differing 0. CDBFSInitWiiIdPath wrote CDB_WIIID_DAT_PATH first and swapped .bss (VFF name vs wiiid path). DOL sha1 45ea54b56b135b08c766cd610d416d72ad7858ca.
|
||||
3. CDBFSReportWiiIdDat only passes "nocopy/cdbwiiid.dat" to the status dump. .bss order restored. pool identical. 12/12 functions differing 0. DOL sha1 26116613f624061ba99c8d1a299aaa6efa85670d.
|
||||
|
||||
Linker strips the new globals. static would drop the strings again.
|
||||
11
tools/decomp-assist/grok-esmisc.attempts.md
Normal file
11
tools/decomp-assist/grok-esmisc.attempts.md
Normal file
@@ -0,0 +1,11 @@
|
||||
# grok-esmisc DeleteSharedContent
|
||||
|
||||
Replaced the ten DECOMP_FORCE_ACTIVE strings with ESMisc::DeleteSharedContent.
|
||||
The function is not in the target object (linker stripped it). Strings stay in source order.
|
||||
|
||||
Attempt 1: heap-alloc a max TMD, ES_ListSharedContents count/list, ES_ListTitlesOnCard count/list, ES_GetTmd size/data per title, mark shared-content hashes (type & 0x8000), ES_DeleteSharedContent on the rest.
|
||||
- pool: IDENTICAL 114/114
|
||||
- .data sha1 b38f8ebbacceb1818e343c6ce51f9abf8603ec23 matches the force-active build (4378 bytes)
|
||||
- .sdata identical to that build
|
||||
- odiff: 30 functions differing 0; DeleteUnauthorizedData differing 74/449 (fuzzy 99.14254), same as the force-active build
|
||||
- gate: PASS. DOL 26116613f624061ba99c8d1a299aaa6efa85670d. data 4416/4416. regressions 0.
|
||||
18
tools/decomp-assist/grok-focus.attempts.md
Normal file
18
tools/decomp-assist/grok-focus.attempts.md
Normal file
@@ -0,0 +1,18 @@
|
||||
# grok-focus is_url_ext
|
||||
|
||||
Replaced the eight DECOMP_FORCE_ACTIVE wide strings with focus_object::is_url_ext.
|
||||
The function is not in the target object (linker must strip it). Strings stay in source order.
|
||||
|
||||
Attempt 1: local `const wchar_t* exts[] = { L".html", ... }` loop.
|
||||
- .rodata 176 -> 208 (MWCC emitted the pointer table). Restored.
|
||||
|
||||
Attempt 2: unrolled wcsncmp tail checks, one local pointer per extension.
|
||||
- .data/.rodata/.sdata/.sdata2 identical to the force-active object
|
||||
- 89/89 original functions byte-identical, odiff differing 0
|
||||
|
||||
Attempt 3: same compares in a loop, pointers assigned one by one (no aggregate initializer).
|
||||
- .data sha 672d08c07636 matches the force-active build (2164 bytes; orig object is 2168 with 4 trailing zero bytes, unchanged)
|
||||
- .rodata/.sdata/.sdata2 identical to the original object
|
||||
- pool IDENTICAL 80/80
|
||||
- odiff: 89/89 differing 0
|
||||
- no DECOMP_FORCE_ACTIVE left in iplFocusObject.cpp
|
||||
12
tools/decomp-assist/grok-osexec.attempts.md
Normal file
12
tools/decomp-assist/grok-osexec.attempts.md
Normal file
@@ -0,0 +1,12 @@
|
||||
# grok-osexec OSExec
|
||||
|
||||
Replaced DECOMP_FORCE_ACTIVE string holders with the SDK functions that own those literals.
|
||||
|
||||
- __OSLaunchNextFirmware before the other functions, so "Failed to exec" (shared execFailure) and "specified game doesn't exist" emit first.
|
||||
- OSLaunchDisk / OSLaunchDiskv after the linked launch helpers: three OSLaunchDisk reports, then "0000000000000000".
|
||||
- IsNewApploader next: "2004/02/01".
|
||||
- OSLaunchPartition / OSLaunchPartitionv last: the two partition reports.
|
||||
|
||||
Pool identical 17/17. All 10 linked functions odiff 0. objdiff data 864/864, fuzzy 100. Relinked DOL sha1 26116613f624061ba99c8d1a299aaa6efa85670d. Dead functions stripped (__OSInReboot stays at 0x81699040).
|
||||
|
||||
GATE PASS. Renamed new varargs params off arg0 so the readability scan stays clean. Volatile on DVDLowIntType is the callback flag the wait loop reloads.
|
||||
8
tools/decomp-assist/grok-osnet.attempts.md
Normal file
8
tools/decomp-assist/grok-osnet.attempts.md
Normal file
@@ -0,0 +1,8 @@
|
||||
# OSNet dead NWC24 functions (grok-osnet)
|
||||
|
||||
Target object keeps only __OSInitNet and __OSSyncTimeWithNetRM. The eight fossil strings are the caller names and paths from the SDK shutdown/scheduler/rtc helpers. RevoEX already defines NWC24iPrepareShutdown, NWC24SuspendScheduler, and NWC24ResumeScheduler, so those three are weak here and the linker keeps the RevoEX copies.
|
||||
|
||||
- Full zeldaret bodies, including CheckCallingStatus's "Illegal status..." report: pool diverged (extra string, and IPA inlined the helpers into __OSInitNet).
|
||||
- never_inline on the definition only: still inlined. MWCC uses the first declaration. Prototypes with NO_INLINE before private/nwc24.h stop the inline. __OSInitNet 0xb4/0xb4 differing 0, __OSSyncTimeWithNetRM 0x8/0x8 differing 0. Pool identical, 11 strings.
|
||||
- Strong definitions: link failed, multiply-defined against NWC24System.o and NWC24Schedule.o.
|
||||
- DECL_WEAK on those three: link succeeded. main.dol SHA1 26116613f624061ba99c8d1a299aaa6efa85670d.
|
||||
11
tools/decomp-assist/grok-parental.attempts.md
Normal file
11
tools/decomp-assist/grok-parental.attempts.md
Normal file
@@ -0,0 +1,11 @@
|
||||
# grok-parental Parental::dump
|
||||
|
||||
Replaced the eleven DECOMP_FORCE_ACTIVE strings with Parental::dump.
|
||||
The function is not in the target object (linker stripped it). Strings stay in source order.
|
||||
|
||||
Attempt 1: print enable, rating, password, secret question/answer/length, SCGetNetContentRestrictions, wwwRestrict, mRequestNum, mMasterKey, getCountry.
|
||||
- pool: IDENTICAL 17/17
|
||||
- .data sha1 e3b3aaf3411decf3cd524b01cc437f434417dda1 matches the force-active build (332 bytes)
|
||||
- .sdata identical to that build
|
||||
- odiff: 30 functions differing 0
|
||||
- gate: PASS. DOL 26116613f624061ba99c8d1a299aaa6efa85670d. data 1576/1576. functions 30/30. regressions 0.
|
||||
14
tools/decomp-assist/grok-singles.attempts.md
Normal file
14
tools/decomp-assist/grok-singles.attempts.md
Normal file
@@ -0,0 +1,14 @@
|
||||
# grok-singles force-retention
|
||||
|
||||
## cnt.c
|
||||
File-scope `const char* __CNTVersion` lands in .sdata and the linker keeps it at 0x81698330 even when CNTInit is stripped (weak and static-used-by-CNTInit both kept). That shifts later sdata: DOL 677 bytes off, sha 01822ae8. Unused static pointer is deleted by the compiler and takes the banner string with it.
|
||||
Banner stays a local in stripped CNTInit, which calls OSRegisterVersion. CNTInitHandle sprintf's `/content%d` and prints the missing-directory warning. Pool bytes match (version, /content%d, warning, then the three ES strings). 16/16 linked functions differing 0. DOL 26116613f624061ba99c8d1a299aaa6efa85670d.
|
||||
|
||||
## CDBConv.c
|
||||
CDBConvDateValueToDateStr sprintf's "%04d%02d%02d" where the force sat, before CDBConvKeyToFullPath. .data 176/176 identical, .sdata 56/56 identical, 39/39 linked functions differing 0. Helper stripped. DOL matches.
|
||||
|
||||
## WUD.c
|
||||
WUDCancelSyncDevice prints its name and returns StopSync(). StopSync stays inlined in WUDStopSyncSimple (38/38 differing 0). 107 strings equal, data bytes identical, 66/66 linked functions differing 0. Cancel function stripped. DOL matches.
|
||||
|
||||
## OSReset.c
|
||||
DECL_WEAK OSReturnToMenu calls __OSReturnToMenu(MENU) then OSPanic with the original "Falied" string. BS2's strong OSReturnToMenu stays at 0x813808a0. 15/15 strings equal, 8/8 linked functions differing 0. DOL matches.
|
||||
31
tools/decomp-assist/grok-so.attempts.md
Normal file
31
tools/decomp-assist/grok-so.attempts.md
Normal file
@@ -0,0 +1,31 @@
|
||||
# grok-so SOGetSockName
|
||||
|
||||
baseline differing: 3 / 63
|
||||
only first memcpy arg order: ours mr r3,r28 / mr r4,r27 / lbz r5; target mr r4 / lbz r5 / mr r3
|
||||
|
||||
len local after reply: 3 / 63
|
||||
source local then len local: 3 / 63
|
||||
len local then source local: 3 / 63
|
||||
memcpy source is the void* parameter: 5 / 63 (also swaps the entry saves)
|
||||
source and length both from the void* parameter: 5 / 63
|
||||
reply assigned before socket store: 3 / 63
|
||||
memcpy dest &request->address, reply assigned after: 6 / 63
|
||||
memcpy dest &request->address, reply assigned before: 3 / 63
|
||||
reply assigned inside the dest argument: 3 / 63
|
||||
length ((u8*)addr)[0]: 3 / 63
|
||||
length *(u8*)addr: 3 / 63
|
||||
dest cast to void*: 3 / 63
|
||||
length cast to unsigned long: 3 / 63
|
||||
const source local: 3 / 63
|
||||
u8* dest local: 14 / 63
|
||||
reply = (SOSockAddr*)((u8*)request+32), memcpy from reply: 3 / 63
|
||||
reply and memcpy dest both (u8*)request+32: 0 / 63
|
||||
len local before reply: 3 / 63
|
||||
len local before socket store: 3 / 63, register shift
|
||||
socketBlock+32, sizeof, and [32]: 3 / 63
|
||||
u8* raw local plus 32: 3 / 63
|
||||
reply and memcpy dest both ((u8*)request)+32: 0 / 63, style check clean, all 22 functions 0
|
||||
|
||||
kept ((u8*)request)+32. Field address schedules the destination move first; the byte offset schedules it last.
|
||||
|
||||
Linking stripped SORead, SOFcntl and SOInetPtoN (nothing live calls them) and shifted the DOL by 660 code bytes. config/43U/config.yml force_active keeps them, same as SOGetSockOpt. DOL sha1 26116613f624061ba99c8d1a299aaa6efa85670d.
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user