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
474 changed files with 17870 additions and 65322 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.
@@ -485,55 +484,52 @@ To pick up the loop:
slot per the effort scale.
4. Handle every `NEEDS REVIEW` line in `/tmp/automerge.log`.
## Completion state
## Goal completion contract
As of 2026-10-09 the 4.3U decompilation is complete: every unit is `Matching`,
code is 100% exact and linked, data is 100% linked, and no assembly
placeholder remains. Every change from here on keeps these green:
The decompilation loop does not stop after a successful wave, a convenient
near-match, or a code-only milestone. Keep dispatching and resuming workers
until the live 43U report proves all of the following:
```
python3 tools/check_decomp_complete.py build/43U/report.json --dol build/43U/main.dol # DECOMPLETE_OK
python3 tools/check_asm_inventory.py # ASM INVENTORY PASS
sha1sum build/43U/main.dol # 26116613f624061ba99c8d1a299aaa6efa85670d
```
- Code is 100.00% exact-matched, not merely fuzzy-matched.
- Code is 100.00% fully linked, with no remaining unlinked code units.
- Data is 100.00% extracted/decompiled and 100.00% fully linked.
- Every source unit and function in the 4.3U target is accounted for; no
`NonMatching`, missing, fuzzy-only, or unlinked unit remains.
- The final full build passes, the DOL hash remains correct, and the report,
object files, and linked DOL agree.
The remaining `asm` blocks are the 162 ORIGINAL SDK hand-assembly functions
listed in `docs/asm-inventory.md`; they stay.
Until every condition is true and independently verified, the goal remains
active. A worker wave with zero accepted matches is a failed attempt, not a
completion condition; preserve useful workers, resume fixable leaves, and
dispatch the next disjoint batch.
## Cleanup phase
## Things that do NOT work
Work now makes the source read like normal code while every byte stays
identical. The brief and priority order live in
`/mnt/drive2/projects/wii-ipl-workers/_luna-runs/prompts/cleanup-common.md`;
read it before any cleanup task. A cleanup that changes any byte is reverted.
Workarounds accepted to reach 100% (owner decision, 2026-10-09) stay unless a
cleanup removes them with identical bytes. Each one carries a one-line comment
naming what the compiler needs:
- function-scoped optimizer pragmas in `#pragma push` / `#pragma pop`;
- per-use `volatile` where the target mixes volatile and plain access;
- compiler intrinsics such as `__rlwinm`;
- a uniform redundant guard or reassignment the compiler needs to keep a
block (AOSSLink, `TMCJPEGDEC_err_restart`);
- dead-stripped stand-in functions that preserve layout (tiInputForm).
Inline asm, `.s` files, section or `force_active` pragmas, padding objects,
`register` and hand-placed `lbl_` references stay out of C sources.
Matching levers learned in the final waves are in
`/mnt/drive2/projects/wii-ipl-workers/_luna-runs/prompts/levers.md`; the
decision log is `_luna-runs/effort-policy.txt` in the same directory.
- **Frame pragmas.** `#pragma ppc_iro_level 0` fixed exactly one function out
of roughly forty attempts and made others worse. A search across pragma
variants produced almost no movement. Do not spend time here.
- **Reverting to pristine upstream to unblock.** The unmodified upstream tree
is needed as a baseline, but it does not help you match anything.
- **Searching other forks for the missing functions.** The eleven unimplemented
`iplESMisc` functions do not exist in any of the twenty-three public forks.
## Known hard cases
Register allocation and scheduling ties usually have a source-level lever:
declaration order, a named local for an inline getter, a function-local static
to drop alias edges, or a scoped optimizer pragma. `combosweep.py` and the
`_mwdbg` declaration-order search find most of them; see `levers.md`.
Many remaining diffs are pure compiler tie-breaks — register allocation and
floating-point scheduling — with no source-level lever. If `ctxdiff.py` shows
the instruction count already matches and the surviving differences are
callee-saved register names, you are probably looking at a tie-break. Record it
and move on rather than thrashing.
## Current status
Do not copy a progress number from this file. Regenerate the live 43U report
with `ninja -C . progress build/43U/report.json`; the report and DOL hash are
the authority for current status. `iplESMisc.cpp` remains `NonMatching` and
unlinked, so work there is DOL-safe.
## Reference
`tools/decomp-assist/iplESMisc.reference.cpp` is a historical snapshot of
`iplESMisc.cpp` from before it matched, kept for its string order and
function layout.
`tools/decomp-assist/iplESMisc.reference.cpp` is a snapshot of `iplESMisc.cpp`
with the matching work applied, kept as a reference for the string order and
function layout that the pool depends on.

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. 162 functions contain 164 assembly
bodies/blocks: 162 ORIGINAL functions and 0 PLACEHOLDER functions.
4.3U, 2026-10-05. 173 functions contain 175 assembly
bodies/blocks: 162 ORIGINAL functions and 11 PLACEHOLDER functions.
Run `python3 tools/check_asm_inventory.py`. Completion requires exit 0, complete
coverage and zero placeholders. The checker also rejects stale/duplicate rows,
@@ -37,6 +37,7 @@ found. Historical logs absent from this branch have commit IDs and excerpts in
| `libs/NW4R/include/nw4r/math/types.h` | `VEC3Scale` | ORIGINAL | psq_l/ps_muls0/psq_st implements paired-single vector/matrix operations. |
| `libs/NW4R/src/math/math_arithmetic.cpp` | `FrSqrt` | ORIGINAL | frsqrte plus fixed refinement matches the public [NW4R arithmetic assembly][arithmetic-cpp]. |
| `libs/NW4R/src/math/math_types.cpp` | `MTX44Identity` | ORIGINAL | psq_st/ps_merge01/ps_merge10 implements paired-single vector/matrix operations. |
| `libs/RVLMiddleware/TMC_JPEG/src/jpegdec/jdec_main.c` | `TMCJPEGDEC_err_restart` | PLACEHOLDER | JPEG marker scan; best C 95.73913%, 114/115 instructions, folded exit branch, [rx19](../tools/decomp-assist/rx19.attempts.md), [rx24][rx24]. |
| `libs/RVL_SDK/include/revolution/os/OSFastCast.h` | `OSInitFastCast` | ORIGINAL | mtspr programs the GQR quantization registers. |
| `libs/RVL_SDK/include/revolution/os/OSFastCast.h` | `__OSu16tof32` | ORIGINAL | psq_l uses a GQR integer conversion format for the fast cast. |
| `libs/RVL_SDK/include/revolution/os/OSFastCast.h` | `__OSf32tou8` | ORIGINAL | psq_st uses a GQR integer conversion format for the fast cast. |
@@ -87,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. |
@@ -158,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. |
@@ -184,11 +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

