Compare commits
112 Commits
agent/fix/
...
agent/fix/
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c19151d83e | ||
|
|
c3dd1c08c0 | ||
|
|
d5b07803ff | ||
|
|
2b4de43971 | ||
|
|
ab9cdd32e1 | ||
|
|
d83fa089e2 | ||
|
|
aed62d8530 | ||
|
|
85d653b0db | ||
|
|
bf4d1c8130 | ||
|
|
8a0c882d14 | ||
|
|
361763ad3e | ||
|
|
3c8503a947 | ||
|
|
5cc6dd1a4e | ||
|
|
f1db6b656e | ||
|
|
c8c8a71e22 | ||
|
|
f7f36d59f8 | ||
|
|
f1d824acd9 | ||
|
|
f393788bb9 | ||
|
|
da26714711 | ||
|
|
5d4b208246 | ||
|
|
0cffbfe4bf | ||
|
|
12e857a9e2 | ||
|
|
a8ac234de8 | ||
|
|
60febe20c3 | ||
|
|
b275eb2d99 | ||
|
|
e47a8e949d | ||
|
|
fa7f4c26e8 | ||
|
|
239334ba8d | ||
|
|
179cd4e3c3 | ||
|
|
09fc62528e | ||
|
|
dbbdc3dd98 | ||
|
|
4789b7c32f | ||
|
|
ad5b9deae3 | ||
|
|
5046adc6da | ||
|
|
87214ff944 | ||
|
|
54ca052b41 | ||
|
|
2ce8487681 | ||
|
|
47fe453260 | ||
|
|
2d4cfa7094 | ||
|
|
e27d9e090a | ||
|
|
983a6a2448 | ||
|
|
c1e1157d8b | ||
|
|
005d3734f0 | ||
|
|
55891734ae | ||
|
|
20cf9f9f25 | ||
|
|
2a7cc791b1 | ||
|
|
b2c43f5a66 | ||
|
|
d9b8013644 | ||
|
|
40b87edd73 | ||
|
|
3d7e767cf7 | ||
|
|
10146c1b5f | ||
|
|
82783c6edb | ||
|
|
72e9c8d658 | ||
|
|
0062d65a27 | ||
|
|
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 |
3
.github/workflows/build.yml
vendored
3
.github/workflows/build.yml
vendored
@@ -6,7 +6,7 @@ on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
require_complete:
|
||||
description: Fail unless 43U code, data, functions, units, and links are all 100%
|
||||
description: Fail unless 43U binary matches completely and source inventory is complete
|
||||
required: false
|
||||
default: false
|
||||
type: boolean
|
||||
@@ -79,6 +79,7 @@ jobs:
|
||||
python tools/check_decomp_complete.py \
|
||||
build/${{ matrix.version }}/report.json \
|
||||
--dol build/${{ matrix.version }}/main.dol
|
||||
python tools/check_asm_inventory.py
|
||||
|
||||
# Upload map files
|
||||
- name: Upload map
|
||||
|
||||
@@ -94,10 +94,11 @@ The final completion assertion is machine-checkable:
|
||||
```
|
||||
python3 tools/check_decomp_complete.py build/43U/report.json \
|
||||
--dol build/43U/main.dol
|
||||
python3 tools/check_asm_inventory.py
|
||||
```
|
||||
|
||||
It must pass before claiming full completion. GitHub Actions runs the same
|
||||
assertion when manually dispatched with `require_complete=true`.
|
||||
Both checks must pass before claiming full completion. GitHub Actions runs the same
|
||||
assertions when manually dispatched with `require_complete=true`.
|
||||
Normal push and pull-request builds publish progress without failing on the
|
||||
current incomplete state. Use the manual `require_complete=true` dispatch for
|
||||
the terminal all-100% gate.
|
||||
|
||||
@@ -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
|
||||
@@ -2524,7 +2524,7 @@ __ct__Q33ipl3snd10tagSSeInfoFv = .text:0x8136C63C; // type:function size:0x30
|
||||
__ct__Q34nw4r3snd11SoundHandleFv = .text:0x8136C66C; // type:function size:0xC
|
||||
__dt__Q34nw4r3snd11SoundHandleFv = .text:0x8136C678; // type:function size:0x54
|
||||
__dt__Q33ipl3snd10tagSSeInfoFv = .text:0x8136C6CC; // type:function size:0x58
|
||||
__dt__Q33ipl3snd6UnkClsFv = .text:0x8136C724; // type:function size:0x1C scope:local
|
||||
__arraydtor$15982 = .text:0x8136C724; // type:function size:0x1C scope:local
|
||||
__ct__Q33ipl3snd11tagSBgmInfoFv = .text:0x8136C740; // type:function size:0x30 scope:local
|
||||
__dt__Q33ipl3snd11tagSBgmInfoFv = .text:0x8136C770; // type:function size:0x58
|
||||
__ct__Q33ipl3snd6SystemFv = .text:0x8136C7C8; // type:function size:0x4C
|
||||
@@ -3223,7 +3223,7 @@ __dt__Q33ipl5scene5BoardFv = .text:0x81393CA4; // type:function size:0x68
|
||||
__ct__Q33ipl5scene11BoardObjectFv = .text:0x81393D1C; // type:function size:0x140
|
||||
__dt__Q33ipl4math28LinearIntp<Q33ipl4math4VEC2>Fv = .text:0x81393E5C; // type:function size:0x40
|
||||
__dt__Q33ipl4math31Interporation<Q33ipl4math4VEC2>Fv = .text:0x81393E9C; // type:function size:0x40
|
||||
init__Q43ipl5scene11BoardObject29@class$8157iplBoardObject_cppFv = .text:0x81393EDC; // type:function size:0x18
|
||||
init__Q43ipl5scene11BoardObject9StandDataFv = .text:0x81393EDC; // type:function size:0x18
|
||||
make_icon_cb___Q23ipl5sceneFPQ33ipl6nigaoe6ObjectPv = .text:0x81393EF4; // type:function size:0x80
|
||||
create__Q33ipl5scene11BoardObjectFPQ33ipl4nand10LayoutFilePUcUlRC6_CDBIdRC13_CDBRecordKeyRCQ33ipl7utility4Date = .text:0x81393F74; // type:function size:0x84
|
||||
init__Q33ipl5scene11BoardObjectFv = .text:0x81393FF8; // type:function size:0xA4
|
||||
@@ -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
|
||||
@@ -20925,31 +20933,28 @@ lbl_81694D18 = .sdata2:0x81694D18; // type:object size:0x4 data:4byte
|
||||
lbl_81694D1C = .sdata2:0x81694D1C; // type:object size:0x4 data:4byte
|
||||
lbl_81694D20 = .sdata2:0x81694D20; // type:object size:0x1 data:byte
|
||||
lbl_81694D24 = .sdata2:0x81694D24; // type:object size:0x1 data:byte
|
||||
scInputFormZeroF = .sdata2:0x81694D28; // type:object size:0x4 align:4 data:float
|
||||
scInputForm640F = .sdata2:0x81694D2C; // type:object size:0x4 align:4 data:float
|
||||
scInputFormF32ConvertMagic = .sdata2:0x81694D30; // type:object size:0x8 align:8 data:double
|
||||
scInputFormOneF = .sdata2:0x81694D38; // type:object size:0x4 align:4 data:float
|
||||
scInputFormHalfF = .sdata2:0x81694D3C; // type:object size:0x4 align:4 data:float
|
||||
scInputFormDegToFIdxF = .sdata2:0x81694D40; // type:object size:0x4 align:4 data:float
|
||||
scInputForm150F = .sdata2:0x81694D44; // type:object size:0x4 align:4 data:float
|
||||
scInputForm30F = .sdata2:0x81694D48; // type:object size:0x4 align:4 data:float
|
||||
scInputForm50F = .sdata2:0x81694D4C; // type:object size:0x4 align:4 data:float
|
||||
scInputForm10F = .sdata2:0x81694D50; // type:object size:0x4 align:4 data:float
|
||||
scInputForm52F = .sdata2:0x81694D54; // type:object size:0x4 align:4 data:float
|
||||
scInputFormTwoF = .sdata2:0x81694D58; // type:object size:0x4 align:4 data:float
|
||||
scInputForm140F = .sdata2:0x81694D5C; // type:object size:0x4 align:4 data:float
|
||||
scInputForm90F = .sdata2:0x81694D60; // type:object size:0x4 align:4 data:float
|
||||
scInputForm253F = .sdata2:0x81694D64; // type:object size:0x4 align:4 data:float
|
||||
scInputForm20F = .sdata2:0x81694D68; // type:object size:0x4 align:4 data:float
|
||||
scInputFormColorRU8 = .sdata2:0x81694D6C; // type:object size:0x1 data:byte
|
||||
scInputFormColorGU8 = .sdata2:0x81694D6D; // type:object size:0x1 data:byte
|
||||
scInputFormColorBU8 = .sdata2:0x81694D6E; // type:object size:0x1 data:byte
|
||||
scInputFormColorAU8 = .sdata2:0x81694D6F; // type:object size:0x1 data:byte
|
||||
scInputForm255F = .sdata2:0x81694D70; // type:object size:0x4 align:4 data:float
|
||||
scInputForm127F = .sdata2:0x81694D74; // type:object size:0x4 align:4 data:float
|
||||
scInputForm14592F = .sdata2:0x81694D78; // type:object size:0x4 align:4 data:float
|
||||
scInputFormF64ConvertMagic = .sdata2:0x81694D80; // type:object size:0x8 align:8 data:double
|
||||
scInputForm15F = .sdata2:0x81694D88; // type:object size:0x4 align:4 data:float
|
||||
@13326 = .sdata2:0x81694D28; // type:object size:0x4 scope:local align:4 data:float
|
||||
@13327 = .sdata2:0x81694D2C; // type:object size:0x4 scope:local align:4 data:float
|
||||
@13360 = .sdata2:0x81694D30; // type:object size:0x8 scope:local align:8 data:double
|
||||
@13767 = .sdata2:0x81694D38; // type:object size:0x4 scope:local align:4 data:float
|
||||
@13772 = .sdata2:0x81694D3C; // type:object size:0x4 scope:local align:4 data:float
|
||||
@13804 = .sdata2:0x81694D40; // type:object size:0x4 scope:local align:4 data:float
|
||||
@13805 = .sdata2:0x81694D44; // type:object size:0x4 scope:local align:4 data:float
|
||||
@13806 = .sdata2:0x81694D48; // type:object size:0x4 scope:local align:4 data:float
|
||||
@13807 = .sdata2:0x81694D4C; // type:object size:0x4 scope:local align:4 data:float
|
||||
@13808 = .sdata2:0x81694D50; // type:object size:0x4 scope:local align:4 data:float
|
||||
@13809 = .sdata2:0x81694D54; // type:object size:0x4 scope:local align:4 data:float
|
||||
@13810 = .sdata2:0x81694D58; // type:object size:0x4 scope:local align:4 data:float
|
||||
@13811 = .sdata2:0x81694D5C; // type:object size:0x4 scope:local align:4 data:float
|
||||
@13812 = .sdata2:0x81694D60; // type:object size:0x4 scope:local align:4 data:float
|
||||
@13813 = .sdata2:0x81694D64; // type:object size:0x4 scope:local align:4 data:float
|
||||
@13814 = .sdata2:0x81694D68; // type:object size:0x4 scope:local align:4 data:float
|
||||
@8131 = .sdata2:0x81694D6C; // type:object size:0x4 scope:local data:byte
|
||||
@14016 = .sdata2:0x81694D70; // type:object size:0x4 scope:local align:4 data:float
|
||||
@14017 = .sdata2:0x81694D74; // type:object size:0x4 scope:local align:4 data:float
|
||||
@14018 = .sdata2:0x81694D78; // type:object size:0x4 scope:local align:4 data:float
|
||||
@14021 = .sdata2:0x81694D80; // type:object size:0x8 scope:local align:8 data:double
|
||||
@14117 = .sdata2:0x81694D88; // type:object size:0x4 scope:local align:4 data:float
|
||||
lbl_81694D90 = .sdata2:0x81694D90; // type:object size:0x4 align:4 data:float
|
||||
lbl_81694D94 = .sdata2:0x81694D94; // type:object size:0x4 align:4 data:float
|
||||
lbl_81694D98 = .sdata2:0x81694D98; // type:object size:0x4 align:4 data:float
|
||||
@@ -22774,10 +22779,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 +23678,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 +23687,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
|
||||
|
||||
71
configure.py
71
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"),
|
||||
]
|
||||
@@ -824,7 +824,7 @@ config.libs = [
|
||||
]
|
||||
),
|
||||
IPLSection("cardSequence", [
|
||||
Object(NonMatching, "scene/cardSequence/iplCardSequence.cpp"),
|
||||
Object(Matching, "scene/cardSequence/iplCardSequence.cpp"),
|
||||
]
|
||||
),
|
||||
IPLSection("nakamuraTest", [
|
||||
@@ -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"),
|
||||
@@ -876,10 +876,11 @@ config.libs = [
|
||||
Object(Matching, "scene/setting/iplUSBAP.cpp"),
|
||||
Object(Matching, "scene/setting/iplUSBAPThread.cpp"),
|
||||
Object(Matching, "scene/setting/iplAOSSThread.cpp"),
|
||||
Object(NonMatching, "scene/setting/AOSSLink.c"),
|
||||
Object(Matching, "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/AOSS.c", extra_cflags=["-O4,p", "-inline on,noauto"]),
|
||||
Object(Matching, "scene/setting/AOSSData.c"),
|
||||
Object(Matching, "scene/setting/ATERM.c", mw_version="GC/3.0a5", extra_cflags=["-O4,p", "-inline on"]),
|
||||
]
|
||||
),
|
||||
IPLSection("settingSelect", [
|
||||
@@ -910,14 +911,14 @@ config.libs = [
|
||||
IPLSection("keyboard", [
|
||||
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/tiInputForm.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(Matching, "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"]),
|
||||
@@ -941,7 +942,7 @@ config.libs = [
|
||||
]
|
||||
),
|
||||
IPLSection("channelScript", [
|
||||
Object(NonMatching, "channelScript/CHANSVm.c"),
|
||||
Object(Matching, "channelScript/CHANSVm.c"),
|
||||
Object(Matching, "channelScript/systemmenu/VmSystem.c"),
|
||||
Object(Matching, "channelScript/systemmenu/iplCSSystem.cpp"),
|
||||
Object(Matching, "channelScript/systemmenu/iplCSLayout.cpp"),
|
||||
@@ -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"),
|
||||
]
|
||||
@@ -1201,7 +1202,7 @@ config.libs = [
|
||||
Object(Matching, "buffer/mkhdec3.c"),
|
||||
Object(Matching, "buffer/buffer_system.c"),
|
||||
Object(Matching, "buffer/getcode.c"),
|
||||
Object(NonMatching, "buffer/idct_block_var.c"),
|
||||
Object(Matching, "buffer/idct_block_var.c"),
|
||||
|
||||
Object(Matching, "api/decapi.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"),
|
||||
@@ -1690,7 +1691,7 @@ config.libs = [
|
||||
Object(Matching, "fa/pdm_api.c"),
|
||||
Object(Matching, "fa/pdm_bpb.c"),
|
||||
Object(Matching, "fa/pdm_disk.c"),
|
||||
Object(NonMatching, "fa/pdm_partition.c"),
|
||||
Object(Matching, "fa/pdm_partition.c"),
|
||||
Object(Matching, "fa/pf_cache.c"),
|
||||
Object(Matching, "fa/pf_cluster.c"),
|
||||
Object(Matching, "fa/pf_dir.c"),
|
||||
@@ -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"),
|
||||
|
||||
@@ -1868,7 +1869,7 @@ config.libs = [
|
||||
]
|
||||
),
|
||||
RVLSDKLib("nup", [
|
||||
Object(NonMatching, "nup/nup.cpp"),
|
||||
Object(Matching, "nup/nup.cpp"),
|
||||
Object(Matching, "nup/nup_nhttp.cpp"),
|
||||
Object(Matching, "nup/nup_mem.cpp"),
|
||||
]
|
||||
@@ -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)
|
||||
|
||||
@@ -178,8 +178,14 @@ namespace textinput {
|
||||
void inputCharZi_(wchar_t character, u32 modifiers);
|
||||
void inputCharDefault_(wchar_t character, u32 modifiers);
|
||||
void inputInputting_(wchar_t character);
|
||||
inline bool hasZiPredictions() const;
|
||||
inline bool usesZiPrediction() const;
|
||||
bool hasZiPredictions() const;
|
||||
bool usesZiPrediction() const;
|
||||
#ifdef TIINPUTFORM_IMPLEMENTATION
|
||||
void checkUnfixConverting_();
|
||||
void setAtokMode_(bool fixMode, bool kanaMode);
|
||||
void trimString_(u32 length);
|
||||
void startConverting_();
|
||||
#endif
|
||||
inline void resetPredictionContext();
|
||||
inline void resetInputRelation();
|
||||
#endif
|
||||
@@ -356,6 +362,7 @@ namespace textinput {
|
||||
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
|
||||
friend class EventHandler;
|
||||
inline const nw4r::lyt::Pane* getLanguageTextPane() const;
|
||||
inline nw4r::lyt::TextBox* getTextBox() const;
|
||||
#endif
|
||||
public:
|
||||
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
|
||||
|
||||
@@ -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; }
|
||||
|
||||
@@ -85,10 +85,30 @@ namespace textinput {
|
||||
#endif
|
||||
|
||||
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION) || defined(TISTRING_IMPLEMENTATION) || defined(TIZISTRING_IMPLEMENTATION)
|
||||
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TISTRING_IMPLEMENTATION)
|
||||
virtual ~Decolated() {}
|
||||
#else
|
||||
virtual ~Decolated();
|
||||
#endif
|
||||
enum TranslateMode { TM_Direct, TM_Kana, TM_Roman, TM_Hangul };
|
||||
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TISTRING_IMPLEMENTATION)
|
||||
virtual void clear() {
|
||||
StringBase::clear();
|
||||
mCursorStart = 0;
|
||||
mCursorEnd = 0;
|
||||
mbSustain = false;
|
||||
initKanaConverter();
|
||||
}
|
||||
virtual void set(const wchar_t* string) {
|
||||
StringBase::set(string);
|
||||
u32 length = getLength();
|
||||
mCursorStart = length;
|
||||
mCursorEnd = length;
|
||||
}
|
||||
#else
|
||||
virtual void clear();
|
||||
virtual void set(const wchar_t* string);
|
||||
#endif
|
||||
virtual void setLength(u16 length);
|
||||
void setTranslateMode(TranslateMode mode);
|
||||
TranslateMode getTranslateMode() const { return static_cast<TranslateMode>(mTranslateMode); }
|
||||
@@ -194,6 +214,9 @@ namespace textinput {
|
||||
public:
|
||||
WithAtok(u16 maxLength) : Decolated(maxLength) {}
|
||||
virtual ~WithAtok();
|
||||
virtual bool isFix();
|
||||
virtual void setFix(bool fix);
|
||||
virtual void initConverting();
|
||||
virtual void pushBack(wchar_t ch);
|
||||
virtual void popBack();
|
||||
virtual void inputChar(wchar_t ch);
|
||||
@@ -209,9 +232,6 @@ namespace textinput {
|
||||
u32 selectedStart;
|
||||
u32 selectedEnd;
|
||||
};
|
||||
virtual bool isFix();
|
||||
virtual void setFix(bool fix);
|
||||
virtual void initConverting();
|
||||
virtual bool isConverting();
|
||||
virtual wchar_t* getConfirmedWCString() const;
|
||||
virtual int getCurrentNumPredicted();
|
||||
|
||||
@@ -47,8 +47,13 @@ namespace textinput {
|
||||
public :
|
||||
virtual ~Base() {}
|
||||
|
||||
#ifdef TIINPUTFORM_IMPLEMENTATION
|
||||
virtual void create(MEMAllocator* allocator) {}
|
||||
virtual void init() {}
|
||||
#else
|
||||
virtual void create(MEMAllocator* allocator);
|
||||
virtual void init();
|
||||
#endif
|
||||
};
|
||||
|
||||
class CommandSender;
|
||||
@@ -59,8 +64,12 @@ namespace textinput {
|
||||
#endif
|
||||
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
|
||||
CommandReceiver() { clearSender(); }
|
||||
#ifdef TIINPUTFORM_IMPLEMENTATION
|
||||
virtual ~CommandReceiver() {}
|
||||
#else
|
||||
virtual ~CommandReceiver();
|
||||
#endif
|
||||
#endif
|
||||
#if defined(MYTIINPUTFORM_IMPLEMENTATION) || defined(MYTILETTERFORM_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
|
||||
struct Scroll {
|
||||
bool absY;
|
||||
|
||||
@@ -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*);
|
||||
|
||||
@@ -159,7 +159,7 @@ namespace ipl {
|
||||
RBRRecordType mRecordType; // 0xDC
|
||||
u32 mOptOutFlag; // 0xE0
|
||||
|
||||
class {
|
||||
class StandData {
|
||||
public:
|
||||
void init() {
|
||||
mAngleIdx = -1;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
|
||||
namespace ipl {
|
||||
namespace scene {
|
||||
extern "C" BOOL push_button_queue(void*, const void*);
|
||||
class ButtonEventHandlerBase;
|
||||
class OptOutButtonEventHandlerBase;
|
||||
class SDMenuEventHandlerBase;
|
||||
@@ -315,7 +314,6 @@ namespace ipl {
|
||||
}
|
||||
|
||||
protected:
|
||||
friend BOOL push_button_queue(void*, const void*);
|
||||
typedef struct Command {
|
||||
enum {
|
||||
TYPE_ANIM = 0,
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -10,31 +10,9 @@ namespace ipl {
|
||||
public:
|
||||
inline Queue<T, c>() : count(c), current(0), popped(0), pushed(0) {}
|
||||
|
||||
BOOL push(const T& item) {
|
||||
if (count == current) {
|
||||
return FALSE;
|
||||
}
|
||||
items[pushed] = item;
|
||||
if (++pushed >= count) {
|
||||
pushed = 0;
|
||||
}
|
||||
current++;
|
||||
return TRUE;
|
||||
}
|
||||
BOOL push(const T& item);
|
||||
|
||||
BOOL pop() {
|
||||
BOOL result = TRUE;
|
||||
if (current == 0) {
|
||||
result = FALSE;
|
||||
goto done;
|
||||
}
|
||||
if (++popped >= count) {
|
||||
popped = 0;
|
||||
}
|
||||
current--;
|
||||
done:
|
||||
return result;
|
||||
}
|
||||
BOOL pop();
|
||||
|
||||
int get_current_index() { return current; }
|
||||
T& get_current_item() { return items[get_current_index()]; }
|
||||
@@ -55,6 +33,34 @@ namespace ipl {
|
||||
int current; // (sizeof(items) * count) + 0x04
|
||||
int popped, pushed; // (sizeof(items) * count) + 0x08
|
||||
};
|
||||
|
||||
template <typename T, int c>
|
||||
BOOL Queue<T, c>::push(const T& item) {
|
||||
if (count == current) {
|
||||
return FALSE;
|
||||
}
|
||||
items[pushed] = item;
|
||||
if (++pushed >= count) {
|
||||
pushed = 0;
|
||||
}
|
||||
current++;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
template <typename T, int c>
|
||||
BOOL Queue<T, c>::pop() {
|
||||
BOOL result = TRUE;
|
||||
if (current == 0) {
|
||||
result = FALSE;
|
||||
goto done;
|
||||
}
|
||||
if (++popped >= count) {
|
||||
popped = 0;
|
||||
}
|
||||
current--;
|
||||
done:
|
||||
return result;
|
||||
}
|
||||
} // namespace utility
|
||||
} // namespace ipl
|
||||
|
||||
|
||||
@@ -22,7 +22,11 @@ int strcmp(const char* s1, const char* s2);
|
||||
char* strpbrk(const char* s1, const char* s2);
|
||||
size_t strspn(const char* s1, const char* s2);
|
||||
char* strtok(char* str, const char* delimiters);
|
||||
#ifdef __cplusplus
|
||||
const char* strstr(const char* str, const char* pat);
|
||||
#else
|
||||
char* strstr(const char* str, const char* pat);
|
||||
#endif
|
||||
|
||||
char* strncpy(char* dst, const char* src, size_t length);
|
||||
char* strncat(char* dst, const char* src, size_t length);
|
||||
@@ -39,4 +43,12 @@ int strcmpi(const char* s1, const char* s2);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C++" {
|
||||
inline char* strstr(char* str, const char* pat) {
|
||||
return const_cast<char*>(strstr(static_cast<const char*>(str), pat));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // MSL_STRING_H
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -36,8 +36,9 @@ namespace nw4r {
|
||||
return instance;
|
||||
}
|
||||
|
||||
// MWCC needs IRO 0 to recompute voice addresses inside the initialization loop.
|
||||
#pragma push
|
||||
#pragma ppc_iro_level 0 // uh
|
||||
#pragma ppc_iro_level 0
|
||||
void AxManager::Init() {
|
||||
if (mInitialized) {
|
||||
return;
|
||||
|
||||
@@ -84,157 +84,139 @@ s32 TMCJPEGDEC_get_byte(u8* dst, TMCCJPEGDecWork* work) {
|
||||
}
|
||||
|
||||
s32 TMCJPEGDEC_get_wbyte(u16* dst, TMCCJPEGDecWork* work) {
|
||||
u8 byte_val;
|
||||
u32 byte_shifted;
|
||||
s32 r;
|
||||
u8 byte;
|
||||
u32 highByte;
|
||||
s32 result;
|
||||
|
||||
u8* cur;
|
||||
u8* end;
|
||||
u8* next;
|
||||
|
||||
if (work->pBufCur >= work->pBufEnd) {
|
||||
if (work->remaining != 0) {
|
||||
r = refillJpegBuffer(work);
|
||||
if (r < 0) {
|
||||
goto br;
|
||||
// MWCC needs the empty else branches to preserve refill branch direction.
|
||||
do {
|
||||
if (work->pBufCur >= work->pBufEnd) {
|
||||
if (work->remaining != 0) {
|
||||
result = refillJpegBuffer(work);
|
||||
if (result < 0) {
|
||||
break;
|
||||
} else {
|
||||
}
|
||||
} else {
|
||||
// This else-branch is load-bearing...
|
||||
// Forces bge instead of blt.
|
||||
result = TMCC_ERROR_UNDERFLOW;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
r = TMCC_ERROR_UNDERFLOW;
|
||||
goto br;
|
||||
}
|
||||
|
||||
{
|
||||
u8* bufferCursor = work->pBufCur;
|
||||
end = work->pBufEnd;
|
||||
cur = bufferCursor;
|
||||
next = bufferCursor + 1;
|
||||
}
|
||||
|
||||
work->pBufCur = next;
|
||||
byte = *cur;
|
||||
if (next >= end) {
|
||||
if (work->remaining != 0) {
|
||||
result = refillJpegBuffer(work);
|
||||
if (result < 0) {
|
||||
break;
|
||||
} else {
|
||||
}
|
||||
} else {
|
||||
result = TMCC_ERROR_UNDERFLOW;
|
||||
break;
|
||||
}
|
||||
}
|
||||
result = 0;
|
||||
} while (0);
|
||||
highByte = (u32)byte << 8;
|
||||
if (result < 0) {
|
||||
return result;
|
||||
}
|
||||
|
||||
{
|
||||
u8* tmp = work->pBufCur;
|
||||
do {
|
||||
if (work->pBufCur >= work->pBufEnd) {
|
||||
if (work->remaining != 0) {
|
||||
result = refillJpegBuffer(work);
|
||||
if (result < 0) {
|
||||
break;
|
||||
} else {
|
||||
}
|
||||
} else {
|
||||
result = TMCC_ERROR_UNDERFLOW;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
cur = work->pBufCur;
|
||||
end = work->pBufEnd;
|
||||
cur = tmp;
|
||||
next = tmp + 1;
|
||||
}
|
||||
|
||||
work->pBufCur = next;
|
||||
byte_val = *cur;
|
||||
if (next < end) {
|
||||
goto o1;
|
||||
}
|
||||
|
||||
if (work->remaining != 0) {
|
||||
r = refillJpegBuffer(work);
|
||||
if (r >= 0) {
|
||||
goto o1;
|
||||
next = cur + 1;
|
||||
work->pBufCur = next;
|
||||
byte = *cur;
|
||||
if (next >= end) {
|
||||
if (work->remaining != 0) {
|
||||
result = refillJpegBuffer(work);
|
||||
if (result < 0) {
|
||||
break;
|
||||
} else {
|
||||
}
|
||||
} else {
|
||||
result = TMCC_ERROR_UNDERFLOW;
|
||||
break;
|
||||
}
|
||||
}
|
||||
goto br;
|
||||
} else {
|
||||
r = TMCC_ERROR_UNDERFLOW;
|
||||
goto br;
|
||||
}
|
||||
|
||||
o1:
|
||||
r = 0;
|
||||
|
||||
br:
|
||||
byte_shifted = (u32)byte_val << 8;
|
||||
if (r >= 0) {
|
||||
goto p2;
|
||||
}
|
||||
return r;
|
||||
|
||||
p2:
|
||||
if (work->pBufCur < work->pBufEnd) {
|
||||
goto r2;
|
||||
}
|
||||
if (work->remaining != 0) {
|
||||
r = refillJpegBuffer(work);
|
||||
if (r < 0)
|
||||
goto ez;
|
||||
else {
|
||||
// ...
|
||||
}
|
||||
} else {
|
||||
r = TMCC_ERROR_UNDERFLOW;
|
||||
goto ez;
|
||||
}
|
||||
|
||||
r2:
|
||||
cur = work->pBufCur;
|
||||
end = work->pBufEnd;
|
||||
next = cur + 1;
|
||||
work->pBufCur = next;
|
||||
byte_val = *cur;
|
||||
if (next < end) {
|
||||
goto o2;
|
||||
}
|
||||
|
||||
if (work->remaining != 0) {
|
||||
r = refillJpegBuffer(work);
|
||||
if (r < 0)
|
||||
goto ez;
|
||||
else {
|
||||
// ...
|
||||
}
|
||||
} else {
|
||||
r = TMCC_ERROR_UNDERFLOW;
|
||||
goto ez;
|
||||
}
|
||||
|
||||
o2:
|
||||
r = 0;
|
||||
ez:
|
||||
*dst = byte_shifted + byte_val;
|
||||
return r < 0 ? r : 0;
|
||||
result = 0;
|
||||
} while (0);
|
||||
*dst = highByte + byte;
|
||||
return result < 0 ? result : 0;
|
||||
}
|
||||
|
||||
s32 TMCJPEGDEC_get_sbyte(u8* dst, u32 count, TMCCJPEGDecWork* work) {
|
||||
int r = 0;
|
||||
int result = 0;
|
||||
u32 i;
|
||||
u8 byte;
|
||||
u8* cur;
|
||||
|
||||
for (i = 0; i < count; i++) {
|
||||
if (work->pBufCur >= work->pBufEnd) {
|
||||
if (work->remaining != 0) {
|
||||
r = refillJpegBuffer(work);
|
||||
if (r < 0) {
|
||||
goto copy_byte;
|
||||
// MWCC needs the empty else branches to preserve refill branch direction.
|
||||
do {
|
||||
if (work->pBufCur >= work->pBufEnd) {
|
||||
if (work->remaining != 0) {
|
||||
result = refillJpegBuffer(work);
|
||||
if (result < 0) {
|
||||
break;
|
||||
} else {
|
||||
}
|
||||
} else {
|
||||
// This else-branch is load-bearing...
|
||||
// Forces bge instead of blt.
|
||||
result = TMCC_ERROR_UNDERFLOW;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
r = TMCC_ERROR_UNDERFLOW;
|
||||
goto copy_byte;
|
||||
}
|
||||
}
|
||||
|
||||
cur = work->pBufCur;
|
||||
work->pBufCur += 1;
|
||||
byte = *cur;
|
||||
cur = work->pBufCur;
|
||||
work->pBufCur += 1;
|
||||
byte = *cur;
|
||||
|
||||
if (work->pBufCur < work->pBufEnd) {
|
||||
goto r0;
|
||||
}
|
||||
if (work->remaining != 0) {
|
||||
r = refillJpegBuffer(work);
|
||||
if (r >= 0) {
|
||||
goto r0;
|
||||
if (work->pBufCur >= work->pBufEnd) {
|
||||
if (work->remaining != 0) {
|
||||
result = refillJpegBuffer(work);
|
||||
if (result < 0) {
|
||||
break;
|
||||
} else {
|
||||
}
|
||||
} else {
|
||||
result = TMCC_ERROR_UNDERFLOW;
|
||||
break;
|
||||
}
|
||||
}
|
||||
goto copy_byte;
|
||||
} else {
|
||||
r = TMCC_ERROR_UNDERFLOW;
|
||||
goto copy_byte;
|
||||
}
|
||||
|
||||
r0:
|
||||
r = 0;
|
||||
|
||||
copy_byte:
|
||||
result = 0;
|
||||
} while (0);
|
||||
*dst = byte;
|
||||
dst++;
|
||||
|
||||
if (r < 0)
|
||||
return r;
|
||||
if (result < 0)
|
||||
return result;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -243,51 +225,41 @@ s32 TMCJPEGDEC_move_ptr(s32 offset, TMCCJPEGDecWork* work) {
|
||||
s32 avail;
|
||||
s32 r;
|
||||
|
||||
if (offset < 0) {
|
||||
goto ng;
|
||||
if (offset >= 0) {
|
||||
while (work->pBufEnd - work->pBufCur <= offset) {
|
||||
avail = work->pBufEnd - work->pBufCur;
|
||||
offset -= avail;
|
||||
if (work->remaining != 0) {
|
||||
r = refillJpegBuffer(work);
|
||||
if (r >= 0) {
|
||||
continue;
|
||||
}
|
||||
return r;
|
||||
} else {
|
||||
return TMCC_ERROR_UNDERFLOW;
|
||||
}
|
||||
}
|
||||
work->pBufCur += offset;
|
||||
if (work->pBufEnd > work->pBufCur) {
|
||||
goto done;
|
||||
}
|
||||
if (work->remaining != 0) {
|
||||
r = refillJpegBuffer(work);
|
||||
if (r >= 0) {
|
||||
goto done;
|
||||
}
|
||||
return r;
|
||||
} else {
|
||||
return TMCC_ERROR_UNDERFLOW;
|
||||
}
|
||||
} else {
|
||||
offset = -offset;
|
||||
if (work->pBufCur - work->pBufStart < offset) {
|
||||
return TMCC_ERROR_UNDERFLOW;
|
||||
}
|
||||
work->pBufCur -= offset;
|
||||
}
|
||||
goto lc;
|
||||
|
||||
lp:
|
||||
offset -= avail;
|
||||
if (work->remaining == 0) {
|
||||
goto er1;
|
||||
}
|
||||
r = refillJpegBuffer(work);
|
||||
if (r >= 0) {
|
||||
goto lc;
|
||||
}
|
||||
return r;
|
||||
er1:
|
||||
return TMCC_ERROR_UNDERFLOW;
|
||||
|
||||
lc:
|
||||
avail = work->pBufEnd - work->pBufCur;
|
||||
if (avail <= offset) {
|
||||
goto lp;
|
||||
}
|
||||
work->pBufCur += offset;
|
||||
if (work->pBufEnd > work->pBufCur) {
|
||||
goto ret0;
|
||||
}
|
||||
if (work->remaining == 0) {
|
||||
goto er2;
|
||||
}
|
||||
r = refillJpegBuffer(work);
|
||||
if (r >= 0) {
|
||||
goto ret0;
|
||||
}
|
||||
return r;
|
||||
er2:
|
||||
return TMCC_ERROR_UNDERFLOW;
|
||||
|
||||
ng:
|
||||
offset = -offset;
|
||||
if (work->pBufCur - work->pBufStart < offset) {
|
||||
return TMCC_ERROR_UNDERFLOW;
|
||||
}
|
||||
work->pBufCur -= offset;
|
||||
ret0:
|
||||
done:
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -314,47 +286,45 @@ s32 TMCJPEGDEC_load_buff(TMCCJPEGDecWork* work) {
|
||||
work->bitBuf = bitBuf;
|
||||
work->bitCount = bitCount;
|
||||
work->pBufCur = cur;
|
||||
goto ret;
|
||||
} else {
|
||||
do {
|
||||
if (work->pBufEnd <= work->pBufCur) {
|
||||
if (work->remaining == 0) {
|
||||
break;
|
||||
}
|
||||
r = refillJpegBufferAfterFF(work);
|
||||
if (r < 0) {
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
u32 bb = work->bitBuf;
|
||||
u8* c = work->pBufCur;
|
||||
u8* next;
|
||||
u8 byte = *c;
|
||||
|
||||
next = c + 1;
|
||||
work->pBufCur = next;
|
||||
work->bitBuf = (bb << 8) + byte;
|
||||
work->bitCount += 8;
|
||||
if (byte == 0xFF) {
|
||||
work->pBufCur = next + 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (work->pBufEnd <= work->pBufCur) {
|
||||
if (work->remaining == 0) {
|
||||
break;
|
||||
}
|
||||
r = refillJpegBufferAfterFF(work);
|
||||
if (r < 0) {
|
||||
return r;
|
||||
}
|
||||
}
|
||||
} while (work->bitCount <= 24);
|
||||
}
|
||||
|
||||
do {
|
||||
if (work->pBufEnd <= work->pBufCur) {
|
||||
if (work->remaining == 0) {
|
||||
break;
|
||||
}
|
||||
r = refillJpegBufferAfterFF(work);
|
||||
if (r < 0) {
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
u32 bb = work->bitBuf;
|
||||
u8* c = work->pBufCur;
|
||||
u8* next;
|
||||
u8 byte = *c;
|
||||
|
||||
next = c + 1;
|
||||
work->pBufCur = next;
|
||||
work->bitBuf = (bb << 8) + byte;
|
||||
work->bitCount += 8;
|
||||
if (byte == 0xFF) {
|
||||
work->pBufCur = next + 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (work->pBufEnd <= work->pBufCur) {
|
||||
if (work->remaining == 0) {
|
||||
break;
|
||||
}
|
||||
r = refillJpegBufferAfterFF(work);
|
||||
if (r < 0) {
|
||||
return r;
|
||||
}
|
||||
}
|
||||
} while (work->bitCount <= 24);
|
||||
|
||||
ret:
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,444 +31,507 @@ static s32 scalingClampU8(s32 value) {
|
||||
return value < 0 ? 0 : 255;
|
||||
}
|
||||
|
||||
static s32 clampLumaDc(s32 coefficient) {
|
||||
return clampU8((coefficient >> 11) + 0x80);
|
||||
}
|
||||
|
||||
void TMCJPEGDEC_IdctBlock_Lumi(s32* block, u8* conv_row_ptr, u16 pitch, s32 zigzag) {
|
||||
s32 workspace[64];
|
||||
s32* workspaceCursor;
|
||||
s32 evenBaseSum;
|
||||
s32 evenRotation;
|
||||
s32 pitch2;
|
||||
s32* dst;
|
||||
s32 rowOddOutput1;
|
||||
int columnAcBits;
|
||||
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;
|
||||
s32 rowEvenOutput0;
|
||||
s32 columnC6;
|
||||
s32 columnC4;
|
||||
s32 columnOddSumRotation;
|
||||
s32 rowDc;
|
||||
s32 rowEvenOutput1;
|
||||
s32 columnC1;
|
||||
s32 columnEvenBaseDifference;
|
||||
s32 columnEvenOutput0;
|
||||
s32 columnC2;
|
||||
s32 columnScaledEvenRotation;
|
||||
s32 columnEvenOutput1;
|
||||
s32 columnC5;
|
||||
s32 rowC4;
|
||||
s32 rowOddSumRotation;
|
||||
s32 columnEvenOutput3;
|
||||
s32 columnOddLowSum;
|
||||
s32 columnOddLowDifference;
|
||||
s32 columnOddHighSum;
|
||||
s32 columnC7;
|
||||
s32 columnC3;
|
||||
s32 columnEvenBaseSum;
|
||||
s32 rowEvenBaseDifference;
|
||||
s32 rowEvenOutput2;
|
||||
s32 rowOddOutput0;
|
||||
s32 rowC1;
|
||||
s32 columnOddHighDifference;
|
||||
s32 columnDc;
|
||||
s32 columnOddDifferenceRotation;
|
||||
s32 columnOddOutput1;
|
||||
s32 rowScaledEvenRotation;
|
||||
s32 columnEvenOutput2;
|
||||
s32 columnOddMix;
|
||||
int rowAcBits;
|
||||
s32 columnEvenRotationSum;
|
||||
s32 rowEvenBaseSum;
|
||||
s32 rowC2;
|
||||
s32 rowEvenRotationSum;
|
||||
s32 rowEvenOutput3;
|
||||
s32 rowOddLowDifference;
|
||||
s32 columnOddOutput0;
|
||||
u8* columnOutput;
|
||||
s32 pitch4;
|
||||
s32* src;
|
||||
s32 rowC3;
|
||||
s32 rowOddHighDifference;
|
||||
s32 rowOddHighSum;
|
||||
s32 rowOddOutput3;
|
||||
s32 pitch7;
|
||||
s32 pitch6;
|
||||
s32 rowC6;
|
||||
s32 columnOddOutput2;
|
||||
u8 columnSample;
|
||||
s32 processed;
|
||||
s32 rowOddLowSum;
|
||||
s32 rowOddDifferenceRotation;
|
||||
s32 columnOddOutput3;
|
||||
s32 rowC5;
|
||||
s32 rowOddMix;
|
||||
s32 rowSampleDc;
|
||||
s32 rowOddOutput2;
|
||||
s32 rowC7;
|
||||
s32 rowCount;
|
||||
s32 pitch5;
|
||||
s32 pitch3;
|
||||
s32 workspace[64];
|
||||
s32 rowEvenSum;
|
||||
s32 rowOddLowRotation;
|
||||
s32 rowEvenRotation;
|
||||
s32 rowOddDifferenceSum;
|
||||
s32 rowOddHighRotation;
|
||||
s32 rowOddSumDifference;
|
||||
s32 columnOddDifferenceSum;
|
||||
s32 columnOddHighRotation;
|
||||
s32 columnOddLowRotation;
|
||||
s32 columnEvenRotation;
|
||||
s32 columnOddSumDifference;
|
||||
int columnEvenSum;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
workspaceCursor = workspace + processedCoefficients;
|
||||
for (; processedCoefficients <= 0x38; processedCoefficients += 8) {
|
||||
memset(workspaceCursor, 0, 0x20);
|
||||
workspaceCursor += 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;
|
||||
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;
|
||||
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;
|
||||
output[pitch] = sample;
|
||||
output[0] = sample;
|
||||
rowCount = (zigzag >> 4) * 8;
|
||||
dst = workspace;
|
||||
for (processed = 0; processed < rowCount; processed += 8) {
|
||||
rowC4 = block[4];
|
||||
rowC6 = block[6];
|
||||
rowC2 = block[2];
|
||||
rowC1 = block[1];
|
||||
rowC7 = block[7];
|
||||
rowC5 = block[5];
|
||||
rowC3 = block[3];
|
||||
rowAcBits = rowC4 | rowC6;
|
||||
rowAcBits = rowC2 | rowAcBits;
|
||||
rowAcBits = rowC1 | rowAcBits;
|
||||
rowAcBits = rowC7 | rowAcBits;
|
||||
rowAcBits = rowC5 | rowAcBits;
|
||||
rowAcBits = rowC3 | rowAcBits;
|
||||
if (rowAcBits == 0) {
|
||||
rowSampleDc = block[0];
|
||||
dst[7] = rowSampleDc;
|
||||
dst[6] = rowSampleDc;
|
||||
dst[5] = rowSampleDc;
|
||||
dst[4] = rowSampleDc;
|
||||
dst[3] = rowSampleDc;
|
||||
dst[2] = rowSampleDc;
|
||||
dst[1] = rowSampleDc;
|
||||
dst[0] = rowSampleDc;
|
||||
} else {
|
||||
s32 oddLowSum;
|
||||
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;
|
||||
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;
|
||||
evenOutput0 = evenBaseSum + evenRotationSum;
|
||||
evenOutput3 = evenBaseSum - evenRotationSum;
|
||||
oddHighRotation = coefficient1 * 0x14E >> 8;
|
||||
evenOutput2 = evenBaseDifference - coefficient2;
|
||||
oddHighRotation = oddHighRotation - oddDifferenceSum;
|
||||
oddLowSum += oddHighRotation;
|
||||
oddOutput0 = oddHighSum + oddLowSum;
|
||||
oddOutput1 = oddSumRotation + oddHighRotation;
|
||||
oddLowRotation = coefficient5 * 0x8B >> 8;
|
||||
oddOutput3 = oddDifferenceSum + oddLowRotation;
|
||||
oddOutput2 = oddOutput3 + oddSumRotation;
|
||||
output[0] = scalingClampU8(evenOutput0 + oddOutput0);
|
||||
output[r] = 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);
|
||||
rowDc = block[0];
|
||||
rowEvenRotation = rowC2 - rowC6;
|
||||
rowEvenSum = rowC2 + rowC6;
|
||||
rowEvenBaseSum = rowDc + rowC4;
|
||||
rowEvenBaseDifference = rowDc - rowC4;
|
||||
rowScaledEvenRotation = rowEvenRotation * 0xB5 >> 8;
|
||||
rowEvenRotationSum = rowScaledEvenRotation + rowEvenSum;
|
||||
rowEvenOutput0 = rowEvenBaseSum + rowEvenRotationSum;
|
||||
rowEvenOutput1 = rowEvenBaseDifference + rowScaledEvenRotation;
|
||||
rowEvenOutput2 = rowEvenBaseDifference - rowScaledEvenRotation;
|
||||
rowEvenOutput3 = rowEvenBaseSum - rowEvenRotationSum;
|
||||
rowOddHighSum = rowC1 + rowC7;
|
||||
rowOddHighDifference = rowC1 - rowC7;
|
||||
rowOddLowSum = rowC5 + rowC3;
|
||||
rowOddLowDifference = rowC5 - rowC3;
|
||||
rowOddSumDifference = rowOddHighSum - rowOddLowSum;
|
||||
rowOddDifferenceSum = rowOddLowDifference + rowOddHighDifference;
|
||||
rowOddSumRotation = rowOddSumDifference * 0xB5 >> 8;
|
||||
rowOddDifferenceRotation = rowOddDifferenceSum * 0x62 >> 8;
|
||||
rowOddHighRotation = rowOddHighDifference * 0x14E >> 8;
|
||||
rowOddLowRotation = rowOddLowDifference * 0x8B >> 8;
|
||||
rowOddMix = rowOddHighRotation - rowOddDifferenceRotation;
|
||||
rowOddLowSum += rowOddMix;
|
||||
rowOddOutput0 = rowOddHighSum + rowOddLowSum;
|
||||
rowOddOutput1 = rowOddSumRotation + rowOddMix;
|
||||
rowOddOutput3 = rowOddDifferenceRotation + rowOddLowRotation;
|
||||
rowOddOutput2 = rowOddOutput3 + rowOddSumRotation;
|
||||
dst[0] = rowEvenOutput0 + rowOddOutput0;
|
||||
dst[7] = rowEvenOutput0 - rowOddOutput0;
|
||||
dst[1] = rowEvenOutput1 + rowOddOutput1;
|
||||
dst[6] = rowEvenOutput1 - rowOddOutput1;
|
||||
dst[2] = rowEvenOutput2 + rowOddOutput2;
|
||||
dst[5] = rowEvenOutput2 - rowOddOutput2;
|
||||
dst[3] = rowEvenOutput3 + rowOddOutput3;
|
||||
dst[4] = rowEvenOutput3 - rowOddOutput3;
|
||||
}
|
||||
workspaceCursor--;
|
||||
block += 8;
|
||||
dst += 8;
|
||||
}
|
||||
|
||||
dst = workspace + processed;
|
||||
for (; processed <= 56; processed += 8) {
|
||||
memset(dst, 0, 32);
|
||||
dst += 8;
|
||||
}
|
||||
|
||||
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--) {
|
||||
columnC4 = src[32];
|
||||
columnC6 = src[48];
|
||||
columnC2 = src[16];
|
||||
columnC1 = src[8];
|
||||
columnC7 = src[56];
|
||||
columnC5 = src[40];
|
||||
columnC3 = src[24];
|
||||
columnAcBits = columnC4 | columnC6;
|
||||
columnAcBits = columnC2 | columnAcBits;
|
||||
columnAcBits = columnC1 | columnAcBits;
|
||||
columnAcBits = columnC7 | columnAcBits;
|
||||
columnAcBits = columnC5 | columnAcBits;
|
||||
columnAcBits = columnC3 | columnAcBits;
|
||||
columnOutput = conv_row_ptr + column;
|
||||
if (columnAcBits == 0) {
|
||||
columnSample = clampLumaDc(*src);
|
||||
columnOutput[pitch7] = columnSample;
|
||||
columnOutput[pitch6] = columnSample;
|
||||
columnOutput[pitch5] = columnSample;
|
||||
columnOutput[pitch4] = columnSample;
|
||||
columnOutput[pitch3] = columnSample;
|
||||
columnOutput[pitch2] = columnSample;
|
||||
columnOutput[pitch] = columnSample;
|
||||
columnOutput[0] = columnSample;
|
||||
} else {
|
||||
columnEvenSum = columnC6 + columnC2;
|
||||
columnEvenRotation = columnC2 - columnC6;
|
||||
columnOddLowSum = columnC5 + columnC3;
|
||||
columnOddHighDifference = columnC1 - columnC7;
|
||||
columnOddLowDifference = columnC5 - columnC3;
|
||||
columnOddHighSum = columnC1 + columnC7;
|
||||
columnScaledEvenRotation = columnEvenRotation * 0xB5 >> 8;
|
||||
columnDc = *src + 0x40000;
|
||||
columnOddDifferenceSum = columnOddLowDifference + columnOddHighDifference;
|
||||
columnOddSumDifference = columnOddHighSum - columnOddLowSum;
|
||||
columnOddSumRotation = columnOddSumDifference * 0xB5 >> 8;
|
||||
columnEvenBaseSum = columnDc + columnC4;
|
||||
columnOddDifferenceRotation = columnOddDifferenceSum * 0x62 >> 8;
|
||||
columnOddHighRotation = columnOddHighDifference * 0x14E >> 8;
|
||||
columnEvenRotationSum = columnScaledEvenRotation + columnEvenSum;
|
||||
columnOddMix = columnOddHighRotation - columnOddDifferenceRotation;
|
||||
columnOddLowSum += columnOddMix;
|
||||
columnEvenOutput0 = columnEvenBaseSum + columnEvenRotationSum;
|
||||
columnEvenBaseDifference = columnDc - columnC4;
|
||||
columnEvenOutput3 = columnEvenBaseSum - columnEvenRotationSum;
|
||||
columnEvenOutput1 = columnEvenBaseDifference + columnScaledEvenRotation;
|
||||
columnOddOutput0 = columnOddHighSum + columnOddLowSum;
|
||||
columnOddLowRotation = columnOddLowDifference * 0x8B >> 8;
|
||||
columnOddOutput3 = columnOddDifferenceRotation + columnOddLowRotation;
|
||||
columnEvenOutput2 = columnEvenBaseDifference - columnScaledEvenRotation;
|
||||
columnOddOutput2 = columnOddOutput3 + columnOddSumRotation;
|
||||
columnOddOutput1 = columnOddSumRotation + columnOddMix;
|
||||
columnOutput[0] = scalingClampU8(columnEvenOutput0 + columnOddOutput0);
|
||||
columnOutput[pitch7] = scalingClampU8(columnEvenOutput0 - columnOddOutput0);
|
||||
columnOutput[pitch] = scalingClampU8(columnEvenOutput1 + columnOddOutput1);
|
||||
columnOutput[pitch6] = scalingClampU8(columnEvenOutput1 - columnOddOutput1);
|
||||
columnOutput[pitch2] = scalingClampU8(columnEvenOutput2 + columnOddOutput2);
|
||||
columnOutput[pitch5] = scalingClampU8(columnEvenOutput2 - columnOddOutput2);
|
||||
columnOutput[pitch3] = scalingClampU8(columnEvenOutput3 + columnOddOutput3);
|
||||
columnOutput[pitch4] = scalingClampU8(columnEvenOutput3 - columnOddOutput3);
|
||||
}
|
||||
src--;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static s32 clampChromaDc(s32 value) {
|
||||
return clampS8(value >> 11);
|
||||
}
|
||||
|
||||
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 rowCount;
|
||||
s32 columnOddSumRotation;
|
||||
s32 rowOddOutput1;
|
||||
s32 columnC1;
|
||||
int rowAcBits;
|
||||
s32 columnEvenBaseDifference;
|
||||
s32 columnC7;
|
||||
s32 rowDc;
|
||||
s32 rowOddSumRotation;
|
||||
s32 rowEvenBaseSum;
|
||||
s32 columnOddDifferenceRotation;
|
||||
s32 columnEvenRotationSum;
|
||||
s32* dst;
|
||||
s32 columnOddOutput2;
|
||||
s32 sparseDc;
|
||||
s32 rowOddDifferenceRotation;
|
||||
s32 columnOddOutput1;
|
||||
s32 rowOddOutput2;
|
||||
s32 columnDc;
|
||||
s32 columnEvenBaseSum;
|
||||
s32* src;
|
||||
s32 rowOuter;
|
||||
s32 processed;
|
||||
s32 columnC6;
|
||||
s32 rowOdd;
|
||||
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 columnOddOutput3;
|
||||
s32 rowSampleDc;
|
||||
s32 rowOddOutput0;
|
||||
s32 rowC3;
|
||||
s32 columnScaledEvenRotation;
|
||||
s32 rowRotation;
|
||||
s32 rowEvenOutput2;
|
||||
s32 rowC2;
|
||||
s32 rowEvenBaseDifference;
|
||||
s32 columnC5;
|
||||
s32 rowEvenRotationSum;
|
||||
s32 columnOddOutput0;
|
||||
s32 rowC1;
|
||||
int columnAcBits;
|
||||
s32 columnC4;
|
||||
s32 columnOddMix;
|
||||
s32 columnOddLowSum;
|
||||
s32 rowEvenOutput1;
|
||||
s32 rowLowRotation;
|
||||
s32 columnC3;
|
||||
s32 rowOddHighDifference;
|
||||
s32 rowC5;
|
||||
s32 columnEvenOutput0;
|
||||
s32 rowEvenOutput0;
|
||||
s32 rowOddMix;
|
||||
s32 rowEvenOutput3;
|
||||
s32 rowC4;
|
||||
s32 rowInner;
|
||||
s32 rowC6;
|
||||
s32 columnEvenOutput1;
|
||||
s32 rowScaledEvenRotation;
|
||||
s32 rowOddLowDifference;
|
||||
s32 rowC7;
|
||||
s32 rowOddOutput3;
|
||||
s32 columnEvenOutput3;
|
||||
s32 rowMid;
|
||||
s32 columnOddHighDifference;
|
||||
s32 columnEvenOutput2;
|
||||
s32 columnC2;
|
||||
s32 columnOddLowDifference;
|
||||
s32 columnOddHighSum;
|
||||
s32 rowOddHighSum;
|
||||
s32 rowOddLowSum;
|
||||
u8* columnOutput;
|
||||
s32 columnOddLowRotation;
|
||||
s32 rowEvenSum;
|
||||
s32 flatDc;
|
||||
s32 columnEvenRotation;
|
||||
s32 rowOddDifferenceSum;
|
||||
s32 rowOddSumDifference;
|
||||
s32 columnSample;
|
||||
s32 columnOddDifferenceSum;
|
||||
int columnEvenSum;
|
||||
s32 rowOddHighRotation;
|
||||
s32 workspace[64];
|
||||
s32 rowOddLowRotation;
|
||||
s32 rowSample;
|
||||
s32 rowEvenRotation;
|
||||
s32 columnOddHighRotation;
|
||||
s32 columnOddSumDifference;
|
||||
s32 rowMix;
|
||||
|
||||
if (zigzag == 0x11) {
|
||||
s32 sample;
|
||||
sample = clampS8(block[0] >> 11);
|
||||
memset(conv_row_ptr, (s8)sample, 0x40);
|
||||
flatDc = block[0];
|
||||
rowSample = clampS8(flatDc >> 11);
|
||||
memset(conv_row_ptr, (s8)rowSample, 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;
|
||||
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;
|
||||
rowCount = (zigzag >> 4) * 8;
|
||||
if ((zigzag & 0xF) <= 2) {
|
||||
dst = workspace;
|
||||
for (processed = 0; processed < rowCount; processed += 8) {
|
||||
rowOdd = block[1];
|
||||
rowRotation = rowOdd * 0xB5 >> 8;
|
||||
rowLowRotation = rowOdd * 0x62 >> 8;
|
||||
sparseDc = block[0];
|
||||
rowMix = (rowOdd * 0x14E >> 8) - rowLowRotation;
|
||||
rowOuter = rowOdd + rowMix;
|
||||
dst[0] = sparseDc + rowOuter;
|
||||
rowInner = rowRotation + rowMix;
|
||||
dst[7] = sparseDc - rowOuter;
|
||||
dst[1] = sparseDc + rowInner;
|
||||
rowMid = rowLowRotation + rowRotation;
|
||||
dst[6] = sparseDc - rowInner;
|
||||
dst[2] = sparseDc + rowMid;
|
||||
dst[5] = sparseDc - rowMid;
|
||||
dst[3] = sparseDc + rowLowRotation;
|
||||
dst[4] = sparseDc - rowLowRotation;
|
||||
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) {
|
||||
rowC4 = block[4];
|
||||
rowC6 = block[6];
|
||||
rowC2 = block[2];
|
||||
rowC1 = block[1];
|
||||
rowC7 = block[7];
|
||||
rowC5 = block[5];
|
||||
rowC3 = block[3];
|
||||
rowAcBits = rowC4 | rowC6;
|
||||
rowAcBits = rowC2 | rowAcBits;
|
||||
rowAcBits = rowC1 | rowAcBits;
|
||||
rowAcBits = rowC7 | rowAcBits;
|
||||
rowAcBits = rowC5 | rowAcBits;
|
||||
rowAcBits = rowC3 | rowAcBits;
|
||||
if (rowAcBits == 0) {
|
||||
rowSampleDc = block[0];
|
||||
dst[7] = rowSampleDc;
|
||||
dst[6] = rowSampleDc;
|
||||
dst[5] = rowSampleDc;
|
||||
dst[4] = rowSampleDc;
|
||||
dst[3] = rowSampleDc;
|
||||
dst[2] = rowSampleDc;
|
||||
dst[1] = rowSampleDc;
|
||||
dst[0] = rowSampleDc;
|
||||
} else {
|
||||
s32 oddLowSum;
|
||||
s32 oddLowDifference;
|
||||
s32 oddHighSum;
|
||||
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;
|
||||
oddSumDifference = oddHighSum - oddLowSum;
|
||||
oddDifferenceSum = oddLowDifference + oddHighDifference;
|
||||
dcValue = block[0];
|
||||
evenBaseDifference = dcValue - coefficient4;
|
||||
oddSumRotation = oddSumDifference * 0xB5 >> 8;
|
||||
evenBaseSum = dcValue + coefficient4;
|
||||
u = rotation45 + u;
|
||||
v = evenBaseDifference + rotation45;
|
||||
z = oddDifferenceSum * 0x62 >> 8;
|
||||
evenOutput0 = evenBaseSum + u;
|
||||
evenOutput3 = evenBaseSum - u;
|
||||
oddHighRotation = oddHighDifference * 0x14E >> 8;
|
||||
evenOutput2 = evenBaseDifference - rotation45;
|
||||
m = oddHighRotation - z;
|
||||
oddLowSum += m;
|
||||
n = oddHighSum + oddLowSum;
|
||||
oddOutput1 = oddSumRotation + m;
|
||||
workspaceCursor[0] = evenOutput0 + n;
|
||||
oddLowRotation = oddLowDifference * 0x8B;
|
||||
workspaceCursor[7] = evenOutput0 - n;
|
||||
oddLowRotation >>= 8;
|
||||
workspaceCursor[1] = v + oddOutput1;
|
||||
oddOutput3 = z + oddLowRotation;
|
||||
oddOutput2 = oddOutput3 + oddSumRotation;
|
||||
workspaceCursor[6] = v - oddOutput1;
|
||||
workspaceCursor[2] = evenOutput2 + oddOutput2;
|
||||
workspaceCursor[5] = evenOutput2 - oddOutput2;
|
||||
workspaceCursor[3] = evenOutput3 + oddOutput3;
|
||||
workspaceCursor[4] = evenOutput3 - oddOutput3;
|
||||
rowDc = block[0];
|
||||
rowEvenRotation = rowC2 - rowC6;
|
||||
rowEvenSum = rowC2 + rowC6;
|
||||
rowEvenBaseSum = rowDc + rowC4;
|
||||
rowEvenBaseDifference = rowDc - rowC4;
|
||||
rowScaledEvenRotation = rowEvenRotation * 0xB5 >> 8;
|
||||
rowEvenRotationSum = rowScaledEvenRotation + rowEvenSum;
|
||||
rowEvenOutput0 = rowEvenBaseSum + rowEvenRotationSum;
|
||||
rowEvenOutput1 = rowEvenBaseDifference + rowScaledEvenRotation;
|
||||
rowEvenOutput2 = rowEvenBaseDifference - rowScaledEvenRotation;
|
||||
rowEvenOutput3 = rowEvenBaseSum - rowEvenRotationSum;
|
||||
rowOddHighSum = rowC1 + rowC7;
|
||||
rowOddHighDifference = rowC1 - rowC7;
|
||||
rowOddLowSum = rowC5 + rowC3;
|
||||
rowOddLowDifference = rowC5 - rowC3;
|
||||
rowOddSumDifference = rowOddHighSum - rowOddLowSum;
|
||||
rowOddDifferenceSum = rowOddLowDifference + rowOddHighDifference;
|
||||
rowOddSumRotation = rowOddSumDifference * 0xB5 >> 8;
|
||||
rowOddDifferenceRotation = rowOddDifferenceSum * 0x62 >> 8;
|
||||
rowOddHighRotation = rowOddHighDifference * 0x14E >> 8;
|
||||
rowOddLowRotation = rowOddLowDifference * 0x8B >> 8;
|
||||
rowOddMix = rowOddHighRotation - rowOddDifferenceRotation;
|
||||
rowOddLowSum += rowOddMix;
|
||||
rowOddOutput0 = rowOddHighSum + rowOddLowSum;
|
||||
rowOddOutput1 = rowOddSumRotation + rowOddMix;
|
||||
rowOddOutput3 = rowOddDifferenceRotation + rowOddLowRotation;
|
||||
rowOddOutput2 = rowOddOutput3 + rowOddSumRotation;
|
||||
dst[0] = rowEvenOutput0 + rowOddOutput0;
|
||||
dst[7] = rowEvenOutput0 - rowOddOutput0;
|
||||
dst[1] = rowEvenOutput1 + rowOddOutput1;
|
||||
dst[6] = rowEvenOutput1 - rowOddOutput1;
|
||||
dst[2] = rowEvenOutput2 + rowOddOutput2;
|
||||
dst[5] = rowEvenOutput2 - rowOddOutput2;
|
||||
dst[3] = rowEvenOutput3 + rowOddOutput3;
|
||||
dst[4] = rowEvenOutput3 - rowOddOutput3;
|
||||
}
|
||||
block += 8;
|
||||
workspaceCursor += 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;
|
||||
u8* output;
|
||||
coefficient4 = workspaceCursor[0x20];
|
||||
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;
|
||||
if (acBits == 0) {
|
||||
s32 sample;
|
||||
sample = clampS8(*workspaceCursor >> 11);
|
||||
output[56] = (u8)sample;
|
||||
output[48] = (u8)sample;
|
||||
output[40] = (u8)sample;
|
||||
output[32] = (u8)sample;
|
||||
output[24] = (u8)sample;
|
||||
output[16] = (u8)sample;
|
||||
output[8] = (u8)sample;
|
||||
output[0] = (u8)sample;
|
||||
} else {
|
||||
s32 oddLowSum;
|
||||
s32 oddLowDifference;
|
||||
s32 oddHighSum;
|
||||
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;
|
||||
oddSumDifference = oddHighSum - oddLowSum;
|
||||
oddDifferenceSum = oddLowDifference + oddHighDifference;
|
||||
dcValue = *workspaceCursor;
|
||||
evenBaseDifference = dcValue - coefficient4;
|
||||
oddSumRotation = oddSumDifference * 0xB5 >> 8;
|
||||
evenBaseSum = dcValue + coefficient4;
|
||||
u = rotation45 + u;
|
||||
v = evenBaseDifference + rotation45;
|
||||
z = oddDifferenceSum * 0x62 >> 8;
|
||||
evenOutput0 = evenBaseSum + u;
|
||||
evenOutput3 = evenBaseSum - u;
|
||||
oddHighRotation = oddHighDifference * 0x14E >> 8;
|
||||
evenOutput2 = evenBaseDifference - rotation45;
|
||||
m = oddHighRotation - z;
|
||||
oddLowSum += m;
|
||||
n = oddHighSum + oddLowSum;
|
||||
oddOutput1 = oddSumRotation + m;
|
||||
oddLowRotation = oddLowDifference * 0x8B >> 8;
|
||||
oddOutput3 = z + oddLowRotation;
|
||||
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[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);
|
||||
dst += 8;
|
||||
}
|
||||
workspaceCursor--;
|
||||
dst = workspace + processed;
|
||||
for (; processed <= 56; processed += 8) {
|
||||
memset(dst, 0, 32);
|
||||
dst += 8;
|
||||
}
|
||||
}
|
||||
|
||||
src = workspace + 7;
|
||||
for (column = 7; column >= 0; column--) {
|
||||
columnC4 = src[32];
|
||||
columnOutput = conv_row_ptr + column;
|
||||
columnC6 = src[48];
|
||||
columnC2 = src[16];
|
||||
columnC1 = src[8];
|
||||
columnC7 = src[56];
|
||||
columnC5 = src[40];
|
||||
columnC3 = src[24];
|
||||
columnAcBits = columnC4 | columnC6;
|
||||
columnAcBits = columnC2 | columnAcBits;
|
||||
columnAcBits = columnC1 | columnAcBits;
|
||||
columnAcBits = columnC7 | columnAcBits;
|
||||
columnAcBits = columnC5 | columnAcBits;
|
||||
columnAcBits = columnC3 | columnAcBits;
|
||||
if (columnAcBits == 0) {
|
||||
columnSample = clampChromaDc(*src);
|
||||
columnOutput[56] = (u8)columnSample;
|
||||
columnOutput[48] = (u8)columnSample;
|
||||
columnOutput[40] = (u8)columnSample;
|
||||
columnOutput[32] = (u8)columnSample;
|
||||
columnOutput[24] = (u8)columnSample;
|
||||
columnOutput[16] = (u8)columnSample;
|
||||
columnOutput[8] = (u8)columnSample;
|
||||
columnOutput[0] = (u8)columnSample;
|
||||
} else {
|
||||
columnOddHighSum = columnC1 + columnC7;
|
||||
columnEvenRotation = columnC2 - columnC6;
|
||||
columnOddLowSum = columnC5 + columnC3;
|
||||
columnOddSumDifference = columnOddHighSum - columnOddLowSum;
|
||||
columnEvenSum = columnC6 + columnC2;
|
||||
columnOddLowDifference = columnC5 - columnC3;
|
||||
columnScaledEvenRotation = columnEvenRotation * 0xB5 >> 8;
|
||||
columnOddHighDifference = columnC1 - columnC7;
|
||||
columnDc = *src;
|
||||
columnEvenRotationSum = columnScaledEvenRotation + columnEvenSum;
|
||||
columnOddSumRotation = columnOddSumDifference * 0xB5 >> 8;
|
||||
columnOddDifferenceSum = columnOddLowDifference + columnOddHighDifference;
|
||||
columnOddDifferenceRotation = columnOddDifferenceSum * 0x62 >> 8;
|
||||
columnEvenBaseDifference = columnDc - columnC4;
|
||||
columnEvenBaseSum = columnDc + columnC4;
|
||||
columnOddHighRotation = columnOddHighDifference * 0x14E >> 8;
|
||||
columnOddMix = columnOddHighRotation - columnOddDifferenceRotation;
|
||||
columnEvenOutput3 = columnEvenBaseSum - columnEvenRotationSum;
|
||||
columnEvenOutput1 = columnEvenBaseDifference + columnScaledEvenRotation;
|
||||
columnEvenOutput2 = columnEvenBaseDifference - columnScaledEvenRotation;
|
||||
columnEvenOutput0 = columnEvenBaseSum + columnEvenRotationSum;
|
||||
columnOddLowRotation = columnOddLowDifference * 0x8B >> 8;
|
||||
columnOddOutput3 = columnOddDifferenceRotation + columnOddLowRotation;
|
||||
columnOddLowSum += columnOddMix;
|
||||
columnOddOutput1 = columnOddSumRotation + columnOddMix;
|
||||
columnOddOutput0 = columnOddHighSum + columnOddLowSum;
|
||||
columnOddOutput2 = columnOddOutput3 + columnOddSumRotation;
|
||||
columnOutput[0] = (u8)clampS8((columnEvenOutput0 + columnOddOutput0) >> 11);
|
||||
columnOutput[56] = (u8)clampS8((columnEvenOutput0 - columnOddOutput0) >> 11);
|
||||
columnOutput[8] = (u8)clampS8((columnEvenOutput1 + columnOddOutput1) >> 11);
|
||||
columnOutput[48] = (u8)clampS8((columnEvenOutput1 - columnOddOutput1) >> 11);
|
||||
columnOutput[16] = (u8)clampS8((columnEvenOutput2 + columnOddOutput2) >> 11);
|
||||
columnOutput[40] = (u8)clampS8((columnEvenOutput2 - columnOddOutput2) >> 11);
|
||||
columnOutput[24] = (u8)clampS8((columnEvenOutput3 + columnOddOutput3) >> 11);
|
||||
columnOutput[32] = (u8)clampS8((columnEvenOutput3 - columnOddOutput3) >> 11);
|
||||
}
|
||||
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,38 @@ static void TMCJPEGDEC_converterYUV444toRGB565edge(TMCCJPEGDecWork*, s32, s32);
|
||||
static void TMCJPEGDEC_converterYUV400toRGB565(TMCCJPEGDecWork*, s32, s32);
|
||||
static void TMCJPEGDEC_converterYUV400toRGB565edge(TMCCJPEGDecWork*, s32, s32);
|
||||
|
||||
/* MWCC needs level 1 to preserve the shared conversion-buffer base. */
|
||||
#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 +56,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 +143,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 +176,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,38 @@ static void TMCJPEGDEC_converterYUV444toRGBA8edge(TMCCJPEGDecWork*, s32, s32);
|
||||
static void TMCJPEGDEC_converterYUV400toRGBA8(TMCCJPEGDecWork*, s32, s32);
|
||||
static void TMCJPEGDEC_converterYUV400toRGBA8edge(TMCCJPEGDecWork*, s32, s32);
|
||||
|
||||
/* MWCC needs level 1 to preserve the shared conversion-buffer base. */
|
||||
#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 +56,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 +143,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 +176,129 @@ 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
|
||||
|
||||
/* MWCC needs the full-width alpha addition before the halfword stores. */
|
||||
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;
|
||||
/* MWCC needs these assignments in the first store to preserve row-address scheduling. */
|
||||
(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,38 @@ static void TMCJPEG_814F32E4(TMCCJPEGDecWork*, s32, s32);
|
||||
static void TMCJPEG_814F34A4(TMCCJPEGDecWork*, s32, s32);
|
||||
static void TMCJPEG_814F372C(TMCCJPEGDecWork*, s32, s32);
|
||||
|
||||
/* MWCC needs level 1 to preserve the shared conversion-buffer base. */
|
||||
#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 +56,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 +143,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 +176,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;
|
||||
|
||||
@@ -57,6 +57,7 @@ ziU8 ZADP_Zi8SetPDremoveOpt(ziU8 option, struct __zi8_work_data_s* __zi8_work_da
|
||||
return previous;
|
||||
}
|
||||
ziU8 Zi8MatchPUDdata_ZHS(ziWChar* pattern, ziU8 length, ziU8 language, ziWChar* output, ziU16 capacity, ziWChar* spelling, ziU16 spellingCapacity, ziU8 complete, ziU8 continuation ZI_NEED_WORK) {
|
||||
// MWCC needs this aggregate to retain the unread workspace store at SP+0x24.
|
||||
struct {
|
||||
int fallback;
|
||||
ziPtr workspace;
|
||||
|
||||
@@ -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,8 @@ struct DVDCommandBlock {
|
||||
DVDCommandBlock* prev; // 0x04
|
||||
|
||||
u32 command; // 0x08
|
||||
volatile s32 state;
|
||||
// MWCC needs plain state stores; asynchronous readers use volatile views.
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,6 +121,7 @@ void defaultOptionalCommandChecker(DVDCommandBlock* block, DVDLowCallback callba
|
||||
|
||||
extern DVDErrorInfo __ErrorInfo;
|
||||
|
||||
// MWCC must reload the interrupt-shared flags and counters below.
|
||||
static vu32 CommandInfoCounter = 0;
|
||||
|
||||
static vBOOL PauseFlag = FALSE;
|
||||
@@ -1889,12 +1890,13 @@ s32 DVDGetCommandBlockStatus(const DVDCommandBlock* block) {
|
||||
BOOL enabled;
|
||||
s32 retVal;
|
||||
DVDCommandBlock* next;
|
||||
const volatile DVDCommandBlock* statusBlock = block;
|
||||
|
||||
enabled = OSDisableInterrupts();
|
||||
|
||||
if (block->state == DVD_STATE_COVER_CLOSED) {
|
||||
if (statusBlock->state == DVD_STATE_COVER_CLOSED) {
|
||||
retVal = DVD_STATE_BUSY;
|
||||
} else if (block->state == DVD_STATE_COVER_OPENED) {
|
||||
} else if (statusBlock->state == DVD_STATE_COVER_OPENED) {
|
||||
retVal = DVD_STATE_NO_DISK;
|
||||
} else if (executing == &__DVDStopMotorCommandBlock) {
|
||||
next = __DVDGetNextWaitingQueue();
|
||||
@@ -1902,17 +1904,17 @@ s32 DVDGetCommandBlockStatus(const DVDCommandBlock* block) {
|
||||
if (block == next) {
|
||||
retVal = DVD_STATE_BUSY;
|
||||
} else {
|
||||
retVal = block->state;
|
||||
retVal = statusBlock->state;
|
||||
}
|
||||
} else {
|
||||
if (block == &__DVDStopMotorCommandBlock) {
|
||||
retVal = DVD_STATE_IDLE;
|
||||
} else {
|
||||
retVal = block->state;
|
||||
retVal = statusBlock->state;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
retVal = block->state;
|
||||
retVal = statusBlock->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*);
|
||||
@@ -136,6 +136,7 @@ typedef union PFD_SDDRV_U16_BYTES {
|
||||
u8 bytes[2];
|
||||
} PFD_SDDRV_U16_BYTES;
|
||||
|
||||
/* MWCC needs buffer-relative word stores to preserve boot-sector address calculations. */
|
||||
#define pfd_sddrv_store_le16(buffer, field, offset, value) \
|
||||
do { \
|
||||
if (((u32)(field) & 1) != 0) { \
|
||||
@@ -243,39 +244,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,17 +276,17 @@ 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);
|
||||
}
|
||||
}
|
||||
@@ -313,18 +298,19 @@ s32 pfd_sddrv_init(FADisk* disk) {
|
||||
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;
|
||||
pf_memset(&g_pfd_sddev, 0, 0x28);
|
||||
pf_memset(&g_pfd_sddev, 0, sizeof(g_pfd_sddev.device));
|
||||
sd_result = ISD_InitCard();
|
||||
if (sd_result != 0) {
|
||||
OSReport("ERR:Failed to init SD Card Driver in pfd_sddrv_init()\n");
|
||||
@@ -332,7 +318,7 @@ s32 pfd_sddrv_init(FADisk* disk) {
|
||||
}
|
||||
g_pfd_sddrv_info.flags |= 4;
|
||||
}
|
||||
pf_memset(&g_pfd_sddev, 0, 0x28);
|
||||
pf_memset(&g_pfd_sddev, 0, sizeof(g_pfd_sddev.device));
|
||||
device = &g_pfd_sddev.device;
|
||||
sd_result = ISD_MountCard(0, &device);
|
||||
if (sd_result != 0) {
|
||||
@@ -473,7 +459,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 +471,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) {
|
||||
@@ -897,7 +883,7 @@ s32 pfd_sddrv_store_bpb_buf(PFD_SDDRV_FORMAT_DATA* format_data, u8* sector_buffe
|
||||
if (format_data == 0) {
|
||||
return -30;
|
||||
}
|
||||
pf_memset(&settings, 0, 0x10);
|
||||
pf_memset(&settings, 0, sizeof(settings));
|
||||
requested_sectors = format_data->total_sectors;
|
||||
size_entry = sddrv_size_depend_tbl;
|
||||
for (entry_index = 0; entry_index < 14; size_entry++, entry_index++) {
|
||||
@@ -979,7 +965,7 @@ s32 pfd_sddrv_store_mbr_buf(PFD_SDDRV_FORMAT_DATA* format_data, u8* sector_buffe
|
||||
if (format_data == 0) {
|
||||
return -30;
|
||||
}
|
||||
pf_memset(&settings, 0, 0x10);
|
||||
pf_memset(&settings, 0, sizeof(settings));
|
||||
requested_sectors = format_data->total_sectors;
|
||||
size_entry = sddrv_size_depend_tbl;
|
||||
for (entry_index = 0; entry_index < 14; size_entry++, entry_index++) {
|
||||
@@ -1040,7 +1026,7 @@ s32 pfd_sddrv_build_mbr_bpb(u32 total_sectors) {
|
||||
s32 result;
|
||||
u32 partition_start_sector;
|
||||
|
||||
pf_memset(&format_data, 0, 0x20);
|
||||
pf_memset(&format_data, 0, sizeof(format_data));
|
||||
format_data.total_sectors = total_sectors;
|
||||
result = pfd_sddrv_calc_mbr_bpb(&format_data);
|
||||
if (result != 0) {
|
||||
@@ -1105,7 +1091,7 @@ s32 pfd_sddrv_calc_fat32_mbr_bpb(PFD_SDDRV_FORMAT_DATA* format_data) {
|
||||
if (format_data == 0) {
|
||||
return -30;
|
||||
}
|
||||
pf_memset(&settings, 0, 0x10);
|
||||
pf_memset(&settings, 0, sizeof(settings));
|
||||
requested_sectors = format_data->total_sectors;
|
||||
total_sectors = format_data->total_sectors;
|
||||
size_entry = sddrv_size_depend_tbl;
|
||||
@@ -1203,7 +1189,7 @@ s32 pfd_sddrv_store_fat32_mbr_buf(PFD_SDDRV_FORMAT_DATA* format_data, u8* sector
|
||||
if (format_data == 0 || sector_buffer == 0) {
|
||||
return -30;
|
||||
}
|
||||
pf_memset(&settings, 0, 0x10);
|
||||
pf_memset(&settings, 0, sizeof(settings));
|
||||
requested_sectors = format_data->total_sectors;
|
||||
size_entry = sddrv_size_depend_tbl;
|
||||
for (entry_index = 0; entry_index < 14; size_entry++, entry_index++) {
|
||||
@@ -1318,7 +1304,7 @@ s32 pfd_sddrv_store_fat32_bpb_buf(PFD_SDDRV_FORMAT_DATA* format_data, u8* sector
|
||||
if (format_data == 0 || sector_buffer == 0) {
|
||||
return -30;
|
||||
}
|
||||
pf_memset(&settings, 0, 0x10);
|
||||
pf_memset(&settings, 0, sizeof(settings));
|
||||
requested_sectors = format_data->total_sectors;
|
||||
size_entry = sddrv_size_depend_tbl;
|
||||
for (entry_index = 0; entry_index < 14; size_entry++, entry_index++) {
|
||||
@@ -1371,26 +1357,29 @@ 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);
|
||||
}
|
||||
|
||||
/* MWCC needs IRO 0 to retain the reserved-sector error path. */
|
||||
#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;
|
||||
pf_memset(&format_data, 0, 0x20);
|
||||
pf_memset(&format_data, 0, sizeof(format_data));
|
||||
format_data.total_sectors = total_sectors;
|
||||
result = pfd_sddrv_calc_fat32_mbr_bpb(&format_data);
|
||||
if (result != 0) {
|
||||
@@ -1408,12 +1397,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 +1418,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 +1440,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 +1461,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,12 +8,8 @@ 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) {
|
||||
// MWCC needs volatile byte loads to preserve the MBR decoding order.
|
||||
pf_s32 pdm_part_is_master_boot_sector(volatile pf_u8* buf, pf_u32 total, pf_bool* p_is_mbr) {
|
||||
pf_u32* p_start;
|
||||
pf_u32* p_count;
|
||||
pf_s16 index;
|
||||
@@ -25,8 +21,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 +32,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) {
|
||||
|
||||
@@ -76,6 +76,7 @@ typedef struct FS_Callback {
|
||||
#define FS_HEAP_SIZE ((FS_HEAP_BLOCK + 1) * OSRoundUp32B(sizeof(FS_Callback)))
|
||||
|
||||
#define FS_ALLOC(p) iosAllocAligned(hId, sizeof(*p), DEFAULT_ALIGN)
|
||||
/* MWCC needs nested null guards to retain both cleanup branches. */
|
||||
#define FS_FREE(p) \
|
||||
if (p != NULL) { \
|
||||
iosFree(hId, p); \
|
||||
@@ -139,7 +140,7 @@ ISFSError ISFS_OpenLibEx() {
|
||||
}
|
||||
|
||||
ISFSError ISFS_CloseLib() {
|
||||
ISFSError ret = ISFS_ERROR_OK;
|
||||
ISFSError ret;
|
||||
|
||||
if (__fsFd < 0) {
|
||||
ret = ISFS_ERROR_INVALID;
|
||||
@@ -265,7 +266,7 @@ IOSError _isfsFuncCb(IOSError result, void* isfsCallbackArg) {
|
||||
}
|
||||
|
||||
ISFSError ISFS_GetStats(ISFSStats* stats) {
|
||||
ISFSError ret = ISFS_ERROR_OK;
|
||||
ISFSError ret;
|
||||
FS_Callback* isfsCallbackArg = NULL;
|
||||
|
||||
if (__fsFd < 0 || stats == NULL) {
|
||||
@@ -296,8 +297,9 @@ out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* MWCC needs path-length assignments in validation to share each error branch. */
|
||||
ISFSError ISFS_CreateDir(const char* dirName, u32 dirAttr, u32 ownerAcc, u32 groupAcc, u32 othersAcc) {
|
||||
ISFSError ret = ISFS_ERROR_OK;
|
||||
ISFSError ret;
|
||||
u32 len;
|
||||
|
||||
ISFSPathAttrArgs* pathAttrArgs;
|
||||
@@ -335,7 +337,7 @@ out:
|
||||
}
|
||||
|
||||
ISFSError ISFS_CreateDirAsync(const char* dirName, u32 dirAttr, u32 ownerAcc, u32 groupAcc, u32 othersAcc, ISFSCallback callback, void* callbackArg) {
|
||||
ISFSError ret = ISFS_ERROR_OK;
|
||||
ISFSError ret;
|
||||
u32 len;
|
||||
|
||||
ISFSPathAttrArgs* pathAttrArgs;
|
||||
@@ -359,7 +361,7 @@ ISFSError ISFS_CreateDirAsync(const char* dirName, u32 dirAttr, u32 ownerAcc, u3
|
||||
isfsCallbackArg->func = ISFS_CB_STATE_NONE;
|
||||
|
||||
pathAttrArgs = (ISFSPathAttrArgs*)isfsCallbackArg->ioBuf;
|
||||
memcpy(pathAttrArgs->path, (void*)dirName, len + 1);
|
||||
memcpy(pathAttrArgs->path, dirName, len + 1);
|
||||
pathAttrArgs->attr = dirAttr;
|
||||
pathAttrArgs->ownerAccess = ownerAcc;
|
||||
pathAttrArgs->groupAccess = groupAcc;
|
||||
@@ -372,7 +374,7 @@ out:
|
||||
}
|
||||
|
||||
ISFSError ISFS_ReadDir(const char* dirName, char* nameList, u32* num) {
|
||||
ISFSError ret = ISFS_ERROR_OK;
|
||||
ISFSError ret;
|
||||
u32 len, numInputs, numOutputs, *numPtr;
|
||||
|
||||
IOSIoVector* vec = NULL;
|
||||
@@ -435,7 +437,7 @@ out:
|
||||
}
|
||||
|
||||
ISFSError ISFS_ReadDirAsync(const char* dirName, char* nameList, u32* num, ISFSCallback callback, void* callbackArg) {
|
||||
ISFSError ret = ISFS_ERROR_OK;
|
||||
ISFSError ret;
|
||||
u32 len, numInputs, numOutputs, *numPtr;
|
||||
|
||||
FS_Callback* isfsCallbackArg = NULL;
|
||||
@@ -494,7 +496,7 @@ out:
|
||||
}
|
||||
|
||||
ISFSError ISFS_SetAttr(const char* fileName, u32 ownerId, u16 groupId, u32 attr, u32 ownerAcc, u32 groupAcc, u32 othersAcc) {
|
||||
ISFSError ret = ISFS_ERROR_OK;
|
||||
ISFSError ret;
|
||||
ISFSPathAttrArgs* pathAttrArgs;
|
||||
|
||||
u32 len;
|
||||
@@ -522,7 +524,7 @@ ISFSError ISFS_SetAttr(const char* fileName, u32 ownerId, u16 groupId, u32 attr,
|
||||
pathAttrArgs->groupAccess = (u8)groupAcc;
|
||||
pathAttrArgs->othersAccess = (u8)othersAcc;
|
||||
|
||||
ret = IOS_Ioctl(__fsFd, ISFS_IOCTL_SET_ATTR, (u8*)pathAttrArgs, sizeof(*pathAttrArgs), NULL, 0);
|
||||
ret = IOS_Ioctl(__fsFd, ISFS_IOCTL_SET_ATTR, pathAttrArgs, sizeof(*pathAttrArgs), NULL, 0);
|
||||
|
||||
out:
|
||||
if (isfsCallbackArg != NULL) {
|
||||
@@ -534,7 +536,7 @@ out:
|
||||
|
||||
ISFSError ISFS_SetAttrAsync(const char* fileName, u32 ownerId, u16 groupId, u32 attr, u32 ownerAcc, u32 groupAcc, u32 othersAcc,
|
||||
ISFSCallback callback, void* callbackArg) {
|
||||
ISFSError ret = ISFS_ERROR_OK;
|
||||
ISFSError ret;
|
||||
ISFSPathAttrArgs* pathAttrArgs;
|
||||
|
||||
u32 len;
|
||||
@@ -566,13 +568,13 @@ ISFSError ISFS_SetAttrAsync(const char* fileName, u32 ownerId, u16 groupId, u32
|
||||
pathAttrArgs->groupAccess = (u8)groupAcc;
|
||||
pathAttrArgs->othersAccess = (u8)othersAcc;
|
||||
|
||||
ret = IOS_IoctlAsync(__fsFd, ISFS_IOCTL_SET_ATTR, (u8*)pathAttrArgs, sizeof(ISFSPathAttrArgs), NULL, 0, _isfsFuncCb, isfsCallbackArg);
|
||||
ret = IOS_IoctlAsync(__fsFd, ISFS_IOCTL_SET_ATTR, pathAttrArgs, sizeof(ISFSPathAttrArgs), NULL, 0, _isfsFuncCb, isfsCallbackArg);
|
||||
out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
ISFSError ISFS_GetAttr(const char* fileName, u32* ownerId, u16* groupId, u32* attr, u32* ownerAcc, u32* groupAcc, u32* othersAcc) {
|
||||
ISFSError ret = ISFS_ERROR_OK;
|
||||
ISFSError ret;
|
||||
ISFSPathAttrArgs* pathAttrArgs;
|
||||
|
||||
u8* ptr;
|
||||
@@ -592,7 +594,7 @@ ISFSError ISFS_GetAttr(const char* fileName, u32* ownerId, u16* groupId, u32* at
|
||||
goto out;
|
||||
}
|
||||
|
||||
ptr = (u8*)isfsCallbackArg->ioBuf;
|
||||
ptr = isfsCallbackArg->ioBuf;
|
||||
memcpy(ptr, fileName, len + 1);
|
||||
pathAttrArgs = (ISFSPathAttrArgs*)OSRoundUp32B(ptr + FS_MAX_PATH);
|
||||
ret = IOS_Ioctl(__fsFd, ISFS_IOCTL_GET_ATTR, ptr, FS_MAX_PATH, pathAttrArgs, sizeof(*pathAttrArgs));
|
||||
@@ -618,7 +620,7 @@ out:
|
||||
|
||||
ISFSError ISFS_GetAttrAsync(const char* fileName, u32* ownerId, u16* groupId, u32* attr, u32* ownerAcc, u32* groupAcc, u32* othersAcc,
|
||||
ISFSCallback callback, void* callbackArg) {
|
||||
ISFSError ret = ISFS_ERROR_OK;
|
||||
ISFSError ret;
|
||||
FS_Callback* isfsCallbackArg;
|
||||
ISFSPathAttrArgs* pathAttrArgs;
|
||||
u8* ptr;
|
||||
@@ -646,7 +648,7 @@ ISFSError ISFS_GetAttrAsync(const char* fileName, u32* ownerId, u16* groupId, u3
|
||||
isfsCallbackArg->callbackArg = callbackArg;
|
||||
isfsCallbackArg->func = ISFS_CB_STATE_GET_ATTR;
|
||||
|
||||
ptr = (u8*)isfsCallbackArg->ioBuf;
|
||||
ptr = isfsCallbackArg->ioBuf;
|
||||
memcpy(ptr, fileName, len + 1);
|
||||
pathAttrArgs = (ISFSPathAttrArgs*)OSRoundUp32B(ptr + FS_MAX_PATH);
|
||||
|
||||
@@ -656,7 +658,7 @@ out:
|
||||
}
|
||||
|
||||
ISFSError ISFS_Delete(const char* fileName) {
|
||||
ISFSError ret = ISFS_ERROR_OK;
|
||||
ISFSError ret;
|
||||
u32 len;
|
||||
FS_Callback* isfsCallbackArg = NULL;
|
||||
|
||||
@@ -683,7 +685,7 @@ out:
|
||||
}
|
||||
|
||||
ISFSError ISFS_DeleteAsync(const char* fileName, ISFSCallback callback, void* callbackArg) {
|
||||
ISFSError ret = ISFS_ERROR_OK;
|
||||
ISFSError ret;
|
||||
u32 len;
|
||||
FS_Callback* isfsCallbackArg;
|
||||
|
||||
@@ -709,7 +711,7 @@ out:
|
||||
}
|
||||
|
||||
ISFSError ISFS_Rename(const char* oldName, const char* newName) {
|
||||
ISFSError ret = ISFS_ERROR_OK;
|
||||
ISFSError ret;
|
||||
ISFSPathsArgs* pathsArgs;
|
||||
|
||||
u32 oldLen, newLen;
|
||||
@@ -742,7 +744,7 @@ out:
|
||||
}
|
||||
|
||||
ISFSError ISFS_RenameAsync(const char* oldName, const char* newName, ISFSCallback callback, void* callbackArg) {
|
||||
ISFSError ret = ISFS_ERROR_OK;
|
||||
ISFSError ret;
|
||||
ISFSPathsArgs* pathsArgs;
|
||||
|
||||
u32 oldLen, newLen;
|
||||
@@ -775,7 +777,7 @@ out:
|
||||
}
|
||||
|
||||
ISFSError ISFS_GetUsage(const char* dirName, u32* blocks, u32* iNodes) {
|
||||
ISFSError ret = ISFS_ERROR_OK;
|
||||
ISFSError ret;
|
||||
|
||||
u32 len, *blkPtr, *inodePtr;
|
||||
|
||||
@@ -828,7 +830,7 @@ out:
|
||||
}
|
||||
|
||||
ISFSError ISFS_CreateFile(const char* fileName, u32 fileAttr, u32 ownerAcc, u32 groupAcc, u32 othersAcc) {
|
||||
ISFSError ret = ISFS_ERROR_OK;
|
||||
ISFSError ret;
|
||||
ISFSPathAttrArgs* pathAttrArgs;
|
||||
|
||||
u32 len;
|
||||
@@ -866,7 +868,7 @@ out:
|
||||
|
||||
ISFSError ISFS_CreateFileAsync(const char* fileName, u32 fileAttr, u32 ownerAcc, u32 groupAcc, u32 othersAcc, ISFSCallback callback,
|
||||
void* callbackArg) {
|
||||
ISFSError ret = ISFS_ERROR_OK;
|
||||
ISFSError ret;
|
||||
ISFSPathAttrArgs* pathAttrArgs;
|
||||
|
||||
u32 len;
|
||||
@@ -901,7 +903,7 @@ out:
|
||||
}
|
||||
|
||||
IOSFd ISFS_Open(const char* fileName, u32 access) {
|
||||
ISFSError ret = ISFS_ERROR_OK;
|
||||
ISFSError ret;
|
||||
u32 len;
|
||||
FS_Callback* isfsCallbackArg = NULL;
|
||||
|
||||
@@ -928,7 +930,7 @@ out:
|
||||
}
|
||||
|
||||
IOSFd ISFS_OpenAsync(const char* fileName, u32 access, ISFSCallback callback, void* callbackArg) {
|
||||
ISFSError ret = ISFS_ERROR_OK;
|
||||
ISFSError ret;
|
||||
u32 len;
|
||||
FS_Callback* isfsCallbackArg;
|
||||
|
||||
@@ -954,7 +956,7 @@ out:
|
||||
}
|
||||
|
||||
ISFSError ISFS_GetFileStats(IOSFd fd, ISFSFileStats* stats) {
|
||||
ISFSError ret = ISFS_ERROR_OK;
|
||||
ISFSError ret;
|
||||
FS_Callback* isfsCallbackArg = NULL;
|
||||
|
||||
if (stats == NULL || ((u32)stats & 31)) {
|
||||
@@ -985,7 +987,7 @@ out:
|
||||
}
|
||||
|
||||
ISFSError ISFS_GetFileStatsAsync(IOSFd fd, ISFSFileStats* stats, ISFSCallback callback, void* callbackArg) {
|
||||
ISFSError ret = ISFS_ERROR_OK;
|
||||
ISFSError ret;
|
||||
FS_Callback* isfsCallbackArg;
|
||||
|
||||
if (stats == NULL || ((u32)stats & 31)) {
|
||||
@@ -1034,14 +1036,14 @@ out:
|
||||
|
||||
ISFSError ISFS_Read(s32 fd, u8* buffer, u32 bufferLen) {
|
||||
if (buffer == NULL || (u32)buffer & 31) {
|
||||
return -101;
|
||||
return ISFS_ERROR_INVALID;
|
||||
}
|
||||
|
||||
return IOS_Read(fd, buffer, bufferLen);
|
||||
}
|
||||
|
||||
ISFSError ISFS_ReadAsync(IOSFd fd, u8* buffer, u32 size, ISFSCallback callback, void* callbackArg) {
|
||||
ISFSError ret = ISFS_ERROR_OK;
|
||||
ISFSError ret;
|
||||
FS_Callback* isfsCallbackArg;
|
||||
|
||||
if (buffer == NULL || ((u32)buffer & 31)) {
|
||||
@@ -1065,7 +1067,7 @@ out:
|
||||
}
|
||||
|
||||
ISFSError ISFS_Write(IOSFd fd, const char* buffer, u32 size) {
|
||||
ISFSError ret = ISFS_ERROR_OK;
|
||||
ISFSError ret;
|
||||
|
||||
if ((buffer == NULL) || ((u32)buffer & 31)) {
|
||||
ret = ISFS_ERROR_INVALID;
|
||||
@@ -1078,7 +1080,7 @@ out:
|
||||
}
|
||||
|
||||
ISFSError ISFS_WriteAsync(IOSFd fd, const char* buffer, u32 size, ISFSCallback callback, void* callbackArg) {
|
||||
ISFSError ret = ISFS_ERROR_OK;
|
||||
ISFSError ret;
|
||||
FS_Callback* isfsCallbackArg;
|
||||
|
||||
if (buffer == NULL || ((u32)buffer & 31)) {
|
||||
@@ -1126,7 +1128,7 @@ out:
|
||||
}
|
||||
|
||||
ISFSError ISFS_ShutdownAsync(ISFSCallback callback, void* callbackArg) {
|
||||
ISFSError ret = ISFS_ERROR_OK;
|
||||
ISFSError ret;
|
||||
FS_Callback* isfsCallbackArg;
|
||||
|
||||
isfsCallbackArg = FS_ALLOC(isfsCallbackArg);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -35,9 +35,8 @@ size_t strnlen(const char* s, size_t maxlen) {
|
||||
}
|
||||
|
||||
static inline IOSError ipcFree(IOSRpcRequest* rpc) {
|
||||
IOSError ret = IPC_RESULT_OK;
|
||||
iosFree(hid, rpc);
|
||||
return ret;
|
||||
return IPC_RESULT_OK;
|
||||
}
|
||||
|
||||
static inline void __ipcSendRequest() {
|
||||
|
||||
@@ -171,7 +171,6 @@ static void kbd_led_handler(BOOL success, void* callbackArg);
|
||||
|
||||
static void kbdAttachHandler(void* device) {
|
||||
u32 channel;
|
||||
channel = 0;
|
||||
|
||||
for (channel = 0; channel < 4; channel++) {
|
||||
if (kbdData[(u8)channel].device == NULL) {
|
||||
@@ -196,7 +195,6 @@ static void kbdAttachHandler(void* device) {
|
||||
|
||||
static void kbdDetachHandler(void* device) {
|
||||
u32 channel;
|
||||
channel = 0;
|
||||
|
||||
for (channel = 0; channel < 4; channel++) {
|
||||
if (device == kbdData[(u8)channel].device) {
|
||||
@@ -221,7 +219,6 @@ static void kbdDetachHandler(void* device) {
|
||||
|
||||
static void kbdEventHandler(void* device, char* report) {
|
||||
u32 channel;
|
||||
channel = 0;
|
||||
|
||||
for (channel = 0; channel < 4; channel++) {
|
||||
if (device == kbdData[(u8)channel].device) {
|
||||
@@ -396,13 +393,14 @@ static void kbdProcKey(u32 key, u32 pressed, u32 channel) {
|
||||
kbdSendKey(&event);
|
||||
}
|
||||
|
||||
/* MWCC needs propagation disabled to preserve the inlined modifier-state registers. */
|
||||
#pragma push
|
||||
#pragma opt_propagation off
|
||||
static void kbdProcMod(u32 key, u32 pressed, u32 channel) {
|
||||
KBDChannel* data;
|
||||
u32 modState;
|
||||
s32 delta;
|
||||
u8 flags;
|
||||
|
||||
u32 finalState;
|
||||
s8 value;
|
||||
data = &kbdData[channel];
|
||||
delta = (pressed & 1) != 0 ? 1 : -1;
|
||||
@@ -521,9 +519,9 @@ static void kbdProcMod(u32 key, u32 pressed, u32 channel) {
|
||||
}
|
||||
break;
|
||||
}
|
||||
finalState = modState | 0x1000;
|
||||
KBDSetModState(channel, finalState);
|
||||
KBDSetModState(channel, modState | 0x1000);
|
||||
}
|
||||
#pragma pop
|
||||
|
||||
static void kbdSendKey(KBDKeyEventData* event) {
|
||||
KBDChannel* data;
|
||||
@@ -554,26 +552,25 @@ static void kbdSendKey(KBDKeyEventData* event) {
|
||||
}
|
||||
}
|
||||
|
||||
/* MWCC needs IRO 0 to reload the callback and retain the success branch. */
|
||||
#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 +820,9 @@ USBKBDErr KBDSetLockProcessing(u32 channel, u32 value) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* MWCC needs IRO 1 to preserve the modifier-state load and store registers. */
|
||||
#pragma push
|
||||
#pragma ppc_iro_level 1
|
||||
USBKBDErr KBDSetModState(u32 channel, u32 value) {
|
||||
if (!kbdInitialized) {
|
||||
return 2;
|
||||
@@ -834,17 +834,18 @@ USBKBDErr KBDSetModState(u32 channel, u32 value) {
|
||||
kbdData[channel].modState = value & ~0x1000;
|
||||
} else {
|
||||
BOOL interrupts;
|
||||
KBDModifierState oldState;
|
||||
u32 oldState;
|
||||
KBDModifierState newState;
|
||||
interrupts = OSDisableInterrupts();
|
||||
newState.value = value & 0xfc0;
|
||||
oldState.value = kbdData[channel].modState;
|
||||
newState.bits.physical = oldState.bits.physical;
|
||||
oldState = kbdData[channel].modState;
|
||||
newState.bits.physical = oldState;
|
||||
kbdData[channel].modState = newState.value;
|
||||
OSRestoreInterrupts(interrupts);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#pragma pop
|
||||
|
||||
u16 KBDTranslateHidCode(u32 keyCode, u32 modifiers, s32 country) {
|
||||
s32 mask;
|
||||
|
||||
@@ -198,17 +198,16 @@ static void* get_ring_buffer_by_kpad1_style(s32 chan, void* buffer, s32 style) {
|
||||
switch (style) {
|
||||
case WPAD_DEV_CORE:
|
||||
size = 0x2A;
|
||||
goto process;
|
||||
break;
|
||||
case WPAD_DEV_FREESTYLE:
|
||||
size = 0x32;
|
||||
goto process;
|
||||
break;
|
||||
case WPAD_DEV_CLASSIC:
|
||||
size = 0x36;
|
||||
goto process;
|
||||
break;
|
||||
default:
|
||||
return buffer;
|
||||
}
|
||||
process:
|
||||
enabled = OSDisableInterrupts();
|
||||
index = kpad->ringIndex - 1;
|
||||
latest = WPADGetLatestIndexInBuf(chan);
|
||||
@@ -622,6 +621,7 @@ static void read_kpad_acc(KPADInside* kpad, KPADSample* status) {
|
||||
kpad->status.acc_speed = (f32)sqrt(previous.z * previous.z + (previous.x * previous.x + previous.y * previous.y));
|
||||
calc_acc_horizon(kpad);
|
||||
calc_acc_vertical(kpad);
|
||||
// MWCC needs separate format exits to preserve both comparisons.
|
||||
if (status->error == WPAD_ERR_OK && status->device == WPAD_DEV_FREESTYLE) {
|
||||
if (status->dataFormat == WPAD_FMT_FS_BTN_ACC) {
|
||||
goto read_extension_acceleration;
|
||||
@@ -664,7 +664,7 @@ static s8 select_2obj_first(KPADInside* kpad) {
|
||||
object = kpad->dpdState.objects;
|
||||
do {
|
||||
if ((s8)object->metadata.bytes.flags != 0) {
|
||||
goto nextObject;
|
||||
continue;
|
||||
}
|
||||
other = object + 1;
|
||||
do {
|
||||
@@ -676,7 +676,7 @@ static s8 select_2obj_first(KPADInside* kpad) {
|
||||
f32 dot;
|
||||
f32 score;
|
||||
if ((s8)other->metadata.bytes.flags != 0) {
|
||||
goto nextOther;
|
||||
continue;
|
||||
}
|
||||
dx = other->x - object->x;
|
||||
dy = other->y - object->y;
|
||||
@@ -687,7 +687,7 @@ static s8 select_2obj_first(KPADInside* kpad) {
|
||||
direction.y = kpad->horizonTangent.y * dx - kpad->horizonTangent.x * dy;
|
||||
dist = kpad->dpdDistanceScale * scale;
|
||||
if (dist <= kpad->minDpdDistance || dist >= kp_err_dist_max) {
|
||||
goto nextOther;
|
||||
continue;
|
||||
}
|
||||
dot = kpad->horizonAxis.x * direction.x + kpad->horizonAxis.y * direction.y;
|
||||
score = dot;
|
||||
@@ -703,12 +703,8 @@ static s8 select_2obj_first(KPADInside* kpad) {
|
||||
first = object;
|
||||
second = other;
|
||||
}
|
||||
nextOther:
|
||||
++other;
|
||||
} while (other <= kpad->dpdState.objects + 3);
|
||||
nextObject:
|
||||
++object;
|
||||
} while (object < kpad->dpdState.objects + 3);
|
||||
} while (++other <= kpad->dpdState.objects + 3);
|
||||
} while (++object < kpad->dpdState.objects + 3);
|
||||
if (best == kp_err_first_inpr) {
|
||||
return 0;
|
||||
}
|
||||
@@ -726,7 +722,7 @@ static s8 select_2obj_continue(KPADInside* kpad) {
|
||||
object = kpad->dpdState.objects;
|
||||
do {
|
||||
if ((s8)object->metadata.bytes.flags != 0) {
|
||||
goto nextObject;
|
||||
continue;
|
||||
}
|
||||
other = object + 1;
|
||||
do {
|
||||
@@ -738,7 +734,7 @@ static s8 select_2obj_continue(KPADInside* kpad) {
|
||||
f32 dot;
|
||||
BOOL reverse;
|
||||
if ((s8)other->metadata.bytes.flags != 0) {
|
||||
goto nextOther;
|
||||
continue;
|
||||
}
|
||||
dx = other->x - object->x;
|
||||
dy = other->y - object->y;
|
||||
@@ -747,7 +743,7 @@ static s8 select_2obj_continue(KPADInside* kpad) {
|
||||
direction.y = dy * scale;
|
||||
scale *= kpad->dpdDistanceScale;
|
||||
if (scale <= kpad->minDpdDistance || scale >= kp_err_dist_max) {
|
||||
goto nextOther;
|
||||
continue;
|
||||
}
|
||||
scale -= kpad->dpdReferenceDistance;
|
||||
if (scale < 0.0f) {
|
||||
@@ -756,7 +752,7 @@ static s8 select_2obj_continue(KPADInside* kpad) {
|
||||
scale *= kpad->invDistSpeed;
|
||||
}
|
||||
if (scale >= 1.0f) {
|
||||
goto nextOther;
|
||||
continue;
|
||||
}
|
||||
dot = kpad->dpdObjectDirection.x * direction.x + kpad->dpdObjectDirection.y * direction.y;
|
||||
if (dot < 0.0f) {
|
||||
@@ -766,7 +762,7 @@ static s8 select_2obj_continue(KPADInside* kpad) {
|
||||
reverse = FALSE;
|
||||
}
|
||||
if (dot <= kp_err_next_inpr) {
|
||||
goto nextOther;
|
||||
continue;
|
||||
}
|
||||
scale += ((1.0f - dot) / (1.0f - kp_err_next_inpr));
|
||||
if (scale < best) {
|
||||
@@ -779,12 +775,8 @@ static s8 select_2obj_continue(KPADInside* kpad) {
|
||||
second = other;
|
||||
}
|
||||
}
|
||||
nextOther:
|
||||
++other;
|
||||
} while (other <= kpad->dpdState.objects + 3);
|
||||
nextObject:
|
||||
++object;
|
||||
} while (object < kpad->dpdState.objects + 3);
|
||||
} while (++other <= kpad->dpdState.objects + 3);
|
||||
} while (++object < kpad->dpdState.objects + 3);
|
||||
if (2.0f == best) {
|
||||
return 0;
|
||||
}
|
||||
@@ -1092,50 +1084,51 @@ static void read_kpad_dpd(KPADInside* kpad, KPADSample* status) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!(kpad->status.acc_vertical.x <= kp_err_up_inpr)) {
|
||||
if (kpad->status.dpd_valid_fg == 2 || kpad->status.dpd_valid_fg == -2) {
|
||||
if (kpad->dpdCount >= 2) {
|
||||
selected = select_2obj_continue(kpad);
|
||||
if (selected != 0) {
|
||||
goto updateSelection;
|
||||
do {
|
||||
if (!(kpad->status.acc_vertical.x <= kp_err_up_inpr)) {
|
||||
if (kpad->status.dpd_valid_fg == 2 || kpad->status.dpd_valid_fg == -2) {
|
||||
if (kpad->dpdCount >= 2) {
|
||||
selected = select_2obj_continue(kpad);
|
||||
if (selected != 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (kpad->dpdCount >= 1) {
|
||||
selected = select_1obj_continue(kpad);
|
||||
if (selected != 0) {
|
||||
goto updateSelection;
|
||||
if (kpad->dpdCount >= 1) {
|
||||
selected = select_1obj_continue(kpad);
|
||||
if (selected != 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (kpad->status.dpd_valid_fg == 1 || kpad->status.dpd_valid_fg == -1) {
|
||||
if (kpad->dpdCount >= 2) {
|
||||
selected = select_2obj_first(kpad);
|
||||
if (selected != 0) {
|
||||
goto updateSelection;
|
||||
} else if (kpad->status.dpd_valid_fg == 1 || kpad->status.dpd_valid_fg == -1) {
|
||||
if (kpad->dpdCount >= 2) {
|
||||
selected = select_2obj_first(kpad);
|
||||
if (selected != 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (kpad->dpdCount >= 1) {
|
||||
selected = select_1obj_continue(kpad);
|
||||
if (selected != 0) {
|
||||
goto updateSelection;
|
||||
if (kpad->dpdCount >= 1) {
|
||||
selected = select_1obj_continue(kpad);
|
||||
if (selected != 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (kpad->dpdCount >= 2) {
|
||||
selected = select_2obj_first(kpad);
|
||||
if (selected != 0) {
|
||||
goto updateSelection;
|
||||
} else {
|
||||
if (kpad->dpdCount >= 2) {
|
||||
selected = select_2obj_first(kpad);
|
||||
if (selected != 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (kpad->dpdCount == 1) {
|
||||
selected = select_1obj_first(kpad);
|
||||
if (selected != 0) {
|
||||
goto updateSelection;
|
||||
if (kpad->dpdCount == 1) {
|
||||
selected = select_1obj_first(kpad);
|
||||
if (selected != 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
selected = 0;
|
||||
updateSelection:
|
||||
selected = 0;
|
||||
} while (0);
|
||||
if (selected != 0) {
|
||||
f32 dy;
|
||||
f32 dx;
|
||||
|
||||
@@ -169,13 +169,15 @@ static inline char* __nupFindTag(char* response, const char* startTag, const cha
|
||||
char** value, size_t* length) {
|
||||
char* start;
|
||||
char* end;
|
||||
/* MWCC needs the tag searches in this short-circuit expression. */
|
||||
if (response == 0 || (start = strstr(response, startTag)) == 0 ||
|
||||
(end = strstr(start, endTag)) == 0) {
|
||||
return 0;
|
||||
}
|
||||
*value = start + strlen(startTag);
|
||||
*length = end - *value;
|
||||
return end + strlen(endTag);
|
||||
end += strlen(endTag);
|
||||
return end;
|
||||
}
|
||||
|
||||
static s32 __nupParseServerInfo(NUPContextInfo* context, char* response, char* messageId,
|
||||
@@ -265,6 +267,7 @@ static s32 __nupParseServerInfo(NUPContextInfo* context, char* response, char* m
|
||||
titleCount = 0;
|
||||
cursor = response;
|
||||
{
|
||||
/* MWCC needs both tag searches in the loop condition to preserve instruction order. */
|
||||
while ((cursor = __nupFindTag(cursor, "<TitleId>", "</TitleId>", &start, &valueLength)) != 0 &&
|
||||
(cursor = __nupFindTag(cursor, "<Version>", "</Version>", &start, &valueLength)) != 0) {
|
||||
titleCount++;
|
||||
@@ -284,6 +287,7 @@ static s32 __nupParseServerInfo(NUPContextInfo* context, char* response, char* m
|
||||
size_t titleLength;
|
||||
size_t versionLength;
|
||||
char* parsedEnd;
|
||||
/* MWCC needs both tag searches in the loop condition to preserve instruction order. */
|
||||
while ((cursor = __nupFindTag(cursor, "<TitleId>", "</TitleId>", &titleStart, &titleLength)) != 0 &&
|
||||
(cursor = __nupFindTag(cursor, "<Version>", "</Version>", &versionStart, &versionLength)) != 0) {
|
||||
unsigned long long titleId = strtoull(titleStart, &parsedEnd, 16);
|
||||
@@ -423,6 +427,7 @@ static s32 __nupGetTicketViews(ESTitleId titleId, ESTicketView** ticketViews, u3
|
||||
return result;
|
||||
}
|
||||
|
||||
/* MWCC must keep this helper out of line to match its callers. */
|
||||
#pragma dont_inline on
|
||||
static u32 __nupSetAuditState(u8 state) {
|
||||
const char* auditPath = "NUPAUDIT";
|
||||
@@ -617,6 +622,7 @@ done:
|
||||
return result;
|
||||
}
|
||||
|
||||
/* MWCC must keep this helper out of line to match its callers. */
|
||||
#pragma dont_inline on
|
||||
static s32 __nupGetTmdView(ESTitleId titleId, ESTmdView** tmdView) {
|
||||
u32 tmdViewSize;
|
||||
@@ -645,10 +651,9 @@ static inline BOOL __nupHasContent(const Title* title, ESContentId contentId) {
|
||||
if (title->contentCount == 0 || title->contentIds == 0) {
|
||||
return FALSE;
|
||||
}
|
||||
ESContentId* installedContent;
|
||||
u32 index;
|
||||
for (index = 0; index < title->contentCount; index++) {
|
||||
if (contentId == *(installedContent = &title->contentIds[index])) {
|
||||
if (contentId == title->contentIds[index]) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -660,10 +665,9 @@ static inline BOOL __nupHasInstalledContent(const ESTitleVersion* title, ESConte
|
||||
if (contentCount == 0 || title->contentIds == 0) {
|
||||
return FALSE;
|
||||
}
|
||||
ESContentId* installedContent;
|
||||
u32 index;
|
||||
for (index = 0; index < contentCount; index++) {
|
||||
if (contentId == *(installedContent = &title->contentIds[index])) {
|
||||
if (contentId == title->contentIds[index]) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -840,7 +844,7 @@ static s32 __nupGetTmd(NUPTitleInfo* title, char* contentPrefixUrl) {
|
||||
result = -5000;
|
||||
} else {
|
||||
result = ES_DiGetTmdView((ESTitleMeta*)title->tmd, title->tmdSize,
|
||||
(ESTmdView*)title->tmdView, &title->tmdViewSize);
|
||||
title->tmdView, &title->tmdViewSize);
|
||||
if (result != 0) {
|
||||
nup::__nupFree(title->tmdView);
|
||||
title->tmdView = 0;
|
||||
@@ -906,10 +910,10 @@ static s32 __nupGetContentFull(NUPContextInfo* context, NUPTitleInfo* title, cha
|
||||
char* url = 0;
|
||||
u8* response = 0;
|
||||
unsigned long responseSize = 0;
|
||||
tmdView = (ESTmdView*)title->tmdView;
|
||||
tmdView = title->tmdView;
|
||||
|
||||
for (contentIndex = 0; contentIndex < tmdView->head.numContents; contentIndex++) {
|
||||
if (contentId == ((ESTmdView*)title->tmdView)->contents[contentIndex].cid) {
|
||||
if (contentId == title->tmdView->contents[contentIndex].cid) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -953,11 +957,11 @@ static s32 __nupGetContentIncr(NUPContextInfo* context, NUPTitleInfo* title, cha
|
||||
if (url == 0) {
|
||||
result = -5000;
|
||||
} else {
|
||||
for (contentIndex = 0; contentIndex < ((ESTmdView*)title->tmdView)->head.numContents; contentIndex++) {
|
||||
ESContentId contentId = ((ESTmdView*)title->tmdView)->contents[contentIndex].cid;
|
||||
for (contentIndex = 0; contentIndex < title->tmdView->head.numContents; contentIndex++) {
|
||||
ESContentId contentId = title->tmdView->contents[contentIndex].cid;
|
||||
if (!__nupHasContent(title, contentId)) {
|
||||
snprintf(url, urlSize, "%s/%016llx/%08x", contentPrefixUrl, title->titleId, contentId);
|
||||
unsigned long contentSize = (u32)((((ESTmdView*)title->tmdView)->contents[contentIndex].size + 0xf) & 0xfffffffffffffff0ULL);
|
||||
unsigned long contentSize = (u32)((title->tmdView->contents[contentIndex].size + 0xf) & 0xfffffffffffffff0ULL);
|
||||
ESFd fd = ES_ImportContentBegin(title->titleId, contentId);
|
||||
result = fd;
|
||||
if (result < 0) {
|
||||
@@ -1020,6 +1024,7 @@ static void __nupCleanup(NUPContextInfo* context) {
|
||||
if (context->titles != 0) {
|
||||
for (u32 i = 0; i < context->titleCount; i++) {
|
||||
NUPTitleInfo* title = &context->titles[i];
|
||||
/* MWCC emits a separate null check before title cleanup. */
|
||||
if (title != 0) {
|
||||
__nupCleanupTitleInfo(title);
|
||||
}
|
||||
@@ -1071,7 +1076,7 @@ static s32 __nupUpdateTitle(NUPContextInfo* context, NUPTitleInfo* title, char*
|
||||
if (result != 0) {
|
||||
goto done;
|
||||
}
|
||||
ESTmdView* tmdView = (ESTmdView*)title->tmdView;
|
||||
ESTmdView* tmdView = title->tmdView;
|
||||
if (tmdView->head.numContents != 1) {
|
||||
result = -0x1389;
|
||||
goto done;
|
||||
@@ -1134,8 +1139,11 @@ static inline s32 __nupGetBoot2Version(u16* version) {
|
||||
s32 result = ES_GetBoot2Version(&bootVersion);
|
||||
if (result == 0) {
|
||||
u16 checkedVersion = bootVersion;
|
||||
if (checkedVersion != bootVersion) { result = -0x1389; }
|
||||
if (checkedVersion == bootVersion) { *version = checkedVersion; }
|
||||
if (checkedVersion != bootVersion) {
|
||||
result = -0x1389;
|
||||
} else {
|
||||
*version = checkedVersion;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -1322,7 +1330,7 @@ extern "C" void* __nupOp(void* argument) {
|
||||
}
|
||||
}
|
||||
if (menuTitle != 0 && menuTitle->updateRequired != 0) {
|
||||
ESTitleId requiredSystemTitle = ((ESTmdView*)menuTitle->tmdView)->head.sysVersion;
|
||||
ESTitleId requiredSystemTitle = menuTitle->tmdView->head.sysVersion;
|
||||
for (i = 0; i < context->titleCount; i++) {
|
||||
if (context->titles[i].titleId == requiredSystemTitle) {
|
||||
systemTitle = &context->titles[i];
|
||||
@@ -1389,7 +1397,8 @@ void* NUP_Init(MEMAllocator* allocator) {
|
||||
NUPContextInfo* context = (NUPContextInfo*)instance;
|
||||
OSInitMutex(&context->mutex);
|
||||
OSLockMutex(&context->mutex);
|
||||
context->progress.message = (context->progress.result = 1, __nupStatusMessage[1]);
|
||||
context->progress.result = 1;
|
||||
context->progress.message = __nupStatusMessage[1];
|
||||
OSUnlockMutex(&context->mutex);
|
||||
}
|
||||
}
|
||||
@@ -1443,6 +1452,7 @@ int NUP_Start(void* instance, const char* serverAddress, const char* countryCode
|
||||
if (result < 0) {
|
||||
OSLockMutex(&context->mutex);
|
||||
context->progress.result = result;
|
||||
/* MWCC retains these status alternatives under the negative-result guard. */
|
||||
if (result < 0) {
|
||||
context->progress.message = __nupStatusMessage[5];
|
||||
} else {
|
||||
|
||||
@@ -73,6 +73,7 @@ static u8* __nupNhttpBufFull(u8** buffer, unsigned long* length, unsigned long r
|
||||
if (state->error != 0) goto done;
|
||||
}
|
||||
next = *buffer;
|
||||
/* MWCC needs the switch's extra branch around buffer allocation. */
|
||||
switch ((u32)next) {
|
||||
case 0: {
|
||||
requested = NhttpBufferSize(requested);
|
||||
@@ -142,6 +143,7 @@ static int __nupNhttpOp(char* url, NHTTPReqMethod method, char* headers, u8* bod
|
||||
char* field = headerCopy;
|
||||
char* colon;
|
||||
char* end;
|
||||
/* MWCC needs the header searches in this loop condition to preserve instruction order. */
|
||||
while (*field != 0 && (colon = strchr(field, ':')) != NULL && (end = strstr(colon, "\r\n")) != NULL) {
|
||||
*colon = 0;
|
||||
*end = 0;
|
||||
@@ -194,7 +196,6 @@ static int __nupNhttpOp(char* url, NHTTPReqMethod method, char* headers, u8* bod
|
||||
goto cleanup;
|
||||
}
|
||||
if (status != 200 && status != 202) result = -5000 - status;
|
||||
goto cleanup;
|
||||
cleanup:
|
||||
if (state.response != NULL || result == -5009) NHTTPDestroyResponse(state.response);
|
||||
if (headerCopy != NULL) nup::__nupFree(headerCopy);
|
||||
@@ -233,6 +234,7 @@ static long __nupHttpStringFlush(u8* data, unsigned long length, unsigned long r
|
||||
return AppendHttpString(length, data, requested, (HttpString*)context);
|
||||
}
|
||||
}
|
||||
/* MWCC must keep this helper out of line to match its callers. */
|
||||
static int __nupNhttpOpString(u8** output, unsigned long* outputLength, char* url, NHTTPReqMethod method, char* headers, u8* body, unsigned long bodyLength, unsigned long limit, ProgressCallback progress, void* context) NO_INLINE;
|
||||
static int __nupNhttpOpString(u8** output, unsigned long* outputLength, char* url, NHTTPReqMethod method, char* headers, u8* body, unsigned long bodyLength, unsigned long limit, ProgressCallback progress, void* context) {
|
||||
HttpString text;
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -264,18 +264,17 @@ static void CloseCallbackFromReload(s32 result, NANDCommandBlock* block) {
|
||||
static void FinishFromReload() {
|
||||
SCStatus status;
|
||||
|
||||
_openFile:
|
||||
Control.openFileType++;
|
||||
|
||||
if (Control.openFileType < SC_CONF_FILE_MAX) {
|
||||
for (;;) {
|
||||
Control.openFileType++;
|
||||
if (Control.openFileType >= SC_CONF_FILE_MAX) {
|
||||
break;
|
||||
}
|
||||
Control.isFileOpen = FALSE;
|
||||
|
||||
if (NANDPrivateOpenAsync(Control.filePaths[Control.openFileType], &Control.fileInfo, NAND_ACCESS_READ, OpenCallbackFromReload,
|
||||
&Control.commandBlock) == NAND_RESULT_OK) {
|
||||
return;
|
||||
}
|
||||
|
||||
goto _openFile;
|
||||
}
|
||||
|
||||
switch (Control.asyncResult) {
|
||||
@@ -293,7 +292,7 @@ _openFile:
|
||||
}
|
||||
}
|
||||
|
||||
*(u8*)((u8*)OSPhysicalToCached(SC_CONFIG_FILE_PHYS_ADDRESS) + SC_CONFIG_FILE_LENGTH - 1) = '\0';
|
||||
((u8*)OSPhysicalToCached(SC_CONFIG_FILE_PHYS_ADDRESS))[SC_CONFIG_FILE_LENGTH - 1] = '\0';
|
||||
|
||||
if (Control.asyncCallback != NULL) {
|
||||
Control.asyncCallback(Control.asyncResult);
|
||||
@@ -442,6 +441,7 @@ static SCStatus ParseConfBuf(u8* conf, u32 size) {
|
||||
|
||||
// Build lookup table
|
||||
|
||||
// MWCC needs the name load in this loop condition to preserve scheduling.
|
||||
for (tblEnd = &tblIter[ItemIDMaxPlus1]; tblIter < tblEnd && (itName = tblIter->name) != (void*)NULL; tblIter++) {
|
||||
u32 itNameLen = strlen(itName);
|
||||
|
||||
@@ -726,6 +726,7 @@ static BOOL CreateItemByID(SCItemID id, u8 primType, const void* src, u32 len) {
|
||||
|
||||
itemSize += len;
|
||||
|
||||
// MWCC needs the name load in this loop condition to preserve both branches.
|
||||
for (; (itemName = it->name) != (void*)NULL; it++) {
|
||||
if (it->id == id) {
|
||||
break;
|
||||
@@ -1011,6 +1012,7 @@ void SCFlushAsync(SCFlushCallback callback) {
|
||||
static void MyNandCallback(s32 result, NANDCommandBlock* block) {
|
||||
SCControl* ctrl = &Control;
|
||||
|
||||
// MWCC needs shared switch paths to preserve branch layout.
|
||||
switch (ctrl->nandCbState) {
|
||||
case NAND_CB_STATE_GET_STATUS: {
|
||||
if (result == NAND_RESULT_OK && ctrl->fileType == NAND_TYPE_FILE) {
|
||||
@@ -1020,15 +1022,15 @@ static void MyNandCallback(s32 result, NANDCommandBlock* block) {
|
||||
goto _error;
|
||||
}
|
||||
} else {
|
||||
goto _case_1_lbl;
|
||||
goto deleteFile;
|
||||
}
|
||||
return;
|
||||
}
|
||||
case NAND_CB_STATE_DELETE: {
|
||||
if (result == NAND_RESULT_OK && ctrl->fileAttr.permission == NAND_PERM_ALL_RW) {
|
||||
goto _case_5_lbl;
|
||||
goto openFile;
|
||||
}
|
||||
_case_1_lbl:
|
||||
deleteFile:
|
||||
ctrl->nandCbState = NAND_CB_STATE_GET_TYPE;
|
||||
|
||||
if (NANDPrivateDeleteAsync(ConfFileName, MyNandCallback, &ctrl->commandBlock) != NAND_RESULT_OK) {
|
||||
@@ -1045,19 +1047,17 @@ static void MyNandCallback(s32 result, NANDCommandBlock* block) {
|
||||
return;
|
||||
}
|
||||
case NAND_CB_STATE_CREATE_DIR: {
|
||||
if (result == NAND_RESULT_OK && ctrl->fileType == NAND_TYPE_DIR) {
|
||||
goto _case_4_lbl;
|
||||
}
|
||||
if (result != NAND_RESULT_OK || ctrl->fileType != NAND_TYPE_DIR) {
|
||||
ctrl->nandCbState = NAND_CB_STATE_CREATE_FILE;
|
||||
|
||||
ctrl->nandCbState = NAND_CB_STATE_CREATE_FILE;
|
||||
|
||||
if (NANDPrivateCreateDirAsync(ConfDirName, NAND_PERM_ALL_RW, 0, MyNandCallback, &ctrl->commandBlock) != NAND_RESULT_OK) {
|
||||
goto _error;
|
||||
if (NANDPrivateCreateDirAsync(ConfDirName, NAND_PERM_ALL_RW, 0, MyNandCallback, &ctrl->commandBlock) != NAND_RESULT_OK) {
|
||||
goto _error;
|
||||
}
|
||||
return;
|
||||
}
|
||||
return;
|
||||
// FALLTHROUGH
|
||||
}
|
||||
case NAND_CB_STATE_CREATE_FILE: {
|
||||
_case_4_lbl:
|
||||
ctrl->nandCbState = NAND_CB_STATE_OPEN_FILE;
|
||||
if (NANDPrivateCreateAsync(ConfFileName, NAND_PERM_ALL_RW, 0, MyNandCallback, &ctrl->commandBlock) != NAND_RESULT_OK) {
|
||||
goto _error;
|
||||
@@ -1065,7 +1065,7 @@ static void MyNandCallback(s32 result, NANDCommandBlock* block) {
|
||||
return;
|
||||
}
|
||||
case NAND_CB_STATE_OPEN_FILE: {
|
||||
_case_5_lbl:
|
||||
openFile:
|
||||
ctrl->nandCbState = NAND_CB_STATE_WRITE_FILE;
|
||||
if (NANDPrivateOpenAsync(ConfFileName, &ctrl->fileInfo, NAND_ACCESS_WRITE, MyNandCallback, &ctrl->commandBlock) != NAND_RESULT_OK) {
|
||||
goto _error;
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#pragma sym on
|
||||
|
||||
#define SD_SLOT_0_PATH "/dev/sdio/slot0"
|
||||
#define SD_SLOT_1_PATH "/dev/sdio/slot1"
|
||||
#define SD_SLOT_W_PATH "/dev/sdio/slotw"
|
||||
@@ -591,27 +589,32 @@ ISD_Error ISD_InitCard() {
|
||||
goto out;
|
||||
}
|
||||
|
||||
if ((__sdCmdBuffer = iosAlloc(__sdHeapId[0], 0x20)) == 0) {
|
||||
__sdCmdBuffer = iosAlloc(__sdHeapId[0], 0x20);
|
||||
if (__sdCmdBuffer == 0) {
|
||||
ret = IPC_RESULT_ALLOC_FAILED;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if ((__sdResp = iosAlloc(__sdHeapId[0], 0x20)) == 0) {
|
||||
__sdResp = iosAlloc(__sdHeapId[0], 0x20);
|
||||
if (__sdResp == 0) {
|
||||
ret = IPC_RESULT_ALLOC_FAILED;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if ((__sdResp2 = iosAlloc(__sdHeapId[0], 0x20)) == 0) {
|
||||
__sdResp2 = iosAlloc(__sdHeapId[0], 0x20);
|
||||
if (__sdResp2 == 0) {
|
||||
ret = IPC_RESULT_ALLOC_FAILED;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if ((__sdReg = iosAlloc(__sdHeapId[0], 0x20)) == 0) {
|
||||
__sdReg = iosAlloc(__sdHeapId[0], 0x20);
|
||||
if (__sdReg == 0) {
|
||||
ret = IPC_RESULT_ALLOC_FAILED;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if ((__sdVect = iosAlloc(__sdHeapId[0], 0x60)) == 0) {
|
||||
__sdVect = iosAlloc(__sdHeapId[0], 0x60);
|
||||
if (__sdVect == 0) {
|
||||
ret = IPC_RESULT_ALLOC_FAILED;
|
||||
goto out;
|
||||
}
|
||||
|
||||
@@ -334,7 +334,8 @@ IOSError IUSB_GetDeviceList(const char* path, USBDeviceInfo* deviceList, u8 maxD
|
||||
rv = IPC_RESULT_INVALID;
|
||||
goto out;
|
||||
}
|
||||
if ((fd = __openDevice(path)) < 0) {
|
||||
fd = __openDevice(path);
|
||||
if (fd < 0) {
|
||||
rv = fd;
|
||||
goto out;
|
||||
}
|
||||
@@ -658,7 +659,8 @@ static void _GetStrCb(IOSError ret, void* ctxt) {
|
||||
buf = (char*)req->msg.buffer;
|
||||
buflen = req->msg.length;
|
||||
USB_LOG("GetStrCb: buf = 0x%x buflen = %u\n", buf, buflen);
|
||||
if ((len = unicode2ascii(buf, buflen)) < 0)
|
||||
len = unicode2ascii(buf, buflen);
|
||||
if (len < 0)
|
||||
USB_ERR("Failed to convert buffer from unicode 2 ascii\n");
|
||||
else
|
||||
buf[len] = '\0';
|
||||
@@ -684,7 +686,8 @@ IOSError IUSB_GetAsciiStr(IOSFd fd, u8 ep, u16 index, u16 langId, char* buf, u16
|
||||
USB_ERR("Failed __CtrlMsg: %d", rv);
|
||||
goto out;
|
||||
}
|
||||
if ((len = unicode2ascii(buf, buflen)) < 0)
|
||||
len = unicode2ascii(buf, buflen);
|
||||
if (len < 0)
|
||||
USB_ERR("Failed to convert unicode 2 ascii\n");
|
||||
else
|
||||
buf[len] = '\0';
|
||||
@@ -912,7 +915,8 @@ IOSError IUSB_DeviceInsertionNotifyAsync(const char* path, u16 vid, u16 pid, USB
|
||||
rv = IPC_RESULT_INVALID;
|
||||
goto done;
|
||||
}
|
||||
if ((fd = IOS_Open(path, 0)) < 0) {
|
||||
fd = IOS_Open(path, 0);
|
||||
if (fd < 0) {
|
||||
rv = fd;
|
||||
USB_ERR("Open(%s) failed\n", path);
|
||||
goto done;
|
||||
@@ -975,7 +979,8 @@ IOSError IUSB_DeviceClassInsertionNotifyAsync(const char* path, u8 devClass, USB
|
||||
rv = IPC_RESULT_INVALID;
|
||||
goto done;
|
||||
}
|
||||
if ((fd = IOS_Open(path, 0)) < 0) {
|
||||
fd = IOS_Open(path, 0);
|
||||
if (fd < 0) {
|
||||
rv = fd;
|
||||
OSReport("Open(%s) failed\n", path);
|
||||
goto done;
|
||||
|
||||
@@ -34,11 +34,11 @@ typedef struct WADBroadOnHeader {
|
||||
u32 headerSize;
|
||||
u32 contentOffset;
|
||||
u32 certSize;
|
||||
u32 crlSize;
|
||||
u32 ticketSize;
|
||||
u32 titleMetaSize;
|
||||
u32 metaSize;
|
||||
u32 contentSize;
|
||||
u32 fileListSize;
|
||||
u32 crlSize;
|
||||
} WADBroadOnHeader;
|
||||
|
||||
typedef struct WADUnpackInfo {
|
||||
@@ -46,22 +46,22 @@ typedef struct WADUnpackInfo {
|
||||
s32 headerInfo;
|
||||
u16 cidxMode;
|
||||
u8 reserved_0x0a[2];
|
||||
u32 size_0x0c;
|
||||
u32 offset_0x10;
|
||||
void* buffer_0x14;
|
||||
u32 size_0x18;
|
||||
u32 size_0x1c;
|
||||
u32 offset_0x20;
|
||||
void* buffer_0x24;
|
||||
u32 size_0x28;
|
||||
u32 size_0x2c;
|
||||
u32 offset_0x30;
|
||||
void* buffer_0x34;
|
||||
u32 size_0x38;
|
||||
u32 sectionSize;
|
||||
u32 sectionOffset;
|
||||
ESTitleMeta* titleMeta;
|
||||
u32 certificateSize;
|
||||
u32 certificateOffset;
|
||||
void* certificates;
|
||||
u32 certificatesAllocated;
|
||||
u32 crlSize;
|
||||
u32 crlOffset;
|
||||
void* crls;
|
||||
u32 crlsAllocated;
|
||||
u32 ticketSize;
|
||||
u32 ticketOffset;
|
||||
void* ticket;
|
||||
u32 ticketAllocated;
|
||||
u32 titleMetaSize;
|
||||
u32 titleMetaOffset;
|
||||
ESTitleMeta* titleMeta;
|
||||
u32 titleMetaAllocated;
|
||||
u32 contentSize;
|
||||
u32 contentOffset;
|
||||
u32 metaSize;
|
||||
@@ -69,7 +69,7 @@ typedef struct WADUnpackInfo {
|
||||
u32 fileListSize;
|
||||
u32 fileOffset;
|
||||
u32 fileCount;
|
||||
void* contentIndex;
|
||||
ESContentMask* contentIndex;
|
||||
void* fileNames;
|
||||
} WADUnpackInfo;
|
||||
|
||||
@@ -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;
|
||||
@@ -399,6 +401,7 @@ s32 WADImportGetBlocks(char* path, MEMAllocator* allocator, WADLocation location
|
||||
s32 result;
|
||||
BOOL streamOpened;
|
||||
u32 index;
|
||||
/* MWCC needs these buffer lifetimes to preserve the original cleanup branches. */
|
||||
void* secondBuffer;
|
||||
void* firstBuffer;
|
||||
WADFileEntry* allocatedFiles;
|
||||
@@ -437,7 +440,7 @@ s32 WADImportGetBlocks(char* path, MEMAllocator* allocator, WADLocation location
|
||||
titleMeta = workspace.unpackInfo.titleMeta;
|
||||
if (titleMeta != 0) {
|
||||
if (skipTitleMeta == 0) {
|
||||
blocks->unkBlocks += (workspace.unpackInfo.sectionSize + 0x3FFF) >> 14;
|
||||
blocks->unkBlocks += (workspace.unpackInfo.titleMetaSize + 0x3FFF) >> 14;
|
||||
blocks->unkInodes = 1;
|
||||
}
|
||||
if (workspace.unpackInfo.cidxMode >= 1) {
|
||||
@@ -689,24 +692,24 @@ s32 WADImportEx(char* path, MEMAllocator* allocator, WADLocation location, u32 o
|
||||
goto cleanup;
|
||||
}
|
||||
result = 0;
|
||||
result = ES_ImportBoot(unpackInfo.buffer_0x34,
|
||||
unpackInfo.buffer_0x14,
|
||||
unpackInfo.size_0x0c,
|
||||
result = ES_ImportBoot(unpackInfo.ticket,
|
||||
unpackInfo.certificates,
|
||||
unpackInfo.certificateSize,
|
||||
unpackInfo.titleMeta,
|
||||
unpackInfo.sectionSize,
|
||||
unpackInfo.buffer_0x14,
|
||||
unpackInfo.size_0x0c,
|
||||
unpackInfo.buffer_0x24,
|
||||
unpackInfo.size_0x1c, readBuffer,
|
||||
unpackInfo.titleMetaSize,
|
||||
unpackInfo.certificates,
|
||||
unpackInfo.certificateSize,
|
||||
unpackInfo.crls,
|
||||
unpackInfo.crlSize, readBuffer,
|
||||
size);
|
||||
goto cleanup;
|
||||
}
|
||||
if (unpackInfo.buffer_0x34 != 0) {
|
||||
result = ES_ImportTicket(unpackInfo.buffer_0x34,
|
||||
unpackInfo.buffer_0x14,
|
||||
unpackInfo.size_0x0c,
|
||||
unpackInfo.buffer_0x24,
|
||||
unpackInfo.size_0x1c, unpackInfo.headerInfo);
|
||||
if (unpackInfo.ticket != 0) {
|
||||
result = ES_ImportTicket(unpackInfo.ticket,
|
||||
unpackInfo.certificates,
|
||||
unpackInfo.certificateSize,
|
||||
unpackInfo.crls,
|
||||
unpackInfo.crlSize, unpackInfo.headerInfo);
|
||||
if (result != 0) {
|
||||
goto cleanup;
|
||||
}
|
||||
@@ -726,7 +729,7 @@ s32 WADImportEx(char* path, MEMAllocator* allocator, WADLocation location, u32 o
|
||||
contentCount = titleMeta->head.numContents;
|
||||
}
|
||||
result = ES_ListTmdContentsOnCard(titleMeta,
|
||||
unpackInfo.sectionSize, 0,
|
||||
unpackInfo.titleMetaSize, 0,
|
||||
&installedContentCount);
|
||||
if ((result == 0) && (installedContentCount != 0)) {
|
||||
installedContentIds = _WADMemAlloc(allocator, installedContentCount * sizeof(ESContentId));
|
||||
@@ -735,21 +738,22 @@ s32 WADImportEx(char* path, MEMAllocator* allocator, WADLocation location, u32 o
|
||||
goto cleanup;
|
||||
}
|
||||
result = ES_ListTmdContentsOnCard(titleMeta,
|
||||
unpackInfo.sectionSize,
|
||||
unpackInfo.titleMetaSize,
|
||||
installedContentIds, &installedContentCount);
|
||||
if ((result == 0) &&
|
||||
((result = ES_GetTmd(titleMeta->head.titleId, 0,
|
||||
&installedTmdSize)) == 0)) {
|
||||
alignedSize = (installedTmdSize + 0x1F) & ~0x1F;
|
||||
installedTitleMeta = _WADMemAlloc(allocator, alignedSize);
|
||||
if (installedTitleMeta == 0) {
|
||||
result = -3003;
|
||||
goto cleanup;
|
||||
}
|
||||
result = ES_GetTmd(titleMeta->head.titleId,
|
||||
installedTitleMeta, &installedTmdSize);
|
||||
if (result == 0) {
|
||||
result = ES_GetTmd(titleMeta->head.titleId, 0, &installedTmdSize);
|
||||
if (result == 0) {
|
||||
importExistingTitle = FALSE;
|
||||
alignedSize = (installedTmdSize + 0x1F) & ~0x1F;
|
||||
installedTitleMeta = _WADMemAlloc(allocator, alignedSize);
|
||||
if (installedTitleMeta == 0) {
|
||||
result = -3003;
|
||||
goto cleanup;
|
||||
}
|
||||
result = ES_GetTmd(titleMeta->head.titleId,
|
||||
installedTitleMeta, &installedTmdSize);
|
||||
if (result == 0) {
|
||||
importExistingTitle = FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -787,11 +791,11 @@ s32 WADImportEx(char* path, MEMAllocator* allocator, WADLocation location, u32 o
|
||||
}
|
||||
}
|
||||
result = ES_ImportTitleInit(titleMeta,
|
||||
unpackInfo.sectionSize,
|
||||
unpackInfo.buffer_0x14,
|
||||
unpackInfo.size_0x0c,
|
||||
unpackInfo.buffer_0x24,
|
||||
unpackInfo.size_0x1c,
|
||||
unpackInfo.titleMetaSize,
|
||||
unpackInfo.certificates,
|
||||
unpackInfo.certificateSize,
|
||||
unpackInfo.crls,
|
||||
unpackInfo.crlSize,
|
||||
unpackInfo.headerInfo, 1);
|
||||
if (result != 0) {
|
||||
goto cleanup;
|
||||
@@ -1644,7 +1648,7 @@ s32 WADBackupEx(u64 titleId, u32 flags, MEMAllocator* allocator, char* path, u32
|
||||
streamResult = WADWriteStream(&stream, fileHeaderBuffer, size);
|
||||
if ((u32)streamResult != size) {
|
||||
result = -3006;
|
||||
goto file_done;
|
||||
goto cleanupFile;
|
||||
}
|
||||
result = 0;
|
||||
importedSize += sizeof(WADBackupHeaderBlock);
|
||||
@@ -1655,7 +1659,7 @@ s32 WADBackupEx(u64 titleId, u32 flags, MEMAllocator* allocator, char* path, u32
|
||||
result = NANDPrivateOpen(fileHeaderBuffer->name, &savedFile, NAND_ACCESS_READ);
|
||||
fileOpened = TRUE;
|
||||
if (result != 0) {
|
||||
goto file_done;
|
||||
goto cleanupFile;
|
||||
}
|
||||
byteCount = (fileHeaderBuffer->fileSize + 0x1F) & ~0x1F;
|
||||
while (byteCount != 0) {
|
||||
@@ -1667,13 +1671,13 @@ s32 WADBackupEx(u64 titleId, u32 flags, MEMAllocator* allocator, char* path, u32
|
||||
length = NANDRead(&savedFile, encryptionBuffer, size);
|
||||
if (((length + 0x1F) & ~0x1F) != size) {
|
||||
result = -3005;
|
||||
goto file_done;
|
||||
goto cleanupFile;
|
||||
}
|
||||
result = 0;
|
||||
result = ES_Encrypt(6, fileHeaderBuffer->iv, encryptionBuffer, size,
|
||||
outputBuffer);
|
||||
if (result != 0) {
|
||||
goto file_done;
|
||||
goto cleanupFile;
|
||||
}
|
||||
result = SHA1Input(hashContext, outputBuffer, size);
|
||||
if (result != 0) {
|
||||
@@ -1682,7 +1686,7 @@ s32 WADBackupEx(u64 titleId, u32 flags, MEMAllocator* allocator, char* path, u32
|
||||
streamResult = WADWriteStream(&stream, outputBuffer, size);
|
||||
if ((u32)streamResult != size) {
|
||||
result = -3006;
|
||||
goto file_done;
|
||||
goto cleanupFile;
|
||||
}
|
||||
result = 0;
|
||||
importedSize += size;
|
||||
@@ -1694,7 +1698,7 @@ s32 WADBackupEx(u64 titleId, u32 flags, MEMAllocator* allocator, char* path, u32
|
||||
result = NANDClose(&savedFile);
|
||||
fileOpened = FALSE;
|
||||
if (result != 0) {
|
||||
goto file_done;
|
||||
goto cleanupFile;
|
||||
}
|
||||
{
|
||||
u32 roundedSize = (fileHeaderBuffer->fileSize + 0x1F) & ~0x1F;
|
||||
@@ -1711,7 +1715,7 @@ s32 WADBackupEx(u64 titleId, u32 flags, MEMAllocator* allocator, char* path, u32
|
||||
size);
|
||||
if ((u32)streamResult != size) {
|
||||
result = -3006;
|
||||
goto file_done;
|
||||
goto cleanupFile;
|
||||
}
|
||||
result = 0;
|
||||
importedSize += size;
|
||||
@@ -1723,7 +1727,7 @@ s32 WADBackupEx(u64 titleId, u32 flags, MEMAllocator* allocator, char* path, u32
|
||||
} else if (fileHeaderBuffer->flags[2] == NAND_TYPE_FILE) {
|
||||
byteCount = 0;
|
||||
}
|
||||
file_done:
|
||||
cleanupFile:
|
||||
if (fileOpened) {
|
||||
NANDClose(&savedFile);
|
||||
}
|
||||
@@ -1863,7 +1867,7 @@ static s32 _WADCheckContents(ESTmdView* titleMeta, ESContentMask* contentMask) {
|
||||
if (installedIndex == installedContentCount) {
|
||||
if ((titleMeta->contents[contentIndex].type & 0x4000) == 0) {
|
||||
result = -3002;
|
||||
goto done;
|
||||
break;
|
||||
}
|
||||
result = 0;
|
||||
}
|
||||
@@ -1871,10 +1875,10 @@ static s32 _WADCheckContents(ESTmdView* titleMeta, ESContentMask* contentMask) {
|
||||
}
|
||||
}
|
||||
}
|
||||
done:
|
||||
return result;
|
||||
}
|
||||
|
||||
/* MWCC keeps allocator calls out of line in the original callers. */
|
||||
#pragma dont_inline on
|
||||
static void* _WADMemAlloc(MEMAllocator* allocator, u32 size) {
|
||||
s32 allocationKind;
|
||||
@@ -1992,7 +1996,6 @@ s32 WADOpenStream(WADLocation location, const char* path, WADStream* stream, u32
|
||||
|
||||
case WAD_LOCATION_DVD:
|
||||
{
|
||||
s32 result;
|
||||
if (write != 0) {
|
||||
return -3004;
|
||||
}
|
||||
@@ -2298,7 +2301,6 @@ static s32 WAD_815C2F44(WADHeader* header, s32* headerInfo) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#pragma dont_inline on
|
||||
static s32 _WADUnpack(void* header, WADStream* stream, WADUnpackInfo* info, MEMAllocator* allocator,
|
||||
u32 offset, u32 flags, u32 mode) {
|
||||
s32 result;
|
||||
@@ -2325,7 +2327,6 @@ static s32 _WADUnpack(void* header, WADStream* stream, WADUnpackInfo* info, MEMA
|
||||
}
|
||||
return result;
|
||||
}
|
||||
#pragma dont_inline reset
|
||||
|
||||
static s32 _WADUnpackIRD(WADHeader* header, WADStream* stream, WADUnpackInfo* info,
|
||||
MEMAllocator* allocator, u32 offset, u32 mode) {
|
||||
@@ -2356,17 +2357,17 @@ static s32 _WADUnpackIRD(WADHeader* header, WADStream* stream, WADUnpackInfo* in
|
||||
|
||||
sectionSize = header->certSize;
|
||||
if (sectionSize != 0) {
|
||||
info->size_0x0c = sectionSize;
|
||||
info->offset_0x10 = sectionOffset;
|
||||
info->certificateSize = sectionSize;
|
||||
info->certificateOffset = sectionOffset;
|
||||
if (mode == 0) {
|
||||
alignedSize = WAD_ALIGN32(sectionSize);
|
||||
info->buffer_0x14 = _WADMemAlloc(allocator, alignedSize);
|
||||
if (info->buffer_0x14 == 0) {
|
||||
info->certificates = _WADMemAlloc(allocator, alignedSize);
|
||||
if (info->certificates == 0) {
|
||||
return -3003;
|
||||
}
|
||||
info->size_0x18 = 1;
|
||||
bytesRead = WADReadStream(stream, &info->buffer_0x14, alignedSize,
|
||||
offset + info->offset_0x10);
|
||||
info->certificatesAllocated = 1;
|
||||
bytesRead = WADReadStream(stream, &info->certificates, alignedSize,
|
||||
offset + info->certificateOffset);
|
||||
if (bytesRead != alignedSize) {
|
||||
return -3005;
|
||||
}
|
||||
@@ -2375,17 +2376,17 @@ static s32 _WADUnpackIRD(WADHeader* header, WADStream* stream, WADUnpackInfo* in
|
||||
}
|
||||
sectionSize = header->crlSize;
|
||||
if (sectionSize != 0) {
|
||||
info->size_0x1c = sectionSize;
|
||||
info->offset_0x20 = sectionOffset;
|
||||
info->crlSize = sectionSize;
|
||||
info->crlOffset = sectionOffset;
|
||||
if (mode == 0) {
|
||||
alignedSize = WAD_ALIGN32(sectionSize);
|
||||
info->buffer_0x24 = _WADMemAlloc(allocator, alignedSize);
|
||||
if (info->buffer_0x24 == 0) {
|
||||
info->crls = _WADMemAlloc(allocator, alignedSize);
|
||||
if (info->crls == 0) {
|
||||
return -3003;
|
||||
}
|
||||
info->size_0x28 = 1;
|
||||
bytesRead = WADReadStream(stream, &info->buffer_0x24, alignedSize,
|
||||
offset + info->offset_0x20);
|
||||
info->crlsAllocated = 1;
|
||||
bytesRead = WADReadStream(stream, &info->crls, alignedSize,
|
||||
offset + info->crlOffset);
|
||||
if (bytesRead != alignedSize) {
|
||||
return -3005;
|
||||
}
|
||||
@@ -2394,17 +2395,17 @@ static s32 _WADUnpackIRD(WADHeader* header, WADStream* stream, WADUnpackInfo* in
|
||||
}
|
||||
sectionSize = header->ticketSize;
|
||||
if (sectionSize != 0) {
|
||||
info->size_0x2c = sectionSize;
|
||||
info->offset_0x30 = sectionOffset;
|
||||
info->ticketSize = sectionSize;
|
||||
info->ticketOffset = sectionOffset;
|
||||
if (mode == 0) {
|
||||
alignedSize = WAD_ALIGN32(sectionSize);
|
||||
info->buffer_0x34 = _WADMemAlloc(allocator, alignedSize);
|
||||
if (info->buffer_0x34 == 0) {
|
||||
info->ticket = _WADMemAlloc(allocator, alignedSize);
|
||||
if (info->ticket == 0) {
|
||||
return -3003;
|
||||
}
|
||||
info->size_0x38 = 1;
|
||||
bytesRead = WADReadStream(stream, &info->buffer_0x34, alignedSize,
|
||||
offset + info->offset_0x30);
|
||||
info->ticketAllocated = 1;
|
||||
bytesRead = WADReadStream(stream, &info->ticket, alignedSize,
|
||||
offset + info->ticketOffset);
|
||||
if (bytesRead != alignedSize) {
|
||||
return -3005;
|
||||
}
|
||||
@@ -2413,16 +2414,16 @@ static s32 _WADUnpackIRD(WADHeader* header, WADStream* stream, WADUnpackInfo* in
|
||||
}
|
||||
sectionSize = header->tmdSize;
|
||||
if (sectionSize != 0) {
|
||||
info->sectionSize = sectionSize;
|
||||
info->sectionOffset = sectionOffset;
|
||||
info->titleMetaSize = sectionSize;
|
||||
info->titleMetaOffset = sectionOffset;
|
||||
alignedSize = WAD_ALIGN32(sectionSize);
|
||||
info->titleMeta = _WADMemAlloc(allocator, alignedSize);
|
||||
if (info->titleMeta == 0) {
|
||||
return -3003;
|
||||
}
|
||||
info->titleMetaSize = 1;
|
||||
info->titleMetaAllocated = 1;
|
||||
bytesRead = WADReadStream(stream, (void**)&info->titleMeta, alignedSize,
|
||||
offset + info->sectionOffset);
|
||||
offset + info->titleMetaOffset);
|
||||
if (bytesRead != alignedSize) {
|
||||
return -3005;
|
||||
}
|
||||
@@ -2447,24 +2448,24 @@ static s32 _WADUnpackBroadOn(WADBroadOnHeader* header, WADStream* stream, WADUnp
|
||||
s32 alignedSize;
|
||||
s32 bytesRead;
|
||||
|
||||
if ((header->crlSize == 0) && (header->ticketSize == 0)) {
|
||||
if ((header->ticketSize == 0) && (header->titleMetaSize == 0)) {
|
||||
return -3001;
|
||||
}
|
||||
|
||||
currentOffset = header->headerSize;
|
||||
sectionSize = header->certSize;
|
||||
if (sectionSize != 0) {
|
||||
info->size_0x0c = sectionSize;
|
||||
info->offset_0x10 = currentOffset;
|
||||
info->certificateSize = sectionSize;
|
||||
info->certificateOffset = currentOffset;
|
||||
if (mode == 0) {
|
||||
alignedSize = WAD_ALIGN32(sectionSize);
|
||||
info->buffer_0x14 = _WADMemAlloc(allocator, alignedSize);
|
||||
if (info->buffer_0x14 == 0) {
|
||||
info->certificates = _WADMemAlloc(allocator, alignedSize);
|
||||
if (info->certificates == 0) {
|
||||
return -3003;
|
||||
}
|
||||
info->size_0x18 = 1;
|
||||
bytesRead = WADReadStream(stream, &info->buffer_0x14, alignedSize,
|
||||
offset + info->offset_0x10);
|
||||
info->certificatesAllocated = 1;
|
||||
bytesRead = WADReadStream(stream, &info->certificates, alignedSize,
|
||||
offset + info->certificateOffset);
|
||||
if (bytesRead != alignedSize) {
|
||||
return -3005;
|
||||
}
|
||||
@@ -2472,64 +2473,64 @@ static s32 _WADUnpackBroadOn(WADBroadOnHeader* header, WADStream* stream, WADUnp
|
||||
currentOffset += header->certSize;
|
||||
}
|
||||
|
||||
sectionSize = header->crlSize;
|
||||
sectionSize = header->ticketSize;
|
||||
if (sectionSize != 0) {
|
||||
info->size_0x2c = sectionSize;
|
||||
info->offset_0x30 = currentOffset;
|
||||
info->ticketSize = sectionSize;
|
||||
info->ticketOffset = currentOffset;
|
||||
if (mode == 0) {
|
||||
alignedSize = WAD_ALIGN32(sectionSize);
|
||||
info->buffer_0x34 = _WADMemAlloc(allocator, alignedSize);
|
||||
if (info->buffer_0x34 == 0) {
|
||||
info->ticket = _WADMemAlloc(allocator, alignedSize);
|
||||
if (info->ticket == 0) {
|
||||
return -3003;
|
||||
}
|
||||
info->size_0x38 = 1;
|
||||
bytesRead = WADReadStream(stream, &info->buffer_0x34, alignedSize,
|
||||
offset + info->offset_0x30);
|
||||
info->ticketAllocated = 1;
|
||||
bytesRead = WADReadStream(stream, &info->ticket, alignedSize,
|
||||
offset + info->ticketOffset);
|
||||
if (bytesRead != alignedSize) {
|
||||
return -3005;
|
||||
}
|
||||
}
|
||||
currentOffset += header->crlSize;
|
||||
}
|
||||
|
||||
sectionSize = header->ticketSize;
|
||||
if (sectionSize != 0) {
|
||||
info->sectionSize = sectionSize;
|
||||
info->sectionOffset = currentOffset;
|
||||
alignedSize = WAD_ALIGN32(sectionSize);
|
||||
info->titleMeta = _WADMemAlloc(allocator, alignedSize);
|
||||
if (info->titleMeta == 0) {
|
||||
return -3003;
|
||||
}
|
||||
info->titleMetaSize = 1;
|
||||
bytesRead = WADReadStream(stream, (void**)&info->titleMeta, alignedSize,
|
||||
offset + info->sectionOffset);
|
||||
if (bytesRead != alignedSize) {
|
||||
return -3005;
|
||||
}
|
||||
currentOffset += header->ticketSize;
|
||||
}
|
||||
|
||||
sectionSize = header->titleMetaSize;
|
||||
if (sectionSize != 0) {
|
||||
info->metaSize = sectionSize;
|
||||
info->metaOffset = currentOffset;
|
||||
info->titleMetaSize = sectionSize;
|
||||
info->titleMetaOffset = currentOffset;
|
||||
alignedSize = WAD_ALIGN32(sectionSize);
|
||||
info->titleMeta = _WADMemAlloc(allocator, alignedSize);
|
||||
if (info->titleMeta == 0) {
|
||||
return -3003;
|
||||
}
|
||||
info->titleMetaAllocated = 1;
|
||||
bytesRead = WADReadStream(stream, (void**)&info->titleMeta, alignedSize,
|
||||
offset + info->titleMetaOffset);
|
||||
if (bytesRead != alignedSize) {
|
||||
return -3005;
|
||||
}
|
||||
currentOffset += header->titleMetaSize;
|
||||
}
|
||||
|
||||
sectionSize = header->fileListSize;
|
||||
sectionSize = header->metaSize;
|
||||
if (sectionSize != 0) {
|
||||
info->size_0x1c = sectionSize;
|
||||
info->offset_0x20 = currentOffset;
|
||||
info->metaSize = sectionSize;
|
||||
info->metaOffset = currentOffset;
|
||||
currentOffset += header->metaSize;
|
||||
}
|
||||
|
||||
sectionSize = header->crlSize;
|
||||
if (sectionSize != 0) {
|
||||
info->crlSize = sectionSize;
|
||||
info->crlOffset = currentOffset;
|
||||
if (mode == 0) {
|
||||
alignedSize = WAD_ALIGN32(sectionSize);
|
||||
info->buffer_0x24 = _WADMemAlloc(allocator, alignedSize);
|
||||
if (info->buffer_0x24 == 0) {
|
||||
info->crls = _WADMemAlloc(allocator, alignedSize);
|
||||
if (info->crls == 0) {
|
||||
return -3003;
|
||||
}
|
||||
info->size_0x28 = 1;
|
||||
bytesRead = WADReadStream(stream, &info->buffer_0x24, alignedSize,
|
||||
offset + info->offset_0x20);
|
||||
info->crlsAllocated = 1;
|
||||
bytesRead = WADReadStream(stream, &info->crls, alignedSize,
|
||||
offset + info->crlOffset);
|
||||
if (bytesRead != alignedSize) {
|
||||
return -3005;
|
||||
}
|
||||
@@ -2578,16 +2579,16 @@ static s32 _WADUnpackBackup(WADHeader* header, WADStream* stream, WADUnpackInfo*
|
||||
|
||||
if (titleMetaSize != 0) {
|
||||
if ((flags & 4) == 0) {
|
||||
info->sectionSize = titleMetaSize;
|
||||
info->sectionOffset = sectionOffset;
|
||||
info->titleMetaSize = titleMetaSize;
|
||||
info->titleMetaOffset = sectionOffset;
|
||||
alignedSize = WAD_ALIGN32(titleMetaSize);
|
||||
info->titleMeta = _WADMemAlloc(allocator, alignedSize);
|
||||
if (info->titleMeta == 0) {
|
||||
return -3003;
|
||||
}
|
||||
info->titleMetaSize = 1;
|
||||
info->titleMetaAllocated = 1;
|
||||
result = WADReadStream(stream, (void**)&info->titleMeta, alignedSize,
|
||||
offset + info->sectionOffset);
|
||||
offset + info->titleMetaOffset);
|
||||
if (result != (s32)alignedSize) {
|
||||
return -3005;
|
||||
}
|
||||
@@ -2622,6 +2623,7 @@ done:
|
||||
return result;
|
||||
}
|
||||
|
||||
/* MWCC needs these content and backup helpers out of line to preserve caller code. */
|
||||
#pragma dont_inline on
|
||||
s32 _WADGetCidxCount(const ESContentMask* contentMask) {
|
||||
u32 bitIndex;
|
||||
@@ -2731,6 +2733,7 @@ static s32 _WADBackupGetFiles(const char* directoryPath, u32 flags, MEMAllocator
|
||||
result = -3003;
|
||||
goto cleanup;
|
||||
}
|
||||
/* MWCC needs the repeated check to preserve the original error path. */
|
||||
if (nameList == 0) {
|
||||
result = -3003;
|
||||
goto cleanup;
|
||||
@@ -2765,24 +2768,24 @@ static s32 _WADBackupGetFiles(const char* directoryPath, u32 flags, MEMAllocator
|
||||
}
|
||||
result = NANDPrivateGetType(fullFilePath, &fileType);
|
||||
if (result != 0) {
|
||||
goto nextName;
|
||||
goto cleanupName;
|
||||
}
|
||||
if ((flags & 0x10) == 0) {
|
||||
if (absolutePaths && strcmp(directoryPath, ".") == 0) {
|
||||
snprintf(noCopyPath, sizeof(noCopyPath), "%s/%s", currentDirectory, "nocopy");
|
||||
snprintf(bannerPath, sizeof(bannerPath), "%s/%s", currentDirectory, "banner.bin");
|
||||
if (strcmp(fullFilePath, noCopyPath) == 0 && fileType == NAND_TYPE_DIR) {
|
||||
goto nextName;
|
||||
goto cleanupName;
|
||||
}
|
||||
if (strcmp(fullFilePath, bannerPath) == 0 && fileType == NAND_TYPE_FILE) {
|
||||
goto nextName;
|
||||
goto cleanupName;
|
||||
}
|
||||
} else {
|
||||
if (strcmp(fullFilePath, "nocopy") == 0 && fileType == NAND_TYPE_DIR) {
|
||||
goto nextName;
|
||||
goto cleanupName;
|
||||
}
|
||||
if (strcmp(fullFilePath, "banner.bin") == 0 && fileType == NAND_TYPE_FILE) {
|
||||
goto nextName;
|
||||
goto cleanupName;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2790,20 +2793,20 @@ static s32 _WADBackupGetFiles(const char* directoryPath, u32 flags, MEMAllocator
|
||||
result = NANDPrivateOpen(fullFilePath, &fileInfo, NAND_ACCESS_READ);
|
||||
closeFile = TRUE;
|
||||
if (result != 0) {
|
||||
goto nextName;
|
||||
goto cleanupName;
|
||||
}
|
||||
result = NANDGetLength(&fileInfo, &fileSize);
|
||||
if (result != 0) {
|
||||
goto nextName;
|
||||
goto cleanupName;
|
||||
}
|
||||
result = NANDClose(&fileInfo);
|
||||
closeFile = FALSE;
|
||||
if (result != 0) {
|
||||
goto nextName;
|
||||
goto cleanupName;
|
||||
}
|
||||
} else if (fileType == NAND_TYPE_DIR) {
|
||||
if ((flags & 8) == 0) {
|
||||
goto nextName;
|
||||
goto cleanupName;
|
||||
}
|
||||
fileSize = 0;
|
||||
if (files != 0) {
|
||||
@@ -2812,7 +2815,7 @@ static s32 _WADBackupGetFiles(const char* directoryPath, u32 flags, MEMAllocator
|
||||
}
|
||||
result = NANDPrivateGetStatus(fullFilePath, &status);
|
||||
if (result != 0) {
|
||||
goto nextName;
|
||||
goto cleanupName;
|
||||
}
|
||||
if (files != 0) {
|
||||
file->magic = 0x3ADF17E;
|
||||
@@ -2842,7 +2845,7 @@ static s32 _WADBackupGetFiles(const char* directoryPath, u32 flags, MEMAllocator
|
||||
}
|
||||
result = _WADBackupGetFiles(fullFilePath, flags, allocator, &childFileCount, children);
|
||||
if (result != 0) {
|
||||
goto nextName;
|
||||
goto cleanupName;
|
||||
}
|
||||
if (childFileCount != 0) {
|
||||
if (files != 0) {
|
||||
@@ -2851,7 +2854,7 @@ static s32 _WADBackupGetFiles(const char* directoryPath, u32 flags, MEMAllocator
|
||||
totalFiles += childFileCount;
|
||||
}
|
||||
}
|
||||
nextName:
|
||||
cleanupName:
|
||||
nameIndex++;
|
||||
name += strlen(name) + 1;
|
||||
if (closeFile) {
|
||||
@@ -2921,19 +2924,19 @@ static s32 _WADBackupGetSize(u32 flags, ESTmdView* titleMeta, ESContentMask* con
|
||||
|
||||
|
||||
static void _WADFreeMemory(WADUnpackInfo* info, MEMAllocator* allocator) {
|
||||
if ((info->size_0x18 != 0) && (info->buffer_0x14 != 0)) {
|
||||
_WADMemFree(allocator, info->buffer_0x14);
|
||||
info->buffer_0x14 = 0;
|
||||
if ((info->certificatesAllocated != 0) && (info->certificates != 0)) {
|
||||
_WADMemFree(allocator, info->certificates);
|
||||
info->certificates = 0;
|
||||
}
|
||||
if ((info->size_0x28 != 0) && (info->buffer_0x24 != 0)) {
|
||||
_WADMemFree(allocator, info->buffer_0x24);
|
||||
info->buffer_0x24 = 0;
|
||||
if ((info->crlsAllocated != 0) && (info->crls != 0)) {
|
||||
_WADMemFree(allocator, info->crls);
|
||||
info->crls = 0;
|
||||
}
|
||||
if ((info->size_0x38 != 0) && (info->buffer_0x34 != 0)) {
|
||||
_WADMemFree(allocator, info->buffer_0x34);
|
||||
info->buffer_0x34 = 0;
|
||||
if ((info->ticketAllocated != 0) && (info->ticket != 0)) {
|
||||
_WADMemFree(allocator, info->ticket);
|
||||
info->ticket = 0;
|
||||
}
|
||||
if ((info->titleMetaSize != 0) && (info->titleMeta != 0)) {
|
||||
if ((info->titleMetaAllocated != 0) && (info->titleMeta != 0)) {
|
||||
_WADMemFree(allocator, info->titleMeta);
|
||||
info->titleMeta = 0;
|
||||
}
|
||||
@@ -3165,6 +3168,7 @@ cleanup:
|
||||
return result;
|
||||
}
|
||||
|
||||
/* MWCC keeps transfer initialization out of line in the original callers. */
|
||||
#pragma dont_inline on
|
||||
void WAD_815C4A2C(WADImportTransfer* transfer, void* firstBuffer, void* secondBuffer,
|
||||
u32 chunkSize) {
|
||||
@@ -3183,6 +3187,7 @@ void WAD_815C4A2C(WADImportTransfer* transfer, void* firstBuffer, void* secondBu
|
||||
}
|
||||
#pragma dont_inline reset
|
||||
|
||||
/* MWCC needs separate termination checks to preserve the savedata validation loops. */
|
||||
#pragma dont_inline on
|
||||
static u32 _WADIsTerminated(const char* text, u32 maxLength) {
|
||||
u32 index;
|
||||
@@ -3226,22 +3231,12 @@ s32 WADCheckSavedataZD(const WADSaveDataFile* saveData) {
|
||||
record = saveData->primary;
|
||||
index = 0;
|
||||
do {
|
||||
if (!_WADIsTerminated(record->fileName, 8)) {
|
||||
goto done;
|
||||
}
|
||||
if (!_WADIsTerminated(record->bannerName, 8)) {
|
||||
goto done;
|
||||
}
|
||||
if (!_WADIsTerminated(record->saveName, 8)) {
|
||||
goto done;
|
||||
}
|
||||
if (!_WADIsTerminated(record->titleName, 8)) {
|
||||
goto done;
|
||||
}
|
||||
if (!_WADIsTerminated(record->description, 0x11)) {
|
||||
goto done;
|
||||
}
|
||||
if (!_WADIsTerminated(record->subtitle, 0x11)) {
|
||||
if (!_WADIsTerminated(record->fileName, 8) ||
|
||||
!_WADIsTerminated(record->bannerName, 8) ||
|
||||
!_WADIsTerminated(record->saveName, 8) ||
|
||||
!_WADIsTerminated(record->titleName, 8) ||
|
||||
!_WADIsTerminated(record->description, 0x11) ||
|
||||
!_WADIsTerminated(record->subtitle, 0x11)) {
|
||||
goto done;
|
||||
}
|
||||
index++;
|
||||
@@ -3249,22 +3244,12 @@ s32 WADCheckSavedataZD(const WADSaveDataFile* saveData) {
|
||||
} while (index < 3);
|
||||
record = saveData->secondary;
|
||||
for (index = 0; index < 3; index++, record++) {
|
||||
if (!_WADIsTerminated(record->fileName, 8)) {
|
||||
goto done;
|
||||
}
|
||||
if (!_WADIsTerminated(record->bannerName, 8)) {
|
||||
goto done;
|
||||
}
|
||||
if (!_WADIsTerminated(record->saveName, 8)) {
|
||||
goto done;
|
||||
}
|
||||
if (!_WADIsTerminated(record->titleName, 8)) {
|
||||
goto done;
|
||||
}
|
||||
if (!_WADIsTerminated(record->description, 0x11)) {
|
||||
goto done;
|
||||
}
|
||||
if (!_WADIsTerminated(record->subtitle, 0x11)) {
|
||||
if (!_WADIsTerminated(record->fileName, 8) ||
|
||||
!_WADIsTerminated(record->bannerName, 8) ||
|
||||
!_WADIsTerminated(record->saveName, 8) ||
|
||||
!_WADIsTerminated(record->titleName, 8) ||
|
||||
!_WADIsTerminated(record->description, 0x11) ||
|
||||
!_WADIsTerminated(record->subtitle, 0x11)) {
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
@@ -3397,7 +3382,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 +3418,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 +3481,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;
|
||||
@@ -3531,6 +3504,7 @@ s32 WADImportDVDExForBS(const char* path, void* buffer, u32 bufferSize) {
|
||||
return -3004;
|
||||
}
|
||||
fileOpened = TRUE;
|
||||
/* MWCC needs this repeated check to preserve the DVD import error path. */
|
||||
if (buffer == NULL) {
|
||||
result = -3003;
|
||||
goto cleanup;
|
||||
|
||||
@@ -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();
|
||||
@@ -3030,14 +3034,18 @@ void _WUDStartSyncDevice(BD_ADDR bd_addr, u8* bd_name) {
|
||||
|
||||
void _WUDDeleteStoredDevice() {
|
||||
WUDCB* p_wcb = &_wcb;
|
||||
BOOL enabled;
|
||||
u8 deleteState;
|
||||
|
||||
WUD_DEBUGPrint("_WUDDeleteStoreDevice()\n");
|
||||
|
||||
WUDiDeleteAllLinkKeys();
|
||||
|
||||
do {
|
||||
;
|
||||
} while (p_wcb->deleteState != 0);
|
||||
enabled = OSDisableInterrupts();
|
||||
deleteState = p_wcb->deleteState;
|
||||
OSRestoreInterrupts(enabled);
|
||||
} while (deleteState != WUD_STATE_DELETE_START);
|
||||
|
||||
WUD_DEBUGPrint("dev number = %d\n", WUDiGetDevNumber());
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -199,6 +199,7 @@ NWC24Err NWC24SetMsgSubjectPublic(NWC24MsgObj* msg, const u16* subject, u32 subj
|
||||
|
||||
nwcWork = NWC24WorkP;
|
||||
result = NWC24iDetectEncodingToSend(nwcWork->stringWork, 0x40, subject, subjectSize, NULL, 0, region);
|
||||
/* MWCC needs the success-only switches to retain their extra branches. */
|
||||
switch (result) {
|
||||
case NWC24_OK:
|
||||
break;
|
||||
@@ -206,29 +207,29 @@ NWC24Err NWC24SetMsgSubjectPublic(NWC24MsgObj* msg, const u16* subject, u32 subj
|
||||
goto done;
|
||||
}
|
||||
if (NWC24ParseCharsetStr(&charset, nwcWork->stringWork) != NWC24_OK) {
|
||||
charset = 0;
|
||||
charset = NWC24_US_ASCII;
|
||||
}
|
||||
if (charset == 0) {
|
||||
if (charset == NWC24_US_ASCII) {
|
||||
result = NWC24iSetMsgSubjectPlain(msg, subject, subjectSize, region, alternative, work, workSize, charset, nwcWork->stringWork);
|
||||
goto done;
|
||||
}
|
||||
switch (region) {
|
||||
case 0:
|
||||
result = 2;
|
||||
case NWC24_ENCODING_REGION_JPN:
|
||||
result = NWC24_ENC_BASE64;
|
||||
break;
|
||||
case 1:
|
||||
case 2:
|
||||
result = 3;
|
||||
case NWC24_ENCODING_REGION_USA:
|
||||
case NWC24_ENCODING_REGION_EUR:
|
||||
result = NWC24_ENC_QUOTED_PRINTABLE;
|
||||
break;
|
||||
case 3:
|
||||
case 4:
|
||||
result = 2;
|
||||
case NWC24_ENCODING_REGION_KOR:
|
||||
case NWC24_ENCODING_REGION_CHN:
|
||||
result = NWC24_ENC_BASE64;
|
||||
break;
|
||||
default:
|
||||
result = 2;
|
||||
result = NWC24_ENC_BASE64;
|
||||
break;
|
||||
}
|
||||
if (result == 3) {
|
||||
if (result == NWC24_ENC_QUOTED_PRINTABLE) {
|
||||
result = NWC24iSetMsgSubjectQP(msg, subject, subjectSize, region, alternative, work, workSize, charset, nwcWork->stringWork);
|
||||
} else {
|
||||
result = NWC24iSetMsgSubjectBase64(msg, subject, subjectSize, region, alternative, work, workSize, charset, nwcWork->stringWork);
|
||||
@@ -275,6 +276,7 @@ NWC24Err NWC24SetMsgSubjectAndTextPublic(NWC24MsgObj* msg, const u16* subject, u
|
||||
|
||||
nwcWork = NWC24WorkP;
|
||||
result = NWC24iDetectEncodingToSend(nwcWork->stringWork, 0x40, subject, subjectSize, text, textSize, region);
|
||||
/* MWCC needs the success-only switches to retain their extra branches. */
|
||||
switch (result) {
|
||||
case NWC24_OK:
|
||||
break;
|
||||
@@ -282,7 +284,7 @@ NWC24Err NWC24SetMsgSubjectAndTextPublic(NWC24MsgObj* msg, const u16* subject, u
|
||||
goto done;
|
||||
}
|
||||
if (NWC24ParseCharsetStr(&charset, nwcWork->stringWork) != NWC24_OK) {
|
||||
charset = 0;
|
||||
charset = NWC24_US_ASCII;
|
||||
}
|
||||
textCapacity = (workSize * textSize) / (textSize + subjectSize * 4);
|
||||
textWorkSize = textCapacity;
|
||||
@@ -300,23 +302,23 @@ NWC24Err NWC24SetMsgSubjectAndTextPublic(NWC24MsgObj* msg, const u16* subject, u
|
||||
result = ENCIs7BitEncoding(&is7Bit, nwcWork->stringWork);
|
||||
if (!is7Bit || (result != ENC_OK)) {
|
||||
switch (region) {
|
||||
case 0:
|
||||
result = 2;
|
||||
case NWC24_ENCODING_REGION_JPN:
|
||||
result = NWC24_ENC_BASE64;
|
||||
break;
|
||||
case 1:
|
||||
case 2:
|
||||
result = 3;
|
||||
case NWC24_ENCODING_REGION_USA:
|
||||
case NWC24_ENCODING_REGION_EUR:
|
||||
result = NWC24_ENC_QUOTED_PRINTABLE;
|
||||
break;
|
||||
case 3:
|
||||
case 4:
|
||||
result = 2;
|
||||
case NWC24_ENCODING_REGION_KOR:
|
||||
case NWC24_ENCODING_REGION_CHN:
|
||||
result = NWC24_ENC_BASE64;
|
||||
break;
|
||||
default:
|
||||
result = 2;
|
||||
result = NWC24_ENC_BASE64;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
result = 0;
|
||||
result = NWC24_ENC_7BIT;
|
||||
}
|
||||
result = NWC24SetMsgText(msg, (char*)work, textWorkSize - 1, charset, result);
|
||||
switch (result) {
|
||||
@@ -325,27 +327,27 @@ NWC24Err NWC24SetMsgSubjectAndTextPublic(NWC24MsgObj* msg, const u16* subject, u
|
||||
default:
|
||||
goto done;
|
||||
}
|
||||
if (charset == 0) {
|
||||
if (charset == NWC24_US_ASCII) {
|
||||
result = NWC24iSetMsgSubjectPlain(msg, subject, subjectSize, region, alternative, subjectWork, subjectWorkSize, charset, nwcWork->stringWork);
|
||||
goto done;
|
||||
}
|
||||
switch (region) {
|
||||
case 0:
|
||||
result = 2;
|
||||
case NWC24_ENCODING_REGION_JPN:
|
||||
result = NWC24_ENC_BASE64;
|
||||
break;
|
||||
case 1:
|
||||
case 2:
|
||||
result = 3;
|
||||
case NWC24_ENCODING_REGION_USA:
|
||||
case NWC24_ENCODING_REGION_EUR:
|
||||
result = NWC24_ENC_QUOTED_PRINTABLE;
|
||||
break;
|
||||
case 3:
|
||||
case 4:
|
||||
result = 2;
|
||||
case NWC24_ENCODING_REGION_KOR:
|
||||
case NWC24_ENCODING_REGION_CHN:
|
||||
result = NWC24_ENC_BASE64;
|
||||
break;
|
||||
default:
|
||||
result = 2;
|
||||
result = NWC24_ENC_BASE64;
|
||||
break;
|
||||
}
|
||||
if (result == 3) {
|
||||
if (result == NWC24_ENC_QUOTED_PRINTABLE) {
|
||||
result = NWC24iSetMsgSubjectQP(msg, subject, subjectSize, region, alternative, subjectWork, subjectWorkSize, charset, nwcWork->stringWork);
|
||||
} else {
|
||||
result =
|
||||
@@ -360,33 +362,32 @@ NWC24Err NWC24iGetDefaultCharset(char* charset, u32 charsetSize, NWC24EncodingRe
|
||||
NWC24Err result = NWC24_OK;
|
||||
|
||||
switch (region) {
|
||||
case 0:
|
||||
case NWC24_ENCODING_REGION_JPN:
|
||||
strncpy(charset, DefaultCharsetJp, charsetSize - 1);
|
||||
charset[charsetSize - 1] = 0;
|
||||
goto done;
|
||||
case 1:
|
||||
break;
|
||||
case NWC24_ENCODING_REGION_USA:
|
||||
strncpy(charset, "iso-8859-1", charsetSize - 1);
|
||||
charset[charsetSize - 1] = 0;
|
||||
goto done;
|
||||
case 2:
|
||||
break;
|
||||
case NWC24_ENCODING_REGION_EUR:
|
||||
strncpy(charset, "iso-8859-1", charsetSize - 1);
|
||||
charset[charsetSize - 1] = 0;
|
||||
goto done;
|
||||
case 3:
|
||||
break;
|
||||
case NWC24_ENCODING_REGION_KOR:
|
||||
strncpy(charset, DefaultCharsetKr, charsetSize - 1);
|
||||
charset[charsetSize - 1] = 0;
|
||||
goto done;
|
||||
case 4:
|
||||
break;
|
||||
case NWC24_ENCODING_REGION_CHN:
|
||||
strncpy(charset, "gb2312", charsetSize - 1);
|
||||
charset[charsetSize - 1] = 0;
|
||||
goto done;
|
||||
break;
|
||||
default:
|
||||
strncpy(charset, "iso-8859-1", charsetSize - 1);
|
||||
charset[charsetSize - 1] = 0;
|
||||
result = NWC24_ERR_INVALID_VALUE;
|
||||
}
|
||||
|
||||
done:
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -403,6 +404,7 @@ NWC24Err NWC24iConvertToInternalEncoding(u16* dst, u32* dstSize, const u8* src,
|
||||
result = NWC24_ERR_OVERFLOW;
|
||||
goto done;
|
||||
}
|
||||
/* MWCC needs the success switch and short-circuit setup for this instruction order. */
|
||||
if (charset[0] == '\0') {
|
||||
result = NWC24iGetDefaultCharset(charset, charsetSize, region);
|
||||
switch (result) {
|
||||
@@ -421,52 +423,29 @@ NWC24Err NWC24iConvertToInternalEncoding(u16* dst, u32* dstSize, const u8* src,
|
||||
dst[convertedBytes >> 1] = 0;
|
||||
*dstSize = (convertedBytes >> 1) + 1;
|
||||
}
|
||||
if (result == ENC_ERR_NO_MAP_RULE) {
|
||||
goto invalidCharacter;
|
||||
switch (result) {
|
||||
case ENC_OK:
|
||||
result = NWC24_OK;
|
||||
break;
|
||||
case ENC_ERR_INVALID_PARAM:
|
||||
result = NWC24_ERR_INVALID_VALUE;
|
||||
break;
|
||||
case ENC_ERR_NO_BUF_LEFT:
|
||||
result = NWC24_ERR_OVERFLOW;
|
||||
break;
|
||||
case ENC_ERR_NO_MAP_RULE:
|
||||
case ENC_ERR_INVALID_FORMAT:
|
||||
result = NWC24_ERR_INVALID_CHAR;
|
||||
break;
|
||||
case ENC_ERR_UNKNOWN_ENCODING:
|
||||
case ENC_ERR_UNSUPPORTED:
|
||||
case ENC_ERR_NOT_LOADED:
|
||||
result = NWC24_ERR_NOT_SUPPORTED;
|
||||
break;
|
||||
default:
|
||||
result = NWC24_ERR_FATAL;
|
||||
break;
|
||||
}
|
||||
if (result < ENC_ERR_NO_MAP_RULE) {
|
||||
if (result == ENC_ERR_INVALID_FORMAT) {
|
||||
goto invalidCharacter;
|
||||
}
|
||||
if (result >= ENC_ERR_INVALID_FORMAT) {
|
||||
goto invalidValue;
|
||||
}
|
||||
if (result >= ENC_ERR_NOT_LOADED) {
|
||||
goto notSupported;
|
||||
}
|
||||
} else {
|
||||
if (result == ENC_OK) {
|
||||
goto success;
|
||||
}
|
||||
if (result >= ENC_OK) {
|
||||
goto fatal;
|
||||
}
|
||||
goto overflow;
|
||||
}
|
||||
goto fatal;
|
||||
|
||||
success:
|
||||
result = ENC_OK;
|
||||
goto done;
|
||||
|
||||
invalidValue:
|
||||
result = NWC24_ERR_INVALID_VALUE;
|
||||
goto done;
|
||||
|
||||
overflow:
|
||||
result = NWC24_ERR_OVERFLOW;
|
||||
goto done;
|
||||
|
||||
invalidCharacter:
|
||||
result = NWC24_ERR_INVALID_CHAR;
|
||||
goto done;
|
||||
|
||||
notSupported:
|
||||
result = NWC24_ERR_NOT_SUPPORTED;
|
||||
goto done;
|
||||
|
||||
fatal:
|
||||
result = NWC24_ERR_FATAL;
|
||||
|
||||
done:
|
||||
return result;
|
||||
@@ -486,6 +465,7 @@ NWC24Err NWC24iConvertFromInternalEncoding(u8* dst, u32* dstSize, const u16* src
|
||||
result = NWC24_ERR_OVERFLOW;
|
||||
goto done;
|
||||
}
|
||||
/* MWCC needs the success switch and short-circuit setup for this instruction order. */
|
||||
if (charset[0] == '\0') {
|
||||
result = NWC24iGetDefaultCharset(charset, charsetSize, region);
|
||||
switch (result) {
|
||||
@@ -506,51 +486,29 @@ NWC24Err NWC24iConvertFromInternalEncoding(u8* dst, u32* dstSize, const u16* src
|
||||
*srcSize = inputBytes >> 1;
|
||||
*dstSize = outputBytes + 1;
|
||||
}
|
||||
if (result == ENC_ERR_NO_MAP_RULE) {
|
||||
goto invalidCharacter;
|
||||
switch (result) {
|
||||
case ENC_OK:
|
||||
result = NWC24_OK;
|
||||
break;
|
||||
case ENC_ERR_INVALID_PARAM:
|
||||
result = NWC24_ERR_INVALID_VALUE;
|
||||
break;
|
||||
case ENC_ERR_NO_BUF_LEFT:
|
||||
result = NWC24_ERR_OVERFLOW;
|
||||
break;
|
||||
case ENC_ERR_NO_MAP_RULE:
|
||||
case ENC_ERR_INVALID_FORMAT:
|
||||
result = NWC24_ERR_INVALID_CHAR;
|
||||
break;
|
||||
case ENC_ERR_UNKNOWN_ENCODING:
|
||||
case ENC_ERR_UNSUPPORTED:
|
||||
case ENC_ERR_NOT_LOADED:
|
||||
result = NWC24_ERR_NOT_SUPPORTED;
|
||||
break;
|
||||
default:
|
||||
result = NWC24_ERR_FATAL;
|
||||
break;
|
||||
}
|
||||
if (result < ENC_ERR_NO_MAP_RULE) {
|
||||
if (result == ENC_ERR_INVALID_FORMAT) {
|
||||
goto invalidCharacter;
|
||||
}
|
||||
if (result >= ENC_ERR_INVALID_FORMAT) {
|
||||
goto invalidValue;
|
||||
}
|
||||
if (result >= ENC_ERR_NOT_LOADED) {
|
||||
goto notSupported;
|
||||
}
|
||||
goto fatal;
|
||||
}
|
||||
if (result == ENC_OK) {
|
||||
goto success;
|
||||
}
|
||||
if (result >= ENC_OK) {
|
||||
goto fatal;
|
||||
}
|
||||
goto overflow;
|
||||
|
||||
success:
|
||||
result = ENC_OK;
|
||||
goto done;
|
||||
|
||||
invalidValue:
|
||||
result = NWC24_ERR_INVALID_VALUE;
|
||||
goto done;
|
||||
|
||||
overflow:
|
||||
result = NWC24_ERR_OVERFLOW;
|
||||
goto done;
|
||||
|
||||
invalidCharacter:
|
||||
result = NWC24_ERR_INVALID_CHAR;
|
||||
goto done;
|
||||
|
||||
notSupported:
|
||||
result = NWC24_ERR_NOT_SUPPORTED;
|
||||
goto done;
|
||||
|
||||
fatal:
|
||||
result = NWC24_ERR_FATAL;
|
||||
|
||||
done:
|
||||
return result;
|
||||
@@ -572,20 +530,20 @@ NWC24Err NWC24iDetectEncodingToSend(char* charset, u32 charsetSize, const u16* s
|
||||
startIndex = 0;
|
||||
lastIndex = -1;
|
||||
switch (region) {
|
||||
case 0:
|
||||
case NWC24_ENCODING_REGION_JPN:
|
||||
names = JapaneseCharsets;
|
||||
numNames = 3;
|
||||
break;
|
||||
case 1:
|
||||
case 2:
|
||||
case NWC24_ENCODING_REGION_USA:
|
||||
case NWC24_ENCODING_REGION_EUR:
|
||||
names = WesternCharsets;
|
||||
numNames = 8;
|
||||
break;
|
||||
case 3:
|
||||
case NWC24_ENCODING_REGION_KOR:
|
||||
names = KoreanCharsets;
|
||||
numNames = 3;
|
||||
break;
|
||||
case 4:
|
||||
case NWC24_ENCODING_REGION_CHN:
|
||||
names = ChineseCharsets;
|
||||
numNames = 2;
|
||||
break;
|
||||
@@ -642,7 +600,7 @@ NWC24Err NWC24iDetectBreakPoint(u32* breakPoint, NWC24Charset charset, const u8*
|
||||
if ((breakPoint == NULL) || (text == NULL)) {
|
||||
return NWC24_ERR_INVALID_VALUE;
|
||||
}
|
||||
if (charset == 0) {
|
||||
if (charset == NWC24_US_ASCII) {
|
||||
byteEncoding = TRUE;
|
||||
} else if (charset == NWC24_UTF_8) {
|
||||
byteEncoding = FALSE;
|
||||
@@ -797,7 +755,7 @@ NWC24Err NWC24iSetMsgSubjectQP(NWC24MsgObj* msg, const u16* subject, u32 subject
|
||||
charsetLength = (0x40 - strlen(charsetName)) / 3;
|
||||
total = outputLength - 1;
|
||||
workHalf = secondSize;
|
||||
for (; sourceOffset < subjectLength;) {
|
||||
while (sourceOffset < subjectLength) {
|
||||
if (workHalf - total < 3) {
|
||||
result = NWC24_ERR_OVERFLOW;
|
||||
goto done;
|
||||
@@ -808,6 +766,7 @@ NWC24Err NWC24iSetMsgSubjectQP(NWC24MsgObj* msg, const u16* subject, u32 subject
|
||||
NWC24iDetectBreakPoint(&lineLength, charset, work + sourceOffset, subjectLength - sourceOffset, charsetLength);
|
||||
result = NWC24EncodeWord(second + total, workHalf - total, &outputLength, charsetName, 0x40, 'Q', work + sourceOffset,
|
||||
lineLength);
|
||||
/* MWCC needs this success-only switch's extra branch. */
|
||||
switch (result) {
|
||||
case NWC24_OK:
|
||||
break;
|
||||
@@ -829,6 +788,7 @@ done:
|
||||
|
||||
NWC24Err NWC24iSetMsgSubjectBase64(NWC24MsgObj* msg, const u16* subject, u32 subjectSize, NWC24EncodingRegion region, u16 alternative, u8* work,
|
||||
u32 workSize, NWC24Charset charset, char* charsetName) {
|
||||
/* MWCC needs a const input alias to preserve the conversion-call registers. */
|
||||
const u8* encodedInput = work;
|
||||
u8* second;
|
||||
u32 secondSize;
|
||||
@@ -852,6 +812,7 @@ NWC24Err NWC24iSetMsgSubjectBase64(NWC24MsgObj* msg, const u16* subject, u32 sub
|
||||
subjectLength = subjectSize;
|
||||
result = NWC24iConvertFromInternalEncoding(work, &workHalf, subject, &subjectLength, charsetName, 0x40, region, alternative);
|
||||
if (result != NWC24_OK) {
|
||||
/* MWCC needs the success-only switches to retain their extra branches. */
|
||||
switch (result) {
|
||||
case NWC24_ERR_OVERFLOW: break;
|
||||
default: goto done;
|
||||
@@ -867,7 +828,7 @@ NWC24Err NWC24iSetMsgSubjectBase64(NWC24MsgObj* msg, const u16* subject, u32 sub
|
||||
charsetLength = strlen(charsetName);
|
||||
lineLength = (((0x3E - charsetLength) * 3) >> 2) + 1;
|
||||
total = outputLength - 1;
|
||||
for (; sourceOffset < subjectSize;) {
|
||||
while (sourceOffset < subjectSize) {
|
||||
subjectLength = subjectSize - sourceOffset;
|
||||
workHalf = lineLength;
|
||||
if (secondSize - total < 3) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -16,6 +16,7 @@ const u8 scWpaOui0 = 0;
|
||||
const u8 scWpaOui1 = 0x50;
|
||||
const u8 scWpaOui2 = 0xF2;
|
||||
const u8 scWpaOuiPad = 0;
|
||||
/* MWCC places the WPA search bytes in .sdata. */
|
||||
#pragma push
|
||||
#pragma section sconst_type ".sdata"
|
||||
const u8 scWpaFindOui0 = 0;
|
||||
@@ -28,6 +29,7 @@ const u8 scWpaFindOuiPad3 = 0;
|
||||
const u8 scWpaFindOuiPad4 = 0;
|
||||
#pragma pop
|
||||
|
||||
/* MWCC must load the OUI bytes from memory instead of folding their values. */
|
||||
#define scRsnOui0 (*((volatile const u8*)&scRsnOui0))
|
||||
#define scRsnOui1 (*((volatile const u8*)&scRsnOui1))
|
||||
#define scRsnOui2 (*((volatile const u8*)&scRsnOui2))
|
||||
@@ -96,68 +98,58 @@ static inline s32 GetResultNCD(s32 result) {
|
||||
|
||||
s32 WDCheckEnableChannel(u16* enableChannel) {
|
||||
s32 id;
|
||||
s32 result;
|
||||
s32 infoResult;
|
||||
|
||||
if (enableChannel != NULL) {
|
||||
*enableChannel = 0;
|
||||
}
|
||||
|
||||
id = NCDLockWirelessDriver();
|
||||
if (id <= 0) {
|
||||
goto ncd_err;
|
||||
} else {
|
||||
s32 result = WD_Startup(3);
|
||||
s32 result2;
|
||||
if (id > 0) {
|
||||
result = WD_Startup(3);
|
||||
if (result == WD_INTERNAL_ERR_OK) {
|
||||
WD_Info info;
|
||||
result2 = WD_GetInfo(&info);
|
||||
if (result2 == WD_INTERNAL_ERR_OK && enableChannel != NULL) {
|
||||
infoResult = WD_GetInfo(&info);
|
||||
if (infoResult == WD_INTERNAL_ERR_OK && enableChannel != NULL) {
|
||||
*enableChannel = info.enableChannel;
|
||||
}
|
||||
WAIT_FOR_OPERATION(WD_Cleanup());
|
||||
}
|
||||
|
||||
WAIT_FOR_OPERATION(NCDUnlockWirelessDriver(id));
|
||||
goto wd_err;
|
||||
|
||||
ncd_err:
|
||||
} else {
|
||||
return GetResultNCD(id);
|
||||
|
||||
wd_err:
|
||||
if (result == WD_ERR_OK) {
|
||||
return GetResultWD(result2);
|
||||
} else {
|
||||
return GetResultWD(result);
|
||||
}
|
||||
}
|
||||
if (result == WD_ERR_OK) {
|
||||
return GetResultWD(infoResult);
|
||||
} else {
|
||||
return GetResultWD(result);
|
||||
}
|
||||
}
|
||||
|
||||
s32 WDScanOnce(u8* scanBuffer, u32 scanBufferLen, WDScanParam* param) {
|
||||
s32 id;
|
||||
s32 result;
|
||||
s32 scanResult;
|
||||
|
||||
id = NCDLockWirelessDriver();
|
||||
if (id <= 0) {
|
||||
goto ncd_err;
|
||||
} else {
|
||||
s32 result = WD_Startup(3);
|
||||
s32 result2;
|
||||
if (id > 0) {
|
||||
result = WD_Startup(3);
|
||||
if (result == WD_INTERNAL_ERR_OK) {
|
||||
memset(scanBuffer, 0, scanBufferLen);
|
||||
result2 = WD_Scan(param, scanBuffer, scanBufferLen);
|
||||
scanResult = WD_Scan(param, scanBuffer, scanBufferLen);
|
||||
WAIT_FOR_OPERATION(WD_Cleanup());
|
||||
}
|
||||
|
||||
WAIT_FOR_OPERATION(NCDUnlockWirelessDriver(id));
|
||||
goto wd_err;
|
||||
|
||||
ncd_err:
|
||||
} else {
|
||||
return GetResultNCD(id);
|
||||
|
||||
wd_err:
|
||||
if (result == WD_ERR_OK) {
|
||||
return GetResultWD(result2);
|
||||
} else {
|
||||
return GetResultWD(result);
|
||||
}
|
||||
}
|
||||
if (result == WD_ERR_OK) {
|
||||
return GetResultWD(scanResult);
|
||||
} else {
|
||||
return GetResultWD(result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,93 +167,55 @@ s32 WDGetPrivacyMode(WDBssDesc* bssDesc) {
|
||||
data[2] = scRsnOui2;
|
||||
memcpy(readIE, ieData, sizeof(WDVendorInfoElement) + 2);
|
||||
if (memcmp(&readIE[2], data, WD_VENDOR_LENGTH) == 0) {
|
||||
if ((s32)readIE[5] == 3) {
|
||||
goto privacy_second;
|
||||
switch (readIE[5]) {
|
||||
case 1:
|
||||
return WD_PRIVACY_MODE_DS_COMMUNICATION;
|
||||
case 2:
|
||||
return WD_PRIVACY_MODE_7;
|
||||
case 3:
|
||||
break;
|
||||
case 4:
|
||||
return WD_PRIVACY_MODE_5;
|
||||
case 5:
|
||||
return WD_PRIVACY_MODE_2;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if ((s32)readIE[5] >= 3) {
|
||||
goto privacy_rsn_high;
|
||||
}
|
||||
if ((s32)readIE[5] == 1) {
|
||||
goto privacy_rsn_mode1;
|
||||
}
|
||||
if ((s32)readIE[5] >= 1) {
|
||||
goto privacy_rsn_mode7;
|
||||
}
|
||||
goto privacy_second;
|
||||
privacy_rsn_high:
|
||||
if ((s32)readIE[5] == 5) {
|
||||
goto privacy_rsn_mode2;
|
||||
}
|
||||
if ((s32)readIE[5] >= 5) {
|
||||
goto privacy_second;
|
||||
}
|
||||
goto privacy_rsn_mode5;
|
||||
}
|
||||
}
|
||||
goto privacy_second;
|
||||
|
||||
privacy_rsn_mode1:
|
||||
return WD_PRIVACY_MODE_DS_COMMUNICATION;
|
||||
privacy_rsn_mode7:
|
||||
return WD_PRIVACY_MODE_7;
|
||||
privacy_rsn_mode5:
|
||||
return WD_PRIVACY_MODE_5;
|
||||
privacy_rsn_mode2:
|
||||
return WD_PRIVACY_MODE_2;
|
||||
|
||||
privacy_second: {
|
||||
{
|
||||
u8 data[WD_VENDOR_LENGTH];
|
||||
u8 findData[WD_VENDOR_LENGTH];
|
||||
|
||||
findData[0] = scWpaFindOui0;
|
||||
findData[1] = scWpaFindOui1;
|
||||
findData[2] = scWpaFindOui2;
|
||||
if (!WDiFindVendorSpecificIE(&ieData, &ieLength, bssDesc, 0xDD, findData, 1)) {
|
||||
goto privacy_fallback;
|
||||
}
|
||||
data[0] = scWpaOui0;
|
||||
data[1] = scWpaOui1;
|
||||
data[2] = scWpaOui2;
|
||||
if (WDiFindVendorSpecificIE(&ieData, &ieLength, bssDesc, 0xDD, findData, 1)) {
|
||||
data[0] = scWpaOui0;
|
||||
data[1] = scWpaOui1;
|
||||
data[2] = scWpaOui2;
|
||||
|
||||
{
|
||||
memcpy(readIE, ieData, sizeof(WDVendorInfoElement));
|
||||
if (memcmp(&readIE[2], data, WD_VENDOR_LENGTH) != 0) {
|
||||
goto privacy_fallback;
|
||||
if (memcmp(&readIE[2], data, WD_VENDOR_LENGTH) == 0) {
|
||||
switch (readIE[5]) {
|
||||
case 1:
|
||||
return WD_PRIVACY_MODE_DS_COMMUNICATION;
|
||||
case 2:
|
||||
return WD_PRIVACY_MODE_4;
|
||||
case 3:
|
||||
break;
|
||||
case 4:
|
||||
return WD_PRIVACY_MODE_6;
|
||||
case 5:
|
||||
return WD_PRIVACY_MODE_2;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ((s32)readIE[5] == 3) {
|
||||
goto privacy_fallback;
|
||||
}
|
||||
if ((s32)readIE[5] >= 3) {
|
||||
goto privacy_wpa_high;
|
||||
}
|
||||
if ((s32)readIE[5] == 1) {
|
||||
goto privacy_wpa_mode1;
|
||||
}
|
||||
if ((s32)readIE[5] >= 1) {
|
||||
goto privacy_wpa_mode4;
|
||||
}
|
||||
goto privacy_fallback;
|
||||
privacy_wpa_high:
|
||||
if ((s32)readIE[5] == 5) {
|
||||
goto privacy_wpa_mode2;
|
||||
}
|
||||
if ((s32)readIE[5] >= 5) {
|
||||
goto privacy_fallback;
|
||||
}
|
||||
goto privacy_wpa_mode6;
|
||||
}
|
||||
}
|
||||
|
||||
privacy_wpa_mode1:
|
||||
return WD_PRIVACY_MODE_DS_COMMUNICATION;
|
||||
privacy_wpa_mode4:
|
||||
return WD_PRIVACY_MODE_4;
|
||||
privacy_wpa_mode6:
|
||||
return WD_PRIVACY_MODE_6;
|
||||
privacy_wpa_mode2:
|
||||
return WD_PRIVACY_MODE_2;
|
||||
|
||||
privacy_fallback:
|
||||
if (bssDesc != NULL && (bssDesc->capabilities & 0x10) == 0x10) {
|
||||
result = WD_PRIVACY_MODE_8;
|
||||
} else {
|
||||
|
||||
@@ -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,66 @@ 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;
|
||||
// MWCC must preserve the reads and writes of interrupt-shared flags below.
|
||||
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 +240,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
|
||||
@@ -311,36 +308,33 @@ BOOL BS2GetLockedTitles(ESTitleId *pTitleIds, u32 *count) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (pTitleIds) {
|
||||
goto getLockedTitles;
|
||||
}
|
||||
|
||||
*count = 0;
|
||||
PartitionCursor = (u32)PartitionInfoBuf;
|
||||
for (i = 0; i < **(u32 **)&GameToc; i++) {
|
||||
BS2Report("gamePartition ... 0x%08X\n", (u32)((DVDPartitionInfo *)PartitionCursor)->partition);
|
||||
BS2Report("type ... 0x%08X\n", ((DVDPartitionInfo *)PartitionCursor)->partitionType);
|
||||
if (((DVDPartitionInfo *)PartitionCursor)->partitionType & 0xFF000000) {
|
||||
BS2Report(" count++\n");
|
||||
(*count)++;
|
||||
if (!pTitleIds) {
|
||||
*count = 0;
|
||||
PartitionCursor = (u32)PartitionInfoBuf;
|
||||
for (i = 0; i < **(u32 **)&GameToc; i++) {
|
||||
BS2Report("gamePartition ... 0x%08X\n", (u32)((DVDPartitionInfo *)PartitionCursor)->partition);
|
||||
BS2Report("type ... 0x%08X\n", ((DVDPartitionInfo *)PartitionCursor)->partitionType);
|
||||
if (((DVDPartitionInfo *)PartitionCursor)->partitionType & 0xFF000000) {
|
||||
BS2Report(" count++\n");
|
||||
(*count)++;
|
||||
}
|
||||
PartitionCursor += 8;
|
||||
}
|
||||
PartitionCursor += 8;
|
||||
}
|
||||
|
||||
PartitionCursor = (u32)PartitionInfoBuf + 0x20;
|
||||
for (i = 0; i < **(u32 **)&DataToc; i++) {
|
||||
BS2Report("gamePartition ... 0x%08X\n", (u32)((DVDPartitionInfo *)PartitionCursor)->partition);
|
||||
BS2Report("type ... 0x%08X\n", ((DVDPartitionInfo *)PartitionCursor)->partitionType);
|
||||
if (((DVDPartitionInfo *)PartitionCursor)->partitionType & 0xFF000000) {
|
||||
BS2Report(" count++\n");
|
||||
(*count)++;
|
||||
PartitionCursor = (u32)PartitionInfoBuf + 0x20;
|
||||
for (i = 0; i < **(u32 **)&DataToc; i++) {
|
||||
BS2Report("gamePartition ... 0x%08X\n", (u32)((DVDPartitionInfo *)PartitionCursor)->partition);
|
||||
BS2Report("type ... 0x%08X\n", ((DVDPartitionInfo *)PartitionCursor)->partitionType);
|
||||
if (((DVDPartitionInfo *)PartitionCursor)->partitionType & 0xFF000000) {
|
||||
BS2Report(" count++\n");
|
||||
(*count)++;
|
||||
}
|
||||
PartitionCursor += 8;
|
||||
}
|
||||
PartitionCursor += 8;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
||||
getLockedTitles:
|
||||
titleCount = *count;
|
||||
if (titleCount != 0) {
|
||||
PartitionCursor = (u32)PartitionInfoBuf;
|
||||
@@ -491,16 +485,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 +523,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 +572,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) {
|
||||
@@ -612,6 +601,10 @@ void BS2Reboot(void) {
|
||||
}
|
||||
}
|
||||
|
||||
static inline s32 BS2ReadDVDState(const volatile DVDCommandBlock *block) {
|
||||
return block->state;
|
||||
}
|
||||
|
||||
void BS2StartGame() {
|
||||
u32 runResult;
|
||||
u8 *base;
|
||||
@@ -628,7 +621,7 @@ void BS2StartGame() {
|
||||
u32 (*entry)(void);
|
||||
|
||||
StartingGame = TRUE;
|
||||
while (CoverBlock.state != DVD_STATE_IDLE) {
|
||||
while (BS2ReadDVDState(&CoverBlock) != DVD_STATE_IDLE) {
|
||||
}
|
||||
|
||||
BS2Report("BS2StartGame(1)\n");
|
||||
@@ -672,8 +665,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) {
|
||||
@@ -731,6 +724,7 @@ void BS2StartGame() {
|
||||
}
|
||||
|
||||
status = LowReadResult;
|
||||
// MWCC needs the shared fatal and completion exits below.
|
||||
if (status != 2) {
|
||||
if ((status >= 2) || (status < 1)) {
|
||||
goto disk_fatal;
|
||||
@@ -811,16 +805,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 +842,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 +853,7 @@ void BS2StartGCGame() {
|
||||
OSTime time;
|
||||
|
||||
StartingGame = TRUE;
|
||||
while (CoverBlock.state != DVD_STATE_IDLE) {
|
||||
while (BS2ReadDVDState(&CoverBlock) != DVD_STATE_IDLE) {
|
||||
}
|
||||
|
||||
soundMode = SCGetSoundMode();
|
||||
@@ -883,10 +883,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 +957,7 @@ void BS2StartGCGame() {
|
||||
}
|
||||
}
|
||||
|
||||
BOOL CheckDVDCommandStatus(DVDCommandBlock *block) {
|
||||
static BOOL CheckDVDCommandStatus(DVDCommandBlock *block) {
|
||||
if (State == 0x3A) {
|
||||
return TRUE;
|
||||
}
|
||||
@@ -984,9 +981,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 +1018,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 +1063,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 +1079,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 +1095,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 +1180,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 +1301,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 +1311,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 +1323,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 +1350,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 +1438,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:
|
||||
@@ -1481,6 +1477,7 @@ BS2State BS2Tick() {
|
||||
if (bootDisc->rvlMagic == 0x5d1c9ea3) {
|
||||
discTitle = (const char *)0x80000000;
|
||||
status = strncmp(discTitle, "RAAE", 4);
|
||||
// MWCC needs both 410 comparisons to preserve the instruction stream.
|
||||
if (status == 0 || strncmp(discTitle, "408", 3) == 0 ||
|
||||
strncmp(discTitle, "410", 3) == 0 ||
|
||||
strncmp(discTitle, "410", 3) == 0)
|
||||
@@ -1535,6 +1532,7 @@ BS2State BS2Tick() {
|
||||
break;
|
||||
discRegion = bi2.countryCode;
|
||||
productRegion = SCGetProductGameRegion();
|
||||
// MWCC needs the shared false-result paths in these region switches.
|
||||
switch (productRegion) {
|
||||
case 0:
|
||||
if (discRegion != 0)
|
||||
@@ -1576,8 +1574,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 +1733,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 +1883,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 +2021,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 +2064,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 +2176,7 @@ invalidRvlRegion:
|
||||
BS2BootFromCache = 0;
|
||||
BS2BootCaching = 1;
|
||||
LoadingTitle = 0;
|
||||
switch (Block.state) {
|
||||
switch (BS2ReadDVDState(&Block)) {
|
||||
case 4:
|
||||
case 5:
|
||||
CheckDVDCommandStatus(&Block);
|
||||
@@ -2318,7 +2321,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,45 @@ 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);
|
||||
}
|
||||
|
||||
// MWCC needs the shared product-region result paths to preserve branch layout.
|
||||
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 +132,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) {
|
||||
case SC_PRODUCT_AREA_JPN:
|
||||
case SC_PRODUCT_AREA_USA:
|
||||
case SC_PRODUCT_AREA_EUR:
|
||||
case SC_PRODUCT_AREA_KOR:
|
||||
case SC_PRODUCT_AREA_CHN:
|
||||
strcpy(updatePath, "__update.inf");
|
||||
if (DVDConvertPathToEntrynum(updatePath) < 0) {
|
||||
BS2Report("Error: update information file is not found.");
|
||||
selectedCount = 0;
|
||||
goto selection_complete;
|
||||
@@ -187,13 +160,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 +187,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 +214,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) {
|
||||
case SC_PRODUCT_AREA_JPN:
|
||||
case SC_PRODUCT_AREA_USA:
|
||||
case SC_PRODUCT_AREA_EUR:
|
||||
case SC_PRODUCT_AREA_KOR:
|
||||
case SC_PRODUCT_AREA_CHN:
|
||||
strcpy(seatPath, "__seatholder.inf");
|
||||
if (DVDConvertPathToEntrynum(seatPath) < 0) {
|
||||
BS2Report("Error: update seatholder information file is not found.");
|
||||
goto seats_done;
|
||||
}
|
||||
@@ -282,12 +254,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 +272,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 +307,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 +315,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 +342,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 +380,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 +394,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 +436,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 +461,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 +482,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++;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include <revolution/sc.h>
|
||||
|
||||
VoiceInfo Voices[AX_VOICE_MAX];
|
||||
u8 sZeroMem[0x100];
|
||||
u8 sZeroMem[0x100] ATTRIBUTE_ALIGN(32);
|
||||
|
||||
void* zeroBuffer;
|
||||
bool AxAdpcmSimplePlayer::sSysInit;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -115,99 +115,48 @@ extern const u8 controlKeys[];
|
||||
|
||||
u32 modifierFlag = modifierState & 0x8;
|
||||
|
||||
while (currentKeySet.IsValid()) {
|
||||
for (; currentKeySet.IsValid(); currentKeySet = currentKeySet.GetNext()) {
|
||||
int key = currentKeySet.GetKey();
|
||||
u32 command;
|
||||
|
||||
if (key == 0x4c) {
|
||||
goto sendCommand2;
|
||||
}
|
||||
|
||||
if (key < 0x4c) {
|
||||
if (key != 0x2b) {
|
||||
if (key < 0x2b) {
|
||||
if (key >= 0x2a) {
|
||||
goto sendCommand1;
|
||||
}
|
||||
} else {
|
||||
if (key >= 0x2d) {
|
||||
goto nextRepeatedKey;
|
||||
}
|
||||
goto checkSpecialCommand;
|
||||
}
|
||||
// MWCC needs the navigation cases to share this command tail.
|
||||
switch (key) {
|
||||
case 0x4c:
|
||||
sendCommand(2, NULL);
|
||||
continue;
|
||||
case 0x2a:
|
||||
sendCommand(1, NULL);
|
||||
continue;
|
||||
case 0x4f:
|
||||
command = 0x20;
|
||||
goto sendNavigationCommand;
|
||||
case 0x50:
|
||||
command = 0x1f;
|
||||
goto sendNavigationCommand;
|
||||
case 0x51:
|
||||
command = 0x1e;
|
||||
goto sendNavigationCommand;
|
||||
case 0x52:
|
||||
command = 0x1d;
|
||||
sendNavigationCommand:
|
||||
{
|
||||
u32 commandData[2];
|
||||
commandData[0] = command;
|
||||
commandData[1] = modifierState;
|
||||
sendCommand(0x26, commandData);
|
||||
}
|
||||
goto nextRepeatedKey;
|
||||
}
|
||||
|
||||
if (key == 0x51) {
|
||||
goto setNavigationCommand1e;
|
||||
}
|
||||
|
||||
if (key < 0x51) {
|
||||
if (key == 0x4f) {
|
||||
goto setNavigationCommand20;
|
||||
} else if (key >= 0x4f) {
|
||||
goto setNavigationCommand1f;
|
||||
continue;
|
||||
case 0x2c:
|
||||
if ((mgr()->getToolBar()->isQwerty() ||
|
||||
!mgr()->getCellPhoneKeyboard()->isNumeric()) && modifierFlag == 0) {
|
||||
NavigationCommand commandData = {8, modifierState};
|
||||
sendCommand(0x26, &commandData);
|
||||
}
|
||||
} else {
|
||||
if (key >= 0x53) {
|
||||
goto nextRepeatedKey;
|
||||
}
|
||||
goto setNavigationCommand1d;
|
||||
continue;
|
||||
case 0x2b:
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
|
||||
goto nextRepeatedKey;
|
||||
|
||||
sendCommand2:
|
||||
sendCommand(2, NULL);
|
||||
goto nextRepeatedKey;
|
||||
|
||||
sendCommand1:
|
||||
sendCommand(1, NULL);
|
||||
goto nextRepeatedKey;
|
||||
|
||||
setNavigationCommand20:
|
||||
command = 0x20;
|
||||
goto sendNavigationCommand;
|
||||
|
||||
setNavigationCommand1f:
|
||||
command = 0x1f;
|
||||
goto sendNavigationCommand;
|
||||
|
||||
setNavigationCommand1e:
|
||||
command = 0x1e;
|
||||
goto sendNavigationCommand;
|
||||
|
||||
setNavigationCommand1d:
|
||||
command = 0x1d;
|
||||
|
||||
sendNavigationCommand:
|
||||
{
|
||||
u32 commandData[2];
|
||||
commandData[0] = command;
|
||||
commandData[1] = modifierState;
|
||||
sendCommand(0x26, commandData);
|
||||
}
|
||||
goto nextRepeatedKey;
|
||||
|
||||
checkSpecialCommand:
|
||||
if (mgr()->getToolBar()->isQwerty() ||
|
||||
!mgr()->getCellPhoneKeyboard()->isNumeric()) {
|
||||
if (modifierFlag == 0) {
|
||||
goto sendSpecialCommand;
|
||||
}
|
||||
}
|
||||
goto nextRepeatedKey;
|
||||
|
||||
sendSpecialCommand:
|
||||
{
|
||||
NavigationCommand commandData = {8, modifierState};
|
||||
sendCommand(0x26, &commandData);
|
||||
}
|
||||
|
||||
nextRepeatedKey:
|
||||
|
||||
currentKeySet = currentKeySet.GetNext();
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -250,29 +199,28 @@ extern const u8 controlKeys[];
|
||||
bool sendCharacter = true;
|
||||
if (!mgr()->getToolBar()->isQwerty() &&
|
||||
mgr()->getCellPhoneKeyboard()->isNumeric()) {
|
||||
if (static_cast<wchar_t>(character) == '/') {
|
||||
goto suppressCharacter;
|
||||
}
|
||||
if (static_cast<wchar_t>(character) < '/') {
|
||||
if (static_cast<wchar_t>(character) >= '.') {
|
||||
goto checkNumericDot;
|
||||
switch (static_cast<wchar_t>(character)) {
|
||||
case '0':
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
case '8':
|
||||
case '9':
|
||||
break;
|
||||
case '.':
|
||||
if (mgr()->getCellPhoneKeyboard()->isNumericWithDot()) {
|
||||
break;
|
||||
}
|
||||
goto suppressCharacter;
|
||||
case '/':
|
||||
default:
|
||||
sendCharacter = false;
|
||||
break;
|
||||
}
|
||||
if (static_cast<wchar_t>(character) >= ':') {
|
||||
goto suppressCharacter;
|
||||
}
|
||||
goto sendCharacterCheck;
|
||||
checkNumericDot:
|
||||
if (mgr()->getCellPhoneKeyboard()->isNumericWithDot()) {
|
||||
goto sendCharacterCheck;
|
||||
}
|
||||
suppressCharacter:
|
||||
sendCharacter = false;
|
||||
}
|
||||
|
||||
goto sendCharacterCheck;
|
||||
sendCharacterCheck:
|
||||
if (sendCharacter) {
|
||||
modifierState = 0;
|
||||
if ((hkbManager.GetModifierState() & 0x2) != 0) {
|
||||
@@ -287,7 +235,7 @@ extern const u8 controlKeys[];
|
||||
}
|
||||
|
||||
character = convertWCCode(character);
|
||||
KeyInputData keyInputData = {0, 0, 0, 1, 0, 0, 0};
|
||||
KeyInputData keyInputData = {0, 0, 0, 1, 0, 0, 0};
|
||||
keyInputData.character = character;
|
||||
keyInputData.modifier = modifierState;
|
||||
sendCommand(0, &keyInputData);
|
||||
@@ -325,24 +273,21 @@ extern const u8 controlKeys[];
|
||||
hkbManager.SetModifierState(capsLock ? 0x100 : 0, 0x100);
|
||||
}
|
||||
|
||||
if (mgr()->getToolBar()->isQwerty() ||
|
||||
!mgr()->getCellPhoneKeyboard()->isNumeric()) {
|
||||
goto sendKeyCheck;
|
||||
if (!mgr()->getToolBar()->isQwerty() &&
|
||||
mgr()->getCellPhoneKeyboard()->isNumeric()) {
|
||||
switch (translatedKey) {
|
||||
case 0x15:
|
||||
case 0x16:
|
||||
case 0x1d:
|
||||
case 0x1e:
|
||||
case 0x1f:
|
||||
case 0x20:
|
||||
break;
|
||||
default:
|
||||
sendKey = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
switch (translatedKey) {
|
||||
case 0x15:
|
||||
case 0x16:
|
||||
case 0x1d:
|
||||
case 0x1e:
|
||||
case 0x1f:
|
||||
case 0x20:
|
||||
break;
|
||||
default:
|
||||
sendKey = false;
|
||||
break;
|
||||
}
|
||||
sendKeyCheck:
|
||||
if (sendKey) {
|
||||
u32 commandData[2] = {translatedKey, modifierState};
|
||||
sendCommand(0x26, commandData);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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]}},
|
||||
|
||||
@@ -14,7 +14,6 @@ void KPRSetMode(KPRQueue*, u32);
|
||||
|
||||
namespace textinput {
|
||||
namespace tistring {
|
||||
Decolated::~Decolated() {}
|
||||
void StringBase::create(MEMAllocator* allocator) {
|
||||
mpAllocator = allocator;
|
||||
mpszString = static_cast<wchar_t*>(MEMAllocFromAllocator(allocator, muMaxLength << 1));
|
||||
@@ -142,24 +141,13 @@ wchar_t StringBase::getLastWChar() {
|
||||
}
|
||||
|
||||
namespace {
|
||||
class CharacterOutput {
|
||||
public:
|
||||
CharacterOutput(wchar_t* output) : mpOutput(output), mCount(0) {
|
||||
mpOutput[0] = 0;
|
||||
}
|
||||
// This build has no Hangul composer; syllable state stays empty and keys are committed as typed.
|
||||
// MWCC needs these aggregate tests and dead stores for Hangul scheduling and count narrowing.
|
||||
struct HangulSyllable {
|
||||
u32 length;
|
||||
|
||||
void append(wchar_t ch) {
|
||||
mpOutput[mCount++] = ch;
|
||||
}
|
||||
|
||||
u16 finish() {
|
||||
mpOutput[mCount] = 0;
|
||||
return mCount;
|
||||
}
|
||||
|
||||
private:
|
||||
wchar_t* mpOutput;
|
||||
u32 mCount;
|
||||
bool isEmpty() const { return length == 0; }
|
||||
void clear() { length = 0; }
|
||||
};
|
||||
}
|
||||
|
||||
@@ -172,10 +160,7 @@ void Decolated::inputChar(wchar_t ch) {
|
||||
input[1] = 0;
|
||||
input[0] = 0;
|
||||
u16 count;
|
||||
if (static_cast<u32>(mTranslateMode) - 1 > 1) {
|
||||
goto nonKana;
|
||||
}
|
||||
{
|
||||
if (mTranslateMode == TM_Kana || mTranslateMode == TM_Roman) {
|
||||
mKanaStream.mOutput[4] = 0;
|
||||
mKanaStream.mOutput[3] = 0;
|
||||
mKanaStream.mOutput[2] = 0;
|
||||
@@ -191,20 +176,30 @@ void Decolated::inputChar(wchar_t ch) {
|
||||
input[static_cast<u8>(inputIndex)] = KPRGetChar(&mKanaStream.mQueue);
|
||||
}
|
||||
KPRLookAhead(&mKanaStream.mQueue, mKanaStream.mOutput, 5);
|
||||
goto inputReady;
|
||||
}
|
||||
nonKana:
|
||||
if (mTranslateMode == 3) {
|
||||
CharacterOutput output(input);
|
||||
output.append(ch);
|
||||
count = output.finish();
|
||||
} else if (mTranslateMode == TM_Hangul) {
|
||||
u32 outputLength = 0;
|
||||
HangulSyllable composing = {0};
|
||||
input[outputLength] = 0;
|
||||
if (!composing.isEmpty()) {
|
||||
outputLength += composing.length;
|
||||
}
|
||||
if (ch == L'\n') {
|
||||
composing.clear();
|
||||
}
|
||||
input[outputLength++] = ch;
|
||||
HangulSyllable next = {0};
|
||||
if (next.isEmpty()) {
|
||||
next.length = 1;
|
||||
}
|
||||
input[outputLength] = 0;
|
||||
composing.length = static_cast<u16>(outputLength);
|
||||
count = outputLength;
|
||||
mKanaStream.mOutput[0] = 0;
|
||||
} else {
|
||||
count = 1;
|
||||
input[0] = ch;
|
||||
input[1] = 0;
|
||||
}
|
||||
inputReady:
|
||||
setCandidate(0);
|
||||
u32 start;
|
||||
u32 end;
|
||||
|
||||
@@ -72,16 +72,14 @@ void WithZi::ChangeDictionaryLanguage(u8 language) {
|
||||
}
|
||||
if (entryIndex != -1) {
|
||||
dictionaryEntry = reinterpret_cast<u32*>(dictionaryTable[entryIndex].table);
|
||||
if (dictionaryEntry == NULL) goto noDictionary;
|
||||
attached = EZTXAttachOEMDict(
|
||||
(u8*)SearchOEMDictionary, *dictionaryEntry & 0xffff,
|
||||
dictionaryEntry, mpDictionaryWork);
|
||||
mOemDictionaryId = attached & 0xff;
|
||||
goto dictionaryReady;
|
||||
noDictionary:
|
||||
mOemDictionaryId = 0;
|
||||
dictionaryReady:
|
||||
;
|
||||
if (dictionaryEntry != NULL) {
|
||||
attached = EZTXAttachOEMDict(
|
||||
(u8*)SearchOEMDictionary, *dictionaryEntry & 0xffff,
|
||||
dictionaryEntry, mpDictionaryWork);
|
||||
mOemDictionaryId = attached & 0xff;
|
||||
} else {
|
||||
mOemDictionaryId = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -271,6 +269,7 @@ void WithZi::partialConfirmForKR() {
|
||||
const wchar_t* letters;
|
||||
wchar_t value = util::toWLower(CandidatesBuffer[mInputLength - 1]);
|
||||
letters = kKoreanFinalLetters;
|
||||
// MWCC needs the match flag assigned at the loop exits.
|
||||
for (index = 0; index < 12; ++index) {
|
||||
if (value == *letters) {
|
||||
match = true;
|
||||
@@ -280,28 +279,52 @@ void WithZi::partialConfirmForKR() {
|
||||
}
|
||||
match = false;
|
||||
finalLetterChecked:
|
||||
if (!match) goto keepLastLetter;
|
||||
value = util::toWLower(CandidatesBuffer[mInputLength - 2]);
|
||||
if (!IsKoreanLeadingLetter(value)) goto keepLastLetter;
|
||||
CandidatesBuffer[0] = CandidatesBuffer[mInputLength - 2];
|
||||
CandidatesBuffer[1] = CandidatesBuffer[mInputLength - 1];
|
||||
mInputLength = 2;
|
||||
goto confirmLetters;
|
||||
keepLastLetter:
|
||||
CandidatesBuffer[0] = CandidatesBuffer[mInputLength - 1];
|
||||
mInputLength = 1;
|
||||
confirmLetters:
|
||||
if (match && IsKoreanLeadingLetter(util::toWLower(CandidatesBuffer[mInputLength - 2]))) {
|
||||
CandidatesBuffer[0] = CandidatesBuffer[mInputLength - 2];
|
||||
CandidatesBuffer[1] = CandidatesBuffer[mInputLength - 1];
|
||||
mInputLength = 2;
|
||||
} else {
|
||||
CandidatesBuffer[0] = CandidatesBuffer[mInputLength - 1];
|
||||
mInputLength = 1;
|
||||
}
|
||||
CandidatesBuffer[mInputLength] = 0;
|
||||
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 +362,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;
|
||||
@@ -367,17 +389,14 @@ void WithZi::update() {
|
||||
if (static_cast<s32>(count) > 0x28) {
|
||||
count = 0x28;
|
||||
}
|
||||
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];
|
||||
if (getPredictLanguage() == ZI8_LANG_ZH && mbContextChanged != 0) {
|
||||
mbContextChanged = 0;
|
||||
if (mSearch.count == 0) {
|
||||
copyLength = mCurrentWordLength;
|
||||
CopyWordSuffix(LatestWord, copyLength);
|
||||
mSearch.wordCharCount = wcslen((wchar_t*)LatestWord);
|
||||
count = EZTXGetCandidates(&mSearch, mpDictionaryWork) & 0xff;
|
||||
}
|
||||
LatestWord[copied] = 0;
|
||||
mSearch.wordCharCount = wcslen((wchar_t*)LatestWord);
|
||||
count = EZTXGetCandidates(&mSearch, mpDictionaryWork) & 0xff;
|
||||
}
|
||||
if (count == 0) {
|
||||
if (getPredictLanguage() != ZI8_LANG_ZH) {
|
||||
@@ -392,28 +411,26 @@ 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;
|
||||
// MWCC needs failed copies to join at the destination advance.
|
||||
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 +438,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;
|
||||
@@ -450,22 +465,17 @@ nextCandidate:
|
||||
}
|
||||
}
|
||||
|
||||
u32 WithZi::complementsCandidates_(s32) {
|
||||
bool useSentinel;
|
||||
static inline bool HasNumericElement(const u16* scan) {
|
||||
u16 value;
|
||||
u16* scan = ElementBuffer;
|
||||
goto scanCheck;
|
||||
scanBody:
|
||||
if (0xeff1 <= value && value <= 0xeff9) {
|
||||
useSentinel = true;
|
||||
goto scanDone;
|
||||
while ((value = *scan) != 0) {
|
||||
if (0xeff1 <= value && value <= 0xeff9) return true;
|
||||
++scan;
|
||||
}
|
||||
++scan;
|
||||
scanCheck:
|
||||
value = *scan;
|
||||
if (value != 0) goto scanBody;
|
||||
useSentinel = false;
|
||||
scanDone:
|
||||
return false;
|
||||
}
|
||||
|
||||
u32 WithZi::complementsCandidates_(s32) {
|
||||
bool useSentinel = HasNumericElement(ElementBuffer);
|
||||
if (useSentinel) {
|
||||
CandidatedWord[mInputLength - 1] = 0xfffe;
|
||||
CandidatedWord[mInputLength] = 0;
|
||||
@@ -481,31 +491,26 @@ scanDone:
|
||||
character = source;
|
||||
while (*source != 0) {
|
||||
s32 mode = mLetterMode;
|
||||
if (mode == 2) goto modeTwo;
|
||||
if (mode >= 2) goto modeThree;
|
||||
if (mode == 0) goto modeZero;
|
||||
if (mode >= 0) goto modeOne;
|
||||
goto modeDone;
|
||||
modeThree:
|
||||
if (mode >= 4) goto modeDone;
|
||||
goto modeCopy;
|
||||
modeOne:
|
||||
*destination = util::toWLower(*character);
|
||||
goto modeDone;
|
||||
modeTwo:
|
||||
*destination = util::toWUpper(*character);
|
||||
goto modeDone;
|
||||
modeZero:
|
||||
if (length == 0) {
|
||||
*destination = util::toWUpper(*character);
|
||||
}
|
||||
else {
|
||||
switch (mode) {
|
||||
case LM_1:
|
||||
*destination = util::toWLower(*character);
|
||||
break;
|
||||
case LM_2:
|
||||
*destination = util::toWUpper(*character);
|
||||
break;
|
||||
case LM_0:
|
||||
if (length == 0) {
|
||||
*destination = util::toWUpper(*character);
|
||||
} else {
|
||||
*destination = util::toWLower(*character);
|
||||
}
|
||||
break;
|
||||
case LM_3:
|
||||
*destination = *character;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
goto modeDone;
|
||||
modeCopy:
|
||||
*destination = *character;
|
||||
modeDone:
|
||||
++source;
|
||||
++character;
|
||||
++destination;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -57,7 +57,7 @@ namespace ipl {
|
||||
|
||||
void delete_task_(void* work);
|
||||
|
||||
#define FOREACH_OBJ_IN_LIST(object) while (object = mObjList.getNext(object), object != NULL)
|
||||
#define FOREACH_OBJ_IN_LIST(object) while ((object = mObjList.getNext(object)) != NULL)
|
||||
|
||||
enum {
|
||||
FOCUS_ANIM_IN = 0,
|
||||
@@ -429,6 +429,7 @@ namespace ipl {
|
||||
}
|
||||
|
||||
BOOL Board::appendRecord(CDBRecord* record) {
|
||||
// MWCC needs this aggregate to keep interrupt states in their original stack slots.
|
||||
struct RecordReadState {
|
||||
BOOL recordInterrupts;
|
||||
u32 dataSize;
|
||||
@@ -572,7 +573,6 @@ namespace ipl {
|
||||
close:
|
||||
cdbManager->close(record);
|
||||
|
||||
hide_icon:
|
||||
if (mSearchDirection == CDB_SEARCH_DIRECTION_LEFT) {
|
||||
hide_licon();
|
||||
} else {
|
||||
@@ -693,6 +693,7 @@ namespace ipl {
|
||||
}
|
||||
}
|
||||
|
||||
// MWCC needs IRO disabled to preserve the original scene-check scheduling.
|
||||
#pragma push
|
||||
#pragma ppc_iro_level 0
|
||||
void Board::stt_wait_child_dst() {
|
||||
@@ -1656,24 +1657,18 @@ namespace ipl {
|
||||
}
|
||||
}
|
||||
|
||||
// MWCC needs IRO disabled for the original list cursor registers.
|
||||
#pragma push
|
||||
#pragma ppc_iro_level 0
|
||||
void Board::return_to_freelist_if_diff_date() {
|
||||
BoardObject* object = mObjList.getNext(NULL);
|
||||
goto start_loop;
|
||||
while (TRUE) {
|
||||
BoardObject* tmp = mObjList.getNext(object);
|
||||
|
||||
while (object != NULL) {
|
||||
BoardObject* next = mObjList.getNext(object);
|
||||
if (object->mBoardDate != mCurrentDate) {
|
||||
object->destroy();
|
||||
mObjList.remove(object);
|
||||
}
|
||||
|
||||
object = tmp;
|
||||
start_loop:
|
||||
if (object == NULL) {
|
||||
break;
|
||||
}
|
||||
object = next;
|
||||
}
|
||||
}
|
||||
#pragma pop
|
||||
@@ -2053,6 +2048,7 @@ namespace ipl {
|
||||
}
|
||||
}
|
||||
|
||||
// MWCC needs IRO disabled to preserve the list cursor and result registers.
|
||||
#pragma push
|
||||
#pragma ppc_iro_level 0
|
||||
BoardObject* Board::get_log_obj() {
|
||||
|
||||
@@ -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,9 +7,8 @@
|
||||
|
||||
#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*);
|
||||
|
||||
namespace ipl {
|
||||
namespace scene {
|
||||
@@ -828,7 +827,7 @@ namespace ipl {
|
||||
Command command;
|
||||
command.type = Command::TYPE_ANIM;
|
||||
command.animId = animId;
|
||||
push_button_queue(&mReservedCmd, &command);
|
||||
mReservedCmd.push(command);
|
||||
}
|
||||
|
||||
void Button::reserveText(int paneId, u32 msgId) {
|
||||
@@ -836,7 +835,7 @@ namespace ipl {
|
||||
command.type = Command::TYPE_TEXT;
|
||||
command.paneId = paneId;
|
||||
command.msgId = msgId;
|
||||
push_button_queue(&mReservedCmd, &command);
|
||||
mReservedCmd.push(command);
|
||||
}
|
||||
|
||||
/* ============== */
|
||||
@@ -968,22 +967,6 @@ namespace ipl {
|
||||
|
||||
void OptOutButtonEventHandlerBase::onEventDerived(u32 compId, u32 event, const controller::Interface* con) {
|
||||
}
|
||||
|
||||
extern "C" BOOL push_button_queue(void* storage, const void* item) {
|
||||
typedef utility::Queue<Button::Command, 8> CommandQueue;
|
||||
CommandQueue* queue = static_cast<CommandQueue*>(storage);
|
||||
const Button::Command* command = static_cast<const Button::Command*>(item);
|
||||
if (queue->count == queue->current) {
|
||||
return FALSE;
|
||||
}
|
||||
queue->items[queue->pushed] = *command;
|
||||
if (++queue->pushed >= queue->count) {
|
||||
queue->pushed = 0;
|
||||
}
|
||||
queue->current++;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
} // namespace scene
|
||||
} // namespace ipl
|
||||
|
||||
|
||||
@@ -135,7 +135,7 @@ extern "C" void pollCardSlot(u8 slot) {
|
||||
sThread->slots[slot].state = 3;
|
||||
sThread->slots[slot].changed = 0;
|
||||
}
|
||||
goto done;
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (result == 0) {
|
||||
@@ -144,7 +144,6 @@ extern "C" void pollCardSlot(u8 slot) {
|
||||
}
|
||||
}
|
||||
}
|
||||
done:
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -398,200 +397,204 @@ extern "C" void clearAllCardFileEntries(s32 slot);
|
||||
extern "C" s32 loadCardFileIcons(s32 slot, s32 fileNo, CARDDir* dir);
|
||||
extern "C" void runCardMoveOrCopy(u8 slot, s16 fileNo, s32 command);
|
||||
|
||||
static inline void sendValidityResponse(u32 command, u32 valid) {
|
||||
union {
|
||||
u32 value;
|
||||
struct { u32 upper : 16; u32 valid : 8; u32 command : 8; } fields;
|
||||
} reply;
|
||||
reply.value = command;
|
||||
reply.fields.valid = valid;
|
||||
OSSendMessage(&sThread->responses, (OSMessage)reply.value, OS_MESSAGE_BLOCK);
|
||||
static inline u8 getCardCommandSlot(u32 message) {
|
||||
u8 slot = message >> 16;
|
||||
slot &= 1;
|
||||
return slot;
|
||||
}
|
||||
|
||||
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 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);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void formatCardSlot(u8 slot) {
|
||||
s32 result = CARDFormat(slot);
|
||||
if (result < CARD_RESULT_READY) {
|
||||
reportCardThreadError(slot, 1, result);
|
||||
} else {
|
||||
sThread->mounted[slot] = 1;
|
||||
refreshCardSlotInfo(slot);
|
||||
sendCardSlotState(slot, 1, 0);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void mountCardSlot(u8 slot, CARDDir& mountDir, CARDDir& listingDir, char* fileName) {
|
||||
s32 result;
|
||||
s32 file;
|
||||
u32 listingFile;
|
||||
BOOL brokenFile;
|
||||
|
||||
result = CARDMount(slot, sThread->mountBuffers[slot], 0);
|
||||
if (result < CARD_RESULT_READY) {
|
||||
result = handleCardMountResult(slot, result);
|
||||
if (result != CARD_RESULT_READY) {
|
||||
goto scanFiles;
|
||||
}
|
||||
return;
|
||||
}
|
||||
result = CARDCheck(slot);
|
||||
if (result < CARD_RESULT_READY) {
|
||||
goto mountError;
|
||||
}
|
||||
|
||||
scanFiles:
|
||||
clearAllCardFileEntries(slot);
|
||||
for (file = 0; file < CARD_MAX_FILE; ++file) {
|
||||
result = __CARDGetStatusEx(slot, (s16)file, &mountDir);
|
||||
if (result < CARD_RESULT_READY) {
|
||||
result = handleCardMountResult(slot, result);
|
||||
if (result != CARD_RESULT_READY) {
|
||||
continue;
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
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) {
|
||||
goto mountError;
|
||||
}
|
||||
} else {
|
||||
result = loadCardFileIcons(slot, (s16)file, &mountDir);
|
||||
if (result < CARD_RESULT_READY) {
|
||||
goto mountError;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
refreshCardSlotInfo(slot);
|
||||
sThread->mounted[slot] = 1;
|
||||
sendCardSlotState(slot, 0, 0);
|
||||
OSReport("Slot %c\n", sCardSlotName[slot]);
|
||||
listCardFiles(slot, listingDir, fileName);
|
||||
return;
|
||||
|
||||
mountError:
|
||||
OSReport("MountError\n");
|
||||
reportCardThreadError(slot, 0, result);
|
||||
}
|
||||
|
||||
// MWCC must keep validState in a register for the response bit insert.
|
||||
#pragma push
|
||||
#pragma opt_propagation off
|
||||
extern "C" void* cardThreadMain(void*) {
|
||||
char fileName[33];
|
||||
CARDDir listingDir;
|
||||
CARDDir mountDir;
|
||||
CARDDir freeDir;
|
||||
u32 message;
|
||||
s32 outerSlot;
|
||||
s32 freeFile;
|
||||
s32 freeBlocks;
|
||||
u32 command;
|
||||
u8 validState = TRUE;
|
||||
BOOL exitThread = FALSE;
|
||||
|
||||
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);
|
||||
while (!exitThread) {
|
||||
OSReceiveMessage(&sThread->requests, (OSMessage*)&message, OS_MESSAGE_BLOCK);
|
||||
OSReport("CARD THREAD: Message received %d\n", (s8)(u8)message);
|
||||
if (validState != TRUE) {
|
||||
goto loopCheck;
|
||||
continue;
|
||||
}
|
||||
command = local.message & 0xFF;
|
||||
command = message & 0xFF;
|
||||
|
||||
switch ((s8)command) {
|
||||
case 10:
|
||||
validState = TRUE;
|
||||
OSReport("card thread valid state changed:%d\n", 1);
|
||||
sendValidityResponse(command, validState);
|
||||
OSSendMessage(&sThread->responses, (OSMessage)((validState << 8) | (u8)command), OS_MESSAGE_BLOCK);
|
||||
break;
|
||||
case 11:
|
||||
exitThread = TRUE;
|
||||
break;
|
||||
case 0: {
|
||||
slot = (local.message >> 16) & 1;
|
||||
command = (local.message >> 14) & 4;
|
||||
result = CARDMount(slot, sThread->mountBuffers[command / 4], 0);
|
||||
if (result < CARD_RESULT_READY) {
|
||||
result = handleCardMountResult(slot, result);
|
||||
if (result != CARD_RESULT_READY) {
|
||||
goto mountContinue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
result = CARDCheck(slot);
|
||||
if (result < CARD_RESULT_READY) {
|
||||
goto mountError;
|
||||
}
|
||||
|
||||
mountContinue:
|
||||
clearAllCardFileEntries(slot);
|
||||
for (file = 0; file < CARD_MAX_FILE; ++file) {
|
||||
result = __CARDGetStatusEx(slot, (s16)file, &local.mountDir);
|
||||
if (result < CARD_RESULT_READY) {
|
||||
result = handleCardMountResult(slot, result);
|
||||
if (result != CARD_RESULT_READY) {
|
||||
continue;
|
||||
}
|
||||
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) {
|
||||
brokenFile = TRUE;
|
||||
} else {
|
||||
brokenFile = FALSE;
|
||||
}
|
||||
if (brokenFile) {
|
||||
result = CARDFastDelete(slot, (s16)file);
|
||||
if (result < CARD_RESULT_READY) {
|
||||
goto mountError;
|
||||
}
|
||||
} else {
|
||||
result = loadCardFileIcons(slot, (s16)file, &local.mountDir);
|
||||
if (result < CARD_RESULT_READY) {
|
||||
goto mountError;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
refreshCardSlotInfo(slot);
|
||||
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);
|
||||
}
|
||||
}
|
||||
case 0:
|
||||
mountCardSlot(getCardCommandSlot(message), mountDir, listingDir, fileName);
|
||||
break;
|
||||
|
||||
mountError:
|
||||
OSReport("MountError\n");
|
||||
reportCardThreadError(slot, 0, result);
|
||||
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;
|
||||
result = CARDFormat(slot);
|
||||
if (result < CARD_RESULT_READY) {
|
||||
reportCardThreadError(slot, 1, result);
|
||||
} else {
|
||||
sThread->mounted[slot] = 1;
|
||||
refreshCardSlotInfo(slot);
|
||||
sendCardSlotState(slot, 1, 0);
|
||||
}
|
||||
case 1:
|
||||
formatCardSlot(getCardCommandSlot(message));
|
||||
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;
|
||||
|
||||
} while (outerSlot < 2);
|
||||
sendCardSlotState(0, 0xC, 0);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
loopCheck:
|
||||
if (!exitThread) {
|
||||
goto loopStart;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#pragma pop
|
||||
|
||||
extern "C" s32 checkCardFileDuplicate(s32 slot, s16 fileNo);
|
||||
|
||||
@@ -651,11 +654,13 @@ reportError:
|
||||
}
|
||||
|
||||
extern "C" s32 reportCardThreadError(s32 slot, s32 state, s32 result) {
|
||||
if (result != CARD_RESULT_EXIST && result != -27 && result != CARD_RESULT_NOENT && result != CARD_RESULT_INSSPACE &&
|
||||
(clearAllCardFileEntries(slot), result != CARD_RESULT_BROKEN) && result != CARD_RESULT_ENCODING) {
|
||||
OSReport("DEBUG: UnmountCard %d \n", slot);
|
||||
CARDUnmount(slot);
|
||||
sThread->mounted[slot & 0xFF] = 0;
|
||||
if (result != CARD_RESULT_EXIST && result != -27 && result != CARD_RESULT_NOENT && result != CARD_RESULT_INSSPACE) {
|
||||
clearAllCardFileEntries(slot);
|
||||
if (result != CARD_RESULT_BROKEN && result != CARD_RESULT_ENCODING) {
|
||||
OSReport("DEBUG: UnmountCard %d \n", slot);
|
||||
CARDUnmount(slot);
|
||||
sThread->mounted[slot & 0xFF] = 0;
|
||||
}
|
||||
}
|
||||
OSReport("DEBUG: CardThread error %d %d\n", state, result);
|
||||
markAllCardFilesDirty();
|
||||
@@ -691,25 +696,82 @@ 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, u32 transferSize) {
|
||||
s32 sectorSize;
|
||||
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;
|
||||
s32 result;
|
||||
u32 base;
|
||||
s32 readSize;
|
||||
u32 end;
|
||||
u32 fileSize;
|
||||
s32 offset;
|
||||
s32 sectorSize;
|
||||
address = dir->commentAddr;
|
||||
base = address & 0xFFFFFE00;
|
||||
offset = address - base;
|
||||
readSize = ((address + 0x23F) & 0xFFFFFE00) - base;
|
||||
result = CARDGetSectorSize(slot, (u32*)§orSize);
|
||||
if (result >= CARD_RESULT_READY) {
|
||||
if ((s32)base < 0 || base > (fileSize = (u32)dir->length * sectorSize)) {
|
||||
result = 0;
|
||||
} else {
|
||||
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 imageSize;
|
||||
s32 bannerImageSize = 0;
|
||||
u8 format = dir->bannerFormat & CARD_STAT_BANNER_MASK;
|
||||
u32 iconAddress = dir->iconAddr;
|
||||
iconAddressBase = iconAddress & 0xFFFFFE00;
|
||||
iconAddressOffset = iconAddress - iconAddressBase;
|
||||
u32 transferSize;
|
||||
s32 iconAddressOffset = iconAddress - (iconAddress & 0xFFFFFE00);
|
||||
|
||||
switch (format) {
|
||||
case CARD_STAT_BANNER_C8: {
|
||||
@@ -746,72 +808,71 @@ extern "C" s32 loadCardFileIcons(s32 slot, s32 fileNo, CARDDir* dir) {
|
||||
}
|
||||
}
|
||||
|
||||
s32 shift = 0;
|
||||
s32 iconImageSize = 0;
|
||||
s32 iconCount = 0;
|
||||
s32 iconImageSize;
|
||||
s32 iconFrameSize;
|
||||
s32 icon;
|
||||
BOOL hasTlut;
|
||||
s32 iconCount;
|
||||
s32 shift;
|
||||
|
||||
shift = 0;
|
||||
hasTlut = FALSE;
|
||||
iconImageSize = 0;
|
||||
sThread->icons[slot][fileNo].unk_0x02 = 0;
|
||||
sThread->icons[slot][fileNo].anmMax = 0;
|
||||
sThread->icons[slot][fileNo].anmFrameBits = dir->iconSpeed;
|
||||
sThread->icons[slot][fileNo].unk_0x06 =
|
||||
(dir->iconSpeed & CARD_STAT_SPEED_MASK) << 2;
|
||||
for (icon = 0; icon < CARD_ICON_MAX; ++icon) {
|
||||
sThread->icons[slot][fileNo].unk_0x06 = (dir->iconSpeed & CARD_STAT_SPEED_MASK) << 2;
|
||||
icon = 0;
|
||||
iconCount = 0;
|
||||
while (icon < CARD_ICON_MAX) {
|
||||
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 += 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;
|
||||
++icon;
|
||||
}
|
||||
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) {
|
||||
if (((dir->iconSpeed >> shift) & CARD_STAT_SPEED_MASK) != 0) {
|
||||
s32 iconFormat = (dir->iconFormat >> shift) & CARD_STAT_ICON_MASK;
|
||||
s32 paletteSize;
|
||||
for (iconCount = 0; iconCount < CARD_ICON_MAX; ++iconCount) {
|
||||
if (((dir->iconSpeed >> (iconCount * 2)) & CARD_STAT_SPEED_MASK) != 0) {
|
||||
s32 iconFormat = (dir->iconFormat >> (iconCount * 2)) & CARD_STAT_ICON_MASK;
|
||||
switch (iconFormat) {
|
||||
case CARD_STAT_ICON_C8:
|
||||
paletteSize = 0x400;
|
||||
iconFrameSize = 0x400;
|
||||
hasTlut = TRUE;
|
||||
sThread->icons[slot][fileNo].iconFmt[iconCount] = GX_TF_C8;
|
||||
break;
|
||||
case CARD_STAT_ICON_RGB5A3:
|
||||
paletteSize = 0x800;
|
||||
iconFrameSize = 0x800;
|
||||
sThread->icons[slot][fileNo].iconFmt[iconCount] = GX_TF_RGB5A3;
|
||||
break;
|
||||
case CARD_STAT_ICON_NONE: {
|
||||
paletteSize = 0;
|
||||
u8* iconPalette =
|
||||
&sThread->icons[slot][fileNo].iconFmt[iconCount];
|
||||
*iconPalette = iconPalette[-1];
|
||||
iconFrameSize = 0;
|
||||
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] =
|
||||
paletteSize + sThread->icons[slot][fileNo].iconOffset[iconCount];
|
||||
if (iconCount < CARD_ICON_MAX - 1) {
|
||||
sThread->icons[slot][fileNo].iconOffset[(u32)(iconCount + 1)] =
|
||||
iconFrameSize + sThread->icons[slot][fileNo].iconOffset[iconCount];
|
||||
} else {
|
||||
sThread->icons[slot][fileNo].iconTlutOffset =
|
||||
paletteSize + sThread->icons[slot][fileNo].iconOffset[iconCount];
|
||||
iconFrameSize + sThread->icons[slot][fileNo].iconOffset[iconCount];
|
||||
}
|
||||
iconImageSize += paletteSize;
|
||||
iconImageSize += iconFrameSize;
|
||||
sThread->icons[slot][fileNo].unk_0x02 =
|
||||
sThread->icons[slot][fileNo].unk_0x02 + 1;
|
||||
} else {
|
||||
@@ -819,8 +880,6 @@ iconSpeedDone:
|
||||
sThread->icons[slot][fileNo].iconOffset[iconCount];
|
||||
break;
|
||||
}
|
||||
++iconCount;
|
||||
shift += 2;
|
||||
}
|
||||
if (hasTlut) {
|
||||
iconImageSize += 0x200;
|
||||
@@ -830,85 +889,30 @@ iconSpeedDone:
|
||||
sThread->icons[slot][fileNo].anmDelta = 1;
|
||||
}
|
||||
|
||||
s32 totalImageSize = iconImageSize + bannerImageSize;
|
||||
u32 transferSize = (totalImageSize + iconAddressOffset + 0x1FF) & 0xFFFFFE00;
|
||||
result = CARDGetSectorSize(slot, (u32*)&local.sectorSize);
|
||||
imageSize = bannerImageSize + iconImageSize;
|
||||
transferSize = (imageSize + iconAddressOffset + 0x1FF) & 0xFFFFFE00;
|
||||
return readCardImages(slot, fileNo, dir, fileInfo, iconAddress & 0xFFFFFE00, iconAddressOffset,
|
||||
imageSize, transferSize);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -3,9 +3,6 @@
|
||||
|
||||
#include "titledb.h"
|
||||
|
||||
// actually needed to match.
|
||||
#pragma sym on
|
||||
|
||||
namespace ipl {
|
||||
namespace scene {
|
||||
#define COMMAND_FN(FUNCTION_HEADER, TAG, APP_BOX, SAVE_BOX, WII_TITLE_ID, SD_TITLE_ID) \
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
|
||||
#undef IPL_CHANNEL_TITLE_NOVTABLE
|
||||
|
||||
// :)
|
||||
#define PREV_LOADED_INDEX (1 - mLoadedIndex)
|
||||
|
||||
namespace ipl {
|
||||
@@ -646,6 +645,7 @@ namespace ipl {
|
||||
|
||||
if (System::getFader()->getStatus() == EGG::Fader::PREPARE_IN && System::isReceiveScheduleStopped()) {
|
||||
if (System::getNwc24Manager() && !System::getNwc24Manager()->isReceivingIdle()) {
|
||||
// MWCC needs the shared exit label to preserve these branches.
|
||||
goto scn_continue;
|
||||
}
|
||||
|
||||
@@ -708,7 +708,7 @@ namespace ipl {
|
||||
memcpy(titleName[1], System::getChannelManager()->getTitleName(mChanPage, mChanIndex, 1), sizeof(titleName[1]));
|
||||
|
||||
char code[] = {((char*)&mCurGameCode)[0], ((char*)&mCurGameCode)[1]};
|
||||
__OSCreatePlayRecord(titleName[0], &((char*)&titleId)[sizeof(ESTitleId32)] /* :( */, code);
|
||||
__OSCreatePlayRecord(titleName[0], &((char*)&titleId)[sizeof(ESTitleId32)], code);
|
||||
OSReport("Create play recode\n"); // @BUG: recode instead of record
|
||||
|
||||
BS2SetStateFlags();
|
||||
@@ -801,7 +801,7 @@ namespace ipl {
|
||||
memcpy(titleName[1], System::getChannelManager()->getTitleName(mChanPage, mChanIndex, 1), sizeof(titleName[1]));
|
||||
|
||||
char code[] = {((char*)&mCurGameCode)[0], ((char*)&mCurGameCode)[1]};
|
||||
__OSCreatePlayRecord(titleName[0], &((char*)&titleId)[sizeof(ESTitleId32)] /* :( */, code);
|
||||
__OSCreatePlayRecord(titleName[0], &((char*)&titleId)[sizeof(ESTitleId32)], code);
|
||||
OSReport("Create play recode\n"); // @BUG: recode instead of record
|
||||
|
||||
System::getBS2Manager()->startRVLGame();
|
||||
@@ -1213,6 +1213,7 @@ namespace ipl {
|
||||
}
|
||||
}
|
||||
|
||||
// MWCC needs IRO level 0 to preserve the BS2 argument-base registers.
|
||||
#pragma push
|
||||
#pragma ppc_iro_level 0
|
||||
void ChannelTitle::calcNormalParentalDialog() {
|
||||
@@ -1313,7 +1314,7 @@ namespace ipl {
|
||||
}
|
||||
}
|
||||
|
||||
// uhh
|
||||
// MWCC needs IRO level 0 to preserve ticket-check branches and register saves.
|
||||
#pragma push
|
||||
#pragma ppc_iro_level 0
|
||||
void ChannelTitle::calcNormalWaitTmd() {
|
||||
@@ -1455,6 +1456,7 @@ namespace ipl {
|
||||
}
|
||||
}
|
||||
|
||||
// MWCC needs IRO level 1 to preserve progress-bar register allocation.
|
||||
#pragma push
|
||||
#pragma ppc_iro_level 1
|
||||
void ChannelTitle::calcNormalUpdating() {
|
||||
@@ -1926,6 +1928,7 @@ namespace ipl {
|
||||
bool noDisk = BS2State == bs2::IPL_STATE_NO_DISK;
|
||||
|
||||
nw4r::lyt::Group* group = mpDiskBnrLayout->FindGroupByName(scDiskGroups[DISK_ANIM_GRP_COMMENT]);
|
||||
// MWCC needs group references to preserve pane-loop register allocation.
|
||||
nw4r::lyt::Group*& groupAlias = group;
|
||||
for (nw4r::lyt::PaneLinkList::Iterator it = groupAlias->GetPaneList().GetBeginIter(); it != groupAlias->GetPaneList().GetEndIter();
|
||||
it++) {
|
||||
@@ -2152,8 +2155,7 @@ namespace ipl {
|
||||
}
|
||||
|
||||
BOOL ChannelTitle::checkNetSetting(int page, int index) {
|
||||
// i hate this
|
||||
|
||||
// MWCC needs the shared return label to preserve this branch sequence.
|
||||
BOOL flag = System::getChannelManager()->getSceneID(page, index) == SCENE_DISK_CHANNEL;
|
||||
if (flag) {
|
||||
goto yes;
|
||||
@@ -2552,9 +2554,8 @@ namespace ipl {
|
||||
if (mLimitType == LIMIT_TYPE_TIME) {
|
||||
*hour = mTimeLimitRemain / (60 * 60);
|
||||
|
||||
// FAKEMATCH: should be modular division. not whatever this is
|
||||
// MWCC needs subtraction through the stored hour value to preserve this sequence.
|
||||
*minute = (mTimeLimitRemain - ((60 * 60) * *hour)) / 60;
|
||||
//*minute = (u32)(mTimeLimitRemain % (60 * 60)) / 60U;
|
||||
return TRUE;
|
||||
} else {
|
||||
return FALSE;
|
||||
@@ -2675,8 +2676,6 @@ namespace ipl {
|
||||
chanTtl->mbTmdReady = true;
|
||||
}
|
||||
|
||||
#pragma push
|
||||
#pragma ppc_iro_level 1
|
||||
void ChannelTitle::getTicketLimitTask(void* work) {
|
||||
ChannelTitle* chanTtl = static_cast<ChannelTitle*>(work);
|
||||
|
||||
@@ -2694,7 +2693,6 @@ namespace ipl {
|
||||
}
|
||||
chanTtl->mbTicketLimitReady = true;
|
||||
}
|
||||
#pragma pop
|
||||
|
||||
void ChannelTitle::deleteTmpTitleContentTask(void* work) {
|
||||
ChannelTitle* chanTtl = static_cast<ChannelTitle*>(work);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user