Compare commits

..

1 Commits

Author SHA1 Message Date
coah
379c84d5f6 fix(TMC_JPEG): use consistent two-dimensional sampling tables 2026-10-05 09:32:25 -05:00
301 changed files with 7231 additions and 51058 deletions

View File

@@ -11,9 +11,6 @@ splits: 'config/43U/splits.txt'
ldscript_template: 'config/ldscript_ipl2.lcf'
force_active:
- SORead
- SOFcntl
- SOInetPtoN
- SOGetSockOpt
- SOSetInterfaceOpt
- fprintf

View File

@@ -897,16 +897,13 @@ src/scene/setting/iplRakuRakuThread.cpp:
.sbss start:0x81698C60 end:0x81698C70
src/scene/setting/AOSS.c:
.bss start:0x810BDEF8 end:0x810BE838
.bss start:0x810BDEF8 end:0x810BECA0
.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

View File

@@ -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$1129 = .bss:0x810B1580; // type:object size:0x800 scope:local
Flags0 = .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
s_packetState = .bss:0x810BE838; // type:object size:0x68
s_crcTable = .bss:0x810BE8A0; // type:object size:0x400
AOSS_810BE838 = .bss:0x810BE838; // type:object size:0x68
AOSS_810BE8A0 = .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
@@ -144,7 +144,7 @@ lbl_810C8A80 = .bss:0x810C8A80; // type:object size:0x40 align:32
lbl_810C8AC0 = .bss:0x810C8AC0; // type:object size:0x40 align:32
s_mutex = .bss:0x810C8B00; // type:object size:0x18 scope:local
s_cdbWiiId = .bss:0x810C8B20; // type:object size:0x40 scope:local
ncdMutex = .bss:0x810C8B60; // type:object size:0x18
ncdMutex = .bss:0x810C8B60; // type:object size:0x20
ncdCommonResult = .bss:0x810C8B80; // type:object size:0x20 align:32 data:4byte
ncdCommonVector = .bss:0x810C8BA0; // type:object size:0x20 align:32 data:4byte
NHTTPiStaticResource = .bss:0x810C8BC0; // type:object size:0x40 data:4byte
@@ -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__Q33ipl5scene15SDChannelSelectFUx = .text:0x813DB478; // type:function size:0x5C
enqueueMoveNotice__Q33ipl5scene15SDChannelSelectFUlUlUl = .text:0x813DB478; // type:function size:0x5C
enqueueStateNotice__Q33ipl5scene15SDChannelSelectFUxUl = .text:0x813DB4D4; // type:function size:0x5C
enqueueErrorNotice__Q33ipl5scene15SDChannelSelectFPQ33ipl12NandSDWorker11TitleIdListPQ33ipl12NandSDWorker11TitleIdList = .text:0x813DB530; // type:function size:0x5C
enqueueCommandNotice__Q33ipl5scene15SDChannelSelectFPQ33ipl12NandSDWorker11TitleIdListPQ33ipl12NandSDWorker11TitleIdListPQ33ipl12NandSDWorker11TitleIdList = .text:0x813DB58C; // type:function size:0x60
enqueueDeleteNotice__Q33ipl5scene15SDChannelSelectFUx = .text:0x813DB5EC; // type:function size:0x60
enqueueErrorNotice__Q33ipl5scene15SDChannelSelectFUlUl = .text:0x813DB530; // type:function size:0x5C
enqueueCommandNotice__Q33ipl5scene15SDChannelSelectFUlUlUl = .text:0x813DB58C; // type:function size:0x60
enqueueDeleteNotice__Q33ipl5scene15SDChannelSelectFUlUlUl = .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__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
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
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
__as__Q43ipl5scene8SDMemory10TitleRangeFRCQ43ipl5scene8SDMemory10TitleRange = .text:0x813E6FA0; // type:function size:0x14 scope:weak
iplSDChannelTitle_copyTitleRange = .text:0x813E6FA0; // type:function size:0x14
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
__ct__Q34nw4r2ut5ColorFiiii = .text:0x813EF6C4; // type:function size:0x14
SetTextColor__Q34nw4r3lyt7TextBoxFQ34nw4r2ut5ColorQ34nw4r2ut5Color = .text:0x813EF6D8; // type:function size:0x48
writeFourFlagBytes__Q23ipl5sceneFPUcUcUcUcUc = .text:0x813EF6C4; // type:function size:0x14
setTitleRowColors__Q23ipl5sceneFPQ34nw4r3lyt7TextBoxRCQ34nw4r2ut5ColorRCQ34nw4r2ut5Color = .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:0x264 scope:local
csAninationFile__Q29textinput11predictlang = .rodata:0x816158D8; // type:object size:0x268 scope:local
csAninationFileForSign__Q39textinput8keyboard10signwindow = .rodata:0x81615B40; // type:object size:0x268 scope:local
csPaneNameToControlKey__Q39textinput8keyboard10signwindow = .rodata:0x81615DA8; // type:object size:0x48 scope:local
csLanguageDependencyData__Q39textinput8keyboard10signwindow = .rodata:0x81615DF0; // type:object size:0x50 scope:local
@@ -15632,7 +15632,7 @@ __vt__Q33ipl4math28LinearIntp<Q33ipl4math4VEC2> = .data:0x8164B5E0; // type:obje
__vt__Q33ipl4math31Interporation<Q33ipl4math4VEC2> = .data:0x8164B5F0; // type:object size:0x10
@10018 = .data:0x8164B698; // type:object size:0xB scope:local data:string
@10019 = .data:0x8164B6A3; // type:object size:0xF scope:local data:string
__vt__Q33ipl5scene12UrlProcessor = .data:0x8164B6B8; // type:object size:0x14
__vt__Q33ipl5scene12UrlProcessor = .data:0x8164B6B8; // type:object size:0x18
lbl_8164B6D0 = .data:0x8164B6D0; // type:object size:0x10 data:string
lbl_8164B6E0 = .data:0x8164B6E0; // type:object size:0x1D data:string
lbl_8164B6FD = .data:0x8164B6FD; // type:object size:0x1B data:string
@@ -15765,8 +15765,7 @@ lbl_8164C53A = .data:0x8164C53A; // type:object size:0x14
lbl_8164C54E = .data:0x8164C54E; // type:object size:0x18
lbl_8164C566 = .data:0x8164C566; // type:object size:0xC
lbl_8164C572 = .data:0x8164C572; // type:object size:0xA
__vt__Q33ipl5scene8Calendar = .data:0x8164C57C; // type:object size:0x88
__vt__Q23gui12EventHandler = .data:0x8164C604; // type:object size:0x18 scope:weak
__vt__Q33ipl5scene8Calendar = .data:0x8164C57C; // type:object size:0xA4
scN_CalDay_r = .data:0x8164C620; // type:object size:0xB data:string
scDateAnimPaneNames = .data:0x8164C62C; // type:object size:0x14 data:4byte
scMyIplTopFBrlan = .data:0x8164C640; // type:object size:0x12 data:string
@@ -17727,20 +17726,12 @@ __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
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
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
@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
@@ -22782,7 +22773,10 @@ 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
scCsFatalColor = .sdata:0x81697844; // type:object size:0x4 data:byte
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
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
@@ -23681,8 +23675,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$1963 = .sbss:0x81698A58; // type:object size:0x4 scope:local data:4byte
AudioBufferUnconfigured$2065 = .sbss:0x81698A5C; // 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
ResetTime = .sbss:0x81698A60; // type:object size:0x8 scope:local data:4byte
SpinupDeadline = .sbss:0x81698A68; // type:object size:0x8 scope:local data:4byte
CoverPollTime = .sbss:0x81698A70; // type:object size:0x8 data:4byte
@@ -23690,13 +23684,15 @@ 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
RequiredIos = .sbss:0x81698A88; // type:object size:0x8 data:4byte
RequiredIosHigh = .sbss:0x81698A88; // type:object size:0x4 data:4byte
RequiredIosLow = .sbss:0x81698A8C; // type:object size:0x4 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
CoverOpenTime = .sbss:0x81698AA8; // type:object size:0x8 data:4byte
CoverOpenTimeHigh = .sbss:0x81698AA8; // type:object size:0x4 data:4byte
CoverOpenTimeLow = .sbss:0x81698AAC; // type:object size:0x4 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

View File