@@ -19,7 +19,7 @@ extern "C" {
#define CHANS_VM_CLASS_NAME_LEN 32
CHANSVmErr CHANSVmInit(CHANSVm* vm, vmPtr work, vmU32 size);
CHANSVmErr CHANSVmLinkModules(CHANSVm* vm, vmS32 reserved);
CHANSVmErr CHANSVmLinkModules(CHANSVm* vm, vmS32 unk0);
void CHANSVmSetSignal(CHANSVm* vm, vmBool* signal);
@@ -30,7 +30,7 @@ void CHANSVmSetSignal(CHANSVm* vm, vmBool* signal);
vmU32 CHANSVmGetFreeExeSize(CHANSVm* vm);
vmPtr CHANSVmGetFreeExeBufp(CHANSVm* vm);
CHANSVmErr CHANSVmAddExe(CHANSVm* vm, vmS32 reserved, CHANSVm* execCtx);
CHANSVmErr CHANSVmAddExe(CHANSVm* vm, vmS32 unk0, CHANSVm* execCtx);
CHANSVmErr CHANSVmStep(CHANSVm* vm, int stepCount);

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

@@ -15,32 +15,26 @@ extern "C" {
#define TMCC_JPEG_DEC_WORK_SIZE 0x1C00
enum TMCCJPEGOutputFormat {
TMCC_JPEG_OUTPUT_RGB565 = 0,
TMCC_JPEG_OUTPUT_RGBA8 = 1,
TMCC_JPEG_OUTPUT_Y8U8V8 = 2
};
typedef struct TMCCJPEGDecWork_t TMCCJPEGDecWork;
typedef s32(TMCCReadCallback)(void*, u8*, unsigned int);
typedef struct {
u8 reserved[0x10];
u8 unk_0x00[0x10];
void* pBuf2; // 0x10
u32 buf2Size; // 0x14
u32 dataSize; // 0x18
TMCCReadCallback* pCallback; // 0x1C
void* pContext; // 0x20
u8 thumbnailMode; // 0x24
u8 workBufferPadding[0x03];
u8 unk_0x24; // 0x24
u8 pad_0x25[0x03];
TMCCJPEGDecWork* pBuf1; // 0x28
u8 outputFormat; // 0x2C
u8 alignmentPadding[0x03];
u8 unk_0x2C; // 0x2C
u8 pad_0x2D[0x03];
} TMCCJPEGDecInitParam;
typedef struct {
u8 reserved[0x0C];
u8 unk_0x00[0x0C];
u16 orientation; // 0x0C
u32 xResNum; // 0x10
u32 xResDen; // 0x14
@@ -76,7 +70,7 @@ typedef struct {
u16 posX;
u16 posY;
s32 position; // 0x04
u8 reserved[0x04];
u8 unk_0x08[0x04];
u32 state; // 0x0C
u16 maxX;
u16 maxY;
@@ -86,8 +80,8 @@ typedef struct {
u8 stepYExt;
u32 dataSizeX;
u32 dataSizeY;
u8 scaleFactor; // 0x20
u8 noEoiCheck; // 0x21
u8 exifFlags; // 0x20
u8 thumbFlag; // 0x21
u8 componentCount;
u8 dimensionPadding;
u16 jpegWidth;
@@ -113,7 +107,7 @@ typedef struct {
u16 posX; // 0x00
u16 posY; // 0x02
s32 position; // 0x04
u8 reserved[0x04];
u8 unk_0x08[0x04];
u32 result; // 0x0C
u16 maxX; // 0x10
u16 maxY; // 0x12
@@ -124,26 +118,30 @@ typedef struct {
u32 dataSizeX; // 0x18
u32 dataSizeY; // 0x1C
u8 scaleFactor; // 0x20
u8 noEoiCheck; // 0x21
u8 unk_0x21; // 0x21
u8 componentCount; // 0x22
u8 dimensionPadding;
u8 unk_0x23; // 0x23
u16 jpegWidth; // 0x24
u16 jpegHeight; // 0x26
u16 outputWidth; // 0x28
u16 outputHeight; // 0x2A
u32 convWidth; // 0x2C
u32 convHeight; // 0x30
#ifdef TMC_JPEG_PLANAR_OUTPUT
u32 chromaWidth;
u32 chromaHeight;
u8* pLumaBuffer;
u8* pCbBuffer;
u8* pCrBuffer;
#else
u8 unk_0x34[0x14]; // 0x34
#endif
void* pTexBuffer; // 0x48
TMCCJPEGDecExifData exifData; // 0x4C
u8 unk_0x4C[0x67C];
TMCCJPEGDecWork* pWorkBuf; // 0x6C8
s32 decodeResult; // 0x6CC
u8 converterType; // 0x6D0
u8 alignmentPadding[0x03];
u8 unk_0x6D1[0x03];
} TMCCJPEGDecState;
s32 TMCCJPEGDecInit(TMCCJPEGDecState* state, TMCCJPEGDecInitParam* param);

View File

@@ -5,6 +5,12 @@
#include <tmc_jpeg.h>
enum TMCCJPEGOutputFormat {
TMCC_JPEG_OUTPUT_RGB565 = 0,
TMCC_JPEG_OUTPUT_RGBA8 = 1,
TMCC_JPEG_OUTPUT_Y8U8V8 = 2
};
enum TMCJpegMarker {
TMC_JPEG_MARKER_SOF0 = 0xFFC0,
TMC_JPEG_MARKER_SOF2 = 0xFFC2,

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;
@@ -37,16 +15,16 @@ s32 TMCCJPEGDecInit(TMCCJPEGDecState* state, TMCCJPEGDecInitParam* param) {
work->pState = state;
state->pWorkBuf = work;
if (param->thumbnailMode != 0) {
if (param->unk_0x24 != 0) {
result = -1;
} else if (param->outputFormat != TMCC_JPEG_OUTPUT_RGB565 && param->outputFormat != TMCC_JPEG_OUTPUT_RGBA8 &&
param->outputFormat != TMCC_JPEG_OUTPUT_Y8U8V8) {
} else if (param->unk_0x2C != TMCC_JPEG_OUTPUT_RGB565 && param->unk_0x2C != TMCC_JPEG_OUTPUT_RGBA8 &&
param->unk_0x2C != TMCC_JPEG_OUTPUT_Y8U8V8) {
result = -1;
} else {
state->noEoiCheck = param->thumbnailMode;
state->unk_0x21 = param->unk_0x24;
result = 0;
state->scaleFactor = 1;
state->converterType = param->outputFormat;
state->converterType = param->unk_0x2C;
}
if (result < 0) {
@@ -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;
@@ -221,11 +211,11 @@ s32 TMCCJPEGDecGetInfoEXIF(TMCCJPEGDecExifInfo* pInfo, TMCCJPEGDecInitParam* pPa
return result;
}
if (pParam->thumbnailMode == 0) {
if (pParam->unk_0x24 == 0) {
return 0;
}
if (pParam->thumbnailMode == 1) {
if (pParam->unk_0x24 == 1) {
result = TMCJPEGDEC_ThumbnailCheck(pParam, pInfo, segSizeP2);
if (result < 0) {
return result;
@@ -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;
}
}
@@ -668,7 +615,7 @@ static void TMCJPEGDEC_IFD1_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
static s32 TMCJPEGDEC_ThumbnailCheck(TMCCJPEGDecInitParam* param, TMCCJPEGDecExifInfo* info, u32 totalSize) {
s32 total;
s32 length;
s32 thumbnailBufferOffset;
s32 tmp;
total = (s32)info->exifData.thumbnailOffset;
if (total == 0) {
@@ -684,8 +631,8 @@ static s32 TMCJPEGDEC_ThumbnailCheck(TMCCJPEGDecInitParam* param, TMCCJPEGDecExi
return -0xA0;
}
thumbnailBufferOffset = (s32)info->exifData.thumbnailData - (s32)param->pBuf2;
total = length + total + thumbnailBufferOffset;
tmp = (s32)info->exifData.thumbnailData - (s32)param->pBuf2;
total = length + total + tmp;
if ((u32)total > param->buf2Size) {
return -0xF1;
@@ -695,19 +642,19 @@ static s32 TMCJPEGDEC_ThumbnailCheck(TMCCJPEGDecInitParam* param, TMCCJPEGDecExi
return -0xF1;
}
info->scaleFactor = 1;
info->exifFlags = 1;
if (param->thumbnailMode != 1) {
if (param->unk_0x24 != 1) {
return -1;
}
info->noEoiCheck = 0;
info->thumbFlag = 0;
if (param->outputFormat != TMCC_JPEG_OUTPUT_RGB565 && param->outputFormat != TMCC_JPEG_OUTPUT_RGBA8 &&
param->outputFormat != TMCC_JPEG_OUTPUT_Y8U8V8) {
if (param->unk_0x2C != TMCC_JPEG_OUTPUT_RGB565 && param->unk_0x2C != TMCC_JPEG_OUTPUT_RGBA8 &&
param->unk_0x2C != TMCC_JPEG_OUTPUT_Y8U8V8) {
return -1;
}
info->converterType = param->outputFormat;
info->converterType = param->unk_0x2C;
return 0;
}

View File

@@ -1,6 +1,5 @@
#define TMC_JPEG_FRAME_PARSER
#include <tmc_jpeg_internal.h>
#include <stddef.h>
extern void* memset(void* dest, s32 val, u32 count);
@@ -69,7 +68,7 @@ s32 TMCJPEGDEC_decompmcu(u32 maxMCU, u32 mcuCount, TMCCJPEGDecWork* work, void*
blockCountPtr = frameInfo + mcuIdx;
blockIdx = 0;
while (blockIdx < *(blockCountPtr + offsetof(TMCJpegFrameInfo, blockCount))) {
while (blockIdx < *(blockCountPtr + 0x1c)) {
s32 stackBlock[64];
s32 ret;
@@ -147,7 +146,7 @@ s32 TMCJPEGDEC_imagestart(TMCCJPEGDecWork* work) {
}
s32 TMCJPEGDEC_imageend(TMCCJPEGDecWork* work) {
if (work->pState->noEoiCheck == 1)
if (work->pState->unk_0x21 == 1)
return 0;
if (work->scanCount == 0) {
@@ -817,7 +816,7 @@ static s32 TMCJPEGDEC_parse_sos(TMCCJPEGDecWork* work) {
s32 idx;
TMCFrameComponents* components;
TMCJpegTableInfo* scalePtr;
u8* mapPtr;
TMCFrameComponents* mapPtr;
s32 dcTbl;
s32 acTbl;
@@ -859,7 +858,7 @@ static s32 TMCJPEGDEC_parse_sos(TMCCJPEGDecWork* work) {
for (ci = 0; ci < work->compCount; ci++) {
if ((s32)scanByte == (s32)components->id[ci]) {
components->map[idx] = ci;
mapPtr = &components->map[idx];
mapPtr = (TMCFrameComponents*)&components->map[idx];
goto componentFound;
}
}
@@ -878,8 +877,8 @@ componentFound:
return -0x51;
}
components->dcTable[*mapPtr] = dcTbl;
components->acTable[*mapPtr] = acTbl;
components->dcTable[mapPtr->map[0]] = dcTbl;
components->acTable[mapPtr->map[0]] = acTbl;
if (scalePtr->dcTblFlag[dcTbl] != 1) {
return -0x40;
@@ -889,7 +888,7 @@ componentFound:
return -0x40;
}
if (scalePtr->quantTblFlag[components->quantTable[idx]] != 1) {
if (scalePtr->quantTblFlag[mapPtr->quantTable[0]] != 1) {
return -0x41;
}
}
@@ -901,91 +900,237 @@ componentFound:
return 0;
}
static inline s32 restartFromMarker(TMCCJPEGDecWork* work, TMCCJPEGDecState* state, u8 marker) {
u8 skip;
u16 pitch;
u32 pos;
u16 row;
u16 column;
s32 mcuIndex;
u16 y;
u16 x;
s32 result;
#ifdef __MWERKS__
asm s32 TMCJPEGDEC_err_restart(register TMCCJPEGDecWork* work) {
nofralloc
if (marker > work->rstMarkerIdx + 0xCF) {
skip = marker - (work->rstMarkerIdx + 0xCF);
} else {
skip = (marker + 8) - (work->rstMarkerIdx + 0xCF);
}
skip *= work->restartInterval;
pitch = state->maxX;
pos = work->mcuPos;
row = pos & 0xFF;
column = pos >> 16;
mcuIndex = row * pitch + (skip + column);
work->rstMarkerIdx = (marker + 1) & 7;
y = mcuIndex / pitch;
x = mcuIndex % pitch;
work->components.dcPredict[0] = 0;
work->components.dcPredict[1] = 0;
work->components.dcPredict[2] = 0;
work->components.dcPredict[3] = 0;
work->restartCnt = 0;
work->mcuPos = (x << 16) + y;
result = TMCJPEGDEC_init_buff(work);
if (result < 0) {
return result;
}
state->posX = x;
state->posY = y;
state->position = TMCJPEGDEC_get_position(work);
return state->result - state->posY * state->maxX - state->posX;
stwu r1, -0x20(r1)
mflr r0
stw r0, 0x24(r1)
stw r31, 0x1c(r1)
stw r30, 0x18(r1)
mr r30, r3
stw r29, 0x14(r1)
stw r28, 0x10(r1)
lbz r0, 0x181c(r3)
lwz r31, 0x19e4(r3)
cmplwi r0, 1
bne _err_restart_rewind
li r0, 0
li r3, 0
stw r0, 0x6cc(r31)
b _err_restart_return
_err_restart_rewind:
bl TMCJPEGDEC_rewind_ptr
cmpwi r3, 0
bge _err_restart_load_byte
b _err_restart_return
_err_restart_load_byte:
lwz r3, 0xc(r30)
lbz r0, 0(r3)
stb r0, 8(r1)
b _err_restart_check_byte
_err_restart_read_byte:
mr r4, r30
addi r3, r1, 8
bl TMCJPEGDEC_get_byte
cmpwi r3, 0
bge _err_restart_check_byte
b _err_restart_return
_err_restart_check_byte:
lbz r0, 8(r1)
cmplwi r0, 0xff
bne _err_restart_read_byte
mr r4, r30
addi r3, r1, 8
bl TMCJPEGDEC_get_byte
lbz r6, 8(r1)
cmplwi r6, 0xd9
bne _err_restart_check_result
cmpwi r3, 0
bge _err_restart_eoi
cmpwi r3, -0x90
beq _err_restart_eoi
b _err_restart_return
_err_restart_eoi:
li r3, 0
b _err_restart_return
_err_restart_check_result:
cmpwi r3, 0
bge _err_restart_check_marker
b _err_restart_return
_err_restart_check_marker:
cmplwi r6, 0xd0
blt _err_restart_check_byte
cmplwi r6, 0xd7
ble _err_restart_marker
b _err_restart_check_byte
_err_restart_marker:
lhz r3, 0x52(r30)
addi r0, r6, 8
addi r3, r3, 0xcf
cmpw r6, r3
subf r0, r3, r0
clrlwi r5, r0, 0x18
ble _err_restart_have_diff
subf r0, r3, r6
clrlwi r5, r0, 0x18
_err_restart_have_diff:
lhz r4, 0x181a(r30)
addi r0, r6, 1
clrlwi r3, r0, 0x1d
lhz r7, 0x10(r31)
mullw r5, r5, r4
li r0, 0
lwz r6, 0x54(r30)
sth r3, 0x52(r30)
mr r3, r30
clrlwi r4, r6, 0x18
clrlwi r8, r5, 0x18
srwi r6, r6, 0x10
mullw r5, r4, r7
stw r0, 0x30(r30)
add r4, r8, r6
stw r0, 0x34(r30)
stw r0, 0x38(r30)
add r5, r5, r4
divw r4, r5, r7
stw r0, 0x3c(r30)
sth r0, 0x50(r30)
mullw r0, r4, r7
clrlwi r28, r4, 0x10
subf r4, r0, r5
slwi r0, r4, 0x10
add r0, r0, r28
clrlwi r29, r4, 0x10
stw r0, 0x54(r30)
bl TMCJPEGDEC_init_buff
cmpwi r3, 0
bge _err_restart_store_position
b _err_restart_return
_err_restart_store_position:
sth r29, 0(r31)
mr r3, r30
sth r28, 2(r31)
bl TMCJPEGDEC_get_position
stw r3, 4(r31)
lhz r4, 2(r31)
lhz r3, 0x10(r31)
lwz r0, 0xc(r31)
mullw r3, r4, r3
lhz r4, 0(r31)
subf r0, r3, r0
subf r3, r4, r0
_err_restart_return:
lwz r0, 0x24(r1)
lwz r31, 0x1c(r1)
lwz r30, 0x18(r1)
lwz r29, 0x14(r1)
lwz r28, 0x10(r1)
mtlr r0
addi r1, r1, 0x20
blr
}
#else
s32 TMCJPEGDEC_err_restart(TMCCJPEGDecWork* work) {
TMCCJPEGDecState* state;
TMCCJPEGDecWork* stream;
s32 result;
u16 interval;
u16 pitch;
u32 val;
s32 rem;
s32 div;
s32 next;
u8 rstDiff;
u8 byte;
u8 marker;
s32 r;
state = work->pState;
if (work->scanCount == 1) {
state->decodeResult = 0;
return 0;
}
stream = work;
result = TMCJPEGDEC_rewind_ptr(stream);
if (result < 0) {
return result;
r = TMCJPEGDEC_rewind_ptr(work);
if (r < 0) {
return r;
}
byte = *stream->pBufCur;
for (;;) {
byte = *work->pBufCur;
while (TRUE) {
while (byte != 0xFF) {
result = TMCJPEGDEC_get_byte(&byte, stream);
if (result < 0) {
return result;
r = TMCJPEGDEC_get_byte(&byte, work);
if (r < 0) {
return r;
}
}
result = TMCJPEGDEC_get_byte(&byte, stream);
marker = byte;
if (marker == 0xD9) {
if (result < 0 && result != TMCC_ERROR_UNDERFLOW) {
return result;
r = TMCJPEGDEC_get_byte(&byte, work);
if (byte == 0xD9) {
if (r < 0 && r != TMCC_ERROR_UNDERFLOW) {
return r;
}
return 0;
}
if (result < 0) {
return result;
if (r < 0) {
return r;
}
if (marker >= 0xD0 && marker <= 0xD7) {
break;
if (byte < 0xD0 || byte > 0xD7) {
continue;
}
// MWCC needs the stream reset here to keep the retail loop-exit branch layout.
stream = work;
if (byte > work->rstMarkerIdx + 0xCF) {
rstDiff = byte - (work->rstMarkerIdx + 0xCF);
} else {
rstDiff = (byte + 0x08) - (work->rstMarkerIdx + 0xCF);
}
work->rstMarkerIdx = (byte + 1) & 7;
interval = work->restartInterval;
pitch = state->maxX;
val = work->mcuPos;
work->components.dcPredict[0] = 0;
work->components.dcPredict[1] = 0;
work->components.dcPredict[2] = 0;
work->components.dcPredict[3] = 0;
work->restartCnt = 0;
next = (u8)(val & 0xFF) * (s32)pitch + (val >> 16) + (s32)(u8)(rstDiff * interval);
div = next / (s32)pitch;
rem = next - div * (s32)pitch;
work->mcuPos = (rem << 16) + (u16)div;
r = TMCJPEGDEC_init_buff(work);
if (r < 0) {
return r;
}
state->posX = rem;
state->posY = div;
state->position = TMCJPEGDEC_get_position(work);
return state->result - (state->posY * state->maxX) - state->posY;
}
return restartFromMarker(work, state, marker);
}
#endif
void TMCJPEGDEC_set_entropytbl(TMCJpegTableInfo* work, s32 idx, u8 data) {
switch (idx) {
@@ -1003,15 +1148,18 @@ void TMCJPEGDEC_set_entropytbl(TMCJpegTableInfo* work, s32 idx, u8 data) {
}
}
if ((s32)data != 1) {
if ((s32)data < 1 && (s32)data >= 0) {
work->pACFast = work->huffDecTblAC0;
work->pACHuffSym = work->maxCodeAC0;
work->pACHuffTbl = work->valPtrAC0;
}
} else {
work->pACFast = work->huffDecTblAC1;
work->pACHuffSym = work->maxCodeAC1;
work->pACHuffTbl = work->valPtrAC1;
if ((s32)data == 1) {
goto ac1;
}
if ((s32)data < 1 && (s32)data >= 0) {
work->pACFast = work->huffDecTblAC0;
work->pACHuffSym = work->maxCodeAC0;
work->pACHuffTbl = work->valPtrAC0;
}
return;
ac1:
work->pACFast = work->huffDecTblAC1;
work->pACHuffSym = work->maxCodeAC1;
work->pACHuffTbl = work->valPtrAC1;
}

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

@@ -1,3 +1,4 @@
#define TMC_JPEG_PLANAR_OUTPUT
#include <tmc_jpeg_internal.h>
static void TMCJPEG_814EFEAC(TMCCJPEGDecWork*, s32, s32);
@@ -13,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;
@@ -55,84 +25,97 @@ s32 TMCJPEGDEC_set_converterY8U8V8(TMCCJPEGDecWork* work) {
switch (componentCount) {
case 0: {
mode411 = work->idctMode;
firstRow411 = buffer + 4;
converter411 = TMCJPEG_814EFEAC;
edgeConverter411 = TMCJPEG_814F043C;
secondRow411 = firstRow411 + mode411;
thirdRow411 = secondRow411 + mode411;
fourthRow411 = thirdRow411 + mode411;
cbBlock411 = buffer + 260;
crBlock411 = buffer + 324;
work->pConverterFunc = converter411;
work->pConverterFuncEdge = edgeConverter411;
work->pConvRowPtrs[0] = firstRow411;
work->pConvRowPtrs[1] = secondRow411;
work->pConvRowPtrs[2] = thirdRow411;
work->pConvRowPtrs[3] = fourthRow411;
work->pConvRowPtrs[5] = cbBlock411;
work->pConvRowPtrs[6] = crBlock411;
u8 mode;
u8* firstRow;
u8* secondRow;
u8* thirdRow;
u8* fourthRow;
u8* cbBlock;
u8* crBlock;
mode = work->idctMode;
firstRow = buffer + 4;
work->pConverterFunc = TMCJPEG_814EFEAC;
work->pConverterFuncEdge = TMCJPEG_814F043C;
secondRow = firstRow + mode;
thirdRow = secondRow + mode;
fourthRow = thirdRow + mode;
cbBlock = buffer + 260;
crBlock = buffer + 324;
work->pConvRowPtrs[0] = firstRow;
work->pConvRowPtrs[1] = secondRow;
work->pConvRowPtrs[2] = thirdRow;
work->pConvRowPtrs[3] = fourthRow;
work->pConvRowPtrs[5] = cbBlock;
work->pConvRowPtrs[6] = crBlock;
work->pitch = 32;
work->converterFlags = 0;
break;
}
case 1: {
mode422 = work->idctMode;
firstRow422 = buffer + 4;
converter422 = TMCJPEG_814F0A58;
edgeConverter422 = TMCJPEG_814F11C4;
secondRow422 = firstRow422 + mode422;
cbBlock422 = buffer + 132;
crBlock422 = buffer + 196;
work->pConverterFunc = converter422;
work->pConverterFuncEdge = edgeConverter422;
work->pConvRowPtrs[0] = firstRow422;
work->pConvRowPtrs[1] = secondRow422;
work->pConvRowPtrs[5] = cbBlock422;
work->pConvRowPtrs[6] = crBlock422;
u8 mode;
u8* firstRow;
u8* secondRow;
u8* cbBlock;
u8* crBlock;
mode = work->idctMode;
firstRow = buffer + 4;
work->pConverterFunc = TMCJPEG_814F0A58;
work->pConverterFuncEdge = TMCJPEG_814F11C4;
secondRow = firstRow + mode;
cbBlock = buffer + 132;
crBlock = buffer + 196;
work->pConvRowPtrs[0] = firstRow;
work->pConvRowPtrs[1] = secondRow;
work->pConvRowPtrs[5] = cbBlock;
work->pConvRowPtrs[6] = crBlock;
work->pitch = 16;
work->converterFlags = 0;
break;
}
case 2: {
mode420 = work->idctMode;
firstRow420 = buffer + 4;
converter420 = TMCJPEG_814F17E0;
edgeConverter420 = TMCJPEG_814F1F48;
secondRow420 = firstRow420 + mode420;
thirdRow420 = firstRow420 + mode420 * 16;
fourthRow420 = thirdRow420 + mode420;
cbBlock420 = buffer + 260;
crBlock420 = buffer + 324;
work->pConverterFunc = converter420;
work->pConverterFuncEdge = edgeConverter420;
work->pConvRowPtrs[0] = firstRow420;
work->pConvRowPtrs[1] = secondRow420;
work->pConvRowPtrs[2] = thirdRow420;
work->pConvRowPtrs[3] = fourthRow420;
work->pConvRowPtrs[5] = cbBlock420;
work->pConvRowPtrs[6] = crBlock420;
u8 mode;
u8* firstRow;
u8* secondRow;
u8* thirdRow;
u8* fourthRow;
u8* cbBlock;
u8* crBlock;
mode = work->idctMode;
firstRow = buffer + 4;
work->pConverterFunc = TMCJPEG_814F17E0;
work->pConverterFuncEdge = TMCJPEG_814F1F48;
secondRow = firstRow + mode;
thirdRow = firstRow + mode * 16;
fourthRow = thirdRow + mode;
cbBlock = buffer + 260;
crBlock = buffer + 324;
work->pConvRowPtrs[0] = firstRow;
work->pConvRowPtrs[1] = secondRow;
work->pConvRowPtrs[2] = thirdRow;
work->pConvRowPtrs[3] = fourthRow;
work->pConvRowPtrs[5] = cbBlock;
work->pConvRowPtrs[6] = crBlock;
work->pitch = 16;
work->converterFlags = 0;
break;
}
case 3: {
u32 mode;
u8* crBlock;
u8* cbBlock;
u8* secondRow;
u8 mode;
u8* firstRow;
TMCConverterFunc* edgeConverter;
TMCConverterFunc* converter;
u8* secondRow;
u8* cbBlock;
u8* crBlock;
mode = work->idctMode;
firstRow = buffer + 4;
converter = TMCJPEG_814F2570;
edgeConverter = TMCJPEG_814F2B50;
work->pConverterFunc = TMCJPEG_814F2570;
work->pConverterFuncEdge = TMCJPEG_814F2B50;
secondRow = firstRow + mode * 8;
cbBlock = buffer + 132;
crBlock = buffer + 196;
work->pConverterFunc = converter;
work->pConverterFuncEdge = edgeConverter;
work->pConvRowPtrs[0] = firstRow;
work->pConvRowPtrs[1] = secondRow;
work->pConvRowPtrs[5] = cbBlock;
@@ -142,27 +125,27 @@ s32 TMCJPEGDEC_set_converterY8U8V8(TMCCJPEGDecWork* work) {
break;
}
case 4: {
TMCConverterFunc* edgeConverter;
TMCConverterFunc* converter;
TMCConverterFunc* edgeConverter;
converter = TMCJPEG_814F3158;
edgeConverter = TMCJPEG_814F32E4;
work->pConverterFunc = converter;
work->pConverterFuncEdge = edgeConverter;
work->pConvRowPtrs[0] = buffer + 4;
work->pConvRowPtrs[5] = buffer + 0x44;
work->pConvRowPtrs[6] = buffer + 0x84;
work->pConverterFunc = converter;
work->pConverterFuncEdge = edgeConverter;
work->pitch = 0x08;
work->converterFlags = 0;
break;
}
case 5: {
TMCConverterFunc* edgeConverter;
TMCConverterFunc* converter;
TMCConverterFunc* edgeConverter;
converter = TMCJPEG_814F34A4;
edgeConverter = TMCJPEG_814F372C;
work->pConvRowPtrs[0] = buffer + 4;
work->pConverterFunc = converter;
work->pConverterFuncEdge = edgeConverter;
work->pConvRowPtrs[0] = buffer + 4;
work->pitch = 0x08;
work->converterFlags = 0;
break;
@@ -175,25 +158,16 @@ s32 TMCJPEGDEC_set_converterY8U8V8(TMCCJPEGDecWork* work) {
{
s32 width = state->jpegWidth;
s32 height = state->jpegHeight;
s32 roundedWidth;
s32 heightPadding;
roundedWidth = (u32)width / 8 + (width % 8 != 0);
heightPadding = height % 4 != 0;
state->convWidth = roundedWidth * 8;
state->convHeight = ((u32)height / 4 + heightPadding) * 4;
state->convWidth = ((u32)width / 8 + (width % 8 != 0)) * 8;
state->convHeight = ((u32)height / 4 + (height % 4 != 0)) * 4;
width = state->outputWidth;
height = state->outputHeight;
roundedWidth = (u32)width / 8 + (width % 8 != 0);
heightPadding = height % 4 != 0;
state->chromaWidth = roundedWidth * 8;
state->chromaHeight = ((u32)height / 4 + heightPadding) * 4;
state->chromaWidth = ((u32)width / 8 + (width % 8 != 0)) * 8;
state->chromaHeight = ((u32)height / 4 + (height % 4 != 0)) * 4;
}
return 0;
}
#pragma pop
static void TMCJPEG_814EFEAC(TMCCJPEGDecWork* work, s32 x, s32 y) {
s32 rowSkip;
u8* output;

View File

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

View File

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

View File

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

View File

@@ -185,7 +185,7 @@ extern ziU16 Zi8Ord2Ord(ziU16, ziPtr);
extern ziU8 Zi8LangSupported(ziU8, ziPtr);
extern ziU16 Zi8GetTableCount(ziU8,ziU8,ziPtr);
extern ziU32 Zi8GetTableAddress(ziU8,ziU8,ziPtr);
extern ziPtr Zi8Memset(ziPtr destination, ziU32 value, ziS32 count);
extern void Zi8Memset(ziU8*,ziU32,ziS32);
extern ziU8 _Zi8GetCandidates(ziGetParam*,ziPtr);
extern void Zi8InitDupWordBuf(ziPtr);
extern ziU32 Zi8GetPInfo(ziU32,ziWChar *,ziU8,ziPtr);
@@ -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];
@@ -355,13 +354,16 @@ ziU8 MatchAltSound1Key(ziU16 *spelling,Zi8UInt spellingLength,Zi8UInt requireFul
if ((keyHigh == records[recordIndex].keyHigh) &&
(keyLow == records[recordIndex].keyLow)) {
searchIndex = recordIndex;
} else {
if (keyHigh != records[searchIndex].keyHigh || keyLow != records[searchIndex].keyLow) {
goto BINARY_SEARCH;
}
goto START_PROCESS;
}
if ((keyHigh == records[searchIndex].keyHigh) &&
(keyLow == records[searchIndex].keyLow)) {
goto START_PROCESS;
}
goto BINARY_SEARCH;
START_PROCESS:
recordIndex = searchIndex;
PROCESS:
do {
if (((records[recordIndex].flags & 0xeU) == 0) ||
((modifierFlags & records[recordIndex].flags) != 0)) {
@@ -400,6 +402,7 @@ BACKWARD_PROCESS:
}
}
}
goto BACKWARD_TEST;
BACKWARD_TEST:
recordIndex = recordIndex - 1;
if ((((int)recordIndex < 0) || (keyHigh != records[recordIndex].keyHigh)) ||
@@ -455,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)
@@ -770,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;
@@ -930,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;
@@ -1314,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++;
@@ -1382,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++;
@@ -1422,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;
}
@@ -1486,41 +1495,41 @@ ziU32 Zi8Get1KeyPressCandidates(ziGetParam *params,Zi8OneKeyOptions *options,Zi8
elementIndex = MatchAltSound1Key(spelling,inputLimit,matchFull,(Zi8AltSoundRecord *)alternateTable,phoneticMask,phoneticTable,
phraseCharacter,tone,includeTone,languageMask,work);
}
if (elementIndex != 0) {
if (!emitWords) {
if (trackDuplicates && (ziU8)Zi8SetFindCand(params->scratch,phraseCharacter,work) != 0) goto nextPhrase;
for (index = 0; index < candidateCount; index++) {
if (firstOrdinal == output[index]) goto nextPhrase;
}
} else {
wordLength = 0;
do {
phraseCharacter = ((ziU16)entryCursor[1] << 8) | *entryCursor;
entryCursor += 2;
output[outputIndex + wordLength++] = Zi8Ord2Uni(phraseCharacter & 0x7fff,work);
} while ((phraseCharacter & 0x8000) == 0);
if (prefixSearch != 0 || params->elementCount != 0) wordLength = 1;
if (Zi8IsDupWordW(output + outputIndex,wordLength,work) != 0) goto nextPhrase;
output[outputIndex + wordLength] = 0;
if (elementIndex == 0) goto nextPhrase;
if (!emitWords) {
if (trackDuplicates && (ziU8)Zi8SetFindCand(params->scratch,phraseCharacter,work) != 0) goto nextPhrase;
for (index = 0; index < candidateCount; index++) {
if (firstOrdinal == output[index]) goto nextPhrase;
}
if (optionsMask == 5) {
if (++totalCandidates >= options->maxCount) goto finishCandidates;
} else if (remaining == 0) {
totalCandidates++;
candidateCount++;
if (emitWords) {
outputIndex += wordLength;
output[outputIndex++] = 0x20;
} else {
output[outputIndex++] = firstOrdinal;
}
if (candidateCount >= params->maxCandidates || outputIndex > outputLimit) {
params->count = candidateCount;
goto finishCandidates;
}
} else {
wordLength = 0;
do {
phraseCharacter = ((ziU16)entryCursor[1] << 8) | *entryCursor;
entryCursor += 2;
output[outputIndex + wordLength++] = Zi8Ord2Uni(phraseCharacter & 0x7fff,work);
} while ((phraseCharacter & 0x8000) == 0);
if (prefixSearch != 0 || params->elementCount != 0) wordLength = 1;
if (Zi8IsDupWordW(output + outputIndex,wordLength,work) != 0) goto nextPhrase;
output[outputIndex + wordLength] = 0;
}
if (optionsMask == 5) {
totalCandidates++;
if (totalCandidates >= options->maxCount) goto finishCandidates;
} else if (remaining == 0) {
totalCandidates++;
candidateCount++;
if (emitWords) {
outputIndex += wordLength;
output[outputIndex++] = 0x20;
} else {
remaining--;
output[outputIndex++] = firstOrdinal;
}
if (candidateCount >= params->maxCandidates || outputIndex > outputLimit) {
params->count = candidateCount;
goto finishCandidates;
}
} else {
remaining--;
}
}
nextPhrase:
@@ -1551,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) {
@@ -1568,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++;
@@ -1594,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];
@@ -1620,27 +1630,26 @@ finishPhrases:
elementIndex = MatchAltSound1Key(spelling,inputLimit,matchFull,(Zi8AltSoundRecord *)alternateTable,phoneticMask,phoneticTable,userOrdinal,
tone,includeTone,languageMask,work);
}
if (elementIndex != 0) {
if (!emitWords) {
if (trackDuplicates && (ziU8)Zi8SetFindCand(params->scratch,userOrdinal,work) != 0) goto nextUserOrdinal;
userCharacter = Zi8Ord2Uni(userOrdinal,work);
for (duplicateIndex = 0; duplicateIndex < candidateCount; duplicateIndex++) {
if (userCharacter == output[duplicateIndex]) break;
}
if (duplicateIndex < candidateCount) goto nextUserOrdinal;
} else {
userCharacter = Zi8Ord2Uni(userOrdinal,work);
if (Zi8IsDupWordW(&userCharacter,1,work) != 0) goto nextUserOrdinal;
}
if (remaining == 0) {
totalCandidates++;
candidateCount++;
output[outputIndex++] = userCharacter;
if (emitWords) output[outputIndex++] = 0x20;
if (candidateCount >= params->maxCandidates || outputIndex > outputLimit) goto finishCandidates;
} else {
remaining--;
if (elementIndex == 0) goto nextUserOrdinal;
if (!emitWords) {
if (trackDuplicates && (ziU8)Zi8SetFindCand(params->scratch,userOrdinal,work) != 0) goto nextUserOrdinal;
userCharacter = Zi8Ord2Uni(userOrdinal,work);
for (duplicateIndex = 0; duplicateIndex < candidateCount; duplicateIndex++) {
if (userCharacter == output[duplicateIndex]) break;
}
if (duplicateIndex < candidateCount) goto nextUserOrdinal;
} else {
userCharacter = Zi8Ord2Uni(userOrdinal,work);
if (Zi8IsDupWordW(&userCharacter,1,work) != 0) goto nextUserOrdinal;
}
if (remaining == 0) {
totalCandidates++;
candidateCount++;
output[outputIndex++] = userCharacter;
if (emitWords) output[outputIndex++] = 0x20;
if (candidateCount >= params->maxCandidates || outputIndex > outputLimit) goto finishCandidates;
} else {
remaining--;
}
}
}
@@ -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)))) {
@@ -1675,33 +1683,31 @@ nextUserOrdinal:
elementIndex = MatchAltSound1Key(spelling,inputLimit,matchFull,(Zi8AltSoundRecord *)alternateTable,phoneticMask,phoneticTable,ordinal,
tone,includeTone,languageMask,work);
}
if (elementIndex != 0) {
unicodeCharacter = ((ziU16)phraseTable[6] << 8) + (ziU16)phraseTable[7];
if (unicodeCharacter != previousCharacter) {
previousCharacter = unicodeCharacter;
if (!emitWords) {
if (trackDuplicates && (ziU8)Zi8SetFindCand(params->scratch,ordinal,work) != 0) goto nextOrdinal;
for (index = 0; index < candidateCount; index++) {
if (unicodeCharacter == output[index]) break;
}
if (index < candidateCount) goto nextOrdinal;
} else {
if (Zi8IsDupWordW(&unicodeCharacter,1,work) != 0) goto nextOrdinal;
}
if (remaining == 0) {
totalCandidates++;
if (options->countOnly == 0) {
candidateCount++;
output[outputIndex++] = unicodeCharacter;
if (emitWords) output[outputIndex++] = 0x20;
} else {
if (totalCandidates >= options->maxCount) break;
}
if (candidateCount >= params->maxCandidates || outputIndex > outputLimit) break;
} else {
remaining--;
}
if (elementIndex == 0) goto nextOrdinal;
unicodeCharacter = ((ziU16)phraseTable[6] << 8) + (ziU16)phraseTable[7];
if (unicodeCharacter == previousCharacter) goto nextOrdinal;
previousCharacter = unicodeCharacter;
if (!emitWords) {
if (trackDuplicates && (ziU8)Zi8SetFindCand(params->scratch,ordinal,work) != 0) goto nextOrdinal;
for (index = 0; index < candidateCount; index++) {
if (unicodeCharacter == output[index]) break;
}
if (index < candidateCount) goto nextOrdinal;
} else {
if (Zi8IsDupWordW(&unicodeCharacter,1,work) != 0) goto nextOrdinal;
}
if (remaining == 0) {
totalCandidates++;
if (options->countOnly == 0) {
candidateCount++;
output[outputIndex++] = unicodeCharacter;
if (emitWords) output[outputIndex++] = 0x20;
} else {
if (totalCandidates >= options->maxCount) break;
}
if (candidateCount >= params->maxCandidates || outputIndex > outputLimit) break;
} else {
remaining--;
}
}
nextOrdinal:
@@ -1781,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;
@@ -1838,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

@@ -231,7 +231,7 @@ ziBool Zi8IsVowel(ziU8 language, ziWChar character) {
if (language == 47) return ZI8_FALSE;
switch (character) {
case 0xFF: case 0x152: case 0x153: case 0x178:
break;
goto vowel;
default:
return ZI8_FALSE;
}
@@ -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);
@@ -461,14 +460,10 @@ int Zi8AlphaGetCandidates(ziGetParam* parameters, ziPtr optionData, ziPtr workDa
if (((Zi8GetTableCount(parameters->language,0x1f,workData) & 0x80) != 0) && (parameters->subLanguage == 0x80)) {
contextEnabled = ZI8_TRUE;
}
if (((ZiAlphaOptions*)optionData)->lookupMode != '\0' ||
parameters->subLanguage == 7 ||
parameters->subLanguage == language ||
parameters->subLanguage == 0 ||
parameters->subLanguage == 1 ||
parameters->subLanguage == 2 ||
parameters->subLanguage == 0x80 ||
(Zi8LangSupported(parameters->subLanguage,workData)) == '\0') {
if (!(((((ZiAlphaOptions*)optionData)->lookupMode == '\0') && (parameters->subLanguage != 7)) &&
((parameters->subLanguage != language &&
((((parameters->subLanguage != 0 && (parameters->subLanguage != 1)) && (parameters->subLanguage != 2)) &&
((parameters->subLanguage != 0x80 && ((Zi8LangSupported(parameters->subLanguage,workData)) != '\0'))))))))) {
languagePassCount = 0;
if (((ZiAlphaWork*)workData)->language != parameters->language) {
((ZiAlphaWork*)workData)->language = 0;
@@ -555,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 &&
@@ -563,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)) {
@@ -571,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;
@@ -659,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)) ||
@@ -705,6 +700,7 @@ preparePrefix:
prefixVowelRestriction = ZI8_FALSE;
}
}
goto prepareDictionaryOrder;
prepareDictionaryOrder:
((ZiAlphaWork*)workData)->dictionaryOrder[0] = 0;
if ((Zi8GetTableCount(language,0x1f,workData) & 0x20) != 0) {
@@ -776,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:
@@ -791,7 +787,7 @@ selectDictionary:
case 3:
case 4:
case 10:
continue;
goto finishDictionaryPass;
}
}
{
@@ -809,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 ||
@@ -835,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) {
@@ -847,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++) {
@@ -904,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);
}
}
}
@@ -926,33 +922,36 @@ 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) {
dictionaryStatus[dictionaryKind] = 1;
if (elements[apostropheIndex] >= 0xEFF1) continue;
goto finishDictionaryPass;
}
}
if (wordLength != 0) goto filterVowelCandidate;
dictionaryStatus[dictionaryKind] = 1;
if (elements[apostropheIndex] >= 0xEFF1) goto retryDictionary;
goto finishDictionaryPass;
}
filterVowelCandidate:
if ((wordLength != 0) && (prefixVowelRestriction)) {
if ((*wordCursor >= 0x30) && (*wordCursor <= 0x39)) {
wordLength = 0;
@@ -962,17 +961,20 @@ selectDictionary:
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;
}
}
@@ -980,7 +982,7 @@ selectDictionary:
if (wordLength == 0) {
wordLength = 0;
dictionaryStatus[dictionaryKind] = 1;
continue;
goto retryDictionary;
}
}
if (wordLength != 0) {
@@ -996,9 +998,9 @@ selectDictionary:
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:
@@ -1006,8 +1008,8 @@ selectDictionary:
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;
}
@@ -1017,11 +1019,10 @@ selectDictionary:
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;
@@ -1073,19 +1074,15 @@ selectDictionary:
(((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)) ||
@@ -1097,16 +1094,8 @@ selectDictionary:
(((((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:
break;
default:
goto finishDictionaryPass;
}
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;
}
@@ -1115,17 +1104,18 @@ selectDictionary:
}
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;
@@ -1137,8 +1127,8 @@ selectDictionary:
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;
@@ -1155,7 +1145,7 @@ selectDictionary:
wordCursor[wordLength] = 0;
}
if (((int)((ZiAlphaOptions*)optionData)->maxWordLength < (int)(wordLength + prefixCount)) ||
((Zi8IsDupWordW(wordCursor - prefixCount,wordLength + prefixCount,
((Zi8IsDupWordW(wordCursor - prefixCount,wordLength + prefixCount & 0xff,
workData)) != '\0')) {
if ((prefixCount != 0) && (((ZiAlphaOptions*)optionData)->maxWordLength <= prefixCount)) break;
}
@@ -1168,11 +1158,12 @@ selectDictionary:
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;
@@ -1550,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;
}
@@ -1559,27 +1551,20 @@ checkPrefixPunctuation:
goto preparePrefix;
}
}
if (completionAllowed ||
((ZiAlphaWork*)workData)->suffixMode != 0 ||
((ZiAlphaWork*)workData)->prefixCount == 0 ||
elementCount <= 2 ||
((ZiAlphaWork*)workData)->prefixCount != elementCount - 1 ||
Zi8IsAlphaPunct(parameters->elements[((ZiAlphaWork*)workData)->prefixCount - 1]) == 0) {
if (!completionAllowed && ((ZiAlphaWork*)workData)->suffixMode == 0 && parameters->elementCount > 1 &&
Zi8IsAlphaPunct(parameters->elements[parameters->elementCount - 1]) == 0) goto finishCandidates;
}
if (!completionAllowed && ((ZiAlphaWork*)workData)->suffixMode == 0 && ((ZiAlphaWork*)workData)->prefixCount != 0 &&
elementCount > 2 && ((ZiAlphaWork*)workData)->prefixCount == elementCount - 1 &&
Zi8IsAlphaPunct(parameters->elements[((ZiAlphaWork*)workData)->prefixCount - 1]) != 0) goto checkPrefixFields;
if (!completionAllowed && ((ZiAlphaWork*)workData)->suffixMode == 0 && parameters->elementCount > 1 &&
Zi8IsAlphaPunct(parameters->elements[parameters->elementCount - 1]) == 0) goto finishCandidates;
checkPrefixFields:
prefixMode = ((ZiAlphaWork*)workData)->suffixMode;
prefixLength = ((ZiAlphaWork*)workData)->prefixCount;
if (prefixMode == 0 &&
prefixLength != 0 &&
elementCount > 2 &&
prefixLength == elementCount - 1 &&
parameters->elements[parameters->elementCount - 1] != 0xEFF1) {
((ZiAlphaWork*)workData)->suffixMode = 1;
((ZiAlphaWork*)workData)->prefixElementCount = parameters->elementCount;
prefixPrepared = ZI8_TRUE;
goto preparePrefix;
}
if (prefixMode != 0 || prefixLength == 0 || elementCount <= 2 ||
prefixLength != elementCount - 1 || parameters->elements[parameters->elementCount - 1] == 0xEFF1) goto finishCandidates;
((ZiAlphaWork*)workData)->suffixMode = 1;
((ZiAlphaWork*)workData)->prefixElementCount = parameters->elementCount;
prefixPrepared = ZI8_TRUE;
goto preparePrefix;
finishCandidates:
((ZiAlphaWork*)workData)->usePrefixAsElements = 0;
@@ -1652,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

@@ -1,95 +1,108 @@
#include <zi8clib/zitypes.h>
ziU16 Zi8MatchAltSound(ziU8* elements, ziU16 count, ziU8* table, ziU16 ordinal,
ziU16 Zi8MatchAltSound(ziU8* elements, ziU16 count, ziU8* table, ziU16 ch,
ziU32 mask, ziU16 target, ziU8 flags ZI_NEED_WORK) {
ziU8 ordinalHigh;
ziU8 ordinalLow;
ziS32 recordIndex;
ziS32 searchIndex;
ziS32 midpoint;
ziU16 phoneticOffset;
ziU16 phoneticCode;
ziU8 hi;
ziU8 lo;
ziS32 i;
ziS32 j;
ziS32 mid;
ziU16 off;
ziU16 w;
ordinalHigh = (ziU8)(ordinal >> 8);
ordinalLow = (ziU8)ordinal;
hi = (ziU8)((ziU16)ch >> 8);
lo = (ziU8)ch;
flags = (ziU8)(flags >> 3);
if (count == 0) {
return 0;
}
searchIndex = 0;
recordIndex = count - 1;
if ((elements + recordIndex * 4)[1] == ordinalHigh && (elements + recordIndex * 4)[0] == ordinalLow) {
searchIndex = recordIndex;
} else {
if ((elements + searchIndex * 4)[1] != ordinalHigh || (elements + searchIndex * 4)[0] != ordinalLow) {
goto search;
}
j = 0;
i = count - 1;
if ((elements + i * 4)[1] == hi && (elements + i * 4)[0] == lo) {
j = i;
goto up;
}
if ((elements + j * 4)[1] == hi && (elements + j * 4)[0] == lo) {
goto up;
}
goto search;
up:
recordIndex = searchIndex;
do {
if (((elements + recordIndex * 4)[3] & 0xE) == 0 ||
((elements + recordIndex * 4)[3] & flags) != 0) {
phoneticOffset = (ziU16)(((ziU16)(elements + recordIndex * 4)[2] |
(((ziU16)(elements + recordIndex * 4)[3] & 1) << 8)) << 1);
phoneticCode = (ziU16)((((ziU16)(elements + recordIndex * 4)[3] & 0xF0) >> 4) |
(table[phoneticOffset] | ((ziU16)table[phoneticOffset + 1] << 8)));
if (target == (phoneticCode & (ziU16)mask)) {
return phoneticCode;
}
}
recordIndex++;
if (recordIndex >= count) {
break;
}
} while ((elements + recordIndex * 4)[1] == ordinalHigh && (elements + recordIndex * 4)[0] == ordinalLow);
recordIndex = searchIndex;
while (--recordIndex >= 0 && (elements + recordIndex * 4)[1] == ordinalHigh && (elements + recordIndex * 4)[0] == ordinalLow) {
if (((elements + recordIndex * 4)[3] & 0xE) == 0 ||
((elements + recordIndex * 4)[3] & flags) != 0) {
phoneticOffset = (ziU16)(((ziU16)(elements + recordIndex * 4)[2] |
(((ziU16)(elements + recordIndex * 4)[3] & 1) << 8)) << 1);
phoneticCode = (ziU16)((((ziU16)(elements + recordIndex * 4)[3] & 0xF0) >> 4) |
(table[phoneticOffset] | ((ziU16)table[phoneticOffset + 1] << 8)));
if (target == (phoneticCode & (ziU16)mask)) {
return phoneticCode;
}
i = j;
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) {
goto down_start;
}
if ((elements + i * 4)[1] == hi && (elements + i * 4)[0] == lo) {
goto body;
}
down_start:
i = j;
goto dec;
down_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;
}
}
dec:
i--;
if (i < 0) {
goto fail;
}
if ((elements + i * 4)[1] == hi && (elements + i * 4)[0] == lo) {
goto down_body;
}
fail:
return 0;
search:
if ((elements + searchIndex * 4)[1] == ordinalHigh && (elements + searchIndex * 4)[0] == ordinalLow) {
if ((elements + j * 4)[1] == hi && (elements + j * 4)[0] == lo) {
goto up;
}
if ((((ziU16)(elements + searchIndex * 4)[1] << 8) | (ziU16)(elements + searchIndex * 4)[0]) > ordinal) {
if ((((ziU16)(elements + j * 4)[1] << 8) | (ziU16)(elements + j * 4)[0]) > ch) {
return 0;
}
midpoint = (searchIndex + recordIndex) / 2;
if (midpoint == searchIndex) {
mid = (j + i) / 2;
if (mid == j) {
return 0;
}
if ((((ziU16)(elements + midpoint * 4)[1] << 8) | (ziU16)(elements + midpoint * 4)[0]) >= ordinal) {
recordIndex = midpoint;
} else {
searchIndex = midpoint;
goto search;
}
hi_check:
if ((elements + recordIndex * 4)[1] == ordinalHigh && (elements + recordIndex * 4)[0] == ordinalLow) {
searchIndex = recordIndex;
goto up;
}
if ((((ziU16)(elements + recordIndex * 4)[1] << 8) | (ziU16)(elements + recordIndex * 4)[0]) < ordinal) {
return 0;
}
midpoint = (searchIndex + recordIndex) / 2;
if (midpoint == searchIndex) {
return 0;
}
if ((((ziU16)(elements + midpoint * 4)[1] << 8) | (ziU16)(elements + midpoint * 4)[0]) >= ordinal) {
recordIndex = midpoint;
if ((((ziU16)(elements + mid * 4)[1] << 8) | (ziU16)(elements + mid * 4)[0]) >= ch) {
i = mid;
goto hi_check;
}
searchIndex = midpoint;
j = mid;
goto search;
hi_check:
if ((elements + i * 4)[1] == hi && (elements + i * 4)[0] == lo) {
j = i;
goto up;
}
if ((((ziU16)(elements + i * 4)[1] << 8) | (ziU16)(elements + i * 4)[0]) < ch) {
return 0;
}
mid = (j + i) / 2;
if (mid == j) {
return 0;
}
if ((((ziU16)(elements + mid * 4)[1] << 8) | (ziU16)(elements + mid * 4)[0]) >= ch) {
i = mid;
goto hi_check;
}
j = mid;
goto search;
}

File diff suppressed because it is too large Load Diff

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;
}
@@ -643,7 +643,7 @@ ziU32 Zi8GetSInfo(ziU8* strokes, ziU8* extraStrokes, ziWChar* outputBuffer, ziU8
{
int strokeIndex;
int outputCount;
int extraCount;
volatile int extraCount;
outputCount = 0;
Zi8LogError(100, work);
@@ -652,14 +652,17 @@ ziU32 Zi8GetSInfo(ziU8* strokes, ziU8* extraStrokes, ziWChar* outputBuffer, ziU8
return 0;
}
for (strokeIndex = 0; strokeIndex < 4; strokeIndex++) {
if (strokeIndex != 0) {
outputBuffer[(ziU8)outputCount] = zi8StrokeCode((strokes[strokeIndex] & 0xf0) >> 4, work);
if (outputBuffer[(ziU8)outputCount++] == 0) {
badStroke:
outputBuffer[(ziU8)--outputCount] = 0;
return outputCount;
}
if (strokeIndex == 0) {
goto lowStroke;
}
outputBuffer[(ziU8)outputCount] = zi8StrokeCode((strokes[strokeIndex] & 0xf0) >> 4, work);
if (outputBuffer[(ziU8)outputCount++] != 0) {
goto lowStroke;
}
badStroke:
outputBuffer[(ziU8)--outputCount] = 0;
return outputCount;
lowStroke:
outputBuffer[(ziU8)outputCount] = zi8StrokeCode(strokes[strokeIndex] & 0xf, work);
if (outputBuffer[(ziU8)outputCount++] == 0) {
goto badStroke;
@@ -855,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 {
@@ -889,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;
@@ -914,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) {
@@ -936,6 +939,7 @@ ziU32 ZiCharInfo2(ziWChar ch, ziWChar* charInfoBuffer, ziU8 maxInfoBufSize, ziU3
}
Zi8LogError(100,work);
return count;
}
index++;
tablePtr = tablePtr + 4;
@@ -949,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:
@@ -970,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;
@@ -989,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;
@@ -1005,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--;
@@ -1038,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,38 +117,36 @@ 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;
}
if (context->cnt < count) goto descend;
}
if (context->cnt >= search[1]) {
if (search[0] != 0 && context->cnt > search[1]) goto next_sibling;
if (acceptPrefix != 0 || ZiDAWGgetEOWattribute(current->node)) {
for (index = 0; index < context->cnt; index++) output[index] = (ziU16)records[index].attr;
result = context->cnt;
searching = 0;
if (acceptPrefix != 0) goto next_sibling;
}
if (search[0] != 0 && context->cnt >= search[1]) goto next_sibling;
if (context->cnt < search[1]) goto descend;
if (search[0] != 0 && context->cnt > search[1]) goto next_sibling;
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;
if (acceptPrefix != 0) goto next_sibling;
}
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:
return result;
}
@@ -235,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;
@@ -278,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:
@@ -326,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);
}
}
@@ -383,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;
} 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;
}
if (cur == param->elementCount) goto L5dc;
if (firstCand != 0) {
firstCand--;
goto L5dc;
}
if (sw->countOnly != 0) {
if (++count >= sw->maxCount) goto end;
goto L5dc;
}
search_syllables:
for (; syllableLength >= 1; syllableLength--) {
nextMatch = 0;
goto match_syllable;
syllable_found:
nextMatch = 1;
if (syllableLength == 1) {
needKeyFallback = 0;
}
if (output[0] >= 0xEFF1 && output[0] <= 0xF010) {
continue;
}
emit_syllable:
if (remainingSkip != 0) {
remainingSkip--;
} else if (sw->countOnly != 0) {
if (++candidateCount >= sw->maxCount) goto end;
for (i = cur; i < param->elementCount; i += sylCnt) {
if (param->elements[i] == 0xEFF1 && param->elementCount - i > 1 && flag14 != 0) {
buf2[0] = 0x2D;
} 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;
Zi8getKeyLayout(param->language, param->elements[i], buf2, 1, ZI_WORK);
}
next_syllable:
if (nextCharacter != 0) {
if (*nextCharacter == 0) goto end;
output[0] = *nextCharacter++;
goto emit_syllable;
}
match_syllable:
if (Zi8SyllablesROMdata(param->elements, (ziU8)syllableLength, param->language, output,
(ziU16)remainingCapacity, nextMatch, 0, reverseOrder, ZI_WORK) != 0) {
goto syllable_found;
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 (needKeyFallback != 0) {
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;
}
while (keyLayout[index] != 0) {
keyLayout[index] = keyLayout[index + 1];
index++;
}
} else {
Zi8getKeyLayout(param->language, param->elements[0], keyLayout, 1, ZI_WORK);
if (u28 != 0) {
for (i = 0; i < param->elementCount; i++) {
u28[i] = Zi8ConvertWC2UC(out[i], param->language, ZI_WORK);
}
syllableLength = 1;
nextCharacter = keyLayout;
goto next_syllable;
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;
L5dc:
while (cur >= 1) {
flag12 = 0;
goto rom;
found:
flag12 = 1;
if (cur == 1) {
flag13 = 0;
}
L464:
if (out[0] >= 0xEFF1 && out[0] <= 0xF010) {
goto dec;
}
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 {
i = cur;
out[i++] = 0;
out[i] = 0;
out += i;
}
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;
}
rom:
if (Zi8SyllablesROMdata(param->elements, (ziU8)cur, param->language, out,
(ziU16)rem, flag12, 0, flag11, ZI_WORK) != 0) {
goto found;
}
dec:
cur--;
}
if (flag13 == 0) goto end;
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 (buf2[i] != 0) {
buf2[i] = buf2[i + 1];
i++;
}
} else {
Zi8getKeyLayout(param->language, param->elements[0], buf2, 1, ZI_WORK);
}
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,19 +64,20 @@ 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;
} else {
getParam.getMode = 1;
if (_Zi8GetCandidates(&getParam, __zi8_work_data) != 0) {
charSet |= getParam.subLanguage;
} else {
getParam.getMode = 2;
if (_Zi8GetCandidates(&getParam, __zi8_work_data) != 0) {
charSet |= getParam.subLanguage;
}
}
goto next;
}
getParam.getMode = 1;
if (_Zi8GetCandidates(&getParam, workData) != 0) {
charSet |= getParam.subLanguage;
goto next;
}
getParam.getMode = 2;
if (_Zi8GetCandidates(&getParam, workData) != 0) {
charSet |= getParam.subLanguage;
}
next:
if (getParam.subLanguage == 1) {
getParam.subLanguage = 4;
goto retry;
@@ -122,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,46 +368,46 @@ match_code:
} else if (numParts > 1) {
goto next_node;
}
if (((ziU8)matchedParts == numParts) || (numParts == 0)) {
if (((ziU8)traversal.matchedParts == numParts) || (numParts == 0)) {
*resultNode = node;
*resultCode = ((ziU16)node[6] << 8) + node[7];
*count = remaining;
*count = traversal.remaining;
return 1;
}
/* 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) {
code = Zi8GetPCode(pCodeTable, dictionary + (dictionaryIndex & 0x7FFF) * sizeof(DictionaryNode));
if (((code & masks[partIndex]) != values[partIndex]) && (altMode == 0) && (dictionary[(dictionaryIndex & 0x7FFF) * sizeof(DictionaryNode)] & 0x80) != 0) {
code = Zi8MatchAltSound(soundTable, soundCode, pCodeTable, dictionaryIndex & 0x7FFF, masks[partIndex], values[partIndex], flag, ZI_WORK);
}
if ((code & masks[partIndex]) == values[partIndex]) {
goto phonetic_matched;
}
if (traversal.hasString) {
goto phonetic_skip;
}
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 ((traversal.code & masks[traversal.partIndex]) == values[traversal.partIndex]) {
goto phonetic_matched;
}
phonetic_skip:
if ((dictionaryIndex & 0x8000) == 0) {
if ((traversal.dictionaryIndex & 0x8000) == 0) {
sound++;
while ((*sound & 0x80) == 0) {
sound += 2;
@@ -412,23 +416,23 @@ phonetic_skip:
}
break;
phonetic_matched:
if (++partIndex == numParts) {
if (++traversal.partIndex == numParts) {
if (partialMode != 0) {
if (strictMode == 0 && (dictionaryIndex & 0x8000) != 0) goto phonetic_skip;
if (strictMode != 0 && (dictionaryIndex & 0x8000) == 0) goto phonetic_skip;
if (strictMode == 0 && (traversal.dictionaryIndex & 0x8000) != 0) goto phonetic_skip;
if (strictMode != 0 && (traversal.dictionaryIndex & 0x8000) == 0) goto phonetic_skip;
}
*resultNode = node;
*resultCode = ((ziU16)node[6] << 8) + node[7];
*count = remaining;
*count = traversal.remaining;
return 1;
}
} while ((dictionaryIndex & 0x8000) == 0);
} while ((traversal.dictionaryIndex & 0x8000) == 0);
}
}
if ((nextCode & 0x80) != 0) goto next_node;
if ((traversal.nextCode & 0x80) != 0) goto next_node;
goto next_group;
check_code:
if (*values == (code & *masks)) goto match_code;
if (*values == (traversal.code & *masks)) goto match_code;
goto next_node;
}
return 0;
@@ -479,14 +483,17 @@ ziU8 Zi8GetPyPhonetic(ziWChar* text, ziU8 count, ziU16* initial, ziU16* final, z
initial[outputIndex] = 0;
final[outputIndex] = 0;
value = *current;
if (value >= 0x61) {
if (value <= 0x7A) {
goto pinyin_ascii;
}
if (value < 0x61) {
goto check_pinyin_extension;
}
if (value >= 0xF361) {
if (value <= 0xF37A) goto pinyin_extension;
if (value <= 0x7A) {
goto pinyin_ascii;
}
check_pinyin_extension:
if (value < 0xF361) {
goto invalid_pinyin;
}
if (value <= 0xF37A) goto pinyin_extension;
invalid_pinyin:
*bestInitial = *bestFinal = initial[0] = final[0] = 0xFFFF;
return 1;
@@ -517,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;
@@ -545,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;
}
@@ -605,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;
@@ -636,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;
@@ -648,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;
@@ -659,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;
@@ -680,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;
}
}
}
}
}
}
@@ -712,26 +711,33 @@ pinyin_initial:
*resultCount -= 1;
}
return result;
}
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;
}
@@ -785,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,18 +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);
} else {
if (ch >= ZI_WORK->unicodeRange2Min && ch <= ZI_WORK->unicodeRange2Max) {
i = (ziU16)(ZI_WORK->unicodeRange1Max + (ch - ZI_WORK->unicodeRange2Min) -
ZI_WORK->unicodeRange1Min + 1);
} else {
return 0xFFFF;
}
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;
}
i = ZI_WORK->unicodeMap[i];
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 = WORKP->unicodeMap[i];
if (i != 0xFFFF) {
e = (ziU8*)table + i * 0xC;
if (hi == e[6] && lo == e[7]) {
@@ -107,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]);
@@ -122,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

@@ -76,16 +76,18 @@ ziU8 Zi8ZHaddSpace(ziWChar* src, ziU8 count, ziWChar* dst,
i = 2;
}
if (i-- <= m) {
for (k = 0; k < i; k++) {
pdst[k] = psrc[k];
}
pdst[k] = 0;
Zi8LogError(0x64, ZI_WORK);
return 1;
if (i-- > m) {
goto fail;
}
for (k = 0; k < i; k++) {
pdst[k] = psrc[k];
}
pdst[k] = 0;
Zi8LogError(0x64, ZI_WORK);
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) {
@@ -103,7 +96,7 @@ ziU8 Zi8MatchUWDdata(ziWChar* pattern, ziU8 length, ziWChar* currentWord, ziU16
ziU32 size;
int headerSize;
int entryLanguage;
int entryLength;
volatile int entryLength;
int previousOffset;
int visited = 0;
int fallback = 0;
@@ -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,249 +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) {
{
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;
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 (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) {
}
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 {
wordIndex = 1;
remainingLetters = param->wordCharCount - 1;
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) {
return param->letters;
}
}
} else {
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 ((search.prefixCount += search.candidateCount) >= (ziS32)options->maxCount) return options->maxCount;
param->count = 0;
param->letters = 0;
search.candidateCount = 0;
} else {
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;
search.remainingLetters = param->wordCharCount - 1;
search.wordIndex = 1;
next_word:
if ((*wordNode & 0x80) != 0) {
goto search_table;
}
goto match_word;
}
}
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 (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;
}
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;
}
}
} else {
param->candidates[candidateCount++] = 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;
}
}
}
} 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) {
Zi8_814834AC(param, &remainingCandidates, &candidateCount, &inserted, ZI_WORK);
param->count = candidateCount;
param->letters = candidateCount;
if (candidateCount >= param->maxCandidates) {
if (options->countOnly != 0) {
if ((prefixCount += candidateCount) >= (ziS32)options->maxCount) return options->maxCount;
param->count = 0;
param->letters = 0;
candidateCount = 0;
} else {
return candidateCount;
}
}
}
}
}
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;
}
}
skip_word:
for (; (*wordNode & 0x40) == 0; wordNode = wordNode + 2) {
}
wordNode += 2;
remainingLetters = param->wordCharCount - 1;
wordIndex = 1;
next_word:
if ((*wordNode & 0x80) == 0) {
goto match_word;
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;
}
}
}
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;
}
}
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;
;
}
} while (++search.matchPass < 2);
}
return 0;
if (options->countOnly != 0) return search.resultCount;
return param->letters;
}
return 0;
}

View File

@@ -62,18 +62,23 @@ 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) {
if ((tableCount = Zi8GetTableCount(language, 0x1d, __zi8_work_data)) != 0) {
dataAddress = (ziU8*)Zi8GetTableAddress(language, 0x1d, __zi8_work_data);
goto tables_ready;
}
if (mode == 1) {
goto table_1e;
}
if ((tableCount = Zi8GetTableCount(language, 0x1d, __zi8_work_data)) == 0) {
goto table_1e;
}
{
dataAddress = (ziU8*)Zi8GetTableAddress(language, 0x1d, __zi8_work_data);
goto tables_ready;
}
table_1e:
if ((tableCount = Zi8GetTableCount(language, 0x1e, __zi8_work_data)) != 0) {
dataAddress = (ziU8*)Zi8GetTableAddress(language, 0x1e, __zi8_work_data);
}
@@ -88,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;
}
}
@@ -116,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;
@@ -125,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) {
@@ -139,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;
}
@@ -160,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;
@@ -169,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;
}
@@ -53,28 +53,26 @@ posEntry:
if ((ziS32)position < length) {
if (complete) word[length] = 1; else word[length] = 0;
if (++index >= ZI_WORK->oemLen) goto oemFailed;
} else {
if (fallback) {
index = 0;
*word = *pattern;
return 1;
}
ZI_WORK->oemIdx = ++index;
while (word[position] != 0) position++;
return position;
}
matchRetry:
if (index < ZI_WORK->oemLen) {
if (ZI_WORK->oemMatch(index, word, capacity, ZI_WORK->oemData)) {
goto posEntry;
}
}
oemFailed:
if (length == 1 && complete && !continuation) {
complete = 0;
fallback = 1;
index = 0;
goto matchRetry;
}
if (fallback) {
index = 0;
*word = *pattern;
return 1;
}
ZI_WORK->oemIdx = ++index;
while (word[position] != 0) position++;
return position;
matchRetry:
if ((ziS32)index >= ZI_WORK->oemLen) goto oemFailed;
if (!ZI_WORK->oemMatch(index, word, capacity, ZI_WORK->oemData)) goto oemFailed;
goto posEntry;
oemFailed:
if (length != 1 || !complete || continuation) goto tail0;
complete = 0;
fallback = 1;
index = 0;
goto matchRetry;
tail0:
return 0;
}

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

@@ -43,10 +43,22 @@
#define BTA_DISABLE_DELAY 1000
#ifndef BTA_DISABLE_DELAY
# define BTA_DISABLE_DELAY 200
#endif
#define BTA_DM_REMOTE_DEVICE_NAME_LENGTH 32
#ifndef BTA_DM_REMOTE_DEVICE_NAME_LENGTH
# define BTA_DM_REMOTE_DEVICE_NAME_LENGTH 248
#endif
#define BTA_DM_SDP_DB_SIZE 250
#ifndef BTA_DM_SDP_DB_SIZE
# define BTA_DM_SDP_DB_SIZE 8000
#endif
/* GKI pools */
#ifndef HCI_CMD_POOL_ID
@@ -55,6 +67,10 @@
#define SDP_POOL_ID GKI_POOL_ID_2
#ifndef SDP_POOL_ID
# define SDP_POOL_ID GKI_POOL_ID_3
#endif
#ifndef RFCOMM_CMD_POOL_ID
# define RFCOMM_CMD_POOL_ID GKI_POOL_ID_2
#endif
@@ -94,14 +110,23 @@ void bte_hcisu_send(BT_HDR *p_msg, UINT16 event);
#define BT_1SEC_TIMEOUT 1
#ifndef BT_1SEC_TIMEOUT
# define BT_1SEC_TIMEOUT 2
#endif
/* BTM */
#define BTM_INQ_DB_SIZE 12
#ifndef BTM_INQ_DB_SIZE
# define BTM_INQ_DB_SIZE 40
#endif
#ifndef BTM_DEFAULT_SCAN_TYPE
# define BTM_DEFAULT_SCAN_TYPE BTM_SCAN_TYPE_INTERLACED
#endif
// CLEANUP: header pass, probably
#ifndef BTM_DEFAULT_CONN_WINDOW
# define BTM_DEFAULT_CONN_WINDOW 18
#endif
@@ -114,6 +139,7 @@ void bte_hcisu_send(BT_HDR *p_msg, UINT16 event);
# define BTM_DEFAULT_DISC_MODE BTM_GENERAL_DISCOVERABLE
#endif
// CLEANUP: header pass, probably
#ifndef BTM_DEFAULT_DISC_WINDOW
# define BTM_DEFAULT_DISC_WINDOW 18
#endif
@@ -128,20 +154,44 @@ void bte_hcisu_send(BT_HDR *p_msg, UINT16 event);
*/
#define BTA_DM_COD {0x40, 0x02, 0x04}
#ifndef BTA_DM_COD
# define BTA_DM_COD {0x5a, 0x02, 0x0c}
#endif
#define BTM_MAX_SCO_LINKS 3
#ifndef BTM_MAX_SCO_LINKS
# define BTM_MAX_SCO_LINKS 2
#endif
#ifndef BTM_DEFAULT_SCO_MODE
# define BTM_DEFAULT_SCO_MODE 2
#endif
#define BTM_SEC_MAX_DEVICE_RECORDS 16
#ifndef BTM_SEC_MAX_DEVICE_RECORDS
# define BTM_SEC_MAX_DEVICE_RECORDS 100
#endif
#define BTM_SEC_MAX_SERVICE_RECORDS 24
#ifndef BTM_SEC_MAX_SERVICE_RECORDS
# define BTM_SEC_MAX_SERVICE_RECORDS 32
#endif
#define BTM_MAX_REM_BD_NAME_LEN 64
#ifndef BTM_MAX_REM_BD_NAME_LEN
# define BTM_MAX_REM_BD_NAME_LEN 248
#endif
#define BTM_MAX_LOC_BD_NAME_LEN 31
#ifndef BTM_MAX_LOC_BD_NAME_LEN
# define BTM_MAX_LOC_BD_NAME_LEN 248
#endif
#ifndef BTM_SEC_SERVICE_NAME_LEN
# define BTM_SEC_SERVICE_NAME_LEN BT_MAX_SERVICE_NAME_LEN
#endif
@@ -160,14 +210,37 @@ void bte_hcisu_send(BT_HDR *p_msg, UINT16 event);
/* L2CAP */
#define MAX_L2CAP_LINKS 4
// TODO: could this be resolved by configuring MAX_ACL_CONNECTIONS?
#if 0
#define MAX_ACL_CONNECTIONS 4
#ifndef MAX_ACL_CONNECTIONS
# define MAX_L2CAP_LINKS 7
#else
# define MAX_L2CAP_LINKS MAX_ACL_CONNECTIONS
#endif
#else
# define MAX_L2CAP_LINKS 4
#endif
#define MAX_L2CAP_CHANNELS 10
#ifndef MAX_L2CAP_CHANNELS
# define MAX_L2CAP_CHANNELS 16
#endif
#define MAX_L2CAP_CLIENTS 8
#ifndef MAX_L2CAP_CLIENTS
# define MAX_L2CAP_CLIENTS 15
#endif
#define L2CAP_LINK_INACTIVITY_TOUT 2
#ifndef L2CAP_LINK_INACTIVITY_TOUT
# define L2CAP_LINK_INACTIVITY_TOUT 4
#endif
#ifndef L2CAP_LINK_STARTUP_TOUT
# define L2CAP_LINK_STARTUP_TOUT 60
#endif
@@ -196,11 +269,27 @@ void bte_hcisu_send(BT_HDR *p_msg, UINT16 event);
#define SDP_MAX_PAD_LEN 350
#ifndef SDP_MAX_PAD_LEN
# define SDP_MAX_PAD_LEN 600
#endif
#define SDP_MAX_ATTR_LEN 80
#ifndef SDP_MAX_ATTR_LEN
# if defined(HID_DEV_INCLUDED) && HID_DEV_INCLUDED == TRUE
// probably went here
# define SDP_MAX_ATTR_LEN 80
# else
# define SDP_MAX_ATTR_LEN 100
# endif
#endif
#define SDP_MAX_ATTR_FILTERS 12
#ifndef SDP_MAX_ATTR_FILTERS
# define SDP_MAX_ATTR_FILTERS 15
#endif
#ifndef SDP_MAX_UUID_FILTERS
# define SDP_MAX_UUID_FILTERS 3
#endif
@@ -211,6 +300,10 @@ void bte_hcisu_send(BT_HDR *p_msg, UINT16 event);
#define SDP_MAX_LIST_BYTE_COUNT 1000
#ifndef SDP_MAX_LIST_BYTE_COUNT
# define SDP_MAX_LIST_BYTE_COUNT 0x1000
#endif
#ifndef SDP_MAX_PROTOCOL_PARAMS
# define SDP_MAX_PROTOCOL_PARAMS 2
#endif
@@ -239,30 +332,81 @@ void bte_hcisu_send(BT_HDR *p_msg, UINT16 event);
#define MAX_RFC_PORTS 5
#define MAX_BD_CONNECTIONS 1
#ifndef MAX_RFC_PORTS
# define MAX_RFC_PORTS 30
#endif
// Well I guess not since this is different than MAX_L2CAP_LINKS
#if 0
#define MAX_ACL_CONNECTIONS 4
#ifndef MAX_ACL_CONNECTIONS
# define MAX_BD_CONNECTIONS 7
#else
# define MAX_BD_CONNECTIONS MAX_ACL_CONNECTIONS
#endif
#else
# define MAX_BD_CONNECTIONS 1
#endif
#define PORT_RX_LOW_WM 5000
#ifndef PORT_RX_LOW_WM
# define PORT_RX_LOW_WM (BTA_RFC_MTU_SIZE * PORT_RX_BUF_LOW_WM)
#endif
#define PORT_RX_HIGH_WM 8000
#ifndef PORT_RX_HIGH_WM
# define PORT_RX_HIGH_WM (BTA_RFC_MTU_SIZE * PORT_RX_BUF_HIGH_WM)
#endif
#define PORT_RX_CRITICAL_WM 12000
#ifndef PORT_RX_CRITICAL_WM
# define PORT_RX_CRITICAL_WM (BTA_RFC_MTU_SIZE * PORT_RX_BUF_CRITICAL_WM)
#endif
#define PORT_RX_BUF_LOW_WM 8
#ifndef PORT_RX_BUF_LOW_WM
# define PORT_RX_BUF_LOW_WM 4
#endif
#define PORT_RX_BUF_HIGH_WM 16
#ifndef PORT_RX_BUF_HIGH_WM
# define PORT_RX_BUF_HIGH_WM 10
#endif
#ifndef PORT_RX_BUF_CRITICAL_WM
# define PORT_RX_BUF_CRITICAL_WM 15
#endif
#define PORT_TX_HIGH_WM 8000
#ifndef PORT_TX_HIGH_WM
# define PORT_TX_HIGH_WM (BTA_RFC_MTU_SIZE * PORT_TX_BUF_HIGH_WM)
#endif
#define PORT_TX_CRITICAL_WM 10000
#ifndef PORT_TX_CRITICAL_WM
# define PORT_TX_CRITICAL_WM (BTA_RFC_MTU_SIZE * PORT_TX_BUF_CRITICAL_WM)
#endif
#define PORT_TX_BUF_HIGH_WM 16
#ifndef PORT_TX_BUF_HIGH_WM
# define PORT_TX_BUF_HIGH_WM 10
#endif
#define PORT_TX_BUF_CRITICAL_WM 22
#ifndef PORT_TX_BUF_CRITICAL_WM
# define PORT_TX_BUF_CRITICAL_WM 15
#endif
#ifndef PORT_FC_DEFAULT
# define PORT_FC_DEFAULT PORT_FC_CREDIT
#endif
@@ -307,6 +451,10 @@ void bte_hcisu_send(BT_HDR *p_msg, UINT16 event);
#define HID_HOST_MAX_DEVICES 16
#ifndef HID_HOST_MAX_DEVICES
# define HID_HOST_MAX_DEVICES 7
#endif
#ifndef HID_HOST_MTU
# define HID_HOST_MTU 640
#endif
@@ -317,6 +465,10 @@ void bte_hcisu_send(BT_HDR *p_msg, UINT16 event);
#define HID_HOST_MAX_CONN_RETRY 0
#ifndef HID_HOST_MAX_CONN_RETRY
# define HID_HOST_MAX_CONN_RETRY 3
#endif
#ifndef HID_HOST_REPAGE_WIN
# define HID_HOST_REPAGE_WIN 2
#endif

View File

@@ -55,6 +55,12 @@ enum
};
typedef UINT32 tBTA_SERVICE_MASK;
#if 0
enum
{
/* ... */
};
#endif
// Added constants for tBTA_SEC
typedef UINT8 tBTA_SEC;
@@ -68,12 +74,36 @@ enum
typedef UINT8 tBTA_DM_DISC;
#if 0
enum
{
/* ... */
};
#endif
typedef UINT8 tBTA_DM_CONN;
#if 0
enum
{
/* ... */
};
#endif
typedef UINT8 tBTA_DM_INQ_MODE;
#if 0
enum
{
/* ... */
};
#endif
typedef UINT8 tBTA_DM_INQ_FILT;
#if 0
enum
{
/* ... */
};
#endif
typedef UINT8 tBTA_AUTH_RESP;
enum

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

@@ -26,7 +26,7 @@ typedef struct IOSResourceOpen {
u8* path; // 0x00
u32 flags; // 0x04
u32 ownerId; // 0x08
u16 groupId; // 0x0C
u16 groudId; // 0x0C
} IOSResourceOpen;
typedef struct IOSResourceRead {

View File

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

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