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
451 changed files with 15789 additions and 62584 deletions

View File

@@ -6,7 +6,7 @@ on:
workflow_dispatch:
inputs:
require_complete:
description: Fail unless 43U binary matches completely and source inventory is complete
description: Fail unless 43U code, data, functions, units, and links are all 100%
required: false
default: false
type: boolean
@@ -79,7 +79,6 @@ jobs:
python tools/check_decomp_complete.py \
build/${{ matrix.version }}/report.json \
--dol build/${{ matrix.version }}/main.dol
python tools/check_asm_inventory.py
# Upload map files
- name: Upload map

View File

@@ -94,11 +94,10 @@ The final completion assertion is machine-checkable:
```
python3 tools/check_decomp_complete.py build/43U/report.json \
--dol build/43U/main.dol
python3 tools/check_asm_inventory.py
```
Both checks must pass before claiming full completion. GitHub Actions runs the same
assertions when manually dispatched with `require_complete=true`.
It must pass before claiming full completion. GitHub Actions runs the same
assertion when manually dispatched with `require_complete=true`.
Normal push and pull-request builds publish progress without failing on the
current incomplete state. Use the manual `require_complete=true` dispatch for
the terminal all-100% gate.

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
@@ -2524,7 +2524,7 @@ __ct__Q33ipl3snd10tagSSeInfoFv = .text:0x8136C63C; // type:function size:0x30
__ct__Q34nw4r3snd11SoundHandleFv = .text:0x8136C66C; // type:function size:0xC
__dt__Q34nw4r3snd11SoundHandleFv = .text:0x8136C678; // type:function size:0x54
__dt__Q33ipl3snd10tagSSeInfoFv = .text:0x8136C6CC; // type:function size:0x58
__arraydtor$15982 = .text:0x8136C724; // type:function size:0x1C scope:local
__dt__Q33ipl3snd6UnkClsFv = .text:0x8136C724; // type:function size:0x1C scope:local
__ct__Q33ipl3snd11tagSBgmInfoFv = .text:0x8136C740; // type:function size:0x30 scope:local
__dt__Q33ipl3snd11tagSBgmInfoFv = .text:0x8136C770; // type:function size:0x58
__ct__Q33ipl3snd6SystemFv = .text:0x8136C7C8; // type:function size:0x4C
@@ -3223,7 +3223,7 @@ __dt__Q33ipl5scene5BoardFv = .text:0x81393CA4; // type:function size:0x68
__ct__Q33ipl5scene11BoardObjectFv = .text:0x81393D1C; // type:function size:0x140
__dt__Q33ipl4math28LinearIntp<Q33ipl4math4VEC2>Fv = .text:0x81393E5C; // type:function size:0x40
__dt__Q33ipl4math31Interporation<Q33ipl4math4VEC2>Fv = .text:0x81393E9C; // type:function size:0x40
init__Q43ipl5scene11BoardObject9StandDataFv = .text:0x81393EDC; // type:function size:0x18
init__Q43ipl5scene11BoardObject29@class$8157iplBoardObject_cppFv = .text:0x81393EDC; // type:function size:0x18
make_icon_cb___Q23ipl5sceneFPQ33ipl6nigaoe6ObjectPv = .text:0x81393EF4; // type:function size:0x80
create__Q33ipl5scene11BoardObjectFPQ33ipl4nand10LayoutFilePUcUlRC6_CDBIdRC13_CDBRecordKeyRCQ33ipl7utility4Date = .text:0x81393F74; // type:function size:0x84
init__Q33ipl5scene11BoardObjectFv = .text:0x81393FF8; // type:function size:0xA4
@@ -4584,11 +4584,11 @@ enqueueLoadNotice__Q33ipl5scene15SDChannelSelectFv = .text:0x813DB308; // type:f
enqueuePageNotice__Q33ipl5scene15SDChannelSelectFv = .text:0x813DB364; // type:function size:0x5C
enqueueResultNotice__Q33ipl5scene15SDChannelSelectFUl = .text:0x813DB3C0; // type:function size:0x5C
enqueueChannelNotice__Q33ipl5scene15SDChannelSelectFUxUl = .text:0x813DB41C; // type:function size:0x5C
enqueueMoveNotice__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
@@ -20933,28 +20924,31 @@ lbl_81694D18 = .sdata2:0x81694D18; // type:object size:0x4 data:4byte
lbl_81694D1C = .sdata2:0x81694D1C; // type:object size:0x4 data:4byte
lbl_81694D20 = .sdata2:0x81694D20; // type:object size:0x1 data:byte
lbl_81694D24 = .sdata2:0x81694D24; // type:object size:0x1 data:byte
@13326 = .sdata2:0x81694D28; // type:object size:0x4 scope:local align:4 data:float
@13327 = .sdata2:0x81694D2C; // type:object size:0x4 scope:local align:4 data:float
@13360 = .sdata2:0x81694D30; // type:object size:0x8 scope:local align:8 data:double
@13767 = .sdata2:0x81694D38; // type:object size:0x4 scope:local align:4 data:float
@13772 = .sdata2:0x81694D3C; // type:object size:0x4 scope:local align:4 data:float
@13804 = .sdata2:0x81694D40; // type:object size:0x4 scope:local align:4 data:float
@13805 = .sdata2:0x81694D44; // type:object size:0x4 scope:local align:4 data:float
@13806 = .sdata2:0x81694D48; // type:object size:0x4 scope:local align:4 data:float
@13807 = .sdata2:0x81694D4C; // type:object size:0x4 scope:local align:4 data:float
@13808 = .sdata2:0x81694D50; // type:object size:0x4 scope:local align:4 data:float
@13809 = .sdata2:0x81694D54; // type:object size:0x4 scope:local align:4 data:float
@13810 = .sdata2:0x81694D58; // type:object size:0x4 scope:local align:4 data:float
@13811 = .sdata2:0x81694D5C; // type:object size:0x4 scope:local align:4 data:float
@13812 = .sdata2:0x81694D60; // type:object size:0x4 scope:local align:4 data:float
@13813 = .sdata2:0x81694D64; // type:object size:0x4 scope:local align:4 data:float
@13814 = .sdata2:0x81694D68; // type:object size:0x4 scope:local align:4 data:float
@8131 = .sdata2:0x81694D6C; // type:object size:0x4 scope:local data:byte
@14016 = .sdata2:0x81694D70; // type:object size:0x4 scope:local align:4 data:float
@14017 = .sdata2:0x81694D74; // type:object size:0x4 scope:local align:4 data:float
@14018 = .sdata2:0x81694D78; // type:object size:0x4 scope:local align:4 data:float
@14021 = .sdata2:0x81694D80; // type:object size:0x8 scope:local align:8 data:double
@14117 = .sdata2:0x81694D88; // type:object size:0x4 scope:local align:4 data:float
scInputFormZeroF = .sdata2:0x81694D28; // type:object size:0x4 align:4 data:float
scInputForm640F = .sdata2:0x81694D2C; // type:object size:0x4 align:4 data:float
scInputFormF32ConvertMagic = .sdata2:0x81694D30; // type:object size:0x8 align:8 data:double
scInputFormOneF = .sdata2:0x81694D38; // type:object size:0x4 align:4 data:float
scInputFormHalfF = .sdata2:0x81694D3C; // type:object size:0x4 align:4 data:float
scInputFormDegToFIdxF = .sdata2:0x81694D40; // type:object size:0x4 align:4 data:float
scInputForm150F = .sdata2:0x81694D44; // type:object size:0x4 align:4 data:float
scInputForm30F = .sdata2:0x81694D48; // type:object size:0x4 align:4 data:float
scInputForm50F = .sdata2:0x81694D4C; // type:object size:0x4 align:4 data:float
scInputForm10F = .sdata2:0x81694D50; // type:object size:0x4 align:4 data:float
scInputForm52F = .sdata2:0x81694D54; // type:object size:0x4 align:4 data:float
scInputFormTwoF = .sdata2:0x81694D58; // type:object size:0x4 align:4 data:float
scInputForm140F = .sdata2:0x81694D5C; // type:object size:0x4 align:4 data:float
scInputForm90F = .sdata2:0x81694D60; // type:object size:0x4 align:4 data:float
scInputForm253F = .sdata2:0x81694D64; // type:object size:0x4 align:4 data:float
scInputForm20F = .sdata2:0x81694D68; // type:object size:0x4 align:4 data:float
scInputFormColorRU8 = .sdata2:0x81694D6C; // type:object size:0x1 data:byte
scInputFormColorGU8 = .sdata2:0x81694D6D; // type:object size:0x1 data:byte
scInputFormColorBU8 = .sdata2:0x81694D6E; // type:object size:0x1 data:byte
scInputFormColorAU8 = .sdata2:0x81694D6F; // type:object size:0x1 data:byte
scInputForm255F = .sdata2:0x81694D70; // type:object size:0x4 align:4 data:float
scInputForm127F = .sdata2:0x81694D74; // type:object size:0x4 align:4 data:float
scInputForm14592F = .sdata2:0x81694D78; // type:object size:0x4 align:4 data:float
scInputFormF64ConvertMagic = .sdata2:0x81694D80; // type:object size:0x8 align:8 data:double
scInputForm15F = .sdata2:0x81694D88; // type:object size:0x4 align:4 data:float
lbl_81694D90 = .sdata2:0x81694D90; // type:object size:0x4 align:4 data:float
lbl_81694D94 = .sdata2:0x81694D94; // type:object size:0x4 align:4 data:float
lbl_81694D98 = .sdata2:0x81694D98; // type:object size:0x4 align:4 data:float
@@ -22779,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
@@ -23678,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
@@ -23687,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"),
]
@@ -824,7 +824,7 @@ config.libs = [
]
),
IPLSection("cardSequence", [
Object(Matching, "scene/cardSequence/iplCardSequence.cpp"),
Object(NonMatching, "scene/cardSequence/iplCardSequence.cpp"),
]
),
IPLSection("nakamuraTest", [
@@ -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"),
@@ -876,11 +876,10 @@ config.libs = [
Object(Matching, "scene/setting/iplUSBAP.cpp"),
Object(Matching, "scene/setting/iplUSBAPThread.cpp"),
Object(Matching, "scene/setting/iplAOSSThread.cpp"),
Object(Matching, "scene/setting/AOSSLink.c"),
Object(NonMatching, "scene/setting/AOSSLink.c"),
Object(Matching, "scene/setting/iplRakuRakuThread.cpp"),
Object(Matching, "scene/setting/AOSS.c", extra_cflags=["-O4,p", "-inline on,noauto"]),
Object(Matching, "scene/setting/AOSSData.c"),
Object(Matching, "scene/setting/ATERM.c", mw_version="GC/3.0a5", extra_cflags=["-O4,p", "-inline on"]),
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", [
@@ -911,14 +910,14 @@ config.libs = [
IPLSection("keyboard", [
Object(Matching, "keyboard/tiPcKeyboard.cpp", extra_cflags=["-O4,p"]),
Object(Matching, "keyboard/tiCellPhone.cpp", extra_cflags=["-O4,p"]),
Object(Matching, "keyboard/tiInputForm.cpp", extra_cflags=["-O4,p"]),
Object(Matching, "keyboard/tiCandidateBox.cpp", extra_cflags=["-O4,p"]),
Object(NonMatching, "keyboard/tiInputForm.cpp", extra_cflags=["-O4,p"]),
Object(NonMatching, "keyboard/tiCandidateBox.cpp", extra_cflags=["-O4,p"]),
Object(Matching, "keyboard/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(Matching, "keyboard/tiString.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-09. 163 functions contain 165 assembly
bodies/blocks: 162 ORIGINAL functions and 1 PLACEHOLDER function.
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,6 +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 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. |
@@ -159,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. |
@@ -185,12 +189,21 @@ 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/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. |
| `src/system/rvl_dec.c` | `Rvl_decode_ash` | ORIGINAL | nofralloc hand-built 0x40 frame saves r21..31 with stmw; work address uses lis @h/ori @l. |
| `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
[sdk-init]: https://github.com/doldecomp/ogws/blob/master/src/revolution/OS/__ppc_eabi_init.c
[runtime]: https://github.com/doldecomp/ogws/blob/master/src/runtime/runtime.c

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

@@ -10,7 +10,7 @@ namespace ipl {
volatile u16 size; // 0x02
u8 canCopy; // 0x04
u8 canMove; // 0x05
u16 transferBlocked; // 0x06
u16 unk_0x06; // 0x06
u32 key; // 0x08
} FileInfo; // 0x0C
@@ -21,21 +21,21 @@ namespace ipl {
vu16 reservedSlot; // 0x04
vu16 reservedCommand; // 0x06
vu32 key; // 0x08
vu16 totalBlocks; // 0x0C
vu16 freeFiles; // 0x0E
vu16 unk_0x0C; // 0x0C
vu16 unk_0x0E; // 0x0E
vu16 freeBlocks; // 0x10
vu16 titleBlocks; // 0x12
vu16 unk_0x12; // 0x12
} CardState; // 0x14
typedef struct IconState {
volatile u8 bannerEnable; // 0x00
u8 iconEnable; // 0x01
u8 iconCount; // 0x02
u8 unk_0x01; // 0x01
u8 unk_0x02; // 0x02
u8 bannerType; // 0x03
s8 anmDelta; // 0x04
u8 anmType; // 0x05
u8 anmFirstFrameDuration; // 0x06
u8 anmLastFrameDuration; // 0x07
u8 unk_0x06; // 0x06
u8 unk_0x07; // 0x07
u8 iconFmt[8]; // 0x08
#ifdef IPL_MEMORY_CARD_MANAGER_CPP
volatile u16 anmFrameBits;

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

@@ -178,14 +178,8 @@ namespace textinput {
void inputCharZi_(wchar_t character, u32 modifiers);
void inputCharDefault_(wchar_t character, u32 modifiers);
void inputInputting_(wchar_t character);
bool hasZiPredictions() const;
bool usesZiPrediction() const;
#ifdef TIINPUTFORM_IMPLEMENTATION
void checkUnfixConverting_();
void setAtokMode_(bool fixMode, bool kanaMode);
void trimString_(u32 length);
void startConverting_();
#endif
inline bool hasZiPredictions() const;
inline bool usesZiPrediction() const;
inline void resetPredictionContext();
inline void resetInputRelation();
#endif
@@ -362,7 +356,6 @@ namespace textinput {
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
friend class EventHandler;
inline const nw4r::lyt::Pane* getLanguageTextPane() const;
inline nw4r::lyt::TextBox* getTextBox() const;
#endif
public:
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)

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

@@ -85,30 +85,10 @@ namespace textinput {
#endif
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION) || defined(TISTRING_IMPLEMENTATION) || defined(TIZISTRING_IMPLEMENTATION)
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TISTRING_IMPLEMENTATION)
virtual ~Decolated() {}
#else
virtual ~Decolated();
#endif
enum TranslateMode { TM_Direct, TM_Kana, TM_Roman, TM_Hangul };
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TISTRING_IMPLEMENTATION)
virtual void clear() {
StringBase::clear();
mCursorStart = 0;
mCursorEnd = 0;
mbSustain = false;
initKanaConverter();
}
virtual void set(const wchar_t* string) {
StringBase::set(string);
u32 length = getLength();
mCursorStart = length;
mCursorEnd = length;
}
#else
virtual void clear();
virtual void set(const wchar_t* string);
#endif
virtual void setLength(u16 length);
void setTranslateMode(TranslateMode mode);
TranslateMode getTranslateMode() const { return static_cast<TranslateMode>(mTranslateMode); }
@@ -214,9 +194,6 @@ namespace textinput {
public:
WithAtok(u16 maxLength) : Decolated(maxLength) {}
virtual ~WithAtok();
virtual bool isFix();
virtual void setFix(bool fix);
virtual void initConverting();
virtual void pushBack(wchar_t ch);
virtual void popBack();
virtual void inputChar(wchar_t ch);
@@ -232,6 +209,9 @@ namespace textinput {
u32 selectedStart;
u32 selectedEnd;
};
virtual bool isFix();
virtual void setFix(bool fix);
virtual void initConverting();
virtual bool isConverting();
virtual wchar_t* getConfirmedWCString() const;
virtual int getCurrentNumPredicted();

View File

@@ -47,13 +47,8 @@ namespace textinput {
public :
virtual ~Base() {}
#ifdef TIINPUTFORM_IMPLEMENTATION
virtual void create(MEMAllocator* allocator) {}
virtual void init() {}
#else
virtual void create(MEMAllocator* allocator);
virtual void init();
#endif
};
class CommandSender;
@@ -64,12 +59,8 @@ namespace textinput {
#endif
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
CommandReceiver() { clearSender(); }
#ifdef TIINPUTFORM_IMPLEMENTATION
virtual ~CommandReceiver() {}
#else
virtual ~CommandReceiver();
#endif
#endif
#if defined(MYTIINPUTFORM_IMPLEMENTATION) || defined(MYTILETTERFORM_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
struct Scroll {
bool absY;
@@ -105,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

@@ -159,7 +159,7 @@ namespace ipl {
RBRRecordType mRecordType; // 0xDC
u32 mOptOutFlag; // 0xE0
class StandData {
class {
public:
void init() {
mAngleIdx = -1;

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

@@ -12,6 +12,7 @@
namespace ipl {
namespace scene {
extern "C" BOOL push_button_queue(void*, const void*);
class ButtonEventHandlerBase;
class OptOutButtonEventHandlerBase;
class SDMenuEventHandlerBase;
@@ -314,6 +315,7 @@ namespace ipl {
}
protected:
friend BOOL push_button_queue(void*, const void*);
typedef struct Command {
enum {
TYPE_ANIM = 0,

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

@@ -190,7 +190,6 @@ namespace ipl {
PointerCore mCore; // 0x40
friend class System;
friend class PointerCoreObject;
friend class PointerCore;
friend class utility::BScroller;

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

@@ -10,9 +10,31 @@ namespace ipl {
public:
inline Queue<T, c>() : count(c), current(0), popped(0), pushed(0) {}
BOOL push(const T& item);
BOOL push(const T& item) {
if (count == current) {
return FALSE;
}
items[pushed] = item;
if (++pushed >= count) {
pushed = 0;
}
current++;
return TRUE;
}
BOOL pop();
BOOL pop() {
BOOL result = TRUE;
if (current == 0) {
result = FALSE;
goto done;
}
if (++popped >= count) {
popped = 0;
}
current--;
done:
return result;
}
int get_current_index() { return current; }
T& get_current_item() { return items[get_current_index()]; }
@@ -33,34 +55,6 @@ namespace ipl {
int current; // (sizeof(items) * count) + 0x04
int popped, pushed; // (sizeof(items) * count) + 0x08
};
template <typename T, int c>
BOOL Queue<T, c>::push(const T& item) {
if (count == current) {
return FALSE;
}
items[pushed] = item;
if (++pushed >= count) {
pushed = 0;
}
current++;
return TRUE;
}
template <typename T, int c>
BOOL Queue<T, c>::pop() {
BOOL result = TRUE;
if (current == 0) {
result = FALSE;
goto done;
}
if (++popped >= count) {
popped = 0;
}
current--;
done:
return result;
}
} // namespace utility
} // namespace ipl

View File

@@ -55,7 +55,7 @@ namespace ipl {
void init() {
mState = 0;
mScroll = 0.0f;
mScrollVelocity = 0.0f;
unk_0x3C = 0.0f;
mUpLimit = 0.0f;
mDownLimit = 0.0f;
}
@@ -92,7 +92,7 @@ namespace ipl {
int mState; // 0x30
f32 mDownLimit; // 0x34
f32 mUpLimit; // 0x38
f32 mScrollVelocity;
f32 unk_0x3C;
f32 mScroll; // 0x40
f32 mButtonScrollOrigin;
f32 mVelocityDecay;

View File

@@ -4,7 +4,7 @@
#include <nw4r/snd.h>
#include <revolution/os.h>
#pragma sym on
namespace EGG {
ArcPlayer::ArcPlayer(nw4r::snd::SoundHeap* pHeap) : mpSoundHeap(pHeap) {
mStorage = SARC_STORAGE_NONE;

View File

@@ -74,7 +74,8 @@ namespace EGG {
return MEMAllocFromFrmHeapEx(mHeapHandle, size, align);
}
void FrmHeap::free(void*) {
void FrmHeap::free(void* ptr) {
#pragma unused(ptr)
}
u32 FrmHeap::resizeForMBlock(void* ptr, u32 size) {

View File

@@ -36,6 +36,8 @@ namespace EGG {
}
void* Heap::alloc(u32 size, int align, Heap* heap) {
void* ptr = NULL;
if (sAllocatableHeap != NULL) {
if (sCurrentHeap != NULL && heap == NULL) {
heap = sCurrentHeap;
@@ -51,7 +53,13 @@ namespace EGG {
}
if (sCurrentHeap != NULL) {
return sCurrentHeap->alloc(size, align);
ptr = sCurrentHeap->alloc(size, align);
if (ptr == NULL) {
// stripped out EGG_PRINT
}
return ptr;
}
return NULL;
@@ -162,7 +170,7 @@ void* operator new[](size_t size, EGG::Heap* heap, int align) {
void operator delete(void* ptr) {
EGG::Heap::free(ptr, NULL);
// MWCC needs these no-op statements to keep operator delete out of Heap's destructor.
// don't inline. (NO_INLINE did not want to work)
(void)0;
(void)0;
(void)0;

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

@@ -18,29 +18,29 @@ namespace nw4r {
inline u32 CalcOffsetSheetData(u16 countNames) {
return ROUNDUP(CalcOffsetNameOffsetData() + countNames * sizeof(u16), 4);
}
inline u32 CalcOffsetCWDHData(u16 countNames, u16 countSheets) {
inline u32 CalcOffset0AData(u16 countNames, u16 countSheets) {
return ROUNDUP(CalcOffsetSheetData(countNames) + countSheets * sizeof(u32), 4);
}
inline u32 CalcOffsetCMAPData(u16 countNames, u16 countSheets, u16 countCWDH) {
return ROUNDUP(CalcOffsetCWDHData(countNames, countSheets) + countCWDH * sizeof(u32), 4);
inline u32 CalcOffset0CData(u16 countNames, u16 countSheets, u16 count0A) {
return ROUNDUP(CalcOffset0AData(countNames, countSheets) + count0A * sizeof(u32), 4);
}
inline u32 CalcSizeFlagSet(u32 entries) {
return ((s32)entries + 0x1f) / 32 * 4;
}
inline u32 CalcOffsetSheetFlags(u16 countNames, u16 countSheets, u16 countCWDH, u16 countCMAP) {
return ROUNDUP(CalcOffsetCMAPData(countNames, countSheets, countCWDH) + countCMAP * sizeof(u32), 4);
inline u32 CalcOffsetSheetFlags(u16 countNames, u16 countSheets, u16 count0A, u16 count0C) {
return ROUNDUP(CalcOffset0CData(countNames, countSheets, count0A) + count0C * sizeof(u32), 4);
}
inline u32 CalcOffsetCWDHFlags(u16 countNames, u16 countSheets, u16 countCWDH, u16 countCMAP) {
u32 offsetSheetFlags = CalcOffsetSheetFlags(countNames, countSheets, countCWDH, countCMAP);
inline u32 CalcOffset0AFlags(u16 countNames, u16 countSheets, u16 count0A, u16 count0C) {
u32 offsetSheetFlags = CalcOffsetSheetFlags(countNames, countSheets, count0A, count0C);
u32 stepSheet = CalcSizeFlagSet(countSheets);
return ROUNDUP(offsetSheetFlags + stepSheet * countNames, 4);
}
inline u32 CalcOffsetCMAPFlags(u16 countNames, u16 countSheets, u16 countCWDH, u16 countCMAP) {
u32 offsetCWDHFlags = CalcOffsetCWDHFlags(countNames, countSheets, countCWDH, countCMAP);
u32 stepCWDH = CalcSizeFlagSet(countCWDH);
return ROUNDUP(offsetCWDHFlags + stepCWDH * countNames, 4);
inline u32 CalcOffset0CFlags(u16 countNames, u16 countSheets, u16 count0A, u16 count0C) {
u32 offset0AFlags = CalcOffset0AFlags(countNames, countSheets, count0A, count0C);
u32 step0A = CalcSizeFlagSet(count0A);
return ROUNDUP(offset0AFlags + step0A * countNames, 4);
}
inline u32 CalcSizeSheetOffsets(u32 countSheets) {

View File

@@ -92,8 +92,8 @@ namespace nw4r {
u16 sheetGlyphCount; // 0x04
u16 nameCount; // 0x06
u16 sheetCount; // 0x08
u16 cwdhCount; // 0x0A
u16 cmapCount; // 0x0C
u16 smthCount_0x0a; // 0x0A
u16 smthCount_0x0c; // 0x0C
u16 nameOffsets[0];
} GlyphGroups;

View File

@@ -207,50 +207,56 @@ namespace nw4r {
}
static void DoDrawConsole_(ConsoleHandle console, ut::TextWriter* writer) {
s32 viewOffset;
u16 line;
u16 printLines;
{
s32 viewOffset;
u16 line;
u16 printLines;
viewOffset = console->viewTopLine - console->ringTopLineCnt;
printLines = 0;
viewOffset = console->viewTopLine - console->ringTopLineCnt;
printLines = 0;
if (viewOffset < 0) {
viewOffset = 0;
} else if (viewOffset > GetActiveLines_(console)) {
return;
}
line = static_cast<u16>(console->ringTop + viewOffset);
if (line >= console->height) {
line -= console->height;
}
while (true) {
if (line == console->printTop && !console->printTopUsed) {
break;
if (viewOffset < 0) {
viewOffset = 0;
} else if (viewOffset > GetActiveLines_(console)) {
goto end;
}
DoDrawString_(console, printLines, GetTextPtr_(console, line, 0), writer);
printLines++;
line = static_cast<u16>(console->ringTop + viewOffset);
if (line == console->printTop) {
break;
if (line >= console->height) {
line -= console->height;
}
line++;
if (line == console->height) {
if (console->attr & (1 << 1)) {
break;
while (true) {
if (line == console->printTop && !console->printTopUsed) {
goto end;
}
line = 0;
}
if (printLines >= console->viewLines) {
break;
DoDrawString_(console, printLines, GetTextPtr_(console, line, 0), writer);
printLines++;
if (line == console->printTop) {
goto end;
}
line++;
if (line == console->height) {
if (console->attr & (1 << 1)) {
goto end;
}
line = 0;
}
if (printLines >= console->viewLines) {
goto end;
}
}
}
// maybe not, with this end label?
end:
return;
}
void Console_DrawDirect(ConsoleHandle console) {

View File

@@ -108,7 +108,7 @@ namespace {
} else if (operation == ut::OPERATION_CHAR_SPACE) {
bCharSpace = true;
} else if (operation == ut::OPERATION_NEXT_LINE) {
break;
goto end_draw;
}
} else {
if (bCharSpace) {
@@ -128,11 +128,12 @@ namespace {
if (pRect->GetWidth() > maxWidth) {
*pbOver = true;
break;
goto end_draw;
}
}
}
end_draw:
if (*pbOver && prStrPos) {
*pRect = prMaxRect;
return prStrPos - str;
@@ -222,7 +223,7 @@ namespace nw4r {
} else if (void* fontRes = resBlockSet.pResAccessor->GetResource('font', fontName, NULL)) {
if (void* pMemFont = Layout::AllocMemory(sizeof(ut::ResFont))) {
ut::ResFont* pResFont = new (pMemFont) ut::ResFont();
pResFont->SetResource(fontRes);
bool bSuccess = pResFont->SetResource(fontRes);
mpFont = pResFont;
mTextBoxFlag.allocFont = true;

View File

@@ -1,4 +1,31 @@
#include <nw4r/db/assert.h>
extern "C" const u8 scLytFatalColorR;
extern "C" const u8 scLytFatalColorG;
extern "C" const u8 scLytFatalColorB;
extern "C" const u8 scLytFatalColorA;
extern "C" char scLytFatalMsg[] = "Error#004\nAn error has occurred.\nThe system files are corrupted.";
#undef NW4R_ASSERT
#define NW4R_GLOBAL_ASSERT(x) \
{ \
if (!(x)) { \
GXColor front = {*((volatile const u8*)&::scLytFatalColorR), *((volatile const u8*)&::scLytFatalColorG), \
*((volatile const u8*)&::scLytFatalColorB), *((volatile const u8*)&::scLytFatalColorA)}; \
GXColor back = {0, 0, 0, 0}; \
OSFatal(front, back, ::scLytFatalMsg); \
} \
}
#define NW4R_ASSERT(x) \
{ \
if (!(x)) { \
GXColor front = {255, 255, 255, 0}; \
GXColor back = {0, 0, 0, 0}; \
OSFatal(front, back, ::scLytFatalMsg); \
} \
}
#include <nw4r/lyt/window.h>
#include <nw4r/lyt/common.h>
@@ -11,33 +38,6 @@
#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[];
#undef NW4R_ASSERT
// MWCC needs byte loads from the named color constants instead of folding their values.
#define NW4R_GLOBAL_ASSERT(x) \
{ \
if (!(x)) { \
GXColor front = {*((volatile const u8*)&::scLytFatalColorR), *((volatile const u8*)&::scLytFatalColorG), \
*((volatile const u8*)&::scLytFatalColorB), *((volatile const u8*)&::scLytFatalColorA)}; \
GXColor back = {0, 0, 0, 0}; \
OSFatal(front, back, ::scLytFatalMsg); \
} \
}
#define NW4R_ASSERT(x) \
{ \
if (!(x)) { \
GXColor front = {255, 255, 255, 0}; \
GXColor back = {0, 0, 0, 0}; \
OSFatal(front, back, ::scLytFatalMsg); \
} \
}
namespace nw4r {
namespace lyt {
NW4R_UT_GET_DERIVED_RUNTIME_TYPEINFO(Window, Pane);
@@ -174,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) {
@@ -402,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

@@ -36,9 +36,8 @@ namespace nw4r {
return instance;
}
// MWCC needs IRO 0 to recompute voice addresses inside the initialization loop.
#pragma push
#pragma ppc_iro_level 0
#pragma ppc_iro_level 0 // uh
void AxManager::Init() {
if (mInitialized) {
return;

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

@@ -20,24 +20,25 @@ namespace nw4r {
const HeaderedGlyphGroups* pGlgr;
const ArchiveFontBinaryLayout* font;
u16 countName, countSheet, countCWDH, countCMAP;
u16 countName, countSheet, count0A, count0C;
u32 stepSheets, stepCWDH, stepCMAP;
u32 stepSheets, step0A, step0C;
u32 dataSheetsOff, dataCWDHOff, dataCMAPOff;
const u32* dataCWDH;
const u32* dataCMAP;
u32 dataSheetsOff, data0AOff, data0COff;
const u32* dataSheets;
const u32* data0A;
const u32* data0C;
u32 flagsSheetsOff, flagsCWDHOff, flagsCMAPOff;
u32 flagsSheetsOff, flags0AOff, flags0COff;
const u32* flagsSheets;
const u32* flagsCWDH;
const u32* flagsCMAP;
const u32* flags0A;
const u32* flags0C;
int i;
int entryI;
const HeaderedGlyphGroups* groupHeaderCursor;
const HeaderedGlyphGroups* offsetPGlgr;
const u8* offsetFlags;
u32 loadedSheetCount, loadedCWDHSize, loadedCMAPSize;
u32 loadedSheetCount, loadedSmth0ASize, loadedSmth0CSize;
u32 flagWord;
const char* groupName;
const u32* offsetData;
@@ -48,10 +49,11 @@ namespace nw4r {
u32 neededCharacterSize;
u32 baseSize;
// MWCC needs this widened CMAP count for the original temporary allocation.
u32 cmapCountForLayout;
u32 count0CWork;
u32 loadedCharacterSize;
u32& neededCharacterSizeRef = neededCharacterSize;
u32 loadedSizeRef;
u32 groupOffset;
@@ -59,98 +61,107 @@ namespace nw4r {
return 0;
}
font = static_cast<const ArchiveFontBinaryLayout*>(fontData);
font = (ArchiveFontBinaryLayout*)fontData;
pGlgr = &font->glgr;
countName = pGlgr->inner.nameCount;
countSheet = pGlgr->inner.sheetCount;
countCWDH = pGlgr->inner.cwdhCount;
countCMAP = pGlgr->inner.cmapCount;
cmapCountForLayout = countCMAP;
count0A = pGlgr->inner.smthCount_0x0a;
count0C = pGlgr->inner.smthCount_0x0c;
count0CWork = count0C;
stepSheets = ((s32)countSheet + 0x1f) / 32 * 4;
stepCWDH = ((s32)countCWDH + 0x1f) / 32 * 4;
stepCMAP = ((s32)cmapCountForLayout + 0x1f) / 32 * 4;
step0A = ((s32)count0A + 0x1f) / 32 * 4;
step0C = ((s32)count0CWork + 0x1f) / 32 * 4;
dataSheetsOff = ROUNDUP(offsetof(ArchiveFontBinaryLayout, glgr.inner.nameOffsets) + countName * sizeof(u16), 4);
dataCWDHOff = ROUNDUP(dataSheetsOff + countSheet * sizeof(u32), 4);
dataCMAPOff = ROUNDUP(dataCWDHOff + countCWDH * sizeof(u32), 4);
dataCWDH = (const u32*)(dataCWDHOff + (u32)fontData);
dataCMAP = (const u32*)(dataCMAPOff + (u32)fontData);
data0AOff = ROUNDUP(dataSheetsOff + countSheet * sizeof(u32), 4);
data0COff = ROUNDUP(data0AOff + count0A * sizeof(u32), 4);
dataSheets = (const u32*)((u32)dataSheetsOff + (u32)fontData);
data0A = (const u32*)((u32)data0AOff + (u32)fontData);
data0C = (const u32*)((u32)data0COff + (u32)fontData);
flagsSheetsOff = ROUNDUP(dataCMAPOff + cmapCountForLayout * sizeof(u32), 4);
flagsCWDHOff = ROUNDUP(flagsSheetsOff + stepSheets * countName, 4);
flagsCMAPOff = ROUNDUP(flagsCWDHOff + stepCWDH * countName, 4);
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);
flagsCWDH = (const u32*)(flagsCWDHOff + (u32)fontData);
flagsCMAP = (const u32*)(flagsCMAPOff + (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;
loadedCWDHSize = 0;
loadedCMAPSize = 0;
loadedSmth0ASize = 0;
loadedSmth0CSize = 0;
// Get the NUMBER of sheets that should be loaded
for (i = 0, entryI = 0; entryI < pGlgr->inner.sheetCount; entryI += 0x20, i++) {
offsetFlags = (const u8*)flagsSheets + i * sizeof(u32);
flagWord = 0;
// MWCC needs the header as the induction base for the name-offset loads.
for (j = 0, groupHeaderCursor = pGlgr; j < pGlgr->inner.nameCount;
groupHeaderCursor = (const HeaderedGlyphGroups*)((const u8*)groupHeaderCursor + 2), j++) {
groupName = (const char*)((u32)groupHeaderCursor->inner.nameOffsets[0] + (u32)fontData);
for (j = 0, offsetPGlgr = pGlgr; j < pGlgr->inner.nameCount;
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));
}
}
loadedSheetCount += math::CntBit1(flagWord);
}
// getLoadedSheetCount(pGlgr, flagsSheets, stepSheets, fontData, includedGroups, &loadedSheetCount);
for (i = 0; i * 32 < pGlgr->inner.cwdhCount; i++) {
offsetFlags = (const u8*)flagsCWDH + i * sizeof(u32);
// Get the SIZE of unk_0x0a that should be loaded
for (i = 0; i * 32 < pGlgr->inner.smthCount_0x0a; i++) {
offsetFlags = (const u8*)flags0A + i * sizeof(u32);
flagWord = 0;
for (j = 0; j < pGlgr->inner.nameCount; j++) {
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 * stepCWDH, 4));
flagWord |= *(const u32*)((const u8*)offsetFlags + ROUNDDOWN(j * step0A, 4));
}
}
offsetData = dataCWDH + i * 32;
offsetData = (const u32*)data0A + i * 32;
for (j = 0; j < 32; j++) {
if ((flagWord << j) & 0x80000000U) {
loadedCWDHSize += offsetData[j] - sizeof(BinaryBlockHeader);
loadedSmth0ASize += offsetData[j] - sizeof(BinaryBlockHeader);
}
}
}
for (i = 0; i * 32 < pGlgr->inner.cmapCount; i++) {
offsetFlags = (const u8*)flagsCMAP + i * sizeof(u32);
// Get the SIZE of unk_0x0C that should be loaded
for (i = 0; i * 32 < pGlgr->inner.smthCount_0x0c; i++) {
offsetFlags = (const u8*)flags0C + i * sizeof(u32);
flagWord = 0;
for (j = 0; j < pGlgr->inner.nameCount; j++) {
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 * stepCMAP, 4));
flagWord |= *(const u32*)((const u8*)offsetFlags + ROUNDDOWN(j * step0C, 4));
}
}
offsetData = dataCMAP + i * 32;
offsetData = (const u32*)data0C + i * 32;
for (j = 0; j < 32; j++) {
if ((flagWord << j) & 0x80000000U) {
loadedCMAPSize += offsetData[j] - sizeof(BinaryBlockHeader);
loadedSmth0CSize += offsetData[j] - sizeof(BinaryBlockHeader);
}
}
}
// Calculate the final buffer size based on the three previously
// accessed components
sheetOffsetsSize = ROUNDUP(pGlgr->inner.sheetCount * 2, 4);
loadedSheetsSize = ROUNDUP(loadedSheetCount * pGlgr->inner.uncompSheetSize, 4);
loadedCharacterSize = loadedCWDHSize + loadedCMAPSize;
neededCharacterSize = ut::Max<u32>(loadedCharacterSize, sizeof(CXUncompContextHuffman));
loadedSizeRef = loadedSmth0ASize + loadedSmth0CSize;
neededCharacterSizeRef = sizeof(CXUncompContextHuffman);
if (loadedSizeRef >= sizeof(CXUncompContextHuffman)) {
neededCharacterSize = loadedSizeRef;
}
baseSize = OSRoundUp32B(sizeof(FontInformation) + sizeof(FontTextureGlyph) + sheetOffsetsSize);
return (baseSize + loadedSheetsSize) + neededCharacterSize;

View File

@@ -74,6 +74,16 @@ namespace nw4r {
}
}
// u32 ArchiveFontBase::ConstructContext::updateTextureBlockPtr() {
// u32 imgDataOffset;
// imgDataOffset = (u32)pFontInfo->pGlyph->sheetImage;
// pWorkCurr = (u8*)ROUNDUP((u32)pWorkCurr, 0x20);
// pFontInfo->pGlyph->sheetImage = pWorkCurr;
// return imgDataOffset;
// }
ArchiveFontBase::ArchiveFontBase() : pSheetOffsets(NULL) {
}
@@ -116,6 +126,24 @@ namespace nw4r {
return false;
}
// Check that there is nothing but spaces between the substr
// and the preceeding comma
// - Fails:
// - groupList = "foo, BAD bar, baz"
// - substr ^
// - Succeeds:
// - groupList = "foo, bar, baz"
// - substr ^
// - Succeeds:
// - groupList = "foo,bar,baz"
// - substr ^
// - Succeeds:
// - groupList = "foo,bar,baz"
// - substr ^
// - Fails (I think this is a bug):
// - groupList = " foo, bar, baz"
// - substr ^
// @bug Should allow for leading spaces in groupList (maybe?)
if (substr != groupList) {
const char* backsearchStr = substr - 1;
while (backsearchStr > groupList && *backsearchStr == ' ') {
@@ -126,6 +154,11 @@ namespace nw4r {
}
}
// Get the length of the section up until the next comma or
// the end
// - substr = "foo bar, baz" -> sectionLen = 7
// - substr = "foo , baz" -> sectionLen = 11
// - substr = "foo" -> sectionLen = 3
const char* nextComma = strchr(substr, ',');
u32 sectionLen;
if (nextComma != NULL) {
@@ -134,6 +167,17 @@ namespace nw4r {
sectionLen = strlen(substr);
}
// Check to make sure there is nothing except spaces between
// the end of the group name and the next comma:
// - Fails:
// - substr = "foo bar, baz"
// - group = "foo"
// - Succeeds:
// - substr = "foo , baz"
// - group = "foo"
// - Succeeds:
// - substr = "foo, baz"
// - group = "foo"
const char* sectionEnd = substr + groupLen;
while (sectionEnd < substr + sectionLen && (*sectionEnd == ' ')) {
sectionEnd++;
@@ -269,6 +313,11 @@ namespace nw4r {
ctx->pSheetOffsets = (u16*)sheetOffsets;
}
// inline u32 getOffsetSize(void* fontData, u32 remWorkSpace, u16 countSheet, u16** sheetOffsetsScratch) {
// u32 sheetOffsetsSize = ROUNDUP(countSheet * sizeof(u16), 4);
// *sheetOffsetsScratch = (u16*)ROUNDDOWN((u32)((u8*)fontData + remWorkSpace) - sheetOffsetsSize, 2);
// return sheetOffsetsSize;
// }
class FontGlyphGroupsAcs {
public:
explicit FontGlyphGroupsAcs(const ArchiveFontBinaryLayout* font)
@@ -344,8 +393,8 @@ namespace nw4r {
dataBlockCount = font->hdr.dataBlocks;
countSheet = gg.GetNumSheet();
const u32 stepSheetFlags = detail::CalcSizeFlagSet(countSheet);
flagsSheetsOff = detail::CalcOffsetSheetFlags(gg.GetGroups().nameCount, countSheet, gg.GetGroups().cwdhCount,
gg.GetGroups().cmapCount);
flagsSheetsOff = detail::CalcOffsetSheetFlags(gg.GetGroups().nameCount, countSheet, gg.GetGroups().smthCount_0x0a,
gg.GetGroups().smthCount_0x0c);
flagsSheets = (const u32*)((flagsSheetsOff & ~3) + (u32)font);
gg.SetSheetFlags(stepSheetFlags, flagsSheets);

View File

@@ -343,7 +343,7 @@ void RFLSetExpression(RFLCharModel* charModel, RFLExpression expression) {
}
RFLExpression RFLGetExpression(const RFLCharModel* charModel) {
const RFLiCharModel* charModel_ = (const RFLiCharModel*)charModel;
const RFLiCharModel* charModel_ = (RFLiCharModel*)charModel;
RFLi_ASSERTLINE_NULL(charModel, 499);
@@ -351,7 +351,7 @@ RFLExpression RFLGetExpression(const RFLCharModel* charModel) {
}
BOOL RFLIsAvailableExpression(const RFLCharModel* charModel, RFLExpression expression) {
const RFLiCharModel* charModel_ = (const RFLiCharModel*)charModel;
const RFLiCharModel* charModel_ = (RFLiCharModel*)charModel;
RFLi_ASSERTLINE_NULL(charModel, 518);
@@ -459,13 +459,13 @@ void RFLLoadMaterialSetting(const RFLDrawCoreSetting* setting) {
}
void RFLDrawOpaCore(const RFLCharModel* charModel, const RFLDrawCoreSetting* setting) {
const RFLiCharModel* charModel_ = (const RFLiCharModel*)charModel;
const RFLiCharModel* charModel_ = (RFLiCharModel*)charModel;
const RFLiCharModelRes* charModelRes;
RFLi_ASSERTLINE_NULL(charModel, 760);
RFLi_ASSERTLINE_NULL(setting, 761);
charModelRes = (const RFLiCharModelRes*)charModel_->resource;
charModelRes = (RFLiCharModelRes*)charModel_->resource;
GXSetTevAlphaIn(GX_TEVSTAGE0, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO, GX_CA_KONST);
@@ -550,13 +550,13 @@ void RFLDrawOpaCore(const RFLCharModel* charModel, const RFLDrawCoreSetting* set
}
void RFLDrawXluCore(const RFLCharModel* charModel, const RFLDrawCoreSetting* setting) {
const RFLiCharModel* charModel_ = (const RFLiCharModel*)charModel;
const RFLiCharModel* charModel_ = (RFLiCharModel*)charModel;
const RFLiCharModelRes* charModelRes;
RFLi_ASSERTLINE_NULL(charModel, 897);
RFLi_ASSERTLINE_NULL(setting, 898);
charModelRes = (const RFLiCharModelRes*)charModel_->resource;
charModelRes = (RFLiCharModelRes*)charModel_->resource;
GXSetTevOrder(GX_TEVSTAGE0, setting->txcID, setting->texMapID, GX_COLOR_NULL);
GXSetTevAlphaIn(GX_TEVSTAGE0, GX_CA_ZERO, GX_CA_ZERO, GX_CA_ZERO, GX_CA_TEXA);
@@ -1127,7 +1127,7 @@ void RFLiTransformCoordinate(s16* to, const s16* from) {
}
void RFLDrawShape(const RFLCharModel* charModel) {
const RFLiCharModel* charModel_ = (const RFLiCharModel*)charModel;
const RFLiCharModel* charModel_ = (RFLiCharModel*)charModel;
const RFLiCharModelRes* res;
GXCullMode cullMode;

View File

@@ -318,7 +318,6 @@ s32 RFLGetLastReason() {
}
RFLErrcode RFLWaitAsync() {
/* MWCC needs the status spill and reload on each polling iteration. */
volatile RFLErrcode errcode;
do {
errcode = RFLGetAsyncStatus();

View File

@@ -1,28 +1,6 @@
#include <string.h>
#include <tmc_jpeg_internal.h>
static inline s32 finishImageStart(TMCCJPEGDecWork* work, s32 result) {
if (result < 0) {
return result;
}
if (work->frameWidth == 0) {
return TMCC_ERROR_HEADER;
}
work->mcuCount = work->mcuXCount * work->mcuYCount;
work->mcuRemCount = work->mcuXRem * work->mcuXCount2;
return result;
}
static inline s32 finishScanStart(TMCCJPEGDecWork* work, s32 result) {
if (result < 0) {
return result;
}
if (work->scanCount == 1) {
return 0;
}
return result;
}
s32 TMCCJPEGDecInit(TMCCJPEGDecState* state, TMCCJPEGDecInitParam* param) {
s32 result;
TMCCJPEGDecWork* work;
@@ -59,13 +37,17 @@ s32 TMCCJPEGDecInit(TMCCJPEGDecState* state, TMCCJPEGDecInitParam* param) {
}
result = TMCJPEGDEC_imagestart(work);
result = finishImageStart(work, result);
result = (result < 0) ?
result :
((work->frameWidth == 0) ?
TMCC_ERROR_HEADER :
((work->mcuCount = work->mcuXCount * work->mcuYCount, work->mcuRemCount = work->mcuXRem * work->mcuXCount2), result));
if (result < 0) {
goto error;
}
result = TMCJPEGDEC_scanstart(work);
result = finishScanStart(work, result);
result = (result < 0) ? result : ((work->scanCount == 1) ? 0 : result);
if (result < 0) {
goto error;
}

View File

@@ -10,12 +10,9 @@ static TMCHuffmanEntry readHuffmanEntry(const TMCHuffmanEntry* entries, u32 inde
return entries[index];
}
static inline BOOL exceedsHuffmanLimit(u32 code, const u16* entry, TMCHuffmanEntry* limit, TMCHuffmanEntry* decoded) {
limit->bitLength = entry[0];
limit->symbol = entry[1];
/* MWCC needs the entry copy before reloading its bit length. */
*decoded = *limit;
return code > decoded->bitLength;
static void readHuffmanLimit(const TMCHuffmanEntry* entries, TMCHuffmanEntry* limit) {
limit->bitLength = entries->bitLength;
limit->symbol = entries->symbol;
}
static inline s32 decodeLongHuffman(s32 bitCount, u32* huff_tbl, u8* symbols, TMCCJPEGDecWork* work, TMCHuffmanEntry* limit, TMCHuffmanEntry* decoded) {
@@ -37,7 +34,8 @@ static inline s32 decodeLongHuffman(s32 bitCount, u32* huff_tbl, u8* symbols, TM
bitCount -= 9;
code = (bitData >> bitCount) & 0x1FF;
work->bitCount = bitCount;
while (exceedsHuffmanLimit(code, entry, limit, decoded)) {
goto read_entry;
while (1) {
length++;
entry += 2;
if (length > 16) {
@@ -49,11 +47,69 @@ static inline s32 decodeLongHuffman(s32 bitCount, u32* huff_tbl, u8* symbols, TM
bitCount--;
work->bitCount = bitCount;
code |= (bitData >> bitCount) & 1;
read_entry:
{
limit->bitLength = entry[0];
limit->symbol = entry[1];
*decoded = *limit;
if (code > decoded->bitLength) {
continue;
}
{
u32 relativeCode = code - limit->bitLength;
u32 symbolIndex = relativeCode + limit->symbol;
return symbols[symbolIndex & 0xFF];
}
}
}
{
u32 relativeCode = code - limit->bitLength;
u32 symbolIndex = relativeCode + limit->symbol;
return symbols[symbolIndex & 0xFF];
}
static inline s32 decodeACHuffman(s32 bitCount, u32* huff_tbl, u8* symbols, TMCCJPEGDecWork* work, TMCHuffmanEntry* limit, TMCHuffmanEntry* decoded) {
u16* entry;
u32 bitData;
u32 code;
u32 length;
if (bitCount <= 17) {
s32 result = TMCJPEGDEC_load_buff(work);
if (result < 0) {
return result;
}
}
bitCount = work->bitCount;
entry = (u16*)(huff_tbl + 9);
bitData = work->bitBuf;
length = 9;
bitCount -= 9;
code = (bitData >> bitCount) & 0x1FF;
work->bitCount = bitCount;
goto read_entry;
while (1) {
length++;
entry += 2;
if (length > 16) {
return TMCC_ERROR_OVERFLOW;
}
bitCount = work->bitCount;
code <<= 1;
bitData = work->bitBuf;
bitCount--;
work->bitCount = bitCount;
code |= (bitData >> bitCount) & 1;
read_entry:
{
limit->bitLength = entry[0];
limit->symbol = entry[1];
*decoded = *limit;
if (code > decoded->bitLength) {
continue;
}
{
u32 relativeCode = code - limit->bitLength;
u32 symbolIndex = relativeCode + limit->symbol;
return symbols[symbolIndex & 0xFF];
}
}
}
}
@@ -169,7 +225,7 @@ s32 TMCJPEGDEC_decode_iquant(s32* block, u8* conv_row_ptr, u32* dc_predict_row_p
r = acEntry.symbol;
} else {
bit_pos = work->bitCount;
r = decodeLongHuffman(bit_pos, ac_huff_tbl, ac_huff_sym, work, &acLimit, &acDecoded);
r = decodeACHuffman(bit_pos, ac_huff_tbl, ac_huff_sym, work, &acLimit, &acDecoded);
if (r < 0) {
return r;
}

View File

@@ -84,139 +84,157 @@ s32 TMCJPEGDEC_get_byte(u8* dst, TMCCJPEGDecWork* work) {
}
s32 TMCJPEGDEC_get_wbyte(u16* dst, TMCCJPEGDecWork* work) {
u8 byte;
u32 highByte;
s32 result;
u8 byte_val;
u32 byte_shifted;
s32 r;
u8* cur;
u8* end;
u8* next;
// MWCC needs the empty else branches to preserve refill branch direction.
do {
if (work->pBufCur >= work->pBufEnd) {
if (work->remaining != 0) {
result = refillJpegBuffer(work);
if (result < 0) {
break;
} else {
}
if (work->pBufCur >= work->pBufEnd) {
if (work->remaining != 0) {
r = refillJpegBuffer(work);
if (r < 0) {
goto br;
} else {
result = TMCC_ERROR_UNDERFLOW;
break;
// This else-branch is load-bearing...
// Forces bge instead of blt.
}
} else {
r = TMCC_ERROR_UNDERFLOW;
goto br;
}
{
u8* bufferCursor = work->pBufCur;
end = work->pBufEnd;
cur = bufferCursor;
next = bufferCursor + 1;
}
work->pBufCur = next;
byte = *cur;
if (next >= end) {
if (work->remaining != 0) {
result = refillJpegBuffer(work);
if (result < 0) {
break;
} else {
}
} else {
result = TMCC_ERROR_UNDERFLOW;
break;
}
}
result = 0;
} while (0);
highByte = (u32)byte << 8;
if (result < 0) {
return result;
}
do {
if (work->pBufCur >= work->pBufEnd) {
if (work->remaining != 0) {
result = refillJpegBuffer(work);
if (result < 0) {
break;
} else {
}
} else {
result = TMCC_ERROR_UNDERFLOW;
break;
}
}
cur = work->pBufCur;
{
u8* tmp = work->pBufCur;
end = work->pBufEnd;
next = cur + 1;
work->pBufCur = next;
byte = *cur;
if (next >= end) {
if (work->remaining != 0) {
result = refillJpegBuffer(work);
if (result < 0) {
break;
} else {
}
} else {
result = TMCC_ERROR_UNDERFLOW;
break;
}
cur = tmp;
next = tmp + 1;
}
work->pBufCur = next;
byte_val = *cur;
if (next < end) {
goto o1;
}
if (work->remaining != 0) {
r = refillJpegBuffer(work);
if (r >= 0) {
goto o1;
}
result = 0;
} while (0);
*dst = highByte + byte;
return result < 0 ? result : 0;
goto br;
} else {
r = TMCC_ERROR_UNDERFLOW;
goto br;
}
o1:
r = 0;
br:
byte_shifted = (u32)byte_val << 8;
if (r >= 0) {
goto p2;
}
return r;
p2:
if (work->pBufCur < work->pBufEnd) {
goto r2;
}
if (work->remaining != 0) {
r = refillJpegBuffer(work);
if (r < 0)
goto ez;
else {
// ...
}
} else {
r = TMCC_ERROR_UNDERFLOW;
goto ez;
}
r2:
cur = work->pBufCur;
end = work->pBufEnd;
next = cur + 1;
work->pBufCur = next;
byte_val = *cur;
if (next < end) {
goto o2;
}
if (work->remaining != 0) {
r = refillJpegBuffer(work);
if (r < 0)
goto ez;
else {
// ...
}
} else {
r = TMCC_ERROR_UNDERFLOW;
goto ez;
}
o2:
r = 0;
ez:
*dst = byte_shifted + byte_val;
return r < 0 ? r : 0;
}
s32 TMCJPEGDEC_get_sbyte(u8* dst, u32 count, TMCCJPEGDecWork* work) {
int result = 0;
int r = 0;
u32 i;
u8 byte;
u8* cur;
for (i = 0; i < count; i++) {
// MWCC needs the empty else branches to preserve refill branch direction.
do {
if (work->pBufCur >= work->pBufEnd) {
if (work->remaining != 0) {
result = refillJpegBuffer(work);
if (result < 0) {
break;
} else {
}
if (work->pBufCur >= work->pBufEnd) {
if (work->remaining != 0) {
r = refillJpegBuffer(work);
if (r < 0) {
goto copy_byte;
} else {
result = TMCC_ERROR_UNDERFLOW;
break;
// This else-branch is load-bearing...
// Forces bge instead of blt.
}
} else {
r = TMCC_ERROR_UNDERFLOW;
goto copy_byte;
}
}
cur = work->pBufCur;
work->pBufCur += 1;
byte = *cur;
cur = work->pBufCur;
work->pBufCur += 1;
byte = *cur;
if (work->pBufCur >= work->pBufEnd) {
if (work->remaining != 0) {
result = refillJpegBuffer(work);
if (result < 0) {
break;
} else {
}
} else {
result = TMCC_ERROR_UNDERFLOW;
break;
}
if (work->pBufCur < work->pBufEnd) {
goto r0;
}
if (work->remaining != 0) {
r = refillJpegBuffer(work);
if (r >= 0) {
goto r0;
}
result = 0;
} while (0);
goto copy_byte;
} else {
r = TMCC_ERROR_UNDERFLOW;
goto copy_byte;
}
r0:
r = 0;
copy_byte:
*dst = byte;
dst++;
if (result < 0)
return result;
if (r < 0)
return r;
}
return 0;
}
@@ -225,41 +243,51 @@ s32 TMCJPEGDEC_move_ptr(s32 offset, TMCCJPEGDecWork* work) {
s32 avail;
s32 r;
if (offset >= 0) {
while (work->pBufEnd - work->pBufCur <= offset) {
avail = work->pBufEnd - work->pBufCur;
offset -= avail;
if (work->remaining != 0) {
r = refillJpegBuffer(work);
if (r >= 0) {
continue;
}
return r;
} else {
return TMCC_ERROR_UNDERFLOW;
}
}
work->pBufCur += offset;
if (work->pBufEnd > work->pBufCur) {
goto done;
}
if (work->remaining != 0) {
r = refillJpegBuffer(work);
if (r >= 0) {
goto done;
}
return r;
} else {
return TMCC_ERROR_UNDERFLOW;
}
} else {
offset = -offset;
if (work->pBufCur - work->pBufStart < offset) {
return TMCC_ERROR_UNDERFLOW;
}
work->pBufCur -= offset;
if (offset < 0) {
goto ng;
}
done:
goto lc;
lp:
offset -= avail;
if (work->remaining == 0) {
goto er1;
}
r = refillJpegBuffer(work);
if (r >= 0) {
goto lc;
}
return r;
er1:
return TMCC_ERROR_UNDERFLOW;
lc:
avail = work->pBufEnd - work->pBufCur;
if (avail <= offset) {
goto lp;
}
work->pBufCur += offset;
if (work->pBufEnd > work->pBufCur) {
goto ret0;
}
if (work->remaining == 0) {
goto er2;
}
r = refillJpegBuffer(work);
if (r >= 0) {
goto ret0;
}
return r;
er2:
return TMCC_ERROR_UNDERFLOW;
ng:
offset = -offset;
if (work->pBufCur - work->pBufStart < offset) {
return TMCC_ERROR_UNDERFLOW;
}
work->pBufCur -= offset;
ret0:
return 0;
}
@@ -286,45 +314,47 @@ s32 TMCJPEGDEC_load_buff(TMCCJPEGDecWork* work) {
work->bitBuf = bitBuf;
work->bitCount = bitCount;
work->pBufCur = cur;
} else {
do {
if (work->pBufEnd <= work->pBufCur) {
if (work->remaining == 0) {
break;
}
r = refillJpegBufferAfterFF(work);
if (r < 0) {
return r;
}
}
{
u32 bb = work->bitBuf;
u8* c = work->pBufCur;
u8* next;
u8 byte = *c;
next = c + 1;
work->pBufCur = next;
work->bitBuf = (bb << 8) + byte;
work->bitCount += 8;
if (byte == 0xFF) {
work->pBufCur = next + 1;
}
}
if (work->pBufEnd <= work->pBufCur) {
if (work->remaining == 0) {
break;
}
r = refillJpegBufferAfterFF(work);
if (r < 0) {
return r;
}
}
} while (work->bitCount <= 24);
goto ret;
}
do {
if (work->pBufEnd <= work->pBufCur) {
if (work->remaining == 0) {
break;
}
r = refillJpegBufferAfterFF(work);
if (r < 0) {
return r;
}
}
{
u32 bb = work->bitBuf;
u8* c = work->pBufCur;
u8* next;
u8 byte = *c;
next = c + 1;
work->pBufCur = next;
work->bitBuf = (bb << 8) + byte;
work->bitCount += 8;
if (byte == 0xFF) {
work->pBufCur = next + 1;
}
}
if (work->pBufEnd <= work->pBufCur) {
if (work->remaining == 0) {
break;
}
r = refillJpegBufferAfterFF(work);
if (r < 0) {
return r;
}
}
} while (work->bitCount <= 24);
ret:
return 0;
}

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

@@ -1127,7 +1127,7 @@ s32 TMCJPEGDEC_err_restart(TMCCJPEGDecWork* work) {
state->posY = div;
state->position = TMCJPEGDEC_get_position(work);
return state->result - (state->posY * state->maxX) - state->posX;
return state->result - (state->posY * state->maxX) - state->posY;
}
}
#endif

View File

@@ -2,18 +2,6 @@
extern void* memset(void* dest, int value, unsigned long size);
typedef struct {
u16 bitLength;
u16 symbol;
} TMCHuffmanEntry;
static inline BOOL exceedsHuffmanLimit(u32 code, const u16* entry, TMCHuffmanEntry* limit, TMCHuffmanEntry* decoded) {
*limit = *(const TMCHuffmanEntry*)entry;
/* MWCC needs the entry copy before reloading its bit length. */
*decoded = *limit;
return code > decoded->bitLength;
}
static s32 TMCJPEGDEC_vl_decode_rc(u32* huff_tbl, u8* huff_sym, TMCCJPEGDecWork* work);
static inline s32 readCoefficientBits(TMCCJPEGDecWork* work, s32 count) {
@@ -162,8 +150,6 @@ static s32 TMCJPEGDEC_vl_decode_rc(u32* huff_tbl, u8* huff_sym, TMCCJPEGDecWork*
u32 code;
unsigned int i;
s32 r;
TMCHuffmanEntry limit;
TMCHuffmanEntry decoded;
bit_pos = work->bitCount;
@@ -182,7 +168,9 @@ static s32 TMCJPEGDEC_vl_decode_rc(u32* huff_tbl, u8* huff_sym, TMCCJPEGDecWork*
code = (bit_data >> bit_pos) & 0x1FF;
work->bitCount = bit_pos;
while (exceedsHuffmanLimit(code, entry, &limit, &decoded)) {
goto entry_check;
do {
i++;
entry += 2;
if (i > 16) {
@@ -195,11 +183,24 @@ static s32 TMCJPEGDEC_vl_decode_rc(u32* huff_tbl, u8* huff_sym, TMCCJPEGDecWork*
bit_pos--;
work->bitCount = bit_pos;
code |= (bit_data >> bit_pos) & 1;
}
{
s32 relativeCode = code - limit.bitLength;
code = relativeCode + (u32)limit.symbol;
entry_check: {
typedef struct {
u16 t;
u16 o;
} HuffEnt;
HuffEnt local = *(HuffEnt*)entry;
u32 combined = *(u32*)&local;
u16 th = *(u16*)&combined;
s32 tmp;
if (code > th) {
continue;
}
tmp = code - local.t;
code = tmp + (u32)local.o;
}
return huff_sym[code & 0xFF];
return huff_sym[code & 0xFF];
} while (1);
}

View File

@@ -14,38 +14,7 @@ static void TMCJPEGDEC_converterYUV444toRGB565edge(TMCCJPEGDecWork*, s32, s32);
static void TMCJPEGDEC_converterYUV400toRGB565(TMCCJPEGDecWork*, s32, s32);
static void TMCJPEGDEC_converterYUV400toRGB565edge(TMCCJPEGDecWork*, s32, s32);
/* MWCC needs level 1 to preserve the shared conversion-buffer base. */
#pragma push
#pragma optimization_level 1
s32 TMCJPEGDEC_set_converterRGB565(TMCCJPEGDecWork* work) {
u8 mode411;
u8* crBlock411;
u8* cbBlock411;
u8* fourthRow411;
u8* thirdRow411;
u8* secondRow411;
u8* firstRow411;
TMCConverterFunc* edgeConverter411;
TMCConverterFunc* converter411;
u8 mode422;
u8* crBlock422;
u8* cbBlock422;
u8* secondRow422;
u8* firstRow422;
TMCConverterFunc* edgeConverter422;
TMCConverterFunc* converter422;
u8 mode420;
u8* crBlock420;
u8* cbBlock420;
u8* fourthRow420;
u8* thirdRow420;
u8* secondRow420;
u8* firstRow420;
TMCConverterFunc* edgeConverter420;
TMCConverterFunc* converter420;
u8* buffer;
s32 componentCount;
TMCCJPEGDecState* state;
@@ -56,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;
@@ -143,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;
@@ -176,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,38 +14,7 @@ static void TMCJPEGDEC_converterYUV444toRGBA8edge(TMCCJPEGDecWork*, s32, s32);
static void TMCJPEGDEC_converterYUV400toRGBA8(TMCCJPEGDecWork*, s32, s32);
static void TMCJPEGDEC_converterYUV400toRGBA8edge(TMCCJPEGDecWork*, s32, s32);
/* MWCC needs level 1 to preserve the shared conversion-buffer base. */
#pragma push
#pragma optimization_level 1
s32 TMCJPEGDEC_set_converterRGBA8(TMCCJPEGDecWork* work) {
u8 mode411;
u8* crBlock411;
u8* cbBlock411;
u8* fourthRow411;
u8* thirdRow411;
u8* secondRow411;
u8* firstRow411;
TMCConverterFunc* edgeConverter411;
TMCConverterFunc* converter411;
u8 mode422;
u8* crBlock422;
u8* cbBlock422;
u8* secondRow422;
u8* firstRow422;
TMCConverterFunc* edgeConverter422;
TMCConverterFunc* converter422;
u8 mode420;
u8* crBlock420;
u8* cbBlock420;
u8* fourthRow420;
u8* thirdRow420;
u8* secondRow420;
u8* firstRow420;
TMCConverterFunc* edgeConverter420;
TMCConverterFunc* converter420;
u8* buffer;
s32 componentCount;
TMCCJPEGDecState* state;
@@ -56,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;
@@ -143,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;
@@ -176,129 +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
/* MWCC needs the full-width alpha addition before the halfword stores. */
static void TMCJPEGDEC_converterYUV411toRGBA8(TMCCJPEGDecWork* work, s32 x, s32 y) {
u16* output;
s32 tileRow;
s32 secondGreen;
s32 thirdGreen;
s32 fourthBlue;
s32 columnInTile;
s32 secondColumnInTile;
s32 thirdColumnInTile;
s32 fourthColumnInTile;
s32 red;
s32 secondBlue;
s32 thirdBlue;
s32 fourthGreen;
s32 green;
s32 secondRed;
s32 thirdRed;
s32 fourthRed;
u8* texture;
u8* luminance;
u8* cb;
u8* cr;
TMCCJPEGDecState* state;
u8* texture;
s32 height;
s32 column;
s32 xEnd;
s32 green;
s32 yEnd;
s32 tileWidth;
s32 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;
/* MWCC needs these assignments in the first store to preserve row-address scheduling. */
(output = (u16*)(texture + ((y & 3) << 3)))[
columnInTile + ((((column >> 2) << 1) +
(tileRow = (y >> 2) * tileWidth)) << 4)] = (u8)red + 0x10000 - 0x100;
output[columnInTile + ((((column >> 2) << 1) + (tileRow + 1)) << 4)] = ((green & 255) << 8) + (blue & 255);
value = *luminance++;
secondGreen = value + greenOffset;
secondRed = value + redOffset;
secondBlue = value + blueOffset;
if ((secondRed | secondGreen | secondBlue) >> 8) {
secondBlue = secondBlue > 255 ? 255 : secondBlue < 0 ? 0 : secondBlue;
secondGreen = secondGreen > 255 ? 255 : secondGreen < 0 ? 0 : secondGreen;
secondRed = secondRed > 255 ? 255 : secondRed < 0 ? 0 : secondRed;
}
secondColumnInTile = (column + 1) & 3;
output[secondColumnInTile + (((((column + 1) >> 2) << 1) + tileRow) << 4)] = (u8)secondRed + 0x10000 - 0x100;
output[secondColumnInTile + (((((column + 1) >> 2) << 1) + (tileRow + 1)) << 4)] = ((secondGreen & 255) << 8) + (secondBlue & 255);
value = *luminance++;
thirdGreen = value + greenOffset;
thirdRed = value + redOffset;
thirdBlue = value + blueOffset;
if ((thirdRed | thirdGreen | thirdBlue) >> 8) {
thirdBlue = thirdBlue > 255 ? 255 : thirdBlue < 0 ? 0 : thirdBlue;
thirdGreen = thirdGreen > 255 ? 255 : thirdGreen < 0 ? 0 : thirdGreen;
thirdRed = thirdRed > 255 ? 255 : thirdRed < 0 ? 0 : thirdRed;
}
thirdColumnInTile = (column + 2) & 3;
output[thirdColumnInTile + (((((column + 2) >> 2) << 1) + tileRow) << 4)] = (u8)thirdRed + 0x10000 - 0x100;
output[thirdColumnInTile + (((((column + 2) >> 2) << 1) + (tileRow + 1)) << 4)] = ((thirdGreen & 255) << 8) + (thirdBlue & 255);
value = *luminance++;
fourthGreen = value + greenOffset;
fourthRed = value + redOffset;
fourthBlue = value + blueOffset;
if ((fourthRed | fourthGreen | fourthBlue) >> 8) {
fourthBlue = fourthBlue > 255 ? 255 : fourthBlue < 0 ? 0 : fourthBlue;
fourthGreen = fourthGreen > 255 ? 255 : fourthGreen < 0 ? 0 : fourthGreen;
fourthRed = fourthRed > 255 ? 255 : fourthRed < 0 ? 0 : fourthRed;
}
fourthColumnInTile = (column + 3) & 3;
output[fourthColumnInTile + (((((column + 3) >> 2) << 1) + tileRow) << 4)] = (u8)fourthRed + 0x10000 - 0x100;
output[fourthColumnInTile + (((((column + 3) >> 2) << 1) + (tileRow + 1)) << 4)] = ((fourthGreen & 255) << 8) + (fourthBlue & 255);
luminance += lumaSkip;
cb += chromaSkip;
cr += chromaSkip;
}
luminance += (32 - width);
cb += ((32 - width) >> 2);
cr += ((32 - width) >> 2);
}
}

View File

@@ -14,38 +14,7 @@ static void TMCJPEG_814F32E4(TMCCJPEGDecWork*, s32, s32);
static void TMCJPEG_814F34A4(TMCCJPEGDecWork*, s32, s32);
static void TMCJPEG_814F372C(TMCCJPEGDecWork*, s32, s32);
/* MWCC needs level 1 to preserve the shared conversion-buffer base. */
#pragma push
#pragma optimization_level 1
s32 TMCJPEGDEC_set_converterY8U8V8(TMCCJPEGDecWork* work) {
u8 mode411;
u8* crBlock411;
u8* cbBlock411;
u8* fourthRow411;
u8* thirdRow411;
u8* secondRow411;
u8* firstRow411;
TMCConverterFunc* edgeConverter411;
TMCConverterFunc* converter411;
u8 mode422;
u8* crBlock422;
u8* cbBlock422;
u8* secondRow422;
u8* firstRow422;
TMCConverterFunc* edgeConverter422;
TMCConverterFunc* converter422;
u8 mode420;
u8* crBlock420;
u8* cbBlock420;
u8* fourthRow420;
u8* thirdRow420;
u8* secondRow420;
u8* firstRow420;
TMCConverterFunc* edgeConverter420;
TMCConverterFunc* converter420;
u8* buffer;
s32 componentCount;
TMCCJPEGDecState* state;
@@ -56,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;
@@ -143,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;
@@ -176,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);
@@ -213,7 +213,6 @@ Zi8UInt Zi8SpellingZY(ziU16 *output,Zi8UInt key,ziU8 includeTone)
initialIndex = (ziU16)(((key & 0xffff) >> 9) & 0x3f);
finalIndex = (ziU16)(((key & 0xffff) >> 3) & 0x3f);
tone = (ziU16)(key & 7);
/* MWCC needs the stored initial character as the branch value. */
if ((output[0] = zi8ZYinitialSpelling[initialIndex]) != 0) {
length = 1;
}
@@ -251,7 +250,7 @@ Zi8UInt Zi8SpellingPY(ziU16 *output,Zi8UInt key,ziU8 includeTone)
Zi8UInt length = 0;
ziU16 initialIndex = (ziU16)(((key & 0xffff) >> 9) & 0x3f);
ziU16 finalIndex = (ziU16)(((key & 0xffff) >> 3) & 0x3f);
ziU16 tone = (ziU16)(key & 7);
volatile ziU16 tone = (ziU16)(key & 7);
output[0] = zi8PYinitialSpelling[initialIndex][0];
output[1] = zi8PYinitialSpelling[initialIndex][1];
@@ -364,6 +363,7 @@ ziU8 MatchAltSound1Key(ziU16 *spelling,Zi8UInt spellingLength,Zi8UInt requireFul
goto BINARY_SEARCH;
START_PROCESS:
recordIndex = searchIndex;
PROCESS:
do {
if (((records[recordIndex].flags & 0xeU) == 0) ||
((modifierFlags & records[recordIndex].flags) != 0)) {
@@ -402,6 +402,7 @@ BACKWARD_PROCESS:
}
}
}
goto BACKWARD_TEST;
BACKWARD_TEST:
recordIndex = recordIndex - 1;
if ((((int)recordIndex < 0) || (keyHigh != records[recordIndex].keyHigh)) ||
@@ -457,25 +458,30 @@ static int ZiIsSupportedPhonetic(ziU8 language,ziPtr work)
return 1;
}
switch (language) {
case 0x77:
case 0x78:
case 0x7c:
if ((Zi8LangSupported(0x77,work) != 0) || (Zi8LangSupported(0x78,work) != 0) ||
(Zi8LangSupported(0x7c,work) != 0)) {
return 1;
}
case 0x79:
case 0x7a:
case 0x7d:
if ((Zi8LangSupported(0x79,work) == 0) && (Zi8LangSupported(0x7a,work) == 0) &&
(Zi8LangSupported(0x7d,work) == 0)) {
break;
}
return 1;
goto LAB_group_b;
case 0x77:
case 0x78:
case 0x7c:
goto LAB_group_a;
default:
break;
goto LAB_return_false;
}
return 0;
LAB_group_a:
if ((Zi8LangSupported(0x77,work) != 0) || (Zi8LangSupported(0x78,work) != 0) ||
(Zi8LangSupported(0x7c,work) != 0)) {
return 1;
}
LAB_group_b:
if ((Zi8LangSupported(0x79,work) == 0) && (Zi8LangSupported(0x7a,work) == 0) &&
(Zi8LangSupported(0x7d,work) == 0)) {
goto LAB_return_false;
}
return 1;
LAB_return_false:
return 0;
}
ziU32 Zi8Get1KeyPressSpelling(ziGetParam *params,Zi8OneKeyOptions *options,Zi8OneKeyWork *work)
@@ -772,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;
@@ -932,7 +938,6 @@ ziU32 Zi8Get1KeyPressSpelling(ziGetParam *params,Zi8OneKeyOptions *options,Zi8On
for (;;) {
if (tableCount == 0) break;
spellingEntry = (ziU8 *)Zi8GetTableAddress(1,0xc,work);
/* MWCC needs the spelling-entry advance in the loop body. */
for (tableIndex = 0; tableIndex < tableCount; tableIndex++) {
if ((*spellingEntry & languageMask) != 0) {
if (usePinyin) entryLength = *spellingEntry & 0xf;
@@ -1316,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++;
@@ -1384,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++;
@@ -1424,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;
}
@@ -1506,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++;
@@ -1552,7 +1560,7 @@ finishPhrases:
for (index = 0; index < 4; index++) {
if (keyValues[index] != (keyMasks[index] & phraseTable[index])) break;
}
if (index < 4) continue;
if (index < 4) goto nextSortedOrdinal;
}
entryFlags = false;
if (work->phoneticFilter != 0) {
@@ -1569,17 +1577,17 @@ finishPhrases:
elementIndex = MatchAltSound1Key(spelling,inputLimit,matchFull,(Zi8AltSoundRecord *)alternateTable,phoneticMask,phoneticTable,ordinal,
tone,includeTone,languageMask,work);
}
if (elementIndex == 0) continue;
if (elementIndex == 0) goto nextSortedOrdinal;
if (!emitWords) {
if (trackDuplicates && (ziU8)Zi8SetFindCand(params->scratch,ordinal,work) != 0) continue;
if (trackDuplicates && (ziU8)Zi8SetFindCand(params->scratch,ordinal,work) != 0) goto nextSortedOrdinal;
ordinal = Zi8Ord2Uni(ordinal,work);
for (index = 0; index < candidateCount; index++) {
if (ordinal == output[index]) break;
}
if (index < candidateCount) continue;
if (index < candidateCount) goto nextSortedOrdinal;
} else {
ordinal = Zi8Ord2Uni(ordinal,work);
if (Zi8IsDupWordW(&ordinal,1,work) != 0) continue;
if (Zi8IsDupWordW(&ordinal,1,work) != 0) goto nextSortedOrdinal;
}
if (remaining == 0) {
totalCandidates++;
@@ -1595,11 +1603,12 @@ finishPhrases:
remaining--;
}
}
nextSortedOrdinal:
;
}
}
if ((options->countOnly == '\0') && (ziU8)Zi8GetZHuwdPtr(&userEntriesAddress,&userCount,work) != 0)
{
/* MWCC needs both user-entry cursor advances in the loop body. */
for (phraseOrdinal = 0; phraseOrdinal < userCount;) {
if ((params->elementCount == '\0') || ((((ziU8*)userEntriesAddress)[1] & 0x80) != 0)) {
userOrdinal = (ziU16)(((ziU8*)userEntriesAddress)[1] & 0x7f) << 8 | (ziU16)((ziU8*)userEntriesAddress)[2];
@@ -1651,7 +1660,6 @@ nextUserOrdinal:
}
phraseTable = syllableTable;
previousCharacter = 0;
/* MWCC needs both ordinal cursor advances in the loop body. */
for (ordinal = 0; ordinal < ordinalCount;) {
if (((*phraseTable & languageMask) != 0) &&
((characterSetTable == 0 || ((characterSet & characterSetTable[(Zi8UInt)ordinal]) != 0)))) {
@@ -1779,22 +1787,23 @@ ziBool Zi8ZHCheckSpelling(ziWChar *input,ziWChar *spelling,ziU8 inputLength,ziPt
switch (spelling[index]) {
case 0xf331:
toneMask = 1;
break;
goto validateTone;
case 0xf332:
toneMask = 2;
break;
goto validateTone;
case 0xf333:
toneMask = 4;
break;
goto validateTone;
case 0xf334:
toneMask = 8;
break;
goto validateTone;
case 0xf335:
toneMask = 0x10;
break;
goto validateTone;
default:
continue;
goto nextInputCharacter;
}
validateTone:
if (toneTable != 0) {
while( true ) {
syllableLength = (index - syllableStart) + 1;
@@ -1836,6 +1845,8 @@ ziBool Zi8ZHCheckSpelling(ziWChar *input,ziWChar *spelling,ziU8 inputLength,ziPt
}
input[index] = spelling[index];
syllableStart = index + 1;
nextInputCharacter:
;
}
for (index = 0; input[index] != 0; index = index + 1) {
if ((input[index] >= 0x61) && (input[index] <= 0x7a)) {

View File

@@ -287,7 +287,6 @@ static ziBool ZiIsLetterHyphen(ziWChar character ZI_NEED_WORK) {
void Zi8ChangeWordCase(ziWChar* word, ziU8 language, ZiAlphaWork* work) {
enum { LOWER_CASE, UPPER_CASE } upper = LOWER_CASE;
/* MWCC needs the explicit work cast in the case-mode test below. */
if (work->caseMode == 3) {
Zi8ChangeCharCase(1, word++, language, work);
} else if (((ZiAlphaWork*)work)->caseMode == 1) {
@@ -296,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);
@@ -307,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);
@@ -551,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 &&
@@ -559,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)) {
@@ -567,12 +568,10 @@ int Zi8AlphaGetCandidates(ziGetParam* parameters, ziPtr optionData, ziPtr workDa
switch ((int)((ZiAlphaWork*)workData)->dictionaryKinds[index]) {
case 1:
case 9:
break;
default:
continue;
goto foundHighlightedDictionary;
}
break;
}
foundHighlightedDictionary:
if (firstCandidate == 0 && ((ZiAlphaWork*)workData)->highlightedWord[elementIndex - 1] != 0) {
if (((ZiAlphaWork*)workData)->requiredLength < parameters->elementCount)
((ZiAlphaWork*)workData)->reuseHighlightedWord = 0;
@@ -655,7 +654,7 @@ int Zi8AlphaGetCandidates(ziGetParam* parameters, ziPtr optionData, ziPtr workDa
}
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)) ||
@@ -701,6 +700,7 @@ preparePrefix:
prefixVowelRestriction = ZI8_FALSE;
}
}
goto prepareDictionaryOrder;
prepareDictionaryOrder:
((ZiAlphaWork*)workData)->dictionaryOrder[0] = 0;
if ((Zi8GetTableCount(language,0x1f,workData) & 0x20) != 0) {
@@ -772,11 +772,11 @@ prepareDictionaries:
if (dictionaryIndex != ((ZiAlphaWork*)workData)->dictionaryCount) {
dictionaryKind = ((ZiAlphaWork*)workData)->dictionaryKinds[dictionaryIndex];
if (dictionaryKind == 12) {
if (languagePassCount != 2) continue;
if (languagePassCount != 2) goto finishDictionaryPass;
goto selectDictionary;
}
} else {
if (((ZiAlphaOptions*)optionData)->lookupMode != 0) continue;
if (((ZiAlphaOptions*)optionData)->lookupMode != 0) goto finishDictionaryPass;
dictionaryKind = 10;
}
selectDictionary:
@@ -787,7 +787,7 @@ selectDictionary:
case 3:
case 4:
case 10:
continue;
goto finishDictionaryPass;
}
}
{
@@ -805,7 +805,7 @@ selectDictionary:
((parameters->currentWord == 0 ||
((parameters->wordCharCount == 0 ||
(parameters->currentWord[parameters->wordCharCount - 1] == 0x20))))))))
continue;
goto finishDictionaryPass;
if ((candidateCount == 0) &&
((((!punctuationCandidate && (parameters->firstCandidate == firstCandidate)) &&
((parameters->currentWord == 0 ||
@@ -831,10 +831,10 @@ selectDictionary:
punctuationCandidate = ZI8_FALSE;
break;
case 4:
if (((ZiAlphaOptions*)optionData)->minWordLength > elementCount) continue;
if (((ZiAlphaOptions*)optionData)->minWordLength > elementCount) goto finishDictionaryPass;
break;
case 3:
if (((ZiAlphaOptions*)optionData)->minWordLength > elementCount || elementCount == 1) continue;
if (((ZiAlphaOptions*)optionData)->minWordLength > elementCount || elementCount == 1) goto finishDictionaryPass;
break;
case 9:
if (elementCount == 1 && *elements >= 0xEFF1 && *elements <= 0xF010) {
@@ -843,7 +843,7 @@ selectDictionary:
}
default:
if (elementCount == 1 && prefixCount == 0 && *elements >= 0xEFF1 &&
*elements <= 0xF010 && !contextEnabled) continue;
*elements <= 0xF010 && !contextEnabled) goto finishDictionaryPass;
dictionaryExact = 0;
if (languagePassCount == 2) {
for (index = dictionaryIndex + 1; index < ((ZiAlphaWork*)workData)->dictionaryCount; index++) {
@@ -900,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);
}
}
}
@@ -922,30 +922,33 @@ 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;
}
}
if (wordLength != 0) goto filterVowelCandidate;
dictionaryStatus[dictionaryKind] = 1;
if (elements[apostropheIndex] >= 0xEFF1) continue;
if (elements[apostropheIndex] >= 0xEFF1) goto retryDictionary;
goto finishDictionaryPass;
}
filterVowelCandidate:
@@ -958,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;
}
}
@@ -976,7 +982,7 @@ filterVowelCandidate:
if (wordLength == 0) {
wordLength = 0;
dictionaryStatus[dictionaryKind] = 1;
continue;
goto retryDictionary;
}
}
if (wordLength != 0) {
@@ -992,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:
@@ -1002,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;
}
@@ -1013,11 +1019,10 @@ filterVowelCandidate:
if (elementCount != 0) {
wordLength = Zi8MatchOEMdata(elements,elementCount,language,wordCursor,
wordCapacity,dictionaryExact,
dictionaryStatus[dictionaryKind],workData);
dictionaryStatus[dictionaryKind] & 0xff,workData);
}
break;
case 10:
/* MWCC needs the stored punctuation character as the branch value. */
if ((*wordCursor = *punctuationCursor) != 0) {
punctuationCursor++;
wordLength = 1;
@@ -1069,19 +1074,15 @@ 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;
}
punctuationCursor = &punctuationBuffer[0];
dictionaryKind = 0xb;
retryPunctuation = ZI8_TRUE;
continue;
goto retryDictionary;
}
}
if ((((((dictionaryExact == 0) || (!currentVowelRestriction)) || (prefixCount != 0)) ||
@@ -1093,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;
}
@@ -1112,17 +1104,18 @@ prepareRememberedPunctuation:
}
else if (((ZiAlphaOptions*)optionData)->minWordLength <= wordLength) {
if (prefixVowelRestriction) {
if (*wordCursor >= 0x30 && *wordCursor <= 0x39) continue;
if (*wordCursor >= 0x30 && *wordCursor <= 0x39) goto retryDictionary;
if (language == 0x2f) {
if (Zi8ITspecialExclusion(wordCursor,prefixCount,wordLength) != 0) continue;
if (Zi8ITspecialExclusion(wordCursor,prefixCount,wordLength) != 0) goto retryDictionary;
} else if (language == 0x58) {
if (Zi8_814659E8(wordCursor,prefixCount,wordLength) != 0) continue;
if (Zi8_814659E8(wordCursor,prefixCount,wordLength) != 0) goto retryDictionary;
} else if (Zi8IsVowel(language,*wordCursor) == 0) {
wordLength = 0;
continue;
goto retryDictionary;
}
}
{
prepareCandidate:
if (((elementCount == 1) && (dictionaryKind != 10)) &&
((*wordCursor >= 0xeff1 && *wordCursor <= 0xf010))) {
punctuationCandidate = ZI8_TRUE;
@@ -1134,8 +1127,8 @@ prepareRememberedPunctuation:
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;
@@ -1152,7 +1145,7 @@ prepareRememberedPunctuation:
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;
}
@@ -1165,11 +1158,12 @@ prepareRememberedPunctuation:
case 5:
case 1:
case 9:
checkKeyLayout:
keyLayoutCursor = keyLayout;
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;
@@ -1547,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;
}
@@ -1642,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;
}
@@ -948,181 +947,183 @@ pud_search:
((struct __zi8_work_data_s*)work)->pudCount = ((struct __zi8_work_data_s*)work)->zhPudCount;
}
pud_start:
if (!(((options->countOnly && getOptions != 5) || !wordLength || getMode == 5 ||
if (((options->countOnly && getOptions != 5) || !wordLength || getMode == 5 ||
(request->elementCount && Zi8IsComponent(elements[0], work)) ||
!Zi8IsCharacter(request->currentWord[0], work)) &&
(getMode != 2 || request->elementCount <= 1) &&
(getMode != 0 || match.nSeg <= 1) &&
((getMode != 1 && getMode != 2) || match.nCand <= 1))) {
matchMode = 0;
while ((index = Zi8MatchPUDdata_ZHS(request->currentWord, wordLength, 1, currentSpelling, 32,
candidateWord, 64, 0, matchMode, work)) != 0) {
matchMode = 1;
currentSpelling[index] = 0;
if (!request->elementCount || (getMode == 0 && request->elementCount == 1 && elements[0] == 0xEF00)) {
character = currentSpelling[wordLength];
switch (character) {
case 0xFF0C: case 0xFF01: case 0x3002: case 0xFF1F:
candidateStatus = 1;
candidateOrdinal = 0xFFFF;
goto pud_accept;
}
}
if (getMode == 2 && index >= request->elementCount + wordLength) {
rangeIndex = 0;
rangeCount = wordLength;
while (rangeIndex < request->elementCount) {
if (!((currentSpelling[rangeCount] == 0x2C9 && elements[rangeIndex] == 0xF331) ||
(currentSpelling[rangeCount] == 0x2CA && elements[rangeIndex] == 0xF332) ||
(currentSpelling[rangeCount] == 0x2C7 && elements[rangeIndex] == 0xF333) ||
(currentSpelling[rangeCount] == 0x2CB && elements[rangeIndex] == 0xF334) ||
(currentSpelling[rangeCount] == 0x2D9 && elements[rangeIndex] == 0xF335) ||
currentSpelling[rangeCount] == elements[rangeIndex] - 0xC200)) break;
++rangeCount;
++rangeIndex;
}
if (rangeIndex == request->elementCount) {
if (!(request->context & 0x10)) request->completion = request->elementCount;
candidateStatus = 1;
character = currentSpelling[wordLength];
candidateOrdinal = 0xFFFF;
goto pud_accept;
}
if (match.nCand == 1) continue;
}
if ((getMode == 1 || getMode == 2) && match.nCand > 1) {
if (match.nCand > index - wordLength) continue;
for (index = 1; index < match.nCand; ++index) {
character = currentSpelling[wordLength + index];
candidateOrdinal = Zi8Uni2Ord(character, work);
if (candidateOrdinal == 0xFFFF) break;
record = records + candidateOrdinal * 12;
candidateStatus = (match.phon[index] & (ziU16)Zi8GetPCode(phoneticTable, record)) == match.phon2[index];
if (!candidateStatus && (record[0] & 0x80) && !requireFull &&
Zi8MatchAltSound(alternateTable, alternateCount, phoneticTable, candidateOrdinal,
match.phon[index], match.phon2[index], charset, work)) candidateStatus = 1;
if (!candidateStatus) break;
}
if (index < match.nCand) continue;
}
if (getMode == 0 && match.nSeg > 1) {
if (match.nSeg > index - wordLength) continue;
for (index = 1; index < match.nSeg; ++index) {
character = currentSpelling[wordLength + index];
candidateOrdinal = Zi8Uni2Ord(character, work);
if (candidateOrdinal == 0xFFFF) break;
record = records + candidateOrdinal * 12;
if (match.segmentValues[index][0] != (record[0] & match.segmentMasks[index][0]) ||
match.segmentValues[index][1] != (record[1] & match.segmentMasks[index][1]) ||
match.segmentValues[index][2] != (record[2] & match.segmentMasks[index][2]) ||
match.segmentValues[index][3] != (record[3] & match.segmentMasks[index][3])) break;
}
if (index < match.nSeg) continue;
}
((getMode != 1 && getMode != 2) || match.nCand <= 1)) goto pud_restore;
matchMode = 0;
goto pud_next;
pud_candidate:
matchMode = 1;
currentSpelling[index] = 0;
if (!request->elementCount || (getMode == 0 && request->elementCount == 1 && elements[0] == 0xEF00)) {
character = currentSpelling[wordLength];
switch (character) {
case 0xFF0C: case 0xFF01: case 0x3002: case 0xFF1F:
candidateStatus = 1;
candidateOrdinal = 0xFFFF;
goto pud_accept;
}
}
if (getMode == 2 && index >= request->elementCount + wordLength) {
rangeIndex = 0;
rangeCount = wordLength;
while (rangeIndex < request->elementCount) {
if (!((currentSpelling[rangeCount] == 0x2C9 && elements[rangeIndex] == 0xF331) ||
(currentSpelling[rangeCount] == 0x2CA && elements[rangeIndex] == 0xF332) ||
(currentSpelling[rangeCount] == 0x2C7 && elements[rangeIndex] == 0xF333) ||
(currentSpelling[rangeCount] == 0x2CB && elements[rangeIndex] == 0xF334) ||
(currentSpelling[rangeCount] == 0x2D9 && elements[rangeIndex] == 0xF335) ||
currentSpelling[rangeCount] == elements[rangeIndex] - 0xC200)) break;
++rangeCount;
++rangeIndex;
}
if (rangeIndex == request->elementCount) {
if (!(request->context & 0x10)) request->completion = request->elementCount;
candidateStatus = 1;
character = currentSpelling[wordLength];
candidateOrdinal = 0xFFFF;
goto pud_accept;
}
if (match.nCand == 1) goto pud_next;
}
if ((getMode == 1 || getMode == 2) && match.nCand > 1) {
if (match.nCand > index - wordLength) goto pud_next;
for (index = 1; index < match.nCand; ++index) {
character = currentSpelling[wordLength + index];
candidateOrdinal = Zi8Uni2Ord(character, work);
if (candidateOrdinal == 0xFFFF) continue;
if (candidateOrdinal == 0xFFFF) break;
record = records + candidateOrdinal * 12;
candidateStatus = 0;
switch (getMode) {
case 7: case 8:
phraseEntry = phraseTable + ((record[9] & 15) << 16 | (record[11] | record[10] << 8));
if ((phraseEntry[0] & 7) >= match.length &&
match.prefixValues[0] == (match.prefixMasks[0] & phraseEntry[0]) &&
match.prefixValues[1] == (match.prefixMasks[1] & phraseEntry[1]) &&
match.prefixValues[2] == (match.prefixMasks[2] & phraseEntry[2]) &&
match.prefixValues[3] == (match.prefixMasks[3] & phraseEntry[3])) {
candidateStatus = 1;
break;
}
if (getMode == 7) break;
case 9:
phraseEntry = phraseTable + ((record[9] & 15) << 16 | (record[11] | record[10] << 8));
index = phraseEntry[0] & 7;
if ((phraseEntry[0] & phraseMasks[index].bytes[0]) == phraseValues[index].bytes[0] &&
(phraseEntry[1] & phraseMasks[index].bytes[1]) == phraseValues[index].bytes[1] &&
(phraseEntry[2] & phraseMasks[index].bytes[2]) == phraseValues[index].bytes[2] &&
(phraseEntry[3] & phraseMasks[index].bytes[3]) == phraseValues[index].bytes[3]) candidateStatus = 1;
break;
case 0:
if (match.recordValues[0] == (record[0] & match.recordMasks[0]) &&
(match.count || (match.recordValues[3] == (record[3] & match.recordMasks[3]) &&
match.recordValues[2] == (record[2] & match.recordMasks[2]) &&
match.recordValues[1] == (record[1] & match.recordMasks[1]))) &&
(ziU8)Zi8SecMatchChar(record, componentTable, &match, 0, work)) candidateStatus = 1;
break;
case 1: case 2:
candidateStatus = (match.phon[0] & (ziU16)Zi8GetPCode(phoneticTable, record)) == match.phon2[0];
if (!candidateStatus && (record[0] & 0x80) && !requireFull &&
Zi8MatchAltSound(alternateTable, alternateCount, phoneticTable, candidateOrdinal,
match.phon[0], match.phon2[0], charset, work)) candidateStatus = 1;
break;
}
if (!candidateStatus) continue;
candidateStatus = (match.phon[index] & (ziU16)Zi8GetPCode(phoneticTable, record)) == match.phon2[index];
if (!candidateStatus && (record[0] & 0x80) && !requireFull &&
Zi8MatchAltSound(alternateTable, alternateCount, phoneticTable, candidateOrdinal,
match.phon[index], match.phon2[index], charset, work)) candidateStatus = 1;
if (!candidateStatus) break;
}
if (index < match.nCand) goto pud_next;
}
if (getMode == 0 && match.nSeg > 1) {
if (match.nSeg > index - wordLength) goto pud_next;
for (index = 1; index < match.nSeg; ++index) {
character = currentSpelling[wordLength + index];
candidateOrdinal = Zi8Uni2Ord(character, work);
if (candidateOrdinal == 0xFFFF) break;
record = records + candidateOrdinal * 12;
if (match.segmentValues[index][0] != (record[0] & match.segmentMasks[index][0]) ||
match.segmentValues[index][1] != (record[1] & match.segmentMasks[index][1]) ||
match.segmentValues[index][2] != (record[2] & match.segmentMasks[index][2]) ||
match.segmentValues[index][3] != (record[3] & match.segmentMasks[index][3])) break;
}
if (index < match.nSeg) goto pud_next;
}
character = currentSpelling[wordLength];
candidateOrdinal = Zi8Uni2Ord(character, work);
if (candidateOrdinal == 0xFFFF) goto pud_next;
record = records + candidateOrdinal * 12;
candidateStatus = 0;
switch (getMode) {
case 7: case 8:
phraseEntry = phraseTable + ((record[9] & 15) << 16 | (record[11] | record[10] << 8));
if ((phraseEntry[0] & 7) >= match.length &&
match.prefixValues[0] == (match.prefixMasks[0] & phraseEntry[0]) &&
match.prefixValues[1] == (match.prefixMasks[1] & phraseEntry[1]) &&
match.prefixValues[2] == (match.prefixMasks[2] & phraseEntry[2]) &&
match.prefixValues[3] == (match.prefixMasks[3] & phraseEntry[3])) {
candidateStatus = 1;
break;
}
if (getMode == 7) break;
case 9:
phraseEntry = phraseTable + ((record[9] & 15) << 16 | (record[11] | record[10] << 8));
index = phraseEntry[0] & 7;
if ((phraseEntry[0] & phraseMasks[index].bytes[0]) == phraseValues[index].bytes[0] &&
(phraseEntry[1] & phraseMasks[index].bytes[1]) == phraseValues[index].bytes[1] &&
(phraseEntry[2] & phraseMasks[index].bytes[2]) == phraseValues[index].bytes[2] &&
(phraseEntry[3] & phraseMasks[index].bytes[3]) == phraseValues[index].bytes[3]) candidateStatus = 1;
break;
case 0:
if (match.recordValues[0] == (record[0] & match.recordMasks[0]) &&
(match.count || (match.recordValues[3] == (record[3] & match.recordMasks[3]) &&
match.recordValues[2] == (record[2] & match.recordMasks[2]) &&
match.recordValues[1] == (record[1] & match.recordMasks[1]))) &&
(ziU8)Zi8SecMatchChar(record, componentTable, &match, 0, work)) candidateStatus = 1;
break;
case 1: case 2:
candidateStatus = (match.phon[0] & (ziU16)Zi8GetPCode(phoneticTable, record)) == match.phon2[0];
if (!candidateStatus && (record[0] & 0x80) && !requireFull &&
Zi8MatchAltSound(alternateTable, alternateCount, phoneticTable, candidateOrdinal,
match.phon[0], match.phon2[0], charset, work)) candidateStatus = 1;
break;
}
if (!candidateStatus) goto pud_next;
pud_accept:
if (!emitWords) {
if (character == previousOrdinal) continue;
previousOrdinal = character;
if (candidateOrdinal != 0xFFFF) {
if (trackDuplicates) {
if ((ziU8)Zi8SetFindCand(request->scratch, candidateOrdinal, work)) continue;
} else if (Zi8IsDupWChar(candidateOrdinal, work)) continue;
}
if (!emitWords) {
if (character == previousOrdinal) goto pud_next;
previousOrdinal = character;
if (candidateOrdinal == 0xFFFF) goto pud_charset;
if (trackDuplicates) {
if ((ziU8)Zi8SetFindCand(request->scratch, candidateOrdinal, work)) goto pud_next;
} else if (Zi8IsDupWChar(candidateOrdinal, work)) goto pud_next;
} else {
emittedWords = 0;
for (index = wordLength; currentSpelling[index];) {
++index;
++emittedWords;
}
if (request->elementCount) {
if ((getMode == 1 || getMode == 2) && match.nCand) emittedWords = match.nCand;
else if (getMode == 0 && match.nSeg > 1) emittedWords = match.nSeg;
else emittedWords = 1;
} else if (prefixSearch) emittedWords = 1;
currentSpelling[wordLength + emittedWords] = 0;
if (Zi8IsDupWordW(currentSpelling + wordLength, emittedWords, work)) goto pud_next;
}
pud_charset:
if (charsetTable && wordSearchPhase) {
index = wordLength;
while (currentSpelling[index]) {
rangeIndex = Zi8Uni2Ord(currentSpelling[index], work);
if (rangeIndex == 0xFFFF) break;
charsetEntry = charsetTable + rangeIndex;
if (!(charsetEntry[0] & charsetFilter)) break;
++index;
}
if (currentSpelling[index]) goto pud_next;
}
if (skipCount) --skipCount;
else {
if (!candidateWord[0] || ZiMatchZHSpelling(currentSpelling, candidateWord, request->elements,
request->elementCount, wordLength, work)) {
++totalResults;
if (getOptions == 5) {
if (totalResults >= options->maxResults) goto engine_finish;
} else {
emittedWords = 0;
for (index = wordLength; currentSpelling[index];) {
++index;
++emittedWords;
}
if (request->elementCount) {
if ((getMode == 1 || getMode == 2) && match.nCand) emittedWords = match.nCand;
else if (getMode == 0 && match.nSeg > 1) emittedWords = match.nSeg;
else emittedWords = 1;
} else if (prefixSearch) emittedWords = 1;
currentSpelling[wordLength + emittedWords] = 0;
if (Zi8IsDupWordW(currentSpelling + wordLength, emittedWords, work)) continue;
}
if (charsetTable && wordSearchPhase) {
index = wordLength;
while (currentSpelling[index]) {
rangeIndex = Zi8Uni2Ord(currentSpelling[index], work);
if (rangeIndex == 0xFFFF) break;
charsetEntry = charsetTable + rangeIndex;
if (!(charsetEntry[0] & charsetFilter)) break;
++index;
}
if (currentSpelling[index]) continue;
}
if (skipCount) --skipCount;
else {
if (!candidateWord[0] || ZiMatchZHSpelling(currentSpelling, candidateWord, request->elements,
request->elementCount, wordLength, work)) {
++totalResults;
if (getOptions == 5) {
if (totalResults >= options->maxResults) goto engine_finish;
} else {
if (emitWords) {
++emittedCount;
for (index = wordLength; currentSpelling[index]; ++index) {
output[outputIndex++] = currentSpelling[index];
}
output[outputIndex++] = ' ';
if (outputIndex > outputLimit) {
request->letters = emittedCount;
request->count = emittedCount;
goto engine_finish;
}
} else output[emittedCount++] = character;
if (emittedCount >= request->maxCandidates) {
request->letters = emittedCount;
request->count = emittedCount;
goto engine_finish;
}
if (emitWords) {
++emittedCount;
for (index = wordLength; currentSpelling[index]; ++index) {
output[outputIndex++] = currentSpelling[index];
}
output[outputIndex++] = ' ';
if (outputIndex > outputLimit) {
request->letters = emittedCount;
request->count = emittedCount;
goto engine_finish;
}
} else output[emittedCount++] = character;
if (emittedCount >= request->maxCandidates) {
request->letters = emittedCount;
request->count = emittedCount;
goto engine_finish;
}
}
}
}
pud_next:
if ((index = Zi8MatchPUDdata_ZHS(request->currentWord, wordLength, 1, currentSpelling, 32,
candidateWord, 64, 0, matchMode, work)) != 0) goto pud_candidate;
pud_restore:
if (wordSearchPhase == 1) {
((struct __zi8_work_data_s*)work)->pudCount = savedPudCount;
wordSearchPhase = 0;
@@ -1298,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;
@@ -1433,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;
}
@@ -1484,13 +1485,13 @@ character_range_start:
remainingOrdinals = candidateCount;
while (1) {
if (match.count) {
if (!candidateCount--) break;
if (!candidateCount--) goto character_range_done;
if (match.prefixValues[0] != (record[0] & match.prefixMasks[0])) goto character_range_next;
if ((ziU8)Zi8SecMatchChar(record, componentTable, &match, &candidateOrdinal, work) == 2) goto character_range_accept;
} else {
if (!Zi8ExactMatchNextChar(record, match.prefixMasks[0], match.prefixValues[0], match.prefixMasks[1], match.prefixValues[1],
match.prefixMasks[2], match.prefixValues[2], match.prefixMasks[3], match.prefixValues[3],
&candidateCount, &record, &candidateOrdinal, work)) break;
&candidateCount, &record, &candidateOrdinal, work)) goto character_range_done;
if ((!match.componentIndex && match.length < 8) ||
(ziU8)Zi8SecMatchChar(record, componentTable, &match, &candidateOrdinal, work) == 2) goto character_range_accept;
}
@@ -1498,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) {
@@ -1534,6 +1535,7 @@ character_range_accept:
if (emittedCount >= request->maxCandidates) goto engine_finish;
record += 12;
}
character_range_done:
if (phase != 0xFF) goto character_range_start;
}
if (!options->countOnly && phoneticRetry && ordinalCount && getMode != 5) {
@@ -1584,6 +1586,7 @@ character_range_accept:
} else if (totalResults >= options->maxResults) goto engine_finish;
} else --skipCount;
}
ordinal_done:
exactPhrase = 1;
++tableIndex;
}
@@ -1654,6 +1657,7 @@ phonetic_ordinal_search:
phoneticInput = 1;
}
}
tone_candidates:
if (getMode == 2 && getOptions != 6 && !request->elementCount && request->wordCharCount &&
request->currentWord[request->wordCharCount - 1] >= 0x3105 &&
request->currentWord[request->wordCharCount - 1] <= 0x3129) {
@@ -1672,8 +1676,8 @@ phonetic_ordinal_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;
} else if (totalResults >= options->maxResults) goto engine_finish;
@@ -1953,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;
@@ -2048,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;
@@ -2068,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;
@@ -2120,9 +2124,9 @@ frequency_record_next:
++emittedCount;
output[outputIndex++] = alternateCharacter;
output[outputIndex++] = ' ';
if (outputIndex > outputLimit) break;
if (outputIndex > outputLimit) goto frequency_candidates_done;
} else output[emittedCount++] = alternateCharacter;
if (emittedCount >= request->maxCandidates) break;
if (emittedCount >= request->maxCandidates) goto frequency_candidates_done;
} else --skipCount;
alternateCharacter = 0;
firstPhoneticPass = 1;
@@ -2158,6 +2162,7 @@ frequency_record_next:
exactPhrase = 1;
}
}
frequency_candidates_done:
if (phoneticRetry) {
if (!emitWords && emittedCount < request->maxCandidates && getMode != 5) {
for (duplicateIndex = 0; duplicateIndex < emittedCount; ++duplicateIndex) {
@@ -2190,6 +2195,7 @@ frequency_record_next:
phonetic_filtered_done:
filteringMode = 1;
}
phonetic_main:
if (Zi8GetFormatVersion(1, work) >= 4) rangeCount = Zi8GetTableCount(1, 23, work);
else rangeCount = 0;
if (rangeCount && match.nCand == 2 && emitWords) {
@@ -2292,7 +2298,7 @@ phonetic_pair_next:
alternateCursor += 4;
}
phonetic_group_next:
ordinalIndex++;
ordinalIndex += 1;
frequencyCursor += 5;
}
}
@@ -2312,6 +2318,7 @@ phonetic_component_done:
ordinals_filtered_done:
filteringMode = 1;
}
phonetic_ordinals:
record = records;
candidateCount = recordCount;
phoneticGroups = 0;
@@ -2485,7 +2492,7 @@ filtered_search:
match.prefixValues[0] == (match.prefixMasks[0] & phraseEntry[0]) &&
match.prefixValues[1] == (match.prefixMasks[1] & phraseEntry[1]) &&
match.prefixValues[2] == (match.prefixMasks[2] & phraseEntry[2]) &&
match.prefixValues[3] == (match.prefixMasks[3] & phraseEntry[3])) break;
match.prefixValues[3] == (match.prefixMasks[3] & phraseEntry[3])) goto filtered_accept;
if (getMode == 7) goto filtered_next;
case 9:
phraseEntry = phraseTable + ((record[9] & 15) << 16 | (record[11] | record[10] << 8));
@@ -2523,6 +2530,7 @@ filtered_search:
break;
}
}
filtered_accept:
((ZiChineseWork*)work)->duplicateOrdinals[((ZiChineseWork*)work)->duplicateIndex] = ordinalIndex;
((ZiChineseWork*)work)->duplicateCharacters[((ZiChineseWork*)work)->duplicateIndex] = candidateOrdinal;
if (charsetTable) {
@@ -2668,7 +2676,6 @@ static int Zi8NewMatchPhonetic(ziGetParam* request, ZiChineseRecord* records,
}
groupCandidates = candidateGroups + groupOffset * 2;
candidateIndex = 0;
/* MWCC needs both candidate cursor advances in the loop body. */
while (candidateIndex < groupSize) {
character = groupCandidates[0] | (ziU16)groupCandidates[1] << 8;
if (!(charset & records[character].flags)) {
@@ -2701,43 +2708,43 @@ static int Zi8NewMatchPhonetic(ziGetParam* request, ZiChineseRecord* records,
}
if (remainingSkip) {
--remainingSkip;
} else {
++totalResults;
if (!options->countOnly) {
if (++((ZiChineseWork*)work)->duplicateIndex >= 64) {
((ZiChineseWork*)work)->duplicateIndex = 0;
}
if (wordMode) {
++emittedCount;
output[emittedCharacters++] = character;
output[emittedCharacters++] = 0x20;
if (emittedCharacters > capacity) {
*skipCount = remainingSkip;
*resultCount = totalResults;
*candidateCount = emittedCount;
*outputCount = emittedCharacters;
Zi8ReplaceLastError(0xB54, work);
return 0;
}
} else {
output[emittedCount++] = character;
}
if (emittedCount >= request->maxCandidates) {
goto next_group_candidate;
}
++totalResults;
if (!options->countOnly) {
if (++((ZiChineseWork*)work)->duplicateIndex >= 64) {
((ZiChineseWork*)work)->duplicateIndex = 0;
}
if (wordMode) {
++emittedCount;
output[emittedCharacters++] = character;
output[emittedCharacters++] = 0x20;
if (emittedCharacters > capacity) {
*skipCount = remainingSkip;
*resultCount = totalResults;
*candidateCount = emittedCount;
*outputCount = emittedCharacters;
Zi8ReplaceLastError(0xB55, work);
Zi8ReplaceLastError(0xB54, work);
return 0;
}
} else if (totalResults >= options->maxResults) {
} else {
output[emittedCount++] = character;
}
if (emittedCount >= request->maxCandidates) {
*skipCount = remainingSkip;
*resultCount = totalResults;
*candidateCount = emittedCount;
*outputCount = emittedCharacters;
Zi8ReplaceLastError(0xB56, work);
Zi8ReplaceLastError(0xB55, work);
return 0;
}
} else if (totalResults >= options->maxResults) {
*skipCount = remainingSkip;
*resultCount = totalResults;
*candidateCount = emittedCount;
*outputCount = emittedCharacters;
Zi8ReplaceLastError(0xB56, work);
return 0;
}
next_group_candidate:
++candidateIndex;
@@ -2860,8 +2867,8 @@ ziU8 Zi8GetElementCount(ziWChar* elements, ziU8 elementCount, ziU8 charCount ZI_
ziU8 elementIndex;
ziU8 count;
ziWChar spacedElements[256];
ziWChar savedSeparator;
savedSeparator = ZI_WORK->separator;
struct { ziWChar separator; } savedState;
savedState.separator = ZI_WORK->separator;
if (elementCount <= 1 || !charCount) {
return elementCount;
}
@@ -2876,13 +2883,13 @@ ziU8 Zi8GetElementCount(ziWChar* elements, ziU8 elementCount, ziU8 charCount ZI_
}
ZI_WORK->separator = 0xF360;
Zi8ZHaddSpace(elements, elementCount, spacedElements, 256, __zi8_work_data);
ZI_WORK->separator = savedSeparator;
ZI_WORK->separator = savedState.separator;
spacedIndex = elementIndex = count = 0;
for (; charCount && elementIndex < elementCount; ++spacedIndex) {
while (charCount && elementIndex < elementCount) {
if (spacedElements[spacedIndex] == 0xF360) {
--charCount;
if (elements[elementIndex] != 0xF360) {
continue;
goto next_spaced_element;
}
} else if (spacedElements[spacedIndex] >= 0xF331 && spacedElements[spacedIndex] <= 0xF335) {
--charCount;
@@ -2894,6 +2901,8 @@ ziU8 Zi8GetElementCount(ziWChar* elements, ziU8 elementCount, ziU8 charCount ZI_
}
++elementIndex;
++count;
next_spaced_element:
++spacedIndex;
}
return count;
}

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

@@ -64,7 +64,6 @@ ziU32 Zi8MatchROMdata0(ziWChar* elements, ziU8 count, ziU8 language,
key = Zi8GetTableSize(language, keyTable, ZI_WORK);
if (key != 0 && ZI_WORK->userKeys[language] == 0) {
index = 0;
/* MWCC needs the key-count branch in the loop test block. */
goto check_keys;
next_key:
{
@@ -100,7 +99,7 @@ check_keys:
searching = 1;
current = &records[context->cnt - 1];
while (searching && context->cnt != 0 && current->node != (ziU8*)context->endNode) {
if (capacity < context->cnt) break;
if (capacity < context->cnt) goto finish_graph;
current->attr = ZiDAWGgetCHARattribute(context, current->node, ZI_WORK);
if (context->cnt <= count) {
if (context->keyCodes == 0) {
@@ -118,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;
}
@@ -126,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;
@@ -135,17 +134,17 @@ check_keys:
if (search[0] != 0 && context->cnt >= search[1]) goto next_sibling;
descend:
records[context->cnt].node = ZiDAWGGetChild(records[context->cnt - 1].node);
if (records[context->cnt].node != (ziU8*)0) {
context->cnt++;
if (ZI_WORK->maxCnt < context->cnt) ZI_WORK->maxCnt = context->cnt;
} else {
if (records[context->cnt].node == (ziU8*)0) goto next_sibling;
context->cnt++;
if (ZI_WORK->maxCnt < context->cnt) ZI_WORK->maxCnt = context->cnt;
goto update_current;
next_sibling:
while (context->cnt != 0) {
records[context->cnt - 1].node = ZiDAWGGetSibling(records[context->cnt - 1].node);
if (records[context->cnt - 1].node != (ziU8*)0) break;
context->cnt--;
}
while (context->cnt != 0) {
records[context->cnt - 1].node = ZiDAWGGetSibling(records[context->cnt - 1].node);
if (records[context->cnt - 1].node != (ziU8*)0) break;
context->cnt--;
}
update_current:
current = &records[context->cnt - 1];
}
finish_graph:
@@ -233,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;
@@ -276,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:
@@ -324,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);
}
}
@@ -381,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

@@ -4,7 +4,7 @@ extern ziU16 Zi8GetTableCount(ziU8 lang, ziU8 tableIdx ZI_NEED_WORK);
extern ziU8 Zi8getKeyLayout(ziU8 lang, ziU16 key, ziWChar* layout, ziU8 mode ZI_NEED_WORK);
extern ziChar Zi8ConvertWC2UC(ziWChar ch, ziU8 language ZI_NEED_WORK);
extern ziU32 Zi8AlphaGetCandidates(ziGetParam* param, ziPtr sw ZI_NEED_WORK);
extern ziU8 Zi8SyllablesROMdata(ziWChar* keys, ziU8 keyCount, ziU8 lang, ziWChar* output,
extern ziU8 Zi8SyllablesROMdata(ziWChar* keys, ziU8 count, ziU8 lang, ziWChar* out,
ziU16 a, ziU8 b, ziU8* cntOut, ziU8 c ZI_NEED_WORK);
typedef struct _ziSwParam {
@@ -20,191 +20,197 @@ typedef struct _ziSwParam {
} ziSwParam;
ziU32 Zi8GetSyllablesCandidates(ziGetParam* param, ziSwParam* sw ZI_NEED_WORK) {
ziWChar syllableBuffer[0x40];
ziWChar keyLayout[0x32];
ziS32 remainingCapacity;
ziS32 syllableLength;
ziS32 remainingSkip;
ziS32 candidateCount;
ziWChar* nextCharacter;
ziU16 error;
ziU8 allowHyphen;
ziU8 needKeyFallback;
ziU8 nextMatch;
ziU8 reverseOrder;
ziU8 matchedLength;
ziWChar* output;
ziU8* encodedOutput;
ziS32 index;
ziWChar buf[0x40];
ziWChar buf2[0x32];
ziS32 rem;
ziS32 cur;
ziS32 firstCand;
ziS32 count;
ziWChar* pNext;
ziU16 err;
ziU8 flag14;
ziU8 flag13;
ziU8 flag12;
ziU8 flag11;
ziU8 sylCnt;
ziWChar* out;
ziU8* u28;
ziS32 i;
remainingSkip = param->firstCandidate;
candidateCount = 0;
encodedOutput = 0;
nextCharacter = 0;
allowHyphen = 1;
needKeyFallback = 1;
nextMatch = 0;
reverseOrder = 0;
matchedLength = 0;
error = 0x64;
firstCand = param->firstCandidate;
count = 0;
u28 = 0;
pNext = 0;
flag14 = 1;
flag13 = 1;
flag12 = 0;
flag11 = 0;
sylCnt = 0;
err = 0x64;
if (param->currentWord != 0 && param->wordCharCount != 0 &&
param->currentWord[param->wordCharCount - 1] != 0x20) {
reverseOrder = 1;
flag11 = 1;
}
if (param->elementCount == 0 || (param->elementCount == 1 && reverseOrder == 0)) {
candidateCount = Zi8AlphaGetCandidates(param, sw, ZI_WORK);
if (param->elementCount == 0 || (param->elementCount == 1 && flag11 == 0)) {
count = Zi8AlphaGetCandidates(param, sw, ZI_WORK);
goto end;
}
if (sw->countOnly != 0 || (param->getOptions & 0xFD) != 0x81) {
output = syllableBuffer;
remainingCapacity = 0x40;
out = buf;
rem = 0x40;
} else {
output = param->candidates;
remainingCapacity = sw->capacity - 1;
out = (ziWChar*)param->candidates;
rem = sw->capacity - 1;
}
if ((param->getOptions & 0xFD) == 0x80) {
encodedOutput = (ziU8*)param->candidates;
remainingCapacity = sw->capacity - 1;
u28 = (ziU8*)param->candidates;
rem = sw->capacity - 1;
}
if (remainingCapacity <= param->elementCount) {
error = 0x168;
if (rem <= param->elementCount) {
err = 0x168;
goto end;
}
if ((Zi8GetTableCount(param->language, 0x1F, ZI_WORK) & 8) != 0) {
allowHyphen = 0;
flag14 = 0;
}
if (param->elements[0] == 0xEFF1 && param->elementCount > 1 && allowHyphen != 0) {
syllableBuffer[0] = 0x2D;
if (param->elements[0] == 0xEFF1 && param->elementCount > 1 && flag14 != 0) {
buf[0] = 0x2D;
} else {
Zi8getKeyLayout(param->language, param->elements[0], syllableBuffer, 1, ZI_WORK);
Zi8getKeyLayout(param->language, param->elements[0], buf, 1, ZI_WORK);
}
output[0] = syllableBuffer[0];
Zi8SyllablesROMdata(param->elements, param->elementCount, param->language, output,
(ziU16)remainingCapacity, 0, &matchedLength, reverseOrder, ZI_WORK);
if (matchedLength != 0) {
syllableLength = matchedLength;
out[0] = buf[0];
Zi8SyllablesROMdata(param->elements, param->elementCount, param->language, out,
(ziU16)rem, 0, &sylCnt, flag11, ZI_WORK);
if (sylCnt != 0) {
cur = sylCnt;
} else {
syllableLength = 1;
cur = 1;
}
if (syllableLength != param->elementCount) {
if (remainingSkip != 0) {
remainingSkip--;
} else if (sw->countOnly != 0) {
if (++candidateCount >= sw->maxCount) goto end;
if (cur == param->elementCount) goto L5dc;
if (firstCand != 0) {
firstCand--;
goto L5dc;
}
if (sw->countOnly != 0) {
if (++count >= sw->maxCount) goto end;
goto L5dc;
}
for (i = cur; i < param->elementCount; i += sylCnt) {
if (param->elements[i] == 0xEFF1 && param->elementCount - i > 1 && flag14 != 0) {
buf2[0] = 0x2D;
} else {
for (index = syllableLength; index < param->elementCount; index += matchedLength) {
if (param->elements[index] == 0xEFF1 && param->elementCount - index > 1 && allowHyphen != 0) {
keyLayout[0] = 0x2D;
} else {
Zi8getKeyLayout(param->language, param->elements[index], keyLayout, 1, ZI_WORK);
}
output[index] = keyLayout[0];
Zi8SyllablesROMdata(param->elements + index, param->elementCount - index, param->language,
output + index, (ziU16)remainingCapacity, 0, &matchedLength, 1, ZI_WORK);
if (matchedLength == 0) {
matchedLength = 1;
}
}
if (encodedOutput != 0) {
for (index = 0; index < param->elementCount; index++) {
encodedOutput[index] = Zi8ConvertWC2UC(output[index], param->language, ZI_WORK);
}
encodedOutput[index++] = 0;
encodedOutput[index] = 0;
encodedOutput += index;
} else {
output[index++] = 0;
output[index] = 0;
output += index;
}
remainingCapacity -= index;
if (++candidateCount >= param->maxCandidates) goto end;
/* MWCC needs the forward capacity branch before the common exit. */
if (remainingCapacity > param->elementCount) goto search_syllables;
goto end;
Zi8getKeyLayout(param->language, param->elements[i], buf2, 1, ZI_WORK);
}
out[i] = buf2[0];
Zi8SyllablesROMdata(param->elements + i, param->elementCount - i, param->language,
out + i, (ziU16)rem, 0, &sylCnt, 1, ZI_WORK);
if (sylCnt == 0) {
sylCnt = 1;
}
}
if (u28 != 0) {
for (i = 0; i < param->elementCount; i++) {
u28[i] = Zi8ConvertWC2UC(out[i], param->language, ZI_WORK);
}
u28[i++] = 0;
u28[i] = 0;
u28 += i;
} else {
out[i++] = 0;
out[i] = 0;
out += i;
}
rem -= i;
if (++count >= param->maxCandidates) goto end;
if (rem > param->elementCount) goto L5dc;
goto end;
search_syllables:
for (; syllableLength >= 1; syllableLength--) {
nextMatch = 0;
goto match_syllable;
syllable_found:
nextMatch = 1;
if (syllableLength == 1) {
needKeyFallback = 0;
L5dc:
while (cur >= 1) {
flag12 = 0;
goto rom;
found:
flag12 = 1;
if (cur == 1) {
flag13 = 0;
}
if (output[0] >= 0xEFF1 && output[0] <= 0xF010) {
continue;
L464:
if (out[0] >= 0xEFF1 && out[0] <= 0xF010) {
goto dec;
}
emit_syllable:
if (remainingSkip != 0) {
remainingSkip--;
} else if (sw->countOnly != 0) {
if (++candidateCount >= sw->maxCount) goto end;
L464b:
if (firstCand != 0) {
firstCand--;
goto L560;
}
if (sw->countOnly != 0) {
if (++count >= sw->maxCount) goto end;
goto L560;
}
if (u28 != 0) {
for (i = 0; i < cur; i++) {
u28[i] = Zi8ConvertWC2UC(out[i], param->language, ZI_WORK);
}
u28[i++] = 0;
u28[i] = 0;
u28 += i;
} else {
if (encodedOutput != 0) {
for (index = 0; index < syllableLength; index++) {
encodedOutput[index] = Zi8ConvertWC2UC(output[index], param->language, ZI_WORK);
}
encodedOutput[index++] = 0;
encodedOutput[index] = 0;
encodedOutput += index;
} else {
index = syllableLength;
output[index++] = 0;
output[index] = 0;
output += index;
}
remainingCapacity -= index;
if (++candidateCount >= param->maxCandidates) goto end;
if (remainingCapacity <= syllableLength) goto end;
i = cur;
out[i++] = 0;
out[i] = 0;
out += i;
}
next_syllable:
if (nextCharacter != 0) {
if (*nextCharacter == 0) goto end;
output[0] = *nextCharacter++;
goto emit_syllable;
rem -= i;
if (++count >= param->maxCandidates) goto end;
if (rem <= cur) goto end;
L560:
if (pNext != 0) {
if (*pNext == 0) goto end;
out[0] = *pNext++;
goto L464b;
}
match_syllable:
if (Zi8SyllablesROMdata(param->elements, (ziU8)syllableLength, param->language, output,
(ziU16)remainingCapacity, nextMatch, 0, reverseOrder, ZI_WORK) != 0) {
goto syllable_found;
rom:
if (Zi8SyllablesROMdata(param->elements, (ziU8)cur, param->language, out,
(ziU16)rem, flag12, 0, flag11, ZI_WORK) != 0) {
goto found;
}
dec:
cur--;
}
if (needKeyFallback == 0) goto end;
if (flag13 == 0) goto end;
if (param->elements[0] == 0xEFF1 && param->elementCount > 1 && allowHyphen != 0) {
keyLayout[0] = 0x2D;
keyLayout[1] = 0;
Zi8getKeyLayout(param->language, param->elements[0], &keyLayout[1], 1, ZI_WORK);
for (index = 1; keyLayout[index] != 0; index++) {
if (keyLayout[index] == 0x2D) break;
if (param->elements[0] == 0xEFF1 && param->elementCount > 1 && flag14 != 0) {
buf2[0] = 0x2D;
buf2[1] = 0;
Zi8getKeyLayout(param->language, param->elements[0], &buf2[1], 1, ZI_WORK);
for (i = 1; buf2[i] != 0; i++) {
if (buf2[i] == 0x2D) break;
}
while (keyLayout[index] != 0) {
keyLayout[index] = keyLayout[index + 1];
index++;
while (buf2[i] != 0) {
buf2[i] = buf2[i + 1];
i++;
}
} else {
Zi8getKeyLayout(param->language, param->elements[0], keyLayout, 1, ZI_WORK);
Zi8getKeyLayout(param->language, param->elements[0], buf2, 1, ZI_WORK);
}
syllableLength = 1;
nextCharacter = keyLayout;
goto next_syllable;
cur = 1;
pNext = buf2;
goto L560;
end:
if (sw->countOnly != 0) {
param->letters = 0;
} else {
param->letters = (ziU8)candidateCount;
param->letters = (ziU8)count;
}
Zi8LogError(error, ZI_WORK);
return candidateCount;
Zi8LogError(err, ZI_WORK);
return count;
}

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) {
if ((node[0] & flag) == 0) {
while (traversal.remaining-- != 0) {
if ((node[0] & flag) != 0) goto decode_node;
next_node:
node += 0xC;
continue;
}
code = Zi8GetPCode(pCodeTable, node);
if ((*values != (code & *masks)) && (altMode == 0) && ((node[0] & 0x80) != 0)) {
node += 0xC;
continue;
decode_node:
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,47 +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;
}
/* MWCC needs the group-end branch before the backward group jump. */
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;
@@ -413,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;
@@ -521,23 +524,23 @@ pinyin_initial:
final[outputIndex] &= 0xfdff;
}
value = *current;
if (value == 0x68 || value == 0xF368) {
if (outputIndex == 0) {
*resultCount += 1;
}
final[outputIndex] += 0x200;
*bestInitial = initial[0];
*bestFinal = final[0];
count--;
if (count == 0) {
break;
}
current += 1;
if (value != 0x68 && value != 0xF368) goto scan_final;
if (outputIndex == 0) {
*resultCount += 1;
}
final[outputIndex] += 0x200;
*bestInitial = initial[0];
*bestFinal = final[0];
count--;
if (count == 0) {
break;
}
current += 1;
}
} else if ((*current == 0xF369) || (*current == 0x69)) {
goto invalid_pinyin;
}
scan_final:
partial = 0;
for (index = 0; index < 4; index++) {
pinyin[index] = 0;
@@ -549,45 +552,45 @@ pinyin_initial:
if (index != 0) {
partial = 1;
}
break;
goto finish_final;
}
if ((value >= 0xF331) && (value < 0xF336)) {
if (index != 0) {
partial = 1;
}
break;
goto finish_final;
}
if ((value < 0x61) || (value > 0x7A)) {
if (value < 0xF361) {
break;
goto finish_final;
}
value -= 0xF361;
if (value > 0x19) {
if (outputIndex == 0) {
*resultCount += 1;
}
break;
goto finish_final;
}
} else {
value -= 0x61;
}
pinyin[index] = (ziU8)value + 1;
if (Zi8GetPyFinal(pinyin, &pyInitial, &pyFinal)) {
if (outputIndex == 0) {
*resultCount += 1;
}
current++;
index++;
count--;
if (count == 0) {
break;
}
continue;
if (Zi8GetPyFinal(pinyin, &pyInitial, &pyFinal) == 0) goto try_final_extension;
if (outputIndex == 0) {
*resultCount += 1;
}
current++;
index++;
count--;
if (count == 0) {
goto finish_final;
}
continue;
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;
}
@@ -609,21 +612,19 @@ pinyin_initial:
}
}
if (index > 3 && count != 0) {
value = *current;
if (value == 0x27 || value == 0xF360 || value == 0x20) {
if (outputIndex == 0) {
*resultCount += 1;
}
current++;
count--;
finish_final:
if ((index > 3) && (count != 0) && (((value = *current) == 0x27) || (value == 0xF360) || (value == 0x20))) {
if (outputIndex == 0) {
*resultCount += 1;
}
current++;
count--;
}
if (index > 3) {
partial = 1;
}
if (partial && alternateInitial == 0) {
if (Zi8GetPyFinal(pinyin, &pyInitial, &pyFinal)) {
if (Zi8GetPyFinal(pinyin, &pyInitial, &pyFinal) != 0) {
if (convertedCount == 0) {
result++;
initial[outputIndex] = 0x7E00;
@@ -640,7 +641,7 @@ pinyin_initial:
}
} else {
pinyin[index] = 0xFF;
if (Zi8GetPyFinal(pinyin, &pyInitial, &pyFinal)) {
if (Zi8GetPyFinal(pinyin, &pyInitial, &pyFinal) != 0) {
if (convertedCount == 0) {
result++;
initial[outputIndex] = 0x7E00;
@@ -652,7 +653,7 @@ pinyin_initial:
*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;
@@ -663,7 +664,7 @@ pinyin_initial:
}
} else {
pinyin[index] = 0;
if (Zi8GetPyFinal(pinyin, &pyInitial, &pyFinal)) {
if (Zi8GetPyFinal(pinyin, &pyInitial, &pyFinal) != 0) {
if (convertedCount == 0) {
result++;
initial[outputIndex] = 0x7E00;
@@ -684,29 +685,23 @@ pinyin_initial:
if (outputIndex == 0) {
*resultCount = *resultCount + 1;
}
} else if (value >= 0xF331) {
value -= 0xF331;
if (value <= 4) {
value++;
initial[outputIndex] |= 7;
final[outputIndex] |= value;
*bestInitial = initial[0];
*bestFinal = final[0];
} else if ((value >= 0xF331) && ((value -= 0xF331) <= 4)) {
value++;
initial[outputIndex] |= 7;
final[outputIndex] |= value;
*bestInitial = initial[0];
*bestFinal = final[0];
count--;
current++;
if (outputIndex == 0) {
*resultCount = *resultCount + 1;
}
if ((count != 0) && (((value = *current) == 0x27) || (value == 0xF360) || (value == 0x20))) {
count--;
current++;
if (outputIndex == 0) {
*resultCount = *resultCount + 1;
}
if (count != 0) {
value = *current;
if (value == 0x27 || value == 0xF360 || value == 0x20) {
count--;
current++;
if (outputIndex == 0) {
*resultCount = *resultCount + 1;
}
}
}
}
}
}
@@ -723,20 +718,26 @@ ziBool Zi8GetPyFinal(ziU8* pinyin, ziU8* initial, ziU8* final) {
ziU8 index = 0;
ziU8 row;
row = 0;
while (row < 0x36) {
while (index < 4) {
if (pinyin[index] != Zi8PinyinFinals[row][index]) {
break;
}
index++;
goto check_row;
scan_row:
while (index < 4) {
if (pinyin[index] != Zi8PinyinFinals[row][index]) {
break;
}
if (index >= 4) {
*initial = Zi8PinyinFinals[row][4];
*final = Zi8PinyinFinals[row][5];
return 1;
}
row++;
index = 0;
index++;
}
if (index < 4) {
goto next_row;
}
*initial = Zi8PinyinFinals[row][4];
*final = Zi8PinyinFinals[row][5];
return 1;
next_row:
row++;
index = 0;
check_row:
if (row < 0x36) {
goto scan_row;
}
return 0;
}
@@ -790,43 +791,52 @@ ziU8 Zi8GetBpmfPhonetic(ziWChar* text, ziU8 count, ziU16* initial, ziU16* final,
value = *text - 0xF305;
switch ((ziS32)value) {
case 0x22:
*final |= 0x80;
*initial |= 0x180;
resultCount++;
if (--count == 0) {
*bestInitial = *initial | 0x78;
*bestFinal = *final | 0x38;
return resultCount;
}
text++;
break;
goto bpmf_value_22;
case 0x23:
*final |= 0x100;
*initial |= 0x180;
resultCount++;
if (--count == 0) {
*bestInitial = *initial | 0x78;
*bestFinal = *final | 0x38;
return resultCount;
}
text++;
break;
goto bpmf_value_23;
case 0x24:
*final |= 0x180;
*initial |= 0x180;
resultCount++;
if (--count == 0) {
*bestInitial = *initial | 0x78;
*bestFinal = *final | 0x38;
return resultCount;
}
text++;
break;
goto bpmf_value_24;
default:
if ((*text < 0xF331) || (*text > 0xF335)) {
*initial |= 0x180;
}
goto set_bpmf_initial;
}
bpmf_value_22:
*final |= 0x80;
*initial |= 0x180;
resultCount++;
if (--count == 0) {
*bestInitial = *initial | 0x78;
*bestFinal = *final | 0x38;
return resultCount;
}
text++;
goto after_bpmf_initial;
bpmf_value_23:
*final |= 0x100;
*initial |= 0x180;
resultCount++;
if (--count == 0) {
*bestInitial = *initial | 0x78;
*bestFinal = *final | 0x38;
return resultCount;
}
text++;
goto after_bpmf_initial;
bpmf_value_24:
*final |= 0x180;
*initial |= 0x180;
resultCount++;
if (--count == 0) {
*bestInitial = *initial | 0x78;
*bestFinal = *final | 0x38;
return resultCount;
}
text++;
goto after_bpmf_initial;
set_bpmf_initial:
if ((*text < 0xF331) || (*text > 0xF335)) {
*initial |= 0x180;
}
after_bpmf_initial:
value = *text - 0xF305;
if ((value > 0x14) && (value < 0x22)) {

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

@@ -57,7 +57,6 @@ ziU8 ZADP_Zi8SetPDremoveOpt(ziU8 option, struct __zi8_work_data_s* __zi8_work_da
return previous;
}
ziU8 Zi8MatchPUDdata_ZHS(ziWChar* pattern, ziU8 length, ziU8 language, ziWChar* output, ziU16 capacity, ziWChar* spelling, ziU16 spellingCapacity, ziU8 complete, ziU8 continuation ZI_NEED_WORK) {
// MWCC needs this aggregate to retain the unread workspace store at SP+0x24.
struct {
int fallback;
ziPtr workspace;
@@ -78,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) {
@@ -107,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--;
@@ -119,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;
@@ -144,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

@@ -62,8 +62,8 @@ typedef struct
typedef struct
{
UINT16 vendorId; // 0x00
UINT16 productId; // 0x02
UINT16 at_0x00; // 0x00
UINT16 at_0x02; // 0x02
} tHCI_CFG; // size 0x04
typedef void tHCI_INIT(UINT8, UINT8, UINT16);

View File

@@ -19,11 +19,11 @@ typedef void tUUSB_CBACK(UINT8, INT8);
typedef struct
{
char pad0_[4];
UINT16 vendorId; // 0x04
UINT16 productId; // 0x06
UINT16 taskId; // 0x08
UINT16 at_0x04;
UINT16 at_0x06;
UINT16 at_0x08;
char pad1_[1];
char reserved; // 0x0b
char at_0x0b;
char pad2_[1]; // for stack
} tUUSB;

View File

@@ -8,7 +8,7 @@ extern "C" {
#endif
void CNTCACHEInit(int unk0, int unk1);
s32 CNTCACHEClear(void);
void CNTCACHEClear();
#ifdef __cplusplus
}

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,8 +72,11 @@ struct DVDCommandBlock {
DVDCommandBlock* prev; // 0x04
u32 command; // 0x08
// MWCC needs plain state stores; asynchronous readers use volatile views.
#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

@@ -167,27 +167,24 @@ s32 ARCConvertPathToEntrynum(ARCHandle* handle, const char* path) {
for (i = dirLookAt + 1; i < FSTEntries[dirLookAt].dir.next; i = IS_ENTRY_DIR(FSTEntries, i) ? FSTEntries[i].dir.next : i + 1) {
char* name;
do {
// Skip directories
if (IS_ENTRY_DIR(FSTEntries, i) == FALSE && isDir == TRUE) {
break;
}
loop_back:
// Skip directories
if (IS_ENTRY_DIR(FSTEntries, i) == FALSE && isDir == TRUE) {
continue;
}
name = handle->FSTStringStart + FILE_STRING_OFF(FSTEntries, i);
name = handle->FSTStringStart + FILE_STRING_OFF(FSTEntries, i);
// Skip empty entries
if (*name == '.' && *(name + 1) == 0) {
i++;
continue;
}
// Skip empty entries
if (*name == '.' && *(name + 1) == 0) {
i++;
goto loop_back;
}
// Advance to next file in hierarchy
if (isSame(ptrPath, name) == TRUE) {
// MWCC needs this join to preserve the original search branches.
goto next_in_hier;
}
break;
} while (TRUE);
// Advance to next file in hierarchy
if (isSame(ptrPath, name) == TRUE) {
goto next_in_hier;
}
}
return -1;
@@ -318,26 +315,23 @@ BOOL ARCReadDir(ARCDir* dir, ARCDirEntry* dirent) {
handle = dir->handle;
FSTEntries = (FSTEntry*)handle->FSTStart;
loc = dir->location;
for (;;) {
if (loc <= dir->entryNum || dir->next <= loc) {
return FALSE;
}
dirent->handle = handle;
dirent->entryNum = loc;
dirent->isDir = IS_ENTRY_DIR(FSTEntries, loc);
dirent->name = handle->FSTStringStart + FILE_STRING_OFF(FSTEntries, loc);
if (dirent->name[0] == '.' && dirent->name[1] == 0) {
loc++;
continue;
}
dir->location = IS_ENTRY_DIR(FSTEntries, loc) ? FSTEntries[loc].dir.next : (loc + 1);
break;
retry:
if (loc <= dir->entryNum || dir->next <= loc) {
return FALSE;
}
dirent->handle = handle;
dirent->entryNum = loc;
dirent->isDir = IS_ENTRY_DIR(FSTEntries, loc);
dirent->name = handle->FSTStringStart + FILE_STRING_OFF(FSTEntries, loc);
if (dirent->name[0] == '.' && dirent->name[1] == 0) {
loc++;
goto retry;
}
dir->location = IS_ENTRY_DIR(FSTEntries, loc) ? FSTEntries[loc].dir.next : (loc + 1);
return TRUE;
}

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++) {

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