@@ -658,7 +658,7 @@ config.libs = [
Object(Matching, "system/iplChannelRsoThread.cpp"),
Object(Matching, "system/RsoSystem.cpp"),
Object(Matching, "system/iplCdbBackup.cpp"),
Object(Matching, "system/odh.cpp"),
Object(NonMatching, "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(Matching, "utility/iplESMisc.cpp"),
Object(NonMatching, "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(Matching, "iplwww/www_wiisetting.cpp"),
Object(Equivalent, "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(Matching, "BS2/BS2Mach.c"),
Object(Matching, "BS2/BS2Update.c"),
Object(NonMatching, "BS2/BS2Mach.c"),
Object(NonMatching, "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(Matching, "scene/address/iplAddressEdit.cpp"),
Object(NonMatching, "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(Matching, "scene/memoryCard/iplMemoryCardManager.cpp"),
Object(NonMatching, "scene/memoryCard/iplMemoryCardManager.cpp"),
Object(Matching, "scene/memoryCard/iplGCSaveData.cpp"),
Object(Matching, "scene/memoryCard/iplGCWindow.cpp"),
]
@@ -849,12 +849,12 @@ config.libs = [
]
),
IPLSection("sdChannelSelect", [
Object(Matching, "scene/sdChannelSelect/iplSDChannelSelect.cpp"),
Object(NonMatching, "scene/sdChannelSelect/iplSDChannelSelect.cpp"),
Object(Matching, "scene/sdChannelSelect/iplSDChannelObj.cpp"),
]
),
IPLSection("sdChannelTitle", [
Object(Matching, "scene/sdChannelTitle/iplSDChannelTitle.cpp"),
Object(NonMatching, "scene/sdChannelTitle/iplSDChannelTitle.cpp"),
]
),
IPLSection("sdButton", [
@@ -864,11 +864,11 @@ config.libs = [
]
),
IPLSection("sdChannelMemory", [
Object(Matching, "scene/sdChannelMemory/iplSDMemory.cpp"),
Object(NonMatching, "scene/sdChannelMemory/iplSDMemory.cpp"),
]
),
IPLSection("setting", [
Object(Matching, "scene/setting/iplSetting.cpp"),
Object(NonMatching, "scene/setting/iplSetting.cpp"),
Object(Matching, "scene/setting/iplSensitivity.cpp"),
Object(Matching, "scene/setting/iplNCDSetting.cpp"),
Object(Matching, "scene/setting/iplParental.cpp"),
@@ -878,9 +878,8 @@ config.libs = [
Object(Matching, "scene/setting/iplAOSSThread.cpp"),
Object(NonMatching, "scene/setting/AOSSLink.c"),
Object(Matching, "scene/setting/iplRakuRakuThread.cpp"),
Object(NonMatching, "scene/setting/AOSS.c", extra_cflags=["-O4,p", "-inline on,noauto"]),
Object(Matching, "scene/setting/AOSSData.c"),
Object(NonMatching, "scene/setting/ATERM.c", mw_version="GC/3.0a5", extra_cflags=["-O4,p", "-inline on"]),
Object(NonMatching, "scene/setting/AOSS.c", extra_cflags=["-O4,p", "-inline off"]),
Object(NonMatching, "scene/setting/ATERM.c", extra_cflags=["-O4,p", "-inline on"]),
]
),
IPLSection("settingSelect", [
@@ -912,13 +911,13 @@ config.libs = [
Object(Matching, "keyboard/tiPcKeyboard.cpp", extra_cflags=["-O4,p"]),
Object(Matching, "keyboard/tiCellPhone.cpp", extra_cflags=["-O4,p"]),
Object(NonMatching, "keyboard/tiInputForm.cpp", extra_cflags=["-O4,p"]),
Object(Matching, "keyboard/tiCandidateBox.cpp", extra_cflags=["-O4,p"]),
Object(NonMatching, "keyboard/tiCandidateBox.cpp", extra_cflags=["-O4,p"]),
Object(Matching, "keyboard/tiToolBar.cpp", extra_cflags=["-O4,p"]),
Object(Matching, "keyboard/tiPredictLang.cpp", extra_cflags=["-O4,p"]),
Object(Matching, "keyboard/tiSignWindow.cpp", extra_cflags=["-O4,p"]),
Object(NonMatching, "keyboard/tiString.cpp", extra_cflags=["-O4,p"]),
Object(NonMatching, "keyboard/tiAtokString.cpp", extra_cflags=["-O4,p"]), # for 4.3J
Object(Matching, "keyboard/tiZiString.cpp", extra_cflags=["-O4,p"]), # for 4.3U and 4.3E
Object(NonMatching, "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"]),
@@ -942,7 +941,7 @@ config.libs = [
]
),
IPLSection("channelScript", [
Object(Matching, "channelScript/CHANSVm.c"),
Object(NonMatching, "channelScript/CHANSVm.c"),
Object(Matching, "channelScript/systemmenu/VmSystem.c"),
Object(Matching, "channelScript/systemmenu/iplCSSystem.cpp"),
Object(Matching, "channelScript/systemmenu/iplCSLayout.cpp"),
@@ -984,10 +983,10 @@ config.libs = [
ZI8Lib("zi8clib", [
Object(Matching, "clib/zaddress.c"),
Object(Matching, "clib/zconvert.c"),
Object(Matching, "clib/zi81key.c"),
Object(Matching, "clib/zi8alpha.c"),
Object(NonMatching, "clib/zi81key.c"),
Object(NonMatching, "clib/zi8alpha.c"),
Object(Matching, "clib/zi8alts.c"),
Object(Matching, "clib/zi8cgetc.c"),
Object(NonMatching, "clib/zi8cgetc.c"),
Object(Matching, "clib/zi8cinfo.c"),
Object(Matching, "clib/zi8copy.c"),
Object(Matching, "clib/zi8dawg.c"),
@@ -1001,17 +1000,17 @@ config.libs = [
Object(Matching, "clib/zi8pud2.c"),
Object(Matching, "clib/Zi8punct.c"),
Object(Matching, "clib/zi8space.c"),
Object(Matching, "clib/zi8uwd.c"),
Object(NonMatching, "clib/zi8uwd.c"),
Object(Matching, "clib/zi8ver.c"),
Object(Matching, "clib/zi8ZHuwd.c"),
Object(Matching, "clib/zidawg1.c"),
Object(Matching, "clib/zikorean.c"),
Object(Matching, "clib/ziswordw.c"),
Object(Matching, "clib/zkokeyp.c"),
Object(NonMatching, "clib/zkokeyp.c"),
Object(Matching, "clib/zierror.c"),
Object(Matching, "clib/zmtkey.c"),
Object(Matching, "clib/zoemdata.c"),
Object(Matching, "clib/zprepare.c"),
Object(NonMatching, "clib/zprepare.c"),
]
),
# RevoEX
@@ -1049,7 +1048,7 @@ config.libs = [
Object(Matching, "net/hmac.c"),
Object(Matching, "net/neterrorcode.c"),
Object(Matching, "net/NETVersion.c"),
Object(Matching, "net/aes.c"),
Object(NonMatching, "net/aes.c"),
Object(Matching, "net/wireless_macaddr.c"),
]
),
@@ -1058,11 +1057,11 @@ config.libs = [
Object(Matching, "nhttp/NHTTP_control.c"),
Object(Matching, "nhttp/NHTTP_list.c"),
Object(Matching, "nhttp/NHTTP_os_RVL.c"),
Object(Matching, "nhttp/NHTTP_recvbuf.c", mw_version="GC/3.0a5"),
Object(NonMatching, "nhttp/NHTTP_recvbuf.c"),
Object(Matching, "nhttp/NHTTP_request.c"),
Object(Matching, "nhttp/NHTTP_response.c"),
Object(Matching, "nhttp/NHTTP_socket_RVL.c"),
Object(Matching, "nhttp/NHTTP_stdlib_RVL.c", mw_version="GC/3.0a5"),
Object(NonMatching, "nhttp/NHTTP_stdlib_RVL.c"),
Object(Matching, "nhttp/NHTTP_thread.c"),
Object(Matching, "nhttp/d_nhttp_private.c"),
Object(Matching, "nhttp/d_nhttp.c"),
@@ -1097,7 +1096,7 @@ config.libs = [
),
RevoEXLib("so", [
Object(Matching, "so/SOCommon.c"),
Object(Matching, "so/SOBasic.c"),
Object(NonMatching, "so/SOBasic.c"),
Object(Matching, "so/SOInformation.c"),
Object(Matching, "so/SOOption.c"),
]
@@ -1202,7 +1201,7 @@ config.libs = [
Object(Matching, "buffer/mkhdec3.c"),
Object(Matching, "buffer/buffer_system.c"),
Object(Matching, "buffer/getcode.c"),
Object(Matching, "buffer/idct_block_var.c"),
Object(NonMatching, "buffer/idct_block_var.c"),
Object(Matching, "api/decapi.c"),
@@ -1210,14 +1209,14 @@ config.libs = [
Object(Matching, "jpegdec/jdec_main.c"),
Object(Matching, "jpegdec/jpformat.c"),
Object(Matching, "exif/exif_parse.c"),
Object(NonMatching, "exif/exif_parse.c"),
Object(Matching, "reschange/iqdec_resolution_change_a3.c"),
Object(Matching, "reschange/idct_resolution_change_var.c"),
Object(Matching, "texturecvtr/Texture_MCUtoY8U8V8.c"),
Object(Matching, "texturecvtr/Texture_MCUtoRGB565.c"),
Object(Matching, "texturecvtr/Texture_MCUtoRGBA8.c"),
Object(NonMatching, "texturecvtr/Texture_MCUtoY8U8V8.c"),
Object(NonMatching, "texturecvtr/Texture_MCUtoRGB565.c"),
Object(NonMatching, "texturecvtr/Texture_MCUtoRGBA8.c"),
Object(Matching, "b65/iqdec_b65_frv32.c"),
]
@@ -1324,7 +1323,7 @@ config.libs = [
Object(Matching, "lyt/lyt_layout.cpp"),
Object(Matching, "lyt/lyt_picture.cpp"),
Object(Matching, "lyt/lyt_textBox.cpp"),
Object(Matching, "lyt/lyt_window.cpp"),
Object(Equivalent, "lyt/lyt_window.cpp"),
Object(Matching, "lyt/lyt_bounding.cpp"),
Object(Matching, "lyt/lyt_material.cpp"),
Object(Matching, "lyt/lyt_drawinfo.cpp"),
@@ -1691,7 +1690,7 @@ config.libs = [
Object(Matching, "fa/pdm_api.c"),
Object(Matching, "fa/pdm_bpb.c"),
Object(Matching, "fa/pdm_disk.c"),
Object(Matching, "fa/pdm_partition.c"),
Object(NonMatching, "fa/pdm_partition.c"),
Object(Matching, "fa/pf_cache.c"),
Object(Matching, "fa/pf_cluster.c"),
Object(Matching, "fa/pf_dir.c"),
@@ -1855,7 +1854,7 @@ config.libs = [
Object(Matching, "fa/kernel/pfk_api.c"),
Object(Matching, "fa/driver/nand_drv.c"),
Object(Matching, "fa/driver/sd_drv.c"),
Object(NonMatching, "fa/driver/sd_drv.c"),
Object(Matching, "fa/driver/pfd_cmn.c"),
Object(Matching, "fa/driver/msc_drv.c"),
@@ -1869,7 +1868,7 @@ config.libs = [
]
),
RVLSDKLib("nup", [
Object(Matching, "nup/nup.cpp"),
Object(NonMatching, "nup/nup.cpp"),
Object(Matching, "nup/nup_nhttp.cpp"),
Object(Matching, "nup/nup_mem.cpp"),
]
@@ -1886,7 +1885,7 @@ config.libs = [
]
),
RVLSDKLib("kbd", [
Object(Matching, "kbd/kbd_lib.c"),
Object(NonMatching, "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"),

View File

@@ -1,7 +1,7 @@
# Assembly inventory
4.3U, 2026-10-08. 166 functions contain 168 assembly
bodies/blocks: 162 ORIGINAL functions and 4 PLACEHOLDER functions.
4.3U, 2026-10-05. 173 functions contain 175 assembly
bodies/blocks: 162 ORIGINAL functions and 11 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,7 +88,9 @@ 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 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/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/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. |
@@ -160,6 +162,7 @@ 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. |
@@ -186,7 +189,11 @@ 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/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/TVRC.cpp` | `TVRCSendStartAsync` | PLACEHOLDER | IR command setup; best recorded C 99.77273%, 198/198 instructions, seven differences, [rx2](../tools/decomp-assist/rx2.attempts.md); newer [rx17][rx17] 99.747475%. |
| `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/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. |
@@ -194,6 +201,7 @@ 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

View File

@@ -7,7 +7,7 @@
extern "C" {
#endif
typedef CHANSVmObjHdr* (*VmConvertFunc)(CHANSVm*, CHANSVmObjType, const CHANSVmObjHdr*);
typedef CHANSVmObjHdr* (*VmConvertFunc)(CHANSVm*, CHANSVmObjType, CHANSVmObjHdr*);
typedef struct VmConvertEntry {
VmConvertFunc convFunc[6]; // 0x00

View File

@@ -12,7 +12,6 @@ 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);

View File

@@ -77,7 +77,7 @@ namespace textinput {
class Base : public CommandSender {
public:
#if defined(TIMANAGER_IMPLEMENTATION) || defined(TI_CANDIDATEBOX_SAMPLE_CLASS)
#ifdef TIMANAGER_IMPLEMENTATION
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:
#if defined(TIMANAGER_IMPLEMENTATION) || defined(TI_CANDIDATEBOX_SAMPLE_CLASS)
#ifdef TIMANAGER_IMPLEMENTATION
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:
#if defined(TIMANAGER_IMPLEMENTATION) || defined(TI_CANDIDATEBOX_SAMPLE_CLASS)
#ifdef TIMANAGER_IMPLEMENTATION
LayoutByNW4R(Manager* manager, nw4r::lyt::MultiArcResourceAccessor* accessor, EventObserver* observer, const char* layoutName)
: Base(manager), nw4rmanager::Layout(accessor, layoutName, observer), mEventHandler(this), mpTiString(NULL),
mTextArea(0, this, this), mLeftScroll(1, this, this), mRightScroll(2, this, this), mOnOffButton(3, this, this),
@@ -371,15 +371,6 @@ 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)

View File

@@ -30,7 +30,6 @@ namespace textinput {
class Base;
class EventHandler;
class LayoutByNW4R;
struct InputFormAnimationFile;
#endif
class EditBuffer {
#ifdef TIMANAGER_IMPLEMENTATION
@@ -357,7 +356,6 @@ namespace textinput {
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
friend class EventHandler;
inline const nw4r::lyt::Pane* getLanguageTextPane() const;
inline void addButtonAnimation(MEMAllocator*, nw4rmanager::AnmPane*, const InputFormAnimationFile* const&, const char*);
#endif
public:
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)

View File

@@ -129,7 +129,7 @@ namespace textinput {
#ifdef TIHWKEYBOARD_IMPLEMENTATION
EventObserver* getEventObserverForHardware() const { return mpEventObserver; }
#endif
#if defined(TISIGNWINDOW_IMPLEMENTATION) || defined(IPL_ADDRESS_EDIT_CPP)
#ifdef TISIGNWINDOW_IMPLEMENTATION
virtual InputForm* getInputForm();
#else
virtual InputForm* getInputForm() { return mpInputForm; }

View File

@@ -96,11 +96,7 @@ namespace textinput {
#else
virtual void sendCommand(u32, void*);
#endif
#ifdef TI_PREDICTLANG_SAMPLE_CLASS
virtual void updateFromReceiver(u32, void*);
#else
virtual void updateFromReceiver(u32, void*) {}
#endif
nw4r::ut::Link mLink; // 0x00

View File

@@ -105,7 +105,7 @@ namespace ipl {
#ifdef IPL_CHANNEL_TITLE_NOVTABLE
template <typename T>
class HermiteIntp : public utility::FrameController {
class __declspec(novtable) HermiteIntp : public utility::FrameController {
public:
HermiteIntp() {}
virtual ~HermiteIntp();
@@ -296,6 +296,45 @@ 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

View File

@@ -50,7 +50,6 @@ 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*);

View File

@@ -180,7 +180,6 @@ 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;

View File

@@ -35,7 +35,11 @@ namespace ipl {
MemoryBase* mpBase; // 0x0C
};
#ifdef IPL_CHANNEL_TITLE_NOVTABLE
class __declspec(novtable) MemoryBase {
#else
class MemoryBase {
#endif
public:
class Anm {
public:

View File

@@ -166,11 +166,11 @@ namespace ipl {
void update_file_array(u8 slot);
void update_change_cardstate(u8 slot);
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);
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 wchar_t* getComment(u8 slot, s16 index, int which);
const GXTexObj* create_banner(u8 slot, s16 index);
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:
const GXTexObj* initBannerTexture(u8 slot, s32 file, void* data) {
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,22 +203,6 @@ 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

View File

@@ -142,9 +142,14 @@ namespace ipl {
u32 mTransferStatus;
u64 mTransferStartTime;
s32 mTransferFrame;
NandSDWorker::TitleIdList mTitleList;
NandSDWorker::TitleIdList mNandTitleList;
NandSDWorker::TitleIdList mSDTitleList;
struct TitleListState {
ESTitleId* mpTitles;
u32 mCount;
ESTitleId* mpSecondaryTitles;
u32 mSecondaryCount;
ESTitleId* mpNames;
u32 mNameCount;
} mTitleListState;
scroller mScroller;
s32 mButtonState;
u8 mControllerFlags[4];

View File

@@ -177,8 +177,8 @@ namespace ipl {
const controller::Interface* controller);
BOOL onEventDerived(const char* paneName, u32 event,
controller::Interface* controller);
bool collectTitlesByUsage(s32* firstUsage, s32* secondUsage,
ESTitleId* titleIds, wchar_t (*titleNames)[21],
bool collectTitlesByUsage(const s32* firstUsage, const s32* secondUsage,
ESTitleId* titleIds, char* titleNames,
u32* titleCount);
static const char* mscChannelPaneNames[PAGE_COUNT][MAX_CHANNEL_INDEX];
@@ -197,8 +197,6 @@ namespace ipl {
friend class SDChannelSelectEventHandler;
friend class SDChannelSelectButtonEventHandler;
#endif
friend class SDMemory;
void enqueueStartNotice();
bool enqueueFinishNotice();
bool enqueueNotice(u32 highTitleId, u32 lowTitleId, u32 result);
@@ -206,14 +204,11 @@ namespace ipl {
bool enqueuePageNotice();
bool enqueueResultNotice(u32 result);
bool enqueueChannelNotice(u64 titleId, u32 value);
bool enqueueMoveNotice(ESTitleId titleId);
bool enqueueMoveNotice(u32 controller, u32 page, u32 index);
bool enqueueStateNotice(u64 titleId, u32 state);
bool enqueueErrorNotice(NandSDWorker::TitleIdList* newTitles,
NandSDWorker::TitleIdList* replacingTitles);
bool enqueueCommandNotice(NandSDWorker::TitleIdList* titles,
NandSDWorker::TitleIdList* foundTitles,
NandSDWorker::TitleIdList* badTitles);
bool enqueueDeleteNotice(ESTitleId titleId);
bool enqueueErrorNotice(u32 page, u32 index);
bool enqueueCommandNotice(u32 page, u32 index, u32 command);
bool enqueueDeleteNotice(u32 controller, u32 page, u32 index);
void clearCommandQueue();
void clearNoticeQueue();
void calcChannelObjects();
@@ -226,7 +221,7 @@ namespace ipl {
int getCenterChannelIndex(const char* paneName) const;
nw4r::lyt::Pane* getCenterChannelPane(int index) const;
nw4r::lyt::Pane* getChannelPane(int index) const;
static nw4r::math::VEC3 getChannelPanePosition(SDChannelSelect* scene, int index);
static math::VEC3 getChannelPanePosition(SDChannelSelect* scene, int index);
void calcPageAnimations();
void processNormalInput();
void updateArrowVisibility();
@@ -237,17 +232,17 @@ namespace ipl {
void setChannelScissor(const SDChannelObj* channel) const;
bool isCurrentTitleUsageEnough(const s32* usage) const;
void getCurrentTitleUsage(s32* bytes, s32* blocks) const;
bool collectTitlesByChannelOrder(s32* firstUsage, s32* secondUsage,
ESTitleId* titleIds, wchar_t (*titleNames)[21],
bool collectTitlesByChannelOrder(const s32* firstUsage, const s32* secondUsage,
ESTitleId* titleIds, char* titleNames,
u32* titleCount);
bool collectTitlesFromNandUsage(s32* firstUsage, s32* secondUsage,
ESTitleId* titleIds, wchar_t (*titleNames)[21],
bool collectTitlesFromNandUsage(const s32* firstUsage, const s32* secondUsage,
ESTitleId* titleIds, char* titleNames,
u32* titleCount);
bool collectTitlesBySpecialChannels(s32* firstUsage, s32* secondUsage,
ESTitleId* titleIds, wchar_t (*titleNames)[21],
bool collectTitlesBySpecialChannels(const s32* firstUsage, const s32* secondUsage,
ESTitleId* titleIds, char* titleNames,
u32* titleCount);
bool collectTitlesForMode(s32* firstUsage, s32* secondUsage,
ESTitleId* titleIds, wchar_t (*titleNames)[21],
bool collectTitlesForMode(const s32* firstUsage, const s32* secondUsage,
ESTitleId* titleIds, char* titleNames,
u32* titleCount, int searchMode);
bool findAdjacentChannel(int direction, int* page, int* index) const;
void setStateAndPlaySelectSound(int state) NO_INLINE;

View File

@@ -20,19 +20,6 @@ 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);

View File

@@ -50,7 +50,6 @@ namespace ipl {
static void makeMasterkey();
static char* getRequestNum();
static void dump();
private:
static void _initRating();

View File

@@ -18,15 +18,6 @@ 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();

View File

@@ -277,9 +277,6 @@ 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 {

View File

@@ -15,7 +15,7 @@ namespace ipl {
Manager(EGG::Heap* heap);
/** @return The message data in use. */
wchar_t* getMessage(u32 id) const { return mpMessage->getMessage(id); }
const wchar_t* getMessage(u32 id) const { return mpMessage->getMessage(id); }
void setResource(u8* msgData) const { mpMessage->setResource(msgData); }
private:

View File

@@ -302,7 +302,7 @@ namespace ipl {
}
/** @return The Message ID as a Wide-string. */
static wchar_t* getMessage(u32 id) { return smArg.mpMessageMgr->getMessage(id); }
static const wchar_t* getMessage(u32 id) { return smArg.mpMessageMgr->getMessage(id); }
static message::Manager* getMessageManager() { return smArg.mpMessageMgr; }
static void* getFont();

View File

@@ -47,8 +47,6 @@ 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();

View File

@@ -22,11 +22,7 @@ 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);
@@ -43,12 +39,4 @@ 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

View File

@@ -27,11 +27,7 @@ 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);
@@ -40,12 +36,6 @@ 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

View File

@@ -432,8 +432,8 @@ static void* allocate_from_var_pools(__mem_pool_obj* pool, unsigned int size, un
}
static void* soft_allocate_from_var_pools(__mem_pool_obj* pool, unsigned int size, unsigned int* out) {
Block* bp;
SubBlock* ptr;
register Block* bp;
register SubBlock* ptr;
size = (size + 15) & ~7;
if (size < 0x50) {
@@ -681,9 +681,9 @@ static unsigned int __pool_allocate_resize(__mem_pool_obj* pool, void* ptr, unsi
return 0;
}
void* malloc(unsigned int size) {
void* malloc(register unsigned int size) {
void* rv;
__mem_pool_obj* pool_obj;
register __mem_pool_obj* pool_obj;
if (size == 0) {
goto null_return;
@@ -712,8 +712,8 @@ void free(void* ptr) {
}
void* realloc(void* ptr, unsigned int size) {
unsigned int rv = size;
__mem_pool_obj* pool;
register unsigned int rv = size;
register __mem_pool_obj* pool;
unsigned int current_size;
unsigned int orig_size;
@@ -773,8 +773,8 @@ void* realloc(void* ptr, unsigned int size) {
}
void* calloc(unsigned int nmemb, unsigned int size) {
void* ptr;
unsigned int total;
register void* ptr;
register unsigned int total;
__mem_pool_obj* pool_obj;
pool_obj = (__mem_pool_obj*)get_malloc_pool();

View File

@@ -742,7 +742,7 @@ int __sformatter(int (*ReadProc)(void*, int, int), void* ReadProcArg, const char
*(long*)arg_ptr = chars_read;
break;
case char_argument:
*arg_ptr = chars_read;
*(char*)arg_ptr = chars_read;
break;
case long_long_argument:
*(long long*)arg_ptr = chars_read;

View File

@@ -552,6 +552,8 @@ long double __strtold(int max_width, int (*ReadProc)(void*, int, int), void* Rea
if (sig_negative && success(scan_state)) {
result = -result;
}
return result;
} else {
unsigned mantissa_bit, dbl_bit;
unsigned one_bit;
@@ -628,8 +630,9 @@ long double __strtold(int max_width, int (*ReadProc)(void*, int, int), void* Rea
}
result = *(long double*)dbl_bits;
return result;
}
return result;
}
double strtod(const char* str, char** end) {

View File

@@ -17,7 +17,7 @@ wchar_t* wmemset(wchar_t* dest, wchar_t ch, size_t num) {
wchar_t* wmemchr(wchar_t* ptr, wchar_t ch, size_t num) {
while (num != 0) {
if (*ptr == ch) {
return ptr;
return (wchar_t*)ptr;
}
ptr++;

View File

@@ -123,7 +123,7 @@ namespace nw4r {
const math::MTX34& GetMtx() const { return mMtx; }
void SetMtx(const math::MTX34& mtx) { mMtx = mtx; }
u8 GetAlpha() const { return mAlpha; }
u8 GetAlpha() { return mAlpha; }
void SetAlpha(u8 alpha) { mAlpha = alpha; }
const char* GetName() const { return mName; }

View File

@@ -55,14 +55,16 @@ 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); }

View File

@@ -1,21 +1,10 @@
#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[];
extern "C" char scLytFatalMsg[] = "Error#004\nAn error has occurred.\nThe system files are corrupted.";
#undef NW4R_ASSERT
#define NW4R_GLOBAL_ASSERT(x) \
@@ -37,6 +26,18 @@ extern "C" char scLytFatalMsg[];
} \
}
#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);
@@ -173,22 +174,8 @@ 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) {
@@ -401,17 +388,7 @@ namespace nw4r {
detail::DrawQuad(polPt, polSize, GX_TEXMAP1, texCds, bUseVtxCol ? vtxColors : NULL, alpha); \
}
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(LT, TEXTUREFLIP_NONE);
DRAW_QUAD_FOR_FRAME_1(RT, TEXTUREFLIP_H);
DRAW_QUAD_FOR_FRAME_1(RB, TEXTUREFLIP_180);
DRAW_QUAD_FOR_FRAME_1(LB, TEXTUREFLIP_V);

View File

@@ -28,7 +28,7 @@ namespace nw4r {
}
void WsdTrack::Start(const void* wsdData, int index) {
mWsdData = wsdData;
mWsdData = (void*)wsdData;
mIndex = index;
}

View File

@@ -77,17 +77,17 @@ namespace nw4r {
dataSheetsOff = ROUNDUP(offsetof(ArchiveFontBinaryLayout, glgr.inner.nameOffsets) + countName * sizeof(u16), 4);
data0AOff = ROUNDUP(dataSheetsOff + countSheet * sizeof(u32), 4);
data0COff = ROUNDUP(data0AOff + count0A * sizeof(u32), 4);
dataSheets = (const u32*)(dataSheetsOff + (u32)fontData);
data0A = (const u32*)(data0AOff + (u32)fontData);
data0C = (const u32*)(data0COff + (u32)fontData);
dataSheets = (const u32*)((u32)dataSheetsOff + (u32)fontData);
data0A = (const u32*)((u32)data0AOff + (u32)fontData);
data0C = (const u32*)((u32)data0COff + (u32)fontData);
flagsSheetsOff = ROUNDUP(data0COff + count0CWork * sizeof(u32), 4);
flags0AOff = ROUNDUP(flagsSheetsOff + stepSheets * countName, 4);
flags0COff = ROUNDUP(flags0AOff + step0A * countName, 4);
flagsSheets = (const u32*)(flagsSheetsOff + (u32)fontData);
flags0A = (const u32*)(flags0AOff + (u32)fontData);
flags0C = (const u32*)(flags0COff + (u32)fontData);
flagsSheets = (const u32*)((u32)flagsSheetsOff + (u32)fontData);
flags0A = (const u32*)((u32)flags0AOff + (u32)fontData);
flags0C = (const u32*)((u32)flags0COff + (u32)fontData);
loadedSheetCount = 0;
loadedSmth0ASize = 0;
@@ -102,7 +102,7 @@ namespace nw4r {
offsetPGlgr = (const HeaderedGlyphGroups*)((const u8*)offsetPGlgr + 2), j++) {
groupName = (const char*)((u32)offsetPGlgr->inner.nameOffsets[0] + (u32)fontData);
if (*includedGroups == '\0' || detail::ArchiveFontBase::IncludeName(includedGroups, groupName)) {
flagWord |= *(const u32*)(offsetFlags + ROUNDDOWN(j * stepSheets, 4));
flagWord |= *(const u32*)((const u8*)offsetFlags + ROUNDDOWN(j * stepSheets, 4));
}
}
@@ -119,11 +119,11 @@ namespace nw4r {
groupOffset = pGlgr->inner.nameOffsets[j];
groupName = (const char*)(groupOffset + (u32)fontData);
if (*includedGroups == '\0' || detail::ArchiveFontBase::IncludeName(includedGroups, groupName)) {
flagWord |= *(const u32*)(offsetFlags + ROUNDDOWN(j * step0A, 4));
flagWord |= *(const u32*)((const u8*)offsetFlags + ROUNDDOWN(j * step0A, 4));
}
}
offsetData = data0A + i * 32;
offsetData = (const u32*)data0A + i * 32;
for (j = 0; j < 32; j++) {
if ((flagWord << j) & 0x80000000U) {
loadedSmth0ASize += offsetData[j] - sizeof(BinaryBlockHeader);
@@ -140,11 +140,11 @@ namespace nw4r {
groupOffset = pGlgr->inner.nameOffsets[j];
groupName = (const char*)(groupOffset + (u32)fontData);
if (*includedGroups == '\0' || detail::ArchiveFontBase::IncludeName(includedGroups, groupName)) {
flagWord |= *(const u32*)(offsetFlags + ROUNDDOWN(j * step0C, 4));
flagWord |= *(const u32*)((const u8*)offsetFlags + ROUNDDOWN(j * step0C, 4));
}
}
offsetData = data0C + i * 32;
offsetData = (const u32*)data0C + i * 32;
for (j = 0; j < 32; j++) {
if ((flagWord << j) & 0x80000000U) {
loadedSmth0CSize += offsetData[j] - sizeof(BinaryBlockHeader);

View File

@@ -31,507 +31,444 @@ 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 pitch2;
s32* dst;
s32 rowOddOutput1;
int columnAcBits;
s32 column;
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;
s32* workspaceCursor;
s32 evenBaseSum;
s32 evenRotation;
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;
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 {
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;
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;
}
block += 8;
dst += 8;
}
dst = workspace + processed;
for (; processed <= 56; processed += 8) {
memset(dst, 0, 32);
dst += 8;
workspaceCursor = workspace + processedCoefficients;
for (; processedCoefficients <= 0x38; processedCoefficients += 8) {
memset(workspaceCursor, 0, 0x20);
workspaceCursor += 8;
}
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;
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;
} 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);
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);
}
src--;
workspaceCursor--;
}
}
static s32 clampChromaDc(s32 value) {
return clampS8(value >> 11);
}
void TMCJPEGDEC_IdctBlock_Col(s32* block, u8* conv_row_ptr, u16 pitch, s32 zigzag) {
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 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;
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 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;
if (zigzag == 0x11) {
flatDc = block[0];
rowSample = clampS8(flatDc >> 11);
memset(conv_row_ptr, (s8)rowSample, 64);
s32 sample;
sample = clampS8(block[0] >> 11);
memset(conv_row_ptr, (s8)sample, 0x40);
return;
}
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;
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;
} else {
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;
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;
}
block += 8;
dst += 8;
}
dst = workspace + processed;
for (; processed <= 56; processed += 8) {
memset(dst, 0, 32);
dst += 8;
}
workspaceCursor += 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;
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 {
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);
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);
}
src--;
workspaceCursor--;
}
}

View File

@@ -13,8 +13,6 @@ 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,
@@ -71,14 +69,6 @@ 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;
@@ -398,7 +388,9 @@ 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_STRIP_OFFSETS:
case TMC_EXIF_TAG_JPEG_INTERCHANGE_FORMAT:
case TMC_EXIF_TAG_JPEG_INTERCHANGE_FORMAT_LENGTH: {
break;
}
case TMC_EXIF_TAG_ORIENTATION: {
@@ -406,27 +398,17 @@ static void TMCJPEGDEC_IFD0_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
return;
}
case TMC_EXIF_TAG_X_RESOLUTION: {
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;
u32 offset = readU32(entry->value, byteOrder);
const u8* p = pInfo->thumbnailData + offset;
if (pInfo->thumbnailData > p) {
return;
}
if (p > pInfo->dataEnd - sizeof(u32)) {
return;
}
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) {
pInfo->xResNum = readU32(p, byteOrder);
p = pInfo->thumbnailData + (offset + sizeof(u32));
if (pInfo->thumbnailData > p) {
return;
}
if (p > pInfo->dataEnd - sizeof(u32)) {
@@ -436,27 +418,17 @@ static void TMCJPEGDEC_IFD0_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
return;
}
case TMC_EXIF_TAG_Y_RESOLUTION: {
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;
u32 offset = readU32(entry->value, byteOrder);
const u8* p = pInfo->thumbnailData + offset;
if (pInfo->thumbnailData > p) {
return;
}
if (p > pInfo->dataEnd - sizeof(u32)) {
return;
}
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) {
pInfo->yResNum = readU32(p, byteOrder);
p = pInfo->thumbnailData + (offset + sizeof(u32));
if (pInfo->thumbnailData > p) {
return;
}
if (p > pInfo->dataEnd - sizeof(u32)) {
@@ -553,12 +525,6 @@ 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;
}
}
@@ -568,18 +534,25 @@ static void TMCJPEGDEC_IFD1_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
s32 tag = readU16(entry->tag, byteOrder);
switch (tag) {
case TMC_EXIF_TAG_STRIP_OFFSETS: {
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: {
break;
}
case TMC_EXIF_TAG_X_RESOLUTION: {
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);
const u8* p;
offset = readU32(entry->value, byteOrder);
p = pInfo->thumbnailData + offset;
if (pInfo->thumbnailData > p) {
return;
@@ -587,12 +560,9 @@ static void TMCJPEGDEC_IFD1_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
if (p > pInfo->dataEnd - sizeof(u32)) {
return;
}
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) {
pInfo->xResNumIfd1 = readU32(p, byteOrder);
p = pInfo->thumbnailData + (offset + sizeof(u32));
if (pInfo->thumbnailData > p) {
return;
}
if (p > pInfo->dataEnd - sizeof(u32)) {
@@ -602,14 +572,9 @@ static void TMCJPEGDEC_IFD1_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
return;
}
case TMC_EXIF_TAG_Y_RESOLUTION: {
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);
const u8* p;
offset = readU32(entry->value, byteOrder);
p = pInfo->thumbnailData + offset;
if (pInfo->thumbnailData > p) {
return;
@@ -617,12 +582,9 @@ static void TMCJPEGDEC_IFD1_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
if (p > pInfo->dataEnd - sizeof(u32)) {
return;
}
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) {
pInfo->planarConfigIfd1 = readU32(p, byteOrder);
p = pInfo->thumbnailData + (offset + sizeof(u32));
if (pInfo->thumbnailData > p) {
return;
}
if (p > pInfo->dataEnd - sizeof(u32)) {
@@ -645,21 +607,6 @@ 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;
}
}

View File

@@ -14,37 +14,7 @@ static void TMCJPEGDEC_converterYUV444toRGB565edge(TMCCJPEGDecWork*, s32, s32);
static void TMCJPEGDEC_converterYUV400toRGB565(TMCCJPEGDecWork*, s32, s32);
static void TMCJPEGDEC_converterYUV400toRGB565edge(TMCCJPEGDecWork*, s32, s32);
#pragma push
#pragma optimization_level 1
s32 TMCJPEGDEC_set_converterRGB565(TMCCJPEGDecWork* work) {
u8 mode411;
u8* crBlock411;
u8* cbBlock411;
u8* fourthRow411;
u8* thirdRow411;
u8* secondRow411;
u8* firstRow411;
TMCConverterFunc* edgeConverter411;
TMCConverterFunc* converter411;
u8 mode422;
u8* crBlock422;
u8* cbBlock422;
u8* secondRow422;
u8* firstRow422;
TMCConverterFunc* edgeConverter422;
TMCConverterFunc* converter422;
u8 mode420;
u8* crBlock420;
u8* cbBlock420;
u8* fourthRow420;
u8* thirdRow420;
u8* secondRow420;
u8* firstRow420;
TMCConverterFunc* edgeConverter420;
TMCConverterFunc* converter420;
u8* buffer;
s32 componentCount;
TMCCJPEGDecState* state;
@@ -55,84 +25,97 @@ s32 TMCJPEGDEC_set_converterRGB565(TMCCJPEGDecWork* work) {
switch (componentCount) {
case 0: {
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;
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;
work->pitch = 32;
work->converterFlags = 0;
break;
}
case 1: {
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;
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;
work->pitch = 16;
work->converterFlags = 0;
break;
}
case 2: {
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;
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;
work->pitch = 16;
work->converterFlags = 0;
break;
}
case 3: {
u32 mode;
u8* crBlock;
u8* cbBlock;
u8* secondRow;
u8 mode;
u8* firstRow;
TMCConverterFunc* edgeConverter;
TMCConverterFunc* converter;
u8* secondRow;
u8* cbBlock;
u8* crBlock;
mode = work->idctMode;
firstRow = buffer + 4;
converter = TMCJPEGDEC_converterYUV211toRGB565;
edgeConverter = TMCJPEGDEC_converterYUV211toRGB565edge;
work->pConverterFunc = TMCJPEGDEC_converterYUV211toRGB565;
work->pConverterFuncEdge = 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;
@@ -142,27 +125,27 @@ s32 TMCJPEGDEC_set_converterRGB565(TMCCJPEGDecWork* work) {
break;
}
case 4: {
TMCConverterFunc* edgeConverter;
TMCConverterFunc* converter;
TMCConverterFunc* edgeConverter;
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* edgeConverter;
TMCConverterFunc* converter;
TMCConverterFunc* edgeConverter;
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;
@@ -175,19 +158,13 @@ s32 TMCJPEGDEC_set_converterRGB565(TMCCJPEGDecWork* work) {
{
s32 width = state->jpegWidth;
s32 height = state->jpegHeight;
s32 roundedWidth;
s32 heightPadding;
state->convWidth = ((u32)width / 4 + (width % 4 != 0)) * 4;
state->convHeight = ((u32)height / 4 + (height % 4 != 0)) * 4;
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;

View File

@@ -14,37 +14,7 @@ static void TMCJPEGDEC_converterYUV444toRGBA8edge(TMCCJPEGDecWork*, s32, s32);
static void TMCJPEGDEC_converterYUV400toRGBA8(TMCCJPEGDecWork*, s32, s32);
static void TMCJPEGDEC_converterYUV400toRGBA8edge(TMCCJPEGDecWork*, s32, s32);
#pragma push
#pragma optimization_level 1
s32 TMCJPEGDEC_set_converterRGBA8(TMCCJPEGDecWork* work) {
u8 mode411;
u8* crBlock411;
u8* cbBlock411;
u8* fourthRow411;
u8* thirdRow411;
u8* secondRow411;
u8* firstRow411;
TMCConverterFunc* edgeConverter411;
TMCConverterFunc* converter411;
u8 mode422;
u8* crBlock422;
u8* cbBlock422;
u8* secondRow422;
u8* firstRow422;
TMCConverterFunc* edgeConverter422;
TMCConverterFunc* converter422;
u8 mode420;
u8* crBlock420;
u8* cbBlock420;
u8* fourthRow420;
u8* thirdRow420;
u8* secondRow420;
u8* firstRow420;
TMCConverterFunc* edgeConverter420;
TMCConverterFunc* converter420;
u8* buffer;
s32 componentCount;
TMCCJPEGDecState* state;
@@ -55,84 +25,97 @@ s32 TMCJPEGDEC_set_converterRGBA8(TMCCJPEGDecWork* work) {
switch (componentCount) {
case 0: {
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;
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;
work->pitch = 32;
work->converterFlags = 0;
break;
}
case 1: {
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;
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;
work->pitch = 16;
work->converterFlags = 0;
break;
}
case 2: {
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;
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;
work->pitch = 16;
work->converterFlags = 0;
break;
}
case 3: {
u32 mode;
u8* crBlock;
u8* cbBlock;
u8* secondRow;
u8 mode;
u8* firstRow;
TMCConverterFunc* edgeConverter;
TMCConverterFunc* converter;
u8* secondRow;
u8* cbBlock;
u8* crBlock;
mode = work->idctMode;
firstRow = buffer + 4;
converter = TMCJPEGDEC_converterYUV211toRGBA8;
edgeConverter = TMCJPEGDEC_converterYUV211toRGBA8edge;
work->pConverterFunc = TMCJPEGDEC_converterYUV211toRGBA8;
work->pConverterFuncEdge = 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;
@@ -142,27 +125,27 @@ s32 TMCJPEGDEC_set_converterRGBA8(TMCCJPEGDecWork* work) {
break;
}
case 4: {
TMCConverterFunc* edgeConverter;
TMCConverterFunc* converter;
TMCConverterFunc* edgeConverter;
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* edgeConverter;
TMCConverterFunc* converter;
TMCConverterFunc* edgeConverter;
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;
@@ -175,127 +158,129 @@ s32 TMCJPEGDEC_set_converterRGBA8(TMCCJPEGDecWork* work) {
{
s32 width = state->jpegWidth;
s32 height = state->jpegHeight;
s32 roundedWidth;
s32 heightPadding;
state->convWidth = ((u32)width / 4 + (width % 4 != 0)) * 4;
state->convHeight = ((u32)height / 4 + (height % 4 != 0)) * 4;
roundedWidth = (u32)width / 4 + (width % 4 != 0);
heightPadding = height % 4 != 0;
state->convWidth = roundedWidth * 4;
state->convHeight = ((u32)height / 4 + heightPadding) * 4;
}
return 0;
}
#pragma pop
static void TMCJPEGDEC_converterYUV411toRGBA8(TMCCJPEGDecWork* work, s32 x, s32 y) {
u16* output;
s32 tileRow;
s32 secondGreen;
s32 thirdGreen;
s32 fourthBlue;
s32 columnInTile;
s32 secondColumnInTile;
s32 thirdColumnInTile;
s32 fourthColumnInTile;
s32 red;
s32 secondBlue;
s32 thirdBlue;
s32 fourthGreen;
s32 green;
s32 secondRed;
s32 thirdRed;
s32 fourthRed;
u8* texture;
u8* luminance;
u8* cb;
u8* cr;
TMCCJPEGDecState* state;
u8* texture;
s32 height;
s32 column;
s32 xEnd;
s32 green;
s32 yEnd;
s32 tileWidth;
s32 redOffset;
s32 greenOffset;
s32 blueOffset;
s32 blue;
s32 value;
TMCCJPEGDecState* state;
s32 width;
s32 height;
s32 greenOffset;
s32 tileRow;
s32 lumaSkip;
s8 crValue;
s32 chromaSkip;
s32 width;
s32 cbValue;
u8 value;
s32 row;
u16* output;
s32 redOffset;
s32 blue;
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;
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;
{
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);
}
}
columnInTile = column & 3;
(output = (u16*)(texture + ((y & 3) << 3)))[
columnInTile + ((((column >> 2) << 1) +
(tileRow = (y >> 2) * tileWidth)) << 4)] = (u8)red + 0x10000 - 0x100;
output[columnInTile + ((((column >> 2) << 1) + (tileRow + 1)) << 4)] = ((green & 255) << 8) + (blue & 255);
value = *luminance++;
secondGreen = value + greenOffset;
secondRed = value + redOffset;
secondBlue = value + blueOffset;
if ((secondRed | secondGreen | secondBlue) >> 8) {
secondBlue = secondBlue > 255 ? 255 : secondBlue < 0 ? 0 : secondBlue;
secondGreen = secondGreen > 255 ? 255 : secondGreen < 0 ? 0 : secondGreen;
secondRed = secondRed > 255 ? 255 : secondRed < 0 ? 0 : secondRed;
}
secondColumnInTile = (column + 1) & 3;
output[secondColumnInTile + (((((column + 1) >> 2) << 1) + tileRow) << 4)] = (u8)secondRed + 0x10000 - 0x100;
output[secondColumnInTile + (((((column + 1) >> 2) << 1) + (tileRow + 1)) << 4)] = ((secondGreen & 255) << 8) + (secondBlue & 255);
value = *luminance++;
thirdGreen = value + greenOffset;
thirdRed = value + redOffset;
thirdBlue = value + blueOffset;
if ((thirdRed | thirdGreen | thirdBlue) >> 8) {
thirdBlue = thirdBlue > 255 ? 255 : thirdBlue < 0 ? 0 : thirdBlue;
thirdGreen = thirdGreen > 255 ? 255 : thirdGreen < 0 ? 0 : thirdGreen;
thirdRed = thirdRed > 255 ? 255 : thirdRed < 0 ? 0 : thirdRed;
}
thirdColumnInTile = (column + 2) & 3;
output[thirdColumnInTile + (((((column + 2) >> 2) << 1) + tileRow) << 4)] = (u8)thirdRed + 0x10000 - 0x100;
output[thirdColumnInTile + (((((column + 2) >> 2) << 1) + (tileRow + 1)) << 4)] = ((thirdGreen & 255) << 8) + (thirdBlue & 255);
value = *luminance++;
fourthGreen = value + greenOffset;
fourthRed = value + redOffset;
fourthBlue = value + blueOffset;
if ((fourthRed | fourthGreen | fourthBlue) >> 8) {
fourthBlue = fourthBlue > 255 ? 255 : fourthBlue < 0 ? 0 : fourthBlue;
fourthGreen = fourthGreen > 255 ? 255 : fourthGreen < 0 ? 0 : fourthGreen;
fourthRed = fourthRed > 255 ? 255 : fourthRed < 0 ? 0 : fourthRed;
}
fourthColumnInTile = (column + 3) & 3;
output[fourthColumnInTile + (((((column + 3) >> 2) << 1) + tileRow) << 4)] = (u8)fourthRed + 0x10000 - 0x100;
output[fourthColumnInTile + (((((column + 3) >> 2) << 1) + (tileRow + 1)) << 4)] = ((fourthGreen & 255) << 8) + (fourthBlue & 255);
luminance += lumaSkip;
cb += chromaSkip;
cr += chromaSkip;
}
luminance += (32 - width);
cb += ((32 - width) >> 2);
cr += ((32 - width) >> 2);
}
}

View File

@@ -14,37 +14,7 @@ static void TMCJPEG_814F32E4(TMCCJPEGDecWork*, s32, s32);
static void TMCJPEG_814F34A4(TMCCJPEGDecWork*, s32, s32);
static void TMCJPEG_814F372C(TMCCJPEGDecWork*, s32, s32);
#pragma push
#pragma optimization_level 1
s32 TMCJPEGDEC_set_converterY8U8V8(TMCCJPEGDecWork* work) {
u8 mode411;
u8* crBlock411;
u8* cbBlock411;
u8* fourthRow411;
u8* thirdRow411;
u8* secondRow411;
u8* firstRow411;
TMCConverterFunc* edgeConverter411;
TMCConverterFunc* converter411;
u8 mode422;
u8* crBlock422;
u8* cbBlock422;
u8* secondRow422;
u8* firstRow422;
TMCConverterFunc* edgeConverter422;
TMCConverterFunc* converter422;
u8 mode420;
u8* crBlock420;
u8* cbBlock420;
u8* fourthRow420;
u8* thirdRow420;
u8* secondRow420;
u8* firstRow420;
TMCConverterFunc* edgeConverter420;
TMCConverterFunc* converter420;
u8* buffer;
s32 componentCount;
TMCCJPEGDecState* state;
@@ -55,84 +25,97 @@ s32 TMCJPEGDEC_set_converterY8U8V8(TMCCJPEGDecWork* work) {
switch (componentCount) {
case 0: {
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;
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;
work->pitch = 32;
work->converterFlags = 0;
break;
}
case 1: {
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;
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;
work->pitch = 16;
work->converterFlags = 0;
break;
}
case 2: {
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;
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;
work->pitch = 16;
work->converterFlags = 0;
break;
}
case 3: {
u32 mode;
u8* crBlock;
u8* cbBlock;
u8* secondRow;
u8 mode;
u8* firstRow;
TMCConverterFunc* edgeConverter;
TMCConverterFunc* converter;
u8* secondRow;
u8* cbBlock;
u8* crBlock;
mode = work->idctMode;
firstRow = buffer + 4;
converter = TMCJPEG_814F2570;
edgeConverter = TMCJPEG_814F2B50;
work->pConverterFunc = TMCJPEG_814F2570;
work->pConverterFuncEdge = 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;
@@ -142,27 +125,27 @@ s32 TMCJPEGDEC_set_converterY8U8V8(TMCCJPEGDecWork* work) {
break;
}
case 4: {
TMCConverterFunc* edgeConverter;
TMCConverterFunc* converter;
TMCConverterFunc* edgeConverter;
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* edgeConverter;
TMCConverterFunc* converter;
TMCConverterFunc* edgeConverter;
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;
@@ -175,25 +158,16 @@ s32 TMCJPEGDEC_set_converterY8U8V8(TMCCJPEGDecWork* work) {
{
s32 width = state->jpegWidth;
s32 height = state->jpegHeight;
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;
state->convWidth = ((u32)width / 8 + (width % 8 != 0)) * 8;
state->convHeight = ((u32)height / 4 + (height % 4 != 0)) * 4;
width = state->outputWidth;
height = state->outputHeight;
roundedWidth = (u32)width / 8 + (width % 8 != 0);
heightPadding = height % 4 != 0;
state->chromaWidth = roundedWidth * 8;
state->chromaHeight = ((u32)height / 4 + heightPadding) * 4;
state->chromaWidth = ((u32)width / 8 + (width % 8 != 0)) * 8;
state->chromaHeight = ((u32)height / 4 + (height % 4 != 0)) * 4;
}
return 0;
}
#pragma pop
static void TMCJPEG_814EFEAC(TMCCJPEGDecWork* work, s32 x, s32 y) {
s32 rowSkip;
u8* output;

View File

@@ -23,8 +23,8 @@ const ziWChar Zi8PunctTable[40] = {
0xFFE1, 0x20AC, 0x203B, 0xFF20, 0x0000,
};
ziU32 Zi8Punctuation(ziGetParam* param, ZiCandidateOptions* options ZI_NEED_WORK) {
ziS32 limit = options->capacity - 1;
ziU32 Zi8Punctuation(ziGetParam* param, ziPtr options ZI_NEED_WORK) {
ziS32 limit = ((ZiCandidateOptions*)options)->capacity - 1;
ziS32 count = 0;
ziU8 i = 0;
ziU16 fc = param->firstCandidate;
@@ -36,11 +36,11 @@ ziU32 Zi8Punctuation(ziGetParam* param, ZiCandidateOptions* options ZI_NEED_WORK
}
if (fc == 0) {
count++;
if (options->countOnly == 0) {
if (((ZiCandidateOptions*)options)->countOnly == 0) {
param->candidates[i++] = Zi8PunctTable[j];
if ((param->context & 0x10) != 0) {
param->candidates[i++] = 0x20;
if (i >= limit) {
if ((ziU8)i >= limit) {
break;
}
}
@@ -48,7 +48,7 @@ ziU32 Zi8Punctuation(ziGetParam* param, ZiCandidateOptions* options ZI_NEED_WORK
break;
}
} else {
if (count >= (ziS32)options->maxCount) {
if (count >= (ziS32)((ZiCandidateOptions*)options)->maxCount) {
return count;
}
}
@@ -57,7 +57,7 @@ ziU32 Zi8Punctuation(ziGetParam* param, ZiCandidateOptions* options ZI_NEED_WORK
}
j++;
}
if (options->countOnly == 0) {
if (((ZiCandidateOptions*)options)->countOnly == 0) {
param->letters = count;
}
return count;

View File

@@ -10,21 +10,21 @@ ziU8 Zi8LangSupported(ziU8 lang ZI_NEED_WORK) {
return 0;
}
for (i = 0; ZI_WORK->langEntries[i].language != ZI8_LANG_NONE; i++) {
for (i = 0; ZI_WORK->langEntries[i].language != 0; i++) {
if (lang == ZI_WORK->langEntries[i].language) {
break;
}
}
if (ZI_WORK->langEntries[i].language == ZI8_LANG_NONE) {
for (i = 0; ZI_WORK->langEntries[i].language != ZI8_LANG_NONE; i++) {
if (ZI_WORK->langEntries[i].language == 0) {
for (i = 0; ZI_WORK->langEntries[i].language != 0; i++) {
if ((ZI_WORK->langEntries[i].tableData != ZI8_NULL) && (lang == ZI_WORK->langEntries[i].tableData[0])) {
break;
}
}
}
if (ZI_WORK->langEntries[i].language != ZI8_LANG_NONE) {
if (ZI_WORK->langEntries[i].language != 0) {
return i + 1;
} else {
Zi8ReplaceLastError(0x582, ZI_WORK);
@@ -89,19 +89,19 @@ ziU32 Zi8GetTableData(ziU8 lang, ziU8 tableIdx, ziU8 memberId ZI_NEED_WORK) {
}
ziU32 Zi8GetTableAddress(ziU8 lang, ziU8 tableIdx ZI_NEED_WORK) {
return Zi8GetTableData(lang, tableIdx, ziTableAddress, ZI_WORK);
return Zi8GetTableData(lang, tableIdx, 1, ZI_WORK);
}
ziU32 Zi8GetTableSize(ziU8 lang, ziU8 tableIdx ZI_NEED_WORK) {
return Zi8GetTableData(lang, tableIdx, ziTableSize, ZI_WORK);
return Zi8GetTableData(lang, tableIdx, 2, ZI_WORK);
}
ziU16 Zi8GetTableCount(ziU8 lang, ziU8 tableIdx ZI_NEED_WORK) {
return Zi8GetTableData(lang, tableIdx, ziTableSize, ZI_WORK);
return Zi8GetTableData(lang, tableIdx, 2, ZI_WORK);
}
ziU8 Zi8GetFormatVersion(ziU8 lang ZI_NEED_WORK) {
return Zi8GetTableData(lang, 0, ziTableFormatVersion, ZI_WORK);
return Zi8GetTableData(lang, 0, 4, ZI_WORK);
}
ziU32 Zi8WCharCount(ziWChar* str ZI_NEED_WORK) {

View File

@@ -104,7 +104,7 @@ ziChar Zi8ConvertWC2UC(ziWChar character, ziU8 language ZI_NEED_WORK) {
}
entry = (ziConversionEntry*)((ziU8*)table + value + character - first + 8);
Zi8LogError(100, __zi8_work_data);
return entry->first[0];
return *(ziU8*)entry;
}
Zi8LogError(0x6C2, __zi8_work_data);
return 0;

View File

@@ -185,7 +185,7 @@ extern ziU16 Zi8Ord2Ord(ziU16, ziPtr);
extern ziU8 Zi8LangSupported(ziU8, ziPtr);
extern ziU16 Zi8GetTableCount(ziU8,ziU8,ziPtr);
extern ziU32 Zi8GetTableAddress(ziU8,ziU8,ziPtr);
extern ziPtr Zi8Memset(ziPtr destination, ziU32 value, ziS32 count);
extern void Zi8Memset(ziU8*,ziU32,ziS32);
extern ziU8 _Zi8GetCandidates(ziGetParam*,ziPtr);
extern void Zi8InitDupWordBuf(ziPtr);
extern ziU32 Zi8GetPInfo(ziU32,ziWChar *,ziU8,ziPtr);
@@ -778,7 +778,7 @@ ziU32 Zi8Get1KeyPressSpelling(ziGetParam *params,Zi8OneKeyOptions *options,Zi8On
if (options->countOnly == '\0') {
*output++ = spellingBuffer[spellingIndex];
*output++ = 0;
++candidateCount;
candidateCount = candidateCount + 1;
}
else if ((int)totalCandidates >= options->maxCount) goto finishSpelling;
if (candidateCount >= params->maxCandidates) goto finishSpelling;
@@ -1321,7 +1321,8 @@ ziU32 Zi8Get1KeyPressCandidates(ziGetParam *params,Zi8OneKeyOptions *options,Zi8
wordBuffer[params->wordCharCount + wordLength] = 0;
}
if (optionsMask == 5) {
if (++totalCandidates >= options->maxCount) goto finishCandidates;
totalCandidates++;
if (totalCandidates >= options->maxCount) goto finishCandidates;
} else if (remaining == 0) {
totalCandidates++;
candidateCount++;
@@ -1389,7 +1390,8 @@ ziU32 Zi8Get1KeyPressCandidates(ziGetParam *params,Zi8OneKeyOptions *options,Zi8
wordBuffer[params->wordCharCount + wordLength] = 0;
}
if (optionsMask == 5) {
if (++totalCandidates >= options->maxCount) goto finishCandidates;
totalCandidates++;
if (totalCandidates >= options->maxCount) goto finishCandidates;
} else if (remaining == 0) {
totalCandidates++;
candidateCount++;
@@ -1429,7 +1431,7 @@ ziU32 Zi8Get1KeyPressCandidates(ziGetParam *params,Zi8OneKeyOptions *options,Zi8
}
if ((*phraseEntries & 0x80) != 0) {
entryRemaining = 0;
phraseEntries += ((int)(*phraseEntries & 0x7f) >> 4) + 1;
phraseEntries = phraseEntries + ((int)(*phraseEntries & 0x7f) >> 4) + 1;
} else {
entryRemaining = 0x80;
}
@@ -1511,7 +1513,8 @@ ziU32 Zi8Get1KeyPressCandidates(ziGetParam *params,Zi8OneKeyOptions *options,Zi8
output[outputIndex + wordLength] = 0;
}
if (optionsMask == 5) {
if (++totalCandidates >= options->maxCount) goto finishCandidates;
totalCandidates++;
if (totalCandidates >= options->maxCount) goto finishCandidates;
} else if (remaining == 0) {
totalCandidates++;
candidateCount++;

View File

@@ -295,7 +295,7 @@ void Zi8ChangeWordCase(ziWChar* word, ziU8 language, ZiAlphaWork* work) {
while (*word != 0) Zi8ChangeCharCase(upper, word++, language, work);
}
ziU16 Zi8DeTokenization(ziWChar* word, ziU16 length, ziU16 capacity, ziU16 language);
ziU32 Zi8DeTokenization(ziWChar* word, ziU32 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);
ziPtr Zi8Memset(ziPtr destination, ziU32 value, ziS32 count);
void Zi8Memset(ziPtr destination, ziU32 value, ziU32 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,6 +550,7 @@ 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 &&
@@ -558,7 +559,8 @@ 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];
wordCursor[elementIndex] = parameters->elements[elementIndex];
elementIndex++;
if (parameters->elementCount == 1) ((ZiAlphaWork*)workData)->singleCharacter = *wordCursor;
if (elementIndex == parameters->elementCount &&
(firstCandidate == 0 || ((ZiAlphaWork*)workData)->reuseHighlightedWord != 0)) {
@@ -652,7 +654,7 @@ foundHighlightedDictionary:
}
goto prepareDictionaryOrder;
preparePrefix:
prefixMode = (ziU8)((ZiAlphaWork*)workData)->suffixMode;
prefixMode = ((ZiAlphaWork*)workData)->suffixMode;
prefixTableFlags = Zi8GetTableCount(language,0x1f,workData);
prefixVowelFlags = prefixTableFlags & 0x10;
if (((((language == 0x3f) || (language == 4)) ||
@@ -898,19 +900,19 @@ selectDictionary:
}
else {
if (alternateSingleCharacter != 2) {
wordLength = Zi8MatchROMdata(elements,elementCount,language,wordCursor,
wordCapacity,matchMode,
dictionaryStatus[dictionaryKind],0,exactLengthOnly,workData);
wordLength = Zi8MatchROMdata(elements,elementCount & 0xff,language,wordCursor,
wordCapacity & 0xffff,matchMode,
dictionaryStatus[dictionaryKind] & 0xff,0,exactLengthOnly,workData);
}
if ((alternateSingleCharacter != 0) && ((wordLength == 0 || (*wordCursor == *elements)))) {
if (alternateSingleCharacter == 1) {
alternateSingleCharacter = 2;
wordLength = Zi8MatchROMdata(elements,elementCount,parameters->subLanguage,wordCursor,
wordCapacity,1,0,0,exactLengthOnly,workData);
wordLength = Zi8MatchROMdata(elements,elementCount & 0xff,parameters->subLanguage,wordCursor,
wordCapacity & 0xffff,1,0,0,exactLengthOnly,workData);
}
else {
wordLength = Zi8MatchROMdata(elements,elementCount,parameters->subLanguage,wordCursor,
wordCapacity,1,1,0,exactLengthOnly,workData);
wordLength = Zi8MatchROMdata(elements,elementCount & 0xff,parameters->subLanguage,wordCursor,
wordCapacity & 0xffff,1,1,0,exactLengthOnly,workData);
}
}
}
@@ -920,24 +922,27 @@ selectDictionary:
if ((((wordLength == 0) && (*punctuationCursor != 0)) && (dictionaryExact != 0)) &&
((((ZiAlphaWork*)workData)->singleCharacter != 0 && (parameters->elementCount == 2)))) {
*wordCursor = ((ZiAlphaWork*)workData)->singleCharacter;
wordCursor[1] = *punctuationCursor++;
wordCursor[2] = 0;
wordCursor[1] = *punctuationCursor++;
wordLength = 2;
}
if (((apostropheIndex != 0) && (wordLength != 0)) && (elementCount == parameters->elementCount)) {
if (language == 0x2f) {
if (Zi8ITspecialExclusion
(wordCursor + apostropheIndex,apostropheIndex,wordLength - apostropheIndex) != 0) {
index = Zi8ITspecialExclusion
(wordCursor + apostropheIndex,apostropheIndex,wordLength - apostropheIndex);
if (index != '\0') {
wordLength = 0;
}
}
else if (language == 0x58) {
if (Zi8_814659E8(wordCursor + apostropheIndex,apostropheIndex,wordLength - apostropheIndex) != 0) {
index = Zi8_814659E8(wordCursor + apostropheIndex,apostropheIndex,wordLength - apostropheIndex);
if (index != '\0') {
wordLength = 0;
}
}
else {
if (Zi8IsVowel(language,wordCursor[apostropheIndex]) == 0) {
index = Zi8IsVowel(language,wordCursor[apostropheIndex]);
if (index == '\0') {
wordLength = 0;
}
}
@@ -956,17 +961,20 @@ filterVowelCandidate:
goto finishDictionaryPass;
}
if (language == 0x2f) {
if (Zi8ITspecialExclusion(wordCursor,prefixCount,wordLength) != 0) {
index = Zi8ITspecialExclusion(wordCursor,prefixCount,wordLength);
if (index != '\0') {
wordLength = 0;
}
}
else if (language == 0x58) {
if (Zi8_814659E8(wordCursor,prefixCount,wordLength) != 0) {
index = Zi8_814659E8(wordCursor,prefixCount,wordLength);
if (index != '\0') {
wordLength = 0;
}
}
else {
if (Zi8IsVowel(language,*wordCursor) == 0) {
index = Zi8IsVowel(language,*wordCursor);
if (index == '\0') {
wordLength = 0;
}
}
@@ -990,9 +998,9 @@ filterVowelCandidate:
case 2:
case 6:
if (elementCount != 0) {
wordLength = Zi8MatchPUDdata(elements,elementCount,language,wordCursor,
wordCapacity,dictionaryExact,
dictionaryStatus[dictionaryKind],workData);
wordLength = Zi8MatchPUDdata(elements,elementCount & 0xff,language,wordCursor,
wordCapacity & 0xffff,dictionaryExact,
dictionaryStatus[dictionaryKind] & 0xff,workData);
}
break;
case 3:
@@ -1000,8 +1008,8 @@ filterVowelCandidate:
while( ZI8_TRUE ) {
wordLength = Zi8MatchUWDdata(elements,elementCount,
parameters->currentWord,parameters->wordCharCount,
language,wordCursor,wordCapacity,dictionaryExact,
dictionaryStatus[dictionaryKind],workData);
language,wordCursor,wordCapacity & 0xffff,dictionaryExact,
dictionaryStatus[dictionaryKind] & 0xff,workData);
if (((elementCount != 0) || (wordLength != 1)) || (*wordCursor != 0x20)) break;
dictionaryStatus[dictionaryKind] = 1;
}
@@ -1011,7 +1019,7 @@ filterVowelCandidate:
if (elementCount != 0) {
wordLength = Zi8MatchOEMdata(elements,elementCount,language,wordCursor,
wordCapacity,dictionaryExact,
dictionaryStatus[dictionaryKind],workData);
dictionaryStatus[dictionaryKind] & 0xff,workData);
}
break;
case 10:
@@ -1066,12 +1074,8 @@ filterVowelCandidate:
(((ZiAlphaOptions*)optionData)->lookupMode == '\0')) &&
(((ZiAlphaWork*)workData)->dictionaries[language] == 0)))))) {
if (language != ((ZiAlphaWork*)workData)->language) break;
switch (((ZiAlphaWork*)workData)->dictionaryKinds[dictionaryIndex + 1]) {
case 5:
case 6:
case 7:
case 8:
case 12:
index = ((ZiAlphaWork*)workData)->dictionaryKinds[dictionaryIndex + 1];
if (index == 0xc || (index < 9 && index >= 5)) {
if (Zi8getKeyLayout(language,0xeff1,&punctuationBuffer[0],1,workData) == 0) {
punctuationBuffer[0] = 0;
}
@@ -1090,17 +1094,8 @@ filterVowelCandidate:
(((((ZiAlphaWork*)workData)->rememberedWord[0] == 0 || (((ZiAlphaOptions*)optionData)->lookupMode != '\0')) ||
(((ZiAlphaWork*)workData)->dictionaries[language] != 0)))))) ||
(languagePassCount == 2)))) break;
switch (((ZiAlphaWork*)workData)->dictionaryKinds[dictionaryIndex + 1]) {
case 5:
case 6:
case 7:
case 8:
case 12:
goto prepareRememberedPunctuation;
default:
goto finishDictionaryPass;
}
prepareRememberedPunctuation:
index = ((ZiAlphaWork*)workData)->dictionaryKinds[dictionaryIndex + 1];
if ((index != 0xc) && (((0xb < index || (8 < index)) || (index < 5)))) break;
if (Zi8getKeyLayout(language,0xeff1,&punctuationBuffer[0],1,workData) == 0) {
punctuationBuffer[0] = 0;
}
@@ -1132,8 +1127,8 @@ prepareCandidate:
wordLength = elementCount;
wordCursor[wordLength] = 0;
}
wordLength = Zi8DeTokenization(wordCursor,wordLength,wordCapacity,language);
if (((phoneticInput) && ((ziU8)parameters->elementCount < (wordLength & 0xffU))) &&
wordLength = (ziU16)Zi8DeTokenization(wordCursor,wordLength & 0xffff,wordCapacity & 0xffff,language);
if (((phoneticInput) && ((unsigned int)parameters->elementCount < (wordLength & 0xff))) &&
((wordCursor[wordLength - 1] == 0xf360 || (wordCursor[wordLength - 1] == 0x27)))) {
wordLength = wordLength - 1;
wordCursor[wordLength] = 0;
@@ -1150,7 +1145,7 @@ prepareCandidate:
wordCursor[wordLength] = 0;
}
if (((int)((ZiAlphaOptions*)optionData)->maxWordLength < (int)(wordLength + prefixCount)) ||
((Zi8IsDupWordW(wordCursor - prefixCount,wordLength + prefixCount,
((Zi8IsDupWordW(wordCursor - prefixCount,wordLength + prefixCount & 0xff,
workData)) != '\0')) {
if ((prefixCount != 0) && (((ZiAlphaOptions*)optionData)->maxWordLength <= prefixCount)) break;
}
@@ -1168,7 +1163,7 @@ checkKeyLayout:
candidateCharacterCount = wordLength + prefixCount;
for (index = 0; (int)index < (int)(unsigned int)keyLayoutCount; index = index + 1) {
if (*keyLayoutCursor < candidateCharacterCount) {
keyLayoutCursor += *keyLayoutCursor + 1;
keyLayoutCursor = keyLayoutCursor + *keyLayoutCursor + 1;
} else {
if (*keyLayoutCursor++ > candidateCharacterCount) {
index = (unsigned int)keyLayoutCount;
@@ -1546,7 +1541,8 @@ 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)->prefix[((ZiAlphaWork*)workData)->prefixCount] = elements[((ZiAlphaWork*)workData)->prefixCount];
((ZiAlphaWork*)workData)->prefixCount++;
} else {
((ZiAlphaWork*)workData)->prefix[((ZiAlphaWork*)workData)->prefixCount++] = ((ZiAlphaWork*)workData)->letterHyphen;
}
@@ -1641,7 +1637,7 @@ finishCandidates:
ziU16 Zi8DeTokenization(ziWChar* word, ziU16 length, ziU16 capacity, ziU16 language) {
ziU32 Zi8DeTokenization(ziWChar* word, ziU32 length, ziU16 capacity, ziU16 language) {
ziU16 index;
ziBool changed = ZI8_FALSE;
ziU16 outputCount = 0;

View File

@@ -10,7 +10,7 @@ ziU16 Zi8MatchAltSound(ziU8* elements, ziU16 count, ziU8* table, ziU16 ch,
ziU16 off;
ziU16 w;
hi = (ziU8)(ch >> 8);
hi = (ziU8)((ziU16)ch >> 8);
lo = (ziU8)ch;
flags = (ziU8)(flags >> 3);
if (count == 0) {
@@ -28,22 +28,25 @@ ziU16 Zi8MatchAltSound(ziU8* elements, ziU16 count, ziU8* table, ziU16 ch,
goto search;
up:
i = j;
do {
if (((elements + i * 4)[3] & 0xE) == 0 ||
((elements + i * 4)[3] & flags) != 0) {
off = (ziU16)(((ziU16)(elements + i * 4)[2] |
(((ziU16)(elements + i * 4)[3] & 1) << 8)) << 1);
w = (ziU16)((((ziU16)(elements + i * 4)[3] & 0xF0) >> 4) |
(table[off] | ((ziU16)table[off + 1] << 8)));
if (target == (w & (ziU16)mask)) {
return w;
}
body:
if (((elements + i * 4)[3] & 0xE) == 0 ||
((elements + i * 4)[3] & flags) != 0) {
off = (ziU16)(((ziU16)(elements + i * 4)[2] |
(((ziU16)(elements + i * 4)[3] & 1) << 8)) << 1);
w = (ziU16)((((ziU16)(elements + i * 4)[3] & 0xF0) >> 4) |
(table[off] | ((ziU16)table[off + 1] << 8)));
if (target == (w & (ziU16)mask)) {
return w;
}
i++;
if (i >= count) {
break;
}
} while ((elements + i * 4)[1] == hi && (elements + i * 4)[0] == lo);
}
i++;
if (i >= count) {
goto down_start;
}
if ((elements + i * 4)[1] == hi && (elements + i * 4)[0] == lo) {
goto body;
}
down_start:
i = j;
goto dec;
down_body:

View File

@@ -138,7 +138,7 @@ extern ziU16 Zi8GetTableCount(ziU8 language, ziU8 table, ziPtr work);
extern ziU8 Zi8IsDupWChar(ziWChar character, ziPtr work);
extern ziU8 Zi8IsDupWordW(ziWChar* word, ziU8 length, ziPtr work);
extern ziWChar Zi8Ord2Uni(ziU16 ordinal, ziPtr work);
extern ziBool Zi8MatchPhonetic(ziU8* phonetics, ziU8* records,
extern ziU8 Zi8MatchPhonetic(ziPtr phonetics, ziU8* records,
ziPtr indexTable, ziU16 indexCount, ziU32 dictionary,
ziU8* record, ziU16* mask, ziU16* match,
ziU16* length, ziU8** matchedRecord,
@@ -169,15 +169,15 @@ extern ziU16 Zi8Uni2Ord(ziWChar character, ziPtr work);
extern ziU16 Zi8GetPCode(ziU8* table, ziU8* record);
extern ziU16 Zi8MatchAltSound(ziPtr table, ziU16 count, ziPtr phonetics,
ziU16 ordinal, ziU16 mask, ziU16 value, ziU8 flags, ziPtr work);
extern ziU32 Zi8SecMatchChar(ziU8* record, ziU8* dictionary, ziMatchParam* match, ziU16* code, ziPtr work);
extern ziU32 Zi8SecMatchChar(ziPtr record, ziU8* dictionary, ziMatchParam* match, ziU16* code, ziPtr work);
extern ziBool Zi8PriMatchNextChar(ziU8* record, ziU8 firstByteMask, ziU8 firstByteValue, ziU8 secondByteMask, ziU8 secondByteValue, ziU8 thirdByteMask, ziU8 thirdByteValue, ziU8 fourthByteMask, ziU8 fourthByteValue, ziU16* count, ziU8** result, ziU16* code, ziPtr work);
extern ziBool Zi8ExactMatchNextChar(ziU8* record, ziU8 firstByteMask, ziU8 firstByteValue, ziU8 secondByteMask, ziU8 secondByteValue, ziU8 thirdByteMask, ziU8 thirdByteValue, ziU8 fourthByteMask, ziU8 fourthByteValue, ziU16* count, ziU8** result, ziU16* code, ziPtr work);
extern ziBool Zi8PriMatchNextComp(ziU8* component, ziU8 firstByteMask, ziU8 firstByteValue, ziU8 secondByteMask, ziU8 secondByteValue, ziU8 thirdByteMask, ziU8 thirdByteValue, ziU8 fourthByteMask, ziU8 fourthByteValue, ziU16* count, ziU8** result, ziPtr work);
extern ziBool Zi8SecMatchComp(ziU8* component, ziMatchParam* match, ziU8* dictionary, ziPtr work);
extern ziBool Zi8SecMatchComp(ziPtr component, ziMatchParam* match, ziPtr dictionary, ziPtr work);
extern void Zi8InitDupWordBuf(ziPtr work);
extern ziU8 Zi8MatchPUDdata_ZHS(ziWChar* word, ziU8 length, ziU8 language, ziWChar* spelling, ziU16 spellingCapacity, ziWChar* candidate, ziU16 candidateCapacity, ziU8 mode, ziU8 next, ziPtr work);
extern ziPtr Zi8Memcpy(ziPtr destination, ziPtr source, ziS32 count);
extern ziPtr Zi8Memset(ziPtr destination, ziU32 value, ziS32 count);
extern ziPtr Zi8Memcpy(ziPtr destination, ziPtr source, ziS32 length);
extern void Zi8Memset(ziPtr destination, int value, ziU32 size);
static int Zi8NewMatchPhonetic(ziGetParam* request, ZiChineseRecord* records,
ziPtr indexTable, ziU16 indexCount, ziPtr dictionary,
@@ -753,11 +753,10 @@ static int zi8InternalGetZH(ziGetParam* request, ZiChineseOptions* options, ziPt
if (!componentTable) {
componentCount = Zi8GetTableCount(1, 7, work);
componentOrdinals = (ziU8*)Zi8GetTableAddress(1, 7, work);
componentCursor = (ziU8*)Zi8GetTableAddress(1, 2, work);
componentTable = componentCursor;
componentTable = componentCursor = (ziU8*)Zi8GetTableAddress(1, 2, work);
componentCursor += 8;
componentIndex = componentCount - 1;
--componentCount;
componentIndex = componentCount;
alternateCharacter = 0;
phoneticRetry = 1;
}
@@ -1300,8 +1299,8 @@ context_word_lookup:
if (emitWords) {
++emittedCount;
outputIndex += emittedWords;
output[outputIndex++] = ' ';
if (outputIndex > outputLimit) {
output[outputIndex] = ' ';
if (++outputIndex > outputLimit) {
request->letters = emittedCount;
request->count = emittedCount;
goto engine_finish;
@@ -1435,8 +1434,8 @@ candidate_dictionary_search:
if (emitWords) {
++emittedCount;
output[outputIndex++] = character;
output[outputIndex++] = ' ';
if (outputIndex > outputLimit) goto engine_finish;
output[outputIndex] = ' ';
if (++outputIndex > outputLimit) goto engine_finish;
} else output[emittedCount++] = character;
if (emittedCount >= request->maxCandidates) goto engine_finish;
}
@@ -1500,7 +1499,7 @@ character_range_next:
record += 12;
continue;
character_range_accept:
ordinalIndex = firstOrdinal + (remainingOrdinals - candidateCount - 1);
ordinalIndex = remainingOrdinals - candidateCount + firstOrdinal - 1;
((ZiChineseWork*)work)->duplicateOrdinals[((ZiChineseWork*)work)->duplicateIndex] = ordinalIndex;
((ZiChineseWork*)work)->duplicateCharacters[((ZiChineseWork*)work)->duplicateIndex] = candidateOrdinal;
if (charsetTable) {
@@ -1677,8 +1676,8 @@ tone_candidates:
if (emitWords) {
++emittedCount;
output[outputIndex++] = character;
output[outputIndex++] = ' ';
if (outputIndex > outputLimit) goto engine_finish;
output[outputIndex] = ' ';
if (++outputIndex > outputLimit) goto engine_finish;
} else output[emittedCount++] = character;
if (emittedCount >= request->maxCandidates) goto engine_finish;
} else if (totalResults >= options->maxResults) goto engine_finish;
@@ -1958,7 +1957,7 @@ component_retry:
goto character_pass_done;
}
if (!(ziU8)Zi8SecMatchChar(record, componentTable, &match, &candidateOrdinal, work)) goto component_record_next;
ordinalIndex = firstOrdinal + (remainingOrdinals - candidateCount - 1);
ordinalIndex = remainingOrdinals - candidateCount + firstOrdinal - 1;
if (charsetTable) charsetEntry = charsetTable + ordinalIndex;
if (charsetTable && !(charsetEntry[0] & charsetFilter)) goto component_record_next;
currentSpelling[0] = ((ZiChineseWork*)work)->duplicateCharacters[((ZiChineseWork*)work)->duplicateIndex] = candidateOrdinal;
@@ -2053,7 +2052,7 @@ component_record_next:
if (getMode != 5) {
while (exactPhrase) {
while (match.count) {
if (candidateCount-- == 0) goto frequency_range_retry;
if ((candidateCount -= 1) == 0xFFFF) goto frequency_range_retry;
if (match.recordValues[0] == (record[0] & match.recordMasks[0]) &&
(ziU8)Zi8SecMatchChar(record, componentTable, &match, &candidateOrdinal, work)) goto frequency_accept;
record += 12;
@@ -2073,7 +2072,7 @@ frequency_range_retry:
continue;
}
frequency_accept:
ordinalIndex = firstOrdinal + (remainingOrdinals - candidateCount - 1);
ordinalIndex = remainingOrdinals - candidateCount + firstOrdinal - 1;
if (charsetTable) charsetEntry = charsetTable + ordinalIndex;
if (charsetTable && !(charsetEntry[0] & charsetFilter)) goto frequency_record_next;
((ZiChineseWork*)work)->duplicateOrdinals[((ZiChineseWork*)work)->duplicateIndex] = ordinalIndex;
@@ -2299,7 +2298,7 @@ phonetic_pair_next:
alternateCursor += 4;
}
phonetic_group_next:
ordinalIndex++;
ordinalIndex += 1;
frequencyCursor += 5;
}
}

View File

@@ -25,7 +25,7 @@ const ziU8 zi8CangjieCodes[32] = {
21, 22, 23, 25, 26, 27, 29, 30, 31
};
ziU32 Zi8GetCJInfo(ziU8* input, ziWChar* output, ziU8 outputSize, ziPtr __zi8_work_data)
ziU32 Zi8GetCJInfo(ziU8* input, ziWChar* output, ziU8 outputSize, ziPtr work)
{
ziS32 packedCodes;
ziS32 code;
@@ -33,13 +33,13 @@ ziU32 Zi8GetCJInfo(ziU8* input, ziWChar* output, ziU8 outputSize, ziPtr __zi8_wo
ziS32 codeCount;
ziS32 index;
ZI_WORK->cangjieEnabled = Zi8GetFormatVersion(ZI8_LANG_ZH, __zi8_work_data) & 2;
if (ZI_WORK->cangjieEnabled == 0) {
Zi8LogError(0x8fc, __zi8_work_data);
((ZiInfoWork*)work)->cangjieEnabled = Zi8GetFormatVersion(1, work) & 2;
if (((ZiInfoWork*)work)->cangjieEnabled == 0) {
Zi8LogError(0x8fc, work);
return 0;
}
if (outputSize < 6) {
Zi8LogError(0x322, __zi8_work_data);
Zi8LogError(0x322, work);
return 0;
}
@@ -57,14 +57,14 @@ ziU32 Zi8GetCJInfo(ziU8* input, ziWChar* output, ziU8 outputSize, ziPtr __zi8_wo
}
}
if (index >= 0x19) {
Zi8LogError(0x26d, __zi8_work_data);
Zi8LogError(0x26d, work);
return 0;
}
output[outputCount] = index + 0x41;
outputCount++;
}
output[outputCount] = 0;
Zi8LogError(100, __zi8_work_data);
Zi8LogError(100, work);
return (ziU8)outputCount;
}
@@ -858,7 +858,7 @@ ziPtr work)
return;
}
ziU32 ZiCharInfo2(ziWChar ch, ziWChar* charInfoBuffer, ziU8 maxInfoBufSize, ziU32 hetMode, ziWChar* elements, ziU32 elementCount, ZiInfoWork* work)
ziU32 ZiCharInfo2(ziWChar ch, ziWChar* charInfoBuffer, ziU8 maxInfoBufSize, ziU32 hetMode, ziWChar* elements, ziU32 elementCount, ziPtr work)
{
union {
@@ -892,22 +892,22 @@ ziU32 ZiCharInfo2(ziWChar ch, ziWChar* charInfoBuffer, ziU8 maxInfoBufSize, ziU3
}
if (((ziU8)hetMode & 0x80) != 0) {
hetMode = (ziU8)(hetMode & 0x7f);
if (Zi8GetFormatVersion(ZI8_LANG_ZH,work) >= 4) {
charTableCount = Zi8GetTableCount(ZI8_LANG_ZH,0x19,work);
tablePtr = (ziU8*)Zi8GetTableAddress(ZI8_LANG_ZH,0x19,work);
if (Zi8GetFormatVersion(1,work) >= 4) {
charTableCount = Zi8GetTableCount(1,0x19,work);
tablePtr = (ziU8*)Zi8GetTableAddress(1,0x19,work);
}
else {
charTableCount = 0;
tablePtr = ZI8_NULL;
tablePtr = (ziU8*)0;
}
if ((hetMode & 0xff) == 1) {
tableBase = (ziU8*)Zi8GetTableAddress(ZI8_LANG_ZH,3,work);
tableBase = (ziU8*)Zi8GetTableAddress(1,3,work);
}
else {
tableBase = (ziU8*)Zi8GetTableAddress(ZI8_LANG_ZH,4,work);
tableBase = (ziU8*)Zi8GetTableAddress(1,4,work);
}
if ((hetMode & 0xff) != 1 && (hetMode & 0xff) != 2) goto lookupCharacter;
if (charTableCount <= Zi8GetTableCount(ZI8_LANG_ZH,8,work)) {
if (charTableCount <= Zi8GetTableCount(1,8,work)) {
highByte = (ziU8)((ch >> 8) & 0xff);
lowByte = (ziU8)ch;
index = 0;
@@ -917,10 +917,10 @@ ziU32 ZiCharInfo2(ziWChar ch, ziWChar* charInfoBuffer, ziU8 maxInfoBufSize, ziU3
charIndex = (ziU16)(((ziU32)tablePtr[2] >> 5) & 7) + tableBase[codeOffset] +
(ziU16)(((ziU32)tableBase[codeOffset + 1] & 0xffff) << 8);
if ((hetMode & 0xff) == 1) {
count = Zi8GetPInfo(charIndex,charInfoBuffer,maxInfoBufSize,work);
count = Zi8GetPInfo(charIndex,(ziU16*)charInfoBuffer,maxInfoBufSize,work);
}
else {
count = Zi8GetZInfo(charIndex,charInfoBuffer,maxInfoBufSize,work);
count = Zi8GetZInfo(charIndex,(ziU16*)charInfoBuffer,maxInfoBufSize,work);
}
normalizeStrokes:
if ((hetMode & 0xff) == 0x11) {
@@ -953,10 +953,10 @@ lookupCharacter:
count = 0;
}
else {
tablePtr = (ziU8*)Zi8GetTableAddress(ZI8_LANG_ZH,1,work);
tablePtr = (ziU8*)Zi8GetTableAddress(1,1,work);
tablePtr += ((uniInfoBuffer[9] & 0xf) << 0x10 | (uniInfoBuffer[11] | ((ziU32)uniInfoBuffer[10] << 8)));
work->cangjieEnabled = Zi8GetFormatVersion(ZI8_LANG_ZH,work) & 2;
if ((((work->cangjieEnabled != 0) && ((hetMode & 0xff) != 7)) && ((hetMode & 0xff) != 10))
((ZiInfoWork*)work)->cangjieEnabled = Zi8GetFormatVersion(1,work) & 2;
if ((((((ZiInfoWork*)work)->cangjieEnabled != 0) && ((hetMode & 0xff) != 7)) && ((hetMode & 0xff) != 10))
&& (((hetMode & 0xff) != 8 && ((hetMode & 0xff) != 9)))) {
switch (*tablePtr & 7) {
case 2:
@@ -974,12 +974,12 @@ lookupCharacter:
break;
}
}
switch(hetMode & 0xff) {
switch((ziU32)hetMode & 0xff) {
case 7:
case 8:
case 9:
case 10:
count = Zi8GetCJInfo(tablePtr,charInfoBuffer,maxInfoBufSize,work);
count = (ziU32)Zi8GetCJInfo(tablePtr,charInfoBuffer,maxInfoBufSize,work);
if ((((hetMode & 0xff) == 9) || ((hetMode & 0xff) == 10)) && (2 < (count & 0xff))) {
charInfoBuffer[1] = charInfoBuffer[(count & 0xff) - 1];
charInfoBuffer[2] = 0;
@@ -993,15 +993,15 @@ lookupCharacter:
break;
case 1:
case 3:
tableBase = (ziU8*)Zi8GetTableAddress(ZI8_LANG_ZH,3,work);
tableBase = (ziU8*)Zi8GetTableAddress(1,3,work);
charIndex = Zi8GetPCode((ziU32)tableBase,uniInfoBuffer);
count = Zi8GetPInfo(charIndex,charInfoBuffer,maxInfoBufSize,work);
count = Zi8GetPInfo(charIndex,(ziU16*)charInfoBuffer,maxInfoBufSize,work);
break;
case 2:
case 4:
tableBase = (ziU8*)Zi8GetTableAddress(ZI8_LANG_ZH,4,work);
tableBase = (ziU8*)Zi8GetTableAddress(1,4,work);
charIndex = Zi8GetPCode((ziU32)tableBase,uniInfoBuffer);
count = Zi8GetZInfo(charIndex,charInfoBuffer,maxInfoBufSize,work);
count = Zi8GetZInfo(charIndex,(ziU16*)charInfoBuffer,maxInfoBufSize,work);
break;
default:
count = 0;
@@ -1009,8 +1009,8 @@ lookupCharacter:
}
if ((((elementCount & 0xff) != 0) && ((uniInfoBuffer[0] & 0x80) != 0)) &&
(((hetMode & 0xff) == 3 || ((hetMode & 0xff) == 4)))) {
alternateTable = (ziU8 *)Zi8GetTableAddress(ZI8_LANG_ZH,5,work);
alternatesRemaining = Zi8GetTableCount(ZI8_LANG_ZH,5,work);
alternateTable = (ziU8 *)Zi8GetTableAddress(1,5,work);
alternatesRemaining = Zi8GetTableCount(1,5,work);
while (alternatesRemaining != 0) {
if (codeOffset == (((ziU16)alternateTable[1] << 8) | (ziU16)alternateTable[0])) break;
alternatesRemaining--;
@@ -1042,10 +1042,10 @@ lookupCharacter:
alternatesRemaining--;
alternateTable = alternateTable + 4;
if ((hetMode & 0xff) == 3) {
count = Zi8GetPInfo(charIndex,charInfoBuffer,maxInfoBufSize,work);
count = Zi8GetPInfo(charIndex,(ziU16*)charInfoBuffer,maxInfoBufSize,work);
}
else {
count = Zi8GetZInfo(charIndex,charInfoBuffer,maxInfoBufSize,work);
count = Zi8GetZInfo(charIndex,(ziU16*)charInfoBuffer,maxInfoBufSize,work);
}
goto checkElements;
}

View File

@@ -117,7 +117,7 @@ check_keys:
records[context->cnt].key = 0;
}
if (prefixLength != 0 && *prefixLength < context->cnt &&
ZiDAWGgetEOWattribute(current->node)) {
ZiDAWGgetEOWattribute(current->node) != 0) {
*prefixLength = context->cnt;
for (index = 0; index < context->cnt; index++) output[index] = (ziU16)records[index].attr;
}
@@ -125,7 +125,7 @@ check_keys:
}
if (context->cnt < search[1]) goto descend;
if (search[0] != 0 && context->cnt > search[1]) goto next_sibling;
if (acceptPrefix != 0 || ZiDAWGgetEOWattribute(current->node)) {
if (acceptPrefix != 0 || ZiDAWGgetEOWattribute(current->node) != 0) {
for (index = 0; index < context->cnt; index++) output[index] = (ziU16)records[index].attr;
result = context->cnt;
searching = 0;
@@ -232,7 +232,7 @@ unsigned int Zi8MatchROMdata2(ziWChar* elements, ziU8 count, ziU8 language,
if (status == 0) {
ZI_WORK->dawgGroupIndex = 0;
ZI_WORK->matchOffset = 0;
if (group != 0 && *group == 0xc && language == ZI8_LANG_FI && ZI_WORK->forceAltGraph != 0) {
if (group != 0 && *group == 0xc && language == 10 && ZI_WORK->forceAltGraph != 0) {
ZI_WORK->graphTableId = 0x10;
} else {
ZI_WORK->graphTableId = 0;
@@ -275,7 +275,7 @@ search_segment:
ZI_WORK->dawgGroupIndex++;
status = 0;
ZI_WORK->graphTableId = 0;
if (ZI_WORK->dawgCtx.key == 0 && language == ZI8_LANG_FI) {
if (ZI_WORK->dawgCtx.key == 0 && language == 10) {
for (index = 0; index < ZI_WORK->matchOffset; index++) {
switch (ZI_WORK->dawgWord[index]) {
case 0x61:
@@ -323,7 +323,7 @@ ziU32 Zi8MatchROMdata(ziWChar* elements, ziU8 count, ziU8 language,
acceptPrefix, ZI_WORK);
if ((ziU8)result != 0) break;
status = 0;
if (count <= 1 && language == ZI8_LANG_SW) break;
if (count <= 1 && language == 0x36) break;
ZI_WORK->dawgGroup = NextDawgGroup(ZI_WORK->dawgGroup, language, ZI_WORK);
}
}
@@ -380,7 +380,7 @@ void Zi8SyllablesROMdata(ziWChar *elements, ziU8 count, ziU8 language, ziWChar *
keyTable = 0x1b;
}
}
Zi8MatchROMdata0(elements,count,language & 0xff,output,capacity,1,status,graphTable,keyTable,0,prefixLength,
Zi8MatchROMdata0(elements,count,language & 0xff,output,capacity,1,status,graphTable,keyTable,0,(ziU8 *)prefixLength,
&ZI_WORK->dawgCtx,ZI_WORK->dawgSearchState,ZI_WORK);
return;
}

View File

@@ -62,7 +62,7 @@ ziU32 Zi8GetSyllablesCandidates(ziGetParam* param, ziSwParam* sw ZI_NEED_WORK) {
out = buf;
rem = 0x40;
} else {
out = param->candidates;
out = (ziWChar*)param->candidates;
rem = sw->capacity - 1;
}
if ((param->getOptions & 0xFD) == 0x80) {

View File

@@ -27,7 +27,7 @@ ziU16 Zi8GetTableCount(ziU8 language, ziU8 table, ziPtr work);
ziU16 Zi8GetVersion(ziPtr work);
ziU16 Zi8GetOEMID(ziPtr work);
ziU16 Zi8GetBuildID(ziPtr work);
ziPtr Zi8Memcpy(ziPtr destination, ziPtr source, ziS32 count);
void Zi8Memcpy(ziU8* destination, ziU8* source, ziS32 count);
ziU32 Zi8GetCandidatesOrCount(ziGetParam* parameters, ZiCandidateOptions* options, ziPtr work);
ziBool Zi8ZHsetPYfuzzyPairs(ziFuzzyPYPairs pairs ZI_NEED_WORK) {
@@ -66,8 +66,8 @@ ziU16 Zi8GetGlobalDataSize(void) {
static ziU16 Zi8GetDataSignature(ziU8* destination, ziU16 capacity, ziU8 language, ziPtr work) {
ziU8* signature;
ziU16 length;
if (language == ZI8_LANG_ZH) {
if (Zi8GetFormatVersion(ZI8_LANG_ZH, work) < 8) {
if (language == 1) {
if (Zi8GetFormatVersion(1, work) < 8) {
Zi8LogError(0x26f, work);
return 0;
}
@@ -293,8 +293,8 @@ ziU8 Zi8LangSupported(ziU8 language, ziPtr work);
ziBool Zi8IsCharacter(ziWChar character, ziPtr work);
ziU8 Zi8GetCharInfo(ziWChar character, ziWChar* output, ziU8 capacity, ziU8 type, ziPtr work);
ziU32 Zi8GetKOcandidates(ziGetParam* parameters, ziPtr options, ziPtr work);
ziU32 Zi8GetKoreanCandidates(ziGetParam* parameters, ziU8* countOnly, struct __zi8_work_data_s* work);
ziU32 Zi8Punctuation(ziGetParam* parameters, ZiCandidateOptions* options, ziPtr work);
ziU32 Zi8GetKoreanCandidates(ziGetParam* parameters, ziPtr options, ziPtr work);
ziU32 Zi8Punctuation(ziGetParam* parameters, ziPtr options, ziPtr work);
ziU32 Zi8GetChineseCandidates(ziGetParam* parameters, ziPtr options, ziPtr work);
ziU32 Zi8Get1KeyPressCandidates(ziGetParam* parameters, ziPtr options, ziPtr work);
ziU32 Zi8Get1KeyPressSpelling(ziGetParam* parameters, ziPtr options, ziPtr work);
@@ -324,11 +324,11 @@ ziU32 Zi8GetCandidatesOrCount(ziGetParam* parameters, ZiCandidateOptions* option
saved.savedCandidates = 0;
saved.restoreCandidates = 0;
if (options->lookupMode == '\0') {
if (ZI_WORK->getcPhase == '\t' && parameters->elementCount != 0 &&
((parameters->elements[parameters->elementCount - 1] == 0xEFF8 &&
Zi8AlphaSignature(parameters,options->countOnly,ZI_WORK)) ||
(parameters->elements[parameters->elementCount - 1] == 0xEF04 &&
Zi8ZhSignature(parameters,options->countOnly,ZI_WORK)))) {
if (((ZI_WORK->getcPhase == '\t') && (parameters->elementCount != 0)) &&
(((parameters->elements[parameters->elementCount - 1] == 0xEFF8 &&
((ziU8)Zi8AlphaSignature(parameters,options->countOnly,ZI_WORK) != 0)) ||
((parameters->elements[parameters->elementCount - 1] == 0xEF04 &&
((ziU8)Zi8ZhSignature(parameters,options->countOnly,ZI_WORK) != 0)))))) {
candidateCount = (unsigned int)parameters->letters;
if (options->countOnly != '\0') {
parameters->letters = 0;
@@ -338,7 +338,7 @@ ziU32 Zi8GetCandidatesOrCount(ziGetParam* parameters, ZiCandidateOptions* option
}
if ((parameters->elementCount == 1) && (parameters->firstCandidate == 0)) {
switch (parameters->language) {
case ZI8_LANG_ZH:
case 1:
if ((ZI_WORK->getcPhase == '\0') || (ZI_WORK->countOnly == options->countOnly)) {
switch(ZI_WORK->getcPhase) {
case '\0':
@@ -371,7 +371,7 @@ ziU32 Zi8GetCandidatesOrCount(ziGetParam* parameters, ZiCandidateOptions* option
case '\b':
case '\t':
if ((parameters->elements[0] == 0xEF04) &&
Zi8ZhSignature(parameters,options->countOnly,ZI_WORK)) {
((ziU8)Zi8ZhSignature(parameters,options->countOnly,ZI_WORK) != 0)) {
ZI_WORK->getcPhase = '\t';
candidateCount = (unsigned int)parameters->letters;
if (options->countOnly != '\0') {
@@ -388,15 +388,15 @@ ziU32 Zi8GetCandidatesOrCount(ziGetParam* parameters, ZiCandidateOptions* option
}
}
break;
case ZI8_LANG_JP:
case ZI8_LANG_KO:
case ZI8_LANG_PYP:
case ZI8_LANG_PYS:
case ZI8_LANG_ZYP:
case ZI8_LANG_ZYS:
case ZI8_LANG_SP2:
case ZI8_LANG_PY2:
case ZI8_LANG_ZY2:
case 0x10:
case 0x12:
case 0x77:
case 0x78:
case 0x79:
case 0x7A:
case 0x7B:
case 0x7C:
case 0x7D:
break;
case 0x11:
default:
@@ -467,7 +467,7 @@ ziU32 Zi8GetCandidatesOrCount(ziGetParam* parameters, ZiCandidateOptions* option
case '\b':
case '\t':
if ((parameters->elements[0] == 0xEFF8) &&
Zi8AlphaSignature(parameters,options->countOnly,ZI_WORK)) {
((ziU8)Zi8AlphaSignature(parameters,options->countOnly,ZI_WORK) != 0)) {
ZI_WORK->getcPhase = '\t';
candidateCount = (unsigned int)parameters->letters;
if (options->countOnly != '\0') {
@@ -491,34 +491,34 @@ ziU32 Zi8GetCandidatesOrCount(ziGetParam* parameters, ZiCandidateOptions* option
}
}
ZI_WORK->subLanguage = parameters->subLanguage;
ZI_WORK->cangjieEnabled = Zi8GetFormatVersion(ZI8_LANG_ZH,ZI_WORK) & 2;
ZI_WORK->cangjieEnabled = Zi8GetFormatVersion(1,ZI_WORK) & 2;
options->maxCount = ZI_WORK->maxCandidateCount;
options->maxWordLength = ZI_WORK->maxWordLength;
ZI_WORK->maxWordLength = -1;
if (Zi8LangSupported(parameters->language,ZI_WORK) == 0) {
if ((ziU8)Zi8LangSupported(parameters->language,ZI_WORK) == 0) {
Zi8LogError(0x163,ZI_WORK);
return 0;
}
else {
if (parameters->language == ZI8_LANG_JP) {
if (parameters->language == 0x10) {
error = 0x2c1;
candidateCount = 0;
}
else if (parameters->language == ZI8_LANG_KO) {
else if (parameters->language == 0x12) {
if ((parameters->elementCount == 0) || (parameters->elements[0] >= 0xeff1)) {
candidateCount = Zi8GetKOcandidates(parameters,options,ZI_WORK);
}
else {
candidateCount = Zi8GetKoreanCandidates(parameters,&options->countOnly,ZI_WORK);
candidateCount = Zi8GetKoreanCandidates(parameters,options,ZI_WORK);
}
}
else if ((parameters->language == ZI8_LANG_ZH) && ((parameters->context & 8) != 0)) {
else if ((parameters->language == 1) && ((parameters->context & 8) != 0)) {
candidateCount = Zi8Punctuation(parameters,options,ZI_WORK);
error = 100;
}
else if ((parameters->language == ZI8_LANG_ZH) &&
((parameters->getOptions & 0xbf) == 4 && parameters->elementCount != 0 &&
Zi8IsCharacter(parameters->elements[0],ZI_WORK))) {
else if ((parameters->language == 1) &&
((((parameters->getOptions & 0xbf) == 4 && (parameters->elementCount != 0)) &&
((ziU8)Zi8IsCharacter(parameters->elements[0],ZI_WORK) != 0)))) {
saved.convertedElementCount = Zi8GetCharInfo(parameters->elements[0],characterInfo,0x10,1,ZI_WORK);
if (saved.convertedElementCount == 0) {
parameters->letters = parameters->completion = parameters->count = 0;
@@ -543,11 +543,11 @@ ziU32 Zi8GetCandidatesOrCount(ziGetParam* parameters, ZiCandidateOptions* option
parameters->completion = 1;
}
}
else if ((parameters->language == ZI8_LANG_ZH) && (parameters->getMode == 0xf)) {
else if ((parameters->language == 1) && (parameters->getMode == 0xf)) {
error = 0x2d0;
candidateCount = 0;
}
else if ((parameters->language == ZI8_LANG_ZH) && ((parameters->getMode == 3 || (parameters->getMode == 4)))) {
else if ((parameters->language == 1) && ((parameters->getMode == 3 || (parameters->getMode == 4)))) {
if ((parameters->getOptions & 0x80) != 0) {
candidateCount = Zi8Get1KeyPressSpelling(parameters,options,ZI_WORK);
} else if (parameters->elementCount == 0) {
@@ -556,7 +556,7 @@ ziU32 Zi8GetCandidatesOrCount(ziGetParam* parameters, ZiCandidateOptions* option
candidateCount = Zi8Get1KeyPressCandidates(parameters,options,ZI_WORK);
}
}
else if ((parameters->language == ZI8_LANG_ZH) &&
else if ((parameters->language == 1) &&
((((parameters->getMode == 7 || (parameters->getMode == 8)) || (parameters->getMode == 10)) || (parameters->getMode == 9)))) {
if (ZI_WORK->cangjieEnabled != '\0') {
candidateCount = Zi8GetChineseCandidates(parameters,options,ZI_WORK);
@@ -565,11 +565,11 @@ ziU32 Zi8GetCandidatesOrCount(ziGetParam* parameters, ZiCandidateOptions* option
candidateCount = 0;
}
}
else if ((parameters->language == ZI8_LANG_ZH) && ((parameters->getMode == 0xb || (parameters->getMode == 0xe)))) {
else if ((parameters->language == 1) && ((parameters->getMode == 0xb || (parameters->getMode == 0xe)))) {
error = 0x2ee;
candidateCount = 0;
}
else if (parameters->language == ZI8_LANG_ZH) {
else if (parameters->language == 1) {
candidateCount = Zi8GetChineseCandidates(parameters,options,ZI_WORK);
if ((((candidateCount == 0) && ((parameters->getOptions & 0x20) == 0)) && ((parameters->getMode == 1 && (parameters->elementCount != 0))))
&& (((parameters->elements[parameters->elementCount - 1] == 0xF37A ||
@@ -700,16 +700,14 @@ ziBool Zi8IsDupWordW(ziWChar* word, ziU8 length ZI_NEED_WORK) {
return duplicate;
}
ziPtr Zi8Memset(ziPtr destination, ziU32 value, ziS32 count) {
void Zi8Memset(ziU8* destination, ziU32 value, ziS32 count) {
ziS32 index;
for (index = 0; index < count; index++) ((ziU8*)destination)[index] = (ziU8)value;
return destination;
for (index = 0; index < count; index++) destination[index] = (ziU8)value;
}
ziPtr Zi8Memcpy(ziPtr destination, ziPtr source, ziS32 count) {
void Zi8Memcpy(ziU8* destination, ziU8* source, ziS32 count) {
ziS32 index;
for (index = 0; index < count; index++) ((ziU8*)destination)[index] = ((ziU8*)source)[index];
return destination;
for (index = 0; index < count; index++) destination[index] = source[index];
}
ziBool Zi8SetMaxWordLength(ziU8 length ZI_NEED_WORK) {

View File

@@ -1,7 +1,7 @@
#include <zi8clib/zitypes.h>
#include <zi8clib/zierror.h>
extern ziPtr Zi8Memset(ziPtr destination, ziU32 value, ziS32 count);
extern void Zi8Memset(ziPtr p, ziU32 v, ziU32 len);
extern void Zi8SetLatinSearchOrder(ziU32 a, ziU8 b ZI_NEED_WORK);
extern void ZADP_Zi8SetPDremoveOpt(ziU8 a ZI_NEED_WORK);
extern ziU16 Zi8GetFormatVersion(ziU8 a ZI_NEED_WORK);
@@ -37,18 +37,18 @@ ziU8 Zi8InitializeDynamic(ziLanguageEntry* langEntries ZI_NEED_WORK) {
Zi8LogError(0x578, ZI_WORK);
return 0;
}
if (ZI_WORK->langEntries->language == ZI8_LANG_NONE) {
if (ZI_WORK->langEntries->language == 0) {
Zi8LogError(0x582, ZI_WORK);
return 0;
}
ZI_WORK->letterHyphen = 0x2D;
ZI_WORK->language = ZI8_LANG_NONE;
ZI_WORK->language = 0;
ZI_WORK->searchModes[3] = 0;
ZI_WORK->capacity = 0x100;
Zi8SetLatinSearchOrder(0, 0, ZI_WORK);
ZADP_Zi8SetPDremoveOpt(1, ZI_WORK);
ZI_WORK->zhPudMinPrefix = 5;
ZI_WORK->cangjieEnabled = Zi8GetFormatVersion(ZI8_LANG_ZH, ZI_WORK) & 2;
ZI_WORK->cangjieEnabled = Zi8GetFormatVersion(1, ZI_WORK) & 2;
ZI_WORK->pyFuzzy.bits.msb = 1;
ZI_WORK->zyFuzzy.bits.msb = 1;
zyFuzzy = ZI_WORK->zyFuzzy.word;
@@ -63,11 +63,11 @@ ziU8 Zi8InitializeDynamic(ziLanguageEntry* langEntries ZI_NEED_WORK) {
}
ziU8 Zi8IsZicorpSignature(ziU16* p, ziU16 len ZI_NEED_WORK) {
if (len > 6 && p[0] == 0x7A && p[1] == 0x69 && p[2] == 0x63 &&
if ((ziU16)len > 6 && p[0] == 0x7A && p[1] == 0x69 && p[2] == 0x63 &&
p[3] == 0x6F && p[4] == 0x72 && p[5] == 0x70) {
return 1;
}
if (len > 6 && p[0] == 0x39 && p[1] == 0x34 && p[2] == 0x32 &&
if ((ziU16)len > 6 && p[0] == 0x39 && p[1] == 0x34 && p[2] == 0x32 &&
p[3] == 0x36 && p[4] == 0x37 && p[5] == 0x37) {
return 1;
}

View File

@@ -5,9 +5,9 @@ extern ziU8 Zi8LangSupported(ziU8 lang ZI_NEED_WORK);
extern ziU16 Zi8GetTableCount(ziU8 lang, ziU8 tableIdx ZI_NEED_WORK);
extern ziU32 Zi8GetTableAddress(ziU8 lang, ziU8 tableIdx ZI_NEED_WORK);
extern ziU8 _Zi8GetCandidates(ziGetParam* getParam ZI_NEED_WORK);
extern ziPtr Zi8Memset(ziPtr destination, ziU32 value, ziS32 count);
extern void Zi8Memset(ziPtr p, ziU32 v, ziU32 len);
ziU8 Zi8GetZHCharSet(ziPtr __zi8_work_data) {
ziU8 Zi8GetZHCharSet(ziPtr workData) {
ziU8 charSet = 0;
ziU8 bak;
ziU16 v0;
@@ -18,23 +18,23 @@ ziU8 Zi8GetZHCharSet(ziPtr __zi8_work_data) {
ziWChar candBuf[0x10];
ziGetParam getParam;
Zi8LogError(0x64, __zi8_work_data);
if (Zi8LangSupported(ZI8_LANG_ZH, __zi8_work_data) == 0) {
Zi8ReplaceLastError(0x26C, __zi8_work_data);
Zi8LogError(0x64, workData);
if (Zi8LangSupported(1, workData) == 0) {
Zi8ReplaceLastError(0x26C, workData);
return 0;
}
if (Zi8GetTableCount(ZI8_LANG_ZH, 10, __zi8_work_data) != 0) {
bak = ZI_WORK->subLanguage;
ZI_WORK->subLanguage = 1;
addr = Zi8GetTableAddress(ZI8_LANG_ZH, 10, __zi8_work_data);
if (Zi8GetTableCount(1, 10, workData) != 0) {
bak = ((struct __zi8_work_data_s*)workData)->subLanguage;
((struct __zi8_work_data_s*)workData)->subLanguage = 1;
addr = Zi8GetTableAddress(1, 10, workData);
p = (ziU8*)addr;
v0 = (ziU16)((ziU16)p[0] | ((ziU16)p[1] << 8));
ZI_WORK->subLanguage = 0;
addr = Zi8GetTableAddress(ZI8_LANG_ZH, 10, __zi8_work_data);
((struct __zi8_work_data_s*)workData)->subLanguage = 0;
addr = Zi8GetTableAddress(1, 10, workData);
p = (ziU8*)addr;
v1 = (ziU16)((ziU16)p[2] | ((ziU16)p[3] << 8));
v2 = (ziU16)((ziU16)p[4] | ((ziU16)p[5] << 8));
ZI_WORK->subLanguage = bak;
((struct __zi8_work_data_s*)workData)->subLanguage = bak;
if (v0 != 0) {
if (v0 > 0x4E20) {
charSet |= 8;
@@ -56,7 +56,7 @@ ziU8 Zi8GetZHCharSet(ziPtr __zi8_work_data) {
}
Zi8Memset(&getParam, 0, 0x2C);
getParam.language = ZI8_LANG_ZH;
getParam.language = 1;
getParam.context = 1;
getParam.getOptions = 0;
getParam.candidates = candBuf;
@@ -64,17 +64,17 @@ ziU8 Zi8GetZHCharSet(ziPtr __zi8_work_data) {
getParam.subLanguage = 1;
retry:
getParam.getMode = 0;
if (_Zi8GetCandidates(&getParam, __zi8_work_data) != 0) {
if (_Zi8GetCandidates(&getParam, workData) != 0) {
charSet |= getParam.subLanguage;
goto next;
}
getParam.getMode = 1;
if (_Zi8GetCandidates(&getParam, __zi8_work_data) != 0) {
if (_Zi8GetCandidates(&getParam, workData) != 0) {
charSet |= getParam.subLanguage;
goto next;
}
getParam.getMode = 2;
if (_Zi8GetCandidates(&getParam, __zi8_work_data) != 0) {
if (_Zi8GetCandidates(&getParam, workData) != 0) {
charSet |= getParam.subLanguage;
}
next:
@@ -123,10 +123,10 @@ ziBool Zi8IsCharacter(ziWChar ch ZI_NEED_WORK) {
case 0xFF1F:
return 1;
}
hi = (ziU8)((ch >> 8) & 0xFF);
hi = (ziU8)(((ziU16)ch >> 8) & 0xFF);
lo = (ziU8)ch;
count = Zi8GetTableCount(ZI8_LANG_ZH, 0, ZI_WORK);
addr = Zi8GetTableAddress(ZI8_LANG_ZH, 0, ZI_WORK);
count = Zi8GetTableCount(1, 0, ZI_WORK);
addr = Zi8GetTableAddress(1, 0, ZI_WORK);
table = (ziU8*)addr;
for (i = 0; i < count; i++) {
if (table[6] == hi && table[7] == lo) {

View File

@@ -108,21 +108,23 @@ ziBool Zi8ExactMatchNextChar(ziU8* node, ziU8 firstByteMask, ziU8 firstByteValue
return 0;
}
ziU32 Zi8SecMatchChar(ziU8* nodeAddress, ziU8* dictionaryAddress, ziMatchParam* match, ziU16* code ZI_NEED_WORK) {
ziU32 Zi8SecMatchChar(ziPtr nodeAddress, ziU8* dictionaryAddress, ziMatchParam* match, ziU16* code ZI_NEED_WORK) {
ziBool isPartial = 0;
ziU16 matchCode;
ziU8* data;
ziU8 value;
ziU16 targetCode;
ziU8 dataIndex;
ziU8 remaining;
struct {
ziU8 remaining;
ziU8 dataIndex;
ziU16 targetCode;
} state;
if (match->componentIndex != 0) {
targetCode = match->componentIndex;
matchCode = ((ziU16)(nodeAddress[4] & 3) << 8) | nodeAddress[5];
state.targetCode = match->componentIndex;
matchCode = ((ziU16)(((ziU8*)nodeAddress)[4] & 3) << 8) | ((ziU8*)nodeAddress)[5];
value = 0;
while (value++ < 6) {
if (targetCode == matchCode) {
if (state.targetCode == matchCode) {
break;
}
matchCode = ((ziU16)(*(dictionaryAddress + matchCode * 8 + 6) & 3) << 8) | *(dictionaryAddress + matchCode * 8 + 7);
@@ -130,13 +132,13 @@ ziU32 Zi8SecMatchChar(ziU8* nodeAddress, ziU8* dictionaryAddress, ziMatchParam*
break;
}
}
if (targetCode != matchCode) {
if (state.targetCode != matchCode) {
return 0;
}
}
data = (ziU8*)Zi8GetTableAddress(ZI8_LANG_ZH, 1, ZI_WORK);
data += nodeAddress[0xB] + (nodeAddress[0xA] << 8) + ((nodeAddress[9] & 0xF) << 16);
data = (ziU8*)Zi8GetTableAddress(1, 1, ZI_WORK);
data += ((ziU8*)nodeAddress)[0xB] + (((ziU8*)nodeAddress)[0xA] << 8) + ((((ziU8*)nodeAddress)[9] & 0xF) << 16);
if (ZI_WORK->cangjieEnabled != 0) {
switch (data[0] & 7) {
case 2:
@@ -166,27 +168,27 @@ ziU32 Zi8SecMatchChar(ziU8* nodeAddress, ziU8* dictionaryAddress, ziMatchParam*
isPartial = 1;
}
} else if ((match->length & 1) != 0) {
if ((nodeAddress[match->length >> 1] & 0xF) == 0xF) {
if ((((ziU8*)nodeAddress)[match->length >> 1] & 0xF) == 0xF) {
isPartial = 1;
}
} else {
if ((nodeAddress[match->length >> 1] & 0xF0) == 0xF0) {
if ((((ziU8*)nodeAddress)[match->length >> 1] & 0xF0) == 0xF0) {
isPartial = 1;
}
}
if (match->length > 2) {
if ((match->length & 1) != 0) {
if (((nodeAddress[(match->length - 1) >> 1] & 0xF0) == 0) || ((nodeAddress[(match->length - 1) >> 1] & 0xF0) == 0xF0)) {
if (((((ziU8*)nodeAddress)[(match->length - 1) >> 1] & 0xF0) == 0) || ((((ziU8*)nodeAddress)[(match->length - 1) >> 1] & 0xF0) == 0xF0)) {
return 0;
}
} else {
if (((nodeAddress[(match->length - 1) >> 1] & 0xF) == 0) || ((nodeAddress[(match->length - 1) >> 1] & 0xF) == 0xF)) {
if (((((ziU8*)nodeAddress)[(match->length - 1) >> 1] & 0xF) == 0) || ((((ziU8*)nodeAddress)[(match->length - 1) >> 1] & 0xF) == 0xF)) {
return 0;
}
}
}
if (code != 0) {
*code = ((ziU16)nodeAddress[6] << 8) + (ziU16)nodeAddress[7];
*code = ((ziU16)((ziU8*)nodeAddress)[6] << 8) + (ziU16)((ziU8*)nodeAddress)[7];
}
if (isPartial) {
return 2;
@@ -204,9 +206,9 @@ ziU32 Zi8SecMatchChar(ziU8* nodeAddress, ziU8* dictionaryAddress, ziMatchParam*
}
}
dataIndex = 4;
remaining = ((match->length + 1) >> 1) - 4;
if ((value + 1) < remaining) {
state.dataIndex = 4;
state.remaining = ((match->length + 1) >> 1) - 4;
if (((ziU8)value + 1) < (int)state.remaining) {
return 0;
}
if ((match->length & 1) != 0) {
@@ -219,17 +221,17 @@ ziU32 Zi8SecMatchChar(ziU8* nodeAddress, ziU8* dictionaryAddress, ziMatchParam*
}
}
if (match->count == 0) {
while (remaining != 0) {
if ((data[0] & match->recordMasks[dataIndex]) != match->recordValues[dataIndex]) {
while (state.remaining != 0) {
if ((data[0] & match->recordMasks[state.dataIndex]) != match->recordValues[state.dataIndex]) {
return 0;
}
dataIndex++;
remaining--;
state.dataIndex++;
state.remaining--;
data++;
}
}
if (code != 0) {
*code = ((ziU16)nodeAddress[6] << 8) + (ziU16)nodeAddress[7];
*code = ((ziU16)((ziU8*)nodeAddress)[6] << 8) + (ziU16)((ziU8*)nodeAddress)[7];
}
if (isPartial) {
return 2;
@@ -252,20 +254,20 @@ ziBool Zi8PriMatchNextComp(ziU8* node, ziU8 firstByteMask, ziU8 firstByteValue,
return 0;
}
ziBool Zi8SecMatchComp(ziU8* nodeAddress, ziMatchParam* matchAddress, ziU8* dictionaryAddress ZI_NEED_WORK) {
ziBool Zi8SecMatchComp(ziPtr nodeAddress, ziMatchParam* matchAddress, ziPtr dictionaryAddress ZI_NEED_WORK) {
int chainIndex;
ziU16 matchCode;
ziU16 targetCode;
if (matchAddress->componentIndex != 0) {
targetCode = matchAddress->componentIndex;
matchCode = ((ziU16)(nodeAddress[6] & 3) << 8) | nodeAddress[7];
matchCode = ((ziU16)(((ziU8*)nodeAddress)[6] & 3) << 8) | ((ziU8*)nodeAddress)[7];
chainIndex = 0;
while (chainIndex++ < 6) {
if (targetCode == matchCode) {
break;
}
matchCode = ((ziU16)(*(dictionaryAddress + matchCode * 8 + 6) & 3) << 8) | *(dictionaryAddress + matchCode * 8 + 7);
matchCode = ((ziU16)(*((ziU8*)dictionaryAddress + matchCode * 8 + 6) & 3) << 8) | *((ziU8*)dictionaryAddress + matchCode * 8 + 7);
if (matchCode == 0) {
break;
}
@@ -275,10 +277,10 @@ ziBool Zi8SecMatchComp(ziU8* nodeAddress, ziMatchParam* matchAddress, ziU8* dict
}
}
if (matchAddress->length > 8) {
if (nodeAddress[5] < (matchAddress->length - 2)) {
if ((int)((ziU8*)nodeAddress)[5] < (int)(matchAddress->length - 2)) {
return 0;
}
} else if (nodeAddress[5] < (matchAddress->length - 1)) {
} else if ((int)((ziU8*)nodeAddress)[5] < (int)(matchAddress->length - 1)) {
return 0;
}
return 1;
@@ -287,16 +289,18 @@ ziBool Zi8SecMatchComp(ziU8* nodeAddress, ziMatchParam* matchAddress, ziU8* dict
extern ziU16 Zi8MatchAltSound(ziPtr soundTable, ziU16 soundCode, ziPtr pCodeTable, ziU16 index, ziU16 mask, ziU16 value, ziU8 flag ZI_NEED_WORK);
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) {
ziU16 code;
ziU16 remaining;
ziU16 soundIndex;
ziU16 dictionaryIndex;
ziU8 matchedParts;
ziU8 nextCode;
ziU8 partCount;
ziU8 partIndex;
ziBool hasString;
ziBool Zi8MatchPhonetic(ziPtr 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;
ziU8* sound;
typedef struct {
ziU8 header;
@@ -304,42 +308,42 @@ ziBool Zi8MatchPhonetic(ziU8* pCodeTable, ziU8* dictionary, ziPtr soundTable, zi
} DictionaryNode;
if (*stringOffset != 0) {
hasString = 1;
traversal.hasString = 1;
} else {
hasString = 0;
traversal.hasString = 0;
}
if (*count != 0) {
remaining = *count;
traversal.remaining = *count;
} else {
remaining = 1;
traversal.remaining = 1;
}
matchedParts = 0;
traversal.matchedParts = 0;
if ((lastMode != 0) && (numParts > 1)) {
altMode = 1;
}
while (remaining-- != 0) {
while (traversal.remaining-- != 0) {
if ((node[0] & flag) != 0) goto decode_node;
next_node:
node += 0xC;
continue;
decode_node:
code = Zi8GetPCode(pCodeTable, node);
if ((*values != (code & *masks)) && (altMode == 0) && ((node[0] & 0x80) != 0)) {
traversal.code = Zi8GetPCode((ziU8*)pCodeTable, node);
if ((*values != (traversal.code & *masks)) && (altMode == 0) && ((node[0] & 0x80) != 0)) {
if (*count != 0) {
soundIndex = (initialCode - remaining) - 1;
traversal.soundIndex = (initialCode - traversal.remaining) - 1;
} else {
soundIndex = initialCode;
traversal.soundIndex = initialCode;
}
code = Zi8MatchAltSound(soundTable, soundCode, pCodeTable, soundIndex, *masks, *values, flag, ZI_WORK);
traversal.code = Zi8MatchAltSound(soundTable, soundCode, pCodeTable, traversal.soundIndex, *masks, *values, flag, ZI_WORK);
}
goto check_code;
match_code:
if (partValue == (code & partMask)) goto next_node;
matchedParts = 1;
if (partValue == (traversal.code & partMask)) goto next_node;
traversal.matchedParts = 1;
if (*count != 0) {
soundIndex = (initialCode - remaining) - 1;
traversal.soundIndex = (initialCode - traversal.remaining) - 1;
} else {
soundIndex = initialCode;
traversal.soundIndex = initialCode;
}
sound = (ziU8*)(tableAddress + ((node[9] & 0xF) * 0x10000 + (node[0xB] + node[0xA] * 0x100)));
if (ZI_WORK->cangjieEnabled != 0) {
@@ -364,46 +368,46 @@ match_code:
} else if (numParts > 1) {
goto next_node;
}
if (((ziU8)matchedParts == numParts) || (numParts == 0)) {
if (((ziU8)traversal.matchedParts == numParts) || (numParts == 0)) {
*resultNode = node;
*resultCode = ((ziU16)node[6] << 8) + node[7];
*count = remaining;
*count = traversal.remaining;
return 1;
}
next_group:
{
nextCode = *sound++;
partCount = nextCode & 0xF;
if ((nextCode & flag) == 0) {
for (; partCount != 0; partCount--) {
traversal.nextCode = *sound++;
traversal.partCount = traversal.nextCode & 0xF;
if ((traversal.nextCode & flag) == 0) {
for (; traversal.partCount != 0; traversal.partCount--) {
for (sound++; (*sound & 0x80) == 0; sound += 2) {
}
sound++;
}
}
for (; partCount != 0; partCount--) {
partIndex = 1;
if (hasString && (sound > *stringOffset)) {
hasString = 0;
for (; traversal.partCount != 0; traversal.partCount--) {
traversal.partIndex = 1;
if (traversal.hasString && (sound > *stringOffset)) {
traversal.hasString = 0;
}
if (!hasString) {
if (!traversal.hasString) {
*stringOffset = sound;
}
do {
dictionaryIndex = sound[0] | ((ziU16)sound[1] << 8);
traversal.dictionaryIndex = sound[0] | ((ziU16)sound[1] << 8);
sound += 2;
if (hasString) {
if (traversal.hasString) {
goto phonetic_skip;
}
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);
traversal.code = Zi8GetPCode((ziU8*)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);
}
if ((code & masks[partIndex]) == values[partIndex]) {
if ((traversal.code & masks[traversal.partIndex]) == values[traversal.partIndex]) {
goto phonetic_matched;
}
phonetic_skip:
if ((dictionaryIndex & 0x8000) == 0) {
if ((traversal.dictionaryIndex & 0x8000) == 0) {
sound++;
while ((*sound & 0x80) == 0) {
sound += 2;
@@ -412,23 +416,23 @@ phonetic_skip:
}
break;
phonetic_matched:
if (++partIndex == numParts) {
if (++traversal.partIndex == numParts) {
if (partialMode != 0) {
if (strictMode == 0 && (dictionaryIndex & 0x8000) != 0) goto phonetic_skip;
if (strictMode != 0 && (dictionaryIndex & 0x8000) == 0) goto phonetic_skip;
if (strictMode == 0 && (traversal.dictionaryIndex & 0x8000) != 0) goto phonetic_skip;
if (strictMode != 0 && (traversal.dictionaryIndex & 0x8000) == 0) goto phonetic_skip;
}
*resultNode = node;
*resultCode = ((ziU16)node[6] << 8) + node[7];
*count = remaining;
*count = traversal.remaining;
return 1;
}
} while ((dictionaryIndex & 0x8000) == 0);
} while ((traversal.dictionaryIndex & 0x8000) == 0);
}
}
if ((nextCode & 0x80) != 0) goto next_node;
if ((traversal.nextCode & 0x80) != 0) goto next_node;
goto next_group;
check_code:
if (*values == (code & *masks)) goto match_code;
if (*values == (traversal.code & *masks)) goto match_code;
goto next_node;
}
return 0;
@@ -571,7 +575,7 @@ scan_final:
value -= 0x61;
}
pinyin[index] = (ziU8)value + 1;
if (!Zi8GetPyFinal(pinyin, &pyInitial, &pyFinal)) goto try_final_extension;
if (Zi8GetPyFinal(pinyin, &pyInitial, &pyFinal) == 0) goto try_final_extension;
if (outputIndex == 0) {
*resultCount += 1;
}
@@ -586,7 +590,7 @@ try_final_extension:
if (index < 3) {
pinyin[index + 1] = 0xFF;
if (Zi8GetPyFinal(pinyin, &pyInitial, &pyFinal)) {
if (Zi8GetPyFinal(pinyin, &pyInitial, &pyFinal) != 0) {
if (outputIndex == 0) {
*resultCount += 1;
}
@@ -620,7 +624,7 @@ finish_final:
partial = 1;
}
if (partial && alternateInitial == 0) {
if (Zi8GetPyFinal(pinyin, &pyInitial, &pyFinal)) {
if (Zi8GetPyFinal(pinyin, &pyInitial, &pyFinal) != 0) {
if (convertedCount == 0) {
result++;
initial[outputIndex] = 0x7E00;
@@ -637,7 +641,7 @@ finish_final:
}
} else {
pinyin[index] = 0xFF;
if (Zi8GetPyFinal(pinyin, &pyInitial, &pyFinal)) {
if (Zi8GetPyFinal(pinyin, &pyInitial, &pyFinal) != 0) {
if (convertedCount == 0) {
result++;
initial[outputIndex] = 0x7E00;
@@ -649,7 +653,7 @@ finish_final:
*bestFinal = final[0];
if ((outputIndex == 0) && (count == 0)) {
pinyin[index] = 0;
if (Zi8GetPyFinal(pinyin, &pyInitial, &pyFinal)) {
if (Zi8GetPyFinal(pinyin, &pyInitial, &pyFinal) != 0) {
if (convertedCount == 0) {
*bestInitial = 0x7E00;
*bestFinal = 0x200;
@@ -660,7 +664,7 @@ finish_final:
}
} else {
pinyin[index] = 0;
if (Zi8GetPyFinal(pinyin, &pyInitial, &pyFinal)) {
if (Zi8GetPyFinal(pinyin, &pyInitial, &pyFinal) != 0) {
if (convertedCount == 0) {
result++;
initial[outputIndex] = 0x7E00;

View File

@@ -6,6 +6,8 @@ extern ziU32 Zi8GetTableAddress(ziU8 lang, ziU8 tableIdx ZI_NEED_WORK);
typedef struct { ziU8 b[0xC]; } ziE12;
#define WORKP ((struct __zi8_work_data_s*)__zi8_work_data)
ziU16 Zi8Uni2Ptr(ziU16 ch, ziE12* buf ZI_NEED_WORK) {
ziU8 hi;
ziU8 lo;
@@ -16,15 +18,15 @@ ziU16 Zi8Uni2Ptr(ziU16 ch, ziE12* buf ZI_NEED_WORK) {
ziU8* e;
ziU8* p;
hi = (ziU8)((ch >> 8) & 0xFF);
hi = (ziU8)(((ziU16)ch >> 8) & 0xFF);
lo = (ziU8)ch;
count = Zi8GetTableCount(ZI8_LANG_ZH, 0, __zi8_work_data);
table = Zi8GetTableAddress(ZI8_LANG_ZH, 0, __zi8_work_data);
table2 = Zi8GetTableAddress(ZI8_LANG_ZH, 1, __zi8_work_data);
count = Zi8GetTableCount(1, 0, __zi8_work_data);
table = Zi8GetTableAddress(1, 0, __zi8_work_data);
table2 = Zi8GetTableAddress(1, 1, __zi8_work_data);
if (buf == ZI8_NULL) {
for (i = 0; i < 0x40; i++) {
if (ch == ZI_WORK->duplicateCharacters[i]) {
i = ZI_WORK->duplicateOrdinalCache[i];
if (ch == WORKP->duplicateCharacters[i]) {
i = WORKP->duplicateOrdinalCache[i];
e = (ziU8*)table + i * 0xC;
if (i >= count) {
break;
@@ -35,7 +37,7 @@ ziU16 Zi8Uni2Ptr(ziU16 ch, ziE12* buf ZI_NEED_WORK) {
p = (ziU8*)(table2 +
(((e[9] & 0xF) << 16) |
(e[0xB] | (e[0xA] << 8))));
if (ZI_WORK->cangjieEnabled != 0) {
if (WORKP->cangjieEnabled != 0) {
switch (p[0] & 7) {
case 2:
p += 2;
@@ -63,19 +65,19 @@ ziU16 Zi8Uni2Ptr(ziU16 ch, ziE12* buf ZI_NEED_WORK) {
}
}
e = (ziU8*)table;
if (ZI_WORK->unicodeMap != ZI8_NULL && ZI_WORK->unicodeMapSubLang == ZI_WORK->subLanguage) {
if (ch >= ZI_WORK->unicodeRange1Min && ch <= ZI_WORK->unicodeRange1Max) {
i = (ziU16)(ch - ZI_WORK->unicodeRange1Min);
if (WORKP->unicodeMap != ZI8_NULL && WORKP->unicodeMapSubLang == WORKP->subLanguage) {
if ((ziU16)ch >= WORKP->unicodeRange1Min && (ziU16)ch <= WORKP->unicodeRange1Max) {
i = (ziU16)(ch - WORKP->unicodeRange1Min);
goto map;
}
if (ch >= ZI_WORK->unicodeRange2Min && ch <= ZI_WORK->unicodeRange2Max) {
i = (ziU16)(ZI_WORK->unicodeRange1Max + (ch - ZI_WORK->unicodeRange2Min) -
ZI_WORK->unicodeRange1Min + 1);
if ((ziU16)ch >= WORKP->unicodeRange2Min && (ziU16)ch <= WORKP->unicodeRange2Max) {
i = (ziU16)(WORKP->unicodeRange1Max + (ch - WORKP->unicodeRange2Min) -
WORKP->unicodeRange1Min + 1);
goto map;
}
return 0xFFFF;
map:
i = ZI_WORK->unicodeMap[i];
i = WORKP->unicodeMap[i];
if (i != 0xFFFF) {
e = (ziU8*)table + i * 0xC;
if (hi == e[6] && lo == e[7]) {
@@ -108,11 +110,11 @@ ziU16 Zi8Uni2Ord(ziU16 ch ZI_NEED_WORK) {
ziU16 Zi8Ord2Uni(ziU16 ord ZI_NEED_WORK) {
ziU8* p;
if (ord >= Zi8GetTableCount(ZI8_LANG_ZH, 0, __zi8_work_data)) {
if ((ziU16)ord >= Zi8GetTableCount(1, 0, __zi8_work_data)) {
Zi8LogError(0x132, __zi8_work_data);
return 0;
}
p = (ziU8*)Zi8GetTableAddress(ZI8_LANG_ZH, 0, __zi8_work_data);
p = (ziU8*)Zi8GetTableAddress(1, 0, __zi8_work_data);
p += ord * 0xC;
Zi8LogError(0x64, __zi8_work_data);
return (ziU16)(((ziU16)p[6] << 8) + p[7]);
@@ -123,9 +125,9 @@ ziU16 Zi8Ord2Ord(ziU16 ord ZI_NEED_WORK) {
ziU16 count;
ziU8* p;
count = Zi8GetTableCount(ZI8_LANG_ZH, 0, __zi8_work_data);
table = Zi8GetTableAddress(ZI8_LANG_ZH, 0, __zi8_work_data);
if (ord == 0 || ord >= count) {
count = Zi8GetTableCount(1, 0, __zi8_work_data);
table = Zi8GetTableAddress(1, 0, __zi8_work_data);
if (ord == 0 || (ziU16)ord >= count) {
Zi8LogError(0x132, __zi8_work_data);
return ord;
}

View File

@@ -77,7 +77,7 @@ ziU8 Zi8MatchPUDdata_ZHS(ziWChar* pattern, ziU8 length, ziU8 language, ziWChar*
Zi8LogError(0x4B0, __zi8_work_data);
return 0;
}
if (language == ZI8_LANG_ZH) {
if (language == 1) {
length *= 2;
}
if (continuation == 0) {
@@ -106,7 +106,7 @@ ziU8 Zi8MatchPUDdata_ZHS(ziWChar* pattern, ziU8 length, ziU8 language, ziWChar*
while ((ziS32)ZI_WORK->pudWordIndex < (ziS32)ZI_WORK->pudWordCount) {
wordSize = *word++;
entrySize = wordSize;
if (language == ZI8_LANG_ZH) {
if (language == 1) {
if (ZI_WORK->zhPudMinPrefix > *word) goto next;
wordSize--;
entrySize--;
@@ -118,7 +118,7 @@ next:
ZI_WORK->pudWordIndex++;
word += entrySize;
} else {
if (language == ZI8_LANG_ZH) {
if (language == 1) {
bytePattern = (ziU8*)pattern;
for (index = 0; index < length; index++) {
if (word[index] != bytePattern[index]) goto next;
@@ -143,7 +143,7 @@ matched:
else *output = Zi8ConvertWC2Key(*pattern, language, __zi8_work_data);
return 1;
}
if (language == ZI8_LANG_ZH) {
if (language == 1) {
byteOutput = (ziU8*)output;
for (index = copied = 0; index < (ziS32)wordSize && copied < capacity; copied++) {
byteOutput[index] = word[index];

View File

@@ -87,7 +87,7 @@ ziU8 Zi8ZHaddSpace(ziWChar* src, ziU8 count, ziWChar* dst,
return 1;
fail:
if (count >= maxLen) {
if ((ziU8)count >= (ziU16)maxLen) {
count = (ziU8)(maxLen - 1);
}
for (i = 0; i < count; i++) {

View File

@@ -1,4 +1,3 @@
#include <stddef.h>
#include <zi8clib/zitypes.h>
#include <zi8clib/zierror.h>
#include <zi8clib/zconvert.h>
@@ -8,25 +7,19 @@ typedef struct ziUserWord {
ziU8 size, language, length, priority;
ziU8 text[1];
} ziUserWord;
enum {
ZI_UWD_LENGTH_OFFSET = offsetof(ziUserWord, length),
ZI_UWD_PRIORITY_OFFSET = offsetof(ziUserWord, priority),
ZI_UWD_TEXT_OFFSET = offsetof(ziUserWord, text),
};
typedef struct ziUserDictionary {
ziU16 flags, end, current, boundary;
ziU8 entries[1];
} ziUserDictionary;
ziPtr Zi8Memset(ziPtr destination, ziU32 value, ziS32 count);
void Zi8Memset(ziPtr, ziU32, ziU32);
ziBool Zi8_81480224(ziU8* word ZI_NEED_WORK) {
ziBool Zi8_81480224(ziUserWord* word ZI_NEED_WORK) {
ziU8 length;
ziUwdNode* previous;
ziUwdNode* current;
ziUwdNode* added;
ziU8 position;
ziU8* candidate;
ziUserWord* candidate;
if (ZI_WORK->uwdCount >= 32) {
Zi8LogError(0x19D, __zi8_work_data);
return 0;
@@ -35,7 +28,7 @@ ziBool Zi8_81480224(ziU8* word ZI_NEED_WORK) {
Zi8LogError(0x19F, __zi8_work_data);
return 0;
}
length = word[ZI_UWD_LENGTH_OFFSET];
length = word->length;
if (length == 0) {
Zi8LogError(0x193, __zi8_work_data);
return 0;
@@ -47,12 +40,12 @@ ziBool Zi8_81480224(ziU8* word ZI_NEED_WORK) {
previous = 0;
current = ZI_WORK->uwdList;
while (current != 0) {
candidate = current->word;
if (ZI_WORK->uwdPrioritySort == 1 && word[ZI_UWD_PRIORITY_OFFSET] > candidate[ZI_UWD_PRIORITY_OFFSET]) break;
if (candidate[ZI_UWD_LENGTH_OFFSET] == length) {
candidate = (ziUserWord*)current->word;
if (ZI_WORK->uwdPrioritySort == 1 && word->priority > candidate->priority) break;
if (candidate->length == length) {
position = 0;
while (position < length) {
if (candidate[position + ZI_UWD_TEXT_OFFSET] != word[position + ZI_UWD_TEXT_OFFSET]) break;
if (candidate->text[position] != word->text[position]) break;
position++;
}
if (position == length) {
@@ -210,7 +203,7 @@ next:
if (ZI_WORK->uwdContextRecord[prefixLength] != ((ziU8*)previous)[prefixLength] && ZI_WORK->uwdContextAlternateCase[prefixLength] != ((ziU8*)previous)[prefixLength]) goto next;
}
}
Zi8_81480224(cursor, __zi8_work_data);
Zi8_81480224((ziUserWord*)cursor, __zi8_work_data);
}
goto next;
}

View File

@@ -129,8 +129,8 @@ ziU8* ZiDAWGGetSibling(ziU8* cursor) {
}
ziU8 ZiDAWGgetEOWattribute(ziU8* node) {
return (nodeHeaderTable[*node >> 4] & 0x10) > 0;
ziU8 ZiDAWGgetEOWattribute(ziU32 node) {
return (nodeHeaderTable[*(ziU8*)node >> 4] & 0x10) > 0;
}
ziU32 ZiDAWGgetCHARattribute(zi8DawgCtx* context, ziU32 node, ziPtr __zi8_work_data) {
@@ -149,17 +149,17 @@ ziU32 ZiDAWGgetCHARattribute(zi8DawgCtx* context, ziU32 node, ziPtr __zi8_work_d
}
attribute = key << 24;
attribute |= context->characterFlags[key] << 16;
attribute |= (((ziU32)context->characters[key * 2] & 0xFFFF) << 8) +
(context->characters + key * 2)[1];
attribute |= ((ziU8*)context->characterFlags)[key] << 16;
attribute |= (((ziU32)((ziU8*)context->characters)[key * 2] & 0xFFFF) << 8) +
((ziU8*)context->characters + key * 2)[1];
Zi8LogError(0x64, __zi8_work_data);
return attribute;
}
ziU32 ZiDAWGGetGraph(zi8DawgCtx* context) {
return (((ziU32)context->table[2] & 0xFFFF) << 8) +
context->table[3] +
((ziU32)context->table + 4);
ziU32 ZiDAWGGetGraph(ziPtr context) {
return (((ziU32)((zi8DawgCtx*)context)->table[2] & 0xFFFF) << 8) +
((zi8DawgCtx*)context)->table[3] +
((ziU32)((zi8DawgCtx*)context)->table + 4);
}
ziU32 ZiDAWGGetGraphInfo(zi8DawgCtx* context, ziU8* entry, ziU16* keys) {

View File

@@ -23,33 +23,35 @@ ziU8 Zi8LookupKoreanChar(ziWChar character, ziU8* result, ziU16* index, ziPtr wo
return 0;
}
ziU8 Zi8MatchKoreanSequence(ziU16* resultIndex, ziU16* input, ziU8 type, ziU16 count, struct __zi8_work_data_s* workData);
ziU8 Zi8MatchKoreanSequence(ziU16* resultIndex, ziU16* input, ziU8 type, ziU16 count, ziPtr workData);
ziU32 Zi8GetKoreanCandidates(ziGetParam* params, ziU8* argument,
struct __zi8_work_data_s* workData) {
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;
ziPtr 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;
ziU16 buffer[100];
ziU8 result;
ziU16 currentCharacter;
ziU8* selectedTable;
nextIndex = 0;
state.nextIndex = 0;
result = 0;
characterIndex = 0xFF;
currentCandidate = params->firstCandidate;
state.characterIndex = 0xFF;
state.currentCandidate = params->firstCandidate;
params->letters = params->completion = params->count = 0;
if ((argument != 0) && (*argument != 0)) {
Zi8LogError(0x7D0, workData);
@@ -61,31 +63,31 @@ ziU32 Zi8GetKoreanCandidates(ziGetParam* params, ziU8* argument,
}
selectedTable = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 4, 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);
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);
for (elementIndex = 0; elementIndex < params->elementCount;
elementIndex++) {
currentCharacter = params->elements[elementIndex];
for (state.elementIndex = 0; state.elementIndex < params->elementCount;
state.elementIndex++) {
currentCharacter = params->elements[state.elementIndex];
if ((currentCharacter >= 0x61) && (currentCharacter <= 0x7A)) {
buffer[elementIndex] = table1[(currentCharacter - 0x61) * 2];
buffer[state.elementIndex] = state.table1[(currentCharacter - 0x61) * 2];
} else if ((currentCharacter >= 0x41) && (currentCharacter <= 0x5A)) {
buffer[elementIndex] = (table1 + (currentCharacter - 0x41) * 2)[1];
buffer[state.elementIndex] = (state.table1 + (currentCharacter - 0x41) * 2)[1];
} else {
matched = 0;
for (; table2[matched * 3] != 0; matched++) {
if (currentCharacter == table2[matched * 3]) break;
state.matched = 0;
for (; state.table2[state.matched * 3] != 0; state.matched++) {
if (currentCharacter == state.table2[state.matched * 3]) break;
}
if (table2[matched * 3] != 0) {
buffer[elementIndex] =
((ziU16)(table2 + matched * 3)[1] << 8) |
(table2 + matched * 3)[2];
if (state.table2[state.matched * 3] != 0) {
buffer[state.elementIndex] =
((ziU16)(state.table2 + state.matched * 3)[1] << 8) |
(state.table2 + state.matched * 3)[2];
} else {
Zi8LogError(0x161, workData);
return 0;
@@ -94,16 +96,16 @@ ziU32 Zi8GetKoreanCandidates(ziGetParam* params, ziU8* argument,
}
result = 0;
for (currentCharacter = 0; currentCharacter < elementIndex; currentCharacter++) {
if (Zi8LookupKoreanChar(buffer[currentCharacter], &characterIndex,
&inputIndex, workData) != 0) {
matched = Zi8MatchKoreanSequence(&nextIndex,
for (currentCharacter = 0; currentCharacter < state.elementIndex; currentCharacter++) {
if (Zi8LookupKoreanChar(buffer[currentCharacter], &state.characterIndex,
&state.inputIndex, workData) != 0) {
state.matched = Zi8MatchKoreanSequence(&state.nextIndex,
buffer + currentCharacter + 1,
characterIndex,
(elementIndex - currentCharacter) - 1,
state.characterIndex,
(state.elementIndex - currentCharacter) - 1,
workData);
if (workData->koAltTables == 1) {
switch (characterIndex) {
if ((((struct __zi8_work_data_s*)workData)->koAltTables == 1)) {
switch (state.characterIndex) {
case 1:
selectedTable = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 0x1E, workData);
break;
@@ -166,59 +168,59 @@ ziU32 Zi8GetKoreanCandidates(ziGetParam* params, ziU8* argument,
}
}
} else {
matched = 0;
state.matched = 0;
}
if (matched != 0) {
if (tableCount6 == 0) {
nextIndex += inputIndex * tableCount3;
if (state.matched != 0) {
if (state.tableCount6 == 0) {
state.nextIndex += state.inputIndex * state.tableCount3;
}
if (currentCandidate != 0) {
currentCandidate--;
if (state.currentCandidate != 0) {
state.currentCandidate--;
} else {
params->candidates[result] =
((ziU16)selectedTable[nextIndex * 2] << 8) | (selectedTable + nextIndex * 2)[1];
if ((tableCount6 != 0) && (workData->koAltTables == 0)) {
params->candidates[result] += inputIndex * tableCount3;
params->candidates[(ziU8)result] =
((ziU16)selectedTable[state.nextIndex * 2] << 8) | (selectedTable + state.nextIndex * 2)[1];
if ((state.tableCount6 != 0) && (((struct __zi8_work_data_s*)workData)->koAltTables == 0)) {
params->candidates[(ziU8)result] += state.inputIndex * state.tableCount3;
}
result++;
}
if (currentCharacter == 0) {
params->completion = matched + 1;
params->completion = state.matched + 1;
}
currentCharacter += matched;
currentCharacter += state.matched;
} else {
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.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 (index == tableCount31) {
currentCandidate--;
if (state.index == state.tableCount31) {
state.currentCandidate--;
}
if (currentCharacter == 0) {
params->completion = 1;
}
} else {
for (index = 0; index < tableCount31; index++) {
if ((table31[(index * 3)] == buffer[currentCharacter]) &&
((table31 + index * 3)[1] == buffer[currentCharacter + 1])) {
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])) {
if (currentCharacter == 0) {
params->completion = 1;
}
params->candidates[result] =
tableCount0 + (table31 + index * 3)[2];
params->candidates[(ziU8)result] =
state.tableCount0 + (state.table31 + state.index * 3)[2];
result++;
currentCharacter++;
break;
}
}
if (index == tableCount31) {
if ((params->candidates[result] = buffer[currentCharacter]) < 0xFF) {
if (state.index == state.tableCount31) {
if ((params->candidates[(ziU8)result] = buffer[currentCharacter]) < 0xFF) {
if (currentCharacter == 0) {
params->completion = 1;
}
params->candidates[result] += tableCount0;
params->candidates[(ziU8)result] += state.tableCount0;
result++;
}
}
@@ -233,7 +235,7 @@ ziU32 Zi8GetKoreanCandidates(ziGetParam* params, ziU8* argument,
return result;
}
ziU8 Zi8MatchKoreanSequence(ziU16* resultIndex, ziU16* input, ziU8 type, ziU16 count, struct __zi8_work_data_s* workData) {
ziU8 Zi8MatchKoreanSequence(ziU16* resultIndex, ziU16* input, ziU8 type, ziU16 count, ziPtr workData) {
ziU16 nestedScratch;
ziU16 nestedIndexStorage;
ziU16 index1;
@@ -247,7 +249,7 @@ ziU8 Zi8MatchKoreanSequence(ziU16* resultIndex, ziU16* input, ziU8 type, ziU16 c
firstCharacter = input[0];
mappedCharacter = 0xFF;
if (workData->koAltTables == 0) {
if (((struct __zi8_work_data_s*)workData)->koAltTables == 0) {
table = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 3, workData);
tableCount = Zi8GetTableCount(ZI8_LANG_KO, 3, workData);
} else {

View File

@@ -53,7 +53,7 @@ ziBool Zi8IsWordW(ziWChar* word, ziU8 language ZI_NEED_WORK) {
Zi8ReplaceLastError(300, __zi8_work_data);
return 0;
}
if (language != ZI8_LANG_ZH) {
if (language != 1) {
for (count = 0; word[count] != 0; count++) {
if (word[count] >= 0xEFF1 || count == 64) return 0;
}
@@ -91,7 +91,7 @@ ziBool Zi8IsWordW(ziWChar* word, ziU8 language ZI_NEED_WORK) {
ZI_WORK->formatCount = savedCount;
if (count != 0) return 1;
}
if (language != ZI8_LANG_ZH) {
if (language != 1) {
Zi8ReplaceLastError(0x26C, __zi8_work_data);
return 0;
}
@@ -106,10 +106,10 @@ ziBool Zi8IsWordW(ziWChar* word, ziU8 language ZI_NEED_WORK) {
{
if (count-- == 1) return 1;
ordinals[count] |= 0x8000;
ZI_WORK->cangjieEnabled = Zi8GetFormatVersion(ZI8_LANG_ZH, __zi8_work_data) & 2;
table = Zi8GetTableAddress(ZI8_LANG_ZH, 0, __zi8_work_data);
ZI_WORK->cangjieEnabled = Zi8GetFormatVersion(1, __zi8_work_data) & 2;
table = (ziChineseEntry*)Zi8GetTableAddress(1, 0, __zi8_work_data);
entry = table + ordinals[0];
baseData = Zi8GetTableAddress(ZI8_LANG_ZH, 1, __zi8_work_data);
baseData = (ziU8*)Zi8GetTableAddress(1, 1, __zi8_work_data);
baseData += ((entry->offsetHigh & 15) << 16 | (entry->offsetLow[1] | (entry->offsetLow[0] << 8)));
data = baseData;
if (ZI_WORK->cangjieEnabled != 0) {
@@ -168,10 +168,10 @@ ziWChar Zi8ConvertUC2UserKey(ziChar character, ziU8 language ZI_NEED_WORK) {
if (character == 0 || language > 0x82 || (keys = ZI_WORK->userKeys[language]) == 0) return 0;
for (key = 0; key < 32; key++) {
for (cursor = keys->lower[key]; cursor != 0 && *cursor != 0; cursor++) {
if (*cursor == (ziU16)character) goto found;
if ((ziU16)*cursor == (ziU16)character) goto found;
}
for (cursor = keys->upper[key]; cursor != 0 && *cursor != 0; cursor++) {
if (*cursor == (ziU16)character) goto found;
if ((ziU16)*cursor == (ziU16)character) goto found;
}
}
found:

View File

@@ -189,8 +189,7 @@ ziU32 Zi8_814834AC(ziGetParam* param, ziU16* remaining, ziU8* count,
if (matches) {
for (candidateIndex = 0; candidateIndex < *count; candidateIndex++) {
if (param->candidates[candidateIndex] ==
(((ziU16)tableA[i * sizeof(ZiKoreanKeyEntry) + offsetof(ZiKoreanKeyEntry, characterHigh)] << 8) |
(ziU16)tableA[i * sizeof(ZiKoreanKeyEntry) + offsetof(ZiKoreanKeyEntry, characterLow)])) {
(((ziU16)((ZiKoreanKeyEntry*)tableA)[i].characterHigh << 8) | (ziU16)((ZiKoreanKeyEntry*)tableA)[i].characterLow)) {
matched++;
param->candidates[candidateIndex] &= 0x7FFF;
break;
@@ -248,251 +247,254 @@ typedef struct {
} ZiKoreanCandidateOptions;
ziU32 Zi8GetKOcandidates(ziGetParam* param, ZiKoreanCandidateOptions* options ZI_NEED_WORK) {
ziU8* wordTable;
ziS32 tableIndex;
ziS32 resultCount;
ziU32 wordOffset;
ziS32 prefixCount;
ziS32 candidateIndex;
ZiKoreanKeyEntry* entry;
ziU16 keyIndex;
ziU16 tableCount;
ziU16 character;
ziU16 previousIndex;
ziU16 remainingCandidates;
ziU8 remainingLetters;
ziU8 wordIndex;
ziU8 candidateCount;
ziU8 keyByte;
ziU8 matchPass;
ziU8 inserted;
ziBool matches;
struct {
ziBool matches;
ziU8 inserted;
ziU8 matchPass;
ziU8 keyByte;
ziU8 candidateCount;
ziU8 wordIndex;
ziU8 remainingLetters;
ziU16 remainingCandidates;
ziU16 previousIndex;
ziU16 character;
ziU16 tableCount;
ziU16 keyIndex;
ZiKoreanKeyEntry* entry;
ziS32 candidateIndex;
ziS32 prefixCount;
ziU32 wordOffset;
ziS32 resultCount;
ziS32 tableIndex;
ziU8* wordTable;
union {
ziU32 firstWord;
ziU8 bytes[5];
} packedKeys;
} search;
ziU8* keyTable;
ziU8* wordNode;
previousIndex = 0xFFFF;
resultCount = 0;
{
ziU8 packedKeys[5] = {0};
remainingLetters = 0;
wordIndex = 0;
candidateCount = 0;
keyByte = 0;
remainingCandidates = param->firstCandidate;
prefixCount = 0;
candidateIndex = 0;
inserted = 0;
Zi8LogError(100, ZI_WORK);
Zi8_81483264(param, ZI_WORK);
keyTable = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 9, ZI_WORK);
wordTable = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 10, ZI_WORK);
if (keyTable == 0) {
Zi8ReplaceLastError(0x76C, ZI_WORK);
search.previousIndex = 0xFFFF;
search.resultCount = 0;
search.packedKeys.firstWord = 0;
search.packedKeys.bytes[4] = 0;
search.wordIndex = search.remainingLetters = 0;
search.candidateCount = 0;
search.keyByte = 0;
search.remainingCandidates = param->firstCandidate;
search.prefixCount = 0;
search.candidateIndex = 0;
search.inserted = 0;
Zi8LogError(100, ZI_WORK);
Zi8_81483264(param, ZI_WORK);
keyTable = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 9, ZI_WORK);
search.wordTable = (ziU8*)Zi8GetTableAddress(ZI8_LANG_KO, 10, ZI_WORK);
if (keyTable == 0) {
Zi8ReplaceLastError(0x76C, ZI_WORK);
return 0;
} else {
if (search.wordTable == 0) {
Zi8ReplaceLastError(0x776, ZI_WORK);
return 0;
} else {
if (wordTable == 0) {
Zi8ReplaceLastError(0x776, ZI_WORK);
return 0;
}
if (options->countOnly == 0) {
param->letters = 0;
param->count = 0;
param->candidates[0] = 0;
}
Zi8LogError(100, ZI_WORK);
if (param->wordCharCount == 0) goto scan_key_table;
{
if (((keyIndex = Zi8_8148302C(param->currentWord[0], keyTable, ZI_WORK)) != 0xFFFF) &&
((keyTable[(keyIndex << 3) + keyIndex + offsetof(ZiKoreanKeyEntry, keyBytes[4])] & 8) != 0)) {
wordOffset = keyTable[(keyIndex << 3) + keyIndex + offsetof(ZiKoreanKeyEntry, childLow)] |
((keyTable[(keyIndex << 3) + keyIndex + offsetof(ZiKoreanKeyEntry, keyBytes[4])] & 3) << 16 |
keyTable[(keyIndex << 3) + keyIndex + offsetof(ZiKoreanKeyEntry, childHigh)] << 8);
remainingLetters = param->wordCharCount - 1;
wordIndex = 1;
wordNode = wordTable + wordOffset;
}
if (options->countOnly == 0) {
param->letters = 0;
param->count = 0;
param->candidates[0] = 0;
}
Zi8LogError(100, ZI_WORK);
if (param->wordCharCount == 0) goto scan_key_table;
{
if (((search.keyIndex = Zi8_8148302C(param->currentWord[0], keyTable, ZI_WORK)) != 0xFFFF) &&
((keyTable[(search.keyIndex << 3) + search.keyIndex + offsetof(ZiKoreanKeyEntry, keyBytes[4])] & 8) != 0)) {
search.wordOffset = ((ZiKoreanKeyEntry*)(((search.keyIndex << 3) + search.keyIndex) + keyTable))->childLow |
((((ZiKoreanKeyEntry*)(((search.keyIndex << 3) + search.keyIndex) + keyTable))->keyBytes[4] & 3) << 16 |
((ZiKoreanKeyEntry*)(((search.keyIndex << 3) + search.keyIndex) + keyTable))->childHigh << 8);
search.remainingLetters = param->wordCharCount - 1;
search.wordIndex = 1;
wordNode = search.wordTable + search.wordOffset;
match_word:
while (remainingLetters != 0) {
keyIndex = Zi8_8148302C(param->currentWord[wordIndex], keyTable, ZI_WORK);
if (keyIndex == (((ziU16)*wordNode & 0x1F) << 8 | (ziU16)wordNode[1])) {
--remainingLetters;
++wordIndex;
if ((*wordNode & 0x40) != 0) {
remainingLetters = param->wordCharCount - 1;
wordIndex = 1;
break;
}
wordNode += 2;
} else {
wordIndex = 1;
remainingLetters = param->wordCharCount - 1;
while (search.remainingLetters != 0) {
search.keyIndex = Zi8_8148302C(param->currentWord[search.wordIndex], (ziU8*)keyTable, ZI_WORK);
if (search.keyIndex == (((ziU16)*wordNode & 0x1F) << 8 | (ziU16)wordNode[1])) {
--search.remainingLetters;
++search.wordIndex;
if ((*wordNode & 0x40) != 0) {
search.remainingLetters = param->wordCharCount - 1;
search.wordIndex = 1;
break;
}
wordNode += 2;
} else {
search.wordIndex = 1;
search.remainingLetters = param->wordCharCount - 1;
break;
}
if (remainingLetters == 0) {
keyIndex = ((ziU16)*wordNode & 0x1F) << 8 | (ziU16)wordNode[1];
character = (ziU16)((ziU16)keyTable[(keyIndex << 3) + keyIndex + offsetof(ZiKoreanKeyEntry, characterHigh)] << 8 |
keyTable[(keyIndex << 3) + keyIndex + offsetof(ZiKoreanKeyEntry, characterLow)]);
if (param->wordCharCount == 1) {
if (keyIndex == previousIndex) {
for (; (*wordNode & 0x40) == 0; wordNode = wordNode + 2) {
}
wordNode += 2;
remainingLetters = param->wordCharCount - 1;
wordIndex = 1;
goto next_word;
}
if (search.remainingLetters == 0) {
search.keyIndex = ((ziU16)*wordNode & 0x1F) << 8 | (ziU16)wordNode[1];
search.character = (ziU16)((ziU16)((ZiKoreanKeyEntry*)(((search.keyIndex << 3) + search.keyIndex) + keyTable))->characterHigh << 8 |
((ZiKoreanKeyEntry*)(((search.keyIndex << 3) + search.keyIndex) + keyTable))->characterLow);
if (param->wordCharCount == 1) {
if (search.keyIndex == search.previousIndex) {
for (; (*wordNode & 0x40) == 0; wordNode = wordNode + 2) {
}
previousIndex = keyIndex;
if (param->elementCount == 0) {
if (remainingCandidates != 0) {
--remainingCandidates;
} else {
if (options->countOnly != 0) {
if (++prefixCount < (ziS32)options->maxCount) {
goto skip_word;
}
return options->maxCount;
}
param->candidates[candidateCount++] = character;
++param->count;
if (++param->letters >= param->maxCandidates) {
return param->letters;
}
}
wordNode += 2;
search.remainingLetters = param->wordCharCount - 1;
search.wordIndex = 1;
goto next_word;
}
search.previousIndex = search.keyIndex;
if (param->elementCount == 0) {
if (search.remainingCandidates != 0) {
--search.remainingCandidates;
} else {
param->candidates[candidateCount++] = character;
if (options->countOnly != 0) {
if (++search.prefixCount < (ziS32)options->maxCount) {
goto skip_word;
}
return options->maxCount;
}
param->candidates[search.candidateCount++] = search.character;
++param->count;
if (++param->letters >= param->maxCandidates) {
Zi8_814834AC(param, &remainingCandidates, &candidateCount, &inserted, ZI_WORK);
param->count = candidateCount;
param->letters = candidateCount;
if (candidateCount < param->maxCandidates) goto skip_word;
if (options->countOnly != 0) {
if ((prefixCount += candidateCount) >= (ziS32)options->maxCount) return options->maxCount;
param->count = 0;
param->letters = 0;
candidateCount = 0;
} else {
return candidateCount;
}
return param->letters;
}
}
} else {
for (candidateIndex = 0; candidateIndex < candidateCount; candidateIndex++) {
if (character == param->candidates[candidateIndex]) break;
}
if ((candidateIndex == candidateCount) &&
(Zi8_814833F0(param, character, ZI_WORK) == 0)) {
param->candidates[candidateCount++] = character;
++param->count;
if (++param->letters < param->maxCandidates) {
goto skip_word;
}
Zi8_814834AC(param, &remainingCandidates, &candidateCount, &inserted, ZI_WORK);
param->count = candidateCount;
param->letters = candidateCount;
if (candidateCount < param->maxCandidates) goto skip_word;
param->candidates[search.candidateCount++] = search.character;
++param->count;
if (++param->letters >= param->maxCandidates) {
Zi8_814834AC(param, &search.remainingCandidates, &search.candidateCount, &search.inserted, ZI_WORK);
param->count = search.candidateCount;
param->letters = search.candidateCount;
if (search.candidateCount < param->maxCandidates) goto skip_word;
if (options->countOnly != 0) {
if ((prefixCount += candidateCount) >= (ziS32)options->maxCount) return options->maxCount;
if ((search.prefixCount += search.candidateCount) >= (ziS32)options->maxCount) return options->maxCount;
param->count = 0;
param->letters = 0;
candidateCount = 0;
search.candidateCount = 0;
} else {
return candidateCount;
return search.candidateCount;
}
}
}
} else {
for (search.candidateIndex = 0; search.candidateIndex < search.candidateCount; search.candidateIndex++) {
if (search.character == param->candidates[search.candidateIndex]) break;
}
if ((search.candidateIndex == search.candidateCount) &&
(Zi8_814833F0(param, search.character, ZI_WORK) == 0)) {
param->candidates[search.candidateCount++] = search.character;
++param->count;
if (++param->letters < param->maxCandidates) {
goto skip_word;
}
Zi8_814834AC(param, &search.remainingCandidates, &search.candidateCount, &search.inserted, ZI_WORK);
param->count = search.candidateCount;
param->letters = search.candidateCount;
if (search.candidateCount < param->maxCandidates) goto skip_word;
if (options->countOnly != 0) {
if ((search.prefixCount += search.candidateCount) >= (ziS32)options->maxCount) return options->maxCount;
param->count = 0;
param->letters = 0;
search.candidateCount = 0;
} else {
return search.candidateCount;
}
}
}
}
skip_word:
for (; (*wordNode & 0x40) == 0; wordNode = wordNode + 2) {
}
wordNode += 2;
remainingLetters = param->wordCharCount - 1;
wordIndex = 1;
for (; (*wordNode & 0x40) == 0; wordNode = wordNode + 2) {
}
wordNode += 2;
search.remainingLetters = param->wordCharCount - 1;
search.wordIndex = 1;
next_word:
if ((*wordNode & 0x80) != 0) {
goto search_table;
}
goto match_word;
if ((*wordNode & 0x80) != 0) {
goto search_table;
}
goto match_word;
}
search_table:
resultCount = prefixCount;
if (candidateCount != 0) {
Zi8_814834AC(param, &remainingCandidates, &candidateCount, &inserted, ZI_WORK);
if (options->countOnly != 0) {
if ((prefixCount += candidateCount) >= (ziS32)options->maxCount) return options->maxCount;
resultCount = prefixCount;
}
param->count = candidateCount;
param->letters = candidateCount;
}
scan_key_table:
if (param->elementCount > 9) {
param->letters = 0;
return 0;
}
{
if (param->elementCount != 0 && options->countOnly == 0) {
matchPass = 0;
} else {
matchPass = 1;
}
tableCount = Zi8GetTableCount(ZI8_LANG_KO, 9, ZI_WORK);
Zi8_81483118(param, packedKeys);
do {
for (tableIndex = 0; tableIndex < tableCount; tableIndex = tableIndex + 1) {
matches = ZI8_TRUE;
entry = (ZiKoreanKeyEntry*)(((tableIndex << 3) + tableIndex) + keyTable);
keyByte = 0;
if (1 < param->elementCount) {
for (keyByte = 0;
(ziS32)keyByte < (int)param->elementCount / 2;
keyByte++) {
if (packedKeys[keyByte] != entry->keyBytes[keyByte]) {
matches = ZI8_FALSE;
break;
}
}
}
if ((matches && ((param->elementCount % 2) != 0)) &&
((packedKeys[keyByte] & 0xF0) !=
(entry->keyBytes[keyByte] & 0xF0))) {
matches = ZI8_FALSE;
}
if (matches) {
if (param->elementCount % 2 != 0) {
if ((entry->keyBytes[keyByte] & 0xF) != 0) {
if (matchPass == 0) goto next_entry;
} else if (matchPass != 0 && options->countOnly == 0) {
goto next_entry;
}
} else {
if ((entry->keyBytes[keyByte] & 0xF0) != 0) {
if (matchPass == 0) goto next_entry;
} else if (matchPass != 0 && options->countOnly == 0) {
goto next_entry;
}
}
if (remainingCandidates != 0) {
--remainingCandidates;
} else if (options->countOnly != 0) {
if (++resultCount >= (ziS32)options->maxCount) return options->maxCount;
} else {
param->candidates[candidateCount++] =
(ziU16)((ziU16)keyTable[(tableIndex << 3) + tableIndex + offsetof(ZiKoreanKeyEntry, characterHigh)] << 8 |
keyTable[(tableIndex << 3) + tableIndex + offsetof(ZiKoreanKeyEntry, characterLow)]);
if (++param->letters >= param->maxCandidates) return param->letters;
}
}
next_entry:
;
}
} while (++matchPass < 2);
}
if (options->countOnly != 0) return resultCount;
return param->letters;
}
return 0;
search_table:
search.resultCount = search.prefixCount;
if (search.candidateCount != 0) {
Zi8_814834AC(param, &search.remainingCandidates, &search.candidateCount, &search.inserted, ZI_WORK);
if (options->countOnly != 0) {
if ((search.prefixCount += search.candidateCount) >= (ziS32)options->maxCount) return options->maxCount;
search.resultCount = search.prefixCount;
}
param->count = search.candidateCount;
param->letters = search.candidateCount;
}
scan_key_table:
if (param->elementCount > 9) {
param->letters = 0;
return 0;
}
{
if (param->elementCount != 0 && options->countOnly == 0) {
search.matchPass = 0;
} else {
search.matchPass = 1;
}
search.tableCount = Zi8GetTableCount(ZI8_LANG_KO, 9, ZI_WORK);
Zi8_81483118(param, search.packedKeys.bytes);
do {
for (search.tableIndex = 0; search.tableIndex < search.tableCount; search.tableIndex = search.tableIndex + 1) {
search.matches = ZI8_TRUE;
search.entry = (ZiKoreanKeyEntry*)(((search.tableIndex << 3) + search.tableIndex) + keyTable);
search.keyByte = 0;
if (1 < param->elementCount) {
for (search.keyByte = 0;
(ziS32)search.keyByte < (int)param->elementCount / 2;
search.keyByte++) {
if (search.packedKeys.bytes[search.keyByte] != search.entry->keyBytes[search.keyByte]) {
search.matches = ZI8_FALSE;
break;
}
}
}
if ((search.matches && ((param->elementCount % 2) != 0)) &&
((search.packedKeys.bytes[search.keyByte] & 0xF0) !=
(search.entry->keyBytes[search.keyByte] & 0xF0))) {
search.matches = ZI8_FALSE;
}
if (search.matches) {
if (param->elementCount % 2 != 0) {
if ((search.entry->keyBytes[search.keyByte] & 0xF) != 0) {
if (search.matchPass == 0) goto next_entry;
} else if (search.matchPass != 0 && options->countOnly == 0) {
goto next_entry;
}
} else {
if ((search.entry->keyBytes[search.keyByte] & 0xF0) != 0) {
if (search.matchPass == 0) goto next_entry;
} else if (search.matchPass != 0 && options->countOnly == 0) {
goto next_entry;
}
}
if (search.remainingCandidates != 0) {
--search.remainingCandidates;
} else if (options->countOnly != 0) {
if (++search.resultCount >= (ziS32)options->maxCount) return options->maxCount;
} else {
param->candidates[search.candidateCount++] =
(ziU16)((ziU16)((ZiKoreanKeyEntry*)(((search.tableIndex << 3) + search.tableIndex) + keyTable))->characterHigh << 8 |
((ZiKoreanKeyEntry*)(((search.tableIndex << 3) + search.tableIndex) + keyTable))->characterLow);
if (++param->letters >= param->maxCandidates) return param->letters;
}
}
next_entry:
;
}
} while (++search.matchPass < 2);
}
if (options->countOnly != 0) return search.resultCount;
return param->letters;
}
return 0;
}

View File

@@ -62,10 +62,10 @@ ziBool Zi8getKeyLayout(ziU8 language, ziWChar key, ziWChar* chars, ziU8 mode, zi
return 0;
}
keyChars = customTable->lower[key];
for (keyIndex = 0; keyChars[keyIndex] != 0; keyIndex++) {
chars[keyIndex] = keyChars[keyIndex];
for (keyIndex = 0; keyChars[(ziU16)keyIndex] != 0; keyIndex++) {
chars[(ziU16)keyIndex] = keyChars[(ziU16)keyIndex];
}
chars[keyIndex] = 0;
chars[(ziU16)keyIndex] = 0;
return 1;
} else {
if (mode == 1) {
@@ -93,19 +93,19 @@ tables_ready:
}
keyIndex = tableCount = 0;
for (; keyIndex < key; keyIndex++) {
tableCount += dataAddress[keyIndex];
for (; (ziU16)keyIndex < key; keyIndex++) {
tableCount += dataAddress[(ziU16)keyIndex];
}
if ((charCount = (ziU8)dataAddress[key]) == 0) {
return 0;
}
dataAddress = dataAddress + numKeys + (tableCount * 2);
keyIndex = 0;
for (; keyIndex < charCount; keyIndex++) {
chars[keyIndex] = (ziU16)dataAddress[keyIndex * 2] |
((ziU16)dataAddress[(keyIndex * 2) + 1] << 8);
for (; (ziU16)keyIndex < charCount; keyIndex++) {
chars[(ziU16)keyIndex] = (ziU16)dataAddress[(ziU16)keyIndex * 2] |
((ziU16)dataAddress[((ziU16)keyIndex * 2) + 1] << 8);
}
chars[keyIndex] = 0;
chars[(ziU16)keyIndex] = 0;
return 1;
}
}
@@ -121,7 +121,7 @@ ziBool Zi8ChangeCharCase(ziBool upper, ziWChar* character, ziU8 language ZI_NEED
ziU16 result;
ziS32 keyIndex;
ziPtr from;
ziWChar* to;
ziPtr to;
ziS32 characterIndex;
customTables = 0;
@@ -130,9 +130,9 @@ ziBool Zi8ChangeCharCase(ziBool upper, ziWChar* character, ziU8 language ZI_NEED
numKeys = 0x20;
Zi8LogError(0x64, ZI_WORK);
if (ZI_WORK->userKeys[language] != 0) {
customTables = ZI_WORK->userKeys[language];
customTables = (ziUserKeyMap*)ZI_WORK->userKeys[language];
} else if (ZI_WORK->customKeyMap != 0) {
customTables = ZI_WORK->customKeyMap;
customTables = (ziUserKeyMap*)ZI_WORK->customKeyMap;
} else {
tableCount = Zi8GetTableCount(language, 0x1e, ZI_WORK);
if (tableCount != 0) {
@@ -144,18 +144,18 @@ ziBool Zi8ChangeCharCase(ziBool upper, ziWChar* character, ziU8 language ZI_NEED
}
}
if (customTables != 0) {
for (keyIndex = 0; (changed == 0) && (keyIndex < (ziS32)numKeys); keyIndex++) {
for (keyIndex = 0; (changed == 0) && (keyIndex < (ziS32)(ziU32)numKeys); keyIndex++) {
if (upper != 0) {
from = customTables->lower[keyIndex];
to = customTables->upper[keyIndex];
from = (ziPtr)customTables->lower[keyIndex];
to = (ziPtr)customTables->upper[keyIndex];
} else {
from = customTables->upper[keyIndex];
to = customTables->lower[keyIndex];
from = (ziPtr)customTables->upper[keyIndex];
to = (ziPtr)customTables->lower[keyIndex];
}
if ((from != 0) && (to != 0)) {
for (characterIndex = 0; ((ziU16)((ziS16*)from)[characterIndex]) != 0; characterIndex++) {
if ((ziU16)((ziS16*)from)[characterIndex] == *character) {
*character = (ziU16)to[characterIndex];
*character = (ziU16)((ziWChar*)to)[characterIndex];
changed = 1;
break;
}
@@ -165,7 +165,7 @@ ziBool Zi8ChangeCharCase(ziBool upper, ziWChar* character, ziU8 language ZI_NEED
}
else if (dataAddress != 0) {
total = 0;
for (keyIndex = 0; keyIndex < (ziS32)numKeys; keyIndex++) {
for (keyIndex = 0; keyIndex < (ziS32)(ziU32)numKeys; keyIndex++) {
total += dataAddress[keyIndex];
}
dataAddress = dataAddress + numKeys;
@@ -174,7 +174,7 @@ ziBool Zi8ChangeCharCase(ziBool upper, ziWChar* character, ziU8 language ZI_NEED
dataAddress = dataAddress + ((ziU32)total * 2);
direction = -1;
}
for (keyIndex = 0; keyIndex < (ziS32)total; keyIndex++) {
for (keyIndex = 0; keyIndex < (ziS32)(ziU32)total; keyIndex++) {
tableCount = (ziU16)(dataAddress[(keyIndex * 2)] |
((ziU16)dataAddress[(keyIndex * 2) + 1] << 8));
if (tableCount == *character) {

View File

@@ -44,7 +44,7 @@ posEntry:
if (pattern[position] == Zi8ConvertWC2Key(word[position], language, __zi8_work_data)) continue;
break;
} else if (word[position] != pattern[position]) {
if (!ZI_WORK->ignoreCase || language == ZI8_LANG_ZH) break;
if (!ZI_WORK->ignoreCase || language == 1) break;
folded = pattern[position];
if (!Zi8ChangeCharCase(1, &folded, language, __zi8_work_data) || folded != word[position]) break;
}
@@ -64,7 +64,7 @@ posEntry:
while (word[position] != 0) position++;
return position;
matchRetry:
if (index >= ZI_WORK->oemLen) goto oemFailed;
if ((ziS32)index >= ZI_WORK->oemLen) goto oemFailed;
if (!ZI_WORK->oemMatch(index, word, capacity, ZI_WORK->oemData)) goto oemFailed;
goto posEntry;
oemFailed:

View File

@@ -1,7 +1,7 @@
#include <zi8clib/zitypes.h>
ziPtr Zi8Memset(ziPtr destination, ziU32 value, ziS32 count);
ziPtr Zi8Memcpy(ziPtr destination, ziPtr source, ziS32 count);
void Zi8Memset(ziPtr, ziU32, ziU32);
void Zi8Memcpy(ziPtr, ziPtr, ziU32);
ziBool Zi8IsComponent(ziWChar ZI_NEED_WORK);
ziU32 Zi8GetTableAddress(ziU8, ziU8 ZI_NEED_WORK);
ziU16 Zi8GetTableCount(ziU8, ziU8 ZI_NEED_WORK);
@@ -60,14 +60,15 @@ ziBool Zi8PrepareMatch(ziGetParam* request, ziMatchParam* match, ziU8 skipMode Z
}
}
if (elementCount != 0) {
match->comp = element = request->elements[0];
element = request->elements[0];
match->comp = element;
if (Zi8IsComponent(element,__zi8_work_data) != 0) {
elementIndex++;
hasComponent = 1;
buffers.component = (ziU8*)Zi8GetTableAddress(1,2,__zi8_work_data);
buffers.componentIndex = (ziU8*)Zi8GetTableAddress(1,6,__zi8_work_data);
buffers.componentIndex += (element - 0xef10) * 2;
match->componentIndex = (((ziU16)buffers.componentIndex[1] & 0x3f) << 8) + *buffers.componentIndex;
match->componentIndex = ((buffers.componentIndex[1] & 0x3f) << 8) + *buffers.componentIndex;
buffers.component += (ziU32)match->componentIndex * 8;
switch(*buffers.component & 0xf) {
case 0:
@@ -248,10 +249,8 @@ ziBool Zi8PrepareMatch(ziGetParam* request, ziMatchParam* match, ziU8 skipMode Z
else {
initial = 0;
final = 0;
bestInitial = 0;
bestFinal = 0;
previousInitial = 0;
previousFinal = 0;
bestFinal = bestInitial = 0;
previousFinal = previousInitial = 0;
buffers.phoneticInput = request->elements;
match->nCand = 0;
request->completion = request->elementCount;

View File

@@ -38,7 +38,7 @@ typedef struct CXUncompContextLZ {
} CXUncompContextLZ;
typedef union CXHuffmanDecodeTableEntry {
volatile u8 raw;
u8 raw;
struct {
u8 leafR : 1; // 10000000
u8 leafL : 1; // 01000000

View File

@@ -72,7 +72,11 @@ struct DVDCommandBlock {
DVDCommandBlock* prev; // 0x04
u32 command; // 0x08
#ifdef BS2_MACH_VOLATILE_DVD_STATE
volatile s32 state;
#else
s32 state; // 0x0C
#endif
u32 offset; // 0x10
u32 length; // 0x14

View File

@@ -14,7 +14,7 @@ typedef GXTlutRegion* (*GXTlutRegionCallback)(u32 idx);
u32 GXGetTexBufferSize(u16 width, u16 height, u32 format, u8 mipmap, u8 max_lod);
void GXInitTexObj(GXTexObj* obj, void* image_ptr, u16 width, u16 height, GXTexFmt format, GXTexWrapMode wrap_s, GXTexWrapMode wrap_t,
void GXInitTexObj(const 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);

View File

@@ -8,7 +8,7 @@ extern "C" {
#endif
typedef struct OSSemaphore {
volatile s32 count;
s32 count;
OSThreadQueue queue;
} OSSemaphore;

View File

@@ -1,7 +1,7 @@
#include <private/axfx.h>
#include <revolution/axfx.h>
#include <revolution/mem.h>
#include <revolution/os.h>
#include <revolution/AXFX.h>
#include <revolution/MEM.h>
#include <revolution/OS.h>
#include <math.h>
#include <string.h>
@@ -371,9 +371,10 @@ static void __FreeDelayLine(AXFX_REVERBHI_EXP* fx) {
}
}
DECOMP_FORCE_LITERAL(AXFXReverbHiExp_c, -3.0f, 10.0);
static BOOL __InitParams(AXFX_REVERBHI_EXP* reverb) {
u32 ch, i;
f32 attenuation;
if (reverb->earlyMode >= 8)
return FALSE;
@@ -420,8 +421,7 @@ static BOOL __InitParams(AXFX_REVERBHI_EXP* reverb) {
for (i = 0; i < 3; i++) {
reverb->combPos[i] = 0;
reverb->combLength[i] = __FilterSizeTable[reverb->fusedMode][i];
attenuation = -3.0f * (f32)reverb->combLength[i] / (reverb->fusedTime * 32000);
reverb->combCoef[i] = pow(10.0, attenuation);
reverb->combCoef[i] = pow(10.0f, (-3.0f * (f32)(reverb->combLength[i]) / (f32)(reverb->fusedTime * 32000)));
}
for (i = 0; i < 2; i++) {

View File

@@ -1,7 +1,7 @@
#include <private/axfx.h>
#include <revolution/axfx.h>
#include <revolution/mem.h>
#include <revolution/os.h>
#include <revolution/AXFX.h>
#include <revolution/MEM.h>
#include <revolution/OS.h>
#include <revolution/ax.h>
#include <math.h>
@@ -385,9 +385,10 @@ static void __FreeDelayLine(AXFX_REVERBHI_EXP_DPL2* fx) {
}
}
DECOMP_FORCE_LITERAL(AXFXReverbHiExpDpl2_c, -3.0f, 10.0);
static BOOL __InitParams(AXFX_REVERBHI_EXP_DPL2* reverb) {
u32 ch, i;
f32 attenuation;
if (reverb->earlyMode >= 8)
return FALSE;
@@ -434,8 +435,7 @@ static BOOL __InitParams(AXFX_REVERBHI_EXP_DPL2* reverb) {
for (i = 0; i < 3; i++) {
reverb->combPos[i] = 0;
reverb->combLength[i] = __FilterSizeTable[reverb->fusedMode][i];
attenuation = -3.0f * (f32)reverb->combLength[i] / (reverb->fusedTime * 32000);
reverb->combCoef[i] = pow(10.0, attenuation);
reverb->combCoef[i] = pow(10.0f, (-3.0f * (f32)(reverb->combLength[i]) / (f32)(reverb->fusedTime * 32000)));
}
for (i = 0; i < 2; i++) {

View File

@@ -94,9 +94,9 @@ s32 CARDWriteAsync(CARDFileInfo* fileInfo, void* buf, s32 length, s32 offset, CA
if (result < 0)
return __CARDPutControlBlock(card, result);
DCStoreRange(buf, (u32)length);
DCStoreRange((void*)buf, (u32)length);
card->apiCallback = callback ? callback : __CARDDefaultApiCallback;
card->buffer = buf;
card->buffer = (void*)buf;
result = __CARDEraseSector(fileInfo->chan, card->sectorSize * (u32)fileInfo->iBlock, EraseCallback);
if (result < 0) {

View File

@@ -11,27 +11,9 @@
#include <stdio.h>
#include <string.h>
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;
}
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");
typedef struct FSTEntry {
u32 isDirAndStringOff; // 0x00

View File

@@ -31,6 +31,8 @@ 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;
@@ -261,102 +263,254 @@ void _CNTCACHEDeleteTitle() {
}
}
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 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
}
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));
}
}
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
}

View File

@@ -359,7 +359,7 @@ CXStreamingResult CXReadUncompHuffman(CXUncompContextHuffman* context, const voi
while (context->bitsLeft) {
BOOL currBit = context->bits >> 31;
int c = (context->decodeTable->raw << currBit) & 0x80;
int c = (*(vu8*)context->decodeTable << currBit) & 0x80; // ?
context->decodeTable = GetNextNode((CXHuffmanDecodeTableEntry*)context->decodeTable, currBit);
context->bits <<= 1;

View File

@@ -597,10 +597,11 @@ static void cbForStateGettingError(u32 intType) {
if (error == REQUEST_ERROR_053000h) {
StampCommand(COMMAND_STOP_MOTOR, 0, 0);
DVDLowStopMotor(FALSE, FALSE, cbForStateCheckID1);
return;
} else {
stateError(NAND_ERROR_GENERIC);
return;
}
return;
} else {
stateError(NAND_ERROR_GENERIC);
return;
@@ -1707,11 +1708,12 @@ static void cbForStateBusy(u32 intType) {
NumInternalRetry = 0;
stateReady();
return;
} else {
StampCommand(COMMAND_STOP_MOTOR, 0, 0);
DVDLowStopMotor(FALSE, FALSE, cbForStateCheckID1);
return;
}
return;
}
if (CurrCommand == COMMAND_GET_PARTITION_PARAMS) {
@@ -1892,7 +1894,7 @@ s32 DVDGetCommandBlockStatus(const DVDCommandBlock* block) {
enabled = OSDisableInterrupts();
if (block->state == DVD_STATE_COVER_CLOSED) {
if (((volatile DVDCommandBlock*)block)->state == DVD_STATE_COVER_CLOSED) {
retVal = DVD_STATE_BUSY;
} else if (((volatile DVDCommandBlock*)block)->state == DVD_STATE_COVER_OPENED) {
retVal = DVD_STATE_NO_DISK;
@@ -1902,13 +1904,13 @@ s32 DVDGetCommandBlockStatus(const DVDCommandBlock* block) {
if (block == next) {
retVal = DVD_STATE_BUSY;
} else {
retVal = block->state;
retVal = ((volatile DVDCommandBlock*)block)->state;
}
} else {
if (block == &__DVDStopMotorCommandBlock) {
retVal = DVD_STATE_IDLE;
} else {
retVal = block->state;
retVal = ((volatile DVDCommandBlock*)block)->state;
}
}
} else {
@@ -2175,14 +2177,14 @@ s32 DVDCancel(DVDCommandBlock* block) {
enabled = OSDisableInterrupts();
while (TRUE) {
state = block->state;
state = ((volatile DVDCommandBlock*)block)->state;
if (state == DVD_STATE_IDLE || state == DVD_STATE_FATAL || state == DVD_STATE_CANCELED) {
break;
}
if (state == DVD_STATE_COVER_CLOSED) {
command = block->command;
command = ((volatile DVDCommandBlock*)block)->command;
if (command == COMMAND_BSREAD || command == COMMAND_READID || command == COMMAND_AUDIO_BUFFER_CONFIG ||
command == COMMAND_READ_UNENCRYPTED || command == COMMAND_OPEN_PARTITION || command == COMMAND_GET_PARTITION_PARAMS ||

View File

@@ -39,29 +39,6 @@ enum {
DVD_IOCTLV_GET_NO_DISC_BUFFER_SIZE = 0x92,
};
typedef struct DVDVideoPhysical {
u8 data[2048];
} DVDVideoPhysical;
typedef struct DVDVideoDiscKey {
u8 data[2048];
} DVDVideoDiscKey;
typedef struct DVDDiskBca {
u8 optionalInfo[52];
u8 manufacturerCode[2];
u8 recorderDeviceCode[2];
u8 APMRecorderDeviceCode[1];
u8 discManufactureDate[2];
u8 discManufactureTime[2];
u8 discNumber[3];
} DVDDiskBca;
typedef struct DVDLowDriveSer {
u8 data[12];
u8 reserved[20];
} DVDLowDriveSer;
typedef struct DVDLowContext {
DVDLowCallback callback;
int callbackType;
@@ -97,7 +74,7 @@ static u32 statusRegister[8] ALIGN32;
static u32 coverStatus[8] ALIGN32;
static u32 statusRegister[8] ALIGN32;
static DVDLowContext dvdContexts[4] ALIGN32 = {0};
static DVDLowContext dvdContexts[4] ALIGN32;
static DVDLowRegValues diRegValCache ALIGN32;
static u32 registerBuf[8] ALIGN32;
static IOSIoVector ioVec[10] ALIGN32;
@@ -122,6 +99,8 @@ static bool requestInProgress;
#define IS_ALIGNED(addr) (((u32)(addr) & 0x1F) == 0)
DECOMP_FORCE_ACTIVE(dvd_broadway_c, dvdContexts);
IOSError doTransactionCallback(IOSError ret, void* context) {
DVDLowContext* dvdContext = context;
@@ -156,32 +135,7 @@ out:
return 0;
}
static IOSError doCoverCallback(IOSError ret, void* context) {
DVDLowContext* dvdContext;
requestInProgress = false;
dvdContext = (DVDLowContext*)context;
if (dvdContext->contextMagic != 0xfeebdaed) {
OSReport("(doCoverCallback) Error - context mangled!\n");
dvdContext->contextMagic = 0xfeebdaed;
goto out;
}
if (dvdContext->callback != NULL) {
s32 callbackArg;
callbackInProgress = true;
callbackArg = ret;
if (breakRequested == true) {
breakRequested = false;
callbackArg |= 0x00000008;
}
dvdContext->callback((u32)callbackArg);
callbackInProgress = false;
}
out:
dvdContext->inUse = false;
return 0;
}
DECOMP_FORCE_ACTIVE(dvd_broadway_c, "(doCoverCallback) Error - context mangled!\n");
IOSError doPrepareCoverRegisterCallback(IOSError ret, void* context) {
DVDLowContext* dvdContext;
@@ -425,7 +379,7 @@ bool DVDLowOpenPartition(u32 partitionWordOffset, ESTicket* eTicket, u32 numCert
ioVec[1].length = sizeof(ESTicket);
}
ioVec[2].base = certificates;
ioVec[2].base = (u8*)certificates;
if (certificates == 0) {
ioVec[2].length = 0;
} else {
@@ -448,65 +402,14 @@ bool DVDLowOpenPartition(u32 partitionWordOffset, ESTicket* eTicket, u32 numCert
return true;
}
DECOMP_FORCE_ACTIVE(dvd_broadway_c, coverStatus);
DECOMP_FORCE_ACTIVE(dvd_broadway_c, coverRegister);
bool DVDLowOpenPartitionWithTmdAndTicket(const u32 partitionWordOffset, const ESTicket* const eTicket, const u32 numTmdBytes,
const ESTitleMeta* const tmd, const u32 numCertBytes, const u8* const certificates,
DVDLowCallback callback) {
DVDLowContext* dvdContext;
IOSError rv;
if (eTicket != NULL && !(((u32)(eTicket) & 0x1F) == 0)) {
OSReport("(%s) eTicket memory is unaligned\n", __FUNCTION__);
return false;
}
if (certificates != NULL && !(((u32)(certificates) & 0x1F) == 0)) {
return false;
}
if (tmd == NULL) {
OSReport("(%s) tmd parameter cannot be NULL\n", __FUNCTION__);
return false;
} else if (!(((u32)(tmd) & 0x1F) == 0)) {
OSReport("(%s) tmd memory is unaligned\n", __FUNCTION__);
return false;
}
if (eTicket == NULL) {
OSReport("(%s) eTicket parameter cannot be NULL\n", __FUNCTION__);
return false;
} else if (!(((u32)(eTicket) & 0x1F) == 0)) {
OSReport("(%s) eTicket memory is unaligned\n", __FUNCTION__);
return false;
}
requestInProgress = true;
dvdContext = newContext(callback, 1);
nextCommandBuf(&freeCommandBuf);
diCommand[freeCommandBuf].diCmd = 0x93;
diCommand[freeCommandBuf].arg[0] = partitionWordOffset;
ioVec[0].base = (u8*)&(diCommand[freeCommandBuf]);
ioVec[0].length = sizeof(DVDLowCommand);
ioVec[1].base = (u8*)eTicket;
ioVec[1].length = sizeof(ESTicket);
ioVec[2].base = (u8*)tmd;
ioVec[2].length = numTmdBytes;
ioVec[3].base = (u8*)certificates;
if (certificates == NULL) {
ioVec[3].length = 0;
} else {
ioVec[3].length = numCertBytes;
}
ioVec[4].base = (u8*)&(lastTicketError[0]);
ioVec[4].length = sizeof(lastTicketError);
rv = IOS_IoctlvAsync(DiFD, 0x93, 4, 1, ioVec, doTransactionCallback, dvdContext);
if (rv != IPC_RESULT_OK) {
OSReport("@@@ (DVDLowOpenPartition) IOS_IoctlvAsync returned error: %d\n", rv);
dvdContext->inUse = false;
return false;
}
return true;
}
DECOMP_FORCE_ACTIVE(dvd_broadway_c, "DVDLowOpenPartitionWithTmdAndTicket");
DECOMP_FORCE_ACTIVE(dvd_broadway_c, "(%s) eTicket memory is unaligned\n");
DECOMP_FORCE_ACTIVE(dvd_broadway_c, "(%s) tmd parameter cannot be NULL\n");
DECOMP_FORCE_ACTIVE(dvd_broadway_c, "(%s) tmd memory is unaligned\n");
DECOMP_FORCE_ACTIVE(dvd_broadway_c, "(%s) eTicket parameter cannot be NULL\n");
bool DVDLowOpenPartitionWithTmdAndTicketView(u32 partitionWordOffset, ESTicketView* eTicketView, u32 numTmdBytes, ESTitleMeta* tmd, u32 numCertBytes,
u8* certificates, DVDLowCallback callback) {
@@ -550,7 +453,7 @@ bool DVDLowOpenPartitionWithTmdAndTicketView(u32 partitionWordOffset, ESTicketVi
ioVec[2].base = (u8*)tmd;
ioVec[2].length = numTmdBytes;
ioVec[3].base = certificates;
ioVec[3].base = (u8*)certificates;
if (certificates == 0) {
ioVec[3].length = 0;
} else {
@@ -678,49 +581,7 @@ bool DVDLowGetNoDiscOpenPartitionParams(const u32 partitionWordOffset, ESTicket*
return true;
}
bool DVDLowNoDiscOpenPartition(const ESTicket* const eTicket, const u32 numTmdBytes, const ESTitleMeta* const tmd, const u32 numCertBytes,
const u8* const certificates, const u32 dataWordOffset, const u8* const h3HashPtr, DVDLowCallback callback) {
DVDLowContext* dvdContext;
IOSError rv;
if (eTicket == NULL || tmd == NULL || certificates == NULL) {
OSReport("(%s) Error: NULL pointer argument\n", __FUNCTION__);
return false;
}
if (!(((u32)(eTicket) & 0x1F) == 0) || !(((u32)(tmd) & 0x1F) == 0) || !(((u32)(certificates) & 0x1F) == 0) ||
!(((u32)(dataWordOffset) & 0x1F) == 0) || !(((u32)(h3HashPtr) & 0x1F) == 0)) {
OSReport("(%s) pointer argument is unaligned\n", __FUNCTION__);
return false;
}
requestInProgress = true;
dvdContext = newContext(callback, 1);
nextCommandBuf(&freeCommandBuf);
diCommand[freeCommandBuf].diCmd = 0x91;
diCommand[freeCommandBuf].arg[0] = dataWordOffset;
ioVec[0].base = (u8*)&(diCommand[freeCommandBuf]);
ioVec[0].length = sizeof(DVDLowCommand);
ioVec[1].base = (u8*)eTicket;
ioVec[1].length = sizeof(ESTicket);
ioVec[2].base = (u8*)tmd;
ioVec[2].length = numTmdBytes;
ioVec[3].base = (u8*)certificates;
ioVec[3].length = numCertBytes;
ioVec[4].base = (u8*)h3HashPtr;
ioVec[4].length = (96 * 1024);
ioVec[5].base = (u8*)&(lastTicketError[0]);
ioVec[5].length = sizeof(u32);
rv = IOS_IoctlvAsync(DiFD, 0x91, 5, 1, ioVec, doTransactionCallback, dvdContext);
if (rv != IPC_RESULT_OK) {
OSReport("@@@ (%s) IOS_IoctlvAsync returned error: %d\n", __FUNCTION__, rv);
dvdContext->inUse = false;
return false;
}
return true;
}
DECOMP_FORCE_ACTIVE(dvd_broadway_c, "DVDLowNoDiscOpenPartition");
bool DVDLowClosePartition(DVDLowCallback callback) {
DVDLowContext* dvdContext;
@@ -791,49 +652,12 @@ bool DVDLowStopMotor(bool eject, bool saving, DVDLowCallback callback) {
return true;
}
bool DVDLowWaitForCoverClose(DVDLowCallback callback) {
DVDLowContext* dvdContext;
IOSError rv;
requestInProgress = true;
dvdContext = newContext(callback, 2);
nextCommandBuf(&freeCommandBuf);
diCommand[freeCommandBuf].diCmd = 0x79;
rv = IOS_IoctlAsync(DiFD, 0x79, &(diCommand[freeCommandBuf]), sizeof(DVDLowCommand), NULL, 0, doCoverCallback, dvdContext);
if (rv != IPC_RESULT_OK) {
OSReport("@@@ (DVDLowWaitForCoverClose) IOS_IoctlAsync returned error: %d\n", rv);
dvdContext->inUse = false;
return false;
}
return true;
}
static char inquiryErrorMessage[] = "@@@ (DVDLowInquiry) IOS_IoctlAsync returned error: %d\n";
static char requestErrorMessage[] = "@@@ (DVDLowRequestError) IOS_IoctlAsync returned error: %d\n";
bool DVDLowNotifyReset(void) {
IOSError rv;
if (callbackInProgress == true) {
OSReport("(DVDLowSetSpinupFlag): Synch functions can't be called in callbacks\n");
return false;
}
nextCommandBuf(&freeCommandBuf);
diCommand[freeCommandBuf].diCmd = 0x7E;
rv = IOS_Ioctl(DiFD, 0x7E, &(diCommand[freeCommandBuf]), sizeof(DVDLowCommand), NULL, 0);
if (rv != IPC_RESULT_OK) {
OSReport("@@@ (DVDLowNotifyReset) IOS_IoctlAsync returned error: %d\n", rv);
return false;
}
return true;
}
static char resetErrorMessage[] = "@@@ (DVDLowReset) IOS_IoctlAsync returned error: %d\n";
DECOMP_FORCE_ACTIVE(dvd_broadway_c, "@@@ (DVDLowWaitForCoverClose) IOS_IoctlAsync returned error: %d\n");
DECOMP_FORCE_ACTIVE(dvd_broadway_c, "@@@ (DVDLowInquiry) IOS_IoctlAsync returned error: %d\n");
DECOMP_FORCE_ACTIVE(dvd_broadway_c, "@@@ (DVDLowRequestError) IOS_IoctlAsync returned error: %d\n");
DECOMP_FORCE_ACTIVE(dvd_broadway_c, "(DVDLowSetSpinupFlag): Synch functions can't be called in callbacks\n");
DECOMP_FORCE_ACTIVE(dvd_broadway_c, "@@@ (DVDLowNotifyReset) IOS_IoctlAsync returned error: %d\n");
DECOMP_FORCE_ACTIVE(dvd_broadway_c, "@@@ (DVDLowReset) IOS_IoctlAsync returned error: %d\n");
bool DVDLowInquiry(DVDDriveInfo* info, DVDLowCallback callback) {
DVDLowContext* dvdContext;
@@ -849,7 +673,7 @@ bool DVDLowInquiry(DVDDriveInfo* info, DVDLowCallback callback) {
ret = IOS_IoctlAsync(DiFD, DVD_IOCTL_INQUIRY, &diCommand[freeCommandBuf], sizeof(DVDLowCommand), info, sizeof(DVDDriveInfo),
doTransactionCallback, dvdContext);
if (ret != IPC_RESULT_OK) {
OSReport(inquiryErrorMessage, ret);
OSReport("@@@ (DVDLowInquiry) IOS_IoctlAsync returned error: %d\n", ret);
dvdContext->inUse = false;
return false;
}
@@ -871,7 +695,7 @@ bool DVDLowRequestError(DVDLowCallback callback) {
ret = IOS_IoctlAsync(DiFD, DVD_IOCTL_REQUEST_ERROR, &diCommand[freeCommandBuf], sizeof(DVDLowCommand), &diRegValCache, sizeof(DVDLowRegValues),
doTransactionCallback, dvdContext);
if (ret != IPC_RESULT_OK) {
OSReport(requestErrorMessage, ret);
OSReport("@@@ (DVDLowRequestError) IOS_IoctlAsync returned error: %d\n", ret);
dvdContext->inUse = false;
return false;
}
@@ -898,7 +722,7 @@ bool DVDLowReset(DVDLowCallback callback) {
ret = IOS_IoctlAsync(DiFD, DVD_IOCTL_RESET, &diCommand[freeCommandBuf], sizeof(DVDLowCommand), 0, 0, doTransactionCallback, dvdContext);
if (ret != IPC_RESULT_OK) {
OSReport(resetErrorMessage, ret);
OSReport("@@@ (DVDLowReset) IOS_IoctlAsync returned error: %d\n", ret);
dvdContext->inUse = false;
return false;
}
@@ -930,305 +754,20 @@ bool DVDLowAudioBufferConfig(BOOL enable, u32 size, DVDLowCallback callback) {
return true;
}
u32 DVDLowGetCoverStatus(void) {
IOSError rv;
if (callbackInProgress == true) {
OSReport("(DVDLowGetCoverStatus): Synch functions can't be called in callbacks\n");
return false;
}
nextCommandBuf(&freeCommandBuf);
diCommand[freeCommandBuf].diCmd = 0x88;
rv = IOS_Ioctl(DiFD, 0x88, &(diCommand[freeCommandBuf]), sizeof(DVDLowCommand), coverStatus, sizeof(u32) * 8);
if (rv != IPC_RESULT_OK) {
OSReport("@@@ (DVDLowGetCoverStatus) IOS_Ioctl returned error: %d\n", rv);
return 0xdeaddead;
}
return coverStatus[0];
}
bool DVDLowReadDvd(u32 strm, u32 retry, void* destAddr, u32 lengthInSectors, u32 lsn, DVDLowCallback callback) {
DVDLowContext* dvdContext;
IOSError rv;
requestInProgress = true;
dvdContext = newContext(callback, 1);
nextCommandBuf(&freeCommandBuf);
diCommand[freeCommandBuf].diCmd = 0xD0;
if (strm == 0) {
diCommand[freeCommandBuf].arg[0] = 0x0;
} else {
diCommand[freeCommandBuf].arg[0] = 0x1;
}
if (retry == 0) {
diCommand[freeCommandBuf].arg[1] = 0x0;
} else {
diCommand[freeCommandBuf].arg[1] = 0x1;
}
diCommand[freeCommandBuf].arg[2] = lengthInSectors;
diCommand[freeCommandBuf].arg[3] = lsn;
readLength = lengthInSectors * 2048;
rv = IOS_IoctlAsync(DiFD, 0xD0, &(diCommand[freeCommandBuf]), sizeof(DVDLowCommand), destAddr, lengthInSectors * 2048, doTransactionCallback,
dvdContext);
if (rv != IPC_RESULT_OK) {
OSReport("@@@ (DVDLowReadDVD) IOS_IoctlAsync returned error: %d\n", rv);
dvdContext->inUse = false;
return false;
}
return true;
}
bool DVDLowReadDvdConfig(bool set, u32 type, u32 config, DVDLowCallback callback) {
DVDLowContext* dvdContext;
IOSError rv;
requestInProgress = true;
dvdContext = newContext(callback, 1);
nextCommandBuf(&freeCommandBuf);
diCommand[freeCommandBuf].diCmd = 0xD1;
diCommand[freeCommandBuf].arg[0] = set;
diCommand[freeCommandBuf].arg[1] = type;
diCommand[freeCommandBuf].arg[2] = config;
rv = IOS_IoctlAsync(DiFD, 0xD1, &(diCommand[freeCommandBuf]), sizeof(DVDLowCommand), &diRegValCache, sizeof(DVDLowRegValues), doTransactionCallback,
dvdContext);
if (rv != IPC_RESULT_OK) {
OSReport("@@@ (DVDLowReadDVDConfig) IOS_IoctlAsync returned error: %d\n", rv);
dvdContext->inUse = false;
return false;
}
return true;
}
bool DVDLowReadDvdCopyright(u32 layer, DVDLowCallback callback) {
DVDLowContext* dvdContext;
IOSError rv;
requestInProgress = true;
dvdContext = newContext(callback, 1);
nextCommandBuf(&freeCommandBuf);
diCommand[freeCommandBuf].diCmd = 0x81;
diCommand[freeCommandBuf].arg[0] = layer;
rv = IOS_IoctlAsync(DiFD, 0x81, &(diCommand[freeCommandBuf]), sizeof(DVDLowCommand), &diRegValCache, sizeof(DVDLowRegValues), doTransactionCallback,
dvdContext);
if (rv != IPC_RESULT_OK) {
OSReport("@@@ (DVDLowReadDvdCopyright) IOS_IoctlAsync returned error: %d\n", rv);
dvdContext->inUse = false;
return false;
}
return true;
}
bool DVDLowReadDvdPhysical(DVDVideoPhysical* physical, u32 layer, DVDLowCallback callback) {
DVDLowContext* dvdContext;
IOSError rv;
requestInProgress = true;
dvdContext = newContext(callback, 1);
nextCommandBuf(&freeCommandBuf);
diCommand[freeCommandBuf].diCmd = 0x80;
diCommand[freeCommandBuf].arg[0] = layer;
rv = IOS_IoctlAsync(DiFD, 0x80, &(diCommand[freeCommandBuf]), sizeof(DVDLowCommand), physical, sizeof(DVDVideoPhysical), doTransactionCallback,
dvdContext);
if (rv != IPC_RESULT_OK) {
OSReport("@@@ (DVDLowReadDvdPhysical) IOS_IoctlAsync returned error: %d\n", rv);
dvdContext->inUse = false;
return false;
}
return true;
}
bool DVDLowReadDvdDiscKey(DVDVideoDiscKey* diskKey, u32 layer, DVDLowCallback callback) {
DVDLowContext* dvdContext;
IOSError rv;
requestInProgress = true;
dvdContext = newContext(callback, 1);
nextCommandBuf(&freeCommandBuf);
diCommand[freeCommandBuf].diCmd = 0x82;
diCommand[freeCommandBuf].arg[0] = layer;
rv = IOS_IoctlAsync(DiFD, 0x82, &(diCommand[freeCommandBuf]), sizeof(DVDLowCommand), diskKey, sizeof(DVDVideoDiscKey), doTransactionCallback,
dvdContext);
if (rv != IPC_RESULT_OK) {
OSReport("@@@ (DVDLowReadDvdDiscKey) IOS_IoctlAsync returned error: %d\n", rv);
dvdContext->inUse = false;
return false;
}
return true;
}
bool DVDLowReportKey(DVDVideoReportKey* reportKey, u32 format, u32 lsn, DVDLowCallback callback) {
DVDLowContext* dvdContext;
IOSError rv;
requestInProgress = true;
dvdContext = newContext(callback, 1);
nextCommandBuf(&freeCommandBuf);
diCommand[freeCommandBuf].diCmd = 0xA4;
diCommand[freeCommandBuf].arg[0] = format >> 16;
diCommand[freeCommandBuf].arg[1] = lsn;
rv = IOS_IoctlAsync(DiFD, 0xA4, &diCommand[freeCommandBuf], sizeof(DVDLowCommand), reportKey, sizeof(DVDVideoReportKey), doTransactionCallback,
dvdContext);
if (rv != IPC_RESULT_OK) {
OSReport("@@@ (DVDLowReportKey) IOS_IoctlAsync returned error: %d\n", rv);
dvdContext->inUse = false;
return false;
}
return true;
}
bool DVDLowOffset(u32 subcmd, u32 offset_4_byte, DVDLowCallback callback) {
DVDLowContext* dvdContext;
IOSError rv;
requestInProgress = true;
dvdContext = newContext(callback, 1);
nextCommandBuf(&freeCommandBuf);
diCommand[freeCommandBuf].diCmd = 0xD9;
if (subcmd == 0) {
diCommand[freeCommandBuf].arg[0] = 0x0;
} else {
diCommand[freeCommandBuf].arg[0] = 0x1;
}
diCommand[freeCommandBuf].arg[1] = offset_4_byte;
rv = IOS_IoctlAsync(DiFD, 0xD9, &(diCommand[freeCommandBuf]), sizeof(DVDLowCommand), &diRegValCache, sizeof(DVDLowRegValues), doTransactionCallback,
dvdContext);
if (rv != IPC_RESULT_OK) {
OSReport("@@@ (DVDLowOffset) IOS_IoctlAsync returned error: %d\n", rv);
dvdContext->inUse = false;
return false;
}
return true;
}
bool DVDLowStopLaser(DVDLowCallback callback) {
DVDLowContext* dvdContext;
IOSError rv;
requestInProgress = true;
dvdContext = newContext(callback, 1);
nextCommandBuf(&freeCommandBuf);
diCommand[freeCommandBuf].diCmd = 0xD2;
rv = IOS_IoctlAsync(DiFD, 0xD2, &(diCommand[freeCommandBuf]), sizeof(DVDLowCommand), &diRegValCache, sizeof(DVDLowRegValues), doTransactionCallback,
dvdContext);
if (rv != IPC_RESULT_OK) {
OSReport("@@@ (DVDLowStopLaser) IOS_IoctlAsync returned error: %d\n", rv);
dvdContext->inUse = false;
return false;
}
return true;
}
bool DVDLowReadDiskBca(DVDDiskBca* diskBca, DVDLowCallback callback) {
DVDLowContext* dvdContext;
IOSError rv;
requestInProgress = true;
dvdContext = newContext(callback, 1);
nextCommandBuf(&freeCommandBuf);
diCommand[freeCommandBuf].diCmd = 0xDA;
rv =
IOS_IoctlAsync(DiFD, 0xDA, &(diCommand[freeCommandBuf]), sizeof(DVDLowCommand), diskBca, sizeof(DVDDiskBca), doTransactionCallback, dvdContext);
if (rv != IPC_RESULT_OK) {
OSReport("@@@ (DVDLowReadDiskBca) IOS_IoctlAsync returned error: %d\n", rv);
dvdContext->inUse = false;
return false;
}
return true;
}
bool DVDLowSerMeasControl(DVDLowDriveSer* ser, bool clear, bool enable, DVDLowCallback callback) {
DVDLowContext* dvdContext;
IOSError rv;
requestInProgress = true;
dvdContext = newContext(callback, 1);
nextCommandBuf(&freeCommandBuf);
diCommand[freeCommandBuf].diCmd = 0xDF;
diCommand[freeCommandBuf].arg[0] = clear;
diCommand[freeCommandBuf].arg[1] = enable;
rv =
IOS_IoctlAsync(DiFD, 0xDF, &(diCommand[freeCommandBuf]), sizeof(DVDLowCommand), ser, sizeof(DVDLowDriveSer), doTransactionCallback, dvdContext);
if (rv != IPC_RESULT_OK) {
OSReport("@@@ (DVDLowSerMeasControl) IOS_IoctlAsync returned error: %d\n", rv);
dvdContext->inUse = false;
return false;
}
return true;
}
bool DVDLowRequestDiscStatus(DVDLowCallback callback) {
DVDLowContext* dvdContext;
IOSError rv;
requestInProgress = true;
dvdContext = newContext(callback, 1);
nextCommandBuf(&freeCommandBuf);
diCommand[freeCommandBuf].diCmd = 0xDB;
rv = IOS_IoctlAsync(DiFD, 0xDB, &(diCommand[freeCommandBuf]), sizeof(DVDLowCommand), &diRegValCache, sizeof(DVDLowRegValues), doTransactionCallback,
dvdContext);
if (rv != IPC_RESULT_OK) {
OSReport("@@@ (DVDLowRequestDiscStatus) IOS_IoctlAsync returned error: %d\n", rv);
dvdContext->inUse = false;
return false;
}
return true;
}
bool DVDLowRequestRetryNumber(DVDLowCallback callback) {
DVDLowContext* dvdContext;
IOSError rv;
requestInProgress = true;
dvdContext = newContext(callback, 1);
nextCommandBuf(&freeCommandBuf);
diCommand[freeCommandBuf].diCmd = 0xDC;
rv = IOS_IoctlAsync(DiFD, 0xDC, &(diCommand[freeCommandBuf]), sizeof(DVDLowCommand), &diRegValCache, sizeof(DVDLowRegValues), doTransactionCallback,
dvdContext);
if (rv != IPC_RESULT_OK) {
OSReport("@@@ (DVDLowRequestRetryNumber) IOS_IoctlAsync returned error: %d\n", rv);
dvdContext->inUse = false;
return false;
}
return true;
}
DECOMP_FORCE_ACTIVE(dvd_broadway_c, "(DVDLowGetCoverStatus): Synch functions can't be called in callbacks\n");
DECOMP_FORCE_ACTIVE(dvd_broadway_c, "@@@ (DVDLowGetCoverStatus) IOS_Ioctl returned error: %d\n");
DECOMP_FORCE_ACTIVE(dvd_broadway_c, "@@@ (DVDLowReadDVD) IOS_IoctlAsync returned error: %d\n");
DECOMP_FORCE_ACTIVE(dvd_broadway_c, "@@@ (DVDLowReadDVDConfig) IOS_IoctlAsync returned error: %d\n");
DECOMP_FORCE_ACTIVE(dvd_broadway_c, "@@@ (DVDLowReadDvdCopyright) IOS_IoctlAsync returned error: %d\n");
DECOMP_FORCE_ACTIVE(dvd_broadway_c, "@@@ (DVDLowReadDvdPhysical) IOS_IoctlAsync returned error: %d\n");
DECOMP_FORCE_ACTIVE(dvd_broadway_c, "@@@ (DVDLowReadDvdDiscKey) IOS_IoctlAsync returned error: %d\n");
DECOMP_FORCE_ACTIVE(dvd_broadway_c, "@@@ (DVDLowReportKey) IOS_IoctlAsync returned error: %d\n");
DECOMP_FORCE_ACTIVE(dvd_broadway_c, "@@@ (DVDLowOffset) IOS_IoctlAsync returned error: %d\n");
DECOMP_FORCE_ACTIVE(dvd_broadway_c, "@@@ (DVDLowStopLaser) IOS_IoctlAsync returned error: %d\n");
DECOMP_FORCE_ACTIVE(dvd_broadway_c, "@@@ (DVDLowReadDiskBca) IOS_IoctlAsync returned error: %d\n");
DECOMP_FORCE_ACTIVE(dvd_broadway_c, "@@@ (DVDLowSerMeasControl) IOS_IoctlAsync returned error: %d\n");
DECOMP_FORCE_ACTIVE(dvd_broadway_c, "@@@ (DVDLowRequestDiscStatus) IOS_IoctlAsync returned error: %d\n");
DECOMP_FORCE_ACTIVE(dvd_broadway_c, "@@@ (DVDLowRequestRetryNumber) IOS_IoctlAsync returned error: %d\n");
bool DVDLowSetMaximumRotation(u32 subcmd, DVDLowCallback callback) {
DVDLowContext* dvdContext;
@@ -1305,26 +844,8 @@ bool DVDLowSeek(u32 wordOffset, DVDLowCallback callback) {
return true;
}
u32 DVDLowGetCoverReg(void) {
IOSError rv;
if (callbackInProgress == true) {
OSReport("(DVDLowGetCoverReg): Synch functions can't be called in callbacks\n");
return false;
}
nextCommandBuf(&freeCommandBuf);
diCommand[freeCommandBuf].diCmd = 0x7A;
rv = IOS_Ioctl(DiFD, 0x7A, &(diCommand[freeCommandBuf]), sizeof(DVDLowCommand), coverRegister, sizeof(u32) * 8);
if (rv != IPC_RESULT_OK) {
OSReport("@@@ (DVDLowGetCoverReg) IOS_Ioctl returned error: %d\n", rv);
return false;
}
return coverRegister[0];
}
DECOMP_FORCE_ACTIVE(dvd_broadway_c, "(DVDLowGetCoverReg): Synch functions can't be called in callbacks\n");
DECOMP_FORCE_ACTIVE(dvd_broadway_c, "@@@ (DVDLowGetCoverReg) IOS_Ioctl returned error: %d\n");
u32 DVDLowGetCoverRegister() {
return diRegValCache.diCoverReg;
@@ -1420,23 +941,4 @@ BOOL __DVDLowTestAlarm(OSAlarm* alarm) {
return FALSE;
}
bool DVDLowEnableDvdVideo(const bool enable, DVDLowCallback callback) {
DVDLowContext* dvdContext;
IOSError rv;
nextCommandBuf(&freeCommandBuf);
diCommand[freeCommandBuf].diCmd = 0x8E;
diCommand[freeCommandBuf].arg[0] = enable;
requestInProgress = true;
dvdContext = newContext(callback, 1);
rv = IOS_IoctlAsync(DiFD, 0x8E, &(diCommand[freeCommandBuf]), sizeof(DVDLowCommand), NULL, 0, doTransactionCallback, dvdContext);
if (rv != IPC_RESULT_OK) {
OSReport("@@@ (DVDLowEnableDvdVideo) IOS_IoctlAsync returned error: %d\n", rv);
dvdContext->inUse = false;
return false;
}
return true;
}
DECOMP_FORCE_ACTIVE(dvd_broadway_c, "@@@ (DVDLowEnableDvdVideo) IOS_IoctlAsync returned error: %d\n"); // DVD video...

View File

@@ -326,7 +326,7 @@ s32 DVDReadPrio(DVDFileInfo* fileInfo, void* addr, s32 length, s32 offset, s32 p
enabled = OSDisableInterrupts();
while (TRUE) {
state = block->state;
state = ((DVDCommandBlock*)block)->state;
if (state == DVD_STATE_IDLE) {
retVal = block->transferredSize;

View File

@@ -1270,17 +1270,17 @@ ESError ES_Encrypt(u32 keyNum, u8* iv, u8* input, u32 size, u8* output) {
vec[0].length = sizeof(*pKeyNum);
// IV read
vec[1].base = iv;
vec[1].base = (u8*)iv;
vec[1].length = 16;
vec[2].base = input;
vec[2].base = (u8*)input;
vec[2].length = size;
// IV write
vec[3].base = iv;
vec[3].base = (u8*)iv;
vec[3].length = 16;
vec[4].base = output;
vec[4].base = (u8*)output;
vec[4].length = size;
ret = IOS_Ioctlv(__esFd, ES_IOCTLV_ENCRYPT, 3, 2, vec);
@@ -1306,17 +1306,17 @@ ESError ES_Decrypt(u32 keyNum, u8* iv, u8* input, u32 size, u8* output) {
vec[0].length = sizeof(*pKeyNum);
// IV read
vec[1].base = iv;
vec[1].base = (u8*)iv;
vec[1].length = 16;
vec[2].base = input;
vec[2].base = (u8*)input;
vec[2].length = size;
// IV write
vec[3].base = iv;
vec[3].base = (u8*)iv;
vec[3].length = 16;
vec[4].base = output;
vec[4].base = (u8*)output;
vec[4].length = size;
ret = IOS_Ioctlv(__esFd, ES_IOCTLV_DECRYPT, 3, 2, vec);

View File

@@ -29,13 +29,13 @@ typedef struct PFD_SDDRV_FORMAT_DATA {
u32 total_sectors;
} PFD_SDDRV_FORMAT_DATA;
volatile PFD_SDDRV_INFO g_pfd_sddrv_info;
PFD_SDDEV_STORAGE g_pfd_sddev ATTRIBUTE_ALIGN(32);
PFD_SDDRV_INFO g_pfd_sddrv_info;
PFD_SDDEV_STORAGE g_pfd_sddev;
u8 g_pfd_sddrv_buf[0x200];
static FAInsertCallback g_attach_func = 0;
static FAEjectCallback g_detach_func = 0;
u32 g_event ATTRIBUTE_ALIGN(32);
u32 g_event;
extern u8 pfd_get_media_drv_char(FADisk*, s8*, u32);
extern void pdm_disk_notify_media_insert(FADisk*);
@@ -243,23 +243,39 @@ 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 (g_pfd_sddrv_info.device != 0) {
if (pfd_sddrv_device(&g_pfd_sddrv_info) != 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 (g_pfd_sddrv_info.disk != 0) {
if (pfd_sddrv_disk(&g_pfd_sddrv_info) != 0) {
update_media_drive();
pdm_disk_notify_media_insert(g_pfd_sddrv_info.disk);
if (g_pfd_sddrv_info.drive != 0 && g_attach_func != 0) {
if (pfd_sddrv_drive(&g_pfd_sddrv_info) != 0 && g_attach_func != 0) {
g_attach_func(g_pfd_sddrv_info.drive);
}
}
@@ -275,39 +291,36 @@ s32 pfd_st_removal_callback(s32 status, void* data) {
return 0;
}
g_pfd_sddrv_info.media_inserted = 0;
if (g_pfd_sddrv_info.device != 0) {
if (g_pfd_sddrv_info.media_inserted == 0 && pfd_sddrv_device(&g_pfd_sddrv_info) != 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 (g_pfd_sddrv_info.disk != 0) {
if (pfd_sddrv_disk(&g_pfd_sddrv_info) != 0) {
update_media_drive();
pdm_disk_notify_media_eject(g_pfd_sddrv_info.disk);
if (g_pfd_sddrv_info.drive != 0 && g_detach_func != 0) {
if (pfd_sddrv_drive(&g_pfd_sddrv_info) != 0 && g_detach_func != 0) {
g_detach_func(g_pfd_sddrv_info.drive);
}
}
return 0;
}
#pragma push
#pragma ppc_iro_level 0
s32 pfd_sddrv_init(FADisk* disk) {
s32 sd_result;
SDDev* device;
u32 status;
if (disk == NULL) {
if (disk == 0) {
return -30;
}
if ((g_pfd_sddrv_info.flags & 1) != 0) {
if ((pfd_sddrv_flags(&g_pfd_sddrv_info) & 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;
@@ -359,7 +372,6 @@ s32 pfd_sddrv_init(FADisk* disk) {
}
return 0;
}
#pragma pop
s32 pfd_sddrv_mount(FADisk* disk) {
s32 result;
@@ -461,7 +473,7 @@ s32 pfd_sddrv_unmount(FADisk* disk) {
if (disk == 0) {
return -30;
}
if ((g_pfd_sddrv_info.flags & 2) != 0) {
if ((pfd_sddrv_flags(&g_pfd_sddrv_info) & 2) != 0) {
clear_mount_flag();
}
return 0;
@@ -473,7 +485,7 @@ s32 pfd_sddrv_finalize(FADisk* disk) {
if (disk == 0) {
return -30;
}
if ((g_pfd_sddrv_info.flags & 2) != 0) {
if ((pfd_sddrv_flags(&g_pfd_sddrv_info) & 2) != 0) {
clear_mount_flag();
}
if ((g_pfd_sddrv_info.flags & 1) != 0) {
@@ -1359,24 +1371,22 @@ 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;
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;
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;
}
return 0;
return result;
}
static inline s32 pfd_sddrv_write_sector(u32 sector) {
return ISD_WriteBlock(g_pfd_sddrv_info.device, sector, g_pfd_sddrv_buf, 1);
}
#pragma push
#pragma ppc_iro_level 0
s32 pfd_sddrv_build_fat32_mbr_bpb(u32 total_sectors) {
PFD_SDDRV_FORMAT_DATA format_data;
s32 result;
@@ -1398,12 +1408,12 @@ s32 pfd_sddrv_build_fat32_mbr_bpb(u32 total_sectors) {
if (g_pfd_sddrv_info.media_ejected != 0) {
return -33;
}
result = pfd_sddrv_write_sector(format_data.partition_start_sector);
result = ISD_WriteBlock(g_pfd_sddrv_info.device, format_data.partition_start_sector, g_pfd_sddrv_buf, 1);
if (result != 0) {
OSReport("ERR Failed to write BPB fields. ISD_WriteBlock()\n");
return -36;
}
result = pfd_sddrv_write_sector(format_data.partition_start_sector + 6);
result = ISD_WriteBlock(g_pfd_sddrv_info.device, format_data.partition_start_sector + 6, g_pfd_sddrv_buf, 1);
if (result != 0) {
OSReport("ERR Failed to write BPB fields. ISD_WriteBlock()\n");
return -36;
@@ -1419,12 +1429,12 @@ s32 pfd_sddrv_build_fat32_mbr_bpb(u32 total_sectors) {
if (g_pfd_sddrv_info.media_ejected != 0) {
return -33;
}
result = pfd_sddrv_write_sector(format_data.partition_start_sector + 1);
result = ISD_WriteBlock(g_pfd_sddrv_info.device, format_data.partition_start_sector + 1, g_pfd_sddrv_buf, 1);
if (result != 0) {
OSReport("ERR Failed to write BPB fields. ISD_WriteBlock()\n");
return -36;
}
result = pfd_sddrv_write_sector(format_data.partition_start_sector + 7);
result = ISD_WriteBlock(g_pfd_sddrv_info.device, format_data.partition_start_sector + 7, g_pfd_sddrv_buf, 1);
if (result != 0) {
OSReport("ERR Failed to write BPB fields. ISD_WriteBlock()\n");
return -36;
@@ -1441,12 +1451,12 @@ s32 pfd_sddrv_build_fat32_mbr_bpb(u32 total_sectors) {
if (g_pfd_sddrv_info.media_ejected != 0) {
return -33;
}
result = pfd_sddrv_write_sector(format_data.partition_start_sector + 2);
result = ISD_WriteBlock(g_pfd_sddrv_info.device, format_data.partition_start_sector + 2, g_pfd_sddrv_buf, 1);
if (result != 0) {
OSReport("ERR Failed to write BPB fields. ISD_WriteBlock()\n");
return -36;
}
result = pfd_sddrv_write_sector(format_data.partition_start_sector + 8);
result = ISD_WriteBlock(g_pfd_sddrv_info.device, format_data.partition_start_sector + 8, g_pfd_sddrv_buf, 1);
if (result != 0) {
OSReport("ERR Failed to write BPB fields. ISD_WriteBlock()\n");
return -36;
@@ -1462,14 +1472,13 @@ s32 pfd_sddrv_build_fat32_mbr_bpb(u32 total_sectors) {
if (g_pfd_sddrv_info.media_ejected != 0) {
return -33;
}
result = pfd_sddrv_write_sector(0);
result = ISD_WriteBlock(g_pfd_sddrv_info.device, 0, g_pfd_sddrv_buf, 1);
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;

View File

@@ -8,7 +8,12 @@ static inline pf_u16 read_boot_u16(pf_u8* buf, pf_u32 offset) {
return PF_SWAP_16(*(pf_u16*)&buf[(offset + 1) & ~1]);
}
pf_s32 pdm_part_is_master_boot_sector(volatile pf_u8* buf, pf_u32 total, pf_bool* p_is_mbr) {
static inline pf_u32 read_partition_u32(const pf_u8* buf, pf_u32 offset) {
return (((pf_u32)buf[offset + 2] << 16) + buf[offset]) +
(((pf_u32)buf[offset + 3] << 24) + ((pf_u32)buf[offset + 1] << 8));
}
pf_s32 pdm_part_is_master_boot_sector(pf_u8* buf, pf_u32 total, pf_bool* p_is_mbr) {
pf_u32* p_start;
pf_u32* p_count;
pf_s16 index;
@@ -20,8 +25,8 @@ pf_s32 pdm_part_is_master_boot_sector(volatile pf_u8* buf, pf_u32 total, pf_bool
p_count = count;
for (index = 0; index < 4; index++) {
*p_start = 0;
*p_start = MBR_WORD(buf, 454);
*p_count = MBR_WORD(buf, 458);
*p_start = read_partition_u32(buf, 454);
*p_count = read_partition_u32(buf, 458);
if (*p_start != 0 && *p_count != 0) {
if (index == 0) { *p_is_mbr = 1; }
} else {
@@ -31,11 +36,15 @@ pf_s32 pdm_part_is_master_boot_sector(volatile pf_u8* buf, pf_u32 total, pf_bool
p_count++;
buf += 16;
}
p_start = start;
p_count = count;
for (index = 0; index < 4; index++) {
if (start[index] + count[index] > total) {
if (*p_start + *p_count > total) {
if (index == 0) { *p_is_mbr = 0; }
return 2;
}
p_start++;
p_count++;
}
return 0;
}

View File

@@ -173,77 +173,72 @@ pf_s32 PFFAT12_WriteFATEntryWithBuf(PF_VOLUME* p_vol, pf_s16 cluster, pf_u16 val
#undef FLUSH_FAT_BUFFER
}
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 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;
pf_s32 result;
#define LOAD_FAT_SECTOR(next_sector) \
if (p_page->sector != sector + (next_sector)) { \
if (p_page->sector != state.sector + (next_sector)) { \
if (p_page->option == 1) { \
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); \
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); \
} \
} \
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.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); \
}
sector = p_vol->bpb.active_FAT_sector + (offset >> p_vol->bpb.log2_bytes_per_sector) & 0xFFFF;
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;
if ((p_vol->bpb.ext_flags & 0x80) != 0) {
current_fat = p_vol->bpb.ext_flags & (0x01 | 0x02 | 0x04);
state.current_fat = p_vol->bpb.ext_flags & (0x01 | 0x02 | 0x04);
} else {
current_fat = 1;
state.current_fat = 1;
}
err = 0;
state.err = 0;
while (PF_TRUE) {
if (err == 0x1000 && p_vol->p_callback != PF_NULL) {
if (state.err == 0x1000 && p_vol->p_callback != PF_NULL) {
result = ((PF_VOLUME_CB)p_vol->p_callback)(p_vol->last_driver_error);
if (result == 0) {
err = 0;
state.err = 0;
continue;
}
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;
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;
continue;
}
} else {
LOAD_FAT_SECTOR(0);
offset &= p_vol->bpb.bytes_per_sector - 1;
if (offset == (p_vol->bpb.bytes_per_sector - 1)) {
*p_value = p_page->p_buf[offset];
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];
if (p_page->option == 1) {
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);
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);
}
}
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;
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;
*p_value += (pf_u16)(*p_page->p_buf) << 8;
} else {
*p_value = ((pf_u16)p_page->p_buf[offset + 1] << 8) + p_page->p_buf[offset];
*p_value = ((pf_u16)p_page->p_buf[state.offset + 1] << 8) + p_page->p_buf[state.offset];
}
}
break;
}
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) {
if (state.err != 0) {
*p_value = -1;
return err;
return state.err;
}
if ((cluster & 0x01) != 0) {
*p_value = *p_value >> 4;
@@ -251,4 +246,6 @@ pf_s32 PFFAT12_ReadFATEntryWithBuf(PF_VOLUME* p_vol, pf_u16 cluster, pf_u32* p_v
*p_value &= 0xFFF;
}
return 0;
#undef LOAD_FAT_SECTOR
}

View File

@@ -1873,7 +1873,10 @@ 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;
PFFILE_FAT_HINT saved_hint;
struct {
PF_FAT_HINT hint;
pf_u32 last_access_chain_index;
} saved_hint;
pf_u16 access_time;
pf_s32 error;
@@ -1891,7 +1894,8 @@ pf_s32 PFFILE_fadjust(PFFILE_FILE* file) {
}
((PFFILE_VOLUME_DIRS*)volume)->cache_signature = file;
saved_cursor = file->cursor;
saved_hint = *(PFFILE_FAT_HINT*)&file->hint;
saved_hint.hint = file->hint;
saved_hint.last_access_chain_index = file->last_access_data.last_access.chain_index;
if ((file->open_mode & 8) == 0 && (file->open_mode & 2) != 0) {
error = 0x0A;
} else if ((file->p_sfd->lock.mode & 3) != 0 &&
@@ -1903,7 +1907,8 @@ pf_s32 PFFILE_fadjust(PFFILE_FILE* file) {
error &= (-error | error) >> 31;
}
file->cursor = saved_cursor;
*(PFFILE_FAT_HINT*)&file->hint = saved_hint;
file->hint = saved_hint.hint;
file->last_access_data.last_access.chain_index = saved_hint.last_access_chain_index;
((PFFILE_VOLUME_DIRS*)volume)->cache_signature = PF_NULL;
if (error != 0) {
pf_vol_set.last_error = error;
@@ -1918,7 +1923,10 @@ 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;
PFFILE_FAT_HINT saved_hint;
struct {
PF_FAT_HINT hint;
pf_u32 last_access_chain_index;
} saved_hint;
pf_s32 error;
error = PFVOL_CheckForRead(volume);
@@ -1935,10 +1943,12 @@ pf_s32 PFFILE_finfo(PFFILE_FILE* file, PF_INFO* info) {
}
((PFFILE_VOLUME_DIRS*)volume)->cache_signature = file;
saved_cursor = file->cursor;
saved_hint = *(PFFILE_FAT_HINT*)&file->hint;
saved_hint.hint = file->hint;
saved_hint.last_access_chain_index = file->last_access_data.last_access.chain_index;
error = PFFILE_p_finfo(file, info);
file->cursor = saved_cursor;
*(PFFILE_FAT_HINT*)&file->hint = saved_hint;
file->hint = saved_hint.hint;
file->last_access_data.last_access.chain_index = saved_hint.last_access_chain_index;
((PFFILE_VOLUME_DIRS*)volume)->cache_signature = PF_NULL;
if (error != 0) {
pf_vol_set.last_error = error;

View File

@@ -418,13 +418,15 @@ 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) {
pf_s8 name_buffer[13];
pf_u32 matched_end;
pf_s8* name = name_buffer;
struct {
pf_u32 matched_end;
pf_s8 name[0x10];
} work;
pf_s8* name = work.name;
pf_s8* name_end;
const pf_s8* pattern_text;
matched_end = 0;
work.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 &&
@@ -448,7 +450,7 @@ pf_s32 PFPATH_cmpName(const pf_s8* short_name, PF_STR* pattern, pf_u32 short_sea
return 1;
}
}
return PFPATH_cmpNameImpl(name_buffer, pattern_text, &matched_end);
return PFPATH_cmpNameImpl(work.name, pattern_text, &work.matched_end);
}
pf_s32 PFPATH_cmpTailSFN(const pf_s8* sfn_name, const pf_s8* pattern) {

View File

@@ -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(GXTexObj* obj, void* image_ptr, u16 width, u16 height, GXTexFmt format, GXTexWrapMode wrap_s, GXTexWrapMode wrap_t,
void GXInitTexObj(const GXTexObj* obj, void* image_ptr, u16 width, u16 height, GXTexFmt format, GXTexWrapMode wrap_s, GXTexWrapMode wrap_t,
GXBool mipmap) {
u32 imageBase;
u32 maxLOD;

View File

@@ -7,12 +7,14 @@
static u32 IpcNumPendingReqs = 0;
static u32 IpcNumUnIssuedReqs = 0;
static s32 IpcFdArray[MAX_REQUEST] = {0};
static s32 IpcFdArray[MAX_REQUEST];
static u32 IpcReqPtrArray[MAX_REQUEST];
static void AddReqInfo(void* ptr, s32 fd);
static void DelReqInfo(void* ptr, s32 fd);
DECOMP_FORCE_ACTIVE(ipcProfile_c, IpcFdArray); // Force `IpcFdArray` to be first
void IPCiProfInit() {
u32 i;

View File

@@ -396,8 +396,6 @@ static void kbdProcKey(u32 key, u32 pressed, u32 channel) {
kbdSendKey(&event);
}
#pragma push
#pragma opt_propagation off
static void kbdProcMod(u32 key, u32 pressed, u32 channel) {
KBDChannel* data;
u32 modState;
@@ -526,7 +524,6 @@ static void kbdProcMod(u32 key, u32 pressed, u32 channel) {
finalState = modState | 0x1000;
KBDSetModState(channel, finalState);
}
#pragma pop
static void kbdSendKey(KBDKeyEventData* event) {
KBDChannel* data;
@@ -557,24 +554,26 @@ static void kbdSendKey(KBDKeyEventData* event) {
}
}
#pragma push
#pragma ppc_iro_level 0
static void kbd_led_handler(BOOL success, void* callbackArg) {
u32 index;
USBKBDErr err;
index = (u32)callbackArg;
const KBDLEDCallbackData* callback;
s32 index;
u32 err;
index = (s32)callbackArg;
callback = &kbdLCBuf[index];
kbdCmdBuf[index].device = 0;
if (kbdLCBuf[index].callbackAddress == NULL) {
if (callback->callbackAddress == (USBKBDCmdLEDCallback)(u32)kbdCmdBuf[(u32)callbackArg].device) {
return;
}
if (success == TRUE) {
err = 0;
} else {
switch (success) {
default:
err = 7;
break;
case TRUE:
err = 0;
break;
}
kbdLCBuf[index].callbackAddress(err, kbdLCBuf[index].callbackArg);
kbdLCBuf[(u32)callbackArg].callbackAddress(err, kbdLCBuf[(u32)callbackArg].callbackArg);
}
#pragma pop
USBKBDErr KBDSetLedsAsync(u32 channel, u32 leds, USBKBDCmdLEDCallback callback, void* callbackArg) {
u8 ledBits;
@@ -824,8 +823,6 @@ USBKBDErr KBDSetLockProcessing(u32 channel, u32 value) {
return 0;
}
#pragma push
#pragma ppc_iro_level 1
USBKBDErr KBDSetModState(u32 channel, u32 value) {
if (!kbdInitialized) {
return 2;
@@ -842,13 +839,12 @@ USBKBDErr KBDSetModState(u32 channel, u32 value) {
interrupts = OSDisableInterrupts();
newState.value = value & 0xfc0;
oldState.value = kbdData[channel].modState;
newState.bits.physical = oldState.value;
newState.bits.physical = oldState.bits.physical;
kbdData[channel].modState = newState.value;
OSRestoreInterrupts(interrupts);
}
return 0;
}
#pragma pop
u16 KBDTranslateHidCode(u32 keyCode, u32 modifiers, s32 country) {
s32 mask;

View File

@@ -55,11 +55,12 @@ void nandRemoveTailToken(char* newPath, const char* oldPath) {
if (i != 0) {
strncpy(newPath, oldPath, i);
newPath[i] = '\0';
break;
} else {
newPath[0] = '/';
newPath[1] = '\0';
break;
}
break;
}
}
}

View File

@@ -175,8 +175,7 @@ static inline char* __nupFindTag(char* response, const char* startTag, const cha
}
*value = start + strlen(startTag);
*length = end - *value;
end += strlen(endTag);
return end;
return end + strlen(endTag);
}
static s32 __nupParseServerInfo(NUPContextInfo* context, char* response, char* messageId,

View File

@@ -518,7 +518,7 @@ void OSInit() {
void* bi2StartAddr;
void* arenaAddr;
OSExecParams* params = &__OSRebootParams;
volatile OSExecParams* params = (volatile OSExecParams*)&__OSRebootParams;
if (AreWeInitialized == FALSE) {
BOOL enabled;

View File

@@ -19,222 +19,14 @@
/* 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(): 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) {
@@ -592,13 +384,13 @@ void LaunchCommon(ESTitleId titleId, u32 launchArg, const char** argv, BOOL laun
} else {
ret = ESP_InitLib();
if (ret != ES_ERR_OK) {
OSReport(execFailure, ret, 1712);
OSReport("\nOSExec(): Failed to exec %d in %d\n", ret, 1712);
__OSHotResetForError();
}
ret = ESP_GetTitleId(&title);
if (ret != ES_ERR_OK) {
OSReport(execFailure, ret, 1720);
OSReport("\nOSExec(): Failed to exec %d in %d\n", ret, 1720);
__OSHotResetForError();
}
}
@@ -701,95 +493,11 @@ void __OSReturnToMenul(u32 launchArg, const char* arg0, ...) {
__OSReturnToMenuForError();
}
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);
}
/* 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");

View File

@@ -1,23 +1,9 @@
#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;
@@ -52,157 +38,11 @@ s32 __OSSyncTimeWithNetRM() {
return NWC24iSynchronizeRtcCounter(FALSE);
}
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;
}
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");

View File

@@ -10,6 +10,8 @@ static NANDFileInfo FileInfo;
static NANDCommandBlock Block;
static OSAlarm PlayRecordAlarm;
DECOMP_FORCE_ACTIVE(OSPlayRecord_c, PlayRecord);
static BOOL PlayRecordGet = FALSE;
static s32 PlayRecordState = OS_RECORD_STATE_STOPPED;
static BOOL PlayRecordError = FALSE;

View File

@@ -63,39 +63,11 @@ vBOOL __OSIsReturnToIdle;
}
// They're used but pooled first.
static char resetSource[] = "OSReset.c";
static char hotResetFailure[] = "__OSHotReset(): Falied to reset system.\n";
DECOMP_FORCE_ACTIVE(OSReset_c, "OSReset.c");
DECOMP_FORCE_ACTIVE(OSReset_c, "__OSHotReset(): Falied to reset system.\n");
void __OSReturnToMenu(u8 menuMode) {
OSStateFlags state;
__OSStopPlayRecord();
__OSUnRegisterStateEvent();
__DVDPrepareReset();
__OSReadStateFlags(&state);
state.discState = __OSGetDiscState(state.discState);
state.shutdownType = OS_STATE_FLAGS_SHUTDOWN_RETURN_MENU;
state.menuMode = menuMode;
__OSClearRTCFlags();
__OSWriteStateFlags(&state);
OSDisableScheduler();
__OSShutdownDevices(OS_SHUTDOWN_RETURN_MENU);
OSEnableScheduler();
__OSLaunchMenu();
OSDisableScheduler();
__VISetRGBModeImm();
__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");
}
DECOMP_FORCE_ACTIVE(OSReset_c, "OSReturnToMenu(): Falied to boot system menu.\n");
DECOMP_FORCE_ACTIVE(OSReset_c, "OSReturnToDataManager(): Falied to boot system menu.\n");
enum {
LAUNCH_ARG_MENU = 0,
@@ -240,7 +212,7 @@ void OSReturnToSetting(u8 setting) {
}
default: {
OSReport("OSReturnToSetting(): You can't specify %d. \n", setting);
OSPanic(resetSource, 910, "");
OSHalt("", 910);
}
}
@@ -262,7 +234,7 @@ void __OSReturnToMenuForError() {
__VISetRGBModeImm();
__OSHotResetForError();
OSPanic(resetSource, 949, "__OSReturnToMenu(): Falied to boot system menu.\n");
OSHalt("__OSReturnToMenu(): Falied to boot system menu.\n", 949);
}
void __OSHotResetForError() {
@@ -270,7 +242,7 @@ void __OSHotResetForError() {
__OSInitSTM();
}
__OSHotReset();
OSPanic(resetSource, 973, hotResetFailure);
OSHalt("__OSHotReset(): Falied to reset system.\n", 973);
}
u32 OSGetResetCode() {
@@ -283,11 +255,5 @@ u32 OSGetResetCode() {
return code;
}
void OSResetSystem(int reset, u32 resetCode, int forceMenu) {
OSPanic(resetSource, __LINE__, "OSResetSystem() is obsoleted. It doesn't work any longer.\n");
}
u32 OSSetBootDol(u32 dolOffset) {
OSPanic(resetSource, __LINE__, "OSSetBootDol() is obsoleted. It doesn't work any longer.\n");
return 0;
}
DECOMP_FORCE_ACTIVE(OSReset_c, "OSResetSystem() is obsoleted. It doesn't work any longer.\n");
DECOMP_FORCE_ACTIVE(OSReset_c, "OSSetBootDol() is obsoleted. It doesn't work any longer.\n");

View File

@@ -13,7 +13,7 @@ s32 OSWaitSemaphore(OSSemaphore* sem) {
BOOL enabled = OSDisableInterrupts();
s32 count;
while ((count = sem->count) <= 0) {
while ((count = ((volatile OSSemaphore*)sem)->count) <= 0) {
OSSleepThread(&sem->queue);
}
sem->count--;
@@ -28,7 +28,7 @@ s32 OSSignalSemaphore(OSSemaphore* sem) {
s32 count;
count = sem->count;
sem->count = count + 1;
sem->count++;
OSWakeupThread(&sem->queue);

View File

@@ -537,7 +537,7 @@ BOOL OSJoinThread(OSThread* thread, void* val) {
}
}
if (thread->state == OS_THREAD_STATE_DEAD) {
if (((volatile OSThread*)thread)->state == OS_THREAD_STATE_DEAD) {
if (val != NULL) {
*(u32*)val = (u32)thread->value;
}

View File

@@ -741,7 +741,7 @@ static void RSORelocate(RSORel* rel, int index, u32 offset) {
x = offset + rel->addend;
y = ((u32)p & ~0x03FFFFFC) | ((((u32)p & 0x03FFFFFC) + (*p & 0x03FFFFFC)) & 0x03FFFFFC);
#if SDK_VERSION > 20090224 && !defined(SDK_IPL)
if ((x != 0) && (x != y)) {
if (((u32)x != 0) && (x != y)) {
*p = (u32)((*p & ~0x03FFFFFC) | 0x03FF0000 | 0xFFFC);
}
#endif

View File

@@ -314,7 +314,7 @@ static IOSFd sduOpenFD(u32 slot) {
switch (ret) {
case IPC_RESULT_ACCESS:
case IPC_RESULT_EXISTS: {
ASSERTLINE(ret >= 0, 314);
int dummy = 0;
}
}
return ret;

View File

@@ -37,42 +37,13 @@ typedef struct USBMsg {
u16 length; // 0x04
} USBMsg;
typedef struct {
u8 bLength;
u8 bDescriptorType;
u16 bcdUSB;
u8 bDeviceClass;
u8 bDeviceSubClass;
u8 bDeviceProtocol;
u8 bMaxPacketSize0;
u16 idVendor;
u16 idProduct;
u16 bcdDevice;
u8 iManufacturer;
u8 iProduct;
u8 iSerialNumber;
u8 bNumConfigurations;
} USBDeviceDescriptor;
typedef struct USBDeviceInfo {
IOSFd fd;
u16 vid;
u16 pid;
} USBDeviceInfo;
typedef struct USBIsoTransfer {
void* buf;
u8 numPackets;
u16* packets;
} USBIsoTransfer;
typedef struct USBCommandBlock {
USBCallback callback; // 0x00
USBIsoCallback isoCallback; // 0x04
void* callbackArg; // 0x08
void* isoArg; // 0x0C
void* spare;
char pad_0x10[0x4];
void* clean[USB_NCLEAN_MAX]; // 0x14
u32 nclean; // 0x34
@@ -80,7 +51,6 @@ typedef struct USBCommandBlock {
union {
char path[FS_MAX_PATH];
USBMsg msg;
USBDeviceDescriptor descriptor;
}; // 0x40
} USBCommandBlock;
@@ -243,40 +213,16 @@ end:
return result;
}
IOSError IUSB_OpenDeviceIdsAsync(const char* interface, u16 vid, u16 pid, USBCallback callback, void* callbackArg) {
IOSError result;
USBCommandBlock* block;
USB_LOG("OpenDevice\n");
block = IOSAlloc(sizeof(USBCommandBlock));
if (block == NULL) {
USB_ERR("OpenDeviceIdsAsync: Not enough memory\n");
return IPC_RESULT_ALLOC_FAILED;
}
memset(block, 0, sizeof(USBCommandBlock));
block->callback = callback;
block->callbackArg = callbackArg;
block->nclean = USB_NCLEAN_CLOSEDEVICE;
snprintf(block->path, sizeof(block->path), "/dev/usb/%s/%x/%x", interface, vid, pid);
USB_LOG("OpenDevice - %s\n", block->path);
result = IOS_OpenAsync(block->path, 0, _intrBlkCtrlIsoCb, block);
USB_LOG("OpenDevice returned: %d\n", result);
if (result < IPC_RESULT_OK) {
IOSFree(block);
}
return result;
}
static char closeDeviceMessage[] = "CloseDevice\n";
static char closeDeviceResult[] = "CloseDevice returned: %d\n";
DECOMP_FORCE_ACTIVE(usb_c, "OpenDevice\n");
DECOMP_FORCE_ACTIVE(usb_c, "OpenDeviceIdsAsync: Not enough memory\n");
DECOMP_FORCE_ACTIVE(usb_c, "CloseDevice\n");
DECOMP_FORCE_ACTIVE(usb_c, "CloseDevice returned: %d\n");
IOSError IUSB_CloseDeviceAsync(s32 fd, USBCallback callback, void* callbackArg) {
IOSError result;
USBCommandBlock* block;
USB_LOG(closeDeviceMessage);
USB_LOG("CloseDevice\n");
block = IOSAlloc(sizeof(USBCommandBlock));
if (block == NULL) {
@@ -292,7 +238,7 @@ IOSError IUSB_CloseDeviceAsync(s32 fd, USBCallback callback, void* callbackArg)
block->nclean = USB_NCLEAN_CLOSEDEVICE;
result = IOS_CloseAsync(fd, _intrBlkCtrlIsoCb, block);
USB_LOG(closeDeviceResult, result);
USB_LOG("CloseDevice returned: %d\n", result);
if (result < 0) {
IOSFree(block);
@@ -302,83 +248,8 @@ end:
return result;
}
static IOSFd __openDevice(const char* path) {
IOSFd rv;
char* pathBuf;
USBCommandBlock* ctx = IOSAlloc(OSRoundUp32B(sizeof(USBCommandBlock)));
if (ctx == 0) {
USB_ERR("openDevice: Not enough memory\n");
rv = IPC_RESULT_ALLOC_FAILED;
goto done;
}
pathBuf = ctx->path;
strncpy(pathBuf, path, 64);
rv = IOS_Open(pathBuf, 0);
IOSFree(ctx);
done:
return rv;
}
IOSError IUSB_GetDeviceList(const char* path, USBDeviceInfo* deviceList, u8 maxDev, u8 deviceClass, u8* numDev) {
IOSError rv = IPC_RESULT_OK;
IOSIoVector* vector = NULL;
u8* smaxDev = NULL;
u8* sclass = NULL;
u8* snumDev = NULL;
IOSFd fd;
if ((u32)deviceList & 0x1f) {
rv = IPC_RESULT_INVALID;
goto out;
}
if ((fd = __openDevice(path)) < 0) {
rv = fd;
goto out;
}
vector = IOSAlloc(OSRoundUp32B(sizeof(IOSIoVector)) * 4);
smaxDev = IOSAlloc(OSRoundUp32B(sizeof(u8)));
sclass = IOSAlloc(OSRoundUp32B(sizeof(u8)));
snumDev = IOSAlloc(OSRoundUp32B(sizeof(u8)));
if (NULL == smaxDev || NULL == sclass || NULL == snumDev || NULL == vector) {
USB_ERR("getDeviceList: Not enough memory\n");
rv = IPC_RESULT_ALLOC_FAILED;
goto out;
}
*smaxDev = maxDev;
*sclass = deviceClass;
*snumDev = 0;
vector[0].base = smaxDev;
vector[0].length = sizeof(u8);
vector[1].base = sclass;
vector[1].length = sizeof(u8);
vector[2].base = (u8*)snumDev;
vector[2].length = sizeof(u8);
vector[3].base = (u8*)deviceList;
vector[3].length = sizeof(USBDeviceInfo) * maxDev;
DCInvalidateRange(deviceList, sizeof(USBDeviceInfo) * maxDev);
DCInvalidateRange(snumDev, OSRoundUp32B(sizeof(u8)));
DCFlushRange(sclass, OSRoundUp32B(sizeof(u8)));
DCFlushRange(smaxDev, OSRoundUp32B(sizeof(u8)));
DCFlushRange(vector, OSRoundUp32B(sizeof(IOSIoVector)) * 4);
rv = IOS_Ioctlv(fd, 12, 2, 2, vector);
*numDev = *snumDev;
IOS_Close(fd);
out:
IOSFree(snumDev);
IOSFree(smaxDev);
IOSFree(sclass);
IOSFree(vector);
return rv;
}
DECOMP_FORCE_ACTIVE(usb_c, "openDevice: Not enough memory\n");
DECOMP_FORCE_ACTIVE(usb_c, "getDeviceList: Not enough memory\n");
IOSError __IntrBlkMsgInt(s32 fd, u32 endpoint, u32 length, void* buffer, u8 ioctl, USBCallback callback, void* callbackArg, u8 async) {
IOSError result;
@@ -608,397 +479,44 @@ end_async:
return result;
}
IOSError IUSB_ReadCtrlMsgAsync(IOSFd fd, u8 reqType, u8 request, u16 value, u16 index, u16 buflen, char* buf, USBCallback cb, void* cbArg) {
DCInvalidateRange(buf, buflen);
return __CtrlMsgInt(fd, reqType, request, value, index, buflen, buf, cb, cbArg, 1);
}
IOSError IUSB_WriteCtrlMsgAsync(s32 fd, u8 requestType, u8 request, u16 value, u16 index, u16 length, void* buffer, USBCallback callback,
void* callbackArg) {
DCFlushRange(buffer, length);
return __CtrlMsgInt(fd, requestType, request, value, index, length, buffer, callback, callbackArg, TRUE);
}
static s8 unicode2ascii(char* tbuf, int buflen) {
char buf[128];
s8 di, si;
if (tbuf[1] != 0x03) {
di = -1;
goto out;
}
for (di = 0, si = 2; si < tbuf[0] && si < buflen; si += 2) {
if (di >= (sizeof(buf) - 1))
break;
if (tbuf[si + 1])
buf[di++] = '?';
else
buf[di++] = tbuf[si];
}
buf[di] = 0;
memcpy(tbuf, buf, (u32)di);
out:
return di;
}
static void _GetStrCb(IOSError ret, void* ctxt) {
IOSError rv = ret;
USBCommandBlock* req = (USBCommandBlock*)ctxt;
char* buf;
u16 buflen;
s8 len;
USB_LOG("GetStrCb returned: %d\n", rv);
if (rv <= 0)
goto out;
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)
USB_ERR("Failed to convert buffer from unicode 2 ascii\n");
else
buf[len] = '\0';
out:
if (req->callback) {
USB_LOG("calling cb 0x%x with arg 0x%x\n", req->callback, req->callbackArg);
req->callback(ret, req->callbackArg);
}
IOSFree(req);
return;
}
IOSError IUSB_GetAsciiStr(IOSFd fd, u8 ep, u16 index, u16 langId, char* buf, u16 buflen) {
IOSError rv = IPC_RESULT_OK;
s8 len;
USB_LOG("GetStr\n");
DCInvalidateRange(buf, (u32)buflen);
rv = __CtrlMsgInt(fd, 0x80, 0x06, (u16)((0x03 << 8) + index), langId, buflen, buf, NULL, NULL, 0);
if (rv <= 0) {
USB_ERR("Failed __CtrlMsg: %d", rv);
goto out;
}
if ((len = unicode2ascii(buf, buflen)) < 0)
USB_ERR("Failed to convert unicode 2 ascii\n");
else
buf[len] = '\0';
out:
return rv;
}
IOSError IUSB_GetAsciiStrAsync(IOSFd fd, u8 ep, u16 index, u16 langId, char* buf, u16 buflen, USBCallback cb, void* cbArg) {
IOSError rv = IPC_RESULT_OK;
USBCommandBlock* req;
USB_LOG("GetStr - _GetStrCb\n");
req = IOSAlloc(OSRoundUp32B(sizeof(*req)));
if (req == 0) {
USB_ERR(" GetAsciiStrAsync: Not enough memory\n");
rv = IPC_RESULT_ALLOC_FAILED;
goto out;
}
memset(req, 0, sizeof(USBCommandBlock));
req->callback = cb;
req->callbackArg = cbArg;
req->nclean = 0;
req->msg.buffer = buf;
req->msg.length = buflen;
DCInvalidateRange(buf, buflen);
rv = __CtrlMsgInt(fd, 0x80, 0x06, (u16)((0x03 << 8) + index), langId, buflen, buf, _GetStrCb, req, 1);
if (rv < 0) {
USB_ERR("__CtrlMsgInt failed %d\n", rv);
IOSFree(req);
goto out;
}
out:
return rv;
}
static void _GetDescrCb(IOSError ret, void* ctxt) {
IOSError rv = ret;
USBCommandBlock* req = (USBCommandBlock*)ctxt;
USB_LOG("GetDescrCb returned: %d\n", rv);
if (rv <= 0)
goto out;
*(USBDeviceDescriptor*)req->spare = req->descriptor;
out:
if (req->callback)
req->callback(ret, req->callbackArg);
IOSFree(req);
return;
}
IOSError IUSB_GetDevDescr(IOSFd fd, USBDeviceDescriptor* des) {
IOSError rv = IPC_RESULT_OK;
USBCommandBlock* req = 0;
USB_LOG("GetDevDescr\n");
req = IOSAlloc(OSRoundUp32B(sizeof(*req)));
if (req == 0) {
USB_ERR("GetDevDescr: Not enough memory\n");
rv = IPC_RESULT_ALLOC_FAILED;
goto out;
}
memset(req, 0, sizeof(USBCommandBlock));
DCInvalidateRange(&req->descriptor, (u32)sizeof(*des));
rv = __CtrlMsgInt(fd, 0x80, 0x06, 0x100, 0, sizeof(*des), &req->descriptor, NULL, NULL, 0);
if (rv < 0) {
USB_ERR("Failed __CtrlMsg: %d", rv);
goto out;
}
USB_LOG("GetDevDescr: %d\n", rv);
*des = req->descriptor;
out:
IOSFree(req);
return rv;
}
IOSError IUSB_GetDevDescrAsync(IOSFd fd, USBDeviceDescriptor* des, USBCallback cb, void* cbArg) {
IOSError rv = IPC_RESULT_OK;
USBCommandBlock* req;
USB_LOG("GetDevDescr - _GetDescrCb\n");
req = IOSAlloc(OSRoundUp32B(sizeof(*req)));
if (req == 0) {
USB_ERR("GetDevDescrAsync: Not enough memory\n");
rv = IPC_RESULT_ALLOC_FAILED;
goto out;
}
memset(req, 0, sizeof(USBCommandBlock));
req->callback = cb;
req->callbackArg = cbArg;
req->nclean = 0;
req->spare = des;
rv = IUSB_ReadCtrlMsgAsync(fd, 0x80, 0x06, 0x100, 0, sizeof(*des), (char*)&req->descriptor, _GetDescrCb, req);
if (rv < 0) {
IOSFree(req);
goto out;
}
out:
return rv;
}
IOSError IUSB_DeviceRemovalNotifyAsync(IOSFd fd, IOSIpcCb cb, void* cbArg) {
IOSError rv;
USB_LOG("DeviceRemovalNotifyAsync\n");
rv = IOS_IoctlAsync(fd, 26, 0, 0, 0, 0, cb, cbArg);
return rv;
}
static IOSError __checkIsoArgs(USBIsoTransfer* xfer, u16* buflen) {
IOSError rv = IPC_RESULT_INVALID;
if (NULL == xfer || NULL == xfer->buf || 0 == xfer->numPackets || xfer->numPackets > 8 || NULL == xfer->packets) {
goto out;
}
{
u32 i;
*buflen = 0;
for (i = 0; i < xfer->numPackets; ++i) {
if (xfer->packets[i] > 1023) {
USB_ERR("packet %u too big: %u\n", i, xfer->packets[i]);
goto out;
}
*buflen += xfer->packets[i];
}
}
rv = IPC_RESULT_OK;
out:
return rv;
}
IOSError IUSB_IsoMsgAsync(IOSFd fd, u8 ep, USBIsoTransfer* xfer, USBIsoCallback cb, void* cbArg) {
IOSError rv = IPC_RESULT_OK;
u8 *sep, *snumPackets;
u16* sbuflen;
IOSIoVector* vector;
USBCommandBlock* req;
u16 buflen;
if (0 == ep || NULL == cb || (__checkIsoArgs(xfer, &buflen) < 0)) {
USB_ERR("Invalid parameters for ISO transfer request\n");
rv = IPC_RESULT_INVALID;
goto out;
}
vector = IOSAlloc(OSRoundUp32B(sizeof(IOSIoVector)) * 5);
sep = IOSAlloc(OSRoundUp32B(sizeof(u8)));
sbuflen = IOSAlloc(OSRoundUp32B(sizeof(u16)));
snumPackets = IOSAlloc(OSRoundUp32B(sizeof(u8)));
req = IOSAlloc(OSRoundUp32B(sizeof(*req)));
if (NULL == vector || NULL == sep || NULL == sbuflen || NULL == req) {
USB_ERR("IUSB_IsoMsgAsync: Not enough memory\n");
rv = IPC_RESULT_ALLOC_FAILED;
IOSFree(req);
goto clean;
}
memset(req, 0, sizeof(USBCommandBlock));
*sep = ep;
*sbuflen = buflen;
*snumPackets = xfer->numPackets;
vector[0].base = (u8*)sep;
vector[0].length = sizeof(u8);
vector[1].base = (u8*)sbuflen;
vector[1].length = sizeof(u16);
vector[2].base = snumPackets;
vector[2].length = sizeof(u8);
vector[3].base = (u8*)xfer->packets;
vector[3].length = sizeof(u16) * xfer->numPackets;
vector[4].base = xfer->buf;
vector[4].length = buflen;
DCFlushRange(sep, OSRoundUp32B(sizeof(u8)));
DCFlushRange(sbuflen, OSRoundUp32B(sizeof(u16)));
DCFlushRange(snumPackets, OSRoundUp32B(sizeof(u8)));
DCFlushRange(vector, OSRoundUp32B(sizeof(IOSIoVector)) * 5);
req->isoCallback = cb;
req->isoArg = xfer;
req->callbackArg = cbArg;
req->nclean = 4;
req->clean[0] = sep;
req->clean[1] = sbuflen;
req->clean[2] = snumPackets;
req->clean[3] = vector;
rv = IOS_IoctlvAsync(fd, 9, 3, 2, vector, _intrBlkCtrlIsoCb, req);
if (rv < 0) {
IOSFree(req);
goto clean;
}
goto out;
clean:
IOSFree(sep);
IOSFree(sbuflen);
IOSFree(snumPackets);
IOSFree(vector);
out:
return rv;
}
IOSError IUSB_DeviceInsertionNotifyAsync(const char* path, u16 vid, u16 pid, USBCallback cb, void* cbArg) {
IOSError rv;
IOSFd fd;
IOSIoVector* vector;
u16 *svid, *spid;
USBCommandBlock* req;
if (NULL == path || 0 == vid || 0 == pid) {
rv = IPC_RESULT_INVALID;
goto done;
}
if ((fd = IOS_Open(path, 0)) < 0) {
rv = fd;
USB_ERR("Open(%s) failed\n", path);
goto done;
}
vector = IOSAlloc(OSRoundUp32B(sizeof(IOSIoVector)) * 2);
spid = IOSAlloc(OSRoundUp32B(sizeof(u16)));
svid = IOSAlloc(OSRoundUp32B(sizeof(u16)));
req = IOSAlloc(OSRoundUp32B(sizeof(*req)));
if (NULL == vector || NULL == spid || NULL == svid || NULL == req) {
USB_ERR("getDeviceList: Not enough memory\n");
rv = IPC_RESULT_ALLOC_FAILED;
goto clean;
}
memset(req, 0, sizeof(USBCommandBlock));
*svid = vid;
*spid = pid;
vector[0].base = (u8*)svid;
vector[0].length = sizeof(u16);
vector[1].base = (u8*)spid;
vector[1].length = sizeof(u16);
DCFlushRange(svid, OSRoundUp32B(sizeof(u16)));
DCFlushRange(spid, OSRoundUp32B(sizeof(u16)));
DCFlushRange(vector, OSRoundUp32B(sizeof(IOSIoVector)) * 2);
req->callback = cb;
req->callbackArg = cbArg;
req->nclean = 3;
req->clean[0] = svid;
req->clean[1] = spid;
req->clean[2] = vector;
rv = IOS_IoctlvAsync(fd, 27, 2, 0, vector, _intrBlkCtrlIsoCb, req);
if (rv < 0) {
goto clean;
}
IOS_Close(fd);
goto done;
clean:
IOSFree(svid);
IOSFree(spid);
IOSFree(vector);
IOSFree(req);
done:
return rv;
}
IOSError IUSB_DeviceClassInsertionNotifyAsync(const char* path, u8 devClass, USBCallback cb, void* cbArg) {
IOSError rv;
IOSFd fd;
IOSIoVector* vector;
u8* sdevClass;
USBCommandBlock* req;
if (NULL == path || 0 == devClass) {
OSReport("Invalid path or devClass in insertion notification call\n");
rv = IPC_RESULT_INVALID;
goto done;
}
if ((fd = IOS_Open(path, 0)) < 0) {
rv = fd;
OSReport("Open(%s) failed\n", path);
goto done;
}
vector = IOSAlloc(OSRoundUp32B(sizeof(IOSIoVector)) * 2);
sdevClass = IOSAlloc(OSRoundUp32B(sizeof(u8)));
req = IOSAlloc(OSRoundUp32B(sizeof(*req)));
*sdevClass = devClass;
vector[0].base = (u8*)sdevClass;
vector[0].length = sizeof(u8);
DCFlushRange(sdevClass, OSRoundUp32B(sizeof(u8)));
DCFlushRange(vector, OSRoundUp32B(sizeof(IOSIoVector)) * 2);
req->callback = cb;
req->callbackArg = cbArg;
req->nclean = 2;
req->clean[0] = sdevClass;
req->clean[1] = vector;
rv = IOS_IoctlvAsync(fd, 28, 1, 0, vector, _intrBlkCtrlIsoCb, req);
IOS_Close(fd);
done:
return rv;
}
// oh my
DECOMP_FORCE_ACTIVE(usb_c, "CloseDeviceAsync: Not enough memory\n");
DECOMP_FORCE_ACTIVE(usb_c, "openDevice: Not enough memory\n");
DECOMP_FORCE_ACTIVE(usb_c, "getDeviceList: Not enough memory\n");
DECOMP_FORCE_ACTIVE(usb_c, "getDeviceList: Not enough memory\n");
DECOMP_FORCE_ACTIVE(usb_c, "__IntrBlkMsgInt: Not enough memory\n");
DECOMP_FORCE_ACTIVE(usb_c, "intr/blk ioctl returned: %d\n");
DECOMP_FORCE_ACTIVE(usb_c, "IntBlkMsgInt (async): Not enough memory\n");
DECOMP_FORCE_ACTIVE(usb_c, "intrblkmsg: cb = 0x%x cbArg = 0x%x\n");
DECOMP_FORCE_ACTIVE(usb_c, "ctrlmsg: bad data buffer\n");
DECOMP_FORCE_ACTIVE(usb_c, "Ctrl Msg: Not enough memory\n");
DECOMP_FORCE_ACTIVE(usb_c, "CtrlMsgInt (async): Not enough memory\n");
DECOMP_FORCE_ACTIVE(usb_c, "ctrlmsgint: cb = 0x%x cbArg = 0x%x\n");
DECOMP_FORCE_ACTIVE(usb_c, "Ctrl Msg async returned: %d\n");
DECOMP_FORCE_ACTIVE(usb_c, "GetStrCb returned: %d\n");
DECOMP_FORCE_ACTIVE(usb_c, "GetStrCb: buf = 0x%x buflen = %u\n");
DECOMP_FORCE_ACTIVE(usb_c, "Failed to convert buffer from unicode 2 ascii\n");
DECOMP_FORCE_ACTIVE(usb_c, "calling cb 0x%x with arg 0x%x\n");
DECOMP_FORCE_ACTIVE(usb_c, "Failed __CtrlMsg: %d");
DECOMP_FORCE_ACTIVE(usb_c, "Failed to convert unicode 2 ascii\n");
DECOMP_FORCE_ACTIVE(usb_c, "GetStr - _GetStrCb\n");
DECOMP_FORCE_ACTIVE(usb_c, " GetAsciiStrAsync: Not enough memory\n");
DECOMP_FORCE_ACTIVE(usb_c, "__CtrlMsgInt failed %d\n");
DECOMP_FORCE_ACTIVE(usb_c, "GetDescrCb returned: %d\n");
DECOMP_FORCE_ACTIVE(usb_c, "GetDevDescr\n");
DECOMP_FORCE_ACTIVE(usb_c, "GetDevDescr: Not enough memory\n");
DECOMP_FORCE_ACTIVE(usb_c, "GetDevDescr: %d\n");
DECOMP_FORCE_ACTIVE(usb_c, "GetDevDescr - _GetDescrCb\n");
DECOMP_FORCE_ACTIVE(usb_c, "GetDevDescrAsync: Not enough memory\n");
DECOMP_FORCE_ACTIVE(usb_c, "DeviceRemovalNotifyAsync\n");
DECOMP_FORCE_ACTIVE(usb_c, "packet %u too big: %u\n");
DECOMP_FORCE_ACTIVE(usb_c, "Invalid parameters for ISO transfer request\n");
DECOMP_FORCE_ACTIVE(usb_c, "IUSB_IsoMsgAsync: Not enough memory\n");
DECOMP_FORCE_ACTIVE(usb_c, "Open(%s) failed\n");
DECOMP_FORCE_ACTIVE(usb_c, "Invalid path or devClass in insertion notification call\n");

Some files were not shown because too many files have changed in this diff Show More