Compare commits
1 Commits
agent/bitt
...
cdb-clean
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9e76cabe2f |
20
.github/workflows/readme-progress.yml
vendored
20
.github/workflows/readme-progress.yml
vendored
@@ -2,8 +2,8 @@ name: README progress
|
||||
|
||||
# runs on the self-hosted runner on cole's server so it doesn't use hosted minutes.
|
||||
# only push/schedule/manual triggers, never pull_request, so fork PRs can't reach this machine.
|
||||
# it never commits to main: it rebuilds, publishes the numbers to the job summary, and force-pushes
|
||||
# the README badge JSON as a single commit on the orphan progress-data branch.
|
||||
# README progress is written inside each landing commit by the orchestrator, so this job never commits;
|
||||
# it only rebuilds and publishes the current numbers to the job summary.
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
@@ -17,7 +17,7 @@ concurrency:
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
contents: read
|
||||
|
||||
jobs:
|
||||
progress:
|
||||
@@ -55,17 +55,3 @@ jobs:
|
||||
python3 tools/update_readme_progress.py build/43U/report.json README.md "$GITHUB_SHA"
|
||||
sed -n '/progress:start/,/progress:end/p' README.md >> "$GITHUB_STEP_SUMMARY"
|
||||
git checkout -- README.md
|
||||
|
||||
- name: Publish badges
|
||||
if: github.ref == 'refs/heads/main'
|
||||
run: |
|
||||
out="$RUNNER_TEMP/progress-data"
|
||||
rm -rf "$out"
|
||||
python3 tools/progress_badges.py build/43U/report.json "$out"
|
||||
cd "$out"
|
||||
git init -q -b progress-data
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
||||
git add .
|
||||
git commit -q -m "progress for $GITHUB_SHA"
|
||||
git push -q -f "https://x-access-token:${{ github.token }}@github.com/$GITHUB_REPOSITORY.git" HEAD:refs/heads/progress-data
|
||||
|
||||
37
README.md
37
README.md
@@ -7,23 +7,23 @@
|
||||
|
||||
<!--- Github Actions Badge -->
|
||||
|
||||
[Build Status]: https://github.com/coah80/wii-ipl/actions/workflows/readme-progress.yml/badge.svg?branch=main
|
||||
[actions]: https://github.com/coah80/wii-ipl/actions/workflows/readme-progress.yml
|
||||
[Build Status]: https://github.com/coah80/wii-ipl/actions/workflows/build.yml/badge.svg
|
||||
[actions]: https://github.com/coah80/wii-ipl/actions/workflows/build.yml
|
||||
|
||||
<!--- Discord Badge -->
|
||||
|
||||
[Discord Badge]: https://img.shields.io/discord/727908905392275526?color=%237289DA&logo=discord&logoColor=%23FFFFFF
|
||||
[discord]: https://discord.gg/hKx3FJJgrV
|
||||
|
||||
<!-- Progress badges: JSON on the progress-data branch, refreshed by the README progress workflow on every push to main -->
|
||||
<!-- Progress links -->
|
||||
|
||||
[progress]: https://github.com/coah80/wii-ipl/actions/workflows/readme-progress.yml
|
||||
[DecompiledBadge]: https://img.shields.io/endpoint?url=https%3A%2F%2Fraw.githubusercontent.com%2Fcoah80%2Fwii-ipl%2Fprogress-data%2Fdecompiled.json
|
||||
[MatchedBadge]: https://img.shields.io/endpoint?url=https%3A%2F%2Fraw.githubusercontent.com%2Fcoah80%2Fwii-ipl%2Fprogress-data%2Fmatched.json
|
||||
[LinkedBadge]: https://img.shields.io/endpoint?url=https%3A%2F%2Fraw.githubusercontent.com%2Fcoah80%2Fwii-ipl%2Fprogress-data%2Flinked.json
|
||||
[DataBadge]: https://img.shields.io/endpoint?url=https%3A%2F%2Fraw.githubusercontent.com%2Fcoah80%2Fwii-ipl%2Fprogress-data%2Fdata.json
|
||||
[FunctionsBadge]: https://img.shields.io/endpoint?url=https%3A%2F%2Fraw.githubusercontent.com%2Fcoah80%2Fwii-ipl%2Fprogress-data%2Ffunctions.json
|
||||
[UnitsBadge]: https://img.shields.io/endpoint?url=https%3A%2F%2Fraw.githubusercontent.com%2Fcoah80%2Fwii-ipl%2Fprogress-data%2Funits.json
|
||||
[V43U]: https://decomp.dev/koopthekoopa/wii-ipl/43U
|
||||
|
||||
<!--- Version 4.3U progress Badge -->
|
||||
|
||||
[DecompBadgeV43U]: https://decomp.dev/koopthekoopa/wii-ipl/43U.svg?&measure=code&label=Decompiled&mode=shield&labelColor=%237c7c7c&color=%2333b8ff&style=plastic
|
||||
[LinkBadgeV43U]: https://decomp.dev/koopthekoopa/wii-ipl/43U.svg?&measure=complete_code&label=Linked&mode=shield&labelColor=%237c7c7c&color=%2333b8ff&style=plastic
|
||||
[FuncBadgeV43U]: https://decomp.dev/koopthekoopa/wii-ipl/43U.svg?&measure=functions&label=Functions&mode=shield&labelColor=%237c7c7c&color=%2333b8ff&style=plastic
|
||||
|
||||
<!--- Header -->
|
||||
|
||||
@@ -43,17 +43,28 @@ Live decomp status
|
||||
|
||||
[![Build status]][actions]
|
||||
|
||||
Every push to `main` rebuilds 4.3U, checks the DOL hash, and refreshes the progress badges below. Open the latest [README progress run][actions] for the full objdiff summary.
|
||||
Open the latest successful [Build workflow run][actions] and check its summary for the current objdiff metrics. It includes perfect-match/decompiled, fuzzy-match, fully linked, data, function, unit, and category breakdowns. The run also publishes the 43U report artifact and generated decomp-status report.
|
||||
|
||||
Supported versions:
|
||||
- `43U` - Version **4.3U** (USA)
|
||||
|
||||
Progress
|
||||
========
|
||||
[![DecompiledBadge]][progress] [![MatchedBadge]][progress] [![LinkedBadge]][progress] [![DataBadge]][progress]
|
||||
[![FunctionsBadge]][progress] [![UnitsBadge]][progress]
|
||||
<!-- progress:start -->
|
||||
| Decompiled | Matched | Linked | Data |
|
||||
|:---:|:---:|:---:|:---:|
|
||||
| 99.59% | 91.12% | 74.40% | 99.42% |
|
||||
|
||||
units 963/1027 complete, functions 12376/12563 matched.
|
||||
|
||||
decompiled = code with a C/C++ implementation (objdiff fuzzy), matched = byte-exact code, linked = code actually linked into the DOL, data = byte-exact data
|
||||
<!-- progress:end -->
|
||||
|
||||
| Version | Progress |
|
||||
|-----------------------|------------------------------------------------------------------------------|
|
||||
| [Wii Menu 4.3U][V43U] | [![FuncBadgeV43U]][V43U] [![DecompBadgeV43U]][V43U] [![LinkBadgeV43U]][V43U] |
|
||||
|
||||
> You can see the full progress and its history by clicking on one of the versions in the table.
|
||||
|
||||
Dependencies
|
||||
============
|
||||
|
||||
@@ -37,9 +37,6 @@ force_active:
|
||||
|
||||
# textinput::toolbar::csPaneToAnimation points one past the end of csAninationFile.
|
||||
block_relocations:
|
||||
# Run establishes a fixed stack at 0x81600000, not __pformatter + 0x280.
|
||||
- source: .text:0x8137B468
|
||||
- source: .text:0x8137B46C
|
||||
- source: .data:0x8165E15C
|
||||
- source: .data:0x8165E19C
|
||||
|
||||
|
||||
@@ -95,15 +95,11 @@ AOSS_810BDF18 = .bss:0x810BDF18; // type:object size:0x6A0
|
||||
AOSS_810BE5B8 = .bss:0x810BE5B8; // type:object size:0x280
|
||||
AOSS_810BE838 = .bss:0x810BE838; // type:object size:0x68
|
||||
AOSS_810BE8A0 = .bss:0x810BE8A0; // type:object size:0x400
|
||||
gAtermIpConfig = .bss:0x810BECA0; // type:object size:0x7C4 data:4byte
|
||||
gAtermIfConfig = .bss:0x810BF464; // type:object size:0x15E
|
||||
ATERM_810BECA0 = .bss:0x810BECA0; // type:object size:0x924 data:4byte
|
||||
ATERM_810BF5C4 = .bss:0x810BF5C4; // type:object size:0x24
|
||||
ATERM_810BF5E8 = .bss:0x810BF5E8; // type:object size:0x258
|
||||
gAtermConfigurationResult = .bss:0x810BF840; // type:object size:0xE8
|
||||
gAtermAssociationRequest = .bss:0x810BF928; // type:object size:0x10
|
||||
gAtermPacketBuffer = .bss:0x810BF938; // type:object size:0x800
|
||||
gAtermDecodedResponse = .bss:0x810C0138; // type:object size:0x800 data:2byte
|
||||
gAtermSession = .bss:0x810C0938; // type:object size:0x20
|
||||
ATERM_810BF840 = .bss:0x810BF840; // type:object size:0x900
|
||||
ATERM_810C0140 = .bss:0x810C0140; // type:object size:0x818 data:2byte
|
||||
AtermThread = .bss:0x810C0958; // type:object size:0x318 scope:local align:32
|
||||
Voices = .bss:0x810C0C80; // type:object size:0x1800 data:4byte
|
||||
sZeroMem = .bss:0x810C2480; // type:object size:0x100 data:byte
|
||||
@@ -118,9 +114,7 @@ ziStringColorRightDestructorRecord = .bss:0x810C65CC; // type:object size:0xC da
|
||||
underlateColorDestructorRecord = .bss:0x810C65D8; // type:object size:0xC data:4byte
|
||||
unInputedWCharColorSpaceDestructorRecord = .bss:0x810C65E4; // type:object size:0xC data:4byte
|
||||
ElementBuffer__Q39textinput8tistring6WithZi = .bss:0x810C65F0; // type:object size:0x200 data:2byte
|
||||
CandidatesBuffer__Q39textinput8tistring6WithZi = .bss:0x810C67F0; // type:object size:0x200 data:2byte
|
||||
ElementWorkBuffer__Q39textinput8tistring6WithZi = .bss:0x810C69F0; // type:object size:0x200 data:2byte
|
||||
PredictionBuffer__Q39textinput8tistring6WithZi = .bss:0x810C6BF0; // type:object size:0x200 data:2byte
|
||||
CandidatesBuffer__Q39textinput8tistring6WithZi = .bss:0x810C67F0; // type:object size:0x600 data:2byte
|
||||
CandidatedWord__Q39textinput8tistring6WithZi = .bss:0x810C6DF0; // type:object size:0x1400 data:2byte
|
||||
LatestWord__Q39textinput8tistring6WithZi = .bss:0x810C81F0; // type:object size:0x80 data:2byte
|
||||
snWidthTable__Q29textinput10textdrawer = .bss:0x810C8270; // type:object size:0x580 data:4byte
|
||||
@@ -16049,7 +16043,7 @@ mscClockPaneNames__Q33ipl5scene13ChannelSelect = .data:0x8164DCA8; // type:objec
|
||||
@23740 = .data:0x8164DE49; // type:object size:0x1B scope:local data:string
|
||||
scPaneName_N_GCIcon = .data:0x8164DE64; // type:object size:0x9 data:string
|
||||
scPaneName_N_DiscUpdateIcon = .data:0x8164DE6D; // type:object size:0x11 data:string
|
||||
@24295 = .data:0x8164DE80; // type:object size:0x1C scope:local
|
||||
updateDiskState_jumptable = .data:0x8164DE80; // type:object size:0x1C scope:local
|
||||
scSE_WSD_SELECT = .data:0x8164DE9C; // type:object size:0xB data:string
|
||||
@24254 = .data:0x8164DEA7; // type:object size:0x10 scope:local data:string
|
||||
@24282 = .data:0x8164DEB7; // type:object size:0x12 scope:local data:string
|
||||
|
||||
26
configure.py
26
configure.py
@@ -648,7 +648,7 @@ config.libs = [
|
||||
Object(Matching, "system/iplDialogWindow.cpp"),
|
||||
Object(Matching, "system/iplHomeButtonMenu.cpp"),
|
||||
Object(Matching, "system/iplNandSDWorker.cpp"),
|
||||
Object(Matching, "system/iplKeyboard.cpp"),
|
||||
Object(Equivalent, "system/iplKeyboard.cpp"),
|
||||
Object(Matching, "system/iplErrorHandler.cpp"),
|
||||
Object(Matching, "system/iplResetHandler.cpp"),
|
||||
Object(Matching, "system/iplWarningHandler.cpp"),
|
||||
@@ -727,7 +727,7 @@ config.libs = [
|
||||
]
|
||||
),
|
||||
IPLSection("address", [
|
||||
Object(Matching, "scene/address/iplAddress.cpp"),
|
||||
Object(NonMatching, "scene/address/iplAddress.cpp"),
|
||||
Object(Matching, "scene/address/iplAddressAddSel.cpp"),
|
||||
Object(NonMatching, "scene/address/iplAddressEdit.cpp"),
|
||||
]
|
||||
@@ -879,7 +879,7 @@ config.libs = [
|
||||
Object(NonMatching, "scene/setting/AOSSLink.c"),
|
||||
Object(Matching, "scene/setting/iplRakuRakuThread.cpp"),
|
||||
Object(NonMatching, "scene/setting/AOSS.c", extra_cflags=["-O4,p", "-inline off"]),
|
||||
Object(NonMatching, "scene/setting/ATERM.c", extra_cflags=["-O4,p", "-inline on"]),
|
||||
Object(NonMatching, "scene/setting/ATERM.c", extra_cflags=["-O4,p", "-inline off"]),
|
||||
]
|
||||
),
|
||||
IPLSection("settingSelect", [
|
||||
@@ -908,7 +908,7 @@ config.libs = [
|
||||
),
|
||||
# it decides to do fast optimization for this one
|
||||
IPLSection("keyboard", [
|
||||
Object(Matching, "keyboard/tiPcKeyboard.cpp", extra_cflags=["-O4,p"]),
|
||||
Object(NonMatching, "keyboard/tiPcKeyboard.cpp", extra_cflags=["-O4,p"]),
|
||||
Object(NonMatching, "keyboard/tiCellPhone.cpp", extra_cflags=["-O4,p"]),
|
||||
Object(NonMatching, "keyboard/tiInputForm.cpp", extra_cflags=["-O4,p"]),
|
||||
Object(NonMatching, "keyboard/tiCandidateBox.cpp", extra_cflags=["-O4,p"]),
|
||||
@@ -982,7 +982,7 @@ config.libs = [
|
||||
),
|
||||
ZI8Lib("zi8clib", [
|
||||
Object(Matching, "clib/zaddress.c"),
|
||||
Object(Matching, "clib/zconvert.c"),
|
||||
Object(NonMatching, "clib/zconvert.c"),
|
||||
Object(NonMatching, "clib/zi81key.c"),
|
||||
Object(NonMatching, "clib/zi8alpha.c"),
|
||||
Object(Matching, "clib/zi8alts.c"),
|
||||
@@ -997,7 +997,7 @@ config.libs = [
|
||||
Object(Matching, "clib/zi8is.c"),
|
||||
Object(NonMatching, "clib/zi8match.c"),
|
||||
Object(Matching, "clib/zi8misc.c"),
|
||||
Object(Matching, "clib/zi8pud2.c"),
|
||||
Object(NonMatching, "clib/zi8pud2.c"),
|
||||
Object(Matching, "clib/Zi8punct.c"),
|
||||
Object(Matching, "clib/zi8space.c"),
|
||||
Object(NonMatching, "clib/zi8uwd.c"),
|
||||
@@ -1043,7 +1043,7 @@ config.libs = [
|
||||
RevoEXLib("net", [
|
||||
Object(Matching, "net/nettime.c"),
|
||||
Object(Matching, "net/crc.c"),
|
||||
Object(Matching, "net/md5.c"),
|
||||
Object(NonMatching, "net/md5.c"),
|
||||
Object(Matching, "net/sha1.c"),
|
||||
Object(Matching, "net/hmac.c"),
|
||||
Object(Matching, "net/neterrorcode.c"),
|
||||
@@ -1081,9 +1081,9 @@ config.libs = [
|
||||
Object(Matching, "nwc24/NWC24Parser.c"),
|
||||
Object(Matching, "nwc24/NWC24MsgCommit.c"),
|
||||
Object(Matching, "nwc24/NWC24MsgRead.c"),
|
||||
Object(Matching, "nwc24/NWC24MsgSubject.c"),
|
||||
Object(NonMatching, "nwc24/NWC24MsgSubject.c"),
|
||||
Object(Matching, "nwc24/NWC24Schedule.c"),
|
||||
Object(Matching, "nwc24/NWC24DateParser.c"),
|
||||
Object(NonMatching, "nwc24/NWC24DateParser.c"),
|
||||
Object(Matching, "nwc24/NWC24FriendList.c"),
|
||||
Object(Matching, "nwc24/NWC24SecretFList.c"),
|
||||
Object(Matching, "nwc24/NWC24UserId.c"),
|
||||
@@ -1299,7 +1299,7 @@ config.libs = [
|
||||
Object(Matching, "ut/ut_RomFont.cpp"),
|
||||
Object(Matching, "ut/ut_ResFontBase.cpp"),
|
||||
Object(Matching, "ut/ut_ResFont.cpp"),
|
||||
Object(Matching, "ut/ut_ArchiveFontBase.cpp"),
|
||||
Object(NonMatching, "ut/ut_ArchiveFontBase.cpp"),
|
||||
Object(Matching, "ut/ut_ArchiveFont.cpp"),
|
||||
Object(Matching, "ut/ut_CharWriter.cpp"),
|
||||
Object(Matching, "ut/ut_TextWriterBase.cpp"),
|
||||
@@ -1691,7 +1691,7 @@ config.libs = [
|
||||
Object(Matching, "fa/pdm_bpb.c"),
|
||||
Object(Matching, "fa/pdm_disk.c"),
|
||||
Object(NonMatching, "fa/pdm_partition.c"),
|
||||
Object(Matching, "fa/pf_cache.c"),
|
||||
Object(NonMatching, "fa/pf_cache.c"),
|
||||
Object(Matching, "fa/pf_cluster.c"),
|
||||
Object(Matching, "fa/pf_dir.c"),
|
||||
Object(Matching, "fa/pf_entry.c"),
|
||||
@@ -1826,7 +1826,7 @@ config.libs = [
|
||||
Object(Matching, "fa/pfs_unmount.c"),
|
||||
Object(Matching, "fa/pf_stub_unicode.c"),
|
||||
|
||||
Object(Matching, "fa/api/FAAttach.c"),
|
||||
Object(NonMatching, "fa/api/FAAttach.c"),
|
||||
Object(Matching, "fa/api/FABuffering.c"),
|
||||
Object(Matching, "fa/api/FACreate.c"),
|
||||
Object(Matching, "fa/api/FACreatedir.c"),
|
||||
@@ -1908,7 +1908,7 @@ config.libs = [
|
||||
[
|
||||
Object(Matching, "core/eggAllocator.cpp"),
|
||||
Object(Matching, "core/eggAudioArcPlayerMgr.cpp"),
|
||||
Object(Matching, "core/eggAudioExpMgr.cpp"),
|
||||
Object(Equivalent, "core/eggAudioExpMgr.cpp"),
|
||||
Object(Matching, "core/eggAudioFxMgr.cpp"),
|
||||
Object(Matching, "core/eggAudioMgr.cpp"),
|
||||
Object(Matching, "core/eggAudioHeapMgr.cpp"),
|
||||
|
||||
@@ -24,7 +24,7 @@ typedef struct BS2UpdateHeader {
|
||||
|
||||
typedef struct BS2UpdateEntry {
|
||||
// Update Meta Data
|
||||
vu32 type; // 0x00
|
||||
u32 type; // 0x00
|
||||
u32 attr; // 0x04
|
||||
u32 size; // 0x08
|
||||
u32 depend; // 0x0C
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace ipl {
|
||||
namespace memorycard {
|
||||
typedef struct FileInfo {
|
||||
u16 fileNo; // 0x00
|
||||
volatile u16 size; // 0x02
|
||||
u16 size; // 0x02
|
||||
u8 canCopy; // 0x04
|
||||
u8 canMove; // 0x05
|
||||
u16 unk_0x06; // 0x06
|
||||
@@ -28,7 +28,7 @@ namespace ipl {
|
||||
} CardState; // 0x14
|
||||
|
||||
typedef struct IconState {
|
||||
volatile u8 bannerEnable; // 0x00
|
||||
u8 bannerEnable; // 0x00
|
||||
u8 unk_0x01; // 0x01
|
||||
u8 unk_0x02; // 0x02
|
||||
u8 bannerType; // 0x03
|
||||
|
||||
@@ -142,6 +142,9 @@ namespace textinput {
|
||||
|
||||
// TODO enum?
|
||||
int getInputType() const;
|
||||
#if defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIHWKEYBOARD_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
|
||||
void resetHoldingButton();
|
||||
#endif
|
||||
|
||||
#if defined(MYTIMANAGER_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIHWKEYBOARD_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
|
||||
#if defined(MYTIMANAGER_IMPLEMENTATION) && defined(TI_CELLPHONE_IMPLEMENTATION)
|
||||
|
||||
@@ -69,9 +69,6 @@
|
||||
virtual bool updateInput(int chan, f32 x, f32 y, u32 trig, u32 hold, u32 release, void* data) override;
|
||||
virtual bool updateInput(input::HKBManager& hkbManager) override;
|
||||
#endif
|
||||
#if defined(TI_CELLPHONE_IMPLEMENTATION) || defined(TIINPUTFORM_IMPLEMENTATION) || defined(TIHWKEYBOARD_IMPLEMENTATION) || defined(TIMANAGER_IMPLEMENTATION)
|
||||
void resetHoldingButton();
|
||||
#endif
|
||||
#ifdef TI_CELLPHONE_IMPLEMENTATION
|
||||
virtual ~LayoutByNW4R();
|
||||
virtual void create(MEMAllocator* allocator) override;
|
||||
@@ -98,6 +95,7 @@
|
||||
virtual void changeSpaceKeyTop(const PaneNameToCharCode* keys);
|
||||
void setUpperCaseJP(bool enabled);
|
||||
void setLangKeyActive(bool enabled);
|
||||
void resetHoldingButton();
|
||||
|
||||
private:
|
||||
bool mbLineFeedButton;
|
||||
|
||||
@@ -74,16 +74,8 @@ namespace textinput {
|
||||
|
||||
virtual void onEvent(GUIComponent& comp, u32 event, void* data) {} // 0x0C
|
||||
|
||||
#ifdef TI_PC_KEYBOARD_IMPLEMENTATION
|
||||
virtual void setLatestEventCtrlNo(int ctrlNo);
|
||||
#else
|
||||
virtual void setLatestEventCtrlNo(int ctrlNo) { muLatestEventCtrlNo = ctrlNo; } // 0x10
|
||||
#endif
|
||||
#ifdef TI_PC_KEYBOARD_IMPLEMENTATION
|
||||
virtual int getLatestEventCtrlNo();
|
||||
#else
|
||||
virtual int getLatestEventCtrlNo() { return muLatestEventCtrlNo; } // 0x14
|
||||
#endif
|
||||
|
||||
protected:
|
||||
int muLatestEventCtrlNo; // 0x04
|
||||
@@ -117,11 +109,7 @@ namespace textinput {
|
||||
: GUIInterface(), mbInitialize(false), mDraggingButton(0xFFFF), mID(id), mbTriggerTarget(false), mpManager(NULL), mpListener(NULL) {
|
||||
init();
|
||||
}
|
||||
#ifdef TI_PC_KEYBOARD_IMPLEMENTATION
|
||||
virtual ~GUIComponent();
|
||||
#else
|
||||
virtual ~GUIComponent() {} // 0x08
|
||||
#endif
|
||||
|
||||
virtual u32 getID() { return mID; } // 0x20
|
||||
|
||||
@@ -158,11 +146,7 @@ namespace textinput {
|
||||
}
|
||||
|
||||
virtual bool isTriggerTarget() { return mbTriggerTarget; } // 0x48
|
||||
#ifdef TI_PC_KEYBOARD_IMPLEMENTATION
|
||||
virtual void setTriggerTarget(bool bEnable);
|
||||
#else
|
||||
virtual void setTriggerTarget(bool bEnable) { mbTriggerTarget = bEnable; } // 0x4C
|
||||
#endif
|
||||
|
||||
void setParentManager(GUIManager* manager) { mpManager = manager; }
|
||||
GUIManager* getParentManager() { return mpManager; }
|
||||
|
||||
@@ -47,11 +47,7 @@ namespace textinput {
|
||||
#else
|
||||
virtual Language getLanguage() const { return meLanguage; }
|
||||
#endif
|
||||
#ifdef TI_PC_KEYBOARD_IMPLEMENTATION
|
||||
virtual void update();
|
||||
#else
|
||||
virtual void update() {}
|
||||
#endif
|
||||
#else
|
||||
virtual Language getLanguage() const;
|
||||
virtual void update();
|
||||
|
||||
@@ -64,11 +64,7 @@ namespace textinput {
|
||||
virtual void setWCString(const wchar_t* string);
|
||||
|
||||
virtual void setLanguage(Language language);
|
||||
#ifdef TI_PC_KEYBOARD_IMPLEMENTATION
|
||||
virtual Language getLanguage() const;
|
||||
#else
|
||||
virtual Language getLanguage() const { return meLanguage; }
|
||||
#endif
|
||||
#ifdef MYTIMANAGER_IMPLEMENTATION
|
||||
Language getLanguageForMemo() const { return meLanguage; }
|
||||
#endif
|
||||
@@ -133,18 +129,10 @@ namespace textinput {
|
||||
virtual const InputForm* getInputForm() const { return mpInputForm; }
|
||||
|
||||
virtual keyboard::hwkey::HWKeyboard* getHWKeyboard() { return mpHWKeyboard; }
|
||||
#ifdef TI_PC_KEYBOARD_IMPLEMENTATION
|
||||
virtual const keyboard::hwkey::HWKeyboard* getHWKeyboard() const;
|
||||
#else
|
||||
virtual const keyboard::hwkey::HWKeyboard* getHWKeyboard() const { return mpHWKeyboard; }
|
||||
#endif
|
||||
|
||||
virtual keyboard::pctype::LayoutByNW4R* getPCKeyboard() { return mpPCKeyboard; }
|
||||
#ifdef TI_PC_KEYBOARD_IMPLEMENTATION
|
||||
virtual const keyboard::pctype::LayoutByNW4R* getPCKeyboard() const;
|
||||
#else
|
||||
virtual const keyboard::pctype::LayoutByNW4R* getPCKeyboard() const { return mpPCKeyboard; }
|
||||
#endif
|
||||
|
||||
virtual keyboard::cellphonetype::LayoutByNW4R* getCellPhoneKeyboard() { return mpCellPhoneKeyboard; }
|
||||
virtual const keyboard::cellphonetype::LayoutByNW4R* getCellPhoneKeyboard() const { return mpCellPhoneKeyboard; }
|
||||
@@ -161,11 +149,7 @@ namespace textinput {
|
||||
virtual const candidatebox::LayoutByNW4R* getCandidateBox() const { return mpCandidateBox; }
|
||||
|
||||
virtual toolbar::LayoutByNW4R* getToolBar() { return mpToolBar; }
|
||||
#ifdef TI_PC_KEYBOARD_IMPLEMENTATION
|
||||
virtual const toolbar::LayoutByNW4R* getToolBar() const;
|
||||
#else
|
||||
virtual const toolbar::LayoutByNW4R* getToolBar() const { return mpToolBar; }
|
||||
#endif
|
||||
|
||||
#ifdef TIMANAGER_IMPLEMENTATION
|
||||
virtual void* getPredictLanguageSelectDialog();
|
||||
|
||||
@@ -36,11 +36,7 @@ namespace textinput {
|
||||
|
||||
virtual void onTiEvent(gui::PaneComponent* paneComponent, u32 event, Input* input) = 0; // 0x18
|
||||
|
||||
#ifdef TI_PC_KEYBOARD_IMPLEMENTATION
|
||||
virtual void setEventObserver(EventObserver *event);
|
||||
#else
|
||||
virtual void setEventObserver(EventObserver *event) { mpEventObserver = event; } // 0x1C
|
||||
#endif
|
||||
|
||||
protected:
|
||||
EventObserver* mpEventObserver; // 0x08
|
||||
@@ -101,19 +97,25 @@ namespace textinput {
|
||||
virtual void calc(); // 0x0C
|
||||
|
||||
#ifdef TI_PC_KEYBOARD_IMPLEMENTATION
|
||||
virtual void onAnmEvent(AnmPaneEvent);
|
||||
virtual void onAnmEvent(AnmPaneEvent) {}
|
||||
#else
|
||||
virtual void onAnmEvent(AnmPaneEvent paneEvent);
|
||||
#endif // 0x10
|
||||
|
||||
virtual void changeAnimation(u32 id); // 0x14
|
||||
#ifdef TI_PC_KEYBOARD_IMPLEMENTATION
|
||||
virtual bool isInAnimation();
|
||||
virtual bool isInAnimation() { return mpCurrentAnim != NULL; }
|
||||
#else
|
||||
virtual bool isInAnimation();
|
||||
#endif // 0x18
|
||||
#ifdef TI_PC_KEYBOARD_IMPLEMENTATION
|
||||
virtual Anim* searchAnimation(u32 id);
|
||||
virtual Anim* searchAnimation(u32 id) {
|
||||
for (Anim* animation = static_cast<Anim*>(nw4r::ut::List_GetNext(&mAnms, NULL)); animation != NULL;
|
||||
animation = static_cast<Anim*>(nw4r::ut::List_GetNext(&mAnms, animation))) {
|
||||
if (animation->muID == id) return animation;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
#else
|
||||
virtual Anim* searchAnimation(u32 id);
|
||||
#endif // 0x1C
|
||||
@@ -245,22 +247,14 @@ namespace textinput {
|
||||
virtual bool updateInput(int point, f32 x, f32 y, u32 trig, u32 hold, u32 release, void* data); // 0x20
|
||||
virtual bool updateInput(input::HKBManager& hkbManager); // 0x24
|
||||
|
||||
#ifdef TI_PC_KEYBOARD_IMPLEMENTATION
|
||||
virtual TiLayout* getLayout();
|
||||
#else
|
||||
virtual TiLayout* getLayout() { return mpLayout; } // 0x28
|
||||
#endif
|
||||
|
||||
virtual nw4r::lyt::Pane* getPane(const char* paneName); // 0x2C
|
||||
virtual const nw4r::lyt::Pane* getPane(const char* paneName) const; // 0x30
|
||||
|
||||
virtual u32 getFlightDuration(int point, const char* paneName); // 0x34
|
||||
|
||||
#ifdef TI_PC_KEYBOARD_IMPLEMENTATION
|
||||
virtual void setAnimOn(bool flag);
|
||||
#else
|
||||
virtual void setAnimOn(bool flag) { mbAnimOn = flag; } // 0x38
|
||||
#endif
|
||||
|
||||
virtual void drawPane(const char* paneName); // 0x3C
|
||||
|
||||
@@ -288,16 +282,8 @@ namespace textinput {
|
||||
virtual AnmPane* searchAnmPane(const char* paneName); // 0x60
|
||||
virtual AnmPane* searchAnmPane(wchar_t ch); // 0x64
|
||||
|
||||
#ifdef TI_PC_KEYBOARD_IMPLEMENTATION
|
||||
virtual nw4r::ut::List& getAnmPaneList();
|
||||
#else
|
||||
virtual nw4r::ut::List& getAnmPaneList() { return mAnmPanes; } // 0x68
|
||||
#endif
|
||||
#ifdef TI_PC_KEYBOARD_IMPLEMENTATION
|
||||
virtual gui::PaneManager* getPaneManager();
|
||||
#else
|
||||
virtual gui::PaneManager* getPaneManager() { return mpPaneManager; } // 0x6C
|
||||
#endif
|
||||
|
||||
virtual void AdjustPaneMtx(Mtx& mtx, const nw4r::lyt::DrawInfo& drawInfo, const nw4r::math::MTX34& mGlobalMtx); // 0x70
|
||||
|
||||
|
||||
@@ -191,11 +191,7 @@ namespace textinput {
|
||||
#endif
|
||||
virtual ~Base();
|
||||
virtual void create(MEMAllocator* allocator);
|
||||
#ifdef TI_PC_KEYBOARD_IMPLEMENTATION
|
||||
virtual void init();
|
||||
#else
|
||||
virtual inline void init();
|
||||
#endif
|
||||
virtual void updateFromReceiver(u32 command, void* data);
|
||||
virtual void onKey(u32 event, void* data);
|
||||
virtual int getType();
|
||||
@@ -227,9 +223,6 @@ namespace textinput {
|
||||
virtual void updateFixMode();
|
||||
|
||||
protected:
|
||||
#ifdef TI_PC_KEYBOARD_IMPLEMENTATION
|
||||
inline void initializeKeyState();
|
||||
#endif
|
||||
State mState;
|
||||
const LanguageData* mpInitialLanguageData;
|
||||
KeyState mKeyState;
|
||||
@@ -308,8 +301,6 @@ namespace textinput {
|
||||
LayoutByNW4R(Manager* manager, nw4r::lyt::MultiArcResourceAccessor* accessor, EventObserver* observer, const char* layoutName)
|
||||
: Base(manager), nw4rmanager::Layout(accessor, layoutName, observer), mpKeyboardEventHandler(NULL),
|
||||
mShiftButton(1, this, this), mCapsButton(0, this, this), mModePanel(2, this, this) {}
|
||||
#elif defined(TI_PC_KEYBOARD_IMPLEMENTATION)
|
||||
LayoutByNW4R(Manager* manager, nw4r::lyt::MultiArcResourceAccessor* accessor, EventObserver* observer, const char* layoutName);
|
||||
#endif
|
||||
virtual ~LayoutByNW4R();
|
||||
virtual void create(MEMAllocator* allocator);
|
||||
@@ -361,15 +352,6 @@ namespace textinput {
|
||||
UIModePanel mModePanel;
|
||||
};
|
||||
|
||||
#ifdef TI_PC_KEYBOARD_IMPLEMENTATION
|
||||
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 AnmPane : public nw4rmanager::AnmPane {
|
||||
public:
|
||||
AnmPane(nw4r::lyt::Pane* pane, nw4rmanager::AnmObserver* observer) : nw4rmanager::AnmPane(pane, observer), mAnimation(0) {}
|
||||
|
||||
@@ -14,17 +14,9 @@ namespace textinput {
|
||||
Base(Manager* manager) : mQwerty(true), meLanguage(USA), mpAllocator(NULL), mpManager(manager) {}
|
||||
#endif
|
||||
|
||||
#ifdef TI_PC_KEYBOARD_IMPLEMENTATION
|
||||
virtual void create(MEMAllocator* allocator);
|
||||
#else
|
||||
virtual void create(MEMAllocator* allocator) { mpAllocator = allocator; }
|
||||
#endif
|
||||
virtual void init() {}
|
||||
#ifdef TI_PC_KEYBOARD_IMPLEMENTATION
|
||||
virtual bool isQwerty() const;
|
||||
#else
|
||||
virtual bool isQwerty() const { return mQwerty; }
|
||||
#endif
|
||||
virtual void setQwerty(bool qwerty);
|
||||
virtual void setLanguage(Language language) { meLanguage = language; }
|
||||
virtual Language getLanguage() const { return meLanguage; }
|
||||
|
||||
@@ -39,9 +39,7 @@ public:
|
||||
};
|
||||
|
||||
static u16 ElementBuffer[0x100];
|
||||
static u16 CandidatesBuffer[0x100];
|
||||
static u16 ElementWorkBuffer[0x100];
|
||||
static u16 PredictionBuffer[0x100];
|
||||
static u16 CandidatesBuffer[0x300];
|
||||
static u16 CandidatedWord[0xa00];
|
||||
static u16 LatestWord[0x40];
|
||||
|
||||
|
||||
@@ -163,9 +163,6 @@ namespace ipl {
|
||||
void init(const f32& start, const f32& end, f32 maxFrame, f32 startTangent, f32 endTangent, int playback = ANIM_TYPE_FORWARD,
|
||||
f32 speed = 1.0f);
|
||||
|
||||
#ifdef IPL_SD_CHANNEL_TITLE_CPP
|
||||
f32 get() const;
|
||||
#else
|
||||
f32 get() const {
|
||||
f32 var_f27 = mFrame;
|
||||
f32 var_f28 = 1.0f / mMaxFrame;
|
||||
@@ -184,7 +181,6 @@ namespace ipl {
|
||||
|
||||
return r;
|
||||
}
|
||||
#endif
|
||||
|
||||
protected:
|
||||
f32 mStart;
|
||||
|
||||
@@ -103,7 +103,7 @@ namespace ipl {
|
||||
y = r.y;
|
||||
z = 0.0f;
|
||||
}
|
||||
#if defined(IPL_ADDRESS_EDIT_CPP) || defined(IPL_SD_CHANNEL_SELECT_CPP) || defined(IPL_GC_WINDOW_CPP) || defined(IPL_SD_CHANNEL_TITLE_CPP)
|
||||
#if defined(IPL_ADDRESS_EDIT_CPP) || defined(IPL_SD_CHANNEL_SELECT_CPP) || defined(IPL_GC_WINDOW_CPP)
|
||||
VEC3(f32 fx, f32 fy, f32 fz);
|
||||
#else
|
||||
VEC3(f32 fx, f32 fy, f32 fz) {
|
||||
|
||||
@@ -141,9 +141,6 @@ namespace ipl {
|
||||
void init(nw4r::lyt::Pane* pane);
|
||||
void set(u64 fdId);
|
||||
void reset();
|
||||
#ifdef IPL_ADDRESS_MATCHING
|
||||
nigaoe::Object* getPortrait() const { return mpNigaoe; }
|
||||
#endif
|
||||
|
||||
static void create_callback(nigaoe::Object* object, void* work);
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
|
||||
namespace ipl {
|
||||
namespace scene {
|
||||
extern "C" BOOL push_button_queue(void*, const void*);
|
||||
class ButtonEventHandlerBase;
|
||||
class OptOutButtonEventHandlerBase;
|
||||
class SDMenuEventHandlerBase;
|
||||
@@ -315,7 +314,6 @@ namespace ipl {
|
||||
}
|
||||
|
||||
protected:
|
||||
friend BOOL push_button_queue(void*, const void*);
|
||||
typedef struct Command {
|
||||
enum {
|
||||
TYPE_ANIM = 0,
|
||||
|
||||
@@ -31,12 +31,8 @@ namespace ipl {
|
||||
|
||||
virtual void calc();
|
||||
|
||||
#ifdef IPL_SD_CHANNEL_TITLE_CPP
|
||||
virtual void initCalcNormal();
|
||||
#else
|
||||
virtual void initCalcNormal() {
|
||||
} // 0x4C
|
||||
#endif
|
||||
virtual void initCalcFadeout() {
|
||||
} // 0x50
|
||||
|
||||
@@ -53,12 +49,8 @@ namespace ipl {
|
||||
return FADER_SCN_NEXT;
|
||||
} // 0x60
|
||||
|
||||
#ifdef IPL_SD_CHANNEL_TITLE_CPP
|
||||
virtual void calcCommonAfter();
|
||||
#else
|
||||
virtual void calcCommonAfter() {
|
||||
} // 0x64
|
||||
#endif
|
||||
|
||||
int getSceneFadeState() {
|
||||
return mScnFadeState;
|
||||
|
||||
@@ -62,11 +62,7 @@ namespace ipl {
|
||||
virtual ~Base();
|
||||
|
||||
/** @brief If the scene is ready */
|
||||
#ifdef IPL_SD_CHANNEL_TITLE_CPP
|
||||
virtual BOOL isReady() const;
|
||||
#else
|
||||
virtual BOOL isReady() const { return FALSE; }
|
||||
#endif
|
||||
|
||||
/** @brief If the user can power off/reset the system */
|
||||
#ifdef IPL_SD_CHANNEL_TITLE_CPP
|
||||
@@ -77,11 +73,7 @@ namespace ipl {
|
||||
/** @brief The scene running code when powering off/resetting the system */
|
||||
virtual void startResetting() {}
|
||||
/** @brief If the scene has finished its powering off/resetting task */
|
||||
#ifdef IPL_SD_CHANNEL_TITLE_CPP
|
||||
virtual BOOL isResetProcessDone();
|
||||
#else
|
||||
virtual BOOL isResetProcessDone() { return TRUE; }
|
||||
#endif
|
||||
|
||||
/** @brief Prepare to create scene */
|
||||
virtual void prepare() {}
|
||||
@@ -94,17 +86,10 @@ namespace ipl {
|
||||
/** @brief Destroy the scene and clear from memory */
|
||||
virtual void destroy() {}
|
||||
|
||||
#ifdef IPL_SD_CHANNEL_TITLE_CPP
|
||||
virtual Base* getParent();
|
||||
virtual Base* getChild();
|
||||
virtual Base* getNext();
|
||||
virtual Base* getPrev();
|
||||
#else
|
||||
virtual Base* getParent() { return (Base*)mpParent; }
|
||||
virtual Base* getChild() { return (Base*)mpChild; }
|
||||
virtual Base* getNext() { return (Base*)mpNext; }
|
||||
virtual Base* getPrev() { return (Base*)mpPrev; }
|
||||
#endif
|
||||
|
||||
/** @brief Check if scene has been created.*/
|
||||
bool isSceneCreated() const { return (mScnState & SCN_STATE_CREATED); }
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace ipl {
|
||||
STATE_FINISHED,
|
||||
};
|
||||
|
||||
volatile bool mbDoneProcess; // 0x00
|
||||
bool mbDoneProcess; // 0x00
|
||||
int mCDBResult; // 0x04
|
||||
|
||||
int mPrevFreeSize; // 0x08
|
||||
|
||||
@@ -65,13 +65,8 @@ namespace ipl {
|
||||
/** @brief Writes the file contents. */
|
||||
virtual void write(); // 0x10
|
||||
|
||||
#ifdef IPL_SD_CHANNEL_TITLE_CPP
|
||||
virtual bool isFinished();
|
||||
virtual int checkData();
|
||||
#else
|
||||
virtual bool isFinished() { return mbDoneTask; } // 0x14
|
||||
virtual int checkData() { return mResult; } // 0x18
|
||||
#endif
|
||||
virtual bool isFatalError(); // 0x1C
|
||||
|
||||
u8* getBuffer() const { return mpBuffer; }
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace ipl {
|
||||
static BOOL IsLastTicketExpired(ESTitleId* titleId);
|
||||
static void DeleteExpiredFlagFile();
|
||||
|
||||
static s32 DeleteUnauthorizedData(EGG::Heap* heap);
|
||||
static void DeleteUnauthorizedData(EGG::Heap* heap);
|
||||
|
||||
static u32 CheckTmdCountryCode(ESTmdView* tmdView);
|
||||
static u32 CheckTmdParentalControl(ESTmdView* tmdView);
|
||||
|
||||
@@ -51,17 +51,12 @@ namespace ipl {
|
||||
mArg.mOrthoScale = scale;
|
||||
}
|
||||
|
||||
#ifdef IPL_SD_CHANNEL_TITLE_CPP
|
||||
static void setOrthoTrans(const math::VEC3& translate);
|
||||
static void setOrthoScale(const math::VEC2& scale);
|
||||
#else
|
||||
static void setOrthoTrans(const math::VEC3& translate) { mArg.mOrthoTrans = translate; }
|
||||
|
||||
static void setOrthoScale(const math::VEC2& scale) NO_INLINE {
|
||||
mArg.mOrthoScale.x = scale.x;
|
||||
mArg.mOrthoScale.y = scale.y;
|
||||
}
|
||||
#endif
|
||||
|
||||
private:
|
||||
static Arg mArg;
|
||||
|
||||
@@ -21,12 +21,6 @@ namespace EGG {
|
||||
|
||||
virtual void initialize(IAudioMgr::Arg* arg);
|
||||
};
|
||||
|
||||
class ExpAudioMgr : public SimpleAudioMgr, public AudioFxMgr {
|
||||
public:
|
||||
ExpAudioMgr();
|
||||
virtual ~ExpAudioMgr();
|
||||
};
|
||||
} // namespace EGG
|
||||
|
||||
#endif // EGG_AUDIO_EXP_MGR_H
|
||||
|
||||
@@ -29,10 +29,4 @@ namespace EGG {
|
||||
|
||||
mHeap.SaveState();
|
||||
}
|
||||
|
||||
ExpAudioMgr::ExpAudioMgr() {
|
||||
}
|
||||
|
||||
ExpAudioMgr::~ExpAudioMgr() {
|
||||
}
|
||||
} // namespace EGG
|
||||
|
||||
@@ -88,7 +88,7 @@ namespace nw4r {
|
||||
PaneList& GetChildList() { return mChildList; }
|
||||
|
||||
const math::VEC3& GetTranslate() { return mTranslate; }
|
||||
#if defined(IPL_SDMEMORY_SET_TRANSLATE_OUT_OF_LINE) || defined(IPL_ADDRESS_MATCHING)
|
||||
#ifdef IPL_SDMEMORY_SET_TRANSLATE_OUT_OF_LINE
|
||||
void SetTranslate(const math::VEC3& translate);
|
||||
#else
|
||||
void SetTranslate(const math::VEC3& translate) { mTranslate = translate; }
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace nw4r {
|
||||
namespace ut {
|
||||
class Rect {
|
||||
public:
|
||||
#if defined(IPL_SOUND_RECT_OUT_OF_LINE) || defined(IPL_SD_CHANNEL_TITLE_CPP)
|
||||
#ifdef IPL_SOUND_RECT_OUT_OF_LINE
|
||||
Rect();
|
||||
#else
|
||||
Rect() : left(), top(), right(), bottom() {}
|
||||
@@ -20,7 +20,7 @@ namespace nw4r {
|
||||
Rect(f32 l, f32 t, f32 r, f32 b) : left(l), top(t), right(r), bottom(b) {}
|
||||
#endif
|
||||
|
||||
#if !defined(IPL_CONTROLLER_TRIVIAL_RECT_DTOR) && !defined(IPL_MEMORYCARD_BASE_CPP) && !defined(IPL_SD_CHANNEL_TITLE_CPP)
|
||||
#if !defined(IPL_CONTROLLER_TRIVIAL_RECT_DTOR) && !defined(IPL_MEMORYCARD_BASE_CPP)
|
||||
~Rect() {}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace nw4r {
|
||||
} // namespace detail
|
||||
|
||||
template <typename TDerived, typename TBase>
|
||||
#if defined(IPL_BOARD_OBJECT_EXTERNAL_DYNAMIC_CAST) || defined(IPL_MEMORYCARD_BASE_CPP) || defined(IPL_SD_CHANNEL_TITLE_CPP)
|
||||
#if defined(IPL_BOARD_OBJECT_EXTERNAL_DYNAMIC_CAST) || defined(IPL_MEMORYCARD_BASE_CPP)
|
||||
TDerived DynamicCast(TBase* pPtr);
|
||||
#else
|
||||
inline TDerived DynamicCast(TBase* pPtr) {
|
||||
|
||||
@@ -252,17 +252,14 @@ namespace nw4r {
|
||||
}
|
||||
|
||||
inline void updateSheetFlags(const void* glgrHdr, u32 groupIdx, u16* sheetOffsets, u32 flagsStep, const u32* sheetFlags) {
|
||||
const GlyphGroups* glgr = (const GlyphGroups*)((const u8*)glgrHdr + sizeof(BinaryBlockHeader));
|
||||
int sheetIndex;
|
||||
u32 groupBitOffset;
|
||||
u16* sheetOffset = sheetOffsets;
|
||||
groupBitOffset = groupIdx * flagsStep * 8;
|
||||
for (sheetIndex = 0; sheetIndex < glgr->sheetCount; sheetOffset++, sheetIndex++) {
|
||||
u32 groupBitIdx = sheetIndex + groupBitOffset;
|
||||
const GlyphGroups* glgr = (GlyphGroups*)((u8*)glgrHdr + sizeof(BinaryBlockHeader));
|
||||
for (int sheetI = 0; sheetI < glgr->sheetCount; sheetI++) {
|
||||
u32 groupBitIdx = sheetI + groupIdx * flagsStep * 8;
|
||||
|
||||
const u32* bitBlockPtr = sheetFlags + (groupBitIdx & ~0x1F) / 32;
|
||||
u32 bitBlock = *bitBlockPtr;
|
||||
u32 bitBlock = *(u32*)bitBlockPtr;
|
||||
if (((bitBlock << (groupBitIdx & 0x1F)) & 0x80000000) != 0) {
|
||||
*sheetOffset = 1;
|
||||
sheetOffsets[sheetI] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -271,16 +268,14 @@ namespace nw4r {
|
||||
const u32* bitBlocksPtr, u32 sheetFlagsSize) {
|
||||
HeaderedGlyphGroups* pGlgr = (HeaderedGlyphGroups*)glgrHdr;
|
||||
|
||||
int i;
|
||||
u16* sheetOffset;
|
||||
for (i = 0, sheetOffset = sheetOffsets; i < pGlgr->inner.sheetCount; sheetOffset++, i++) {
|
||||
*sheetOffset = 0;
|
||||
for (int i = 0; i < pGlgr->inner.sheetCount; i++) {
|
||||
sheetOffsets[i] = 0;
|
||||
}
|
||||
|
||||
for (int i = 0; i < pGlgr->inner.nameCount; i++) {
|
||||
const char* includedGroups = ctx->pIncludedGroups;
|
||||
u16 offset = pGlgr->inner.nameOffsets[i];
|
||||
char* name = (char*)(offset + (u32)hdr);
|
||||
char* name = (char*)((u8*)hdr + offset);
|
||||
if (*includedGroups != 0) {
|
||||
if (!ArchiveFontBase::IncludeName(includedGroups, name)) {
|
||||
continue;
|
||||
@@ -293,23 +288,21 @@ namespace nw4r {
|
||||
|
||||
inline void convertSheetOffsetBooleansToOffsets(const void* glgrHdr, u16* sheetOffsets) {
|
||||
HeaderedGlyphGroups* pGlgr = (HeaderedGlyphGroups*)glgrHdr;
|
||||
int i;
|
||||
u16 glyphIdxOffset = 0;
|
||||
u16* sheetOffset;
|
||||
for (i = 0, sheetOffset = sheetOffsets; i < pGlgr->inner.sheetCount; sheetOffset++, i++) {
|
||||
if (*sheetOffset == 1) {
|
||||
*sheetOffset = glyphIdxOffset;
|
||||
for (int i = 0; i < pGlgr->inner.sheetCount; i++) {
|
||||
if (sheetOffsets[i] == 1) {
|
||||
sheetOffsets[i] = glyphIdxOffset;
|
||||
} else {
|
||||
*sheetOffset = -1;
|
||||
sheetOffsets[i] = -1;
|
||||
glyphIdxOffset += pGlgr->inner.sheetGlyphCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline void copyFlagOffsets(ArchiveFontBase::ConstructContext* ctx, u16* sheetOffsetsScratch, u32 workSize, const u16* sheetOffsetsScratchEnd) {
|
||||
inline void copyFlagOffsets(ArchiveFontBase::ConstructContext* ctx, u16* sheetOffsetsScratch, u32 workSize, u32 scratchSize) {
|
||||
u8* sheetOffsets = ctx->pWorkCurr;
|
||||
ctx->pWorkCurr = sheetOffsets + workSize;
|
||||
memmove(sheetOffsets, sheetOffsetsScratch, (sheetOffsetsScratchEnd - sheetOffsetsScratch) * sizeof(u16));
|
||||
memmove(sheetOffsets, sheetOffsetsScratch, scratchSize);
|
||||
ctx->pSheetOffsets = (u16*)sheetOffsets;
|
||||
}
|
||||
|
||||
@@ -318,64 +311,31 @@ namespace nw4r {
|
||||
// *sheetOffsetsScratch = (u16*)ROUNDDOWN((u32)((u8*)fontData + remWorkSpace) - sheetOffsetsSize, 2);
|
||||
// return sheetOffsetsSize;
|
||||
// }
|
||||
class FontGlyphGroupsAcs {
|
||||
public:
|
||||
explicit FontGlyphGroupsAcs(const ArchiveFontBinaryLayout* font)
|
||||
: mFont(font), mGroups(&font->glgr) {}
|
||||
const GlyphGroups& GetGroups() const { return mGroups->inner; }
|
||||
void SetSheetFlags(u32 flagsStep, const u32* sheetFlags) {
|
||||
mFlagsStep = flagsStep;
|
||||
mSheetFlags = sheetFlags;
|
||||
}
|
||||
|
||||
u16 GetNumSheet() const { return mGroups->inner.sheetCount; }
|
||||
int GetGlyphsPerSheet() const { return mGroups->inner.sheetGlyphCount; }
|
||||
u16 GetNumSet() const { return mGroups->inner.nameCount; }
|
||||
const char* GetSetName(int groupIndex) const {
|
||||
const u16 nameOffset = mGroups->inner.nameOffsets[groupIndex];
|
||||
return (const char*)(nameOffset + (u32)mFont);
|
||||
}
|
||||
bool IsUseSheet(int groupIndex, int sheetIndex) const {
|
||||
const u32 groupBitIndex = sheetIndex + groupIndex * mFlagsStep * 8;
|
||||
const u32* bitBlock = mSheetFlags + (groupBitIndex & ~0x1F) / 32;
|
||||
return ((*bitBlock << (groupBitIndex & 0x1F)) & 0x80000000) != 0;
|
||||
}
|
||||
|
||||
private:
|
||||
const ArchiveFontBinaryLayout* mFont;
|
||||
const HeaderedGlyphGroups* mGroups;
|
||||
u32 mFlagsStep;
|
||||
const u32* mSheetFlags;
|
||||
};
|
||||
|
||||
ArchiveFontBase::ConstructState ArchiveFontBase::ConstructOpAnalyzeGLGR(ConstructContext* ctx, CachedStreamReader* reader) {
|
||||
const u32* flagsSheets;
|
||||
u32 sheetOffsetsSize;
|
||||
u32 flagsSheetsOff;
|
||||
u32 glgrInnerLen;
|
||||
const ArchiveFontBinaryLayout* font;
|
||||
u16 sheetGlyphCount;
|
||||
u32 countSheet;
|
||||
HeaderedGlyphGroups* pGlgr;
|
||||
const ArchiveFontBinaryLayout* font;
|
||||
u8* glgrEnd;
|
||||
|
||||
u32 expectedMaxSize;
|
||||
u32 dataBlockCount;
|
||||
u16* sheetOffsetsScratch;
|
||||
int groupIndex;
|
||||
|
||||
font = (ArchiveFontBinaryLayout*)ctx->pWorkCurr;
|
||||
|
||||
glgrInnerLen = ctx->mNextBlockHdr.size - sizeof(BinaryBlockHeader);
|
||||
|
||||
// Check for RFNA
|
||||
if (font->hdr.signature != SIGNATURE_FONT_ARCHIVE) {
|
||||
return CONSTRUCT_STATE_FATAL_ERR;
|
||||
}
|
||||
|
||||
// Check that there's enough data available, and the space to
|
||||
// put that data
|
||||
ENSURE_READER_HAS_SIZE(ctx, reader, glgrInnerLen);
|
||||
ENSURE_WORK_HAS_SIZE(ctx, glgrInnerLen);
|
||||
|
||||
expectedMaxSize = ctx->mNextBlockHdr.size + sizeof(BinaryFileHeader);
|
||||
|
||||
// Copy the glgr to work
|
||||
{
|
||||
pGlgr = (HeaderedGlyphGroups*)&font->glgr;
|
||||
glgrEnd = (u8*)pGlgr + (u32)ctx->mNextBlockHdr.size;
|
||||
@@ -388,45 +348,80 @@ namespace nw4r {
|
||||
return CONSTRUCT_STATE_FATAL_ERR;
|
||||
}
|
||||
|
||||
FontGlyphGroupsAcs gg(font);
|
||||
sheetGlyphCount = gg.GetGlyphsPerSheet();
|
||||
dataBlockCount = font->hdr.dataBlocks;
|
||||
countSheet = gg.GetNumSheet();
|
||||
const u32 stepSheetFlags = detail::CalcSizeFlagSet(countSheet);
|
||||
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);
|
||||
// Before here is fine (other than regswaps)
|
||||
// u16 sheetGlyphCount = FORCE_REACCESS_2(font->glgr.inner.sheetGlyphCount, u16); // 0x1C
|
||||
// u16 dataBlockCount = FORCE_REACCESS_2(font->hdr.dataBlocks, u16); // 0x0E
|
||||
// FORCE_REACCESS_2(font->glgr.inner.sheetCount, u16);
|
||||
// return ConstructOpAnalyzeGLGRInner(ctx, font, pGlgr, glgrEnd);
|
||||
|
||||
sheetOffsetsSize = (RoundUp)(countSheet * sizeof(u16), 4);
|
||||
// u32 fontSizeToEndOfGlgr;
|
||||
|
||||
u16 countSheet;
|
||||
u16 sheetGlyphCount, dataBlockCount;
|
||||
|
||||
u32 stepSheetFlags;
|
||||
u32 flagsSheetsOff;
|
||||
const u32* flagsSheets;
|
||||
|
||||
u32 sheetOffsetsSize;
|
||||
u16* sheetOffsetsScratch;
|
||||
|
||||
u32 sheetOffsetsScratchSize;
|
||||
|
||||
sheetGlyphCount = font->glgr.inner.sheetGlyphCount; // 0x1C
|
||||
dataBlockCount = font->hdr.dataBlocks; // 0x0E
|
||||
// countName = font->glgr.inner.nameCount;
|
||||
countSheet = font->glgr.inner.sheetCount;
|
||||
// count0A = font->glgr.inner.smthCount_0x0a;
|
||||
// count0C = font->glgr.inner.smthCount_0x0c;
|
||||
stepSheetFlags = detail::CalcSizeFlagSet(countSheet);
|
||||
flagsSheetsOff = detail::CalcOffsetSheetFlags(font->glgr.inner.nameCount, countSheet, font->glgr.inner.smthCount_0x0a,
|
||||
font->glgr.inner.smthCount_0x0c);
|
||||
flagsSheets = (const u32*)font + (flagsSheetsOff >> 2);
|
||||
|
||||
sheetOffsetsSize = ROUNDUP(countSheet * sizeof(u16), 4);
|
||||
sheetOffsetsScratch = (u16*)ROUNDDOWN((u32)((u8*)font + ctx->remWorkSpace()) - sheetOffsetsSize, 2);
|
||||
|
||||
pGlgr = (HeaderedGlyphGroups*)&font->glgr;
|
||||
ENSURE_WORK_HAS_SIZE(ctx, glgrEnd - (u8*)font + sheetOffsetsSize);
|
||||
// if (ctx->pWorkEnd - workCurr < fontSizeToEndOfGlgr + sheetOffsetsSize) {
|
||||
// return CONSTRUCT_STATE_FATAL_ERR;
|
||||
// }
|
||||
|
||||
{
|
||||
u16* sheetOffset;
|
||||
int sheetIndex;
|
||||
for (sheetIndex = 0, sheetOffset = sheetOffsetsScratch; sheetIndex < gg.GetNumSheet(); sheetOffset++, sheetIndex++) {
|
||||
*sheetOffset = 0;
|
||||
}
|
||||
for (groupIndex = 0; groupIndex < gg.GetNumSet(); groupIndex++) {
|
||||
const char* includedGroups = ctx->pIncludedGroups;
|
||||
const char* name = gg.GetSetName(groupIndex);
|
||||
if (*includedGroups && !ArchiveFontBase::IncludeName(includedGroups, name)) {
|
||||
continue;
|
||||
}
|
||||
for (int sheetIndex = 0; sheetIndex < gg.GetNumSheet(); sheetIndex++) {
|
||||
if (gg.IsUseSheet(groupIndex, sheetIndex)) {
|
||||
sheetOffsetsScratch[sheetIndex] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Clear sheet offsets scratch
|
||||
// for (s32 i = 0; i < pGlgr->inner.sheetCount; i++) {
|
||||
// sheetOffsetsScratch[i] = 0;
|
||||
// }
|
||||
|
||||
// for (s32 i = 0; i < pGlgr->inner.nameCount; i++) {
|
||||
// // const char* includedGroups = ctx->pIncludedGroups;
|
||||
// u16 offset = pGlgr->inner.nameOffsets[i];
|
||||
// const char* name = (char*)((u8*)font + offset);
|
||||
// if (*ctx->pIncludedGroups != 0) {
|
||||
// if (!ArchiveFontBase::IncludeName(ctx->pIncludedGroups, name)) {
|
||||
// continue;
|
||||
// }
|
||||
// }
|
||||
|
||||
// updateSheetFlags(pGlgr, i, sheetOffsetsScratch, stepSheetFlags, flagsSheets);
|
||||
// }
|
||||
setSheetOffsetBooleans(ctx, pGlgr, font, sheetOffsetsScratch, flagsSheets, stepSheetFlags);
|
||||
|
||||
// u16 glyphIdxOffset = 0;
|
||||
// for (s32 i = 0; i < pGlgr->inner.sheetCount; i++) {
|
||||
// if (sheetOffsetsScratch[i] == 1) {
|
||||
// sheetOffsetsScratch[i] = glyphIdxOffset;
|
||||
// } else {
|
||||
// sheetOffsetsScratch[i] = -1;
|
||||
// glyphIdxOffset += pGlgr->inner.sheetGlyphCount;
|
||||
// }
|
||||
// }
|
||||
convertSheetOffsetBooleansToOffsets(pGlgr, sheetOffsetsScratch);
|
||||
|
||||
copyFlagOffsets(ctx, sheetOffsetsScratch, sheetOffsetsSize, sheetOffsetsScratch + (u16)countSheet);
|
||||
sheetOffsetsScratchSize = (u32)countSheet << 1;
|
||||
sheetOffsetsScratchSize += (sheetOffsetsScratchSize >> 31);
|
||||
sheetOffsetsScratchSize &= ~1;
|
||||
copyFlagOffsets(ctx, sheetOffsetsScratch, sheetOffsetsSize, sheetOffsetsScratchSize);
|
||||
|
||||
ctx->mSheetCount = countSheet;
|
||||
ctx->mGlyphsPerSheet = sheetGlyphCount;
|
||||
|
||||
@@ -1,35 +1,79 @@
|
||||
#include <stddef.h>
|
||||
#include <tmc_jpeg_internal.h>
|
||||
|
||||
#ifdef __MWERKS__
|
||||
asm s32 TMCJPEGDEC_init_buff_thumbnail(register TMCCJPEGDecWork* work, register u8* dst, register u8* src) {
|
||||
nofralloc
|
||||
|
||||
lwz r0, 4(r5)
|
||||
cmpwi r0, 0
|
||||
bne _init_buff_thumbnail_have_src1
|
||||
li r3, -1
|
||||
blr
|
||||
|
||||
_init_buff_thumbnail_have_src1:
|
||||
lwz r0, 8(r5)
|
||||
cmpwi r0, 0
|
||||
bne _init_buff_thumbnail_have_src2
|
||||
li r3, -1
|
||||
blr
|
||||
|
||||
_init_buff_thumbnail_have_src2:
|
||||
lwz r7, 0(r5)
|
||||
li r0, 0
|
||||
stw r7, 0x18(r4)
|
||||
lwz r6, 4(r5)
|
||||
stw r6, 0x1c(r4)
|
||||
lwz r6, 8(r5)
|
||||
stw r6, 0x20(r4)
|
||||
lwz r6, 0xc(r5)
|
||||
stw r6, 0x24(r4)
|
||||
lwz r5, 0x10(r5)
|
||||
stw r5, 0x28(r4)
|
||||
stw r7, 8(r4)
|
||||
lwz r6, 0x674(r3)
|
||||
lwz r5, 0x66c(r3)
|
||||
add r5, r6, r5
|
||||
stw r5, 0xc(r4)
|
||||
lwz r6, 0x670(r3)
|
||||
li r3, 0
|
||||
add r5, r5, r6
|
||||
stw r0, 0x20(r4)
|
||||
subi r0, r5, 0x22
|
||||
stw r5, 0x10(r4)
|
||||
stw r0, 0x14(r4)
|
||||
blr
|
||||
}
|
||||
#else
|
||||
s32 TMCJPEGDEC_init_buff_thumbnail(TMCCJPEGDecWork* work, u8* dst, u8* src) {
|
||||
TMCCJPEGDecWork* buffer = (TMCCJPEGDecWork*)dst;
|
||||
const TMCCJPEGDecInitParam* input = (const TMCCJPEGDecInitParam*)(src - offsetof(TMCCJPEGDecInitParam, pBuf2));
|
||||
s32 endAddress;
|
||||
u8* start;
|
||||
const TMCCJPEGDecExifData* exif = (const TMCCJPEGDecExifData*)work;
|
||||
u32* src32;
|
||||
u32* dst32;
|
||||
u32 tmp;
|
||||
|
||||
if (input->buf2Size == 0) {
|
||||
src32 = (u32*)src;
|
||||
dst32 = (u32*)dst;
|
||||
|
||||
if (src32[1] == 0) {
|
||||
return -1;
|
||||
}
|
||||
if (input->dataSize == 0) {
|
||||
if (src32[2] == 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
start = input->pBuf2;
|
||||
buffer->pBufOrg = start;
|
||||
buffer->bufLen = input->buf2Size;
|
||||
buffer->remaining = input->dataSize;
|
||||
buffer->pCallback = input->pCallback;
|
||||
buffer->pCbCtx = input->pContext;
|
||||
buffer->pBufStart = start;
|
||||
buffer->pBufCur = exif->thumbnailData + exif->thumbnailOffset;
|
||||
endAddress = exif->thumbnailLength;
|
||||
endAddress = (u32)buffer->pBufCur + endAddress;
|
||||
buffer->remaining = 0;
|
||||
buffer->pBufEnd = (u8*)endAddress;
|
||||
buffer->pBufMark = (u8*)((u32)endAddress - 0x22);
|
||||
tmp = src32[0];
|
||||
dst32[6] = src32[0];
|
||||
dst32[7] = src32[1];
|
||||
dst32[8] = src32[2];
|
||||
dst32[9] = src32[3];
|
||||
dst32[10] = src32[4];
|
||||
|
||||
dst32[2] = tmp;
|
||||
dst32[3] = work->thumbHuffSize[2] + work->thumbHuffSize[0];
|
||||
dst32[4] = work->thumbHuffSize[1] + dst32[3];
|
||||
dst32[5] = dst32[4] - 0x22;
|
||||
dst32[8] = 0;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
s32 TMCJPEGDEC_init_buff(TMCCJPEGDecWork* work) {
|
||||
work->bitBuf = 0;
|
||||
|
||||
@@ -28,36 +28,36 @@ static s32 scalingClampU8(s32 value) {
|
||||
void TMCJPEGDEC_IdctBlock_Lumi(s32* block, u8* conv_row_ptr, u16 pitch, s32 zigzag) {
|
||||
s32 tmp[64];
|
||||
s32* dst;
|
||||
s32 d;
|
||||
s32 t;
|
||||
s32 done;
|
||||
s32 iter;
|
||||
s32 i;
|
||||
s32 y;
|
||||
s32 e;
|
||||
s32 b2;
|
||||
s32 b1;
|
||||
s32 b3;
|
||||
s32 b4;
|
||||
s32 b5;
|
||||
s32 b6;
|
||||
s32 b7;
|
||||
s32 n;
|
||||
s32 v;
|
||||
s32 m;
|
||||
s32 a;
|
||||
s32 done;
|
||||
s32 d;
|
||||
s32 z;
|
||||
s32 v;
|
||||
s32 o;
|
||||
s32 p;
|
||||
s32 p_part;
|
||||
s32 m_part;
|
||||
s32 t;
|
||||
s32 u;
|
||||
s32 r;
|
||||
s32 o;
|
||||
s32 x;
|
||||
s32 n;
|
||||
s32 y;
|
||||
s32 x_factor;
|
||||
s32 z_factor;
|
||||
s32 iter;
|
||||
s32 m_part;
|
||||
s32 q;
|
||||
s32 w;
|
||||
s32 e;
|
||||
s32 b3;
|
||||
s32 x;
|
||||
s32 b1;
|
||||
|
||||
r = (zigzag >> 4) * 8;
|
||||
dst = tmp;
|
||||
@@ -93,19 +93,17 @@ void TMCJPEGDEC_IdctBlock_Lumi(s32* block, u8* conv_row_ptr, u16 pitch, s32 zigz
|
||||
} else {
|
||||
s32 oddLowSum;
|
||||
s32 oddHighSum;
|
||||
s32 oddLowDifference;
|
||||
s32 oddHighDifference;
|
||||
s32 dcValue;
|
||||
|
||||
t = b2 - b6;
|
||||
oddLowSum = b5 + b3;
|
||||
oddLowDifference = b5 - b3;
|
||||
b5 = b5 - b3;
|
||||
oddHighSum = b1 + b7;
|
||||
oddHighDifference = b1 - b7;
|
||||
b1 = b1 - b7;
|
||||
u = b6 + b2;
|
||||
t = t * 0xB5 >> 8;
|
||||
x_factor = oddHighSum - oddLowSum;
|
||||
z_factor = oddLowDifference + oddHighDifference;
|
||||
z_factor = b5 + b1;
|
||||
dcValue = block[0];
|
||||
a = dcValue - b4;
|
||||
x = x_factor * 0xB5 >> 8;
|
||||
@@ -115,14 +113,14 @@ void TMCJPEGDEC_IdctBlock_Lumi(s32* block, u8* conv_row_ptr, u16 pitch, s32 zigz
|
||||
z = z_factor * 0x62 >> 8;
|
||||
w = d + u;
|
||||
y = d - u;
|
||||
m_part = oddHighDifference * 0x14E >> 8;
|
||||
m_part = b1 * 0x14E >> 8;
|
||||
e = a - t;
|
||||
m = m_part - z;
|
||||
oddLowSum += m;
|
||||
n = oddHighSum + oddLowSum;
|
||||
o = x + m;
|
||||
dst[0] = w + n;
|
||||
p_part = oddLowDifference * 0x8B;
|
||||
p_part = b5 * 0x8B;
|
||||
dst[7] = w - n;
|
||||
p_part >>= 8;
|
||||
dst[1] = v + o;
|
||||
@@ -227,7 +225,7 @@ void TMCJPEGDEC_IdctBlock_Lumi(s32* block, u8* conv_row_ptr, u16 pitch, s32 zigz
|
||||
void TMCJPEGDEC_IdctBlock_Col(s32* block, u8* conv_row_ptr, u16 pitch, s32 zigzag) {
|
||||
s32 tmp[64];
|
||||
s32* dst;
|
||||
s32 a;
|
||||
s32 done;
|
||||
s32 iter;
|
||||
s32 d;
|
||||
s32 b1;
|
||||
@@ -239,14 +237,14 @@ void TMCJPEGDEC_IdctBlock_Col(s32* block, u8* conv_row_ptr, u16 pitch, s32 zigza
|
||||
s32 b7;
|
||||
s32 v;
|
||||
s32 r;
|
||||
s32 done;
|
||||
s32 a;
|
||||
s32 i;
|
||||
s32 m;
|
||||
s32 n;
|
||||
s32 o;
|
||||
s32 x;
|
||||
s32 q;
|
||||
s32 e;
|
||||
s32 y;
|
||||
s32 u;
|
||||
s32 w;
|
||||
s32 p;
|
||||
@@ -256,7 +254,7 @@ void TMCJPEGDEC_IdctBlock_Col(s32* block, u8* conv_row_ptr, u16 pitch, s32 zigza
|
||||
s32 z_factor;
|
||||
s32 m_part;
|
||||
s32 p_part;
|
||||
s32 y;
|
||||
s32 e;
|
||||
|
||||
if (zigzag == 0x11) {
|
||||
s32 val;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include <tmc_jpeg_internal.h>
|
||||
|
||||
static s32 TMCJPEGDEC_exif_parse(const u8* data, u32 size, TMCCJPEGDecExifData* pInfo);
|
||||
static void TMCJPEGDEC_IFD0_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder, u8* entry);
|
||||
static void TMCJPEGDEC_IFD0_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder, const u8* entry);
|
||||
static void TMCJPEGDEC_IFD1_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder, const u8* entry);
|
||||
static s32 TMCJPEGDEC_ThumbnailCheck(TMCCJPEGDecInitParam* param, TMCCJPEGDecExifInfo* info, u32 totalSize);
|
||||
|
||||
@@ -280,7 +280,7 @@ static s32 TMCJPEGDEC_exif_parse(const u8* data, u32 size, TMCCJPEGDecExifData*
|
||||
return -161;
|
||||
}
|
||||
for (index = 0; index < count; index++) {
|
||||
TMCJPEGDEC_IFD0_tag_parse(pInfo, byteOrder, (u8*)entries);
|
||||
TMCJPEGDEC_IFD0_tag_parse(pInfo, byteOrder, entries);
|
||||
entries += 12;
|
||||
}
|
||||
remaining -= entriesSize;
|
||||
@@ -331,19 +331,19 @@ static s32 TMCJPEGDEC_exif_parse(const u8* data, u32 size, TMCCJPEGDecExifData*
|
||||
return -161;
|
||||
}
|
||||
for (index = 0; index < count; index++) {
|
||||
TMCJPEGDEC_IFD0_tag_parse(pInfo, byteOrder, (u8*)entries);
|
||||
TMCJPEGDEC_IFD0_tag_parse(pInfo, byteOrder, entries);
|
||||
entries += 12;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void TMCJPEGDEC_IFD0_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder, u8* entry) {
|
||||
static void TMCJPEGDEC_IFD0_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder, const u8* entry) {
|
||||
s32 tag;
|
||||
u32 type;
|
||||
u16 type;
|
||||
|
||||
tag = readExifU16(entry, byteOrder);
|
||||
type = readExifU16(entry + 2, byteOrder);
|
||||
tag = readU16(entry, byteOrder);
|
||||
type = readU16(entry + 2, byteOrder);
|
||||
|
||||
switch (tag) {
|
||||
case 0x0103:
|
||||
@@ -366,7 +366,7 @@ static void TMCJPEGDEC_IFD0_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
|
||||
return;
|
||||
}
|
||||
pInfo->xResNum = readU32(p, byteOrder);
|
||||
p = pInfo->thumbnailData + (offset + 4);
|
||||
p = (const u8*)(pInfo->thumbnailData + offset + 4);
|
||||
if (pInfo->thumbnailData > p) {
|
||||
return;
|
||||
}
|
||||
@@ -386,7 +386,7 @@ static void TMCJPEGDEC_IFD0_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
|
||||
return;
|
||||
}
|
||||
pInfo->yResNum = readU32(p, byteOrder);
|
||||
p = pInfo->thumbnailData + (offset + 4);
|
||||
p = (const u8*)(pInfo->thumbnailData + offset + 4);
|
||||
if (pInfo->thumbnailData > p) {
|
||||
return;
|
||||
}
|
||||
@@ -501,10 +501,6 @@ static void TMCJPEGDEC_IFD1_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
|
||||
case 0x8769:
|
||||
case 0x9000:
|
||||
case 0x9101:
|
||||
case 0x011C:
|
||||
case 0xA000:
|
||||
case 0xA001:
|
||||
case 0xA002:
|
||||
case 0xA003: {
|
||||
break;
|
||||
}
|
||||
@@ -520,7 +516,7 @@ static void TMCJPEGDEC_IFD1_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
|
||||
return;
|
||||
}
|
||||
pInfo->xResNumIfd1 = readU32(p, byteOrder);
|
||||
p = pInfo->thumbnailData + (offset + 4);
|
||||
p = (const u8*)(pInfo->thumbnailData + offset + 4);
|
||||
if (pInfo->thumbnailData > p) {
|
||||
return;
|
||||
}
|
||||
@@ -542,7 +538,7 @@ static void TMCJPEGDEC_IFD1_tag_parse(TMCCJPEGDecExifData* pInfo, u16 byteOrder,
|
||||
return;
|
||||
}
|
||||
pInfo->planarConfigIfd1 = readU32(p, byteOrder);
|
||||
p = pInfo->thumbnailData + (offset + 4);
|
||||
p = (const u8*)(pInfo->thumbnailData + offset + 4);
|
||||
if (pInfo->thumbnailData > p) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -106,43 +106,192 @@ s32 TMCJPEGDEC_decompmcu(u32 maxMCU, u32 mcuCount, TMCCJPEGDecWork* work, void*
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline void initZigzag(TMCCJPEGDecWork* work) {
|
||||
const u8* zigzag = TMCJPEGDEC_Zigzag_data;
|
||||
s32 i;
|
||||
work->restartInterval = 0;
|
||||
work->scanCount = 0;
|
||||
for (i = 0; i < 64; i++) {
|
||||
work->zigzagData[i] = *zigzag++ << 2;
|
||||
}
|
||||
#ifdef __MWERKS__
|
||||
asm s32 TMCJPEGDEC_imagestart(register TMCCJPEGDecWork* work) {
|
||||
nofralloc
|
||||
|
||||
stwu r1, -0x20(r1)
|
||||
mflr r0
|
||||
lis r8, TMCJPEGDEC_Zigzag_data@ha
|
||||
li r4, 0
|
||||
stw r0, 0x24(r1)
|
||||
li r0, 4
|
||||
addi r8, r8, TMCJPEGDEC_Zigzag_data@l
|
||||
li r7, 0
|
||||
stw r31, 0x1c(r1)
|
||||
mr r31, r3
|
||||
sth r4, 0x181a(r3)
|
||||
stb r4, 0x181c(r3)
|
||||
mtctr r0
|
||||
|
||||
_imagestart_loop:
|
||||
lbz r6, 0(r8)
|
||||
add r9, r3, r7
|
||||
lbz r5, 1(r8)
|
||||
addi r7, r7, 8
|
||||
rlwinm r6, r6, 2, 0x18, 0x1d
|
||||
lbz r4, 2(r8)
|
||||
stb r6, 0x458(r9)
|
||||
rlwinm r5, r5, 2, 0x18, 0x1d
|
||||
rlwinm r6, r4, 2, 0x18, 0x1d
|
||||
lbz r0, 3(r8)
|
||||
stb r5, 0x459(r9)
|
||||
rlwinm r5, r0, 2, 0x18, 0x1d
|
||||
lbz r4, 4(r8)
|
||||
stb r6, 0x45a(r9)
|
||||
rlwinm r6, r4, 2, 0x18, 0x1d
|
||||
lbz r4, 6(r8)
|
||||
stb r5, 0x45b(r9)
|
||||
lbz r0, 5(r8)
|
||||
rlwinm r4, r4, 2, 0x18, 0x1d
|
||||
stb r6, 0x45c(r9)
|
||||
rlwinm r5, r0, 2, 0x18, 0x1d
|
||||
lbz r0, 7(r8)
|
||||
stb r5, 0x45d(r9)
|
||||
lbz r6, 8(r8)
|
||||
rlwinm r0, r0, 2, 0x18, 0x1d
|
||||
stb r4, 0x45e(r9)
|
||||
lbz r5, 9(r8)
|
||||
rlwinm r6, r6, 2, 0x18, 0x1d
|
||||
stb r0, 0x45f(r9)
|
||||
add r9, r3, r7
|
||||
lbz r4, 0xa(r8)
|
||||
rlwinm r5, r5, 2, 0x18, 0x1d
|
||||
stb r6, 0x458(r9)
|
||||
addi r7, r7, 8
|
||||
rlwinm r6, r4, 2, 0x18, 0x1d
|
||||
lbz r0, 0xb(r8)
|
||||
stb r5, 0x459(r9)
|
||||
rlwinm r5, r0, 2, 0x18, 0x1d
|
||||
lbz r4, 0xc(r8)
|
||||
stb r6, 0x45a(r9)
|
||||
rlwinm r6, r4, 2, 0x18, 0x1d
|
||||
lbz r4, 0xe(r8)
|
||||
stb r5, 0x45b(r9)
|
||||
lbz r0, 0xd(r8)
|
||||
rlwinm r4, r4, 2, 0x18, 0x1d
|
||||
stb r6, 0x45c(r9)
|
||||
rlwinm r5, r0, 2, 0x18, 0x1d
|
||||
lbz r0, 0xf(r8)
|
||||
stb r5, 0x45d(r9)
|
||||
addi r8, r8, 0x10
|
||||
rlwinm r0, r0, 2, 0x18, 0x1d
|
||||
stb r4, 0x45e(r9)
|
||||
stb r0, 0x45f(r9)
|
||||
bdnz _imagestart_loop
|
||||
|
||||
mr r4, r31
|
||||
addi r3, r1, 8
|
||||
bl TMCJPEGDEC_get_wbyte
|
||||
cmpwi r3, 0
|
||||
bge _imagestart_have_marker
|
||||
b _imagestart_return
|
||||
|
||||
_imagestart_have_marker:
|
||||
lhz r0, 8(r1)
|
||||
cmplwi r0, 0xffd8
|
||||
beq _imagestart_parse
|
||||
li r3, -0x20
|
||||
b _imagestart_return
|
||||
|
||||
_imagestart_parse:
|
||||
li r0, 0
|
||||
mr r4, r31
|
||||
sth r0, 8(r1)
|
||||
addi r3, r1, 8
|
||||
bl TMCJPEGDEC_parse_para
|
||||
cmpwi r3, 0
|
||||
bge _imagestart_check_sof
|
||||
b _imagestart_return
|
||||
|
||||
_imagestart_check_sof:
|
||||
lhz r0, 8(r1)
|
||||
cmplwi r0, 0xffc0
|
||||
beq _imagestart_parse_sof
|
||||
li r3, -0x10
|
||||
b _imagestart_return
|
||||
|
||||
_imagestart_parse_sof:
|
||||
mr r3, r31
|
||||
bl TMCJPEGDEC_parse_sof
|
||||
srawi r0, r3, 0x1f
|
||||
and r3, r3, r0
|
||||
|
||||
_imagestart_return:
|
||||
lwz r0, 0x24(r1)
|
||||
lwz r31, 0x1c(r1)
|
||||
mtlr r0
|
||||
addi r1, r1, 0x20
|
||||
blr
|
||||
}
|
||||
|
||||
#else
|
||||
s32 TMCJPEGDEC_imagestart(TMCCJPEGDecWork* work) {
|
||||
u16 marker;
|
||||
s32 r;
|
||||
initZigzag(work);
|
||||
u32 off;
|
||||
u8* p;
|
||||
int i;
|
||||
const u8* zigzag;
|
||||
|
||||
zigzag = TMCJPEGDEC_Zigzag_data;
|
||||
work->restartInterval = 0;
|
||||
work->scanCount = 0;
|
||||
off = 0;
|
||||
i = 4;
|
||||
|
||||
do {
|
||||
p = (u8*)work + off;
|
||||
off += 8;
|
||||
p[0x458] = (zigzag[0] & 0x3F) << 2;
|
||||
p[0x459] = (zigzag[1] & 0x3F) << 2;
|
||||
p[0x45a] = (zigzag[2] & 0x3F) << 2;
|
||||
p[0x45b] = (zigzag[3] & 0x3F) << 2;
|
||||
p[0x45c] = (zigzag[4] & 0x3F) << 2;
|
||||
p[0x45e] = (zigzag[6] & 0x3F) << 2;
|
||||
p[0x45d] = (zigzag[5] & 0x3F) << 2;
|
||||
p[0x45f] = (zigzag[7] & 0x3F) << 2;
|
||||
|
||||
p = (u8*)work + off;
|
||||
off += 8;
|
||||
p[0x458] = (zigzag[8] & 0x3F) << 2;
|
||||
p[0x459] = (zigzag[9] & 0x3F) << 2;
|
||||
p[0x45a] = (zigzag[10] & 0x3F) << 2;
|
||||
p[0x45b] = (zigzag[11] & 0x3F) << 2;
|
||||
p[0x45c] = (zigzag[12] & 0x3F) << 2;
|
||||
p[0x45d] = (zigzag[13] & 0x3F) << 2;
|
||||
p[0x45e] = (zigzag[14] & 0x3F) << 2;
|
||||
p[0x45f] = (zigzag[15] & 0x3F) << 2;
|
||||
|
||||
zigzag += 16;
|
||||
} while (--i != 0);
|
||||
|
||||
r = TMCJPEGDEC_get_wbyte(&marker, work);
|
||||
if (r < 0) {
|
||||
return r;
|
||||
}
|
||||
|
||||
if (marker != 0xFFD8) {
|
||||
return -0x20;
|
||||
}
|
||||
|
||||
marker = 0;
|
||||
r = TMCJPEGDEC_parse_para(&marker, work);
|
||||
if (r < 0) {
|
||||
return r;
|
||||
}
|
||||
|
||||
if (marker != 0xFFC0) {
|
||||
return -0x10;
|
||||
}
|
||||
|
||||
r = TMCJPEGDEC_parse_sof(work);
|
||||
if (r < 0) {
|
||||
return r;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
s32 TMCJPEGDEC_imageend(TMCCJPEGDecWork* work) {
|
||||
if (work->pState->unk_0x21 == 1)
|
||||
@@ -634,85 +783,266 @@ s32 TMCJPEGDEC_restart_interval(TMCCJPEGDecWork* work, u32 maxMCU, u32 mcuCount)
|
||||
}
|
||||
#endif
|
||||
|
||||
static inline s32 skipSegmentData(u16 length, TMCCJPEGDecWork* work) {
|
||||
s32 result = TMCJPEGDEC_move_ptr(length, work);
|
||||
if (result < 0) {
|
||||
return result;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#ifdef __MWERKS__
|
||||
static asm s32 TMCJPEGDEC_parse_para(register u16* marker, register TMCCJPEGDecWork* work) {
|
||||
nofralloc
|
||||
|
||||
static inline s32 parseApplication(TMCCJPEGDecWork* work) {
|
||||
u16 length;
|
||||
s32 result = TMCJPEGDEC_get_wbyte(&length, work);
|
||||
if (result < 0) {
|
||||
return result;
|
||||
}
|
||||
if (length < 2) {
|
||||
return -0x45;
|
||||
}
|
||||
length -= 2;
|
||||
result = skipSegmentData(length, work);
|
||||
if (result < 0) {
|
||||
return result;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
stwu r1, -0x30(r1)
|
||||
mflr r0
|
||||
stw r0, 0x34(r1)
|
||||
stmw r26, 0x18(r1)
|
||||
mr r28, r3
|
||||
mr r29, r4
|
||||
li r31, 0
|
||||
lis r26, 1
|
||||
li r27, 1
|
||||
lhz r30, 0(r3)
|
||||
|
||||
static inline s32 parseRestartInterval(TMCCJPEGDecWork* work) {
|
||||
u16 length;
|
||||
s32 result = TMCJPEGDEC_get_wbyte(&length, work);
|
||||
if (result < 0) {
|
||||
return result;
|
||||
}
|
||||
if (length != 4) {
|
||||
return -0x42;
|
||||
}
|
||||
result = TMCJPEGDEC_get_wbyte(&length, work);
|
||||
if (result < 0) {
|
||||
return result;
|
||||
}
|
||||
work->restartInterval = length;
|
||||
return 0;
|
||||
}
|
||||
_parse_para_loop:
|
||||
mr r4, r29
|
||||
addi r3, r1, 0x12
|
||||
bl TMCJPEGDEC_get_wbyte
|
||||
cmpwi r3, 0
|
||||
bge _parse_para_marker_loaded
|
||||
cmpwi r3, -0x90
|
||||
bne _parse_para_return
|
||||
lhz r0, 0x12(r1)
|
||||
cmplwi r0, 0xffd9
|
||||
bne _parse_para_return
|
||||
li r3, 0
|
||||
b _parse_para_marker_loaded
|
||||
b _parse_para_return
|
||||
|
||||
static inline s32 parseNumberOfLines(TMCCJPEGDecWork* work) {
|
||||
u16 length;
|
||||
s32 result = TMCJPEGDEC_get_wbyte(&length, work);
|
||||
if (result < 0) {
|
||||
return result;
|
||||
}
|
||||
if (length != 4) {
|
||||
return -0x43;
|
||||
}
|
||||
result = TMCJPEGDEC_get_wbyte(&length, work);
|
||||
if (result < 0) {
|
||||
return result;
|
||||
}
|
||||
work->frameHeight = length;
|
||||
return 0;
|
||||
}
|
||||
_parse_para_marker_loaded:
|
||||
lhz r0, 0x12(r1)
|
||||
b _parse_para_marker_condition
|
||||
|
||||
static inline s32 parseComment(TMCCJPEGDecWork* work) {
|
||||
u16 length;
|
||||
s32 result = TMCJPEGDEC_get_wbyte(&length, work);
|
||||
if (result < 0) {
|
||||
return result;
|
||||
}
|
||||
if (length < 2) {
|
||||
return -0x44;
|
||||
}
|
||||
length -= 2;
|
||||
result = skipSegmentData(length, work);
|
||||
if (result < 0) {
|
||||
return result;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
_parse_para_marker_byte:
|
||||
mr r4, r29
|
||||
addi r3, r1, 8
|
||||
bl TMCJPEGDEC_get_byte
|
||||
cmpwi r3, 0
|
||||
bge _parse_para_marker_byte_loaded
|
||||
b _parse_para_return
|
||||
|
||||
_parse_para_marker_byte_loaded:
|
||||
lbz r0, 8(r1)
|
||||
ori r0, r0, 0xff00
|
||||
sth r0, 0x12(r1)
|
||||
|
||||
_parse_para_marker_condition:
|
||||
clrlwi r4, r0, 0x10
|
||||
cmplwi r4, 0xffff
|
||||
beq _parse_para_marker_byte
|
||||
cmplwi r4, 0xffe0
|
||||
blt _parse_para_switch
|
||||
cmplwi r4, 0xffef
|
||||
bgt _parse_para_switch
|
||||
mr r4, r29
|
||||
addi r3, r1, 0x10
|
||||
bl TMCJPEGDEC_get_wbyte
|
||||
cmpwi r3, 0
|
||||
bge _parse_para_app_length
|
||||
b _parse_para_check_result
|
||||
|
||||
_parse_para_app_length:
|
||||
lhz r3, 0x10(r1)
|
||||
cmplwi r3, 2
|
||||
bge _parse_para_app_move
|
||||
li r3, -0x45
|
||||
b _parse_para_check_result
|
||||
|
||||
_parse_para_app_move:
|
||||
addi r0, r3, -2
|
||||
mr r4, r29
|
||||
sth r0, 0x10(r1)
|
||||
clrlwi r3, r0, 0x10
|
||||
bl TMCJPEGDEC_move_ptr
|
||||
srawi r0, r3, 0x1f
|
||||
and r3, r3, r0
|
||||
srawi r0, r3, 0x1f
|
||||
and r3, r3, r0
|
||||
b _parse_para_check_result
|
||||
|
||||
_parse_para_switch:
|
||||
addi r0, r26, -0x27
|
||||
cmpw r4, r0
|
||||
beq _parse_para_eoi
|
||||
bge _parse_para_switch_ge_ffc2
|
||||
addi r0, r26, -0x3e
|
||||
cmpw r4, r0
|
||||
beq _parse_para_sos
|
||||
bge _parse_para_switch_ge_ffc4
|
||||
addi r0, r26, -0x40
|
||||
cmpw r4, r0
|
||||
beq _parse_para_sof
|
||||
b _parse_para_unknown
|
||||
|
||||
_parse_para_switch_ge_ffc4:
|
||||
addi r0, r26, -0x3c
|
||||
cmpw r4, r0
|
||||
beq _parse_para_dht
|
||||
b _parse_para_unknown
|
||||
|
||||
_parse_para_switch_ge_ffc2:
|
||||
addi r0, r26, -0x23
|
||||
cmpw r4, r0
|
||||
beq _parse_para_dri
|
||||
bge _parse_para_switch_ge_ffdc
|
||||
addi r0, r26, -0x25
|
||||
cmpw r4, r0
|
||||
beq _parse_para_dqt
|
||||
bge _parse_para_dnl
|
||||
b _parse_para_com_marker
|
||||
|
||||
_parse_para_switch_ge_ffdc:
|
||||
addi r0, r26, -2
|
||||
cmpw r4, r0
|
||||
beq _parse_para_com
|
||||
b _parse_para_unknown
|
||||
|
||||
_parse_para_dht:
|
||||
mr r3, r30
|
||||
mr r4, r29
|
||||
bl TMCJPEGDEC_parse_dht
|
||||
b _parse_para_check_result
|
||||
|
||||
_parse_para_dqt:
|
||||
mr r3, r29
|
||||
bl TMCJPEGDEC_parse_dqt
|
||||
b _parse_para_check_result
|
||||
|
||||
_parse_para_dri:
|
||||
mr r4, r29
|
||||
addi r3, r1, 0xe
|
||||
bl TMCJPEGDEC_get_wbyte
|
||||
cmpwi r3, 0
|
||||
bge _parse_para_dri_length
|
||||
b _parse_para_check_result
|
||||
|
||||
_parse_para_dri_length:
|
||||
lhz r0, 0xe(r1)
|
||||
cmplwi r0, 4
|
||||
beq _parse_para_dri_value
|
||||
li r3, -0x42
|
||||
b _parse_para_check_result
|
||||
|
||||
_parse_para_dri_value:
|
||||
mr r4, r29
|
||||
addi r3, r1, 0xe
|
||||
bl TMCJPEGDEC_get_wbyte
|
||||
cmpwi r3, 0
|
||||
bge _parse_para_dri_store
|
||||
b _parse_para_check_result
|
||||
|
||||
_parse_para_dri_store:
|
||||
lhz r0, 0xe(r1)
|
||||
li r3, 0
|
||||
sth r0, 0x181a(r29)
|
||||
b _parse_para_check_result
|
||||
|
||||
_parse_para_dnl:
|
||||
mr r4, r29
|
||||
addi r3, r1, 0xc
|
||||
bl TMCJPEGDEC_get_wbyte
|
||||
cmpwi r3, 0
|
||||
bge _parse_para_dnl_length
|
||||
b _parse_para_check_result
|
||||
|
||||
_parse_para_dnl_length:
|
||||
lhz r0, 0xc(r1)
|
||||
cmplwi r0, 4
|
||||
beq _parse_para_dnl_value
|
||||
li r3, -0x43
|
||||
b _parse_para_check_result
|
||||
|
||||
_parse_para_dnl_value:
|
||||
mr r4, r29
|
||||
addi r3, r1, 0xc
|
||||
bl TMCJPEGDEC_get_wbyte
|
||||
cmpwi r3, 0
|
||||
bge _parse_para_dnl_store
|
||||
b _parse_para_check_result
|
||||
|
||||
_parse_para_dnl_store:
|
||||
lhz r0, 0xc(r1)
|
||||
li r3, 0
|
||||
sth r0, 0x17f2(r29)
|
||||
b _parse_para_check_result
|
||||
|
||||
_parse_para_com:
|
||||
mr r4, r29
|
||||
addi r3, r1, 0xa
|
||||
bl TMCJPEGDEC_get_wbyte
|
||||
cmpwi r3, 0
|
||||
bge _parse_para_com_length
|
||||
b _parse_para_check_result
|
||||
|
||||
_parse_para_com_length:
|
||||
lhz r3, 0xa(r1)
|
||||
cmplwi r3, 2
|
||||
bge _parse_para_com_move
|
||||
li r3, -0x44
|
||||
b _parse_para_check_result
|
||||
|
||||
_parse_para_com_move:
|
||||
addi r0, r3, -2
|
||||
mr r4, r29
|
||||
sth r0, 0xa(r1)
|
||||
clrlwi r3, r0, 0x10
|
||||
bl TMCJPEGDEC_move_ptr
|
||||
srawi r0, r3, 0x1f
|
||||
and r3, r3, r0
|
||||
srawi r0, r3, 0x1f
|
||||
and r3, r3, r0
|
||||
b _parse_para_check_result
|
||||
|
||||
_parse_para_sof:
|
||||
li r31, 1
|
||||
b _parse_para_check_result
|
||||
|
||||
_parse_para_sos:
|
||||
li r31, 1
|
||||
b _parse_para_check_result
|
||||
|
||||
_parse_para_com_marker:
|
||||
li r31, 1
|
||||
b _parse_para_check_result
|
||||
|
||||
_parse_para_eoi:
|
||||
stb r27, 0x181c(r29)
|
||||
li r31, 1
|
||||
b _parse_para_check_result
|
||||
|
||||
_parse_para_unknown:
|
||||
li r3, -0x2f
|
||||
|
||||
_parse_para_check_result:
|
||||
cmpwi r3, 0
|
||||
bge _parse_para_keep_going
|
||||
li r31, 1
|
||||
|
||||
_parse_para_keep_going:
|
||||
cmpwi r31, 0
|
||||
beq _parse_para_loop
|
||||
lhz r0, 0x12(r1)
|
||||
sth r0, 0(r28)
|
||||
|
||||
_parse_para_return:
|
||||
lmw r26, 0x18(r1)
|
||||
lwz r0, 0x34(r1)
|
||||
mtlr r0
|
||||
addi r1, r1, 0x30
|
||||
blr
|
||||
}
|
||||
#else
|
||||
static s32 TMCJPEGDEC_parse_para(u16* marker, TMCCJPEGDecWork* work) {
|
||||
u8 byte;
|
||||
u16 local;
|
||||
u16 appSize;
|
||||
u16 driSize;
|
||||
u16 dnlSize;
|
||||
u16 comSize;
|
||||
s32 result;
|
||||
|
||||
u32 keepGoing = 0;
|
||||
@@ -737,7 +1067,18 @@ static s32 TMCJPEGDEC_parse_para(u16* marker, TMCCJPEGDecWork* work) {
|
||||
}
|
||||
|
||||
if (local >= 0xFFE0 && local <= 0xFFEF) {
|
||||
result = parseApplication(work);
|
||||
result = TMCJPEGDEC_get_wbyte(&appSize, work);
|
||||
if (result < 0) {
|
||||
goto _check;
|
||||
}
|
||||
if (appSize < 2) {
|
||||
result = -0x45;
|
||||
goto _check;
|
||||
}
|
||||
appSize -= 2;
|
||||
result = TMCJPEGDEC_move_ptr(appSize, work);
|
||||
result = result & (result >> 31);
|
||||
result = result & (result >> 31);
|
||||
} else {
|
||||
switch ((s32)local) {
|
||||
case 0xFFC4: {
|
||||
@@ -749,15 +1090,48 @@ static s32 TMCJPEGDEC_parse_para(u16* marker, TMCCJPEGDecWork* work) {
|
||||
break;
|
||||
}
|
||||
case 0xFFDD: {
|
||||
result = parseRestartInterval(work);
|
||||
result = TMCJPEGDEC_get_wbyte(&driSize, work);
|
||||
if (result >= 0) {
|
||||
if (driSize != 4) {
|
||||
result = -0x42;
|
||||
} else {
|
||||
result = TMCJPEGDEC_get_wbyte(&driSize, work);
|
||||
if (result < 0) {
|
||||
goto _check;
|
||||
}
|
||||
work->restartInterval = driSize;
|
||||
result = 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 0xFFDC: {
|
||||
result = parseNumberOfLines(work);
|
||||
result = TMCJPEGDEC_get_wbyte(&dnlSize, work);
|
||||
if (result >= 0) {
|
||||
if (dnlSize != 4) {
|
||||
result = -0x43;
|
||||
} else {
|
||||
result = TMCJPEGDEC_get_wbyte(&dnlSize, work);
|
||||
if (result >= 0) {
|
||||
work->frameHeight = dnlSize;
|
||||
result = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 0xFFFE: {
|
||||
result = parseComment(work);
|
||||
result = TMCJPEGDEC_get_wbyte(&comSize, work);
|
||||
if (result >= 0) {
|
||||
if (comSize < 2) {
|
||||
result = -0x44;
|
||||
} else {
|
||||
comSize -= 2;
|
||||
result = TMCJPEGDEC_move_ptr(comSize, work);
|
||||
result = result & result >> 31;
|
||||
result = result & result >> 31;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 0xFFC0: {
|
||||
@@ -784,6 +1158,7 @@ static s32 TMCJPEGDEC_parse_para(u16* marker, TMCCJPEGDecWork* work) {
|
||||
}
|
||||
}
|
||||
|
||||
_check:
|
||||
if (result < 0) {
|
||||
keepGoing = 1;
|
||||
}
|
||||
@@ -792,6 +1167,7 @@ static s32 TMCJPEGDEC_parse_para(u16* marker, TMCCJPEGDecWork* work) {
|
||||
*marker = local;
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __MWERKS__
|
||||
static asm s32 TMCJPEGDEC_parse_dht(register s32 first, register TMCCJPEGDecWork* work) {
|
||||
@@ -1583,19 +1959,167 @@ static s32 TMCJPEGDEC_parse_sof(TMCCJPEGDecWork* work) {
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __MWERKS__
|
||||
static asm s32 TMCJPEGDEC_parse_sos(register TMCCJPEGDecWork* work) {
|
||||
nofralloc
|
||||
|
||||
stwu r1, -0x30(r1)
|
||||
mflr r0
|
||||
stw r0, 0x34(r1)
|
||||
stmw r27, 0x1c(r1)
|
||||
mr r28, r3
|
||||
addi r30, r3, 0x2c
|
||||
addi r29, r3, 0x58
|
||||
addi r3, r1, 0xa
|
||||
mr r4, r28
|
||||
bl TMCJPEGDEC_get_wbyte
|
||||
cmpwi r3, 0
|
||||
bge _parse_sos_have_length
|
||||
b _parse_sos_return
|
||||
|
||||
_parse_sos_have_length:
|
||||
lhz r0, 0xa(r1)
|
||||
cmplwi r0, 2
|
||||
bge _parse_sos_have_count
|
||||
li r3, -0x51
|
||||
b _parse_sos_return
|
||||
|
||||
_parse_sos_have_count:
|
||||
mr r4, r28
|
||||
addi r3, r1, 8
|
||||
bl TMCJPEGDEC_get_byte
|
||||
cmpwi r3, 0
|
||||
bge _parse_sos_store_count
|
||||
b _parse_sos_return
|
||||
|
||||
_parse_sos_store_count:
|
||||
lbz r3, 8(r1)
|
||||
cmplwi r3, 4
|
||||
stb r3, 0x180b(r28)
|
||||
bgt _parse_sos_bad_count
|
||||
lbz r0, 0x180a(r28)
|
||||
cmplw r3, r0
|
||||
beq _parse_sos_count_valid
|
||||
|
||||
_parse_sos_bad_count:
|
||||
li r3, -0x51
|
||||
b _parse_sos_return
|
||||
|
||||
_parse_sos_count_valid:
|
||||
li r31, 0
|
||||
b _parse_sos_loop_condition
|
||||
|
||||
_parse_sos_loop:
|
||||
mr r4, r28
|
||||
addi r3, r1, 8
|
||||
bl TMCJPEGDEC_get_byte
|
||||
cmpwi r3, 0
|
||||
bge _parse_sos_have_component
|
||||
b _parse_sos_return
|
||||
|
||||
_parse_sos_have_component:
|
||||
lbz r0, 0x180a(r28)
|
||||
li r5, 0
|
||||
lbz r4, 8(r1)
|
||||
mtctr r0
|
||||
cmpwi r0, 0
|
||||
ble _parse_sos_bad_component
|
||||
|
||||
_parse_sos_find_component:
|
||||
add r3, r30, r5
|
||||
lbz r0, 0x14(r3)
|
||||
cmpw r4, r0
|
||||
bne _parse_sos_next_component
|
||||
stbx r5, r30, r31
|
||||
add r27, r30, r31
|
||||
b _parse_sos_found_component
|
||||
|
||||
_parse_sos_next_component:
|
||||
addi r5, r5, 1
|
||||
bdnz _parse_sos_find_component
|
||||
|
||||
_parse_sos_bad_component:
|
||||
li r3, -0x51
|
||||
b _parse_sos_return
|
||||
|
||||
_parse_sos_found_component:
|
||||
mr r4, r28
|
||||
addi r3, r1, 8
|
||||
bl TMCJPEGDEC_get_byte
|
||||
cmpwi r3, 0
|
||||
bge _parse_sos_have_tables
|
||||
b _parse_sos_return
|
||||
|
||||
_parse_sos_have_tables:
|
||||
lbz r0, 8(r1)
|
||||
srawi r5, r0, 4
|
||||
clrlwi r6, r0, 0x1c
|
||||
cmpwi r5, 1
|
||||
bgt _parse_sos_bad_tables
|
||||
cmpwi r6, 1
|
||||
ble _parse_sos_tables_valid
|
||||
|
||||
_parse_sos_bad_tables:
|
||||
li r3, -0x51
|
||||
b _parse_sos_return
|
||||
|
||||
_parse_sos_tables_valid:
|
||||
lbz r0, 0(r27)
|
||||
add r3, r29, r5
|
||||
add r4, r30, r0
|
||||
stb r5, 0x1c(r4)
|
||||
lbz r0, 0(r27)
|
||||
add r4, r30, r0
|
||||
stb r6, 0x20(r4)
|
||||
lbz r0, 0x1794(r3)
|
||||
cmplwi r0, 1
|
||||
beq _parse_sos_ac_valid
|
||||
li r3, -0x40
|
||||
b _parse_sos_return
|
||||
|
||||
_parse_sos_ac_valid:
|
||||
add r3, r29, r6
|
||||
lbz r0, 0x1796(r3)
|
||||
cmplwi r0, 1
|
||||
beq _parse_sos_quant_valid
|
||||
li r3, -0x40
|
||||
b _parse_sos_return
|
||||
|
||||
_parse_sos_quant_valid:
|
||||
lbz r0, 0x18(r27)
|
||||
add r3, r29, r0
|
||||
lbz r0, 0x1790(r3)
|
||||
cmplwi r0, 1
|
||||
beq _parse_sos_next
|
||||
li r3, -0x41
|
||||
b _parse_sos_return
|
||||
|
||||
_parse_sos_next:
|
||||
addi r31, r31, 1
|
||||
|
||||
_parse_sos_loop_condition:
|
||||
lbz r0, 0x180b(r28)
|
||||
cmpw r31, r0
|
||||
blt _parse_sos_loop
|
||||
mr r4, r28
|
||||
li r3, 3
|
||||
bl TMCJPEGDEC_move_ptr
|
||||
srawi r0, r3, 0x1f
|
||||
and r3, r3, r0
|
||||
|
||||
_parse_sos_return:
|
||||
lmw r27, 0x1c(r1)
|
||||
lwz r0, 0x34(r1)
|
||||
mtlr r0
|
||||
addi r1, r1, 0x30
|
||||
blr
|
||||
}
|
||||
#else
|
||||
static s32 TMCJPEGDEC_parse_sos(TMCCJPEGDecWork* work) {
|
||||
typedef struct {
|
||||
u8 map[4];
|
||||
u32 dcPredict[4];
|
||||
u8 id[4];
|
||||
u8 quantTable[4];
|
||||
u8 dcTable[4];
|
||||
u8 acTable[4];
|
||||
} TMCComponentInfo;
|
||||
s32 idx;
|
||||
TMCComponentInfo* components;
|
||||
u8* compPtr;
|
||||
TMCUnknownInfo* scalePtr;
|
||||
TMCComponentInfo* mapPtr;
|
||||
u8* mapPtr;
|
||||
|
||||
s32 dcTbl;
|
||||
s32 acTbl;
|
||||
@@ -1606,7 +2130,7 @@ static s32 TMCJPEGDEC_parse_sos(TMCCJPEGDecWork* work) {
|
||||
s32 ci;
|
||||
u8 scanByte;
|
||||
|
||||
components = (TMCComponentInfo*)work->compMap;
|
||||
compPtr = (u8*)work->compMap;
|
||||
scalePtr = (TMCUnknownInfo*)&work->scaleFlag;
|
||||
|
||||
r = TMCJPEGDEC_get_wbyte(&len, work);
|
||||
@@ -1622,12 +2146,12 @@ static s32 TMCJPEGDEC_parse_sos(TMCCJPEGDecWork* work) {
|
||||
return r;
|
||||
}
|
||||
|
||||
work->scanCompCount = scanByte;
|
||||
|
||||
if (work->scanCompCount > 4 || work->scanCompCount != work->compCount) {
|
||||
if (scanByte > 4 || scanByte != work->compCount) {
|
||||
return -0x51;
|
||||
}
|
||||
|
||||
work->scanCompCount = scanByte;
|
||||
|
||||
for (idx = 0; idx < (s32)work->scanCompCount; idx++) {
|
||||
r = TMCJPEGDEC_get_byte(&scanByte, work);
|
||||
if (r < 0) {
|
||||
@@ -1635,15 +2159,18 @@ static s32 TMCJPEGDEC_parse_sos(TMCCJPEGDecWork* work) {
|
||||
}
|
||||
|
||||
for (ci = 0; ci < (s32)work->compCount; ci++) {
|
||||
if ((s32)scanByte == (s32)components->id[ci]) {
|
||||
components->map[idx] = ci;
|
||||
mapPtr = (TMCComponentInfo*)&components->map[idx];
|
||||
goto componentFound;
|
||||
if ((s32)compPtr[ci + 0x14] == (s32)scanByte) {
|
||||
compPtr[idx] = ci;
|
||||
mapPtr = compPtr + idx;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return -0x51;
|
||||
|
||||
componentFound:
|
||||
// TODO: This isn't right...
|
||||
if (ci >= (s32)work->compCount) {
|
||||
return -0x51;
|
||||
}
|
||||
|
||||
r = TMCJPEGDEC_get_byte(&scanByte, work);
|
||||
if (r < 0) {
|
||||
return r;
|
||||
@@ -1656,8 +2183,8 @@ componentFound:
|
||||
return -0x51;
|
||||
}
|
||||
|
||||
components->dcTable[mapPtr->map[0]] = dcTbl;
|
||||
components->acTable[mapPtr->map[0]] = acTbl;
|
||||
compPtr[*mapPtr + 0x1c] = dcTbl;
|
||||
compPtr[*mapPtr + 0x20] = acTbl;
|
||||
|
||||
if (scalePtr->dcTblFlag[dcTbl] != 1) {
|
||||
return -0x40;
|
||||
@@ -1667,17 +2194,15 @@ componentFound:
|
||||
return -0x40;
|
||||
}
|
||||
|
||||
if (scalePtr->quantTblFlag[mapPtr->quantTable[0]] != 1) {
|
||||
if (scalePtr->quantTblFlag[mapPtr[0x18]] != 1) {
|
||||
return -0x41;
|
||||
}
|
||||
}
|
||||
|
||||
moveResult = TMCJPEGDEC_move_ptr(3, work);
|
||||
if (moveResult < 0) {
|
||||
return moveResult;
|
||||
}
|
||||
return 0;
|
||||
return moveResult & (moveResult >> 31);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __MWERKS__
|
||||
asm s32 TMCJPEGDEC_err_restart(register TMCCJPEGDecWork* work) {
|
||||
|
||||
@@ -4,21 +4,219 @@ extern void* memset(void* dest, int value, unsigned long size);
|
||||
|
||||
static s32 TMCJPEGDEC_vl_decode_rc(u32* huff_tbl, u8* huff_sym, TMCCJPEGDecWork* work);
|
||||
|
||||
static inline s32 readCoefficientBits(TMCCJPEGDecWork* work, s32 count) {
|
||||
u32 range = 1UL << count;
|
||||
u32 mask = range - 1;
|
||||
s32 value;
|
||||
#ifdef __MWERKS__
|
||||
asm s32 TMCJPEGDEC_decode_iquant_rc(register s32* block, register u8* conv_row_ptr, register u32* dc_predict_row_ptr, register TMCCJPEGDecWork* work) {
|
||||
nofralloc
|
||||
|
||||
value = work->bitCount - count;
|
||||
work->bitCount = value;
|
||||
value = (work->bitBuf >> value) & mask;
|
||||
if (range >> 1 > (u32)value) {
|
||||
value -= mask;
|
||||
}
|
||||
return value;
|
||||
stwu r1, -0x40(r1)
|
||||
mflr r0
|
||||
stw r0, 0x44(r1)
|
||||
stmw r21, 0x14(r1)
|
||||
mr r22, r3
|
||||
mr r23, r4
|
||||
mr r25, r5
|
||||
mr r24, r6
|
||||
lwz r0, 4(r6)
|
||||
lwz r21, 0x498(r6)
|
||||
cmpwi r0, 8
|
||||
bgt _decode_iquant_rc_have_dc_bits
|
||||
mr r3, r24
|
||||
bl TMCJPEGDEC_load_buff
|
||||
cmpwi r3, 0
|
||||
bge _decode_iquant_rc_have_dc_bits
|
||||
b _decode_iquant_rc_return
|
||||
|
||||
_decode_iquant_rc_have_dc_bits:
|
||||
lwz r4, 4(r24)
|
||||
lwz r3, 0(r24)
|
||||
addi r0, r4, -8
|
||||
srw r0, r3, r0
|
||||
rlwinm r0, r0, 2, 0x16, 0x1d
|
||||
lhzx r5, r21, r0
|
||||
cmpwi r5, 0
|
||||
beq _decode_iquant_rc_decode_dc
|
||||
add r3, r21, r0
|
||||
subf r0, r5, r4
|
||||
lhz r21, 2(r3)
|
||||
stw r0, 4(r24)
|
||||
b _decode_iquant_rc_have_dc_value
|
||||
|
||||
_decode_iquant_rc_decode_dc:
|
||||
lwz r3, 0x49c(r24)
|
||||
mr r5, r24
|
||||
lwz r4, 0x4a0(r24)
|
||||
bl TMCJPEGDEC_vl_decode_rc
|
||||
cmpwi r3, 0
|
||||
mr r21, r3
|
||||
bge _decode_iquant_rc_have_dc_value
|
||||
b _decode_iquant_rc_return
|
||||
|
||||
_decode_iquant_rc_have_dc_value:
|
||||
cmpwi r21, 0
|
||||
beq _decode_iquant_rc_store_dc
|
||||
lwz r0, 4(r24)
|
||||
cmpw r0, r21
|
||||
bgt _decode_iquant_rc_read_dc_bits
|
||||
mr r3, r24
|
||||
bl TMCJPEGDEC_load_buff
|
||||
cmpwi r3, 0
|
||||
bge _decode_iquant_rc_read_dc_bits
|
||||
b _decode_iquant_rc_return
|
||||
|
||||
_decode_iquant_rc_read_dc_bits:
|
||||
lwz r0, 4(r24)
|
||||
li r4, 1
|
||||
lwz r3, 0(r24)
|
||||
slw r6, r4, r21
|
||||
subf r4, r21, r0
|
||||
addi r5, r6, -1
|
||||
srwi r0, r6, 1
|
||||
srw r3, r3, r4
|
||||
stw r4, 4(r24)
|
||||
and r3, r5, r3
|
||||
cmplw r0, r3
|
||||
ble _decode_iquant_rc_store_dc_bits
|
||||
subf r3, r5, r3
|
||||
|
||||
_decode_iquant_rc_store_dc_bits:
|
||||
lwz r0, 0(r25)
|
||||
add r0, r0, r3
|
||||
stw r0, 0(r25)
|
||||
|
||||
_decode_iquant_rc_store_dc:
|
||||
lwz r5, 0(r25)
|
||||
addi r3, r22, 4
|
||||
lwz r0, 0(r23)
|
||||
li r4, 0
|
||||
mullw r0, r5, r0
|
||||
stw r0, 0(r22)
|
||||
lwz r30, 0x4a8(r24)
|
||||
lwz r26, 0x4ac(r24)
|
||||
lwz r25, 0x4b0(r24)
|
||||
lwz r27, 0x1834(r24)
|
||||
lwz r5, 0x1838(r24)
|
||||
bl memset
|
||||
lis r21, TMCJPEGDEC_Zigzag_data@ha
|
||||
li r28, 1
|
||||
addi r21, r21, TMCJPEGDEC_Zigzag_data@l
|
||||
li r31, 1
|
||||
|
||||
_decode_iquant_rc_ac_loop:
|
||||
lwz r0, 4(r24)
|
||||
cmpwi r0, 8
|
||||
bgt _decode_iquant_rc_have_ac_bits
|
||||
mr r3, r24
|
||||
bl TMCJPEGDEC_load_buff
|
||||
cmpwi r3, 0
|
||||
bge _decode_iquant_rc_have_ac_bits
|
||||
b _decode_iquant_rc_return
|
||||
|
||||
_decode_iquant_rc_have_ac_bits:
|
||||
lwz r4, 4(r24)
|
||||
lwz r3, 0(r24)
|
||||
addi r0, r4, -8
|
||||
srw r0, r3, r0
|
||||
rlwinm r0, r0, 2, 0x16, 0x1d
|
||||
add r3, r30, r0
|
||||
lhzx r0, r30, r0
|
||||
cmpwi r0, 0
|
||||
beq _decode_iquant_rc_decode_ac
|
||||
lhz r3, 2(r3)
|
||||
subf r0, r0, r4
|
||||
stw r0, 4(r24)
|
||||
b _decode_iquant_rc_have_ac_value
|
||||
|
||||
_decode_iquant_rc_decode_ac:
|
||||
mr r3, r26
|
||||
mr r4, r25
|
||||
mr r5, r24
|
||||
bl TMCJPEGDEC_vl_decode_rc
|
||||
cmpwi r3, 0
|
||||
bge _decode_iquant_rc_have_ac_value
|
||||
b _decode_iquant_rc_return
|
||||
|
||||
_decode_iquant_rc_have_ac_value:
|
||||
clrlwi. r29, r3, 0x1c
|
||||
beq _decode_iquant_rc_no_ac_bits
|
||||
lwz r0, 4(r24)
|
||||
srawi r3, r3, 4
|
||||
add r28, r28, r3
|
||||
cmpw r0, r29
|
||||
bgt _decode_iquant_rc_read_ac_bits
|
||||
mr r3, r24
|
||||
bl TMCJPEGDEC_load_buff
|
||||
cmpwi r3, 0
|
||||
bge _decode_iquant_rc_read_ac_bits
|
||||
b _decode_iquant_rc_return
|
||||
|
||||
_decode_iquant_rc_read_ac_bits:
|
||||
cmpw r28, r27
|
||||
ble _decode_iquant_rc_store_ac
|
||||
lwz r0, 4(r24)
|
||||
cmpwi r28, 0x40
|
||||
subf r0, r29, r0
|
||||
stw r0, 4(r24)
|
||||
blt _decode_iquant_rc_increment
|
||||
li r3, -0x64
|
||||
b _decode_iquant_rc_return
|
||||
|
||||
_decode_iquant_rc_increment:
|
||||
addi r28, r28, 1
|
||||
b _decode_iquant_rc_loop_check
|
||||
|
||||
_decode_iquant_rc_store_ac:
|
||||
lwz r0, 4(r24)
|
||||
slw r6, r31, r29
|
||||
lwz r3, 0(r24)
|
||||
addi r5, r6, -1
|
||||
subf r4, r29, r0
|
||||
srwi r0, r6, 1
|
||||
srw r3, r3, r4
|
||||
stw r4, 4(r24)
|
||||
and r4, r5, r3
|
||||
cmplw r0, r4
|
||||
ble _decode_iquant_rc_have_extra
|
||||
subf r4, r5, r4
|
||||
|
||||
_decode_iquant_rc_have_extra:
|
||||
cmpwi r28, 0x40
|
||||
blt _decode_iquant_rc_store_coeff
|
||||
li r3, -0x64
|
||||
b _decode_iquant_rc_return
|
||||
|
||||
_decode_iquant_rc_store_coeff:
|
||||
lbzx r0, r21, r28
|
||||
addi r28, r28, 1
|
||||
slwi r3, r0, 2
|
||||
lwzx r0, r23, r3
|
||||
mullw r0, r4, r0
|
||||
stwx r0, r22, r3
|
||||
b _decode_iquant_rc_loop_check
|
||||
|
||||
_decode_iquant_rc_no_ac_bits:
|
||||
cmpwi r3, 0
|
||||
bne _decode_iquant_rc_zrl
|
||||
li r3, 0
|
||||
b _decode_iquant_rc_return
|
||||
|
||||
_decode_iquant_rc_zrl:
|
||||
addi r28, r28, 0x10
|
||||
|
||||
_decode_iquant_rc_loop_check:
|
||||
cmpwi r28, 0x40
|
||||
blt _decode_iquant_rc_ac_loop
|
||||
li r3, 0
|
||||
|
||||
_decode_iquant_rc_return:
|
||||
lmw r21, 0x14(r1)
|
||||
lwz r0, 0x44(r1)
|
||||
mtlr r0
|
||||
addi r1, r1, 0x40
|
||||
blr
|
||||
}
|
||||
|
||||
#else
|
||||
s32 TMCJPEGDEC_decode_iquant_rc(s32* block, u8* conv_row_ptr, u32* dc_predict_row_ptr, TMCCJPEGDecWork* work) {
|
||||
const u8* zztbl;
|
||||
u16* ac_fast;
|
||||
s32 t;
|
||||
s32 idx;
|
||||
@@ -33,6 +231,7 @@ s32 TMCJPEGDEC_decode_iquant_rc(s32* block, u8* conv_row_ptr, u32* dc_predict_ro
|
||||
|
||||
s32 blk_mul;
|
||||
s32 bit_pos;
|
||||
u32 bit_data;
|
||||
|
||||
u16* dcf;
|
||||
s32* conv_row;
|
||||
@@ -49,7 +248,7 @@ s32 TMCJPEGDEC_decode_iquant_rc(s32* block, u8* conv_row_ptr, u32* dc_predict_ro
|
||||
tmp = (work->bitBuf >> (bit_pos - 8) & 0xFF) << 2;
|
||||
val = dcf[tmp >> 1];
|
||||
if (val != 0) {
|
||||
tmp = dcf[(tmp >> 1) + 1];
|
||||
tmp = *(u16*)((u8*)dcf + tmp + 2);
|
||||
work->bitCount -= val;
|
||||
val = tmp;
|
||||
} else {
|
||||
@@ -65,7 +264,16 @@ s32 TMCJPEGDEC_decode_iquant_rc(s32* block, u8* conv_row_ptr, u32* dc_predict_ro
|
||||
return r;
|
||||
}
|
||||
}
|
||||
extra = readCoefficientBits(work, val);
|
||||
tmp = 1UL << val;
|
||||
bit_pos = work->bitCount - val;
|
||||
work->bitCount = bit_pos;
|
||||
bit_data = work->bitBuf;
|
||||
|
||||
extra = tmp - 1;
|
||||
extra = extra & (bit_data >> bit_pos);
|
||||
if (tmp >> 1 > (u32)extra) {
|
||||
extra -= (tmp - 1);
|
||||
}
|
||||
dc_predict_row_ptr[0] += extra;
|
||||
}
|
||||
|
||||
@@ -77,8 +285,9 @@ s32 TMCJPEGDEC_decode_iquant_rc(s32* block, u8* conv_row_ptr, u32* dc_predict_ro
|
||||
blk_size = work->blockSize;
|
||||
blk_mul = work->blockSizeMul;
|
||||
|
||||
memset(block + 1, 0, blk_mul);
|
||||
memset((u8*)block + 4, 0, blk_mul);
|
||||
|
||||
zztbl = TMCJPEGDEC_Zigzag_data;
|
||||
idx = 1;
|
||||
do {
|
||||
if (work->bitCount <= 8) {
|
||||
@@ -88,7 +297,7 @@ s32 TMCJPEGDEC_decode_iquant_rc(s32* block, u8* conv_row_ptr, u32* dc_predict_ro
|
||||
}
|
||||
|
||||
{
|
||||
u16* ac_entry = &ac_fast[(work->bitBuf >> (work->bitCount - 8) & 0xFF) * 2];
|
||||
u16* ac_entry = (u16*)((u8*)ac_fast + ((work->bitBuf >> (work->bitCount - 8) & 0xFF) << 2));
|
||||
val = *ac_entry;
|
||||
if (val != 0) {
|
||||
tmp = val;
|
||||
@@ -119,12 +328,21 @@ s32 TMCJPEGDEC_decode_iquant_rc(s32* block, u8* conv_row_ptr, u32* dc_predict_ro
|
||||
}
|
||||
idx++;
|
||||
} else {
|
||||
extra = readCoefficientBits(work, t);
|
||||
bit_pos = work->bitCount - t;
|
||||
work->bitCount = bit_pos;
|
||||
bit_data = work->bitBuf;
|
||||
|
||||
tmp = 1UL << t;
|
||||
extra = tmp - 1;
|
||||
extra = extra & (bit_data >> bit_pos);
|
||||
if (tmp >> 1 > extra) {
|
||||
extra -= tmp - 1;
|
||||
}
|
||||
|
||||
if (idx >= 64) {
|
||||
return TMCC_ERROR_OVERFLOW;
|
||||
}
|
||||
block[TMCJPEGDEC_Zigzag_data[idx]] = extra * conv_row[TMCJPEGDEC_Zigzag_data[idx]];
|
||||
*(s32*)((u8*)block + zztbl[idx] * 4) = extra * conv_row[zztbl[idx]];
|
||||
idx++;
|
||||
}
|
||||
} else {
|
||||
@@ -137,6 +355,7 @@ s32 TMCJPEGDEC_decode_iquant_rc(s32* block, u8* conv_row_ptr, u32* dc_predict_ro
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static s32 TMCJPEGDEC_vl_decode_rc(u32* huff_tbl, u8* huff_sym, TMCCJPEGDecWork* work) {
|
||||
s32 bit_pos;
|
||||
|
||||
@@ -167,28 +167,28 @@ s32 TMCJPEGDEC_set_converterRGB565(TMCCJPEGDecWork* work) {
|
||||
|
||||
static void TMCJPEGDEC_converterYUV411toRGB565(TMCCJPEGDecWork* work, s32 x, s32 y) {
|
||||
u16* output;
|
||||
s32 tileRow;
|
||||
s32 lumaSkip;
|
||||
s32 cbValue;
|
||||
s32 blue;
|
||||
TMCCJPEGDecState* state;
|
||||
s32 lumaSkip;
|
||||
u32 tileWidth;
|
||||
s32 crValue;
|
||||
s32 width;
|
||||
s32 height;
|
||||
s32 chromaSkip;
|
||||
u8* cb;
|
||||
u8* texture;
|
||||
u8* luminance;
|
||||
u8* cb;
|
||||
s32 chromaSkip;
|
||||
u8* cr;
|
||||
s32 column;
|
||||
s32 xEnd;
|
||||
s32 yEnd;
|
||||
u8 value;
|
||||
u32 tileWidth;
|
||||
s32 greenOffset;
|
||||
s32 redOffset;
|
||||
s32 red;
|
||||
s32 tileRow;
|
||||
s32 blueOffset;
|
||||
u8 value;
|
||||
s32 red;
|
||||
s32 greenOffset;
|
||||
s32 green;
|
||||
|
||||
luminance = work->convBuf + 4;
|
||||
@@ -284,9 +284,7 @@ static void TMCJPEGDEC_converterYUV411toRGB565edge(TMCCJPEGDecWork* work, s32 x,
|
||||
s32 yEnd = y + height;
|
||||
s32 lumaSkip = 32 - width;
|
||||
s32 chromaSkip = lumaSkip >> 2;
|
||||
s32 redOffset;
|
||||
s32 blueOffset;
|
||||
s32 greenOffset;
|
||||
s32 redOffset, greenOffset, blueOffset;
|
||||
ASSERTLINE((x & 3) == 0, __LINE__);
|
||||
for (; y < yEnd; y++) {
|
||||
s32 tileRow = (y >> 2) * tileWidth;
|
||||
@@ -324,11 +322,11 @@ static void TMCJPEGDEC_converterYUV422toRGB565(TMCCJPEGDecWork* work, s32 x, s32
|
||||
s32 chromaSkip;
|
||||
s32 width;
|
||||
s32 blue;
|
||||
u16* output;
|
||||
s32 lumaSkip;
|
||||
s32 red;
|
||||
s32 tileRow;
|
||||
s32 lumaSkip;
|
||||
s32 redOffset;
|
||||
u16* output;
|
||||
u32 tileWidth;
|
||||
u8* texture;
|
||||
TMCCJPEGDecState* state;
|
||||
s32 crValue;
|
||||
@@ -340,7 +338,7 @@ static void TMCJPEGDEC_converterYUV422toRGB565(TMCCJPEGDecWork* work, s32 x, s32
|
||||
s32 cbValue;
|
||||
s32 xEnd;
|
||||
s32 yEnd;
|
||||
u32 tileWidth;
|
||||
s32 redOffset;
|
||||
s32 greenOffset;
|
||||
s32 blueOffset;
|
||||
s32 green;
|
||||
@@ -477,22 +475,22 @@ static void TMCJPEGDEC_converterYUV420toRGB565(TMCCJPEGDecWork* work, s32 x, s32
|
||||
s32 width;
|
||||
s32 redOffset;
|
||||
s32 green;
|
||||
s32 tileRow;
|
||||
s32 lumaSkip;
|
||||
u32 tileWidth;
|
||||
u8* texture;
|
||||
s32 chromaSkip;
|
||||
s32 height;
|
||||
u8* texture;
|
||||
s32 yEnd;
|
||||
u8* luminance;
|
||||
s32 crValue;
|
||||
s32 value;
|
||||
u8* cb;
|
||||
u8* cr;
|
||||
s32 column;
|
||||
s32 xEnd;
|
||||
s32 yEnd;
|
||||
u32 tileWidth;
|
||||
s32 cbValue;
|
||||
s32 column;
|
||||
u8* cr;
|
||||
s32 greenOffset;
|
||||
s32 tileRow;
|
||||
s32 cbValue;
|
||||
s32 lumaSkip;
|
||||
s32 blueOffset;
|
||||
s32 red;
|
||||
TMCCJPEGDecState* state;
|
||||
@@ -565,23 +563,26 @@ static void TMCJPEGDEC_converterYUV420toRGB565(TMCCJPEGDecWork* work, s32 x, s32
|
||||
}
|
||||
|
||||
static void TMCJPEGDEC_converterYUV420toRGB565edge(TMCCJPEGDecWork* work, s32 x, s32 y) {
|
||||
s32 chromaSkip;
|
||||
u16* output;
|
||||
s32 yEnd;
|
||||
s8 crValue;
|
||||
s32 tileRow;
|
||||
u8* texture;
|
||||
u8* luminance;
|
||||
s32 width;
|
||||
s8* cb;
|
||||
s8 crValue;
|
||||
s32 width;
|
||||
s8* cr;
|
||||
s8 cbValue;
|
||||
s32 column;
|
||||
s32 xEnd;
|
||||
s8 cbValue;
|
||||
s32 yEnd;
|
||||
s32 red;
|
||||
s32 blue;
|
||||
u32 tileWidth;
|
||||
s32 height;
|
||||
TMCCJPEGDecState* state;
|
||||
s32 green;
|
||||
s32 lumaSkip;
|
||||
u32 tileWidth;
|
||||
s32 chromaSkip;
|
||||
s32 redOffset;
|
||||
s32 greenOffset;
|
||||
s32 blueOffset;
|
||||
@@ -618,18 +619,16 @@ static void TMCJPEGDEC_converterYUV420toRGB565edge(TMCCJPEGDecWork* work, s32 x,
|
||||
greenOffset = -(cbValue * 88 + crValue * 183) >> 8;
|
||||
blueOffset = (cbValue * 454) >> 8;
|
||||
}
|
||||
{
|
||||
s32 value = *luminance++;
|
||||
s32 red = value + redOffset;
|
||||
s32 blue = value + blueOffset;
|
||||
s32 green = value + greenOffset;
|
||||
if ((blue | red | green) >> 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;
|
||||
}
|
||||
output[(column & 3) + (((column >> 2) + tileRow) << 4)] = ((blue & 0xF8) >> 3) + ((red & 0xF8) << 8) + ((green & 0xFC) << 3);
|
||||
blue = *luminance++;
|
||||
red = blue + redOffset;
|
||||
green = blue + greenOffset;
|
||||
blue = blue + blueOffset;
|
||||
if ((blue | red | green) >> 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;
|
||||
}
|
||||
output[(column & 3) + (((column >> 2) + tileRow) << 4)] = ((blue & 0xF8) >> 3) + ((red & 0xF8) << 8) + ((green & 0xFC) << 3);
|
||||
}
|
||||
luminance += lumaSkip;
|
||||
if (y & 1) {
|
||||
@@ -817,11 +816,15 @@ static void TMCJPEGDEC_converterYUV444toRGB565(TMCCJPEGDecWork* work, s32 x, s32
|
||||
u8* luminance;
|
||||
u8* cb;
|
||||
u8* cr;
|
||||
s32 value;
|
||||
s32 column;
|
||||
s32 xEnd;
|
||||
s32 cbValue;
|
||||
s32 yEnd;
|
||||
u32 tileWidth;
|
||||
s32 green;
|
||||
s32 blue;
|
||||
s32 red;
|
||||
s32 height;
|
||||
|
||||
luminance = work->convBuf + 4;
|
||||
@@ -841,19 +844,17 @@ static void TMCJPEGDEC_converterYUV444toRGB565(TMCCJPEGDecWork* work, s32 x, s32
|
||||
for (column = x; column < xEnd; column++) {
|
||||
cbValue = (s8)*cb++;
|
||||
crValue = (s8)*cr++;
|
||||
{
|
||||
s32 value = *luminance++;
|
||||
s32 green = value + (-(cbValue * 88 + crValue * 183) >> 8);
|
||||
s32 red = value + ((crValue * 359) >> 8);
|
||||
s32 blue = value + ((cbValue * 454) >> 8);
|
||||
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;
|
||||
}
|
||||
output[(column & 3) + (((column >> 2) + tileRow) << 4)] =
|
||||
((blue & 0xF8) >> 3) + (((red & 0xF8) << 8) + ((green & 0xFC) << 3));
|
||||
value = *luminance++;
|
||||
green = value + (-(cbValue * 88 + crValue * 183) >> 8);
|
||||
red = value + ((crValue * 359) >> 8);
|
||||
blue = value + ((cbValue * 454) >> 8);
|
||||
if ((blue | green | red) >> 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;
|
||||
}
|
||||
output[(column & 3) + (((column >> 2) + tileRow) << 4)] =
|
||||
((blue & 0xF8) >> 3) + ((red & 0xF8) << 8) + ((green & 0xFC) << 3);
|
||||
}
|
||||
luminance += rowSkip;
|
||||
cb += rowSkip;
|
||||
|
||||
@@ -179,7 +179,7 @@ static void TMCJPEGDEC_converterYUV411toRGBA8(TMCCJPEGDecWork* work, s32 x, s32
|
||||
s32 yEnd;
|
||||
s32 tileWidth;
|
||||
s32 blueOffset;
|
||||
s32 greenOffset;
|
||||
u16* output;
|
||||
s32 tileRow;
|
||||
s32 lumaSkip;
|
||||
s8 crValue;
|
||||
@@ -188,7 +188,7 @@ static void TMCJPEGDEC_converterYUV411toRGBA8(TMCCJPEGDecWork* work, s32 x, s32
|
||||
s32 cbValue;
|
||||
u8 value;
|
||||
s32 row;
|
||||
u16* output;
|
||||
s32 greenOffset;
|
||||
s32 redOffset;
|
||||
s32 blue;
|
||||
|
||||
@@ -285,9 +285,9 @@ static void TMCJPEGDEC_converterYUV411toRGBA8(TMCCJPEGDecWork* work, s32 x, s32
|
||||
}
|
||||
|
||||
static void TMCJPEGDEC_converterYUV411toRGBA8edge(TMCCJPEGDecWork* work, s32 x, s32 y) {
|
||||
u16* output;
|
||||
s32 chromaSkip;
|
||||
s32 tileRow;
|
||||
s32 lumaSkip;
|
||||
s32 xEnd;
|
||||
u8* texture;
|
||||
TMCCJPEGDecState* state;
|
||||
u8* luminance;
|
||||
@@ -296,15 +296,15 @@ static void TMCJPEGDEC_converterYUV411toRGBA8edge(TMCCJPEGDecWork* work, s32 x,
|
||||
s32 height;
|
||||
u8* cr;
|
||||
s32 column;
|
||||
s32 xEnd;
|
||||
s32 lumaSkip;
|
||||
s32 yEnd;
|
||||
s32 tileWidth;
|
||||
s32 redOffset;
|
||||
u16* output;
|
||||
s32 cbValue;
|
||||
s8 crValue;
|
||||
s32 redOffset;
|
||||
s32 greenOffset;
|
||||
s32 blueOffset;
|
||||
s32 chromaSkip;
|
||||
s32 blue;
|
||||
s32 red;
|
||||
s32 green;
|
||||
@@ -366,11 +366,11 @@ static void TMCJPEGDEC_converterYUV411toRGBA8edge(TMCCJPEGDecWork* work, s32 x,
|
||||
|
||||
static void TMCJPEGDEC_converterYUV422toRGBA8(TMCCJPEGDecWork* work, s32 x, s32 y) {
|
||||
s32 chromaSkip;
|
||||
u16* output;
|
||||
s32 cbValue;
|
||||
s32 tileRow;
|
||||
TMCCJPEGDecState* state;
|
||||
s32 lumaSkip;
|
||||
s32 cbValue;
|
||||
s32 tileWidth;
|
||||
TMCCJPEGDecState* state;
|
||||
u16* output;
|
||||
u8* texture;
|
||||
s32 width;
|
||||
s32 height;
|
||||
@@ -381,8 +381,8 @@ static void TMCJPEGDEC_converterYUV422toRGBA8(TMCCJPEGDecWork* work, s32 x, s32
|
||||
s32 column;
|
||||
s32 xEnd;
|
||||
s32 yEnd;
|
||||
s32 tileWidth;
|
||||
s32 redOffset;
|
||||
s32 tileRow;
|
||||
s32 greenOffset;
|
||||
s32 blueOffset;
|
||||
s32 value;
|
||||
@@ -441,21 +441,21 @@ static void TMCJPEGDEC_converterYUV422toRGBA8(TMCCJPEGDecWork* work, s32 x, s32
|
||||
}
|
||||
|
||||
static void TMCJPEGDEC_converterYUV422toRGBA8edge(TMCCJPEGDecWork* work, s32 x, s32 y) {
|
||||
s32 chromaSkip;
|
||||
s32 blue;
|
||||
u16* output;
|
||||
s32 tileRow;
|
||||
s32 lumaSkip;
|
||||
s32 xEnd;
|
||||
u8* cr;
|
||||
TMCCJPEGDecState* state;
|
||||
u8* texture;
|
||||
s32 tileWidth;
|
||||
u8* luminance;
|
||||
s32 width;
|
||||
s32 height;
|
||||
u8* cb;
|
||||
u8* cr;
|
||||
u8* texture;
|
||||
s32 column;
|
||||
s32 xEnd;
|
||||
s32 chromaSkip;
|
||||
s32 yEnd;
|
||||
s32 tileWidth;
|
||||
s32 tileRow;
|
||||
s32 cbValue;
|
||||
s32 crValue;
|
||||
s32 redOffset;
|
||||
@@ -463,8 +463,8 @@ static void TMCJPEGDEC_converterYUV422toRGBA8edge(TMCCJPEGDecWork* work, s32 x,
|
||||
s32 blueOffset;
|
||||
s32 value;
|
||||
s32 red;
|
||||
s32 lumaSkip;
|
||||
s32 green;
|
||||
s32 blue;
|
||||
|
||||
luminance = work->convBuf + 4;
|
||||
cb = &work->convBuf[132];
|
||||
@@ -517,27 +517,27 @@ static void TMCJPEGDEC_converterYUV422toRGBA8edge(TMCCJPEGDecWork* work, s32 x,
|
||||
}
|
||||
|
||||
static void TMCJPEGDEC_converterYUV420toRGBA8(TMCCJPEGDecWork* work, s32 x, s32 y) {
|
||||
s32 chromaSkip;
|
||||
s8 crValue;
|
||||
s32 lumaSkip;
|
||||
u16* output;
|
||||
TMCCJPEGDecState* state;
|
||||
s32 tileRow;
|
||||
s8 crValue;
|
||||
s32 chromaSkip;
|
||||
u8* luminance;
|
||||
TMCCJPEGDecState* state;
|
||||
u8* texture;
|
||||
s32 width;
|
||||
s32 height;
|
||||
s32 green;
|
||||
s32 blue;
|
||||
u8* luminance;
|
||||
u8* cb;
|
||||
u8* cr;
|
||||
s32 lumaSkip;
|
||||
s32 yEnd;
|
||||
s32 xEnd;
|
||||
s32 value;
|
||||
s32 column;
|
||||
s32 xEnd;
|
||||
s32 yEnd;
|
||||
u8* cr;
|
||||
s32 greenOffset;
|
||||
s32 tileWidth;
|
||||
s32 redOffset;
|
||||
s32 greenOffset;
|
||||
u8* texture;
|
||||
u8* cb;
|
||||
u16* output;
|
||||
s32 blueOffset;
|
||||
s32 red;
|
||||
s32 cbValue;
|
||||
@@ -641,9 +641,7 @@ static void TMCJPEGDEC_converterYUV420toRGBA8edge(TMCCJPEGDecWork* work, s32 x,
|
||||
s32 xEnd = x + width;
|
||||
s32 lumaSkip = 16 - width;
|
||||
s32 chromaSkip = lumaSkip >> 1;
|
||||
s32 redOffset;
|
||||
s32 blueOffset;
|
||||
s32 greenOffset;
|
||||
s32 redOffset, greenOffset, blueOffset;
|
||||
ASSERTLINE((x & 1) == 0, __LINE__);
|
||||
for (; y < yEnd; y++) {
|
||||
u16* output = (u16*)(texture + ((y & 3) << 3));
|
||||
@@ -658,10 +656,10 @@ static void TMCJPEGDEC_converterYUV420toRGBA8edge(TMCCJPEGDecWork* work, s32 x,
|
||||
blueOffset = (cbValue * 454) >> 8;
|
||||
}
|
||||
{
|
||||
s32 red = *luminance++;
|
||||
s32 green = red + greenOffset;
|
||||
s32 blue = red + blueOffset;
|
||||
red = red + redOffset;
|
||||
s32 value = *luminance++;
|
||||
s32 green = value + greenOffset;
|
||||
s32 red = value + redOffset;
|
||||
s32 blue = value + blueOffset;
|
||||
if ((green | red | blue) >> 8) {
|
||||
blue = blue > 255 ? 255 : blue < 0 ? 0 : blue;
|
||||
green = green > 255 ? 255 : green < 0 ? 0 : green;
|
||||
@@ -770,7 +768,7 @@ static void TMCJPEGDEC_converterYUV211toRGBA8(TMCCJPEGDecWork* work, s32 x, s32
|
||||
|
||||
static void TMCJPEGDEC_converterYUV211toRGBA8edge(TMCCJPEGDecWork* work, s32 x, s32 y) {
|
||||
u16* output;
|
||||
s32 tileRow;
|
||||
s32 lumaSkip;
|
||||
s32 blue;
|
||||
u8* texture;
|
||||
u8* luminance;
|
||||
@@ -785,14 +783,14 @@ static void TMCJPEGDEC_converterYUV211toRGBA8edge(TMCCJPEGDecWork* work, s32 x,
|
||||
s32 greenOffset;
|
||||
s32 yEnd;
|
||||
s32 cbValue;
|
||||
s32 tileWidth;
|
||||
s32 tileRow;
|
||||
s32 blueOffset;
|
||||
s32 red;
|
||||
s8 crValue;
|
||||
u8 value;
|
||||
s32 green;
|
||||
s32 redOffset;
|
||||
s32 lumaSkip;
|
||||
s32 tileWidth;
|
||||
|
||||
luminance = work->convBuf + 4;
|
||||
cb = work->convBuf + 132;
|
||||
|
||||
@@ -1,20 +1,5 @@
|
||||
#include <zi8clib/zitypes.h>
|
||||
|
||||
typedef struct {
|
||||
ziU8 countOnly;
|
||||
ziU8 maxWordLength;
|
||||
ziU8 lookupMode;
|
||||
ziU8 suffixOnly;
|
||||
ziU8 controls[8];
|
||||
ziU32 maxCount;
|
||||
ziU16 capacity;
|
||||
ziU8 minWordLength;
|
||||
ziU8 flags;
|
||||
ziU16 candidateCapacity;
|
||||
ziU8 checkOnly;
|
||||
ziU8 reserved;
|
||||
} ZiCandidateOptions;
|
||||
|
||||
const ziWChar Zi8PunctTable[40] = {
|
||||
0xFF0C, 0x3002, 0x3001, 0xFF1A, 0xFF1F, 0xFF01, 0x3005, 0x2026,
|
||||
0x2015, 0xFF1B, 0xFF0E, 0x30FB, 0x201C, 0x201D, 0xFF08, 0xFF09,
|
||||
@@ -23,8 +8,8 @@ const ziWChar Zi8PunctTable[40] = {
|
||||
0xFFE1, 0x20AC, 0x203B, 0xFF20, 0x0000,
|
||||
};
|
||||
|
||||
ziU32 Zi8Punctuation(ziGetParam* param, ziPtr options ZI_NEED_WORK) {
|
||||
ziS32 limit = ((ZiCandidateOptions*)options)->capacity - 1;
|
||||
ziS32 Zi8Punctuation(ziGetParam* param ZI_NEED_WORK) {
|
||||
ziS32 limit = ((ziU16*)__zi8_work_data)[8] - 1;
|
||||
ziS32 count = 0;
|
||||
ziU8 i = 0;
|
||||
ziU16 fc = param->firstCandidate;
|
||||
@@ -36,7 +21,7 @@ ziU32 Zi8Punctuation(ziGetParam* param, ziPtr options ZI_NEED_WORK) {
|
||||
}
|
||||
if (fc == 0) {
|
||||
count++;
|
||||
if (((ZiCandidateOptions*)options)->countOnly == 0) {
|
||||
if (ZI_WORK->getcPhase == 0) {
|
||||
param->candidates[i++] = Zi8PunctTable[j];
|
||||
if ((param->context & 0x10) != 0) {
|
||||
param->candidates[i++] = 0x20;
|
||||
@@ -48,7 +33,7 @@ ziU32 Zi8Punctuation(ziGetParam* param, ziPtr options ZI_NEED_WORK) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (count >= (ziS32)((ZiCandidateOptions*)options)->maxCount) {
|
||||
if (count >= (ziS32)ZI_WORK->targetCount) {
|
||||
return count;
|
||||
}
|
||||
}
|
||||
@@ -57,7 +42,7 @@ ziU32 Zi8Punctuation(ziGetParam* param, ziPtr options ZI_NEED_WORK) {
|
||||
}
|
||||
j++;
|
||||
}
|
||||
if (((ZiCandidateOptions*)options)->countOnly == 0) {
|
||||
if (ZI_WORK->getcPhase == 0) {
|
||||
param->letters = count;
|
||||
}
|
||||
return count;
|
||||
|
||||
@@ -1,8 +1,3 @@
|
||||
#include <zi8clib/zitypes.h>
|
||||
#undef ZI_NEED_WORK
|
||||
#define ZI_NEED_WORK , struct __zi8_work_data_s* __zi8_work_data
|
||||
#undef ZI_WORK
|
||||
#define ZI_WORK __zi8_work_data
|
||||
#include <zi8clib/zconvert.h>
|
||||
#include <zi8clib/zierror.h>
|
||||
|
||||
@@ -28,7 +23,7 @@ typedef struct ziConversionTable {
|
||||
} ziConversionTable;
|
||||
const ziConversionTables Zi8CvrtTables = {0};
|
||||
ziU16 Zi8GetTableCount(ziU8, ziU8 ZI_NEED_WORK);
|
||||
ziU32 Zi8GetTableAddress(ziU8, ziU8 ZI_NEED_WORK);
|
||||
ziPtr Zi8GetTableAddress(ziU8, ziU8 ZI_NEED_WORK);
|
||||
ziWChar Zi8ConvertUC2UserKey(ziChar, ziU8 ZI_NEED_WORK);
|
||||
|
||||
ziWChar Zi8ConvertUC2WC(ziChar character, ziU8 language ZI_NEED_WORK) {
|
||||
@@ -42,7 +37,7 @@ ziWChar Zi8ConvertUC2WC(ziChar character, ziU8 language ZI_NEED_WORK) {
|
||||
return 0;
|
||||
}
|
||||
if (Zi8GetTableCount(language, 6, __zi8_work_data) != 0) {
|
||||
table = (ziU8*)Zi8GetTableAddress(language, 6, __zi8_work_data);
|
||||
table = Zi8GetTableAddress(language, 6, __zi8_work_data);
|
||||
if (table == 0) {
|
||||
Zi8LogError(0x6A4, __zi8_work_data);
|
||||
return 0;
|
||||
@@ -82,7 +77,7 @@ ziChar Zi8ConvertWC2UC(ziWChar character, ziU8 language ZI_NEED_WORK) {
|
||||
return 0;
|
||||
}
|
||||
if (Zi8GetTableCount(language, 7, __zi8_work_data) != 0) {
|
||||
table = (ziConversionTable*)Zi8GetTableAddress(language, 7, __zi8_work_data);
|
||||
table = Zi8GetTableAddress(language, 7, __zi8_work_data);
|
||||
if (table == 0) {
|
||||
Zi8LogError(0x6AE, __zi8_work_data);
|
||||
return 0;
|
||||
@@ -142,7 +137,7 @@ ziWChar Zi8ConvertUC2Key(ziChar character, ziU8 language ZI_NEED_WORK) {
|
||||
if (ZI_WORK->userKeys[language] != 0)
|
||||
return Zi8ConvertUC2UserKey(character, language, __zi8_work_data);
|
||||
if (Zi8GetTableCount(language, 8, __zi8_work_data) != 0) {
|
||||
table = (ziConversionTable*)Zi8GetTableAddress(language, 8, __zi8_work_data);
|
||||
table = Zi8GetTableAddress(language, 8, __zi8_work_data);
|
||||
if (table == 0) {
|
||||
Zi8LogError(0x6B8, __zi8_work_data);
|
||||
return 0;
|
||||
|
||||
@@ -15,6 +15,28 @@ typedef struct {
|
||||
|
||||
typedef struct { ziU8 keyLow; ziU8 keyHigh; ziU8 code; ziU8 flags; } Zi8AltSoundRecord;
|
||||
|
||||
|
||||
|
||||
typedef struct {
|
||||
ziU8 language;
|
||||
ziU8 getMode;
|
||||
ziU8 subLanguage;
|
||||
ziU8 context;
|
||||
ziU8 getOptions;
|
||||
ziWChar* elements;
|
||||
ziU8 elementCount;
|
||||
ziWChar* currentWord;
|
||||
ziU8 wordCharCount;
|
||||
ziWChar* candidates;
|
||||
ziU8 maxCandidates;
|
||||
ziU16 firstCandidate;
|
||||
ziU8 wordCandidates;
|
||||
ziU8 count;
|
||||
ziU8 letters;
|
||||
ziU8* scratch;
|
||||
ziPtr workspace;
|
||||
} Zi8OneKeyParam;
|
||||
|
||||
typedef struct {
|
||||
ziU8 countOnly;
|
||||
ziU8 maxSpellingLength;
|
||||
@@ -181,15 +203,15 @@ const ziWChar zi8PYfinalSpelling[64][4] = {
|
||||
|
||||
const unsigned long long Zi8SOpinyinArray = 0x0303010705000000ULL;
|
||||
|
||||
extern ziU16 Zi8Ord2Ord(ziU16, ziPtr);
|
||||
extern Zi8UInt Zi8Ord2Ord(ziU16, ziPtr);
|
||||
extern ziU8 Zi8LangSupported(ziU8, ziPtr);
|
||||
extern ziU16 Zi8GetTableCount(ziU8,ziU8,ziPtr);
|
||||
extern ziU32 Zi8GetTableAddress(ziU8,ziU8,ziPtr);
|
||||
extern void Zi8Memset(ziU8*,ziU32,ziS32);
|
||||
extern ziU8 _Zi8GetCandidates(ziGetParam*,ziPtr);
|
||||
extern void Zi8InitDupWordBuf(ziPtr);
|
||||
extern ziU32 Zi8GetPInfo(ziU32,ziWChar *,ziU8,ziPtr);
|
||||
extern ziU32 Zi8GetZInfo(ziU32,ziWChar *,ziU8,ziPtr);
|
||||
extern Zi8UInt Zi8GetTableAddress(ziU8,ziU8,ziPtr);
|
||||
extern void Zi8Memset();
|
||||
extern int _Zi8GetCandidates();
|
||||
extern void Zi8InitDupWordBuf();
|
||||
extern ziU16 Zi8GetPInfo(ziU16,ziWChar *,ziU8,ziPtr);
|
||||
extern ziU16 Zi8GetZInfo(ziU16,ziWChar *,ziU8,ziPtr);
|
||||
extern ziBool Zi8IsDupWordW(ziWChar *,ziU8,ziPtr);
|
||||
extern ziU8 Zi8GetFormatVersion(ziU8,ziPtr);
|
||||
extern ziU16 Zi8Uni2Ord(ziWChar,ziPtr);
|
||||
@@ -197,10 +219,10 @@ extern ziU16 Zi8GetPCode(ziU8 *,ziU8 *);
|
||||
extern ziU8 Zi8MatchOEMdata(ziWChar *,ziU8,ziU8,ziWChar *,ziU16,ziU8,ziU8,ziPtr);
|
||||
extern ziU8 Zi8MatchPUDdata(ziWChar *,ziU8,ziU8,ziWChar *,ziU16,ziU8,ziU8,ziPtr);
|
||||
extern ziWChar Zi8Ord2Uni(ziU16,ziPtr);
|
||||
extern ziU32 Zi8GetZHuwdPtr(ziU32*,ziU16*,ziPtr);
|
||||
extern ziU8 Zi8GetPyPhonetic(ziWChar*,ziU8,ziU16*,ziU16*,ziU8*,ziU16*,ziU16*,ziPtr);
|
||||
extern ziU8 Zi8GetBpmfPhonetic(ziWChar*,ziU8,ziU16*,ziU16*,ziU16*,ziU16*,ziPtr);
|
||||
extern ziU8 _Zi8CheckCandidates(ziGetParam*,ziPtr);
|
||||
extern Zi8UInt Zi8GetZHuwdPtr(ziU8 **,ziU16 *,ziPtr);
|
||||
extern int Zi8GetPyPhonetic();
|
||||
extern ziU8 Zi8GetBpmfPhonetic();
|
||||
extern int _Zi8CheckCandidates();
|
||||
|
||||
Zi8UInt Zi8SpellingZY(ziU16 *output,Zi8UInt key,ziU8 includeTone)
|
||||
{
|
||||
@@ -289,21 +311,21 @@ Zi8UInt Zi8SpellingPY(ziU16 *output,Zi8UInt key,ziU8 includeTone)
|
||||
return length;
|
||||
}
|
||||
|
||||
ziU8 Zi8IsMatch1Key(ziU16 *input,Zi8UInt inputLength,ziU16 key,ziU8 requireFull,ziU8 usePinyin,ziU8 tone)
|
||||
ziU8 Zi8IsMatch1Key(ziU16 *input,Zi8UInt inputLength,Zi8UInt key,ziU8 requireFull,ziU8 usePinyin,ziU8 tone)
|
||||
{
|
||||
ziU16 spelling[16];
|
||||
Zi8UInt spellingLength;
|
||||
|
||||
if (key == 0) {
|
||||
if ((key & 0xffff) == 0) {
|
||||
return 0;
|
||||
}
|
||||
if ((inputLength & 0xff) == 0) {
|
||||
return 1;
|
||||
}
|
||||
if (usePinyin != 0) {
|
||||
spellingLength = Zi8SpellingPY(spelling,key,tone & 0xff);
|
||||
spellingLength = Zi8SpellingPY(spelling,key & 0xffff,tone & 0xff);
|
||||
} else {
|
||||
spellingLength = Zi8SpellingZY(spelling,key,tone & 0xff);
|
||||
spellingLength = Zi8SpellingZY(spelling,key & 0xffff,tone & 0xff);
|
||||
}
|
||||
if ((requireFull != 0) && ((inputLength & 0xff) != (spellingLength & 0xff))) {
|
||||
return 0;
|
||||
@@ -440,15 +462,15 @@ BACKWARD_SEARCH:
|
||||
goto BINARY_SEARCH;
|
||||
}
|
||||
}
|
||||
static Zi8UInt Zi8SetFindCand(ziU8 *foundCandidates,ziU16 ordinal,ziPtr work)
|
||||
static Zi8UInt Zi8SetFindCand(ziU8 *foundCandidates,Zi8UInt ordinal,ziPtr work)
|
||||
{
|
||||
Zi8UInt result;
|
||||
|
||||
ordinal = Zi8Ord2Ord(ordinal,work);
|
||||
result = (ziU8)((1 << ((int)ordinal % 8)) &
|
||||
foundCandidates[(int)ordinal / 8]);
|
||||
foundCandidates[(int)ordinal / 8] |=
|
||||
1 << ((int)ordinal % 8);
|
||||
result = (ziU8)((1 << ((int)(ordinal & 0xffff) % 8)) &
|
||||
foundCandidates[(int)(ordinal & 0xffff) / 8]);
|
||||
foundCandidates[(int)(ordinal & 0xffff) / 8] |=
|
||||
1 << ((int)(ordinal & 0xffff) % 8);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -484,7 +506,7 @@ LAB_return_false:
|
||||
return 0;
|
||||
}
|
||||
|
||||
ziU32 Zi8Get1KeyPressSpelling(ziGetParam *params,Zi8OneKeyOptions *options,Zi8OneKeyWork *work)
|
||||
Zi8UInt Zi8Get1KeyPressSpelling(Zi8OneKeyParam *params,Zi8OneKeyOptions *options,Zi8OneKeyWork *work)
|
||||
{
|
||||
ziU8 candidateCount;
|
||||
ziBool exactLength;
|
||||
@@ -509,18 +531,18 @@ ziU32 Zi8Get1KeyPressSpelling(ziGetParam *params,Zi8OneKeyOptions *options,Zi8On
|
||||
ziU16 *output;
|
||||
ziU8 *savedSearchOrder;
|
||||
ziU16 spellingBuffer[8];
|
||||
ziGetParam searchParams;
|
||||
Zi8OneKeyParam searchParams;
|
||||
|
||||
candidateCount = 0;
|
||||
totalCandidates = 0;
|
||||
optionsMask = params->getOptions;
|
||||
params->count = 0;
|
||||
params->letters = 0;
|
||||
params->completion = 0;
|
||||
optionsMask = optionsMask & ~0x10;
|
||||
optionsMask = optionsMask & ~0x20;
|
||||
optionsMask = optionsMask & ~0x40;
|
||||
if (options->maxSpellingLength == '\0') {
|
||||
params->letters = 0;
|
||||
params->count = 0;
|
||||
Zi8LogError(100,work);
|
||||
return 0;
|
||||
}
|
||||
@@ -798,7 +820,7 @@ ziU32 Zi8Get1KeyPressSpelling(ziGetParam *params,Zi8OneKeyOptions *options,Zi8On
|
||||
savedSearchCount = work->searchOrderCount;
|
||||
convertedInput = false;
|
||||
savedSearchFlags = work->searchFlags;
|
||||
Zi8Memset((ziU8*)&searchParams,0,0x2c);
|
||||
Zi8Memset(&searchParams,0,0x2c);
|
||||
searchParams.getMode = 0;
|
||||
searchParams.subLanguage = 0x80;
|
||||
searchParams.context = 1;
|
||||
@@ -896,7 +918,7 @@ ziU32 Zi8Get1KeyPressSpelling(ziGetParam *params,Zi8OneKeyOptions *options,Zi8On
|
||||
work->searchFlags = savedSearchFlags;
|
||||
work->searchOrder = savedSearchOrder;
|
||||
work->searchOrderCount = savedSearchCount;
|
||||
params->letters = searchParams.letters;
|
||||
params->count = searchParams.count;
|
||||
work->spellingOnly = 0;
|
||||
if (convertedInput) {
|
||||
if (params->getMode == '\x03') {
|
||||
@@ -915,7 +937,7 @@ ziU32 Zi8Get1KeyPressSpelling(ziGetParam *params,Zi8OneKeyOptions *options,Zi8On
|
||||
}
|
||||
}
|
||||
if ((options->countOnly == '\0') && (params->getMode == '\x03')) {
|
||||
for (tableIndex = 0; tableIndex < params->letters;) {
|
||||
for (tableIndex = 0; tableIndex < params->count;) {
|
||||
while (*output != 0) {
|
||||
if (*output != 0x27) {
|
||||
*output++ |= 0xf300;
|
||||
@@ -1000,12 +1022,12 @@ nextSpelling:
|
||||
}
|
||||
}
|
||||
finishSpelling:
|
||||
params->letters = candidateCount;
|
||||
params->count = candidateCount;
|
||||
Zi8LogError(100,work);
|
||||
return totalCandidates;
|
||||
}
|
||||
|
||||
ziU32 Zi8Get1KeyPressCandidates(ziGetParam *params,Zi8OneKeyOptions *options,Zi8OneKeyWork *work)
|
||||
int Zi8Get1KeyPressCandidates(Zi8OneKeyParam *params,Zi8OneKeyOptions *options,Zi8OneKeyWork *work)
|
||||
{
|
||||
ziU16 wordBuffer [64];
|
||||
ziU16 spelling [8];
|
||||
@@ -1024,7 +1046,7 @@ ziU32 Zi8Get1KeyPressCandidates(ziGetParam *params,Zi8OneKeyOptions *options,Zi8
|
||||
ziU8 *phraseEntries;
|
||||
ziU16 *currentWord;
|
||||
ziU8 *entryCursor;
|
||||
ziU32 userEntriesAddress;
|
||||
ziU8 *userEntries;
|
||||
int duplicateIndex;
|
||||
ziU16 alternateCount;
|
||||
ziU16 ordinalCount;
|
||||
@@ -1126,8 +1148,8 @@ ziU32 Zi8Get1KeyPressCandidates(ziGetParam *params,Zi8OneKeyOptions *options,Zi8
|
||||
}
|
||||
languageMask = languageMask << 4;
|
||||
remaining = params->firstCandidate;
|
||||
params->count = 0;
|
||||
params->letters = 0;
|
||||
params->completion = 0;
|
||||
inputLength = params->elementCount;
|
||||
if (inputLength != 0) {
|
||||
while (inputLength != 0) {
|
||||
@@ -1249,7 +1271,7 @@ ziU32 Zi8Get1KeyPressCandidates(ziGetParam *params,Zi8OneKeyOptions *options,Zi8
|
||||
tableCursor = Zi8GetTableCount(1,9,work);
|
||||
}
|
||||
if (8 < inputLimit) {
|
||||
params->count = 0;
|
||||
params->wordCandidates = 0;
|
||||
goto finishCandidates;
|
||||
}
|
||||
for (index = 0; index < (int)(Zi8UInt)inputLimit; index++) {
|
||||
@@ -1305,7 +1327,7 @@ ziU32 Zi8Get1KeyPressCandidates(ziGetParam *params,Zi8OneKeyOptions *options,Zi8
|
||||
}
|
||||
if (elementIndex == 0) continue;
|
||||
if (!emitWords) {
|
||||
if (trackDuplicates && (ziU8)Zi8SetFindCand(params->scratch,candidateOrdinal,work) != 0) continue;
|
||||
if (trackDuplicates && Zi8SetFindCand(params->scratch,candidateOrdinal,work) != 0) continue;
|
||||
for (index = 0; index < candidateCount; index++) {
|
||||
if (candidateCharacter == output[index]) break;
|
||||
}
|
||||
@@ -1335,7 +1357,7 @@ ziU32 Zi8Get1KeyPressCandidates(ziGetParam *params,Zi8OneKeyOptions *options,Zi8
|
||||
output[outputIndex++] = candidateCharacter;
|
||||
}
|
||||
if (candidateCount >= params->maxCandidates || outputIndex > outputLimit) {
|
||||
params->count = candidateCount;
|
||||
params->wordCandidates = candidateCount;
|
||||
goto finishCandidates;
|
||||
}
|
||||
} else {
|
||||
@@ -1374,7 +1396,7 @@ ziU32 Zi8Get1KeyPressCandidates(ziGetParam *params,Zi8OneKeyOptions *options,Zi8
|
||||
}
|
||||
if (elementIndex == 0) continue;
|
||||
if (!emitWords) {
|
||||
if (trackDuplicates && (ziU8)Zi8SetFindCand(params->scratch,candidateOrdinal,work) != 0) continue;
|
||||
if (trackDuplicates && Zi8SetFindCand(params->scratch,candidateOrdinal,work) != 0) continue;
|
||||
for (index = 0; index < candidateCount; index++) {
|
||||
if (candidateCharacter == output[index]) break;
|
||||
}
|
||||
@@ -1404,7 +1426,7 @@ ziU32 Zi8Get1KeyPressCandidates(ziGetParam *params,Zi8OneKeyOptions *options,Zi8
|
||||
output[outputIndex++] = candidateCharacter;
|
||||
}
|
||||
if (candidateCount >= params->maxCandidates || outputIndex > outputLimit) {
|
||||
params->count = candidateCount;
|
||||
params->wordCandidates = candidateCount;
|
||||
goto finishCandidates;
|
||||
}
|
||||
} else {
|
||||
@@ -1497,7 +1519,7 @@ ziU32 Zi8Get1KeyPressCandidates(ziGetParam *params,Zi8OneKeyOptions *options,Zi8
|
||||
}
|
||||
if (elementIndex == 0) goto nextPhrase;
|
||||
if (!emitWords) {
|
||||
if (trackDuplicates && (ziU8)Zi8SetFindCand(params->scratch,phraseCharacter,work) != 0) goto nextPhrase;
|
||||
if (trackDuplicates && Zi8SetFindCand(params->scratch,phraseCharacter,work) != 0) goto nextPhrase;
|
||||
for (index = 0; index < candidateCount; index++) {
|
||||
if (firstOrdinal == output[index]) goto nextPhrase;
|
||||
}
|
||||
@@ -1525,7 +1547,7 @@ ziU32 Zi8Get1KeyPressCandidates(ziGetParam *params,Zi8OneKeyOptions *options,Zi8
|
||||
output[outputIndex++] = firstOrdinal;
|
||||
}
|
||||
if (candidateCount >= params->maxCandidates || outputIndex > outputLimit) {
|
||||
params->count = candidateCount;
|
||||
params->wordCandidates = candidateCount;
|
||||
goto finishCandidates;
|
||||
}
|
||||
} else {
|
||||
@@ -1546,7 +1568,7 @@ nextPhrase:
|
||||
else {
|
||||
finishPhrases:
|
||||
if (params->wordCharCount != '\0') {
|
||||
params->count = candidateCount;
|
||||
params->wordCandidates = candidateCount;
|
||||
}
|
||||
}
|
||||
if ((options->countOnly == '\0') && (tableCursor != 0)) {
|
||||
@@ -1579,7 +1601,7 @@ finishPhrases:
|
||||
}
|
||||
if (elementIndex == 0) goto nextSortedOrdinal;
|
||||
if (!emitWords) {
|
||||
if (trackDuplicates && (ziU8)Zi8SetFindCand(params->scratch,ordinal,work) != 0) goto nextSortedOrdinal;
|
||||
if (trackDuplicates && Zi8SetFindCand(params->scratch,ordinal,work) != 0) goto nextSortedOrdinal;
|
||||
ordinal = Zi8Ord2Uni(ordinal,work);
|
||||
for (index = 0; index < candidateCount; index++) {
|
||||
if (ordinal == output[index]) break;
|
||||
@@ -1607,11 +1629,11 @@ nextSortedOrdinal:
|
||||
;
|
||||
}
|
||||
}
|
||||
if ((options->countOnly == '\0') && (ziU8)Zi8GetZHuwdPtr(&userEntriesAddress,&userCount,work) != 0)
|
||||
if ((options->countOnly == '\0') && Zi8GetZHuwdPtr(&userEntries,&userCount,work) != 0)
|
||||
{
|
||||
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];
|
||||
if ((params->elementCount == '\0') || ((userEntries[1] & 0x80) != 0)) {
|
||||
userOrdinal = (userEntries[1] & 0x7f) << 8 | (ziU16)userEntries[2];
|
||||
phraseTable = syllableTable + (Zi8UInt)userOrdinal * 0xc;
|
||||
if (((*phraseTable & languageMask) != 0) &&
|
||||
((characterSetTable == 0 || ((characterSet & characterSetTable[(Zi8UInt)userOrdinal]) != 0)))) {
|
||||
@@ -1632,7 +1654,7 @@ nextSortedOrdinal:
|
||||
}
|
||||
if (elementIndex == 0) goto nextUserOrdinal;
|
||||
if (!emitWords) {
|
||||
if (trackDuplicates && (ziU8)Zi8SetFindCand(params->scratch,userOrdinal,work) != 0) goto nextUserOrdinal;
|
||||
if (trackDuplicates && Zi8SetFindCand(params->scratch,userOrdinal,work) != 0) goto nextUserOrdinal;
|
||||
userCharacter = Zi8Ord2Uni(userOrdinal,work);
|
||||
for (duplicateIndex = 0; duplicateIndex < candidateCount; duplicateIndex++) {
|
||||
if (userCharacter == output[duplicateIndex]) break;
|
||||
@@ -1655,7 +1677,7 @@ nextSortedOrdinal:
|
||||
}
|
||||
nextUserOrdinal:
|
||||
phraseOrdinal++;
|
||||
userEntriesAddress = userEntriesAddress + 3;
|
||||
userEntries = userEntries + 3;
|
||||
}
|
||||
}
|
||||
phraseTable = syllableTable;
|
||||
@@ -1688,7 +1710,7 @@ nextUserOrdinal:
|
||||
if (unicodeCharacter == previousCharacter) goto nextOrdinal;
|
||||
previousCharacter = unicodeCharacter;
|
||||
if (!emitWords) {
|
||||
if (trackDuplicates && (ziU8)Zi8SetFindCand(params->scratch,ordinal,work) != 0) goto nextOrdinal;
|
||||
if (trackDuplicates && Zi8SetFindCand(params->scratch,ordinal,work) != 0) goto nextOrdinal;
|
||||
for (index = 0; index < candidateCount; index++) {
|
||||
if (unicodeCharacter == output[index]) break;
|
||||
}
|
||||
@@ -1716,14 +1738,15 @@ nextOrdinal:
|
||||
}
|
||||
finishCandidates:
|
||||
if ((emitWords) && (outputIndex != 0)) {
|
||||
output[outputIndex++] = 0;
|
||||
output[outputIndex] = 0;
|
||||
outputIndex++;
|
||||
}
|
||||
params->letters = candidateCount;
|
||||
params->count = candidateCount;
|
||||
Zi8LogError(100,work);
|
||||
return totalCandidates;
|
||||
}
|
||||
|
||||
ziBool Zi8ZHCheckSpelling(ziWChar *input,ziWChar *spelling,ziU8 inputLength,ziPtr work)
|
||||
Zi8UInt Zi8ZHCheckSpelling(ziU16 *input,ziU16 *spelling,Zi8UInt inputLength,char *work)
|
||||
{
|
||||
int index;
|
||||
ziU8 result;
|
||||
@@ -1738,11 +1761,11 @@ ziBool Zi8ZHCheckSpelling(ziWChar *input,ziWChar *spelling,ziU8 inputLength,ziPt
|
||||
int syllableStart;
|
||||
int syllableLength;
|
||||
Zi8UInt tableOffset;
|
||||
ziWChar candidateBuffer [16];
|
||||
ziU16 phoneticCodes [16];
|
||||
ziU16 phoneticMasks [16];
|
||||
ziU8 candidateBuffer [32];
|
||||
ziU8 phoneticCodes [32];
|
||||
ziU8 phoneticMasks [32];
|
||||
ziU16 convertedSpelling [64];
|
||||
ziGetParam getParam;
|
||||
Zi8OneKeyParam getParam;
|
||||
ziU8 maskLow;
|
||||
ziU8 codeLow;
|
||||
ziU8 maskHigh;
|
||||
@@ -1783,7 +1806,7 @@ ziBool Zi8ZHCheckSpelling(ziWChar *input,ziWChar *spelling,ziU8 inputLength,ziPt
|
||||
}
|
||||
index = 0;
|
||||
syllableStart = index;
|
||||
for (; index < (int)inputLength; index = index + 1) {
|
||||
for (; index < (int)(inputLength & 0xff); index = index + 1) {
|
||||
switch (spelling[index]) {
|
||||
case 0xf331:
|
||||
toneMask = 1;
|
||||
@@ -1854,7 +1877,7 @@ nextInputCharacter:
|
||||
}
|
||||
else {
|
||||
if ((input[index] == 0x27) || (input[index] == 0xf360)) {
|
||||
if (index < (int)inputLength) {
|
||||
if (index < (int)(inputLength & 0xff)) {
|
||||
convertedSpelling[index] = input[index] = spelling[index];
|
||||
}
|
||||
else {
|
||||
@@ -1896,7 +1919,7 @@ nextInputCharacter:
|
||||
getParam.elementCount = (ziU8)index;
|
||||
getParam.currentWord = 0;
|
||||
getParam.wordCharCount = 0;
|
||||
getParam.candidates = candidateBuffer;
|
||||
getParam.candidates = (ziWChar *)candidateBuffer;
|
||||
getParam.maxCandidates = 1;
|
||||
getParam.firstCandidate = 0;
|
||||
if ((ziU8)_Zi8CheckCandidates(&getParam,work) != 0) {
|
||||
|
||||
@@ -351,7 +351,6 @@ int Zi8AlphaGetCandidates(ziGetParam* parameters, ziPtr optionData, ziPtr workDa
|
||||
int candidateCount;
|
||||
ziU8 *keyLayout;
|
||||
ziU8 *keyLayoutCursor;
|
||||
ziPtr workspace;
|
||||
ziU16 prefixTableFlags;
|
||||
ziU16 prefixVowelFlags;
|
||||
ziU8 prefixMode;
|
||||
@@ -407,7 +406,6 @@ int Zi8AlphaGetCandidates(ziGetParam* parameters, ziPtr optionData, ziPtr workDa
|
||||
contextEnabled = 0;
|
||||
keyLayoutCount = 0;
|
||||
keyLayout = 0;
|
||||
workspace = workData;
|
||||
phoneticInput = 0;
|
||||
phoneticSeparator = 0;
|
||||
if ((((((language == 0x7c) || (language == 0x7d)) || (language == 0x7b)) ||
|
||||
@@ -922,8 +920,9 @@ selectDictionary:
|
||||
if ((((wordLength == 0) && (*punctuationCursor != 0)) && (dictionaryExact != 0)) &&
|
||||
((((ZiAlphaWork*)workData)->singleCharacter != 0 && (parameters->elementCount == 2)))) {
|
||||
*wordCursor = ((ZiAlphaWork*)workData)->singleCharacter;
|
||||
wordCursor[1] = *punctuationCursor;
|
||||
punctuationCursor = punctuationCursor + 1;
|
||||
wordCursor[2] = 0;
|
||||
wordCursor[1] = *punctuationCursor++;
|
||||
wordLength = 2;
|
||||
}
|
||||
if (((apostropheIndex != 0) && (wordLength != 0)) && (elementCount == parameters->elementCount)) {
|
||||
@@ -1006,7 +1005,7 @@ filterVowelCandidate:
|
||||
case 3:
|
||||
case 7:
|
||||
while( ZI8_TRUE ) {
|
||||
wordLength = Zi8MatchUWDdata(elements,elementCount,
|
||||
wordLength = Zi8MatchUWDdata(elements,elementCount & 0xff,
|
||||
parameters->currentWord,parameters->wordCharCount,
|
||||
language,wordCursor,wordCapacity & 0xffff,dictionaryExact,
|
||||
dictionaryStatus[dictionaryKind] & 0xff,workData);
|
||||
@@ -1017,8 +1016,8 @@ filterVowelCandidate:
|
||||
case 4:
|
||||
case 8:
|
||||
if (elementCount != 0) {
|
||||
wordLength = Zi8MatchOEMdata(elements,elementCount,language,wordCursor,
|
||||
wordCapacity,dictionaryExact,
|
||||
wordLength = Zi8MatchOEMdata(elements,elementCount & 0xff,language,wordCursor,
|
||||
wordCapacity & 0xffff,dictionaryExact,
|
||||
dictionaryStatus[dictionaryKind] & 0xff,workData);
|
||||
}
|
||||
break;
|
||||
@@ -1069,7 +1068,7 @@ filterVowelCandidate:
|
||||
(((ZiAlphaWork*)workData)->requiredLength != parameters->elementCount)) &&
|
||||
(((((ZiAlphaWork*)workData)->prefixLength == '\0' ||
|
||||
(((ZiAlphaWork*)workData)->prefixLength + 1 >= parameters->elementCount)) && (dictionaryExact != 0)))
|
||||
))) && ((((currentVowelRestriction && (prefixCount == 0)) && (dictionaryKind != 0xb)) &&
|
||||
))) && ((((completionAllowed && (prefixCount == 0)) && (dictionaryKind != 0xb)) &&
|
||||
((((int)dictionaryIndex < (int)(unsigned int)((ZiAlphaWork*)workData)->dictionaryCount &&
|
||||
(((ZiAlphaOptions*)optionData)->lookupMode == '\0')) &&
|
||||
(((ZiAlphaWork*)workData)->dictionaries[language] == 0)))))) {
|
||||
@@ -1085,7 +1084,7 @@ filterVowelCandidate:
|
||||
goto retryDictionary;
|
||||
}
|
||||
}
|
||||
if ((((((dictionaryExact == 0) || (!currentVowelRestriction)) || (prefixCount != 0)) ||
|
||||
if ((((((dictionaryExact == 0) || (!completionAllowed)) || (prefixCount != 0)) ||
|
||||
((dictionaryKind == 0xb ||
|
||||
(dictionaryIndex >= ((ZiAlphaWork*)workData)->dictionaryCount)))) ||
|
||||
(elements == 0)) ||
|
||||
@@ -1140,7 +1139,7 @@ prepareCandidate:
|
||||
Zi8ChangeWordCase(wordCursor - prefixCount,language,workData);
|
||||
}
|
||||
if ((((ZiAlphaOptions*)optionData)->suffixOnly != '\0') &&
|
||||
((wordLength + prefixCount) > ((ZiAlphaOptions*)optionData)->maxWordLength)) {
|
||||
((int)((ZiAlphaOptions*)optionData)->maxWordLength < (int)(wordLength + prefixCount))) {
|
||||
wordLength = ((ZiAlphaOptions*)optionData)->maxWordLength - prefixCount;
|
||||
wordCursor[wordLength] = 0;
|
||||
}
|
||||
@@ -1195,9 +1194,7 @@ checkKeyLayout:
|
||||
break;
|
||||
}
|
||||
emitCandidate:
|
||||
if (firstCandidate != 0) {
|
||||
--firstCandidate;
|
||||
} else {
|
||||
if (firstCandidate == 0) {
|
||||
if (((ZiAlphaOptions*)optionData)->countOnly != '\0') {
|
||||
if (((ZiAlphaOptions*)optionData)->suffixOnly != '\0') {
|
||||
if ((int)((ZiAlphaOptions*)optionData)->shortestWord > (int)(wordLength + prefixCount)) {
|
||||
@@ -1207,17 +1204,20 @@ emitCandidate:
|
||||
((ZiAlphaOptions*)optionData)->longestWord = wordLength + prefixCount;
|
||||
}
|
||||
}
|
||||
if (++candidateCount >= ((ZiAlphaOptions*)optionData)->maxResults) goto finishCandidates;
|
||||
candidateCount = candidateCount + 1;
|
||||
if (((ZiAlphaOptions*)optionData)->maxResults <= candidateCount) goto finishCandidates;
|
||||
} else {
|
||||
if (((ZiAlphaOptions*)optionData)->lookupMode != '\0') {
|
||||
for (index = 0; index <= wordLength; index++) {
|
||||
if (wordCursor[index] != ((ZiAlphaOptions*)optionData)->dictionary[index]) break;
|
||||
for (index = 0;
|
||||
(index <= (int)wordLength &&
|
||||
(wordCursor[index] == ((ZiAlphaOptions*)optionData)->dictionary[index]));
|
||||
index = index + 1) {
|
||||
}
|
||||
if ((((((ZiAlphaWork*)workData)->operation != '\0') || (index >= wordLength))
|
||||
if ((((((ZiAlphaWork*)workData)->operation != '\0') || ((int)wordLength <= index))
|
||||
&& ((((ZiAlphaWork*)workData)->operation == '\0' ||
|
||||
((exactLengthOnly == 0 ||
|
||||
(index >= (int)(ziU16)Zi8WCharCount(((ZiAlphaOptions*)optionData)->dictionary,workData))))))) &&
|
||||
((exactLengthOnly != 0 || (index >= wordLength)))) {
|
||||
((int)(ziU16)Zi8WCharCount(((ZiAlphaOptions*)optionData)->dictionary,workData) <= index)))))) &&
|
||||
((exactLengthOnly != 0 || ((int)wordLength <= index)))) {
|
||||
candidateCount = 1;
|
||||
goto finishCandidates;
|
||||
}
|
||||
@@ -1326,7 +1326,8 @@ emitCandidate:
|
||||
wordCursor = wordCursor + wordLength;
|
||||
wordCapacity = wordCapacity - wordLength;
|
||||
}
|
||||
if (++candidateCount >= (int)(unsigned int)parameters->maxCandidates) {
|
||||
candidateCount = candidateCount + 1;
|
||||
if ((int)(unsigned int)parameters->maxCandidates <= candidateCount) {
|
||||
prefixCount = 0;
|
||||
goto finishCandidates;
|
||||
}
|
||||
@@ -1358,12 +1359,15 @@ emitCandidate:
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
firstCandidate = firstCandidate - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
retryDictionary:;
|
||||
} while (dictionaryIndex != 0);
|
||||
} while (dictionaryKind != 0);
|
||||
}
|
||||
finishDictionaryPass:;
|
||||
}
|
||||
@@ -1372,23 +1376,27 @@ finishDictionaryPass:;
|
||||
(((parameters->elementCount == 1 &&
|
||||
(((Zi8GetTableCount(parameters->language,0x1f,workData)) & 0x40) == 0)) &&
|
||||
(*parameters->elements >= 0xeff1)))))) &&
|
||||
((*parameters->elements <= 0xf010 &&
|
||||
((*parameters->elements < 0xf011 &&
|
||||
((Zi8getKeyLayout(parameters->language,*parameters->elements,&punctuationBuffer[0],1,workData)) != '\0')))) {
|
||||
punctuationCandidate = ZI8_TRUE;
|
||||
}
|
||||
if (((candidateCount == 0) && (punctuationCandidate)) && (firstCandidate == 0)) {
|
||||
candidateCount = 1;
|
||||
if (((ZiAlphaOptions*)optionData)->countOnly != 0 || (parameters->getOptions & 0xFD) == 0x81) {
|
||||
if ((((ZiAlphaOptions*)optionData)->countOnly == '\0') && ((parameters->getOptions & 0xfd) != 0x81)) {
|
||||
*encodedOutput = 0x3e;
|
||||
encodedOutput[2] = 0;
|
||||
encodedOutput[1] = 0;
|
||||
}
|
||||
else {
|
||||
if (parameters->getMode == 1) {
|
||||
*wordCursor = *elements;
|
||||
} else {
|
||||
*wordCursor = 0x3E;
|
||||
}
|
||||
wordCursor[1] = wordCursor[2] = 0;
|
||||
wordCursor += 2;
|
||||
} else {
|
||||
*encodedOutput = 0x3E;
|
||||
encodedOutput[1] = encodedOutput[2] = 0;
|
||||
else {
|
||||
*wordCursor = 0x3e;
|
||||
}
|
||||
wordCursor[2] = 0;
|
||||
wordCursor[1] = 0;
|
||||
wordCursor = wordCursor + 2;
|
||||
}
|
||||
if (((ZiAlphaOptions*)optionData)->lookupMode == '\0') {
|
||||
((ZiAlphaWork*)workData)->singleCharacter = 0;
|
||||
@@ -1398,13 +1406,13 @@ finishDictionaryPass:;
|
||||
secondLanguagePass = ZI8_TRUE;
|
||||
languagePassCount = 0;
|
||||
language = parameters->subLanguage;
|
||||
completionAllowed = secondaryCompletionAllowed;
|
||||
currentVowelRestriction = secondaryVowelRestriction;
|
||||
dictionaryStatus[9] = 0;
|
||||
dictionaryStatus[5] = 0;
|
||||
dictionaryStatus[6] = 0;
|
||||
dictionaryStatus[7] = 0;
|
||||
dictionaryStatus[8] = 0;
|
||||
completionAllowed = secondaryCompletionAllowed;
|
||||
currentVowelRestriction = secondaryVowelRestriction;
|
||||
if (switchedLanguage) {
|
||||
secondLanguagePass = ZI8_FALSE;
|
||||
dictionaryStatus[1] = 0;
|
||||
@@ -1418,15 +1426,14 @@ finishDictionaryPass:;
|
||||
if (language == 0) {
|
||||
language = parameters->language;
|
||||
}
|
||||
completionAllowed = secondaryCompletionAllowed;
|
||||
currentVowelRestriction = secondaryVowelRestriction;
|
||||
if (language == parameters->language) {
|
||||
completionAllowed = primaryCompletionAllowed;
|
||||
currentVowelRestriction = primaryVowelRestriction;
|
||||
} else {
|
||||
completionAllowed = secondaryCompletionAllowed;
|
||||
currentVowelRestriction = secondaryVowelRestriction;
|
||||
}
|
||||
if ((((ZiAlphaOptions*)optionData)->lookupMode != '\0') || ((!completionAllowed && (!currentVowelRestriction)))) goto finishCandidates;
|
||||
if ((currentVowelRestriction) &&
|
||||
if ((((ZiAlphaOptions*)optionData)->lookupMode != '\0') || ((!currentVowelRestriction && (!completionAllowed)))) goto finishCandidates;
|
||||
if ((completionAllowed) &&
|
||||
((((((ZiAlphaWork*)workData)->suffixMode == '\0' && (2 < (int)elementCount)) &&
|
||||
(elements[elementCount - 2] == 0xeff1)) &&
|
||||
((int)((ZiAlphaWork*)workData)->prefixCount == elementCount - 2)))) {
|
||||
@@ -1437,65 +1444,66 @@ finishDictionaryPass:;
|
||||
prefixPrepared = ZI8_TRUE;
|
||||
goto preparePrefix;
|
||||
}
|
||||
if (currentVowelRestriction && ((ZiAlphaWork*)workData)->suffixMode != 0 &&
|
||||
((ZiAlphaWork*)workData)->suffixLocked == 0 && elementCount > 2 &&
|
||||
((elements[elementCount - 2] == 0xEFF1 &&
|
||||
((ZiAlphaWork*)workData)->suffixCount == elementCount - 2) ||
|
||||
(((ZiAlphaWork*)workData)->suffixCount == elementCount - 1 &&
|
||||
Zi8IsAlphaPunct(elements[elementCount - 1]) != 0))) {
|
||||
if (((ZiAlphaWork*)workData)->prefixEnabled >= 1 && elements[elementCount - 1] == 0xEFF1) {
|
||||
goto checkPrefixPunctuation;
|
||||
}
|
||||
if (!primaryMatched && !secondaryMatched) {
|
||||
((ZiAlphaWork*)workData)->suffixLocked = 1;
|
||||
((ZiAlphaWork*)workData)->suffixElementCount = parameters->elementCount - 1;
|
||||
if (prefixCount != 0) {
|
||||
if (!((((completionAllowed) && (((ZiAlphaWork*)workData)->suffixMode != '\0')) &&
|
||||
((((ZiAlphaWork*)workData)->suffixLocked == '\0' && (2 < (int)elementCount)))) &&
|
||||
(((elements[elementCount - 2] == 0xeff1 &&
|
||||
((int)((ZiAlphaWork*)workData)->suffixCount == elementCount - 2)) ||
|
||||
(((int)((ZiAlphaWork*)workData)->suffixCount == elementCount - 1 &&
|
||||
((Zi8IsAlphaPunct(elements[elementCount - 1])) != '\0'))))))) {
|
||||
tryAlternatePrefix:
|
||||
if ((prefixPrepared) && (1 < ((ZiAlphaWork*)workData)->alternatePrefixCount)) {
|
||||
if (language == parameters->language) {
|
||||
if (primaryMatched) {
|
||||
((ZiAlphaWork*)workData)->alternatePrefixCount = 0;
|
||||
}
|
||||
}
|
||||
else if (secondaryMatched) {
|
||||
((ZiAlphaWork*)workData)->alternatePrefixCount = 0;
|
||||
}
|
||||
if (((ZiAlphaWork*)workData)->alternatePrefixCount != '\0') {
|
||||
wordCursor -= prefixCount;
|
||||
elements -= prefixCount;
|
||||
elementCount = elementCount + prefixCount;
|
||||
wordCapacity = wordCapacity + prefixCount;
|
||||
prefixCount = 0;
|
||||
}
|
||||
goto preparePrefix;
|
||||
}
|
||||
}
|
||||
if ((prefixPrepared) && (1 < ((ZiAlphaWork*)workData)->alternatePrefixCount)) {
|
||||
if (language == parameters->language) {
|
||||
if (primaryMatched) {
|
||||
prefixPrepared = ZI8_FALSE;
|
||||
((ZiAlphaWork*)workData)->suffixMode = 0;
|
||||
((ZiAlphaWork*)workData)->suffixLocked = 0;
|
||||
((ZiAlphaWork*)workData)->suffixCount = 0;
|
||||
for (index = 0; index < (int)(unsigned int)((ZiAlphaWork*)workData)->alternatePrefixCount; index = index + 1) {
|
||||
((ZiAlphaWork*)workData)->prefix[index] =
|
||||
((ZiAlphaWork*)workData)->alternatePrefix[index];
|
||||
}
|
||||
((ZiAlphaWork*)workData)->prefixCount = (ziU8)index;
|
||||
if (((ZiAlphaWork*)workData)->language == parameters->language) {
|
||||
((ZiAlphaWork*)workData)->language = parameters->subLanguage;
|
||||
}
|
||||
else {
|
||||
((ZiAlphaWork*)workData)->language = parameters->language;
|
||||
}
|
||||
((ZiAlphaWork*)workData)->alternatePrefixCount = 0;
|
||||
}
|
||||
}
|
||||
else if (secondaryMatched) {
|
||||
((ZiAlphaWork*)workData)->alternatePrefixCount = 0;
|
||||
if ((((primaryMatched) && (secondaryMatched)) || (elementCount == 0)) ||
|
||||
(((language == parameters->language && (primaryMatched)) || ((language == parameters->subLanguage && (secondaryMatched))))))
|
||||
goto finishCandidates;
|
||||
if (completionAllowed) goto checkPrefixPunctuation;
|
||||
} else {
|
||||
if ((((ZiAlphaWork*)workData)->prefixEnabled == '\0') || (elements[elementCount - 1] != 0xeff1)) {
|
||||
if ((!primaryMatched) && (!secondaryMatched)) {
|
||||
((ZiAlphaWork*)workData)->suffixLocked = 1;
|
||||
((ZiAlphaWork*)workData)->suffixElementCount = parameters->elementCount - 1;
|
||||
if (prefixCount != 0) {
|
||||
wordCursor -= prefixCount;
|
||||
elements -= prefixCount;
|
||||
elementCount = elementCount + prefixCount;
|
||||
wordCapacity = wordCapacity + prefixCount;
|
||||
prefixCount = 0;
|
||||
}
|
||||
goto preparePrefix;
|
||||
}
|
||||
goto tryAlternatePrefix;
|
||||
}
|
||||
if (((ZiAlphaWork*)workData)->alternatePrefixCount != '\0') {
|
||||
wordCursor -= prefixCount;
|
||||
elements -= prefixCount;
|
||||
elementCount = elementCount + prefixCount;
|
||||
wordCapacity = wordCapacity + prefixCount;
|
||||
prefixCount = 0;
|
||||
prefixPrepared = ZI8_FALSE;
|
||||
((ZiAlphaWork*)workData)->suffixMode = 0;
|
||||
((ZiAlphaWork*)workData)->suffixLocked = 0;
|
||||
((ZiAlphaWork*)workData)->suffixCount = 0;
|
||||
for (index = 0; index < (int)(unsigned int)((ZiAlphaWork*)workData)->alternatePrefixCount; index = index + 1) {
|
||||
((ZiAlphaWork*)workData)->prefix[index] =
|
||||
((ZiAlphaWork*)workData)->alternatePrefix[index];
|
||||
}
|
||||
((ZiAlphaWork*)workData)->prefixCount = (ziU8)index;
|
||||
if (((ZiAlphaWork*)workData)->language == parameters->language) {
|
||||
((ZiAlphaWork*)workData)->language = parameters->subLanguage;
|
||||
}
|
||||
else {
|
||||
((ZiAlphaWork*)workData)->language = parameters->language;
|
||||
}
|
||||
((ZiAlphaWork*)workData)->alternatePrefixCount = 0;
|
||||
}
|
||||
}
|
||||
if ((((primaryMatched) && (secondaryMatched)) || (elementCount == 0)) ||
|
||||
(((language == parameters->language && (primaryMatched)) || ((language == parameters->subLanguage && (secondaryMatched))))))
|
||||
goto finishCandidates;
|
||||
if (currentVowelRestriction) {
|
||||
checkPrefixPunctuation:
|
||||
if ((1 < ((ZiAlphaWork*)workData)->prefixEnabled) &&
|
||||
(parameters->elements[parameters->elementCount - 1] != 0xEFF1))
|
||||
@@ -1568,17 +1576,17 @@ checkPrefixFields:
|
||||
|
||||
finishCandidates:
|
||||
((ZiAlphaWork*)workData)->usePrefixAsElements = 0;
|
||||
if (((ZiAlphaOptions*)optionData)->countOnly != '\0') {
|
||||
parameters->letters = 0;
|
||||
if (((ZiAlphaOptions*)optionData)->countOnly == '\0') {
|
||||
parameters->letters = candidateCount;
|
||||
}
|
||||
else {
|
||||
parameters->letters = candidateCount;
|
||||
parameters->letters = 0;
|
||||
}
|
||||
wordCursor[-prefixCount] = 0;
|
||||
if (((((ZiAlphaOptions*)optionData)->countOnly == '\0') && (((ZiAlphaOptions*)optionData)->lookupMode == '\0')) && (parameters->elementCount != 0)) {
|
||||
elementIndex = parameters->elementCount - 1;
|
||||
if (((primaryVowelRestriction) || (secondaryVowelRestriction)) &&
|
||||
((((ZiAlphaWork*)workData)->prefixEnabled <= 1 ||
|
||||
((((ZiAlphaWork*)workData)->prefixEnabled < 2 ||
|
||||
(parameters->elements[elementIndex] == 0xEFF1)))) {
|
||||
index = 0;
|
||||
while (elementIndex >= 0) {
|
||||
|
||||
@@ -133,16 +133,16 @@ typedef struct {
|
||||
ziU8 phonetics[11];
|
||||
} ZiChineseRecord;
|
||||
|
||||
extern ziU32 Zi8GetTableAddress(ziU8 language, ziU8 table, ziPtr work);
|
||||
extern ziPtr Zi8GetTableAddress(ziU8 language, ziU8 table, ziPtr work);
|
||||
extern ziU16 Zi8GetTableCount(ziU8 language, ziU8 table, ziPtr work);
|
||||
extern ziU8 Zi8IsDupWChar(ziWChar character, ziPtr work);
|
||||
extern ziU8 Zi8IsDupWordW(ziWChar* word, ziU8 length, ziPtr work);
|
||||
extern ziWChar Zi8Ord2Uni(ziU16 ordinal, ziPtr work);
|
||||
extern ziU8 Zi8MatchPhonetic(ziPtr phonetics, ziU8* records,
|
||||
ziPtr indexTable, ziU16 indexCount, ziU32 dictionary,
|
||||
ziU8* record, ziU16* mask, ziU16* match,
|
||||
ziU16* length, ziU8** matchedRecord,
|
||||
ziU8** matchedString, ziU8 wordMode, ziU8 partial,
|
||||
extern ziU8 Zi8MatchPhonetic(ziU8* phonetics, ZiChineseRecord* records,
|
||||
ziPtr indexTable, ziU16 indexCount, ziPtr dictionary,
|
||||
ZiChineseRecord* record, ziU16* mask, ziU16* match,
|
||||
ziU16* length, ZiChineseRecord** matchedRecord,
|
||||
int* matchedIndex, ziU8 wordMode, ziU8 partial,
|
||||
ziU8 oneCharacter, ziU16 excludedMask,
|
||||
ziU16 excludedMatch, ziU8 charset, ziU8 options,
|
||||
ziU16 ordinal, ziU16* tone, ziU8 spellingOnly,
|
||||
@@ -160,13 +160,13 @@ extern const ziU8 zi8CangjieCodes[25];
|
||||
extern const ziWChar ziPuncts[4];
|
||||
extern const ziWChar ziTones[4];
|
||||
const ziWChar zi8tones[4];
|
||||
extern ziU32 Zi8GetZHuwdPtr(ziU32* entries, ziU16* count, ziPtr work);
|
||||
extern ziU8 Zi8GetZHuwdPtr(ziU8** entries, ziU16* count, ziPtr work);
|
||||
extern ziBool Zi8IsComponent(ziWChar character, ziPtr work);
|
||||
extern ziBool Zi8IsCharacter(ziWChar character, ziPtr work);
|
||||
extern ziU8 Zi8MatchOEMdata(ziWChar* currentWord, ziU8 length, ziU8 language,
|
||||
ziWChar* output, ziU16 capacity, ziU8 mode, ziU8 next, ziPtr work);
|
||||
extern ziU16 Zi8Uni2Ord(ziWChar character, ziPtr work);
|
||||
extern ziU16 Zi8GetPCode(ziU8* table, ziU8* record);
|
||||
extern int Zi8GetPCode(ziU8* table, ziU8* record);
|
||||
extern ziU16 Zi8MatchAltSound(ziPtr table, ziU16 count, ziPtr phonetics,
|
||||
ziU16 ordinal, ziU16 mask, ziU16 value, ziU8 flags, ziPtr work);
|
||||
extern ziU32 Zi8SecMatchChar(ziPtr record, ziU8* dictionary, ziMatchParam* match, ziU16* code, ziPtr work);
|
||||
@@ -199,7 +199,7 @@ static int zi8InternalGetZH(ziGetParam* request, ZiChineseOptions* options, ziPt
|
||||
ziU8 matchMode;
|
||||
int index;
|
||||
ziWChar* currentWord;
|
||||
ziU32 userEntriesAddress;
|
||||
ziU8* userEntries;
|
||||
ziU16 ordinalIndex;
|
||||
ziU16 tableIndex;
|
||||
ziU16 phraseOrdinal;
|
||||
@@ -614,10 +614,10 @@ static int zi8InternalGetZH(ziGetParam* request, ZiChineseOptions* options, ziPt
|
||||
case 56: case 59:
|
||||
if (((ziFuzzyZYPairs*)&((struct __zi8_work_data_s*)work)->unk_0x1B2C.word)->fANDh) ordinalIndex = 0xF9FF;
|
||||
break;
|
||||
case 60: case 63:
|
||||
case 52: case 55:
|
||||
if (((ziFuzzyZYPairs*)&((struct __zi8_work_data_s*)work)->unk_0x1B2C.word)->bANDp) ordinalIndex = 0xF9FF;
|
||||
break;
|
||||
case 52: case 55:
|
||||
case 60: case 63:
|
||||
if (((ziFuzzyZYPairs*)&((struct __zi8_work_data_s*)work)->unk_0x1B2C.word)->gANDk) ordinalIndex = 0xF9FF;
|
||||
break;
|
||||
case 38:
|
||||
@@ -755,8 +755,8 @@ static int zi8InternalGetZH(ziGetParam* request, ZiChineseOptions* options, ziPt
|
||||
componentOrdinals = (ziU8*)Zi8GetTableAddress(1, 7, work);
|
||||
componentTable = componentCursor = (ziU8*)Zi8GetTableAddress(1, 2, work);
|
||||
componentCursor += 8;
|
||||
componentIndex = componentCount - 1;
|
||||
--componentCount;
|
||||
componentIndex = componentCount;
|
||||
alternateCharacter = 0;
|
||||
phoneticRetry = 1;
|
||||
}
|
||||
@@ -1299,8 +1299,8 @@ context_word_lookup:
|
||||
if (emitWords) {
|
||||
++emittedCount;
|
||||
outputIndex += emittedWords;
|
||||
output[outputIndex] = ' ';
|
||||
if (++outputIndex > outputLimit) {
|
||||
output[outputIndex++] = ' ';
|
||||
if (outputIndex > outputLimit) {
|
||||
request->letters = emittedCount;
|
||||
request->count = emittedCount;
|
||||
goto engine_finish;
|
||||
@@ -1336,7 +1336,7 @@ dictionary_search:
|
||||
Zi8GetFormatVersion(1, work) >= 8) {
|
||||
lastCharHigh = (request->currentWord[request->wordCharCount - 1] >> 8) & 0xFF;
|
||||
lastCharLow = request->currentWord[request->wordCharCount - 1];
|
||||
phoneticGroups = (ziU8*)Zi8GetTableAddress(1, 28, work);
|
||||
phoneticGroups = Zi8GetTableAddress(1, 28, work);
|
||||
rangeCount = Zi8GetTableCount(1, 28, work);
|
||||
rangeIndex = 0;
|
||||
while (rangeIndex < rangeCount) {
|
||||
@@ -1384,7 +1384,7 @@ numeric_setup:
|
||||
default: ordinalCount = 0; break;
|
||||
}
|
||||
}
|
||||
if (ordinalCount) ordinalTable = (ziU8*)Zi8GetTableAddress(1, 29, work);
|
||||
if (ordinalCount) ordinalTable = Zi8GetTableAddress(1, 29, work);
|
||||
}
|
||||
if (!request->elementCount && (getMode == 7 || getMode == 8 || getMode == 9)) {
|
||||
resultFallback = 0;
|
||||
@@ -1434,8 +1434,8 @@ candidate_dictionary_search:
|
||||
if (emitWords) {
|
||||
++emittedCount;
|
||||
output[outputIndex++] = character;
|
||||
output[outputIndex] = ' ';
|
||||
if (++outputIndex > outputLimit) goto engine_finish;
|
||||
output[outputIndex++] = ' ';
|
||||
if (outputIndex > outputLimit) goto engine_finish;
|
||||
} else output[emittedCount++] = character;
|
||||
if (emittedCount >= request->maxCandidates) goto engine_finish;
|
||||
}
|
||||
@@ -1451,7 +1451,7 @@ character_range_start:
|
||||
firstOrdinal = 0;
|
||||
rangeIndex = Zi8GetTableCount(1, 16, work);
|
||||
if (Zi8GetFormatVersion(1, work) >= 4 && rangeIndex && elements[0] != 0xEF00) {
|
||||
phoneticGroups = (ziU8*)Zi8GetTableAddress(1, 16, work);
|
||||
phoneticGroups = Zi8GetTableAddress(1, 16, work);
|
||||
rangeIndex = 0;
|
||||
rangeCount = 0;
|
||||
switch (phase) {
|
||||
@@ -1612,9 +1612,9 @@ phonetic_ordinal_search:
|
||||
record = records + phraseOrdinal * 12;
|
||||
candidateCount = 0;
|
||||
phoneticGroups = 0;
|
||||
if (!Zi8MatchPhonetic(phoneticTable, records, alternateTable, alternateCount,
|
||||
(ziU32)phraseTable, record, match.phon, match.phon2,
|
||||
&candidateCount, &record, &phoneticGroups,
|
||||
if (!Zi8MatchPhonetic(phoneticTable, (ZiChineseRecord*)records, alternateTable, alternateCount,
|
||||
phraseTable, (ZiChineseRecord*)record, match.phon, match.phon2,
|
||||
&candidateCount, (ZiChineseRecord**)&record, (int*)&phoneticGroups,
|
||||
0, 1, match.nCand, phoneticMask, phoneticMatch, charset, requireFull,
|
||||
phraseOrdinal, &candidateOrdinal, 0, work)) continue;
|
||||
if (charsetTable) {
|
||||
@@ -1676,8 +1676,8 @@ tone_candidates:
|
||||
if (emitWords) {
|
||||
++emittedCount;
|
||||
output[outputIndex++] = character;
|
||||
output[outputIndex] = ' ';
|
||||
if (++outputIndex > outputLimit) goto engine_finish;
|
||||
output[outputIndex++] = ' ';
|
||||
if (outputIndex > outputLimit) goto engine_finish;
|
||||
} else output[emittedCount++] = character;
|
||||
if (emittedCount >= request->maxCandidates) goto engine_finish;
|
||||
} else if (totalResults >= options->maxResults) goto engine_finish;
|
||||
@@ -1754,10 +1754,10 @@ tone_candidates:
|
||||
user_character_search:
|
||||
if (((struct __zi8_work_data_s*)work)->uwdPtrCount && (getMode != 0 || !firstPhoneticPass) &&
|
||||
!options->countOnly && (match.nCand <= 1 || (getMode != 1 && getMode != 2)) &&
|
||||
(ziU8)Zi8GetZHuwdPtr(&userEntriesAddress, &userCount, work) && (getMode != 0 || match.nSeg <= 1)) {
|
||||
Zi8GetZHuwdPtr(&userEntries, &userCount, work) && (getMode != 0 || match.nSeg <= 1)) {
|
||||
userIndex = 0;
|
||||
while (userIndex < userCount) {
|
||||
candidateOrdinal = (ziU16)(((ziU8*)userEntriesAddress)[1] & 0x7F) << 8 | ((ziU8*)userEntriesAddress)[2];
|
||||
candidateOrdinal = (ziU16)(userEntries[1] & 0x7F) << 8 | userEntries[2];
|
||||
record = records + candidateOrdinal * 12;
|
||||
if (!(record[0] & charset)) goto user_character_next;
|
||||
character = ((ziU16)record[6] << 8) + record[7];
|
||||
@@ -1792,7 +1792,7 @@ user_character_search:
|
||||
(ziU8)Zi8SecMatchChar(record, componentTable, &match, 0, work)) candidateStatus = 1;
|
||||
break;
|
||||
case 1: case 2:
|
||||
if (request->elementCount && !(((ziU8*)userEntriesAddress)[1] & 0x80)) candidateStatus = 0;
|
||||
if (request->elementCount && !(userEntries[1] & 0x80)) candidateStatus = 0;
|
||||
else {
|
||||
candidateStatus = (match.first & (ziU16)Zi8GetPCode(phoneticTable, record)) == match.first2;
|
||||
if (!candidateStatus && (record[0] & 0x80) && !requireFull &&
|
||||
@@ -1827,7 +1827,7 @@ user_character_search:
|
||||
}
|
||||
user_character_next:
|
||||
++userIndex;
|
||||
userEntriesAddress += 3;
|
||||
userEntries += 3;
|
||||
}
|
||||
}
|
||||
if (!prefixLookup) goto phonetic_alt_continue;
|
||||
@@ -1912,7 +1912,7 @@ cangjie_components:
|
||||
Zi8GetTableCount(1, 16, work) && elements[0] != 0xEF00 && getMode != 5) {
|
||||
rangeIndex = 0;
|
||||
rangeCount = 0;
|
||||
phoneticGroups = (ziU8*)Zi8GetTableAddress(1, 16, work);
|
||||
phoneticGroups = Zi8GetTableAddress(1, 16, work);
|
||||
switch (phase) {
|
||||
case 0: rangeIndex = 0; rangeCount = 2; phase = 1; break;
|
||||
case 1:
|
||||
@@ -2052,7 +2052,7 @@ component_record_next:
|
||||
if (getMode != 5) {
|
||||
while (exactPhrase) {
|
||||
while (match.count) {
|
||||
if ((candidateCount -= 1) == 0xFFFF) goto frequency_range_retry;
|
||||
if (!candidateCount--) goto frequency_range_retry;
|
||||
if (match.arrD[0] == (record[0] & match.arr1[0]) &&
|
||||
(ziU8)Zi8SecMatchChar(record, componentTable, &match, &candidateOrdinal, work)) goto frequency_accept;
|
||||
record += 12;
|
||||
@@ -2199,7 +2199,7 @@ phonetic_main:
|
||||
if (Zi8GetFormatVersion(1, work) >= 4) rangeCount = Zi8GetTableCount(1, 23, work);
|
||||
else rangeCount = 0;
|
||||
if (rangeCount && match.nCand == 2 && emitWords) {
|
||||
frequencyCursor = (ziU8*)Zi8GetTableAddress(1, 24, work);
|
||||
frequencyCursor = Zi8GetTableAddress(1, 24, work);
|
||||
frequencyEntry = frequencyCursor;
|
||||
duplicateIndex = Zi8GetTableCount(1, 24, work);
|
||||
if (!duplicateIndex) isFirstCandidate = 1;
|
||||
@@ -2298,7 +2298,7 @@ phonetic_pair_next:
|
||||
alternateCursor += 4;
|
||||
}
|
||||
phonetic_group_next:
|
||||
ordinalIndex += 1;
|
||||
++ordinalIndex;
|
||||
frequencyCursor += 5;
|
||||
}
|
||||
}
|
||||
@@ -2323,9 +2323,9 @@ phonetic_ordinals:
|
||||
candidateCount = recordCount;
|
||||
phoneticGroups = 0;
|
||||
while (emittedCount < request->maxCandidates && candidateCount) {
|
||||
if (!Zi8MatchPhonetic(phoneticTable, records, alternateTable, alternateCount,
|
||||
(ziU32)phraseTable, record, match.phon, match.phon2,
|
||||
&candidateCount, &record, &phoneticGroups,
|
||||
if (!Zi8MatchPhonetic(phoneticTable, (ZiChineseRecord*)records, alternateTable, alternateCount,
|
||||
phraseTable, (ZiChineseRecord*)record, match.phon, match.phon2,
|
||||
&candidateCount, (ZiChineseRecord**)&record, (int*)&phoneticGroups,
|
||||
emitWords, singleCharacterPass, match.nCand, phoneticMask, phoneticMatch, charset,
|
||||
requireFull, recordCount, &candidateOrdinal, filteringMode, work)) break;
|
||||
ordinalIndex = recordCount - candidateCount - 1;
|
||||
@@ -2446,7 +2446,7 @@ engine_finish:
|
||||
return totalResults;
|
||||
filtered_search:
|
||||
userIndex = Zi8GetTableCount(1, 31, work);
|
||||
frequencyTable = (ziU8*)Zi8GetTableAddress(1, 31, work);
|
||||
frequencyTable = Zi8GetTableAddress(1, 31, work);
|
||||
for (; userIndex; --userIndex) {
|
||||
index = frequencyTable[0] & 15;
|
||||
if (!(*frequencyTable++ & charset)) goto filtered_next;
|
||||
@@ -2608,10 +2608,10 @@ static int Zi8NewMatchPhonetic(ziGetParam* request, ZiChineseRecord* records,
|
||||
ziU8* phonetics;
|
||||
int totalResults;
|
||||
int emittedCharacters;
|
||||
ziU8* matchedRecord;
|
||||
ZiChineseRecord* matchedRecord;
|
||||
ziU8* phoneticGroups;
|
||||
ziU8* candidateGroups;
|
||||
ziU8* matchedString;
|
||||
int matchedIndex;
|
||||
int capacity;
|
||||
ziU8* groupCandidates;
|
||||
ziU16 phoneticCount;
|
||||
@@ -2645,20 +2645,20 @@ static int Zi8NewMatchPhonetic(ziGetParam* request, ZiChineseRecord* records,
|
||||
if ((mask & 7) == 7) {
|
||||
stopAfterTone = match & 7;
|
||||
}
|
||||
phoneticOffsets = (ziU16*)Zi8GetTableAddress(1, 13, work);
|
||||
ordinalTable = (ziU16*)Zi8GetTableAddress(1, 14, work);
|
||||
phoneticOffsets = Zi8GetTableAddress(1, 13, work);
|
||||
ordinalTable = Zi8GetTableAddress(1, 14, work);
|
||||
if (pinyin) {
|
||||
phonetics = (ziU8*)Zi8GetTableAddress(1, 3, work);
|
||||
phonetics = Zi8GetTableAddress(1, 3, work);
|
||||
phoneticCount = Zi8GetTableCount(1, 3, work);
|
||||
phoneticGroups = (ziU8*)Zi8GetTableAddress(1, 17, work);
|
||||
phoneticGroups = Zi8GetTableAddress(1, 17, work);
|
||||
groupCount = Zi8GetTableCount(1, 17, work);
|
||||
candidateGroups = (ziU8*)Zi8GetTableAddress(1, 18, work);
|
||||
candidateGroups = Zi8GetTableAddress(1, 18, work);
|
||||
} else {
|
||||
phonetics = (ziU8*)Zi8GetTableAddress(1, 4, work);
|
||||
phonetics = Zi8GetTableAddress(1, 4, work);
|
||||
phoneticCount = Zi8GetTableCount(1, 4, work);
|
||||
phoneticGroups = (ziU8*)Zi8GetTableAddress(1, 19, work);
|
||||
phoneticGroups = Zi8GetTableAddress(1, 19, work);
|
||||
groupCount = Zi8GetTableCount(1, 19, work);
|
||||
candidateGroups = (ziU8*)Zi8GetTableAddress(1, 20, work);
|
||||
candidateGroups = Zi8GetTableAddress(1, 20, work);
|
||||
}
|
||||
|
||||
if (groupCount) {
|
||||
@@ -2782,12 +2782,12 @@ next_group_candidate:
|
||||
}
|
||||
}
|
||||
if (stopAfterTone) {
|
||||
matchedRecord = (ziU8*)(records + character);
|
||||
matchedRecord = records + character;
|
||||
matchedLength = 0;
|
||||
matchedString = 0;
|
||||
if (!Zi8MatchPhonetic(phonetics, (ziU8*)records, indexTable, indexCount,
|
||||
(ziU32)dictionary, matchedRecord, &mask, &match,
|
||||
&matchedLength, &matchedRecord, &matchedString,
|
||||
matchedIndex = 0;
|
||||
if (!Zi8MatchPhonetic(phonetics, records, indexTable, indexCount,
|
||||
dictionary, matchedRecord, &mask, &match,
|
||||
&matchedLength, &matchedRecord, &matchedIndex,
|
||||
wordMode, 1, 1, excludedMask, excludedMatch,
|
||||
charset, request->getOptions & 0x40, character,
|
||||
&matchedTone, 0, work)) {
|
||||
|
||||
@@ -62,7 +62,7 @@ ziU8 Zi8InitializeDynamic(ziLanguageEntry* langEntries ZI_NEED_WORK) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
ziU8 Zi8IsZicorpSignature(ziU16* p, ziU16 len ZI_NEED_WORK) {
|
||||
ziU8 Zi8IsZicorpSignature(ziU16* p, ziU16 len) {
|
||||
if ((ziU16)len > 6 && p[0] == 0x7A && p[1] == 0x69 && p[2] == 0x63 &&
|
||||
p[3] == 0x6F && p[4] == 0x72 && p[5] == 0x70) {
|
||||
return 1;
|
||||
|
||||
@@ -254,7 +254,7 @@ ziBool Zi8PriMatchNextComp(ziU8* node, ziU8 mask0, ziU8 value0, ziU8 mask1, ziU8
|
||||
return 0;
|
||||
}
|
||||
|
||||
ziBool Zi8SecMatchComp(ziPtr nodeAddress, ziMatchParam* matchAddress, ziPtr dictionaryAddress ZI_NEED_WORK) {
|
||||
ziBool Zi8SecMatchComp(ziPtr nodeAddress, ziMatchParam* matchAddress, ziPtr dictionaryAddress) {
|
||||
int chainIndex;
|
||||
ziU16 matchCode;
|
||||
ziU16 targetCode;
|
||||
@@ -506,7 +506,7 @@ pinyin_initial:
|
||||
convertedCount = Zi8PinyinInitials[value];
|
||||
if (convertedCount != 0) {
|
||||
if (outputIndex == 0) {
|
||||
*resultCount += 1;
|
||||
*resultCount = *resultCount + 1;
|
||||
}
|
||||
result++;
|
||||
initial[outputIndex] = 0x7E00;
|
||||
@@ -526,7 +526,7 @@ pinyin_initial:
|
||||
value = *current;
|
||||
if (value != 0x68 && value != 0xF368) goto scan_final;
|
||||
if (outputIndex == 0) {
|
||||
*resultCount += 1;
|
||||
*resultCount = *resultCount + 1;
|
||||
}
|
||||
final[outputIndex] += 0x200;
|
||||
*bestInitial = initial[0];
|
||||
@@ -567,7 +567,7 @@ scan_final:
|
||||
value -= 0xF361;
|
||||
if (value > 0x19) {
|
||||
if (outputIndex == 0) {
|
||||
*resultCount += 1;
|
||||
*resultCount = *resultCount + 1;
|
||||
}
|
||||
goto finish_final;
|
||||
}
|
||||
@@ -577,7 +577,7 @@ scan_final:
|
||||
pinyin[index] = (ziU8)value + 1;
|
||||
if (Zi8GetPyFinal(pinyin, &pyInitial, &pyFinal) == 0) goto try_final_extension;
|
||||
if (outputIndex == 0) {
|
||||
*resultCount += 1;
|
||||
*resultCount = *resultCount + 1;
|
||||
}
|
||||
current++;
|
||||
index++;
|
||||
@@ -592,7 +592,7 @@ try_final_extension:
|
||||
pinyin[index + 1] = 0xFF;
|
||||
if (Zi8GetPyFinal(pinyin, &pyInitial, &pyFinal) != 0) {
|
||||
if (outputIndex == 0) {
|
||||
*resultCount += 1;
|
||||
*resultCount = *resultCount + 1;
|
||||
}
|
||||
pinyin[index + 1] = 0;
|
||||
current++;
|
||||
@@ -615,7 +615,7 @@ try_final_extension:
|
||||
finish_final:
|
||||
if ((index > 3) && (count != 0) && (((value = *current) == 0x27) || (value == 0xF360) || (value == 0x20))) {
|
||||
if (outputIndex == 0) {
|
||||
*resultCount += 1;
|
||||
*resultCount = *resultCount + 1;
|
||||
}
|
||||
current++;
|
||||
count--;
|
||||
@@ -705,10 +705,11 @@ finish_final:
|
||||
}
|
||||
}
|
||||
}
|
||||
if (++outputIndex > 0xf) break;
|
||||
outputIndex++;
|
||||
if (outputIndex > 0xf) break;
|
||||
}
|
||||
if ((result > 1) && (text[*resultCount - 1] >= 0xF341) && (text[*resultCount - 1] <= 0xF35A)) {
|
||||
*resultCount -= 1;
|
||||
*resultCount = *resultCount - 1;
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -742,9 +743,9 @@ check_row:
|
||||
return 0;
|
||||
}
|
||||
|
||||
ziU8 Zi8GetBpmfPhonetic(ziWChar* text, ziU8 count, ziU16* initial, ziU16* final, ziU16* bestInitial, ziU16* bestFinal ZI_NEED_WORK) {
|
||||
ziS32 Zi8GetBpmfPhonetic(ziWChar* text, ziU8 count, ziU16* initial, ziU16* final, ziU16* bestInitial, ziU16* bestFinal ZI_NEED_WORK) {
|
||||
ziU16 value;
|
||||
ziU8 resultCount = 0;
|
||||
ziU32 resultCount = 0;
|
||||
|
||||
Zi8LogError(0x64, ZI_WORK);
|
||||
if (count == 0) {
|
||||
|
||||
@@ -17,7 +17,7 @@ typedef struct ziPudHeader {
|
||||
ziU8 options[4];
|
||||
ziPudSection sections[1];
|
||||
} ziPudHeader;
|
||||
ziU8 Zi8_8147FD7C(ziWChar*, ziU8, ziU8, ziWChar*, ziU16, ziU8, ziU8 ZI_NEED_WORK);
|
||||
ziU32 Zi8_8147FD7C(ziWChar*, ziU8, ziU8, ziWChar*, ziU16, ziU8, ziU8 ZI_NEED_WORK);
|
||||
|
||||
ziU32 ZiIsPhoneticChar(ziWChar character) {
|
||||
if ((character < 0xF305 || character > 0xF329) && (character < 0xF361 || character > 0xF37A)) return 0;
|
||||
@@ -56,11 +56,8 @@ ziU8 ZADP_Zi8SetPDremoveOpt(ziU8 option, struct __zi8_work_data_s* __zi8_work_da
|
||||
Zi8LogError(100, __zi8_work_data);
|
||||
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) {
|
||||
struct {
|
||||
int fallback;
|
||||
ziPtr workspace;
|
||||
} match;
|
||||
ziU32 Zi8MatchPUDdata_ZHS(ziWChar* pattern, ziU8 length, ziU8 language, ziWChar* output, ziU16 capacity, ziWChar* spelling, ziU16 spellingCapacity, ziU8 complete, ziU8 continuation ZI_NEED_WORK) {
|
||||
int fallback = 0;
|
||||
ziU8* bytePattern;
|
||||
ziWChar folded;
|
||||
ziPudSection* section;
|
||||
@@ -71,8 +68,6 @@ ziU8 Zi8MatchPUDdata_ZHS(ziWChar* pattern, ziU8 length, ziU8 language, ziWChar*
|
||||
ziU32 entrySize;
|
||||
ziPudHeader* table;
|
||||
ziU8* byteOutput;
|
||||
match.workspace = __zi8_work_data;
|
||||
match.fallback = 0;
|
||||
if (!(ZI_WORK->pudCount <= 16 && ZI_WORK->pudCount != 0 && ZI_WORK->pudTable[ZI_WORK->pudCount - 1] != 0)) {
|
||||
Zi8LogError(0x4B0, __zi8_work_data);
|
||||
return 0;
|
||||
@@ -93,8 +88,8 @@ ziU8 Zi8MatchPUDdata_ZHS(ziWChar* pattern, ziU8 length, ziU8 language, ziWChar*
|
||||
Zi8LogError(0x4F6, __zi8_work_data);
|
||||
return 0;
|
||||
}
|
||||
ZI_WORK->unk_0x314 = ((ziU16)section->count[0] << 8) + (ziU16)section->count[1];
|
||||
ZI_WORK->unk_0x310 = (ziU32)table + (((ziU16)section->offset[0] << 8) + (ziU16)section->offset[1]);
|
||||
ZI_WORK->unk_0x314 = section->count[0] * 0x100 + section->count[1];
|
||||
ZI_WORK->unk_0x310 = (ziU32)table + section->offset[0] * 0x100 + section->offset[1];
|
||||
ZI_WORK->unk_0x318 = 0;
|
||||
}
|
||||
for (;;) {
|
||||
@@ -135,7 +130,7 @@ matchText:
|
||||
}
|
||||
}
|
||||
matched:
|
||||
if (match.fallback) {
|
||||
if (fallback) {
|
||||
ZI_WORK->unk_0x310 = 0;
|
||||
ZI_WORK->unk_0x318 = 0;
|
||||
ZI_WORK->unk_0x314 = 0;
|
||||
@@ -169,7 +164,7 @@ matched:
|
||||
}
|
||||
if (length == 1 && complete != 0 && continuation == 0) {
|
||||
complete = 0;
|
||||
match.fallback = 1;
|
||||
fallback = 1;
|
||||
ZI_WORK->unk_0x318 = 0;
|
||||
} else {
|
||||
ZI_WORK->unk_0x310 = 0;
|
||||
@@ -179,12 +174,12 @@ matched:
|
||||
}
|
||||
}
|
||||
}
|
||||
ziU8 Zi8MatchPUDdata(ziWChar* pattern, ziU8 length, ziU8 language, ziWChar* output, ziU16 capacity, ziU8 complete, ziU8 continuation, struct __zi8_work_data_s* __zi8_work_data) {
|
||||
ziU8 result;
|
||||
ziU32 Zi8MatchPUDdata(ziWChar* pattern, ziU8 length, ziU8 language, ziWChar* output, ziU16 capacity, ziU8 complete, ziU8 continuation, struct __zi8_work_data_s* __zi8_work_data) {
|
||||
ziU32 result;
|
||||
if (continuation == 0) __zi8_work_data->pudCount = 1;
|
||||
for (;;) {
|
||||
result = Zi8_8147FD7C(pattern, length, language, output, capacity, complete, continuation, __zi8_work_data);
|
||||
if (result != 0) break;
|
||||
if ((ziU8)result != 0) break;
|
||||
if (++__zi8_work_data->pudCount <= 16) {
|
||||
continuation = 0;
|
||||
} else {
|
||||
@@ -194,6 +189,6 @@ ziU8 Zi8MatchPUDdata(ziWChar* pattern, ziU8 length, ziU8 language, ziWChar* outp
|
||||
}
|
||||
return result;
|
||||
}
|
||||
ziU8 Zi8_8147FD7C(ziWChar* pattern, ziU8 length, ziU8 language, ziWChar* output, ziU16 capacity, ziU8 complete, ziU8 continuation ZI_NEED_WORK) {
|
||||
ziU32 Zi8_8147FD7C(ziWChar* pattern, ziU8 length, ziU8 language, ziWChar* output, ziU16 capacity, ziU8 complete, ziU8 continuation ZI_NEED_WORK) {
|
||||
return Zi8MatchPUDdata_ZHS(pattern, length, language, output, capacity, 0, 0, complete, continuation, __zi8_work_data);
|
||||
}
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
#include <zi8clib/zitypes.h>
|
||||
|
||||
ziU16 Zi8GetVersion(ziPtr __zi8_work_data) {
|
||||
ziU16 Zi8GetVersion() {
|
||||
return 1802;
|
||||
}
|
||||
|
||||
ziU16 Zi8GetBuildID(ziPtr __zi8_work_data) {
|
||||
ziU16 Zi8GetBuildID() {
|
||||
return 41;
|
||||
}
|
||||
|
||||
ziU16 Zi8GetOEMID(ziPtr __zi8_work_data) {
|
||||
ziU16 Zi8GetOEMID() {
|
||||
return 249;
|
||||
}
|
||||
|
||||
@@ -11,15 +11,15 @@ typedef struct {
|
||||
ziU8 characterLow;
|
||||
} ZiKoreanKeyEntry;
|
||||
|
||||
ziU16 Zi8_8148302C(ziU16 key, ziU8* table ZI_NEED_WORK) {
|
||||
ziU32 Zi8_8148302C(ziU16 key, ziU8* table ZI_NEED_WORK) {
|
||||
ziU32 value;
|
||||
ziU16 count;
|
||||
ziU16 i;
|
||||
ziU32 i;
|
||||
|
||||
count = Zi8GetTableCount(ZI8_LANG_KO, 9, ZI_WORK);
|
||||
for (i = 0; i < count; i++) {
|
||||
value = (ziU16)(((ziU16)table[(i << 3) + i + 7] << 8) |
|
||||
table[(i << 3) + i + 8]);
|
||||
for (i = 0; (ziU16)i < count; i++) {
|
||||
value = (ziU16)(((ziU16)table[((i & 0xFFFF) << 3) + (i & 0xFFFF) + 7] << 8) |
|
||||
table[((i & 0xFFFF) << 3) + (i & 0xFFFF) + 8]);
|
||||
if (value == key) {
|
||||
Zi8LogError(0x64, ZI_WORK);
|
||||
return i;
|
||||
@@ -119,19 +119,28 @@ ziU32 Zi8_814833F0(const ziGetParam* param, ziU16 key ZI_NEED_WORK) {
|
||||
|
||||
ziU32 Zi8_814834AC(ziGetParam* param, ziU16* remaining, ziU8* count,
|
||||
ziU8* inserted ZI_NEED_WORK) {
|
||||
ziU8* tableA;
|
||||
ziU8* tableB;
|
||||
ZiKoreanKeyEntry* entry;
|
||||
ziS32 compactIndex;
|
||||
ziU16 tableCount;
|
||||
ziU32 j = 0;
|
||||
ziU8 candidateIndex = 0;
|
||||
ziU8 matched = 0;
|
||||
ziBool matches;
|
||||
ziU8 keys[5] = {0};
|
||||
struct {
|
||||
ziBool matches;
|
||||
ziU8 candidateIndex;
|
||||
ziU16 tableCount;
|
||||
ziS32 compactIndex;
|
||||
ZiKoreanKeyEntry* entry;
|
||||
ziU8* tableB;
|
||||
ziU8* tableA;
|
||||
union {
|
||||
ziU32 firstWord;
|
||||
ziU8 bytes[5];
|
||||
} keys;
|
||||
} filter;
|
||||
ziU32 j;
|
||||
ziS32 i;
|
||||
ziS32 candidate;
|
||||
ziU8 matched;
|
||||
|
||||
j = 0;
|
||||
filter.candidateIndex = 0;
|
||||
matched = 0;
|
||||
filter.keys.bytes[4] = filter.keys.firstWord = 0;
|
||||
Zi8LogError(0x64, ZI_WORK);
|
||||
if (param->elementCount == 0) {
|
||||
if (*remaining >= *count) {
|
||||
@@ -157,40 +166,40 @@ ziU32 Zi8_814834AC(ziGetParam* param, ziU16* remaining, ziU8* count,
|
||||
return 0;
|
||||
}
|
||||
|
||||
tableA = (ziU8*)Zi8GetTableAddress(param->language, 9, ZI_WORK);
|
||||
tableB = (ziU8*)Zi8GetTableAddress(param->language, 10, ZI_WORK);
|
||||
if (tableA == 0) {
|
||||
filter.tableA = (ziU8*)Zi8GetTableAddress(param->language, 9, ZI_WORK);
|
||||
filter.tableB = (ziU8*)Zi8GetTableAddress(param->language, 10, ZI_WORK);
|
||||
if (filter.tableA == 0) {
|
||||
Zi8ReplaceLastError(0x76C, ZI_WORK);
|
||||
return 0;
|
||||
} else if (tableB == 0) {
|
||||
} else if (filter.tableB == 0) {
|
||||
Zi8ReplaceLastError(0x776, ZI_WORK);
|
||||
return 0;
|
||||
} else {
|
||||
tableCount = Zi8GetTableCount(ZI8_LANG_KO, 9, ZI_WORK);
|
||||
Zi8_81483118(param, keys);
|
||||
filter.tableCount = Zi8GetTableCount(ZI8_LANG_KO, 9, ZI_WORK);
|
||||
Zi8_81483118(param, filter.keys.bytes);
|
||||
i = 0;
|
||||
while (i < tableCount && matched < *count) {
|
||||
matches = ZI8_TRUE;
|
||||
entry = (ZiKoreanKeyEntry*)&tableA[(i << 3) + i];
|
||||
while (i < filter.tableCount && matched < *count) {
|
||||
filter.matches = ZI8_TRUE;
|
||||
filter.entry = (ZiKoreanKeyEntry*)&filter.tableA[(i << 3) + i];
|
||||
j = 0;
|
||||
if (param->elementCount > 1) {
|
||||
for (j = 0; (int)(j & 0xFF) < (int)param->elementCount / 2; j++) {
|
||||
if (keys[j & 0xFF] != entry->keyBytes[j & 0xFF]) {
|
||||
matches = ZI8_FALSE;
|
||||
if (filter.keys.bytes[j & 0xFF] != filter.entry->keyBytes[j & 0xFF]) {
|
||||
filter.matches = ZI8_FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (matches && (param->elementCount % 2) != 0 &&
|
||||
((keys[j & 0xFF] & 0xF0) != (entry->keyBytes[j & 0xFF] & 0xF0))) {
|
||||
matches = ZI8_FALSE;
|
||||
if (filter.matches && (param->elementCount % 2) != 0 &&
|
||||
((filter.keys.bytes[j & 0xFF] & 0xF0) != (filter.entry->keyBytes[j & 0xFF] & 0xF0))) {
|
||||
filter.matches = ZI8_FALSE;
|
||||
}
|
||||
if (matches) {
|
||||
for (candidateIndex = 0; candidateIndex < *count; candidateIndex++) {
|
||||
if (param->candidates[candidateIndex] ==
|
||||
(((ziU16)((ZiKoreanKeyEntry*)tableA)[i].characterHigh << 8) | (ziU16)((ZiKoreanKeyEntry*)tableA)[i].characterLow)) {
|
||||
if (filter.matches) {
|
||||
for (filter.candidateIndex = 0; filter.candidateIndex < *count; filter.candidateIndex++) {
|
||||
if (param->candidates[filter.candidateIndex] ==
|
||||
(((ziU16)((ZiKoreanKeyEntry*)filter.tableA)[i].characterHigh << 8) | (ziU16)((ZiKoreanKeyEntry*)filter.tableA)[i].characterLow)) {
|
||||
matched++;
|
||||
param->candidates[candidateIndex] &= 0x7FFF;
|
||||
param->candidates[filter.candidateIndex] &= 0x7FFF;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -216,10 +225,10 @@ ziU32 Zi8_814834AC(ziGetParam* param, ziU16* remaining, ziU8* count,
|
||||
}
|
||||
*remaining = 0;
|
||||
} else {
|
||||
for (compactIndex = 0; compactIndex < *count; compactIndex++) {
|
||||
if ((param->candidates[compactIndex] & 0x8000) == 0) {
|
||||
param->candidates[compactIndex] |= 0x8000;
|
||||
Zi8_81483308(param, param->candidates[compactIndex], inserted, ZI_WORK);
|
||||
for (filter.compactIndex = 0; filter.compactIndex < *count; filter.compactIndex++) {
|
||||
if ((param->candidates[filter.compactIndex] & 0x8000) == 0) {
|
||||
param->candidates[filter.compactIndex] |= 0x8000;
|
||||
Zi8_81483308(param, param->candidates[filter.compactIndex], inserted, ZI_WORK);
|
||||
}
|
||||
}
|
||||
*remaining = *remaining - matched;
|
||||
@@ -278,7 +287,8 @@ ziU32 Zi8GetKOcandidates(ziGetParam* param, ZiKoreanCandidateOptions* options ZI
|
||||
search.resultCount = 0;
|
||||
search.packedKeys.firstWord = 0;
|
||||
search.packedKeys.bytes[4] = 0;
|
||||
search.wordIndex = search.remainingLetters = 0;
|
||||
search.remainingLetters = 0;
|
||||
search.wordIndex = 0;
|
||||
search.candidateCount = 0;
|
||||
search.keyByte = 0;
|
||||
search.remainingCandidates = param->firstCandidate;
|
||||
@@ -303,8 +313,7 @@ ziU32 Zi8GetKOcandidates(ziGetParam* param, ZiKoreanCandidateOptions* options ZI
|
||||
param->candidates[0] = 0;
|
||||
}
|
||||
Zi8LogError(100, ZI_WORK);
|
||||
if (param->wordCharCount == 0) goto scan_key_table;
|
||||
{
|
||||
if (param->wordCharCount != 0) {
|
||||
if (((search.keyIndex = Zi8_8148302C(param->currentWord[0], keyTable, ZI_WORK)) != 0xFFFF) &&
|
||||
((((ZiKoreanKeyEntry*)(((search.keyIndex << 3) + search.keyIndex) + keyTable))->keyBytes[4] & 8) != 0)) {
|
||||
search.wordOffset = ((ZiKoreanKeyEntry*)(((search.keyIndex << 3) + search.keyIndex) + keyTable))->childLow |
|
||||
@@ -429,7 +438,6 @@ search_table:
|
||||
param->count = search.candidateCount;
|
||||
param->letters = search.candidateCount;
|
||||
}
|
||||
scan_key_table:
|
||||
if (param->elementCount > 9) {
|
||||
param->letters = 0;
|
||||
return 0;
|
||||
|
||||
@@ -21,7 +21,6 @@ ziBool Zi8PrepareMatch(ziGetParam* request, ziMatchParam* match, ziU8 skipMode Z
|
||||
ziWChar bestFinal;
|
||||
ziWChar previousInitial;
|
||||
ziWChar previousFinal;
|
||||
ziBool hasComponent;
|
||||
ziU8 elementCount;
|
||||
ziU8 elementIndex;
|
||||
ziU8 stroke;
|
||||
@@ -44,7 +43,6 @@ ziBool Zi8PrepareMatch(ziGetParam* request, ziMatchParam* match, ziU8 skipMode Z
|
||||
stroke = 0;
|
||||
contextMask = 0x20;
|
||||
Zi8Memset(match,0,0x1ee);
|
||||
hasComponent = 0;
|
||||
nibbles = 0;
|
||||
elementIndex = 0;
|
||||
elementCount = request->elementCount;
|
||||
@@ -60,15 +58,13 @@ ziBool Zi8PrepareMatch(ziGetParam* request, ziMatchParam* match, ziU8 skipMode Z
|
||||
}
|
||||
}
|
||||
if (elementCount != 0) {
|
||||
element = request->elements[0];
|
||||
match->comp = element;
|
||||
match->comp = element = request->elements[0];
|
||||
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->field22 = ((buffers.componentIndex[1] & 0x3f) << 8) + *buffers.componentIndex;
|
||||
match->field22 = (((ziU16)buffers.componentIndex[1] & 0x3f) << 8) + *buffers.componentIndex;
|
||||
buffers.component += (ziU32)match->field22 * 8;
|
||||
switch(*buffers.component & 0xf) {
|
||||
case 0:
|
||||
@@ -223,14 +219,13 @@ ziBool Zi8PrepareMatch(ziGetParam* request, ziMatchParam* match, ziU8 skipMode Z
|
||||
Zi8Memcpy((ziU8 (*)[12])match->segs1 + match->nSeg,buffers.masks,0xc);
|
||||
Zi8Memcpy((ziU8 (*)[12])match->segsD + match->nSeg,buffers.strokes,0xc);
|
||||
match->nSeg++;
|
||||
if (stroke != 0xff || elementIndex >= elementCount || match->nSeg >= 0x10) break;
|
||||
if (stroke != 0xff || elementIndex >= elementCount || match->nSeg >= 0x10) goto complete;
|
||||
Zi8Memset(buffers.masks,0,0xc);
|
||||
Zi8Memset(buffers.strokes,0,0xc);
|
||||
buffers.masks[0] = match->arr1[0] & 0xf0;
|
||||
buffers.strokes[0] = match->arrD[0] & 0xf0;
|
||||
nibbles = 1;
|
||||
} while (1);
|
||||
return 1;
|
||||
}
|
||||
match->length = nibbles;
|
||||
if (elementCount != 0) {
|
||||
@@ -249,13 +244,15 @@ ziBool Zi8PrepareMatch(ziGetParam* request, ziMatchParam* match, ziU8 skipMode Z
|
||||
else {
|
||||
initial = 0;
|
||||
final = 0;
|
||||
bestFinal = bestInitial = 0;
|
||||
previousFinal = previousInitial = 0;
|
||||
bestInitial = 0;
|
||||
bestFinal = 0;
|
||||
previousInitial = 0;
|
||||
previousFinal = 0;
|
||||
buffers.phoneticInput = request->elements;
|
||||
match->nCand = 0;
|
||||
request->completion = request->elementCount;
|
||||
phoneticLength = 1;
|
||||
for (index = 0; index < elementCount;) {
|
||||
for (index = 0; index < elementCount; index++) {
|
||||
stroke = Zi8GetBpmfPhonetic(buffers.phoneticInput,phoneticLength,&initial,&final,&bestInitial,&bestFinal,
|
||||
__zi8_work_data);
|
||||
if (stroke != 0) {
|
||||
@@ -283,8 +280,10 @@ savePhonetic:
|
||||
}
|
||||
if (buffers.phoneticInput[phoneticLength - 1] == 0xF360) {
|
||||
match->nCand--;
|
||||
bestInitial = initial = previousInitial;
|
||||
bestFinal = final = previousFinal;
|
||||
bestInitial = previousInitial;
|
||||
bestFinal = previousFinal;
|
||||
final = bestFinal;
|
||||
initial = bestInitial;
|
||||
goto savePhonetic;
|
||||
}
|
||||
if (match->nCand == 1) {
|
||||
@@ -294,7 +293,6 @@ savePhonetic:
|
||||
phoneticLength = 0;
|
||||
index--;
|
||||
}
|
||||
index++;
|
||||
phoneticLength++;
|
||||
}
|
||||
if (elementCount != 0) {
|
||||
@@ -333,5 +331,6 @@ savePhonetic:
|
||||
}
|
||||
}
|
||||
}
|
||||
complete:
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -242,25 +242,61 @@ L_2b0:
|
||||
blr
|
||||
}
|
||||
|
||||
void _CNTCACHEDeleteTitle() {
|
||||
char* token = strtok(NULL, scCntCacheSpaceNl);
|
||||
|
||||
while (token != NULL) {
|
||||
ESTitleId titleId;
|
||||
int removable;
|
||||
|
||||
errno = 0;
|
||||
titleId = strtoull(token, NULL, 16);
|
||||
if (errno == 0 && (u32)ES_TITLE_TYPE(titleId) != 1) {
|
||||
removable = _CNTCACHEIsTitleRemovable(titleId);
|
||||
if (removable == 1) {
|
||||
ES_DeleteTitle(titleId);
|
||||
} else if (removable == 0) {
|
||||
ES_DeleteTitleContent(titleId);
|
||||
}
|
||||
}
|
||||
token = strtok(NULL, scCntCacheSpaceNl);
|
||||
}
|
||||
asm void _CNTCACHEDeleteTitle() {
|
||||
stwu r1, -0x20(r1)
|
||||
mflr r0
|
||||
li r3, 0
|
||||
la r4, scCntCacheSpaceNl
|
||||
stw r0, 0x24(r1)
|
||||
stw r31, 0x1c(r1)
|
||||
stw r30, 0x18(r1)
|
||||
stw r29, 0x14(r1)
|
||||
stw r28, 0x10(r1)
|
||||
bl strtok
|
||||
li r30, 0
|
||||
li r31, -1
|
||||
b L_370
|
||||
L_304:
|
||||
stw r30, errno(r0)
|
||||
li r4, 0
|
||||
li r5, 0x10
|
||||
bl strtoull
|
||||
lwz r0, errno(r0)
|
||||
mr r28, r4
|
||||
mr r29, r3
|
||||
cmpwi r0, 0
|
||||
bne L_364
|
||||
and r0, r3, r31
|
||||
cmplwi r0, 1
|
||||
beq L_364
|
||||
bl _CNTCACHEIsTitleRemovable
|
||||
cmpwi r3, 1
|
||||
bne L_350
|
||||
mr r4, r28
|
||||
mr r3, r29
|
||||
bl ES_DeleteTitle
|
||||
b L_364
|
||||
L_350:
|
||||
cmpwi r3, 0
|
||||
bne L_364
|
||||
mr r4, r28
|
||||
mr r3, r29
|
||||
bl ES_DeleteTitleContent
|
||||
L_364:
|
||||
li r3, 0
|
||||
la r4, scCntCacheSpaceNl
|
||||
bl strtok
|
||||
L_370:
|
||||
cmpwi r3, 0
|
||||
bne L_304
|
||||
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
|
||||
}
|
||||
|
||||
asm int _CNTCACHEIsTitleRemovable(ESTitleId titleId) {
|
||||
|
||||
@@ -6,6 +6,11 @@ typedef struct FA_NAND_ATTACH {
|
||||
u32 size;
|
||||
} FA_NAND_ATTACH;
|
||||
|
||||
typedef struct FA_ATTACH_REQUEST {
|
||||
FADrvTbl* table;
|
||||
u32 count;
|
||||
} FA_ATTACH_REQUEST;
|
||||
|
||||
FADisk* gOpenDisk[26];
|
||||
FAPartition* gOpenPartition[26];
|
||||
typedef struct FA_DISK_INIT {
|
||||
@@ -29,13 +34,13 @@ static struct {
|
||||
} drvInitFunc = {diskInitTbl, 3};
|
||||
extern s32 pdm_open_disk(FA_DISK_INIT* table, FADisk** disk);
|
||||
extern s32 pdm_open_partition(FADisk* disk, u32 index, FAPartition** partition);
|
||||
extern s32 pfstub_attach(FADrvTbl** drives, const void* nand_data);
|
||||
extern s32 pfstub_attach(FA_ATTACH_REQUEST* request, FA_NAND_ATTACH* nand);
|
||||
extern s32 pfd_sddrv_is_media_insert(void);
|
||||
extern s32 pfd_mscdrv_is_media_insert(FADisk* disk);
|
||||
extern s32 pfd_mscdrv_is_media_insert(void);
|
||||
|
||||
FAError FAAttach(u32 device, char* nand_path, u32 nand_size, FADrvTbl* table) {
|
||||
FADisk* disk;
|
||||
FADrvTbl* drives[2];
|
||||
FA_ATTACH_REQUEST request;
|
||||
FA_NAND_ATTACH nand;
|
||||
s32 error;
|
||||
s32 index;
|
||||
@@ -60,16 +65,16 @@ FAError FAAttach(u32 device, char* nand_path, u32 nand_size, FADrvTbl* table) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
drives[0] = table;
|
||||
drives[1] = NULL;
|
||||
request.table = table;
|
||||
request.count = 0;
|
||||
if (device == 2) {
|
||||
memcpy(nand.path, nand_path, 78);
|
||||
nand.size = nand_size;
|
||||
}
|
||||
if (device == 2) {
|
||||
error = pfstub_attach(drives, &nand);
|
||||
error = pfstub_attach(&request, &nand);
|
||||
} else {
|
||||
error = pfstub_attach(drives, NULL);
|
||||
error = pfstub_attach(&request, NULL);
|
||||
}
|
||||
if (error != 0) {
|
||||
return -1;
|
||||
@@ -80,11 +85,11 @@ FAError FAAttach(u32 device, char* nand_path, u32 nand_size, FADrvTbl* table) {
|
||||
gOpenPartition[index] = table->pPart;
|
||||
if (device == 0) {
|
||||
if (pfd_sddrv_is_media_insert()) {
|
||||
drives[0]->stat |= 0x10;
|
||||
request.table->stat |= 0x10;
|
||||
}
|
||||
} else if (device == 1) {
|
||||
if (pfd_mscdrv_is_media_insert(disk)) {
|
||||
drives[0]->stat |= 0x10;
|
||||
if (pfd_mscdrv_is_media_insert()) {
|
||||
request.table->stat |= 0x10;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
static FAEjectCallback g_detach_func;
|
||||
static FAInsertCallback g_attach_func;
|
||||
|
||||
extern s32 uhf_msc_is_media_insert(FADisk* disk);
|
||||
extern s32 uhf_msc_is_media_insert(void);
|
||||
|
||||
s32 pfd_mscdrv_registar_callback(FAInsertCallback insert, FAEjectCallback eject) {
|
||||
g_attach_func = insert;
|
||||
@@ -11,6 +11,6 @@ s32 pfd_mscdrv_registar_callback(FAInsertCallback insert, FAEjectCallback eject)
|
||||
return 0;
|
||||
}
|
||||
|
||||
s32 pfd_mscdrv_is_media_insert(FADisk* disk) {
|
||||
return uhf_msc_is_media_insert(disk);
|
||||
s32 pfd_mscdrv_is_media_insert(void) {
|
||||
return uhf_msc_is_media_insert();
|
||||
}
|
||||
|
||||
@@ -318,58 +318,58 @@ s32 pfd_sddrv_init(FADisk* disk) {
|
||||
}
|
||||
if ((pfd_sddrv_flags(&g_pfd_sddrv_info) & 1) != 0) {
|
||||
OSReport("INFO SD Card driver is already initialize. pfd_sddrv_init()\n");
|
||||
if (disk != g_pfd_sddrv_info.disk) {
|
||||
return -44;
|
||||
if (disk == g_pfd_sddrv_info.disk) {
|
||||
return 0;
|
||||
}
|
||||
return -44;
|
||||
}
|
||||
if ((g_pfd_sddrv_info.flags & 4) == 0) {
|
||||
g_pfd_sddrv_info.bytes_per_sector = 0x200;
|
||||
pf_memset(&g_pfd_sddev, 0, 0x28);
|
||||
sd_result = ISD_InitCard();
|
||||
if (sd_result != 0) {
|
||||
OSReport("ERR:Failed to init SD Card Driver in pfd_sddrv_init()\n");
|
||||
return -40;
|
||||
}
|
||||
g_pfd_sddrv_info.flags |= 4;
|
||||
}
|
||||
pf_memset(&g_pfd_sddev, 0, 0x28);
|
||||
device = &g_pfd_sddev.device;
|
||||
sd_result = ISD_MountCard(0, &device);
|
||||
if (sd_result != 0) {
|
||||
OSReport("ERR SD card can not mount [ret = 0x%x]. pfd_sddrv_init()\n", sd_result);
|
||||
return -41;
|
||||
}
|
||||
sd_result = ISD_GetDeviceStatus(device, &status);
|
||||
if (sd_result != 0) {
|
||||
OSReport("ERR Failed to get sd card status. [ret = 0x%x]\n", sd_result);
|
||||
return 21;
|
||||
}
|
||||
if ((status & 1) != 0) {
|
||||
g_pfd_sddrv_info.media_inserted = 1;
|
||||
}
|
||||
g_pfd_sddrv_info.device = device;
|
||||
if (g_pfd_sddrv_info.media_inserted != 0) {
|
||||
g_event = 2;
|
||||
sd_result = ISD_RegisterDeviceIntrHandler(device, (SDDevIntrCallback)pfd_st_removal_callback, &g_event);
|
||||
if (sd_result != 0) {
|
||||
OSReport("ERR:Failed to regist intr handler1 [ret = 0x%x] pfd_sddrv_init()\n", sd_result);
|
||||
ISD_UnmountCard(device);
|
||||
g_pfd_sddrv_info.device = 0;
|
||||
return -42;
|
||||
}
|
||||
} else {
|
||||
if ((g_pfd_sddrv_info.flags & 4) == 0) {
|
||||
g_pfd_sddrv_info.bytes_per_sector = 0x200;
|
||||
pf_memset(&g_pfd_sddev, 0, 0x28);
|
||||
sd_result = ISD_InitCard();
|
||||
if (sd_result != 0) {
|
||||
OSReport("ERR:Failed to init SD Card Driver in pfd_sddrv_init()\n");
|
||||
return -40;
|
||||
}
|
||||
g_pfd_sddrv_info.flags |= 4;
|
||||
}
|
||||
pf_memset(&g_pfd_sddev, 0, 0x28);
|
||||
device = &g_pfd_sddev.device;
|
||||
sd_result = ISD_MountCard(0, &device);
|
||||
g_event = 1;
|
||||
sd_result = ISD_RegisterDeviceIntrHandler(device, (SDDevIntrCallback)pfd_st_inter_callback, &g_event);
|
||||
if (sd_result != 0) {
|
||||
OSReport("ERR SD card can not mount [ret = 0x%x]. pfd_sddrv_init()\n", sd_result);
|
||||
return -41;
|
||||
OSReport("ERR:Failed to regist intr handler1 [ret = 0x%x] pfd_sddrv_init()\n", sd_result);
|
||||
ISD_UnmountCard(device);
|
||||
g_pfd_sddrv_info.device = 0;
|
||||
return -42;
|
||||
}
|
||||
sd_result = ISD_GetDeviceStatus(device, &status);
|
||||
if (sd_result != 0) {
|
||||
OSReport("ERR Failed to get sd card status. [ret = 0x%x]\n", sd_result);
|
||||
return 21;
|
||||
}
|
||||
if ((status & 1) != 0) {
|
||||
g_pfd_sddrv_info.media_inserted = 1;
|
||||
}
|
||||
g_pfd_sddrv_info.device = device;
|
||||
if (g_pfd_sddrv_info.media_inserted != 0) {
|
||||
g_event = 2;
|
||||
sd_result = ISD_RegisterDeviceIntrHandler(device, (SDDevIntrCallback)pfd_st_removal_callback, &g_event);
|
||||
if (sd_result != 0) {
|
||||
OSReport("ERR:Failed to regist intr handler1 [ret = 0x%x] pfd_sddrv_init()\n", sd_result);
|
||||
ISD_UnmountCard(device);
|
||||
g_pfd_sddrv_info.device = 0;
|
||||
return -42;
|
||||
}
|
||||
} else {
|
||||
g_event = 1;
|
||||
sd_result = ISD_RegisterDeviceIntrHandler(device, (SDDevIntrCallback)pfd_st_inter_callback, &g_event);
|
||||
if (sd_result != 0) {
|
||||
OSReport("ERR:Failed to regist intr handler1 [ret = 0x%x] pfd_sddrv_init()\n", sd_result);
|
||||
ISD_UnmountCard(device);
|
||||
g_pfd_sddrv_info.device = 0;
|
||||
return -42;
|
||||
}
|
||||
}
|
||||
g_pfd_sddrv_info.disk = disk;
|
||||
g_pfd_sddrv_info.flags |= 1;
|
||||
}
|
||||
g_pfd_sddrv_info.disk = disk;
|
||||
g_pfd_sddrv_info.flags |= 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -749,8 +749,7 @@ s32 pfd_sddrv_get_total_sectors(u32* sectors, u16* bytes_per_sector) {
|
||||
minimum_multiplier = multiplier >= 9 ? multiplier : 9;
|
||||
max_multiplier = minimum_multiplier <= 11 ? minimum_multiplier : 11;
|
||||
multiplier_factor = 1;
|
||||
max_multiplier = (u16)(max_multiplier - 9);
|
||||
multiplier_factor = (u16)(multiplier_factor << max_multiplier);
|
||||
multiplier_factor <<= (u16)(max_multiplier - 9);
|
||||
*sectors = cluster_blocks * multiplier_factor;
|
||||
} else {
|
||||
*sectors = ((csd[1] >> 8 & 0x3fffff) + 1) * 0x400;
|
||||
@@ -1361,20 +1360,19 @@ s32 pfd_sddrv_store_fat32_bpb_buf(PFD_SDDRV_FORMAT_DATA* format_data, u8* sector
|
||||
|
||||
static s32 pfd_sddrv_store_fat32_reserved_buf(u8* sector_buffer) {
|
||||
PFD_SDDRV_RESERVED_BOOT_SECTOR* reserved_boot_sector;
|
||||
s32 result = -30;
|
||||
|
||||
if (sector_buffer != 0) {
|
||||
pf_memset(sector_buffer, 0, 0x200);
|
||||
reserved_boot_sector = (PFD_SDDRV_RESERVED_BOOT_SECTOR*)sector_buffer;
|
||||
if (((u32)reserved_boot_sector->signature.bytes & 1) != 0) {
|
||||
reserved_boot_sector->signature.bytes[0] = 0x55;
|
||||
reserved_boot_sector->signature.bytes[1] = 0xaa;
|
||||
} else {
|
||||
reserved_boot_sector->signature.value = 0x55aa;
|
||||
}
|
||||
result = 0;
|
||||
if (sector_buffer == 0) {
|
||||
return -30;
|
||||
}
|
||||
return result;
|
||||
pf_memset(sector_buffer, 0, 0x200);
|
||||
reserved_boot_sector = (PFD_SDDRV_RESERVED_BOOT_SECTOR*)sector_buffer;
|
||||
if (((u32)reserved_boot_sector->signature.bytes & 1) != 0) {
|
||||
reserved_boot_sector->signature.bytes[0] = 0x55;
|
||||
reserved_boot_sector->signature.bytes[1] = 0xaa;
|
||||
} else {
|
||||
reserved_boot_sector->signature.value = 0x55aa;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
s32 pfd_sddrv_build_fat32_mbr_bpb(u32 total_sectors) {
|
||||
|
||||
@@ -1,32 +1,25 @@
|
||||
#include <private/fa/pdm.h>
|
||||
#include <revolution/types.h>
|
||||
#define MBR_WORD(buf, offset) \
|
||||
((pf_u32)(buf)[offset] + ((pf_u32)(buf)[(offset) + 1] << 8) + \
|
||||
((pf_u32)(buf)[(offset) + 2] << 16) + ((pf_u32)(buf)[(offset) + 3] << 24))
|
||||
#define MBR_WORD(buf, offset) (((pf_u32)(buf)[(offset) + 3] << 24) + ((pf_u32)(buf)[(offset) + 2] << 16) + ((pf_u32)(buf)[(offset) + 1] << 8) + (buf)[offset])
|
||||
static inline pf_u16 read_boot_u16(pf_u8* buf, pf_u32 offset) {
|
||||
if ((pf_u32)&buf[offset] & 1) { return (buf[offset + 1] << 8) | buf[offset]; }
|
||||
return PF_SWAP_16(*(pf_u16*)&buf[(offset + 1) & ~1]);
|
||||
}
|
||||
|
||||
static inline pf_u32 read_partition_u32(const pf_u8* buf, pf_u32 offset) {
|
||||
return (((pf_u32)buf[offset + 2] << 16) + buf[offset]) +
|
||||
(((pf_u32)buf[offset + 3] << 24) + ((pf_u32)buf[offset + 1] << 8));
|
||||
}
|
||||
|
||||
pf_s32 pdm_part_is_master_boot_sector(pf_u8* buf, pf_u32 total, pf_bool* p_is_mbr) {
|
||||
pf_u32* p_start;
|
||||
pf_u32* p_count;
|
||||
pf_s16 index;
|
||||
pf_u32 start[4];
|
||||
pf_u32 count[4];
|
||||
pf_u32* p_start;
|
||||
pf_u32* p_count;
|
||||
*p_is_mbr = 0;
|
||||
if (buf[510] != 0x55 || buf[511] != 0xAA) { return 2; }
|
||||
p_start = start;
|
||||
p_count = count;
|
||||
for (index = 0; index < 4; index++) {
|
||||
*p_start = 0;
|
||||
*p_start = read_partition_u32(buf, 454);
|
||||
*p_count = read_partition_u32(buf, 458);
|
||||
*p_start = (((pf_u32)buf[456] << 16) + buf[454]) + (((pf_u32)buf[457] << 24) + ((pf_u32)buf[455] << 8));
|
||||
*p_count = (((pf_u32)buf[460] << 16) + buf[458]) + (((pf_u32)buf[461] << 24) + ((pf_u32)buf[459] << 8));
|
||||
if (*p_start != 0 && *p_count != 0) {
|
||||
if (index == 0) { *p_is_mbr = 1; }
|
||||
} else {
|
||||
@@ -78,20 +71,15 @@ pf_bool pdm_part_is_boot_sector(pf_u8* buf) {
|
||||
return is_boot;
|
||||
}
|
||||
|
||||
static inline pf_u32 read_relative_start_sector(pf_u32 base, const pf_u8* buf, pf_u32 offset) {
|
||||
return base + (buf[offset] + ((unsigned int)buf[offset + 1] << 8) +
|
||||
((unsigned int)buf[offset + 2] << 16) + ((unsigned int)buf[offset + 3] << 24));
|
||||
}
|
||||
|
||||
pf_s32 pdm_part_get_start_sector(PDM_PARTITION* p_part) {
|
||||
pf_u32 part_index = 0;
|
||||
pf_u32 requested = p_part->part_id;
|
||||
pf_u32 start[4];
|
||||
pf_u32 count[4];
|
||||
pf_u32 part_index = 0;
|
||||
pf_u32 sector;
|
||||
pf_u32 base;
|
||||
pf_u16 index;
|
||||
pf_u16 extended_index;
|
||||
pf_u32 base;
|
||||
pf_u32 sector;
|
||||
pf_u32 length;
|
||||
pf_bool is_mbr;
|
||||
pf_u32 success;
|
||||
@@ -124,14 +112,14 @@ pf_s32 pdm_part_get_start_sector(PDM_PARTITION* p_part) {
|
||||
sector = base;
|
||||
for (extended_index = 0; extended_index < 2; extended_index++) {
|
||||
if (extended_index == 0) {
|
||||
sector = read_relative_start_sector(sector, buf, 454);
|
||||
sector = sector + MBR_WORD(buf, 454);
|
||||
length = MBR_WORD(buf, 458);
|
||||
err = pdm_disk_physical_read(p_part->p_disk, buf, sector, 1, 512, &success);
|
||||
if (err != 0) { return err; }
|
||||
if (requested == part_index) { p_part->start_sector = sector; p_part->total_sector = length; return 0; }
|
||||
part_index++;
|
||||
} else {
|
||||
sector = read_relative_start_sector(base, buf, 470);
|
||||
sector = base + MBR_WORD(buf, 470);
|
||||
length = MBR_WORD(buf, 474);
|
||||
if (sector == 0 || length == 0) { break; }
|
||||
err = pdm_disk_physical_read(p_part->p_disk, buf, sector, 1, 512, &success);
|
||||
|
||||
@@ -550,6 +550,15 @@ pf_s32 PFCACHE_DoWriteSector(PF_VOLUME* p_vol, PF_CACHE_PAGE** pp_head, const pf
|
||||
|
||||
#pragma dont_inline reset
|
||||
|
||||
static inline pf_u32 PFCACHE_RecordPageEndOverlap(PF_CACHE_PAGE* p_page, pf_u32 end_sector, pf_u32* p_num_success, pf_u32* p_num_rest_sector) {
|
||||
pf_u32 last_sector = end_sector - 1;
|
||||
pf_u32 num_overlap = end_sector - p_page->sector;
|
||||
*p_num_success += num_overlap;
|
||||
*p_num_rest_sector -= num_overlap;
|
||||
p_page->stat |= 2;
|
||||
return last_sector;
|
||||
}
|
||||
|
||||
pf_s32 PFCACHE_DoWriteNumSectorAndFreeIfNeeded(PF_VOLUME* p_vol, PF_CACHE_PAGE** pp_head, const pf_u8* p_buf, pf_u32 sector,
|
||||
pf_u32 num_sector, pf_u32* p_num_success) {
|
||||
PF_CACHE_PAGE* p_page = PF_NULL;
|
||||
@@ -557,6 +566,8 @@ pf_s32 PFCACHE_DoWriteNumSectorAndFreeIfNeeded(PF_VOLUME* p_vol, PF_CACHE_PAGE**
|
||||
pf_u32 num_rest_sector = num_sector;
|
||||
pf_u8* p_sbuf;
|
||||
pf_u8* p_ebuf;
|
||||
pf_u32 num_overlap;
|
||||
pf_u32 last_sector;
|
||||
*p_num_success = 0;
|
||||
do {
|
||||
if (p_page == PF_NULL) {
|
||||
@@ -606,10 +617,10 @@ pf_s32 PFCACHE_DoWriteNumSectorAndFreeIfNeeded(PF_VOLUME* p_vol, PF_CACHE_PAGE**
|
||||
(p_page->sector + p_page->size) >= (sector + num_sector)) {
|
||||
pf_memcpy(p_page->buffer, (pf_u8*)&p_buf[(p_page->sector - sector) << p_vol->bpb.log2_bytes_per_sector],
|
||||
(sector + num_sector - p_page->sector) << p_vol->bpb.log2_bytes_per_sector);
|
||||
num_rest_sector -= p_page->size - ((p_page->sector + p_page->size) - (sector + num_sector));
|
||||
*p_num_success += p_page->size - ((p_page->sector + p_page->size) - (sector + num_sector));
|
||||
p_page->stat |= 2;
|
||||
p_ebuf = &p_page->buffer[(p_page->size - ((p_page->sector + p_page->size) - (sector + num_sector)) - 1) << p_vol->bpb.log2_bytes_per_sector];
|
||||
num_overlap = num_sector;
|
||||
num_overlap += sector;
|
||||
last_sector = PFCACHE_RecordPageEndOverlap(p_page, num_overlap, p_num_success, &num_rest_sector);
|
||||
p_ebuf = &p_page->buffer[(last_sector - p_page->sector) << p_vol->bpb.log2_bytes_per_sector];
|
||||
p_page->p_mod_sbuf = p_page->buffer;
|
||||
if (p_page->p_mod_ebuf == NULL || p_page->p_mod_ebuf < p_ebuf) {
|
||||
p_page->p_mod_ebuf = p_ebuf;
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
#include <revolution/fa/pf_stub.h>
|
||||
|
||||
s32 pfstub_attach(FADrvTbl** drives, const void* nand_data) {
|
||||
s32 pfstub_attach(FADrvTbl* drives, u32 mode) {
|
||||
PF_STUB_MESSAGE message;
|
||||
|
||||
message.operation = 27;
|
||||
message.object = drives;
|
||||
message.callback = NULL;
|
||||
message.data = nand_data;
|
||||
message.data = (void*)mode;
|
||||
if (pfstub_com_massage(&message) == -1) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -557,14 +557,18 @@ static void kbdSendKey(KBDKeyEventData* event) {
|
||||
}
|
||||
}
|
||||
|
||||
static inline u32 kbdChannelFlags(u32 channel) {
|
||||
return kbdData[channel].flags;
|
||||
}
|
||||
|
||||
static void kbd_led_handler(BOOL success, void* callbackArg) {
|
||||
const KBDLEDCallbackData* callback;
|
||||
s32 index;
|
||||
u32 index;
|
||||
u32 err;
|
||||
index = (s32)callbackArg;
|
||||
index = (u32)callbackArg;
|
||||
callback = &kbdLCBuf[index];
|
||||
kbdCmdBuf[index].device = 0;
|
||||
if (callback->callbackAddress == (USBKBDCmdLEDCallback)(u32)kbdCmdBuf[(u32)callbackArg].device) {
|
||||
if (callback->callbackAddress == (USBKBDCmdLEDCallback)(u32)kbdCmdBuf[index].device) {
|
||||
return;
|
||||
}
|
||||
switch (success) {
|
||||
@@ -575,12 +579,13 @@ static void kbd_led_handler(BOOL success, void* callbackArg) {
|
||||
err = 0;
|
||||
break;
|
||||
}
|
||||
kbdLCBuf[(u32)callbackArg].callbackAddress(err, kbdLCBuf[(u32)callbackArg].callbackArg);
|
||||
kbdLCBuf[index].callbackAddress(err, kbdLCBuf[index].callbackArg);
|
||||
}
|
||||
|
||||
USBKBDErr KBDSetLedsAsync(u32 channel, u32 leds, USBKBDCmdLEDCallback callback, void* callbackArg) {
|
||||
s32 index;
|
||||
u32 ofs;
|
||||
u8 ledBits;
|
||||
u32 index;
|
||||
BOOL interrupts;
|
||||
USBKBDErr result;
|
||||
if (!kbdInitialized) {
|
||||
@@ -589,18 +594,14 @@ USBKBDErr KBDSetLedsAsync(u32 channel, u32 leds, USBKBDCmdLEDCallback callback,
|
||||
if (channel >= 4) {
|
||||
return 4;
|
||||
}
|
||||
{
|
||||
KBDChannel* data = &kbdData[(s32)channel];
|
||||
if ((s32)data->flags == 1 || (s32)data->flags == 4) {
|
||||
return 5;
|
||||
}
|
||||
if ((s32)kbdChannelFlags(channel) == 1 || (s32)kbdChannelFlags(channel) == 4) {
|
||||
return 5;
|
||||
}
|
||||
ledBits = leds;
|
||||
interrupts = OSDisableInterrupts();
|
||||
for (index = 0; index < 12; index++) {
|
||||
if (kbdCmdBuf[(s32)index].device == 0) {
|
||||
KBDChannel* data = &kbdData[channel];
|
||||
kbdCmdBuf[(s32)index].device = (u32)data->device;
|
||||
for (index = 0, ofs = 0; index < 12; index++, ofs += sizeof(KBDLEDCommand)) {
|
||||
if (*(u32*)&((u8*)kbdCmdBuf)[ofs] == 0) {
|
||||
*(u32*)&((u8*)kbdCmdBuf)[ofs] = (u32)kbdData[channel].device;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -608,14 +609,11 @@ USBKBDErr KBDSetLedsAsync(u32 channel, u32 leds, USBKBDCmdLEDCallback callback,
|
||||
if (index == 12) {
|
||||
return 7;
|
||||
}
|
||||
{
|
||||
KBDChannel* data = &kbdData[channel];
|
||||
kbdLCBuf[index].callbackAddress = callback;
|
||||
kbdLCBuf[index].callbackArg = callbackArg;
|
||||
result = USBKBDSetLEDAsync((u32)data->device, ledBits,
|
||||
(USBKBDCmdLEDAsync*)&kbdCmdBuf[index],
|
||||
kbd_led_handler, (void*)index);
|
||||
}
|
||||
kbdLCBuf[index].callbackAddress = callback;
|
||||
kbdLCBuf[index].callbackArg = callbackArg;
|
||||
result = USBKBDSetLEDAsync((u32)kbdData[channel].device, ledBits,
|
||||
(USBKBDCmdLEDAsync*)&kbdCmdBuf[index],
|
||||
kbd_led_handler, (void*)index);
|
||||
switch (result) {
|
||||
default:
|
||||
return 7;
|
||||
@@ -626,6 +624,7 @@ USBKBDErr KBDSetLedsAsync(u32 channel, u32 leds, USBKBDCmdLEDCallback callback,
|
||||
|
||||
USBKBDErr KBDSetLeds(u32 channel, u32 leds) {
|
||||
u32 index;
|
||||
KBDLEDCommand* command;
|
||||
BOOL interrupts;
|
||||
USBKBDErr result;
|
||||
u8 ledBits;
|
||||
@@ -635,16 +634,20 @@ USBKBDErr KBDSetLeds(u32 channel, u32 leds) {
|
||||
if (channel >= 4) {
|
||||
return 4;
|
||||
}
|
||||
if ((s32)kbdData[(s32)channel].flags == 1 || (s32)kbdData[(s32)channel].flags == 4) {
|
||||
if ((s32)kbdChannelFlags(channel) == 1 || (s32)kbdChannelFlags(channel) == 4) {
|
||||
return 5;
|
||||
}
|
||||
ledBits = leds & 0xff;
|
||||
interrupts = OSDisableInterrupts();
|
||||
for (index = 0; index < 12; index++) {
|
||||
if (kbdCmdBuf[(s32)index].device == 0) {
|
||||
kbdCmdBuf[(s32)index].device = (u32)kbdData[channel].device;
|
||||
index = 0;
|
||||
command = kbdCmdBuf;
|
||||
while (index < 12) {
|
||||
if (command->device == 0) {
|
||||
command->device = (u32)kbdData[channel].device;
|
||||
break;
|
||||
}
|
||||
index++;
|
||||
command++;
|
||||
}
|
||||
OSRestoreInterrupts(interrupts);
|
||||
if (index == 12) {
|
||||
@@ -652,7 +655,7 @@ USBKBDErr KBDSetLeds(u32 channel, u32 leds) {
|
||||
}
|
||||
result = USBKBDSetLED((u32)kbdData[channel].device, ledBits,
|
||||
(USBKBDCmdLED*)&kbdCmdBuf[index]);
|
||||
kbdCmdBuf[(s32)index].device = 0;
|
||||
kbdCmdBuf[index].device = 0;
|
||||
switch (result) {
|
||||
default:
|
||||
return 7;
|
||||
|
||||
@@ -571,14 +571,8 @@ static inline f32 clamp_acc_value(f32 value, f32 limit) {
|
||||
}
|
||||
|
||||
static inline void smooth_acc_value(KPADInside* kpad, f32 value, f32* result) {
|
||||
f32 amount;
|
||||
f32 delta;
|
||||
delta = value - *result;
|
||||
if (delta < 0.0f) {
|
||||
amount = -delta;
|
||||
} else {
|
||||
amount = delta;
|
||||
}
|
||||
f32 delta = value - *result;
|
||||
f32 amount = delta < 0.0f ? -delta : delta;
|
||||
if (amount >= kpad->value9C) {
|
||||
amount = 1.0f;
|
||||
} else {
|
||||
@@ -618,16 +612,12 @@ static void read_kpad_acc(KPADInside* kpad, KPADSample* status) {
|
||||
kpad->status.acc_speed = (f32)sqrt(previous.z * previous.z + (previous.x * previous.x + previous.y * previous.y));
|
||||
calc_acc_horizon(kpad);
|
||||
calc_acc_vertical(kpad);
|
||||
if (status->error == 0 && status->device == 1) {
|
||||
if (status->dataFormat == 4) {
|
||||
goto read_extension_acceleration;
|
||||
}
|
||||
if (status->dataFormat == 5) {
|
||||
goto read_extension_acceleration;
|
||||
}
|
||||
if (status->error != 0 || status->device != 1) {
|
||||
return;
|
||||
}
|
||||
if (status->dataFormat != 4 && status->dataFormat != 5) {
|
||||
return;
|
||||
}
|
||||
return;
|
||||
read_extension_acceleration:
|
||||
{
|
||||
Vec extensionPrevious;
|
||||
raw.x = clamp_acc_value((f32)-(s32)status->extension.fs.accX * kpad->value4E8, kp_fs_acc_max);
|
||||
@@ -949,20 +939,15 @@ static void calc_dpd_variable(KPADInside* kpad, s8 valid) {
|
||||
f32 dx;
|
||||
f32 next;
|
||||
dx = value - kpad->status.dist;
|
||||
if (dx < 0.0f) {
|
||||
magnitude = -dx;
|
||||
} else {
|
||||
magnitude = dx;
|
||||
}
|
||||
magnitude = dx < 0.0f ? -dx : dx;
|
||||
if (magnitude >= kpad->value94) {
|
||||
magnitude = 1.0f;
|
||||
} else {
|
||||
magnitude /= kpad->value94;
|
||||
magnitude = magnitude / kpad->value94;
|
||||
magnitude *= magnitude;
|
||||
magnitude *= magnitude;
|
||||
}
|
||||
magnitude *= kpad->value98;
|
||||
next = magnitude * dx;
|
||||
next = magnitude * kpad->value98 * dx;
|
||||
kpad->status.dist_vec = next;
|
||||
if (next < 0.0f) {
|
||||
kpad->status.dist_speed = -next;
|
||||
@@ -973,15 +958,12 @@ static void calc_dpd_variable(KPADInside* kpad, s8 valid) {
|
||||
}
|
||||
}
|
||||
{
|
||||
f32 midpointFactor = 0.5f;
|
||||
f32 scaleX = midpointFactor * (kpad->dpdState.candidates[0].x + kpad->dpdState.candidates[1].x);
|
||||
f32 scaleY = midpointFactor * (kpad->dpdState.candidates[0].y + kpad->dpdState.candidates[1].y);
|
||||
f32 rotatedX = kpad->dpdObjectDirection.x * kpad->horizonTangent.x + kpad->dpdObjectDirection.y * kpad->horizonTangent.y;
|
||||
f32 rotatedX = kpad->horizonTangent.x * kpad->dpdObjectDirection.x + kpad->horizonTangent.y * kpad->dpdObjectDirection.y;
|
||||
f32 rotatedY = -kpad->dpdObjectDirection.y * kpad->horizonTangent.x + kpad->dpdObjectDirection.x * kpad->horizonTangent.y;
|
||||
f32 transformedX = rotatedX * scaleX - rotatedY * scaleY;
|
||||
f32 transformedY = rotatedY * scaleX + rotatedX * scaleY;
|
||||
delta.x = kpad->sensorBarScale * (kpad->sensorBarCenter.x - transformedX);
|
||||
delta.y = kpad->sensorBarScale * (kpad->sensorBarCenter.y - transformedY);
|
||||
f32 scaleX = 0.5f * (kpad->dpdState.candidates[0].x + kpad->dpdState.candidates[1].x);
|
||||
f32 scaleY = 0.5f * (kpad->dpdState.candidates[0].y + kpad->dpdState.candidates[1].y);
|
||||
delta.x = kpad->sensorBarScale * (kpad->sensorBarCenter.x - (rotatedX * scaleX - rotatedY * scaleY));
|
||||
delta.y = kpad->sensorBarScale * (kpad->sensorBarCenter.y - (rotatedY * scaleX + rotatedX * scaleY));
|
||||
point.x = -kpad->accelNormal.y * delta.x + kpad->accelNormal.x * delta.y;
|
||||
point.y = -kpad->accelNormal.x * delta.x - kpad->accelNormal.y * delta.y;
|
||||
if (kpad->status.dpd_valid_fg == 0) {
|
||||
@@ -1314,9 +1296,6 @@ static void read_kpad_stick(KPADInside* kpad, KPADSample* status) {
|
||||
}
|
||||
|
||||
s32 KPADRead(s32 chan, KPADStatus* statuses, u32 count) {
|
||||
u32 changed;
|
||||
u16 heldButtons;
|
||||
KPADStatus* output;
|
||||
KPADInside* kpad = &inside_kpads[chan];
|
||||
s32 probe;
|
||||
BOOL interruptState;
|
||||
@@ -1324,15 +1303,17 @@ s32 KPADRead(s32 chan, KPADStatus* statuses, u32 count) {
|
||||
u32 ringCount;
|
||||
s32 start;
|
||||
s32 sampleIndex;
|
||||
s32 remaining;
|
||||
u32 remaining;
|
||||
u32 remainingSamples;
|
||||
u32 buttons;
|
||||
u16 previousButtons;
|
||||
u32 coreButtons;
|
||||
u32 changed;
|
||||
u32 extensionButtons;
|
||||
u32 coreButtons;
|
||||
u8 device;
|
||||
KPADSample latestSample;
|
||||
KPADSample* sample;
|
||||
KPADStatus* output;
|
||||
if (WPADGetStatus() != 3) {
|
||||
return 0;
|
||||
}
|
||||
@@ -1366,19 +1347,19 @@ s32 KPADRead(s32 chan, KPADStatus* statuses, u32 count) {
|
||||
if (available > count) {
|
||||
available = count;
|
||||
}
|
||||
remaining = available;
|
||||
kpad->ringCount = 0;
|
||||
output = statuses + remaining;
|
||||
start = kpad->ringIndex - available;
|
||||
if (start < 0) {
|
||||
start += 16;
|
||||
}
|
||||
--output;
|
||||
{
|
||||
KPADStatus* copyOutput;
|
||||
sampleIndex = start;
|
||||
remaining = available;
|
||||
copyOutput = statuses + (available - 1);
|
||||
while (--remaining != 0) {
|
||||
output--;
|
||||
*(KPADSample*)output = kpad->ringData[sampleIndex];
|
||||
copyOutput--;
|
||||
*(KPADSample*)copyOutput = kpad->ringData[sampleIndex];
|
||||
sampleIndex++;
|
||||
if (sampleIndex >= 16) {
|
||||
sampleIndex = 0;
|
||||
@@ -1391,7 +1372,7 @@ s32 KPADRead(s32 chan, KPADStatus* statuses, u32 count) {
|
||||
WPADAccGravityUnit gravity = {1, 1, 1};
|
||||
WPADAccGravityUnit extensionGravity = {1, 1, 1};
|
||||
WPADGetAccGravityUnit(chan, WPAD_ACC_GRAVITY_UNIT_CORE, &gravity);
|
||||
if (gravity.x * gravity.y * gravity.z != 0) {
|
||||
if (gravity.z * gravity.x * gravity.y != 0) {
|
||||
kpad->value4DC = 1.0f / gravity.x;
|
||||
kpad->value4E0 = 1.0f / gravity.y;
|
||||
kpad->value4E4 = 1.0f / gravity.z;
|
||||
@@ -1401,7 +1382,7 @@ s32 KPADRead(s32 chan, KPADStatus* statuses, u32 count) {
|
||||
kpad->value4E4 = 0.01f;
|
||||
}
|
||||
WPADGetAccGravityUnit(chan, WPAD_ACC_GRAVITY_UNIT_FS, &extensionGravity);
|
||||
if (extensionGravity.x * extensionGravity.y * extensionGravity.z != 0) {
|
||||
if (extensionGravity.z * extensionGravity.x * extensionGravity.y != 0) {
|
||||
kpad->value4E8 = 1.0f / extensionGravity.x;
|
||||
kpad->value4EC = 1.0f / extensionGravity.y;
|
||||
kpad->value4F0 = 1.0f / extensionGravity.z;
|
||||
@@ -1414,8 +1395,8 @@ s32 KPADRead(s32 chan, KPADStatus* statuses, u32 count) {
|
||||
output = statuses + available;
|
||||
--output;
|
||||
device = 0xFD;
|
||||
extensionButtons = 0xFFFF;
|
||||
coreButtons = 0xFFFF;
|
||||
extensionButtons = 0xFFFF;
|
||||
buttons = 0xFFFF;
|
||||
do {
|
||||
output--;
|
||||
@@ -1452,20 +1433,18 @@ s32 KPADRead(s32 chan, KPADStatus* statuses, u32 count) {
|
||||
if (extensionButtons == 0xFFFF) {
|
||||
extensionButtons = kpad->status.ex_status.cl.hold;
|
||||
}
|
||||
buttons = (buttons & 0x9FFF) | (coreButtons & 0x6000);
|
||||
previousButtons = kpad->status.hold;
|
||||
heldButtons = (buttons & 0x9FFF) | (coreButtons & 0x6000);
|
||||
changed = heldButtons ^ previousButtons;
|
||||
kpad->status.hold = heldButtons;
|
||||
kpad->status.trig = changed & heldButtons;
|
||||
changed = previousButtons ^ buttons;
|
||||
kpad->status.hold = buttons;
|
||||
kpad->status.trig = changed & buttons;
|
||||
kpad->status.release = changed & previousButtons;
|
||||
if (device == 2) {
|
||||
u16 previousExtensionButtons;
|
||||
previousExtensionButtons = kpad->status.ex_status.cl.hold;
|
||||
extensionButtons = (u16)extensionButtons;
|
||||
kpad->status.ex_status.cl.hold = extensionButtons;
|
||||
changed = extensionButtons ^ previousExtensionButtons;
|
||||
previousButtons = kpad->status.ex_status.cl.hold;
|
||||
kpad->status.ex_status.cl.hold = (u16)extensionButtons;
|
||||
changed = previousButtons ^ (u16)extensionButtons;
|
||||
kpad->status.ex_status.cl.trig = changed & extensionButtons;
|
||||
kpad->status.ex_status.cl.release = changed & previousExtensionButtons;
|
||||
kpad->status.ex_status.cl.release = changed & previousButtons;
|
||||
}
|
||||
calc_button_repeat(kpad, device, ringCount);
|
||||
remainingSamples = available;
|
||||
@@ -1510,6 +1489,7 @@ void KPADInit(void) {
|
||||
f32 zero;
|
||||
f32 degreesToRadians;
|
||||
f32 one;
|
||||
f32* matrix;
|
||||
u32 i;
|
||||
s32 chan;
|
||||
BOOL enabled;
|
||||
@@ -1520,6 +1500,7 @@ void KPADInit(void) {
|
||||
one = 1.0f;
|
||||
zero = 0.0f;
|
||||
degreesToRadians = 0.017453292f;
|
||||
matrix = initial_rotation_matrix;
|
||||
kpad = inside_kpads;
|
||||
do {
|
||||
kpad->dpdEnable = 1;
|
||||
@@ -1547,9 +1528,9 @@ void KPADInit(void) {
|
||||
}
|
||||
referenceWidth = referenceWidth < referenceHeight ? referenceWidth : referenceHeight;
|
||||
initial_rotation_matrix[0] = one;
|
||||
initial_rotation_matrix[1] = zero;
|
||||
initial_rotation_matrix[2] = zero;
|
||||
initial_rotation_matrix[3] = zero;
|
||||
matrix[1] = zero;
|
||||
matrix[2] = zero;
|
||||
matrix[3] = zero;
|
||||
kpad->sensorBarScale = sensorDistance / referenceWidth;
|
||||
kpad->value9C = zero;
|
||||
kpad->value94 = zero;
|
||||
@@ -1568,18 +1549,18 @@ void KPADInit(void) {
|
||||
kpad->sensorHeightPending = 1;
|
||||
kpad->sensorBarPosition = 1;
|
||||
kpad->freeStyleAccelRotation = 0;
|
||||
initial_rotation_matrix[4] = zero;
|
||||
matrix[4] = zero;
|
||||
rotationElement = (f32)cos(degreesToRadians * sensor_bar_angle_degrees);
|
||||
initial_rotation_matrix[5] = rotationElement;
|
||||
matrix[5] = rotationElement;
|
||||
rotationElement = (f32)-sin(degreesToRadians * sensor_bar_angle_degrees);
|
||||
initial_rotation_matrix[7] = zero;
|
||||
initial_rotation_matrix[8] = zero;
|
||||
initial_rotation_matrix[6] = rotationElement;
|
||||
matrix[7] = zero;
|
||||
matrix[8] = zero;
|
||||
matrix[6] = rotationElement;
|
||||
rotationElement = (f32)sin(degreesToRadians * sensor_bar_angle_degrees);
|
||||
initial_rotation_matrix[9] = rotationElement;
|
||||
matrix[9] = rotationElement;
|
||||
rotationElement = (f32)cos(degreesToRadians * sensor_bar_angle_degrees);
|
||||
initial_rotation_matrix[10] = rotationElement;
|
||||
initial_rotation_matrix[11] = zero;
|
||||
matrix[10] = rotationElement;
|
||||
matrix[11] = zero;
|
||||
{
|
||||
i = 0;
|
||||
do {
|
||||
|
||||
@@ -64,7 +64,7 @@ struct NUPTitleInfo {
|
||||
u32 ticketCertificateSize;
|
||||
void* tmdCertificate;
|
||||
u32 tmdCertificateSize;
|
||||
ESTmdView* tmdView;
|
||||
void* tmdView;
|
||||
u32 tmdViewSize;
|
||||
u8 hasTicket;
|
||||
u8 hasTmd;
|
||||
@@ -165,7 +165,7 @@ static ESError __nupHttpBufferFlushES(u8* buffer, unsigned long size, unsigned l
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline char* __nupFindTag(char* response, const char* startTag, const char* endTag,
|
||||
static inline char* __nupFindTag(char* response, const char* endTag, const char* startTag,
|
||||
char** value, size_t* length) {
|
||||
char* start;
|
||||
char* end;
|
||||
@@ -188,7 +188,10 @@ static s32 __nupParseServerInfo(NUPContextInfo* context, char* response, char* m
|
||||
size_t titleCount;
|
||||
|
||||
{
|
||||
afterEnd = __nupFindTag(response, "<Version>", "</Version>", &start, &valueLength);
|
||||
const char* versionEndTag = "</Version>";
|
||||
const char* versionStartTag = "<Version>";
|
||||
afterEnd = __nupFindTag(response, versionEndTag, versionStartTag,
|
||||
&start, &valueLength);
|
||||
if (afterEnd == 0 || valueLength != strlen("1.0") || strncmp(start, "1.0", valueLength) != 0) {
|
||||
result = -5004;
|
||||
goto done;
|
||||
@@ -196,7 +199,10 @@ static s32 __nupParseServerInfo(NUPContextInfo* context, char* response, char* m
|
||||
}
|
||||
|
||||
{
|
||||
afterEnd = __nupFindTag(response, "<DeviceId>", "</DeviceId>", &start, &valueLength);
|
||||
const char* deviceIdEndTag = "</DeviceId>";
|
||||
const char* deviceIdStartTag = "<DeviceId>";
|
||||
afterEnd = __nupFindTag(response, deviceIdEndTag, deviceIdStartTag,
|
||||
&start, &valueLength);
|
||||
if (afterEnd == 0 || strtoull(start, 0, 10) != deviceId) {
|
||||
result = -5004;
|
||||
goto done;
|
||||
@@ -204,7 +210,10 @@ static s32 __nupParseServerInfo(NUPContextInfo* context, char* response, char* m
|
||||
}
|
||||
|
||||
{
|
||||
afterEnd = __nupFindTag(response, "<MessageId>", "</MessageId>", &start, &valueLength);
|
||||
const char* messageIdEndTag = "</MessageId>";
|
||||
const char* messageIdStartTag = "<MessageId>";
|
||||
afterEnd = __nupFindTag(response, messageIdEndTag, messageIdStartTag,
|
||||
&start, &valueLength);
|
||||
if (afterEnd == 0 || valueLength != strlen(messageId) || strncmp(start, messageId, valueLength) != 0) {
|
||||
result = -5004;
|
||||
goto done;
|
||||
@@ -212,7 +221,10 @@ static s32 __nupParseServerInfo(NUPContextInfo* context, char* response, char* m
|
||||
}
|
||||
|
||||
{
|
||||
afterEnd = __nupFindTag(response, "<ErrorCode>", "</ErrorCode>", &start, &valueLength);
|
||||
const char* errorCodeEndTag = "</ErrorCode>";
|
||||
const char* errorCodeStartTag = "<ErrorCode>";
|
||||
afterEnd = __nupFindTag(response, errorCodeEndTag, errorCodeStartTag,
|
||||
&start, &valueLength);
|
||||
if (afterEnd == 0 || valueLength != strlen("0") || strncmp(start, "0", valueLength) != 0) {
|
||||
result = -5004;
|
||||
goto done;
|
||||
@@ -220,7 +232,10 @@ static s32 __nupParseServerInfo(NUPContextInfo* context, char* response, char* m
|
||||
}
|
||||
|
||||
{
|
||||
afterEnd = __nupFindTag(response, "<UploadAuditData>", "</UploadAuditData>", &start, &valueLength);
|
||||
const char* uploadAuditEndTag = "</UploadAuditData>";
|
||||
const char* uploadAuditStartTag = "<UploadAuditData>";
|
||||
afterEnd = __nupFindTag(response, uploadAuditEndTag, uploadAuditStartTag,
|
||||
&start, &valueLength);
|
||||
if (afterEnd == 0 || valueLength != strlen("0") || (*start != '0' && *start != '1')) {
|
||||
result = -5004;
|
||||
goto done;
|
||||
@@ -233,7 +248,10 @@ static s32 __nupParseServerInfo(NUPContextInfo* context, char* response, char* m
|
||||
}
|
||||
|
||||
{
|
||||
afterEnd = __nupFindTag(response, "<ContentPrefixURL>", "</ContentPrefixURL>", &start, &valueLength);
|
||||
const char* contentPrefixEndTag = "</ContentPrefixURL>";
|
||||
const char* contentPrefixStartTag = "<ContentPrefixURL>";
|
||||
afterEnd = __nupFindTag(response, contentPrefixEndTag, contentPrefixStartTag,
|
||||
&start, &valueLength);
|
||||
if (afterEnd == 0 || valueLength == 0) {
|
||||
result = -5004;
|
||||
goto done;
|
||||
@@ -248,7 +266,10 @@ static s32 __nupParseServerInfo(NUPContextInfo* context, char* response, char* m
|
||||
}
|
||||
|
||||
{
|
||||
afterEnd = __nupFindTag(response, "<UncachedContentPrefixURL>", "</UncachedContentPrefixURL>", &start, &valueLength);
|
||||
const char* uncachedPrefixEndTag = "</UncachedContentPrefixURL>";
|
||||
const char* uncachedPrefixStartTag = "<UncachedContentPrefixURL>";
|
||||
afterEnd = __nupFindTag(response, uncachedPrefixEndTag, uncachedPrefixStartTag,
|
||||
&start, &valueLength);
|
||||
if (afterEnd == 0 || valueLength == 0) {
|
||||
result = -5004;
|
||||
goto done;
|
||||
@@ -265,8 +286,14 @@ static s32 __nupParseServerInfo(NUPContextInfo* context, char* response, char* m
|
||||
titleCount = 0;
|
||||
cursor = response;
|
||||
{
|
||||
while ((cursor = __nupFindTag(cursor, "<TitleId>", "</TitleId>", &start, &valueLength)) != 0 &&
|
||||
(cursor = __nupFindTag(cursor, "<Version>", "</Version>", &start, &valueLength)) != 0) {
|
||||
const char* versionEndTag = "</Version>";
|
||||
const char* versionStartTag = "<Version>";
|
||||
const char* titleIdEndTag = "</TitleId>";
|
||||
const char* titleIdStartTag = "<TitleId>";
|
||||
while ((cursor = __nupFindTag(cursor, titleIdEndTag, titleIdStartTag,
|
||||
&start, &valueLength)) != 0 &&
|
||||
(cursor = __nupFindTag(cursor, versionEndTag, versionStartTag,
|
||||
&start, &valueLength)) != 0) {
|
||||
titleCount++;
|
||||
}
|
||||
}
|
||||
@@ -279,13 +306,19 @@ static s32 __nupParseServerInfo(NUPContextInfo* context, char* response, char* m
|
||||
memset(context->titles, 0, titleCount * sizeof(NUPTitleInfo));
|
||||
cursor = response;
|
||||
{
|
||||
const char* versionEndTag = "</Version>";
|
||||
const char* versionStartTag = "<Version>";
|
||||
const char* titleIdEndTag = "</TitleId>";
|
||||
const char* titleIdStartTag = "<TitleId>";
|
||||
char* titleStart;
|
||||
char* versionStart;
|
||||
size_t titleLength;
|
||||
size_t versionLength;
|
||||
char* parsedEnd;
|
||||
while ((cursor = __nupFindTag(cursor, "<TitleId>", "</TitleId>", &titleStart, &titleLength)) != 0 &&
|
||||
(cursor = __nupFindTag(cursor, "<Version>", "</Version>", &versionStart, &versionLength)) != 0) {
|
||||
while ((cursor = __nupFindTag(cursor, titleIdEndTag, titleIdStartTag,
|
||||
&titleStart, &titleLength)) != 0 &&
|
||||
(cursor = __nupFindTag(cursor, versionEndTag, versionStartTag,
|
||||
&versionStart, &versionLength)) != 0) {
|
||||
unsigned long long titleId = strtoull(titleStart, &parsedEnd, 16);
|
||||
if (parsedEnd != titleStart + titleLength) {
|
||||
result = -5004;
|
||||
@@ -694,7 +727,7 @@ static s32 __nupGetBootVersion(NUPContextInfo* context, ESTitleVersion* title) {
|
||||
title->hasContent = 1;
|
||||
result = __nupSetBootTitleVersion(title);
|
||||
} else {
|
||||
s32 i;
|
||||
u32 i;
|
||||
for (i = 0; i < context->ownedTitleCount; i++) {
|
||||
if (context->ownedTitleIds[i] == title->titleId) {
|
||||
break;
|
||||
@@ -731,16 +764,18 @@ static s32 __nupGetBootVersion(NUPContextInfo* context, ESTitleVersion* title) {
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
if (title->contentCount < tmdView->head.numContents) {
|
||||
u32 installedContentCount = title->contentCount;
|
||||
if (installedContentCount < tmdView->head.numContents) {
|
||||
goto done;
|
||||
}
|
||||
for (i = 0; i < tmdView->head.numContents; i++) {
|
||||
ESContentId contentId = tmdView->contents[i].cid;
|
||||
if (!__nupHasInstalledContent(title, contentId, title->contentCount)) {
|
||||
s32 contentIndex;
|
||||
for (contentIndex = 0; contentIndex < tmdView->head.numContents; contentIndex++) {
|
||||
if (!__nupHasInstalledContent(title, tmdView->contents[contentIndex].cid,
|
||||
installedContentCount)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i < tmdView->head.numContents) {
|
||||
if (contentIndex < tmdView->head.numContents) {
|
||||
goto done;
|
||||
}
|
||||
title->hasContent = 1;
|
||||
@@ -835,7 +870,7 @@ static s32 __nupGetTmd(NUPTitleInfo* title, char* contentPrefixUrl) {
|
||||
result = ES_DiGetTmdView((ESTitleMeta*)title->tmd, title->tmdSize, 0,
|
||||
&title->tmdViewSize);
|
||||
if (result == 0) {
|
||||
title->tmdView = (ESTmdView*)nup::__nupMalloc(title->tmdViewSize);
|
||||
title->tmdView = nup::__nupMalloc(title->tmdViewSize);
|
||||
if (title->tmdView == 0) {
|
||||
result = -5000;
|
||||
} else {
|
||||
@@ -872,26 +907,23 @@ static s32 __nupGetTitleSize(NUPTitleInfo* title) {
|
||||
if (title->hasTmd == 0 && title->contentCount == 0) {
|
||||
title->progressStep += 4;
|
||||
}
|
||||
title->progressStep += 5;
|
||||
title->installedContentSize += 0x4000;
|
||||
title->progressStep++;
|
||||
title->installedContentSize += (title->tmdSize + 0x3fff) & 0xffffc000;
|
||||
title->progressStep++;
|
||||
title->installedContentSize += 0x8000;
|
||||
title->progressStep++;
|
||||
title->installedContentSize += 0x4000;
|
||||
title->progressStep++;
|
||||
title->installedContentSize += 0x4000;
|
||||
title->progressStep++;
|
||||
for (contentIndex = 0; contentIndex < title->tmdView->head.numContents; contentIndex++) {
|
||||
ESContentId contentId = title->tmdView->contents[contentIndex].cid;
|
||||
for (contentIndex = 0; contentIndex < ((ESTmdView*)title->tmdView)->head.numContents; contentIndex++) {
|
||||
ESCmdView* content = &((ESTmdView*)title->tmdView)->contents[contentIndex];
|
||||
ESContentId contentId = content->cid;
|
||||
if (!__nupHasContent(title, contentId) ||
|
||||
title->titleId == 0x0000000100000001ULL) {
|
||||
if (title->tmdView->contents[contentIndex].size > 0xffffffefULL) {
|
||||
if (content->size > 0xffffffefULL) {
|
||||
result = -0x1394;
|
||||
break;
|
||||
}
|
||||
title->updateContentSize += (title->tmdView->contents[contentIndex].size + 0xf) & 0xfffffffffffffff0ULL;
|
||||
title->installedContentSize += (title->tmdView->contents[contentIndex].size + 0x3fff) & 0xffffffffffffc000ULL;
|
||||
title->updateContentSize += (content->size + 0xf) & 0xfffffffffffffff0ULL;
|
||||
title->installedContentSize += (((ESTmdView*)title->tmdView)->contents[contentIndex].size + 0x3fff) & 0xffffffffffffc000ULL;
|
||||
title->progressStep++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -781,11 +781,114 @@ static ISD_Error sduGetOCR(SDDev* dev, u32* data) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef __MWERKS__
|
||||
asm ISD_Error ISD_GetCardSize(register SDDev* dev, register u32* outSize, register u32* outSize2, register u32* outSectorSize) {
|
||||
nofralloc
|
||||
|
||||
stwu r1, -0x30(r1)
|
||||
mflr r0
|
||||
stw r0, 0x34(r1)
|
||||
stw r31, 0x2c(r1)
|
||||
mr r31, r6
|
||||
stw r30, 0x28(r1)
|
||||
mr r30, r5
|
||||
li r5, 0x10
|
||||
stw r29, 0x24(r1)
|
||||
mr r29, r4
|
||||
li r4, 0
|
||||
stw r28, 0x20(r1)
|
||||
mr r28, r3
|
||||
addi r3, r1, 8
|
||||
bl memset
|
||||
mr r3, r28
|
||||
addi r5, r1, 8
|
||||
li r4, 9
|
||||
li r6, 0x10
|
||||
bl ISD_ReadCardRegister
|
||||
cmpwi r3, 0
|
||||
beq ISD_GetCardSize_success
|
||||
b ISD_GetCardSize_return
|
||||
|
||||
ISD_GetCardSize_success:
|
||||
lwz r0, 0x14(r1)
|
||||
rlwinm. r0, r0, 0xa, 0x1e, 0x1f
|
||||
beq ISD_GetCardSize_standard
|
||||
lwz r0, 0xc(r1)
|
||||
li r5, 0x80
|
||||
rlwinm r3, r0, 0x18, 0xa, 0x1f
|
||||
addi r0, r3, 1
|
||||
slwi r3, r0, 0xa
|
||||
rlwinm r0, r0, 3, 7, 0x1c
|
||||
b ISD_GetCardSize_store
|
||||
|
||||
ISD_GetCardSize_standard:
|
||||
lwz r3, 0x10(r1)
|
||||
li r0, 9
|
||||
lwz r7, 0xc(r1)
|
||||
rlwinm r4, r3, 0x18, 0x1c, 0x1f
|
||||
cmplwi r4, 9
|
||||
srwi r6, r7, 0x16
|
||||
rlwimi r6, r3, 0xa, 0x14, 0x15
|
||||
rlwinm r3, r7, 0x19, 0x1d, 0x1f
|
||||
blt ISD_GetCardSize_clamp_high
|
||||
mr r0, r4
|
||||
ISD_GetCardSize_clamp_high:
|
||||
cmplwi r0, 0xb
|
||||
li r4, 0xb
|
||||
bgt ISD_GetCardSize_clamp_done
|
||||
mr r4, r0
|
||||
ISD_GetCardSize_clamp_done:
|
||||
addi r0, r3, 2
|
||||
li r5, 1
|
||||
addi r3, r6, 1
|
||||
addi r4, r4, -9
|
||||
slw r0, r5, r0
|
||||
lwz r6, 8(r1)
|
||||
mullw r0, r3, r0
|
||||
slw r3, r5, r4
|
||||
srwi r5, r6, 0x1f
|
||||
rlwimi r5, r7, 1, 0x19, 0x1e
|
||||
mullw r3, r3, r0
|
||||
addi r5, r5, 1
|
||||
slwi r0, r3, 9
|
||||
divwu r0, r0, r5
|
||||
srw r0, r0, r4
|
||||
|
||||
ISD_GetCardSize_store:
|
||||
cmpwi r29, 0
|
||||
stw r5, 0x18(r28)
|
||||
stw r0, 0x1c(r28)
|
||||
stw r3, 0x20(r28)
|
||||
beq ISD_GetCardSize_no_outSize
|
||||
stw r3, 0(r29)
|
||||
ISD_GetCardSize_no_outSize:
|
||||
cmpwi r30, 0
|
||||
beq ISD_GetCardSize_no_outSize2
|
||||
stw r3, 0(r30)
|
||||
ISD_GetCardSize_no_outSize2:
|
||||
cmpwi r31, 0
|
||||
beq ISD_GetCardSize_success_return
|
||||
li r0, 0x200
|
||||
stw r0, 0(r31)
|
||||
ISD_GetCardSize_success_return:
|
||||
li r3, 0
|
||||
|
||||
ISD_GetCardSize_return:
|
||||
lwz r0, 0x34(r1)
|
||||
lwz r31, 0x2c(r1)
|
||||
lwz r30, 0x28(r1)
|
||||
lwz r29, 0x24(r1)
|
||||
lwz r28, 0x20(r1)
|
||||
mtlr r0
|
||||
addi r1, r1, 0x30
|
||||
blr
|
||||
}
|
||||
#else
|
||||
ISD_Error ISD_GetCardSize(SDDev* dev, u32* outSize, u32* outSize2, u32* outSectorSize) {
|
||||
ISD_Error ret;
|
||||
u32 eraseBlockCount;
|
||||
u32 sectorCount;
|
||||
u32 eraseBlockSize;
|
||||
u32 out0;
|
||||
u32 out1;
|
||||
u32 out2;
|
||||
|
||||
u32 resp[4];
|
||||
memset(resp, 0, sizeof(resp));
|
||||
@@ -796,33 +899,27 @@ ISD_Error ISD_GetCardSize(SDDev* dev, u32* outSize, u32* outSize2, u32* outSecto
|
||||
}
|
||||
|
||||
if ((resp[3] >> 0x16) & 3) {
|
||||
eraseBlockSize = 0x80;
|
||||
sectorCount = (((resp[1] >> 8) & 0x3FFFFF) + 1) * 1024;
|
||||
eraseBlockCount = ((((resp[1] >> 8) & 0x3FFFFF) + 1) * 8) & 0x01FFFFF8;
|
||||
out0 = 0x80;
|
||||
out2 = (((resp[1] >> 8) & 0x3FFFFF) + 1) * 512;
|
||||
out1 = ((((resp[1] >> 8) & 0x3FFFFF) + 1) * 8) & 0x01FFFFF8;
|
||||
} else {
|
||||
u32 readBlockLength = (resp[2] >> 8) & 0xF;
|
||||
u32 capacity = ((resp[2] & 3) << 10) | (resp[1] >> 22);
|
||||
u32 blockScale;
|
||||
u32 sizeMultiplier = (resp[1] >> 7) & 7;
|
||||
u32 tmp = (((resp[2] >> 8) & 0xF) >= 9 ? ((resp[2] >> 8) & 0xF) : 9);
|
||||
tmp = tmp <= 11 ? tmp : 11;
|
||||
|
||||
readBlockLength = readBlockLength >= 9 ? readBlockLength : 9;
|
||||
readBlockLength = readBlockLength <= 11 ? readBlockLength : 11;
|
||||
|
||||
eraseBlockSize = (((resp[1] & 0x3F) << 1) | (resp[0] >> 31)) + 1;
|
||||
blockScale = 1 << (readBlockLength - 9);
|
||||
sectorCount = ((capacity + 1) * (1 << (sizeMultiplier + 2))) * blockScale;
|
||||
eraseBlockCount = ((sectorCount << 9) / eraseBlockSize) >> (readBlockLength - 9);
|
||||
out2 = (1 << (tmp - 9)) * (((((resp[1] >> 0x16) & ~0xC00) | ((resp[2] << 10) & 0xC00)) + 1) * (1 << (((resp[1] >> 7) & 7) + 2)));
|
||||
out0 = (((resp[0] >> 0x1F) & ~0x7E) | ((resp[1] << 1) & 0x7E)) + 1;
|
||||
out1 = ((out2 << 9) / out0) >> (tmp - 9);
|
||||
}
|
||||
|
||||
dev->SDSectorSize = eraseBlockSize;
|
||||
dev->SDSectorNum = eraseBlockCount;
|
||||
dev->SDDevSize = sectorCount;
|
||||
dev->SDSectorSize = out0;
|
||||
dev->SDSectorNum = out1;
|
||||
dev->SDDevSize = out2;
|
||||
|
||||
if (outSize != NULL) {
|
||||
*outSize = sectorCount;
|
||||
*outSize = out2;
|
||||
}
|
||||
if (outSize2 != NULL) {
|
||||
*outSize2 = sectorCount;
|
||||
*outSize2 = out2;
|
||||
}
|
||||
if (outSectorSize != NULL) {
|
||||
*outSectorSize = 512;
|
||||
@@ -830,6 +927,7 @@ ISD_Error ISD_GetCardSize(SDDev* dev, u32* outSize, u32* outSize2, u32* outSecto
|
||||
|
||||
return SD_ERROR_SUCCESS;
|
||||
}
|
||||
#endif
|
||||
|
||||
ISD_Error ISD_RegisterDeviceIntrHandler(SDDev* dev, SDDevIntrCallback intCB, void* arg) {
|
||||
u32 state;
|
||||
|
||||
@@ -1260,12 +1260,12 @@ s32 WADBackupEx(u64 titleId, u32 flags, MEMAllocator* allocator, char* path, u32
|
||||
|
||||
titleMetaSize = 0;
|
||||
contentDataSize = 0;
|
||||
files = 0;
|
||||
titleMeta = 0;
|
||||
outputBuffer = 0;
|
||||
titleMetaBuffer = 0;
|
||||
titleMeta = 0;
|
||||
files = 0;
|
||||
fileCount = 0;
|
||||
importedSize = 0;
|
||||
outputBuffer = 0;
|
||||
encryptionBuffer = 0;
|
||||
fileDataSize = 0;
|
||||
installedContentCount = 0;
|
||||
|
||||
@@ -563,17 +563,6 @@ static void WPADiGetScSettings() {
|
||||
_scSetting = FALSE;
|
||||
}
|
||||
|
||||
static void __reconnect(BOOL exec) {
|
||||
DEBUGPrint("Reconnect Start!!\n");
|
||||
|
||||
BTA_DmSendHciReset();
|
||||
|
||||
OSCancelAlarm(&_managerAlarm);
|
||||
|
||||
WUDSetHidRecvCallback(NULL);
|
||||
WUDShutdown(exec);
|
||||
}
|
||||
|
||||
static void WPADiAfh() {
|
||||
BOOL enabled;
|
||||
u8* pWifiChannel;
|
||||
@@ -617,6 +606,550 @@ static void WPADiRumbleMotor(s32 chan, BOOL prevSuccess) {
|
||||
_rumbleCnt[chan] = _wpdcb[chan]->motorBusy ? _rumbleCnt[chan] + 1 : 0;
|
||||
}
|
||||
|
||||
static void __reconnect(BOOL exec) {
|
||||
DEBUGPrint("Reconnect Start!!\n");
|
||||
|
||||
BTA_DmSendHciReset();
|
||||
|
||||
OSCancelAlarm(&_managerAlarm);
|
||||
|
||||
WUDSetHidRecvCallback(NULL);
|
||||
WUDShutdown(exec);
|
||||
}
|
||||
#ifdef __MWERKS__
|
||||
char scWpadManageStrs[0x58] = "Reconnect Start!!\n\0\0\0\0\0\0"
|
||||
"Check the update of WiFi using channel\n\0"
|
||||
"WiFi uses channel = %d\n";
|
||||
extern void _savegpr_19();
|
||||
extern void _restgpr_19();
|
||||
static asm void WPADiManageHandler(OSAlarm* pAlarm, OSContext* pContext) {
|
||||
nofralloc
|
||||
stwu r1, -0x160(r1)
|
||||
mflr r0
|
||||
stw r0, 0x164(r1)
|
||||
addi r11, r1, 0x160
|
||||
bl _savegpr_19
|
||||
lis r28, scWpadVersionStr@ha
|
||||
addi r28, r28, scWpadVersionStr@l
|
||||
bl WUDGetStatus
|
||||
cmpwi r3, 0x3
|
||||
beq WPADiManageHandler_8AC8
|
||||
cmpwi r3, 0x2
|
||||
bne WPADiManageHandler_91D8
|
||||
lwz r0, _initialized(r0)
|
||||
cmpwi r0, 0x0
|
||||
bne WPADiManageHandler_91D8
|
||||
li r0, 0x1
|
||||
lis r3, WPADiConnCallback@ha
|
||||
stw r0, _initialized(r0)
|
||||
addi r3, r3, WPADiConnCallback@l
|
||||
bl WUDSetHidConnCallback
|
||||
lis r3, WPADiRecvCallback@ha
|
||||
addi r3, r3, WPADiRecvCallback@l
|
||||
bl WUDSetHidRecvCallback
|
||||
li r0, 0x32
|
||||
stw r0, _recCnt(r0)
|
||||
b WPADiManageHandler_91D8
|
||||
WPADiManageHandler_8AC8:
|
||||
lwz r4, _recCnt(r0)
|
||||
lwz r19, _recFlag(r0)
|
||||
cntlzw r3, r4
|
||||
subi r0, r4, 0x1
|
||||
extrwi r3, r3, 1, 26
|
||||
cmpwi r19, 0x0
|
||||
neg r3, r3
|
||||
andc r0, r0, r3
|
||||
stw r0, _recCnt(r0)
|
||||
blt WPADiManageHandler_8B28
|
||||
cmpwi r0, 0x0
|
||||
bne WPADiManageHandler_91D8
|
||||
addi r3, r28, 0xf0
|
||||
crclr 4*cr1+eq
|
||||
bl DEBUGPrint
|
||||
bl BTA_DmSendHciReset
|
||||
lis r3, _managerAlarm@ha
|
||||
addi r3, r3, _managerAlarm@l
|
||||
bl OSCancelAlarm
|
||||
li r3, 0x0
|
||||
bl WUDSetHidRecvCallback
|
||||
mr r3, r19
|
||||
bl WUDShutdown
|
||||
b WPADiManageHandler_91D8
|
||||
WPADiManageHandler_8B28:
|
||||
lis r24, _wpdcb@ha
|
||||
li r22, 0x0
|
||||
addi r24, r24, _wpdcb@l
|
||||
la r25, _extCnt
|
||||
la r23, _rumbleCnt
|
||||
li r29, 0x0
|
||||
li r30, 0x10
|
||||
li r31, 0x1
|
||||
WPADiManageHandler_8B48:
|
||||
lbz r0, 0x0(r25)
|
||||
li r21, 0x0
|
||||
cmplwi r0, 0x5
|
||||
bne WPADiManageHandler_8D20
|
||||
lwz r26, 0x0(r24)
|
||||
lwz r0, 0x8d8(r26)
|
||||
cmpwi r0, 0x0
|
||||
beq WPADiManageHandler_8D10
|
||||
bl OSDisableInterrupts
|
||||
mr r27, r3
|
||||
bl OSDisableInterrupts
|
||||
lbz r4, 0x5ec(r26)
|
||||
lbz r0, 0x5ed(r26)
|
||||
subf r0, r4, r0
|
||||
extsb. r19, r0
|
||||
bge WPADiManageHandler_8B94
|
||||
lwz r0, 0x5f4(r26)
|
||||
add r0, r19, r0
|
||||
extsb r19, r0
|
||||
WPADiManageHandler_8B94:
|
||||
bl OSRestoreInterrupts
|
||||
cmpwi r19, 0x0
|
||||
bne WPADiManageHandler_8BB0
|
||||
mr r3, r27
|
||||
bl OSRestoreInterrupts
|
||||
li r0, 0x0
|
||||
b WPADiManageHandler_8BDC
|
||||
WPADiManageHandler_8BB0:
|
||||
lbz r0, 0x5ec(r26)
|
||||
addi r3, r1, 0xc8
|
||||
lwz r4, 0x5f0(r26)
|
||||
li r5, 0x30
|
||||
extsb r0, r0
|
||||
mulli r0, r0, 0x30
|
||||
add r4, r4, r0
|
||||
bl memcpy
|
||||
mr r3, r27
|
||||
bl OSRestoreInterrupts
|
||||
li r0, 0x1
|
||||
WPADiManageHandler_8BDC:
|
||||
cmpwi r0, 0x0
|
||||
beq WPADiManageHandler_8D10
|
||||
lwz r0, 0xc8(r1)
|
||||
cmplwi r0, 0x12
|
||||
beq WPADiManageHandler_8BFC
|
||||
lwz r0, 0x840(r26)
|
||||
cmpwi r0, 0x0
|
||||
beq WPADiManageHandler_8D10
|
||||
WPADiManageHandler_8BFC:
|
||||
lwz r21, 0xc8(r1)
|
||||
mr r3, r22
|
||||
lwz r20, 0xcc(r1)
|
||||
addi r4, r1, 0xf8
|
||||
lwz r19, 0xd0(r1)
|
||||
lwz r12, 0xd4(r1)
|
||||
lwz r11, 0xd8(r1)
|
||||
lwz r10, 0xdc(r1)
|
||||
lwz r9, 0xe0(r1)
|
||||
lwz r8, 0xe4(r1)
|
||||
lwz r7, 0xe8(r1)
|
||||
lwz r6, 0xec(r1)
|
||||
lwz r5, 0xf0(r1)
|
||||
lwz r0, 0xf4(r1)
|
||||
stw r21, 0xf8(r1)
|
||||
stw r20, 0xfc(r1)
|
||||
stw r19, 0x100(r1)
|
||||
stw r12, 0x104(r1)
|
||||
stw r11, 0x108(r1)
|
||||
stw r10, 0x10c(r1)
|
||||
stw r9, 0x110(r1)
|
||||
stw r8, 0x114(r1)
|
||||
stw r7, 0x118(r1)
|
||||
stw r6, 0x11c(r1)
|
||||
stw r5, 0x120(r1)
|
||||
stw r0, 0x124(r1)
|
||||
bl WPADiSendData
|
||||
cmpwi r3, 0x0
|
||||
bne WPADiManageHandler_8D10
|
||||
bl OSDisableInterrupts
|
||||
mr r27, r3
|
||||
bl OSDisableInterrupts
|
||||
lbz r4, 0x5ec(r26)
|
||||
lbz r0, 0x5ed(r26)
|
||||
subf r0, r4, r0
|
||||
extsb. r19, r0
|
||||
bge WPADiManageHandler_8C9C
|
||||
lwz r0, 0x5f4(r26)
|
||||
add r0, r19, r0
|
||||
extsb r19, r0
|
||||
WPADiManageHandler_8C9C:
|
||||
bl OSRestoreInterrupts
|
||||
cmpwi r19, 0x0
|
||||
bne WPADiManageHandler_8CB4
|
||||
mr r3, r27
|
||||
bl OSRestoreInterrupts
|
||||
b WPADiManageHandler_8D08
|
||||
WPADiManageHandler_8CB4:
|
||||
lbz r0, 0x5ec(r26)
|
||||
li r4, 0x0
|
||||
lwz r3, 0x5f0(r26)
|
||||
li r5, 0x30
|
||||
extsb r0, r0
|
||||
mulli r0, r0, 0x30
|
||||
add r3, r3, r0
|
||||
bl memset
|
||||
lbz r0, 0x5ec(r26)
|
||||
mr r3, r27
|
||||
lwz r4, 0x5f4(r26)
|
||||
extsb r6, r0
|
||||
subi r4, r4, 0x1
|
||||
subf r5, r4, r6
|
||||
addi r0, r6, 0x1
|
||||
subf r4, r6, r4
|
||||
nor r4, r5, r4
|
||||
srawi r4, r4, 31
|
||||
andc r0, r0, r4
|
||||
stb r0, 0x5ec(r26)
|
||||
bl OSRestoreInterrupts
|
||||
WPADiManageHandler_8D08:
|
||||
li r21, 0x1
|
||||
b WPADiManageHandler_8D14
|
||||
WPADiManageHandler_8D10:
|
||||
li r21, 0x0
|
||||
WPADiManageHandler_8D14:
|
||||
cmpwi r21, 0x0
|
||||
beq WPADiManageHandler_8D20
|
||||
stb r29, 0x0(r25)
|
||||
WPADiManageHandler_8D20:
|
||||
cmpwi r21, 0x0
|
||||
bne WPADiManageHandler_8ED0
|
||||
lwz r27, 0x0(r24)
|
||||
lwz r0, 0x8d8(r27)
|
||||
cmpwi r0, 0x0
|
||||
beq WPADiManageHandler_8EC8
|
||||
bl OSDisableInterrupts
|
||||
mr r26, r3
|
||||
bl OSDisableInterrupts
|
||||
lbz r4, 0x160(r27)
|
||||
lbz r0, 0x161(r27)
|
||||
subf r0, r4, r0
|
||||
extsb. r19, r0
|
||||
bge WPADiManageHandler_8D64
|
||||
lwz r0, 0x168(r27)
|
||||
add r0, r19, r0
|
||||
extsb r19, r0
|
||||
WPADiManageHandler_8D64:
|
||||
bl OSRestoreInterrupts
|
||||
cmpwi r19, 0x0
|
||||
bne WPADiManageHandler_8D80
|
||||
mr r3, r26
|
||||
bl OSRestoreInterrupts
|
||||
li r0, 0x0
|
||||
b WPADiManageHandler_8DAC
|
||||
WPADiManageHandler_8D80:
|
||||
lbz r0, 0x160(r27)
|
||||
addi r3, r1, 0x68
|
||||
lwz r4, 0x164(r27)
|
||||
li r5, 0x30
|
||||
extsb r0, r0
|
||||
mulli r0, r0, 0x30
|
||||
add r4, r4, r0
|
||||
bl memcpy
|
||||
mr r3, r26
|
||||
bl OSRestoreInterrupts
|
||||
li r0, 0x1
|
||||
WPADiManageHandler_8DAC:
|
||||
cmpwi r0, 0x0
|
||||
beq WPADiManageHandler_8EC8
|
||||
lwz r19, 0x68(r1)
|
||||
mr r3, r22
|
||||
lwz r20, 0x6c(r1)
|
||||
addi r4, r1, 0x98
|
||||
lwz r26, 0x70(r1)
|
||||
lwz r12, 0x74(r1)
|
||||
lwz r11, 0x78(r1)
|
||||
lwz r10, 0x7c(r1)
|
||||
lwz r9, 0x80(r1)
|
||||
lwz r8, 0x84(r1)
|
||||
lwz r7, 0x88(r1)
|
||||
lwz r6, 0x8c(r1)
|
||||
lwz r5, 0x90(r1)
|
||||
lwz r0, 0x94(r1)
|
||||
stw r19, 0x98(r1)
|
||||
stw r20, 0x9c(r1)
|
||||
stw r26, 0xa0(r1)
|
||||
stw r12, 0xa4(r1)
|
||||
stw r11, 0xa8(r1)
|
||||
stw r10, 0xac(r1)
|
||||
stw r9, 0xb0(r1)
|
||||
stw r8, 0xb4(r1)
|
||||
stw r7, 0xb8(r1)
|
||||
stw r6, 0xbc(r1)
|
||||
stw r5, 0xc0(r1)
|
||||
stw r0, 0xc4(r1)
|
||||
bl WPADiSendData
|
||||
cmpwi r3, 0x0
|
||||
bne WPADiManageHandler_8EC8
|
||||
bl OSDisableInterrupts
|
||||
mr r26, r3
|
||||
bl OSDisableInterrupts
|
||||
lbz r4, 0x160(r27)
|
||||
lbz r0, 0x161(r27)
|
||||
subf r0, r4, r0
|
||||
extsb. r19, r0
|
||||
bge WPADiManageHandler_8E54
|
||||
lwz r0, 0x168(r27)
|
||||
add r0, r19, r0
|
||||
extsb r19, r0
|
||||
WPADiManageHandler_8E54:
|
||||
bl OSRestoreInterrupts
|
||||
cmpwi r19, 0x0
|
||||
bne WPADiManageHandler_8E6C
|
||||
mr r3, r26
|
||||
bl OSRestoreInterrupts
|
||||
b WPADiManageHandler_8EC0
|
||||
WPADiManageHandler_8E6C:
|
||||
lbz r0, 0x160(r27)
|
||||
li r4, 0x0
|
||||
lwz r3, 0x164(r27)
|
||||
li r5, 0x30
|
||||
extsb r0, r0
|
||||
mulli r0, r0, 0x30
|
||||
add r3, r3, r0
|
||||
bl memset
|
||||
lbz r0, 0x160(r27)
|
||||
mr r3, r26
|
||||
lwz r4, 0x168(r27)
|
||||
extsb r6, r0
|
||||
subi r4, r4, 0x1
|
||||
subf r5, r4, r6
|
||||
addi r0, r6, 0x1
|
||||
subf r4, r6, r4
|
||||
nor r4, r5, r4
|
||||
srawi r4, r4, 31
|
||||
andc r0, r0, r4
|
||||
stb r0, 0x160(r27)
|
||||
bl OSRestoreInterrupts
|
||||
WPADiManageHandler_8EC0:
|
||||
li r0, 0x1
|
||||
b WPADiManageHandler_8ECC
|
||||
WPADiManageHandler_8EC8:
|
||||
li r0, 0x0
|
||||
WPADiManageHandler_8ECC:
|
||||
or r21, r21, r0
|
||||
WPADiManageHandler_8ED0:
|
||||
lwz r20, 0x0(r24)
|
||||
lwz r0, 0x8bc(r20)
|
||||
cmpwi r0, -0x1
|
||||
beq WPADiManageHandler_8FD0
|
||||
cmpwi r21, 0x1
|
||||
beq WPADiManageHandler_8F18
|
||||
bl OSDisableInterrupts
|
||||
lbz r4, 0x160(r20)
|
||||
lbz r0, 0x161(r20)
|
||||
subf r0, r4, r0
|
||||
extsb. r19, r0
|
||||
bge WPADiManageHandler_8F0C
|
||||
lwz r0, 0x168(r20)
|
||||
add r0, r19, r0
|
||||
extsb r19, r0
|
||||
WPADiManageHandler_8F0C:
|
||||
bl OSRestoreInterrupts
|
||||
cmpwi r19, 0x0
|
||||
ble WPADiManageHandler_8F24
|
||||
WPADiManageHandler_8F18:
|
||||
lwz r3, 0x0(r24)
|
||||
stw r29, 0x8d0(r3)
|
||||
b WPADiManageHandler_8FAC
|
||||
WPADiManageHandler_8F24:
|
||||
lbz r0, 0x0(r23)
|
||||
cmplwi r0, 0x5
|
||||
bne WPADiManageHandler_8FAC
|
||||
sth r31, 0x22(r1)
|
||||
mr r3, r22
|
||||
lwz r5, 0x0(r24)
|
||||
addi r4, r1, 0x38
|
||||
stb r29, 0xc(r1)
|
||||
lwz r12, 0x10(r1)
|
||||
stw r29, 0x8d0(r5)
|
||||
lwz r21, 0xc(r1)
|
||||
lwz r11, 0x14(r1)
|
||||
lwz r10, 0x18(r1)
|
||||
lwz r9, 0x1c(r1)
|
||||
lwz r8, 0x20(r1)
|
||||
lwz r7, 0x24(r1)
|
||||
lwz r6, 0x28(r1)
|
||||
lwz r5, 0x2c(r1)
|
||||
lwz r0, 0x30(r1)
|
||||
stw r30, 0x8(r1)
|
||||
stw r29, 0x34(r1)
|
||||
stw r30, 0x38(r1)
|
||||
stw r21, 0x3c(r1)
|
||||
stw r12, 0x40(r1)
|
||||
stw r11, 0x44(r1)
|
||||
stw r10, 0x48(r1)
|
||||
stw r9, 0x4c(r1)
|
||||
stw r8, 0x50(r1)
|
||||
stw r7, 0x54(r1)
|
||||
stw r6, 0x58(r1)
|
||||
stw r5, 0x5c(r1)
|
||||
stw r0, 0x60(r1)
|
||||
stw r29, 0x64(r1)
|
||||
bl __SendData
|
||||
WPADiManageHandler_8FAC:
|
||||
lwz r3, 0x0(r24)
|
||||
lwz r0, 0x8d0(r3)
|
||||
cmpwi r0, 0x0
|
||||
beq WPADiManageHandler_8FC8
|
||||
lbz r3, 0x0(r23)
|
||||
addi r0, r3, 0x1
|
||||
b WPADiManageHandler_8FCC
|
||||
WPADiManageHandler_8FC8:
|
||||
li r0, 0x0
|
||||
WPADiManageHandler_8FCC:
|
||||
stb r0, 0x0(r23)
|
||||
WPADiManageHandler_8FD0:
|
||||
lbz r0, _checkCnt(r0)
|
||||
cmplwi r0, 0x5
|
||||
bne WPADiManageHandler_8FE4
|
||||
mr r3, r22
|
||||
bl WPADiCheckContInputs
|
||||
WPADiManageHandler_8FE4:
|
||||
lhz r0, _senseCnt(r0)
|
||||
cmplwi r0, 0xa
|
||||
bne WPADiManageHandler_8FF8
|
||||
mr r3, r22
|
||||
bl WPADiRadioSensitivity
|
||||
WPADiManageHandler_8FF8:
|
||||
lbz r3, 0x0(r25)
|
||||
cmplwi r3, 0x5
|
||||
addi r0, r3, 0x1
|
||||
bne WPADiManageHandler_900C
|
||||
mr r0, r3
|
||||
WPADiManageHandler_900C:
|
||||
addi r22, r22, 0x1
|
||||
stb r0, 0x0(r25)
|
||||
cmpwi r22, 0x4
|
||||
addi r25, r25, 0x1
|
||||
addi r24, r24, 0x4
|
||||
addi r23, r23, 0x1
|
||||
blt WPADiManageHandler_8B48
|
||||
lhz r0, _afhCnt(r0)
|
||||
cmplwi r0, 0xea60
|
||||
bne WPADiManageHandler_9090
|
||||
lis r21, 0x8000
|
||||
li r4, 0x1
|
||||
addi r3, r21, 0x31a2
|
||||
bl DCInvalidateRange
|
||||
addi r3, r28, 0x108
|
||||
crclr 4*cr1+eq
|
||||
bl DEBUGPrint
|
||||
lbz r3, _afhChannel(r0)
|
||||
lbz r0, 0x31a2(r21)
|
||||
extsb r3, r3
|
||||
cmpw r3, r0
|
||||
beq WPADiManageHandler_9090
|
||||
bl OSDisableInterrupts
|
||||
lbz r0, 0x31a2(r21)
|
||||
stb r0, _afhChannel(r0)
|
||||
bl OSRestoreInterrupts
|
||||
lbz r4, 0x31a2(r21)
|
||||
addi r3, r28, 0x130
|
||||
crclr 4*cr1+eq
|
||||
bl DEBUGPrint
|
||||
lbz r0, _afhChannel(r0)
|
||||
extsb r3, r0
|
||||
bl WUDSetDisableChannel
|
||||
WPADiManageHandler_9090:
|
||||
lhz r6, _senseCnt(r0)
|
||||
lis r3, 0x1
|
||||
subi r0, r3, 0x15a0
|
||||
lbz r9, _checkCnt(r0)
|
||||
subi r4, r6, 0xa
|
||||
subfic r3, r6, 0xa
|
||||
nor r3, r4, r3
|
||||
lhz r10, _afhCnt(r0)
|
||||
srawi r8, r3, 31
|
||||
addi r7, r6, 0x1
|
||||
clrlwi r0, r0, 16
|
||||
subi r4, r9, 0x5
|
||||
subfic r3, r9, 0x5
|
||||
andc r7, r7, r8
|
||||
nor r5, r4, r3
|
||||
subf r4, r0, r10
|
||||
subf r3, r10, r0
|
||||
lbz r0, _scFlush(r0)
|
||||
srawi r6, r5, 31
|
||||
addi r5, r9, 0x1
|
||||
nor r4, r4, r3
|
||||
addi r3, r10, 0x1
|
||||
srawi r4, r4, 31
|
||||
andc r5, r5, r6
|
||||
andc r3, r3, r4
|
||||
cmpwi r0, 0x0
|
||||
sth r7, _senseCnt(r0)
|
||||
stb r5, _checkCnt(r0)
|
||||
sth r3, _afhCnt(r0)
|
||||
beq WPADiManageHandler_9138
|
||||
bl SCCheckStatus
|
||||
cmpwi r3, 0x0
|
||||
bne WPADiManageHandler_9138
|
||||
lis r3, _scArray@ha
|
||||
addi r3, r3, _scArray@l
|
||||
bl SCSetBtDeviceInfoArray
|
||||
cmpwi r3, 0x1
|
||||
bne WPADiManageHandler_9138
|
||||
li r3, 0x0
|
||||
bl SCFlushAsync
|
||||
li r0, 0x0
|
||||
stb r0, _scFlush(r0)
|
||||
WPADiManageHandler_9138:
|
||||
lbz r0, _scSetting(r0)
|
||||
cmpwi r0, 0x0
|
||||
beq WPADiManageHandler_91D4
|
||||
bl SCCheckStatus
|
||||
cmpwi r3, 0x0
|
||||
bne WPADiManageHandler_91D4
|
||||
bl SCGetBtDpdSensibility
|
||||
clrlwi r0, r3, 24
|
||||
cmplwi r0, 0x1
|
||||
bge WPADiManageHandler_9164
|
||||
li r0, 0x1
|
||||
WPADiManageHandler_9164:
|
||||
cmplwi r0, 0x5
|
||||
ble WPADiManageHandler_9170
|
||||
li r0, 0x5
|
||||
WPADiManageHandler_9170:
|
||||
stb r0, _dpdSensitivity(r0)
|
||||
bl SCGetWpadSensorBarPosition
|
||||
clrlwi r3, r3, 24
|
||||
subi r0, r3, 0x1
|
||||
cntlzw r0, r0
|
||||
extrwi r0, r0, 8, 19
|
||||
stb r0, _sensorBarPos(r0)
|
||||
bl SCGetWpadMotorMode
|
||||
clrlwi r3, r3, 24
|
||||
subi r0, r3, 0x1
|
||||
cntlzw r0, r0
|
||||
srwi r0, r0, 5
|
||||
stw r0, _rumble(r0)
|
||||
bl SCGetWpadSpeakerVolume
|
||||
clrlwi. r0, r3, 24
|
||||
mr r4, r3
|
||||
bne WPADiManageHandler_91B8
|
||||
li r4, 0x0
|
||||
WPADiManageHandler_91B8:
|
||||
clrlwi r0, r3, 24
|
||||
cmplwi r0, 0x7f
|
||||
blt WPADiManageHandler_91C8
|
||||
li r4, 0x7f
|
||||
WPADiManageHandler_91C8:
|
||||
li r0, 0x0
|
||||
stb r4, _speakerVolume(r0)
|
||||
stb r0, _scSetting(r0)
|
||||
WPADiManageHandler_91D4:
|
||||
bl BTA_HhGetAclQueueInfo
|
||||
WPADiManageHandler_91D8:
|
||||
addi r11, r1, 0x160
|
||||
bl _restgpr_19
|
||||
lwz r0, 0x164(r1)
|
||||
mtlr r0
|
||||
addi r1, r1, 0x160
|
||||
blr
|
||||
}
|
||||
#else
|
||||
static void WPADiManageHandler(OSAlarm* pAlarm, OSContext* pContext) {
|
||||
s32 status = WPADGetStatus();
|
||||
s32 chan;
|
||||
@@ -635,10 +1168,8 @@ static void WPADiManageHandler(OSAlarm* pAlarm, OSContext* pContext) {
|
||||
return;
|
||||
}
|
||||
|
||||
_recCnt = _recCnt == 0 ? 0 : _recCnt - 1;
|
||||
|
||||
if (_recFlag >= 0) {
|
||||
if (_recCnt == 0) {
|
||||
if (--_recCnt <= 0) {
|
||||
__reconnect(_recFlag);
|
||||
}
|
||||
return;
|
||||
@@ -685,6 +1216,9 @@ static void WPADiManageHandler(OSAlarm* pAlarm, OSContext* pContext) {
|
||||
|
||||
BTA_HhGetAclQueueInfo();
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
static void WPADiManageHandler0(OSAlarm* pAlarm, OSContext* pContext) {
|
||||
OSSwitchFiberEx((u32)pAlarm, (u32)pContext, 0, 0, WPADiManageHandler, __WPADiManageHandlerStack + sizeof(__WPADiManageHandlerStack));
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ void CDBConvTypeStrToFullPath(char* fullPath, char* yearStr, char* monthStr, cha
|
||||
void CDBConvFileNameStrToFullPath(char* fullPath, char* yearStr, char* monthStr, char* dayStr, char* hourStr, char* minuteStr, char* codeStr,
|
||||
char* typeStr, char* fileStr, CDBLocation location, u64* wiiId);
|
||||
|
||||
CDBDate CDBConvDirStrToCDBDate(char* yearStr, char* monthStr, char* dayStr, char* hourStr, char* minuteStr);
|
||||
CDBDate CDBConvDirStrToCDBDate(char* yearStr, char* monthStr, char* dayStr, char* hourStr, char* minuteStr, CDBLocation location, u64* wiiId);
|
||||
|
||||
void CDBConvGCStrToGCValue(char* gcStr, u32* gcValue);
|
||||
void CDBConvGCValueToGCStr(u32 gcValue, char* gcStr);
|
||||
|
||||
@@ -13,12 +13,12 @@ void CDBClampCDBDate(CDBDate* cdbDate);
|
||||
|
||||
CDBDate CDBMakeCDBDate(int year, int month, int day, int hour, int min, int sec);
|
||||
|
||||
CDBDate CDBMakeCDBDateDayBegin(int year, int month, int day);
|
||||
CDBDate CDBMakeCDBDateDayEnd(int year, int month, int day);
|
||||
CDBDate CDBMakeCDBDateMonthBegin(int year, int month);
|
||||
CDBDate CDBMakeCDBDateMonthEnd(int year, int month);
|
||||
CDBDate CDBMakeCDBDateYearBegin(int year);
|
||||
CDBDate CDBMakeCDBDateYearEnd(int year);
|
||||
CDBDate CDBMakeCDBDateDayBegin(int year, int month, int day, int hour, int min, int sec);
|
||||
CDBDate CDBMakeCDBDateDayEnd(int year, int month, int day, int hour, int min, int sec);
|
||||
CDBDate CDBMakeCDBDateMonthBegin(int year, int month, int day, int hour, int min, int sec);
|
||||
CDBDate CDBMakeCDBDateMonthEnd(int year, int month, int day, int hour, int min, int sec);
|
||||
CDBDate CDBMakeCDBDateYearBegin(int year, int month, int day, int hour, int min, int sec);
|
||||
CDBDate CDBMakeCDBDateYearEnd(int year, int month, int day, int hour, int min, int sec);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -58,21 +58,19 @@ CDBDate CDBMakeCDBDate(int year, int month, int day, int hour, int min, int sec)
|
||||
return OSTicksToSeconds(OSCalendarTimeToTicks(&calendar));
|
||||
}
|
||||
|
||||
CDBDate CDBMakeCDBDateDayBegin(int year, int month, int day) {
|
||||
CDBDate CDBMakeCDBDateDayBegin(int year, int month, int day, int hour, int min, int sec) {
|
||||
return CDBMakeCDBDate(year, month, day, MIN_HOUR, MIN_MINUTE, MIN_SECOND);
|
||||
}
|
||||
|
||||
CDBDate CDBMakeCDBDateDayEnd(int year, int month, int day) {
|
||||
CDBDate CDBMakeCDBDateDayEnd(int year, int month, int day, int hour, int min, int sec) {
|
||||
return CDBMakeCDBDate(year, month, day, MAX_HOUR, MAX_MINUTE, MAX_SECOND);
|
||||
}
|
||||
|
||||
CDBDate CDBMakeCDBDateMonthBegin(int year, int month) {
|
||||
CDBDate CDBMakeCDBDateMonthBegin(int year, int month, int day, int hour, int min, int sec) {
|
||||
return CDBMakeCDBDate(year, month, MIN_DAY, MIN_HOUR, MIN_MINUTE, MIN_SECOND);
|
||||
}
|
||||
|
||||
CDBDate CDBMakeCDBDateMonthEnd(int year, int month) {
|
||||
int day;
|
||||
|
||||
CDBDate CDBMakeCDBDateMonthEnd(int year, int month, int day, int hour, int min, int sec) {
|
||||
switch (month) {
|
||||
case 1: {
|
||||
day = 28;
|
||||
@@ -103,11 +101,11 @@ CDBDate CDBMakeCDBDateMonthEnd(int year, int month) {
|
||||
return CDBMakeCDBDate(year, month, day, MAX_HOUR, MAX_MINUTE, MAX_SECOND);
|
||||
}
|
||||
|
||||
CDBDate CDBMakeCDBDateYearBegin(int year) {
|
||||
CDBDate CDBMakeCDBDateYearBegin(int year, int month, int day, int hour, int min, int sec) {
|
||||
return CDBMakeCDBDate(year, MIN_MONTH - 1, MIN_DAY, MIN_HOUR, MIN_MINUTE, MIN_SECOND);
|
||||
}
|
||||
|
||||
CDBDate CDBMakeCDBDateYearEnd(int year) {
|
||||
CDBDate CDBMakeCDBDateYearEnd(int year, int month, int day, int hour, int min, int sec) {
|
||||
return CDBMakeCDBDate(year, MAX_MONTH - 1, MAX_DAY, MAX_HOUR, MAX_MINUTE, MAX_SECOND);
|
||||
}
|
||||
|
||||
@@ -233,7 +231,7 @@ void CDBConvFileNameStrToFullPath(char* fullPath, char* yearStr, char* monthStr,
|
||||
CDBFSConcatenatePath(fullPath, fileNameStr);
|
||||
}
|
||||
|
||||
CDBDate CDBConvDirStrToCDBDate(char* yearStr, char* monthStr, char* dayStr, char* hourStr, char* minuteStr) {
|
||||
CDBDate CDBConvDirStrToCDBDate(char* yearStr, char* monthStr, char* dayStr, char* hourStr, char* minuteStr, CDBLocation location, u64* wiiId) {
|
||||
return CDBMakeCDBDate(atoi(yearStr), atoi(monthStr), atoi(dayStr), atoi(hourStr), atoi(minuteStr), 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,11 +8,13 @@ void CDBCryptBufSysInit(CDBCryptBuf* cryptBuf) {
|
||||
cryptBuf->allocated = FALSE;
|
||||
}
|
||||
|
||||
CDBErr CDBCryptBufAllocate(CDBCryptBuf** cryptBuf) {
|
||||
// Some weird crap is going on with these functions.
|
||||
|
||||
CDBErr CDBCryptBufAllocate(CDBCryptBuf* cryptBuf) {
|
||||
CDBErr err = CDB_ERROR_OK;
|
||||
|
||||
if (s_cryptBuf->allocated == FALSE) {
|
||||
*cryptBuf = &s_cryptBuf[err];
|
||||
cryptBuf->buffer32[0] = (u32)&s_cryptBuf[err];
|
||||
s_cryptBuf[err].allocated = TRUE;
|
||||
return CDB_ERROR_OK;
|
||||
} else {
|
||||
@@ -21,12 +23,12 @@ CDBErr CDBCryptBufAllocate(CDBCryptBuf** cryptBuf) {
|
||||
}
|
||||
}
|
||||
|
||||
CDBErr CDBCryptBufFree(CDBCryptBuf** cryptBuf) {
|
||||
CDBErr CDBCryptBufFree(CDBCryptBuf* cryptBuf) {
|
||||
CDBErr err = CDB_ERROR_OK;
|
||||
|
||||
if (*cryptBuf == s_cryptBuf) {
|
||||
if ((CDBCryptBuf*)*cryptBuf->buffer32 == s_cryptBuf) {
|
||||
s_cryptBuf[err].allocated = FALSE;
|
||||
*cryptBuf = NULL;
|
||||
*cryptBuf->buffer32 = 0;
|
||||
return CDB_ERROR_OK;
|
||||
} else {
|
||||
CDBReportError("failed to free crypt buffer\n");
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -169,11 +169,11 @@ static const u32 AESiDecryptTable[] = {
|
||||
};
|
||||
|
||||
#define ROTATE(x,n) (((x) << (n)) | ((x) >> (32 - (n))))
|
||||
#define ENCRYPT(a,b,c,d) (((ROTATE(AESiEncryptTable[((b)>>16)&255],16) ^ ROTATE(AESiEncryptTable[(a)>>24],24)) ^ AESiEncryptTable[(d)&255]) ^ ROTATE(AESiEncryptTable[((c)>>8)&255],8))
|
||||
#define DECRYPT(a,b,c,d) (((ROTATE(AESiDecryptTable[((b)>>16)&255],16) ^ AESiDecryptTable[(d)&255]) ^ ROTATE(AESiDecryptTable[(a)>>24],24)) ^ ROTATE(AESiDecryptTable[((c)>>8)&255],8))
|
||||
#define SUBSTITUTE(table,a,b,c,d) ((((u32)table[(a)>>24]<<24) | table[(d)&255]) | (((u32)table[((b)>>16)&255]<<16) | ((u32)table[((c)>>8)&255]<<8)))
|
||||
#define ENCRYPT(a,b,c,d) (ROTATE(AESiEncryptTable[(a)>>24],24) ^ ROTATE(AESiEncryptTable[((b)>>16)&255],16) ^ ROTATE(AESiEncryptTable[((c)>>8)&255],8) ^ AESiEncryptTable[(d)&255])
|
||||
#define DECRYPT(a,b,c,d) (ROTATE(AESiDecryptTable[(a)>>24],24) ^ ROTATE(AESiDecryptTable[((b)>>16)&255],16) ^ ROTATE(AESiDecryptTable[((c)>>8)&255],8) ^ AESiDecryptTable[(d)&255])
|
||||
#define SUBSTITUTE(table,a,b,c,d) (((u32)table[(a)>>24]<<24) | ((u32)table[((b)>>16)&255]<<16) | ((u32)table[((c)>>8)&255]<<8) | table[(d)&255])
|
||||
|
||||
#define DECRYPT_FINAL(table,a,b,c,d,key) ((table[(d)&255] ^ ((u32)table[((c)>>8)&255]<<8)) ^ (((u32)table[((b)>>16)&255]<<16) ^ ((key) ^ ((u32)table[(a)>>24]<<24))))
|
||||
#define SUBSTITUTE_XOR(table,a,b,c,d) (((u32)table[(a)>>24]<<24) ^ ((u32)table[((b)>>16)&255]<<16) ^ ((u32)table[((c)>>8)&255]<<8) ^ table[(d)&255])
|
||||
|
||||
void AESiEncryptBlock(AESContext* context, u32* output, const u32* input) {
|
||||
u32 rounds = context->rounds;
|
||||
@@ -197,25 +197,22 @@ void AESiEncryptBlock(AESContext* context, u32* output, const u32* input) {
|
||||
|
||||
void AESiDecryptBlock(AESContext* context, u32* output, const u32* input) {
|
||||
u32 rounds=context->rounds;
|
||||
u32* key=context->keys;
|
||||
u32 b;
|
||||
u32 a;
|
||||
u32 c;
|
||||
u32 d;
|
||||
key += rounds*4;
|
||||
u32* key=context->keys + rounds*4;
|
||||
u32 a,b,c,d;
|
||||
if (context->needsTransform) {
|
||||
u32 round;
|
||||
for (round=1; round<context->rounds; ++round) {
|
||||
u32 word;
|
||||
u32* keys=context->keys + round*4;
|
||||
for (word=0; word<4; ++word) {
|
||||
u32 value=context->keys[round*4 + word];
|
||||
u32 value=keys[word];
|
||||
u32 twice=DOUBLE_BYTES(value);
|
||||
u32 four=DOUBLE_BYTES(twice);
|
||||
u32 eight=DOUBLE_BYTES(four)^value;
|
||||
u32 mixed=(ROTATE(eight,8) ^ (eight ^ four));
|
||||
mixed=(ROTATE(mixed,8) ^ (mixed ^ twice));
|
||||
mixed=(ROTATE(mixed,8) ^ (mixed ^ value));
|
||||
context->keys[round*4 + word]=mixed;
|
||||
u32 mixed=eight ^ (four ^ ROTATE(eight,8));
|
||||
mixed ^= twice ^ ROTATE(mixed,8);
|
||||
mixed ^= value ^ ROTATE(mixed,8);
|
||||
keys[word]=mixed;
|
||||
}
|
||||
}
|
||||
context->needsTransform=0;
|
||||
@@ -230,10 +227,10 @@ void AESiDecryptBlock(AESContext* context, u32* output, const u32* input) {
|
||||
a=nextA^key[0]; b=nextB^key[1]; c=nextC^key[2]; d=nextD^key[3];
|
||||
key-=4;
|
||||
}
|
||||
output[0]=DECRYPT_FINAL(AESiInvSubShiftTable,a,d,c,b,key[0]);
|
||||
output[1]=DECRYPT_FINAL(AESiInvSubShiftTable,b,a,d,c,key[1]);
|
||||
output[2]=DECRYPT_FINAL(AESiInvSubShiftTable,c,b,a,d,key[2]);
|
||||
output[3]=DECRYPT_FINAL(AESiInvSubShiftTable,d,c,b,a,key[3]);
|
||||
output[0]=SUBSTITUTE_XOR(AESiInvSubShiftTable,a,d,c,b)^key[0];
|
||||
output[1]=SUBSTITUTE_XOR(AESiInvSubShiftTable,b,a,d,c)^key[1];
|
||||
output[2]=SUBSTITUTE_XOR(AESiInvSubShiftTable,c,b,a,d)^key[2];
|
||||
output[3]=SUBSTITUTE_XOR(AESiInvSubShiftTable,d,c,b,a)^key[3];
|
||||
}
|
||||
|
||||
BOOL NETAESCreateEx(AESContext* context, const void* key, u32 keyLength, const void* iv, const AESBlockMode* mode) {
|
||||
|
||||
@@ -68,61 +68,45 @@ void NETMD5GetDigest(NETMD5Context* context, void* digest) {
|
||||
memset(context, 0, sizeof(*context));
|
||||
}
|
||||
|
||||
static inline u32 ReadMessageWord(const u32* data) {
|
||||
return __lwbrx((void*)data, 0);
|
||||
}
|
||||
|
||||
static inline u32 rotateSum(u32 state, const u32* word, u32 constant, int shift) {
|
||||
// Each rotation half reads its own byte-reversed message word.
|
||||
u32 right = ReadMessageWord(word);
|
||||
u32 left = ReadMessageWord(word);
|
||||
return ((state + (constant + left)) << shift) | ((constant + (state + right)) >> (32 - shift));
|
||||
}
|
||||
|
||||
static inline u32 rotateNextSum(u32 state, u32** cursor, u32 constant, int shift) {
|
||||
u32 right = ReadMessageWord(*cursor);
|
||||
u32 left = ReadMessageWord((*cursor)++);
|
||||
return ((state + (constant + left)) << shift) | ((constant + (state + right)) >> (32 - shift));
|
||||
}
|
||||
|
||||
#define STEP_NEXT(a, b, c, d, f, word, n) ((a) = (b) + rotateNextSum((a) + (f), &(word), *constant, n))
|
||||
#define STEP(a, b, c, d, f, word, n) ((a) = (b) + rotateSum((a) + (f), word, *constant, n))
|
||||
#define ROTATE(x, n) (((x) << (n)) | ((x) >> (32 - (n))))
|
||||
#define STEP(a, b, c, d, f, word, n) ((a) += (f), (a) = (b) + ROTATE(__lwbrx(0, (int)(word)) + (*constant + (a)), n))
|
||||
|
||||
static void ProcessBlock(NETMD5Context* context) {
|
||||
static u32 constants[64] = {0xD76AA478, 0xE8C7B756, 0x242070DB, 0xC1BDCEEE, 0xF57C0FAF, 0x4787C62A, 0xA8304613, 0xFD469501, 0x698098D8, 0x8B44F7AF, 0xFFFF5BB1, 0x895CD7BE, 0x6B901122, 0xFD987193, 0xA679438E, 0x49B40821, 0xF61E2562, 0xC040B340, 0x265E5A51, 0xE9B6C7AA, 0xD62F105D, 0x02441453, 0xD8A1E681, 0xE7D3FBC8, 0x21E1CDE6, 0xC33707D6, 0xF4D50D87, 0x455A14ED, 0xA9E3E905, 0xFCEFA3F8, 0x676F02D9, 0x8D2A4C8A, 0xFFFA3942, 0x8771F681, 0x6D9D6122, 0xFDE5380C, 0xA4BEEA44, 0x4BDECFA9, 0xF6BB4B60, 0xBEBFBC70, 0x289B7EC6, 0xEAA127FA, 0xD4EF3085, 0x04881D05, 0xD9D4D039, 0xE6DB99E5, 0x1FA27CF8, 0xC4AC5665, 0xF4292244, 0x432AFF97, 0xAB9423A7, 0xFC93A039, 0x655B59C3, 0x8F0CCC92, 0xFFEFF47D, 0x85845DD1, 0x6FA87E4F, 0xFE2CE6E0, 0xA3014314, 0x4E0811A1, 0xF7537E82, 0xBD3AF235, 0x2AD7D2BB, 0xEB86D391};
|
||||
static u32 indices[48] = {0x00000001, 0x00000006, 0x0000000B, 0x00000000, 0x00000005, 0x0000000A, 0x0000000F, 0x00000004, 0x00000009, 0x0000000E, 0x00000003, 0x00000008, 0x0000000D, 0x00000002, 0x00000007, 0x0000000C, 0x00000005, 0x00000008, 0x0000000B, 0x0000000E, 0x00000001, 0x00000004, 0x00000007, 0x0000000A, 0x0000000D, 0x00000000, 0x00000003, 0x00000006, 0x00000009, 0x0000000C, 0x0000000F, 0x00000002, 0x00000000, 0x00000007, 0x0000000E, 0x00000005, 0x0000000C, 0x00000003, 0x0000000A, 0x00000001, 0x00000008, 0x0000000F, 0x00000006, 0x0000000D, 0x00000004, 0x0000000B, 0x00000002, 0x00000009};
|
||||
u32 a = context->a, b = context->b, c = context->c, d = context->d;
|
||||
u32* cursor;
|
||||
u32* block;
|
||||
u32* word;
|
||||
u32* constant;
|
||||
u32* index;
|
||||
int round;
|
||||
u32* block;
|
||||
block = context->buffer32;
|
||||
cursor = block;
|
||||
word = block;
|
||||
constant = constants;
|
||||
index = indices;
|
||||
for (round = 0; round < 4; ++round) {
|
||||
STEP_NEXT(a,b,c,d,(b & c) | (~b & d),cursor,7); ++constant;
|
||||
STEP_NEXT(d,a,b,c,(a & b) | (~a & c),cursor,12); ++constant;
|
||||
STEP_NEXT(c,d,a,b,(d & a) | (~d & b),cursor,17); ++constant;
|
||||
STEP_NEXT(b,c,d,a,(c & d) | (~c & a),cursor,22); ++constant;
|
||||
}
|
||||
cursor = indices;
|
||||
for (round = 0; round < 4; ++round) {
|
||||
STEP(a,b,c,d,(b & d) | (c & ~d),block + *cursor,5); ++constant; ++cursor;
|
||||
STEP(d,a,b,c,(a & c) | (b & ~c),block + *cursor,9); ++constant; ++cursor;
|
||||
STEP(c,d,a,b,(d & b) | (a & ~b),block + *cursor,14); ++constant; ++cursor;
|
||||
STEP(b,c,d,a,(c & a) | (d & ~a),block + *cursor,20); ++constant; ++cursor;
|
||||
STEP(a,b,c,d,(b & c) | (~b & d),word,7); ++word; ++constant;
|
||||
STEP(d,a,b,c,(a & b) | (~a & c),word,12); ++word; ++constant;
|
||||
STEP(c,d,a,b,(d & a) | (~d & b),word,17); ++word; ++constant;
|
||||
STEP(b,c,d,a,(c & d) | (~c & a),word,22); ++word; ++constant;
|
||||
}
|
||||
for (round = 0; round < 4; ++round) {
|
||||
STEP(a,b,c,d,b ^ c ^ d,block + *cursor,4); ++constant; ++cursor;
|
||||
STEP(d,a,b,c,a ^ b ^ c,block + *cursor,11); ++constant; ++cursor;
|
||||
STEP(c,d,a,b,d ^ a ^ b,block + *cursor,16); ++constant; ++cursor;
|
||||
STEP(b,c,d,a,c ^ d ^ a,block + *cursor,23); ++constant; ++cursor;
|
||||
STEP(a,b,c,d,(b & d) | (c & ~d),block + *index,5); ++index; ++constant;
|
||||
STEP(d,a,b,c,(a & c) | (b & ~c),block + *index,9); ++index; ++constant;
|
||||
STEP(c,d,a,b,(d & b) | (a & ~b),block + *index,14); ++index; ++constant;
|
||||
STEP(b,c,d,a,(c & a) | (d & ~a),block + *index,20); ++index; ++constant;
|
||||
}
|
||||
for (round = 0; round < 4; ++round) {
|
||||
STEP(a,b,c,d,c ^ (b | ~d),block + *cursor,6); ++constant; ++cursor;
|
||||
STEP(d,a,b,c,b ^ (a | ~c),block + *cursor,10); ++constant; ++cursor;
|
||||
STEP(c,d,a,b,a ^ (d | ~b),block + *cursor,15); ++constant; ++cursor;
|
||||
STEP(b,c,d,a,d ^ (c | ~a),block + *cursor,21); ++constant; ++cursor;
|
||||
STEP(a,b,c,d,d ^ b ^ c,block + *index,4); ++index; ++constant;
|
||||
STEP(d,a,b,c,c ^ a ^ b,block + *index,11); ++index; ++constant;
|
||||
STEP(c,d,a,b,b ^ d ^ a,block + *index,16); ++index; ++constant;
|
||||
STEP(b,c,d,a,a ^ c ^ d,block + *index,23); ++index; ++constant;
|
||||
}
|
||||
for (round = 0; round < 4; ++round) {
|
||||
STEP(a,b,c,d,c ^ (b | ~d),block + *index,6); ++index; ++constant;
|
||||
STEP(d,a,b,c,b ^ (a | ~c),block + *index,10); ++index; ++constant;
|
||||
STEP(c,d,a,b,a ^ (d | ~b),block + *index,15); ++index; ++constant;
|
||||
STEP(b,c,d,a,d ^ (c | ~a),block + *index,21); ++index; ++constant;
|
||||
}
|
||||
context->a += a;
|
||||
context->b += b;
|
||||
|
||||
@@ -7,7 +7,8 @@ s32 NHTTPi_strcmp(const char* left, const char* right) { return strcmp(left,righ
|
||||
void* NHTTPi_memclr(void* destination, u32 size) { return memset(destination,0,size); }
|
||||
|
||||
static int LowerCase(int character) {
|
||||
return ((character >= 'A') & (character <= 'Z')) ? character + 32 : character;
|
||||
if((character>='A') & (character<='Z')) character+=32;
|
||||
return character;
|
||||
}
|
||||
|
||||
s32 NHTTPi_strnicmp(const char* left, const char* right, s32 length) {
|
||||
@@ -126,13 +127,12 @@ s32 NHTTPi_intToStr(char* destination, u32 value) {
|
||||
}
|
||||
|
||||
s32 NHTTPi_compareToken(const char* left, const char* right) {
|
||||
u32 rawLeft;
|
||||
while (LowerCase((s8)(rawLeft = *(const u8*)left)) == LowerCase((s8)*(const u8*)right)) {
|
||||
if ((s8)rawLeft == 0 || (s8)rawLeft == ' ') {
|
||||
return 0;
|
||||
}
|
||||
++left;
|
||||
++right;
|
||||
for (;;) {
|
||||
int rightCharacter=LowerCase(*right);
|
||||
int leftCharacter=LowerCase(*left);
|
||||
if(leftCharacter!=rightCharacter) break;
|
||||
if(*left==0 || *left==' ') return 0;
|
||||
++left; ++right;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
@@ -158,24 +158,20 @@ s32 NHTTPi_strtonum(const char* string, u32 length) {
|
||||
}
|
||||
|
||||
s32 NHTTPi_Base64Encode(char* destination, const char* source) {
|
||||
const char* table = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
char* output = destination;
|
||||
s32 length = strlen(source);
|
||||
s32 consumed = 0;
|
||||
|
||||
for (; consumed < length; consumed += 3) {
|
||||
output[0] = table[source[0] >> 2];
|
||||
output[1] = table[((source[0] & 3) << 4) + (source[1] >> 4)];
|
||||
output[2] = table[((source[1] & 15) << 2) + (source[2] >> 6)];
|
||||
output[3] = table[source[2] & 63];
|
||||
source += 3;
|
||||
output += 4;
|
||||
static char alphabet[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
const char* table=alphabet;
|
||||
char* output=destination;
|
||||
u32 length=strlen(source);
|
||||
s32 consumed=0;
|
||||
for(; consumed<(s32)length; consumed+=3) {
|
||||
output[0]=table[source[0]>>2];
|
||||
output[1]=table[((source[0]&3)<<4)+(source[1]>>4)];
|
||||
output[2]=table[((source[1]&15)<<2)+(source[2]>>6)];
|
||||
output[3]=table[source[2]&63];
|
||||
source+=3; output+=4;
|
||||
}
|
||||
if (consumed == length + 1) output[-1] = '=';
|
||||
else if (consumed == length + 2) {
|
||||
output[-2] = '=';
|
||||
output[-1] = '=';
|
||||
}
|
||||
*output = 0;
|
||||
if(consumed==length+1) output[-1]='=';
|
||||
else if(consumed==length+2) { output[-2]='='; output[-1]='='; }
|
||||
*output=0;
|
||||
return strlen(destination);
|
||||
}
|
||||
|
||||
@@ -7,9 +7,8 @@ s32 ConvertDateToDays(u16 year, u8 month, u8 day);
|
||||
void ConvertDaysToDate(u16* year, u8* month, u8* day, s32 days);
|
||||
|
||||
static inline BOOL IsLeapYear(u16 year) {
|
||||
s32 calendarYear = year;
|
||||
BOOL leap = FALSE;
|
||||
if ((calendarYear % 4 == 0 && calendarYear % 100 != 0) || calendarYear % 400 == 0)
|
||||
if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0)
|
||||
leap = TRUE;
|
||||
return leap;
|
||||
}
|
||||
@@ -153,7 +152,7 @@ NWC24Err NWC24iIsValidDate(u16 year, u8 month, u8 day) {
|
||||
s32 ConvertDateToDays(u16 year, u8 month, u8 day) {
|
||||
s32 daysOfYear;
|
||||
s32 yearOffset;
|
||||
s32 totalDays;
|
||||
s32 centuryLeapDays;
|
||||
s32 commonLeapDays;
|
||||
BOOL isLeapYear;
|
||||
|
||||
@@ -191,10 +190,11 @@ validDate:
|
||||
}
|
||||
|
||||
yearOffset = year - 1900;
|
||||
centuryLeapDays = (yearOffset + 299) / 400;
|
||||
daysOfYear += yearOffset * 365;
|
||||
totalDays = daysOfYear + (yearOffset + 299) / 400;
|
||||
daysOfYear += centuryLeapDays;
|
||||
commonLeapDays = (yearOffset - 1) / 4 - (yearOffset - 1) / 100;
|
||||
return totalDays + commonLeapDays;
|
||||
return daysOfYear + commonLeapDays;
|
||||
}
|
||||
|
||||
void ConvertDaysToDate(u16* year, u8* month, u8* day, s32 days) {
|
||||
@@ -231,7 +231,7 @@ void ConvertDaysToDate(u16* year, u8* month, u8* day, s32 days) {
|
||||
const u8* parsedMonth = month;
|
||||
previousDays = days;
|
||||
currentMonth = *parsedMonth;
|
||||
if (*parsedMonth == 2 && IsLeapYear(*year)) {
|
||||
if (currentMonth == 2 && IsLeapYear(*year)) {
|
||||
days -= 29;
|
||||
} else {
|
||||
days -= DAYS_OF_MONTH[currentMonth - 1];
|
||||
|
||||
@@ -253,37 +253,6 @@ static inline NWC24Err GetMaxDlTaskCount(u16* count) {
|
||||
return NWC24_OK;
|
||||
}
|
||||
|
||||
static inline BOOL IsDlTaskWritableGroup(u32 groupId, u32 flags) {
|
||||
BOOL allowed = FALSE;
|
||||
if (flags & 0x40) {
|
||||
if (groupId == NWC24GetGroupId()) {
|
||||
allowed = TRUE;
|
||||
}
|
||||
}
|
||||
return allowed;
|
||||
}
|
||||
|
||||
static inline NWC24Err ValidateWritableDlTask(const NWC24DlTask* dlTask) {
|
||||
const DlTaskData* task = (const DlTaskData*)dlTask;
|
||||
DlTaskListHeader* header = GetCachedDlHeader();
|
||||
if (task == NULL) {
|
||||
return NWC24_ERR_INVALID_VALUE;
|
||||
}
|
||||
if (header == NULL) {
|
||||
return NWC24_ERR_LIB_NOT_OPENED;
|
||||
}
|
||||
if (!NWC24IsMsgLibOpenedByTool() && !IsDlTaskOwner(task->appId)) {
|
||||
BOOL allowed = IsDlTaskWritableGroup(task->groupId, task->flags);
|
||||
if (!allowed) {
|
||||
return NWC24_ERR_PROTECTED;
|
||||
}
|
||||
}
|
||||
if (task->id != 0xffff && task->id >= header->maxTaskCount) {
|
||||
return NWC24_ERR_INVALID_VALUE;
|
||||
}
|
||||
return NWC24_OK;
|
||||
}
|
||||
|
||||
NWC24Err NWC24InitDlTask(NWC24DlTask* dlTask, NWC24DLType dlType) {
|
||||
char homePath[64] = {0};
|
||||
u32 nwc24IdHigh;
|
||||
@@ -335,7 +304,7 @@ NWC24Err NWC24InitDlTask(NWC24DlTask* dlTask, NWC24DLType dlType) {
|
||||
strcpy(task->fileName, "content.bin");
|
||||
}
|
||||
|
||||
result = ValidateWritableDlTask(dlTask);
|
||||
result = ValidateDlTask(dlTask, TRUE);
|
||||
return result >> 31;
|
||||
}
|
||||
|
||||
@@ -718,10 +687,10 @@ NWC24Err NWC24IterateDlTaskEx(NWC24DlIterateWork* dlIterateWork, NWC24DlId* dlIt
|
||||
return NWC24_ERR_DONE;
|
||||
}
|
||||
|
||||
static inline NWC24Err SetDlTaskAccessTime(const NWC24DlTask* dlTask, OSTime time) {
|
||||
static inline NWC24Err SetDlTaskAccessTime(NWC24DlTask* dlTask, OSTime time) {
|
||||
NWC24Work* work = NWC24WorkP;
|
||||
DlTaskListHeader* header = work != NULL ? (DlTaskListHeader*)work->dlHead : NULL;
|
||||
const DlTaskData* task = (const DlTaskData*)dlTask;
|
||||
DlTaskData* task = (DlTaskData*)dlTask;
|
||||
NWC24Err result;
|
||||
u16 taskId;
|
||||
if (task == NULL) { result = NWC24_ERR_INVALID_VALUE; }
|
||||
@@ -737,39 +706,19 @@ static inline NWC24Err SetDlTaskAccessTime(const NWC24DlTask* dlTask, OSTime tim
|
||||
return NWC24_OK;
|
||||
}
|
||||
|
||||
static inline NWC24Err CheckDlTaskForRetry(const DlTaskData* task) {
|
||||
DlTaskListHeader* header = NWC24WorkP == NULL ? NULL : (DlTaskListHeader*)NWC24WorkP->dlHead;
|
||||
if (task == NULL) {
|
||||
return NWC24_ERR_INVALID_VALUE;
|
||||
}
|
||||
if (header == NULL) {
|
||||
return NWC24_ERR_LIB_NOT_OPENED;
|
||||
}
|
||||
if (task->id != 0xffff && task->id >= header->maxTaskCount) {
|
||||
return NWC24_ERR_INVALID_VALUE;
|
||||
}
|
||||
static inline NWC24Err CheckDlTaskRetry(NWC24DlTask* dlTask, u8 retryCount) {
|
||||
DlTaskData* task = (DlTaskData*)dlTask;
|
||||
NWC24Err result = ValidateDlTask(dlTask, FALSE);
|
||||
u32 retryMask;
|
||||
if (result != NWC24_OK) { return result; }
|
||||
if (task->retryEnabled == 0) { return NWC24_ERR_INVALID_OPERATION; }
|
||||
retryMask = task->retryMask;
|
||||
if (retryMask == 0) { return NWC24_ERR_FATAL; }
|
||||
if (retryCount > 31) { return NWC24_ERR_INVALID_VALUE; }
|
||||
if ((retryMask & (1 << retryCount)) == 0) { return NWC24_ERR_DISABLED; }
|
||||
return NWC24_OK;
|
||||
}
|
||||
|
||||
static inline NWC24Err CheckDlTaskRetry(const NWC24DlTask* dlTask, u8 retryCount) {
|
||||
const DlTaskData* task = (const DlTaskData*)dlTask;
|
||||
NWC24Err result;
|
||||
result = CheckDlTaskForRetry(task);
|
||||
if (result != NWC24_OK) {
|
||||
return result;
|
||||
}
|
||||
if (task->retryEnabled == 0) {
|
||||
return NWC24_ERR_INVALID_OPERATION;
|
||||
}
|
||||
if (task->retryMask == 0) {
|
||||
return NWC24_ERR_FATAL;
|
||||
}
|
||||
if (retryCount > 31) {
|
||||
return NWC24_ERR_INVALID_VALUE;
|
||||
}
|
||||
return ((1U << retryCount) & task->retryMask) == 0 ? NWC24_ERR_DISABLED : NWC24_OK;
|
||||
}
|
||||
static inline NWC24Err UpdateDlTaskAccessTime(const NWC24DlTask* dlTask) {
|
||||
static inline NWC24Err UpdateDlTaskAccessTime(NWC24DlTask* dlTask) {
|
||||
OSTime universalTime;
|
||||
NWC24Err result = NWC24iGetUniversalTime(&universalTime);
|
||||
if (result >= NWC24_OK) {
|
||||
@@ -779,30 +728,24 @@ static inline NWC24Err UpdateDlTaskAccessTime(const NWC24DlTask* dlTask) {
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline NWC24Err ClearDlTaskError(NWC24DlTask* dlTask) {
|
||||
DlTaskData* task = (DlTaskData*)dlTask;
|
||||
NWC24Err result;
|
||||
result = ValidateWritableDlTask(dlTask);
|
||||
if (result != NWC24_OK) {
|
||||
return result;
|
||||
}
|
||||
task->unknown_0x20 = 0;
|
||||
task->unknown_0x1a = 0;
|
||||
return NWC24_OK;
|
||||
}
|
||||
|
||||
NWC24Err NWC24UpdateDlTask(NWC24DlTask* dlTask) {
|
||||
DlTaskData* task = (DlTaskData*)dlTask;
|
||||
DlTaskListHeader* header;
|
||||
u16 taskId;
|
||||
OSTime universalTime;
|
||||
NWC24Err result;
|
||||
|
||||
result = ValidateWritableDlTask(dlTask);
|
||||
result = ValidateDlTask(dlTask, TRUE);
|
||||
if (result != NWC24_OK) { return result; }
|
||||
taskId = task->id;
|
||||
if (taskId == 0xffff || taskId >= GetCachedDlHeader()->maxTaskCount) { return NWC24_ERR_INVALID_VALUE; }
|
||||
result = UpdateDlTaskAccessTime(dlTask);
|
||||
if (result < NWC24_OK) { return result; }
|
||||
ClearDlTaskError(dlTask);
|
||||
result = ValidateDlTask(dlTask, TRUE);
|
||||
if (result == NWC24_OK) {
|
||||
task->unknown_0x20 = 0;
|
||||
task->unknown_0x1a = 0;
|
||||
}
|
||||
if (task->retryEnabled == 1) {
|
||||
while ((result = CheckDlTaskRetry(dlTask, task->retryCount)) == NWC24_ERR_DISABLED) {
|
||||
task->retryCount = (task->retryCount + 1) & 0x1f;
|
||||
@@ -1101,7 +1044,6 @@ closeList:
|
||||
NWC24Err NWC24iCheckDlHeaderConsistency(DlTaskListHeader* header, BOOL repair) {
|
||||
NWC24DlTask task;
|
||||
NWC24DlTask* taskPointer = &task;
|
||||
NWC24DlTask* readTask = &task;
|
||||
NWC24DlId taskId;
|
||||
NWC24Err result;
|
||||
DlTaskListHeader* currentHeader;
|
||||
@@ -1118,7 +1060,7 @@ NWC24Err NWC24iCheckDlHeaderConsistency(DlTaskListHeader* header, BOOL repair) {
|
||||
if (currentHeader->entries[taskId].appId == 0) { result = NWC24_ERR_NOT_FOUND; }
|
||||
}
|
||||
if (result != NWC24_OK || !shouldRepair) { continue; }
|
||||
result = ReadDlTaskInline(readTask, taskId);
|
||||
result = ReadDlTaskInline(taskPointer, taskId);
|
||||
if (result < NWC24_OK) {
|
||||
if (ValidateDlTask(taskPointer, FALSE) == NWC24_OK) {
|
||||
result = DeleteDlTask(taskPointer);
|
||||
@@ -1285,44 +1227,32 @@ NWC24Err StoreDlTask(NWC24DlTask* dlTask) {
|
||||
return closeResult;
|
||||
}
|
||||
|
||||
static inline NWC24Err CheckDlUrl(const DlTaskData* task) {
|
||||
const char* url = task->url;
|
||||
static inline NWC24Err ValidateDlTaskUrl(NWC24DlTask* dlTask) {
|
||||
DlTaskData* task = (DlTaskData*)dlTask;
|
||||
DlTaskListHeader* header = GetCachedDlHeader();
|
||||
NWC24Err result;
|
||||
result = NWC24iCheckStringLength(url, 7, 0x100);
|
||||
if (result < NWC24_OK) {
|
||||
return result;
|
||||
if (task->id >= header->maxTaskCount && task->id != 0xffff) { return NWC24_ERR_INVALID_VALUE; }
|
||||
{
|
||||
const char* url = task->url;
|
||||
result = NWC24iCheckStringLength(url, 7, 0x100);
|
||||
if (result >= NWC24_OK) {
|
||||
if (strncmp(url, "http://", 7) != 0 && strncmp(url, "https://", 8) != 0) { result = NWC24_ERR_FORMAT; }
|
||||
else { result = NWC24_OK; }
|
||||
}
|
||||
if (result < NWC24_OK) { return result; }
|
||||
return NWC24_OK;
|
||||
}
|
||||
if (strncmp(url, "http://", 7) != 0 && strncmp(url, "https://", 8) != 0) {
|
||||
return NWC24_ERR_FORMAT;
|
||||
}
|
||||
return NWC24_OK;
|
||||
}
|
||||
|
||||
static inline DlTaskEntry* GetDlTaskEntryHeader(u16 taskId) {
|
||||
return &GetCachedDlHeader()->entries[taskId];
|
||||
}
|
||||
|
||||
static inline NWC24Err ValidateDlTaskUrl(const NWC24DlTask* dlTask) {
|
||||
const DlTaskData* task = (const DlTaskData*)dlTask;
|
||||
NWC24Err result;
|
||||
if (task->id >= GetCachedDlHeader()->maxTaskCount && task->id != 0xffff) {
|
||||
return NWC24_ERR_INVALID_VALUE;
|
||||
}
|
||||
result = CheckDlUrl(task);
|
||||
if (result < NWC24_OK) {
|
||||
return result;
|
||||
}
|
||||
return NWC24_OK;
|
||||
}
|
||||
|
||||
static inline NWC24Err FindFreeDlTask(NWC24DlTask* dlTask, u32 taskCount, u32 maxTaskCount) {
|
||||
static inline NWC24Err FindFreeDlTask(NWC24DlTask* dlTask, u16 taskCount, u16 maxTaskCount) {
|
||||
DlTaskListHeader* header = GetCachedDlHeader();
|
||||
NWC24DlId taskId;
|
||||
if (dlTask == NULL || taskCount > maxTaskCount || taskCount >= header->maxTaskCount || maxTaskCount > header->maxTaskCount) {
|
||||
return NWC24_ERR_INVALID_VALUE;
|
||||
}
|
||||
for (taskId = taskCount; taskId < maxTaskCount; taskId++) {
|
||||
if (GetDlTaskEntryHeader(taskId)->appId == 0) {
|
||||
header = GetCachedDlHeader();
|
||||
if (header->entries[taskId].appId == 0) {
|
||||
((DlTaskData*)dlTask)->id = taskId;
|
||||
return NWC24_OK;
|
||||
}
|
||||
@@ -1330,10 +1260,24 @@ static inline NWC24Err FindFreeDlTask(NWC24DlTask* dlTask, u32 taskCount, u32 ma
|
||||
return NWC24_ERR_FULL;
|
||||
}
|
||||
|
||||
|
||||
static inline NWC24Err RetryAndStoreDlTask(NWC24DlTask* dlTask) {
|
||||
static inline NWC24Err UpdateDlTaskInline(NWC24DlTask* dlTask) {
|
||||
DlTaskData* task = (DlTaskData*)dlTask;
|
||||
DlTaskListHeader* header;
|
||||
u16 taskId;
|
||||
OSTime universalTime;
|
||||
NWC24Err result;
|
||||
|
||||
result = ValidateDlTask(dlTask, TRUE);
|
||||
if (result != NWC24_OK) { return result; }
|
||||
taskId = task->id;
|
||||
if (taskId == 0xffff || taskId >= GetCachedDlHeader()->maxTaskCount) { return NWC24_ERR_INVALID_VALUE; }
|
||||
result = UpdateDlTaskAccessTime(dlTask);
|
||||
if (result < NWC24_OK) { return result; }
|
||||
result = ValidateDlTask(dlTask, TRUE);
|
||||
if (result == NWC24_OK) {
|
||||
task->unknown_0x20 = 0;
|
||||
task->unknown_0x1a = 0;
|
||||
}
|
||||
if (task->retryEnabled == 1) {
|
||||
while ((result = CheckDlTaskRetry(dlTask, task->retryCount)) == NWC24_ERR_DISABLED) {
|
||||
task->retryCount = (task->retryCount + 1) & 0x1f;
|
||||
@@ -1342,19 +1286,6 @@ static inline NWC24Err RetryAndStoreDlTask(NWC24DlTask* dlTask) {
|
||||
}
|
||||
return StoreDlTask(dlTask);
|
||||
}
|
||||
|
||||
static inline NWC24Err UpdateDlTaskInline(NWC24DlTask* dlTask) {
|
||||
DlTaskData* task = (DlTaskData*)dlTask;
|
||||
NWC24Err result;
|
||||
|
||||
result = ValidateWritableDlTask(dlTask);
|
||||
if (result != NWC24_OK) { return result; }
|
||||
if (task->id == 0xffff || task->id >= GetCachedDlHeader()->maxTaskCount) { return NWC24_ERR_INVALID_VALUE; }
|
||||
result = UpdateDlTaskAccessTime(dlTask);
|
||||
if (result < NWC24_OK) { return result; }
|
||||
ClearDlTaskError(dlTask);
|
||||
return RetryAndStoreDlTask(dlTask);
|
||||
}
|
||||
NWC24Err AddTaskInternal(NWC24DlTask* dlTask, u16 taskCount, u16 maxTaskCount) {
|
||||
DlTaskData* task = (DlTaskData*)dlTask;
|
||||
NWC24Err result;
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
#include <revolution/nwc24.h>
|
||||
|
||||
#include <revolution/os.h>
|
||||
#include <revolution/sc.h>
|
||||
#include <revolution/ncd.h>
|
||||
#include <revolution/verdefs.h>
|
||||
|
||||
#define MANAGE_ERROR_CODE_BASE 109000
|
||||
@@ -292,104 +290,166 @@ NWC24Err NWC24GetSchedulerError(s32* numErrors, s32* errorCode) {
|
||||
return result;
|
||||
}
|
||||
|
||||
extern NCDErr NCDiGetEnabledConfigList(u32* wiredList, u32* wirelessList, u32* aossList);
|
||||
extern NWC24Err NWC24iMBoxCheck(NWC24MBoxType type, u32 size);
|
||||
NWC24Err AnalyzeScdErrors(s32* errorCode, u32 usage);
|
||||
#ifdef __MWERKS__
|
||||
extern void _savegpr_27();
|
||||
extern void _restgpr_27();
|
||||
extern void NCDiGetEnabledConfigList();
|
||||
extern NWC24Err AnalyzeScdErrors(s32* errorCode, u32 usage);
|
||||
extern void NWC24iMBoxCheck();
|
||||
extern void SCCheckStatus();
|
||||
extern void SCGetWCFlags();
|
||||
extern void SCGetEULA();
|
||||
extern void SCGetNetContentRestrictions();
|
||||
extern void SCGetParentalControl();
|
||||
|
||||
NWC24Err NWC24Check(u32 usage) {
|
||||
NWC24Err result;
|
||||
NWC24Err err;
|
||||
SCParentalControlsInfo pcInfo;
|
||||
u32 wiredList;
|
||||
u32 wirelessList;
|
||||
u32 aossList;
|
||||
NWC24IdCreationStage stage;
|
||||
s32 errorCode;
|
||||
u32 status;
|
||||
u32 wcFlags;
|
||||
BOOL eula;
|
||||
u32 restrictions;
|
||||
asm NWC24Err NWC24Check(register u32 usage) {
|
||||
nofralloc
|
||||
|
||||
GlobalErrorCode = 0;
|
||||
stwu r1, -0x80(r1)
|
||||
mflr r0
|
||||
stw r0, 0x84(r1)
|
||||
addi r11, r1, 0x80
|
||||
bl _savegpr_27
|
||||
lwz r0, Opened(r0)
|
||||
li r4, 0
|
||||
stw r4, GlobalErrorCode(r0)
|
||||
mr r27, r3
|
||||
cmpwi r0, 1
|
||||
beq _NWC24Check_open
|
||||
li r31, -9
|
||||
b _NWC24Check_return
|
||||
|
||||
if (Opened != NWC24_LIB_OPENED) {
|
||||
result = NWC24_ERR_LIB_NOT_OPENED;
|
||||
} else {
|
||||
result = NWC24_ERR_DISABLED;
|
||||
_NWC24Check_open:
|
||||
li r31, -0x27
|
||||
|
||||
do {
|
||||
do {
|
||||
status = SCCheckStatus();
|
||||
} while (status == SC_STATUS_BUSY);
|
||||
_NWC24Check_status:
|
||||
bl SCCheckStatus
|
||||
cmplwi r3, 1
|
||||
beq _NWC24Check_status
|
||||
cmplwi r3, 2
|
||||
bne _NWC24Check_status_ok
|
||||
lis r3, -2
|
||||
addi r0, r3, 0x55c8
|
||||
stw r0, GlobalErrorCode(r0)
|
||||
b _NWC24Check_return
|
||||
|
||||
if (status == SC_STATUS_FATAL) {
|
||||
GlobalErrorCode = -109112;
|
||||
break;
|
||||
}
|
||||
_NWC24Check_status_ok:
|
||||
bl SCGetWCFlags
|
||||
clrlwi r29, r3, 0x1f
|
||||
bl SCGetEULA
|
||||
mr r30, r3
|
||||
bl SCGetNetContentRestrictions
|
||||
rlwinm r28, r3, 0, 0x1e, 0x1e
|
||||
addi r3, r1, 0x1c
|
||||
bl SCGetParentalControl
|
||||
cmpwi r29, 0
|
||||
bne _NWC24Check_eula
|
||||
lis r3, -2
|
||||
addi r0, r3, 0x55ad
|
||||
stw r0, GlobalErrorCode(r0)
|
||||
b _NWC24Check_return
|
||||
|
||||
wcFlags = SCGetWCFlags() & SC_WC_FLAGS_ENABLED;
|
||||
eula = SCGetEULA();
|
||||
restrictions =
|
||||
SCGetNetContentRestrictions() & SC_NET_RESTRICTIONS_MSG_BOARD;
|
||||
SCGetParentalControl(&pcInfo);
|
||||
_NWC24Check_eula:
|
||||
cmpwi r30, 0
|
||||
bne _NWC24Check_restrictions
|
||||
lis r3, -2
|
||||
addi r0, r3, 0x55cd
|
||||
stw r0, GlobalErrorCode(r0)
|
||||
b _NWC24Check_return
|
||||
|
||||
if (!wcFlags) {
|
||||
GlobalErrorCode = -109139;
|
||||
break;
|
||||
}
|
||||
_NWC24Check_restrictions:
|
||||
clrlwi. r30, r27, 0x1f
|
||||
beq _NWC24Check_config
|
||||
lbz r0, 0x1c(r1)
|
||||
rlwinm. r0, r0, 0, 0x18, 0x18
|
||||
beq _NWC24Check_config
|
||||
cmpwi r28, 0
|
||||
beq _NWC24Check_config
|
||||
lis r3, -2
|
||||
addi r0, r3, 0x55cd
|
||||
stw r0, GlobalErrorCode(r0)
|
||||
b _NWC24Check_return
|
||||
|
||||
if (!eula) {
|
||||
GlobalErrorCode = -109107;
|
||||
break;
|
||||
}
|
||||
_NWC24Check_config:
|
||||
addi r3, r1, 0x18
|
||||
addi r4, r1, 0x14
|
||||
addi r5, r1, 0x10
|
||||
li r31, -0x1f
|
||||
bl NCDiGetEnabledConfigList
|
||||
cmpwi r3, 0
|
||||
bge _NWC24Check_config_ok
|
||||
lis r3, -2
|
||||
addi r0, r3, 0x55b3
|
||||
stw r0, GlobalErrorCode(r0)
|
||||
b _NWC24Check_return
|
||||
|
||||
if ((usage & 1) && (pcInfo.enable & SC_PARENTAL_FLAG_ENABLED) &&
|
||||
restrictions) {
|
||||
GlobalErrorCode = -109107;
|
||||
break;
|
||||
}
|
||||
_NWC24Check_config_ok:
|
||||
lwz r0, 0x18(r1)
|
||||
cmpwi r0, 0
|
||||
bne _NWC24Check_id
|
||||
lwz r0, 0x14(r1)
|
||||
cmpwi r0, 0
|
||||
bne _NWC24Check_id
|
||||
lwz r0, 0x10(r1)
|
||||
cmpwi r0, 0
|
||||
bne _NWC24Check_id
|
||||
lis r3, -1
|
||||
addi r0, r3, 0x3b85
|
||||
stw r0, GlobalErrorCode(r0)
|
||||
b _NWC24Check_return
|
||||
|
||||
result = NWC24_ERR_NETWORK;
|
||||
if (NCDiGetEnabledConfigList(&wiredList, &wirelessList,
|
||||
&aossList) < 0) {
|
||||
GlobalErrorCode = -109133;
|
||||
break;
|
||||
}
|
||||
_NWC24Check_id:
|
||||
cmpwi r30, 0
|
||||
beq _NWC24Check_scheduler
|
||||
addi r3, r1, 0xc
|
||||
bl NWC24GetIdCreationStage
|
||||
lwz r0, 0xc(r1)
|
||||
cmpwi r0, 2
|
||||
beq _NWC24Check_scheduler
|
||||
lis r3, -2
|
||||
addi r0, r3, 0x55a8
|
||||
stw r0, GlobalErrorCode(r0)
|
||||
b _NWC24Check_return
|
||||
|
||||
if (wiredList == 0 && wirelessList == 0 && aossList == 0) {
|
||||
GlobalErrorCode = -50299;
|
||||
break;
|
||||
}
|
||||
_NWC24Check_scheduler:
|
||||
li r0, 0
|
||||
mr r4, r27
|
||||
stw r0, 8(r1)
|
||||
addi r3, r1, 8
|
||||
bl AnalyzeScdErrors
|
||||
cmpwi r3, 0
|
||||
bge _NWC24Check_mbox
|
||||
lwz r0, 8(r1)
|
||||
mr r31, r3
|
||||
stw r0, GlobalErrorCode(r0)
|
||||
b _NWC24Check_return
|
||||
|
||||
if (usage & 1) {
|
||||
NWC24GetIdCreationStage(&stage);
|
||||
if (stage != NWC24_IDCS_REGISTERED) {
|
||||
GlobalErrorCode = -109144;
|
||||
break;
|
||||
}
|
||||
}
|
||||
_NWC24Check_mbox:
|
||||
li r3, 0
|
||||
li r4, 0
|
||||
bl NWC24iMBoxCheck
|
||||
cmpwi r3, -6
|
||||
mr r31, r3
|
||||
bne _NWC24Check_mbox_done
|
||||
lis r4, -2
|
||||
addi r0, r4, 0x55ce
|
||||
stw r0, GlobalErrorCode(r0)
|
||||
|
||||
errorCode = 0;
|
||||
err = AnalyzeScdErrors(&errorCode, usage);
|
||||
if (err < 0) {
|
||||
result = err;
|
||||
GlobalErrorCode = errorCode;
|
||||
break;
|
||||
}
|
||||
_NWC24Check_mbox_done:
|
||||
cmpwi r3, -6
|
||||
beq _NWC24Check_return
|
||||
li r31, 0
|
||||
|
||||
result = NWC24iMBoxCheck(NWC24_MBOX_TYPE_SEND, 0);
|
||||
if (result == NWC24_ERR_FULL) {
|
||||
GlobalErrorCode = -109106;
|
||||
}
|
||||
if (result != NWC24_ERR_FULL) {
|
||||
result = NWC24_OK;
|
||||
}
|
||||
} while (0);
|
||||
}
|
||||
|
||||
return result;
|
||||
_NWC24Check_return:
|
||||
addi r11, r1, 0x80
|
||||
mr r3, r31
|
||||
bl _restgpr_27
|
||||
lwz r0, 0x84(r1)
|
||||
mtlr r0
|
||||
addi r1, r1, 0x80
|
||||
blr
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
s32 NWC24GetErrorCode() {
|
||||
return GlobalErrorCode;
|
||||
|
||||
@@ -73,28 +73,22 @@ NWC24Err NWC24ReadMsgSubjectPublic(const NWC24MsgObj* msg, u16* subject, u32* su
|
||||
truncated = TRUE;
|
||||
}
|
||||
result = NWC24ReadMsgSubject(msg, (char*)work, subjectDataSize);
|
||||
switch (result) {
|
||||
case NWC24_OK:
|
||||
break;
|
||||
default:
|
||||
if (result == NWC24_ERR_OVERFLOW) {
|
||||
truncated = TRUE;
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
if (result != NWC24_OK) {
|
||||
if (result == NWC24_ERR_OVERFLOW) {
|
||||
truncated = TRUE;
|
||||
} else {
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
charsetBuffer = NWC24WorkP->stringWork;
|
||||
result =
|
||||
NWC24DecodeMIMEHeaderFieldBody((u8*)charsetBuffer, 0x40, decodedData, decodedCapacity, &decodedSize, work, subjectDataSize);
|
||||
switch (result) {
|
||||
case NWC24_OK:
|
||||
break;
|
||||
default:
|
||||
if (result == NWC24_ERR_OVERFLOW) {
|
||||
truncated = TRUE;
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
if (result != NWC24_OK) {
|
||||
if (result == NWC24_ERR_OVERFLOW) {
|
||||
truncated = TRUE;
|
||||
} else {
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
*subjectSize = originalSize;
|
||||
result =
|
||||
@@ -146,15 +140,11 @@ NWC24Err NWC24ReadMsgTextPublic(const NWC24MsgObj* msg, u16* text, u32* textSize
|
||||
}
|
||||
charsetBuffer = NWC24WorkP->stringWork + 0x20;
|
||||
result = NWC24ReadMsgTextEx(msg, (char*)work, textDataSize, charsetBuffer, 0x40);
|
||||
switch (result) {
|
||||
case NWC24_OK:
|
||||
break;
|
||||
default:
|
||||
if (result == NWC24_ERR_OVERFLOW) {
|
||||
truncated = TRUE;
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
if (result != NWC24_OK) {
|
||||
if (result != NWC24_ERR_OVERFLOW) {
|
||||
goto done;
|
||||
}
|
||||
truncated = TRUE;
|
||||
}
|
||||
|
||||
*textSize = originalSize;
|
||||
@@ -243,12 +233,11 @@ NWC24Err NWC24SetMsgSubjectAndTextPublic(NWC24MsgObj* msg, const u16* subject, u
|
||||
NWC24MsgObjPrivate* privateMsg = (NWC24MsgObjPrivate*)msg;
|
||||
NWC24Work* nwcWork;
|
||||
u32 textSourceSize;
|
||||
u32 textCapacity;
|
||||
u32 textWorkSize;
|
||||
BOOL is7Bit;
|
||||
NWC24Charset charset;
|
||||
u8* subjectWork;
|
||||
u32 subjectWorkSize;
|
||||
u8* subjectWork;
|
||||
NWC24Err result;
|
||||
|
||||
if (((privateMsg->type & 0x100) == 0) || ((privateMsg->type & 0x200) != 0)) {
|
||||
@@ -284,8 +273,7 @@ NWC24Err NWC24SetMsgSubjectAndTextPublic(NWC24MsgObj* msg, const u16* subject, u
|
||||
if (NWC24ParseCharsetStr(&charset, nwcWork->stringWork) != NWC24_OK) {
|
||||
charset = 0;
|
||||
}
|
||||
textCapacity = (workSize * textSize) / (textSize + subjectSize * 4);
|
||||
textWorkSize = textCapacity;
|
||||
textWorkSize = (workSize * textSize) / (textSize + subjectSize * 4);
|
||||
subjectWorkSize = workSize - textWorkSize;
|
||||
subjectWork = work + textWorkSize;
|
||||
textSourceSize = textSize;
|
||||
|
||||
@@ -8,35 +8,74 @@ extern void __shr2u(void);
|
||||
extern void __shl2i(void);
|
||||
|
||||
static NWC24UserId getUnScrambleId(NWC24UserId id);
|
||||
NWC24Err NWC24CheckUserId(NWC24UserId id) {
|
||||
NWC24UserId myId;
|
||||
u64 value;
|
||||
int i;
|
||||
u32 area;
|
||||
u32 myArea;
|
||||
|
||||
NWC24GetMyUserId(&myId);
|
||||
if (myId == id) {
|
||||
return NWC24_ERR_ID_GENERATED;
|
||||
}
|
||||
myArea = (getUnScrambleId(myId) >> 47) & 7;
|
||||
value = getUnScrambleId(id);
|
||||
area = (value >> 47) & 7;
|
||||
for (i = 0; i < 0x2B; i++) {
|
||||
if ((value >> (0x35 - (i + 1))) & 1) {
|
||||
value ^= (u64)0x635 << (0x2A - i);
|
||||
}
|
||||
}
|
||||
if (value != 0) {
|
||||
return NWC24_ERR_ID_CRC;
|
||||
}
|
||||
if (myArea == 0 && area != 0) {
|
||||
return NWC24_ERR_PROTECTED;
|
||||
}
|
||||
return NWC24_OK;
|
||||
asm NWC24Err NWC24CheckUserId(register NWC24UserId id) {
|
||||
stwu r1,-0x30(r1)
|
||||
mfspr r0,LR
|
||||
stw r0,0x34(r1)
|
||||
addi r11,r1,0x30
|
||||
bl _savegpr_27
|
||||
or r28,r3,r3
|
||||
or r27,r4,r4
|
||||
addi r3,r1,0x8
|
||||
bl NWC24GetMyUserId
|
||||
lwz r3,0x8(r1)
|
||||
lwz r4,0xc(r1)
|
||||
xor r0,r3,r28
|
||||
xor r5,r4,r27
|
||||
or. r0,r5,r0
|
||||
bne NWC24CheckUserId_not_same
|
||||
li r3,-0x23
|
||||
b NWC24CheckUserId_return
|
||||
NWC24CheckUserId_not_same:
|
||||
bl getUnScrambleId
|
||||
or r4,r27,r27
|
||||
rlwinm r27,r3,0x11,0x1d,0x1f
|
||||
or r3,r28,r28
|
||||
bl getUnScrambleId
|
||||
or r30,r4,r4
|
||||
or r31,r3,r3
|
||||
rlwinm r28,r3,0x11,0x1d,0x1f
|
||||
li r29,0
|
||||
NWC24CheckUserId_crc_loop:
|
||||
addi r0,r29,1
|
||||
or r3,r31,r31
|
||||
or r4,r30,r30
|
||||
subfic r5,r0,0x35
|
||||
bl __shr2u
|
||||
rlwinm. r0,r4,0,0x1f,0x1f
|
||||
beq NWC24CheckUserId_crc_next
|
||||
subfic r5,r29,0x2a
|
||||
li r4,0x635
|
||||
li r3,0
|
||||
bl __shl2i
|
||||
xor r30,r30,r4
|
||||
xor r31,r31,r3
|
||||
NWC24CheckUserId_crc_next:
|
||||
addi r29,r29,1
|
||||
cmpwi r29,0x2b
|
||||
blt NWC24CheckUserId_crc_loop
|
||||
or. r0,r30,r31
|
||||
beq NWC24CheckUserId_crc_ok
|
||||
li r3,-0x25
|
||||
b NWC24CheckUserId_return
|
||||
NWC24CheckUserId_crc_ok:
|
||||
cmpwi r27,0
|
||||
bne NWC24CheckUserId_return_ok
|
||||
cmpwi r28,0
|
||||
beq NWC24CheckUserId_return_ok
|
||||
li r3,-0x7
|
||||
b NWC24CheckUserId_return
|
||||
NWC24CheckUserId_return_ok:
|
||||
li r3,0
|
||||
NWC24CheckUserId_return:
|
||||
addi r11,r1,0x30
|
||||
bl _restgpr_27
|
||||
lwz r0,0x34(r1)
|
||||
mtspr LR,r0
|
||||
addi r1,r1,0x30
|
||||
blr
|
||||
}
|
||||
|
||||
|
||||
NWC24Err NWC24iCheckUserIdCRC(NWC24UserId id) {
|
||||
u64 value = getUnScrambleId(id);
|
||||
int i;
|
||||
|
||||
@@ -414,27 +414,503 @@ s32 VFi_NandFlushNANDFromHandleIdx(s32 i_handleIdx, BOOL i_setLastDeviceError) {
|
||||
return NAND_RESULT_OK;
|
||||
}
|
||||
|
||||
#ifdef __MWERKS__
|
||||
extern void _savegpr_23();
|
||||
extern void _restgpr_23();
|
||||
static asm s32 _MountPrfFile(register PDM_DISK* p_disk, register char* i_fullpath_p) {
|
||||
nofralloc
|
||||
|
||||
clrlwi r11, r1, 26
|
||||
mr r12, r1
|
||||
subfic r11, r11, -0xc0
|
||||
stwux r1, r1, r11
|
||||
mflr r0
|
||||
mr r11, r12
|
||||
stw r0, 0x4(r12)
|
||||
bl _savegpr_23
|
||||
mr r26, r3
|
||||
mr r27, r4
|
||||
bl VFSysPDMDisk2DriveP
|
||||
mr r23, r3
|
||||
mr r3, r26
|
||||
bl dCommon_getHandleIdxFromDisk
|
||||
cmpwi r23, 0x0
|
||||
mr r31, r3
|
||||
bne _MountPrfFile_L_814D7C0C
|
||||
li r3, -0x14
|
||||
b _MountPrfFile_L_814D824C
|
||||
_MountPrfFile_L_814D7C0C:
|
||||
cmplwi r3, 0x1a
|
||||
lwz r28, 0x0(r23)
|
||||
bge _MountPrfFile_L_814D7CD8
|
||||
lis r4, l_nandFunc@ha
|
||||
slwi r0, r3, 4
|
||||
addi r4, r4, l_nandFunc@l
|
||||
add r3, r4, r0
|
||||
lwz r12, 0x4(r3)
|
||||
cmpwi r12, 0x0
|
||||
beq _MountPrfFile_L_814D7C50
|
||||
mr r3, r27
|
||||
mr r4, r28
|
||||
li r5, 0x1
|
||||
mtctr r12
|
||||
bctrl
|
||||
mr r29, r3
|
||||
b _MountPrfFile_L_814D7DF0
|
||||
_MountPrfFile_L_814D7C50:
|
||||
lis r3, 0x1062
|
||||
lwz r30, VF_nand_retry_max(r0)
|
||||
addi r25, r3, 0x4dd3
|
||||
li r29, 0x0
|
||||
lis r24, 0x8000
|
||||
li r23, 0x0
|
||||
b _MountPrfFile_L_814D7CC8
|
||||
_MountPrfFile_L_814D7C6C:
|
||||
mr r3, r27
|
||||
mr r4, r28
|
||||
li r5, 0x1
|
||||
bl NANDOpen
|
||||
cmpwi r3, -0x3
|
||||
mr r29, r3
|
||||
beq _MountPrfFile_L_814D7C94
|
||||
cmpwi r3, -0x2
|
||||
beq _MountPrfFile_L_814D7C94
|
||||
b _MountPrfFile_L_814D7DF0
|
||||
_MountPrfFile_L_814D7C94:
|
||||
lwz r0, 0xf8(r24)
|
||||
lwz r6, VF_nand_sleep_msec(r0)
|
||||
srwi r0, r0, 2
|
||||
mulhwu r3, r25, r0
|
||||
srawi r0, r6, 31
|
||||
mullw r4, r23, r6
|
||||
srwi r5, r3, 6
|
||||
mulhwu r3, r5, r6
|
||||
mullw r0, r5, r0
|
||||
add r3, r3, r4
|
||||
mullw r4, r5, r6
|
||||
add r3, r3, r0
|
||||
bl OSSleepTicks
|
||||
_MountPrfFile_L_814D7CC8:
|
||||
cmpwi r30, 0x0
|
||||
subi r30, r30, 0x1
|
||||
bgt _MountPrfFile_L_814D7C6C
|
||||
b _MountPrfFile_L_814D7DF0
|
||||
_MountPrfFile_L_814D7CD8:
|
||||
addis r0, r3, 0x1
|
||||
cmplwi r0, 0xfff6
|
||||
bne _MountPrfFile_L_814D7D6C
|
||||
lis r3, 0x1062
|
||||
lwz r30, VF_nand_retry_max(r0)
|
||||
addi r25, r3, 0x4dd3
|
||||
li r29, 0x0
|
||||
lis r24, 0x8000
|
||||
li r23, 0x0
|
||||
b _MountPrfFile_L_814D7D5C
|
||||
_MountPrfFile_L_814D7D00:
|
||||
mr r3, r27
|
||||
mr r4, r28
|
||||
li r5, 0x1
|
||||
bl NANDOpen
|
||||
cmpwi r3, -0x3
|
||||
mr r29, r3
|
||||
beq _MountPrfFile_L_814D7D28
|
||||
cmpwi r3, -0x2
|
||||
beq _MountPrfFile_L_814D7D28
|
||||
b _MountPrfFile_L_814D7DF0
|
||||
_MountPrfFile_L_814D7D28:
|
||||
lwz r0, 0xf8(r24)
|
||||
lwz r6, VF_nand_sleep_msec(r0)
|
||||
srwi r0, r0, 2
|
||||
mulhwu r3, r25, r0
|
||||
srawi r0, r6, 31
|
||||
mullw r4, r23, r6
|
||||
srwi r5, r3, 6
|
||||
mulhwu r3, r5, r6
|
||||
mullw r0, r5, r0
|
||||
add r3, r3, r4
|
||||
mullw r4, r5, r6
|
||||
add r3, r3, r0
|
||||
bl OSSleepTicks
|
||||
_MountPrfFile_L_814D7D5C:
|
||||
cmpwi r30, 0x0
|
||||
subi r30, r30, 0x1
|
||||
bgt _MountPrfFile_L_814D7D00
|
||||
b _MountPrfFile_L_814D7DF0
|
||||
_MountPrfFile_L_814D7D6C:
|
||||
lis r3, 0x1062
|
||||
lwz r30, VF_nand_retry_max(r0)
|
||||
addi r23, r3, 0x4dd3
|
||||
li r29, 0x0
|
||||
lis r25, 0x8000
|
||||
li r24, 0x0
|
||||
b _MountPrfFile_L_814D7DE4
|
||||
_MountPrfFile_L_814D7D88:
|
||||
mr r3, r27
|
||||
mr r4, r28
|
||||
li r5, 0x1
|
||||
bl NANDPrivateOpen
|
||||
cmpwi r3, -0x3
|
||||
mr r29, r3
|
||||
beq _MountPrfFile_L_814D7DB0
|
||||
cmpwi r3, -0x2
|
||||
beq _MountPrfFile_L_814D7DB0
|
||||
b _MountPrfFile_L_814D7DF0
|
||||
_MountPrfFile_L_814D7DB0:
|
||||
lwz r0, 0xf8(r25)
|
||||
lwz r6, VF_nand_sleep_msec(r0)
|
||||
srwi r0, r0, 2
|
||||
mulhwu r3, r23, r0
|
||||
srawi r0, r6, 31
|
||||
mullw r4, r24, r6
|
||||
srwi r5, r3, 6
|
||||
mulhwu r3, r5, r6
|
||||
mullw r0, r5, r0
|
||||
add r3, r3, r4
|
||||
mullw r4, r5, r6
|
||||
add r3, r3, r0
|
||||
bl OSSleepTicks
|
||||
_MountPrfFile_L_814D7DE4:
|
||||
cmpwi r30, 0x0
|
||||
subi r30, r30, 0x1
|
||||
bgt _MountPrfFile_L_814D7D88
|
||||
_MountPrfFile_L_814D7DF0:
|
||||
cmpwi r29, 0x0
|
||||
bne _MountPrfFile_L_814D8038
|
||||
addi r3, r1, 0x40
|
||||
li r4, 0x0
|
||||
li r5, 0x20
|
||||
bl VFipf_memset
|
||||
mr r3, r28
|
||||
addi r4, r1, 0x40
|
||||
li r5, 0x20
|
||||
bl A32_NANDRead
|
||||
cmpwi r3, 0x0
|
||||
mr r30, r3
|
||||
bge _MountPrfFile_L_814D7EAC
|
||||
lis r3, 0x1062
|
||||
lwz r29, VF_nand_retry_max(r0)
|
||||
addi r27, r3, 0x4dd3
|
||||
lis r25, 0x8000
|
||||
li r24, 0x0
|
||||
b _MountPrfFile_L_814D7E8C
|
||||
_MountPrfFile_L_814D7E3C:
|
||||
mr r3, r28
|
||||
bl NANDClose
|
||||
cmpwi r3, -0x3
|
||||
beq _MountPrfFile_L_814D7E58
|
||||
cmpwi r3, -0x2
|
||||
beq _MountPrfFile_L_814D7E58
|
||||
b _MountPrfFile_L_814D7E98
|
||||
_MountPrfFile_L_814D7E58:
|
||||
lwz r0, 0xf8(r25)
|
||||
lwz r6, VF_nand_sleep_msec(r0)
|
||||
srwi r0, r0, 2
|
||||
mulhwu r3, r27, r0
|
||||
srawi r0, r6, 31
|
||||
mullw r4, r24, r6
|
||||
srwi r5, r3, 6
|
||||
mulhwu r3, r5, r6
|
||||
mullw r0, r5, r0
|
||||
add r3, r3, r4
|
||||
mullw r4, r5, r6
|
||||
add r3, r3, r0
|
||||
bl OSSleepTicks
|
||||
_MountPrfFile_L_814D7E8C:
|
||||
cmpwi r29, 0x0
|
||||
subi r29, r29, 0x1
|
||||
bgt _MountPrfFile_L_814D7E3C
|
||||
_MountPrfFile_L_814D7E98:
|
||||
mr r3, r26
|
||||
mr r4, r30
|
||||
bl dCommon_setLastDeviceErrorToDisk
|
||||
mr r3, r30
|
||||
b _MountPrfFile_L_814D824C
|
||||
_MountPrfFile_L_814D7EAC:
|
||||
addi r3, r1, 0x40
|
||||
bl dCommon_PrintSignature
|
||||
addi r3, r1, 0x40
|
||||
bl dCommon_IsPrfFile
|
||||
cmpwi r3, 0x0
|
||||
bne _MountPrfFile_L_814D7F40
|
||||
lis r3, 0x1062
|
||||
lwz r23, VF_nand_retry_max(r0)
|
||||
addi r26, r3, 0x4dd3
|
||||
lis r25, 0x8000
|
||||
li r24, 0x0
|
||||
b _MountPrfFile_L_814D7F2C
|
||||
_MountPrfFile_L_814D7EDC:
|
||||
mr r3, r28
|
||||
bl NANDClose
|
||||
cmpwi r3, -0x3
|
||||
beq _MountPrfFile_L_814D7EF8
|
||||
cmpwi r3, -0x2
|
||||
beq _MountPrfFile_L_814D7EF8
|
||||
b _MountPrfFile_L_814D7F38
|
||||
_MountPrfFile_L_814D7EF8:
|
||||
lwz r0, 0xf8(r25)
|
||||
lwz r6, VF_nand_sleep_msec(r0)
|
||||
srwi r0, r0, 2
|
||||
mulhwu r3, r26, r0
|
||||
srawi r0, r6, 31
|
||||
mullw r4, r24, r6
|
||||
srwi r5, r3, 6
|
||||
mulhwu r3, r5, r6
|
||||
mullw r0, r5, r0
|
||||
add r3, r3, r4
|
||||
mullw r4, r5, r6
|
||||
add r3, r3, r0
|
||||
bl OSSleepTicks
|
||||
_MountPrfFile_L_814D7F2C:
|
||||
cmpwi r23, 0x0
|
||||
subi r23, r23, 0x1
|
||||
bgt _MountPrfFile_L_814D7EDC
|
||||
_MountPrfFile_L_814D7F38:
|
||||
li r3, -0x1
|
||||
b _MountPrfFile_L_814D824C
|
||||
_MountPrfFile_L_814D7F40:
|
||||
lbz r0, 0x49(r1)
|
||||
mr r3, r26
|
||||
lbz r6, 0x4a(r1)
|
||||
lbz r5, 0x4b(r1)
|
||||
slwi r0, r0, 16
|
||||
lbz r4, 0x48(r1)
|
||||
rlwimi r5, r6, 8, 16, 23
|
||||
rlwimi r0, r4, 24, 0, 7
|
||||
or r4, r5, r0
|
||||
bl dCommon_setFileSizeToDisk
|
||||
mr r3, r26
|
||||
bl dCommon_getFileSizeFromDisk
|
||||
subi r0, r3, 0x1f
|
||||
li r3, 0x0
|
||||
srwi r4, r0, 9
|
||||
li r5, 0x1
|
||||
li r6, 0x200
|
||||
bl dCommon_GetNiceFatType
|
||||
mr r23, r3
|
||||
mr r3, r26
|
||||
mr r4, r23
|
||||
bl dCommon_setFatTypeToDisk
|
||||
mr r3, r23
|
||||
bl dCommon_GetReservedSecFromFatType
|
||||
mr r4, r3
|
||||
mr r3, r26
|
||||
bl dCommon_setResvSecNumToDisk
|
||||
mr r3, r23
|
||||
bl dCommon_GetRootEntNumFromFatType
|
||||
mr r4, r3
|
||||
mr r3, r26
|
||||
bl dCommon_setRootEntNumToDisk
|
||||
lis r3, 0x1062
|
||||
lwz r29, VF_nand_retry_max(r0)
|
||||
addi r30, r3, 0x4dd3
|
||||
lis r25, 0x8000
|
||||
li r24, 0x0
|
||||
b _MountPrfFile_L_814D8028
|
||||
_MountPrfFile_L_814D7FD8:
|
||||
mr r3, r28
|
||||
bl NANDClose
|
||||
cmpwi r3, -0x3
|
||||
beq _MountPrfFile_L_814D7FF4
|
||||
cmpwi r3, -0x2
|
||||
beq _MountPrfFile_L_814D7FF4
|
||||
b _MountPrfFile_L_814D804C
|
||||
_MountPrfFile_L_814D7FF4:
|
||||
lwz r0, 0xf8(r25)
|
||||
lwz r6, VF_nand_sleep_msec(r0)
|
||||
srwi r0, r0, 2
|
||||
mulhwu r3, r30, r0
|
||||
srawi r0, r6, 31
|
||||
mullw r4, r24, r6
|
||||
srwi r5, r3, 6
|
||||
mulhwu r3, r5, r6
|
||||
mullw r0, r5, r0
|
||||
add r3, r3, r4
|
||||
mullw r4, r5, r6
|
||||
add r3, r3, r0
|
||||
bl OSSleepTicks
|
||||
_MountPrfFile_L_814D8028:
|
||||
cmpwi r29, 0x0
|
||||
subi r29, r29, 0x1
|
||||
bgt _MountPrfFile_L_814D7FD8
|
||||
b _MountPrfFile_L_814D804C
|
||||
_MountPrfFile_L_814D8038:
|
||||
mr r3, r26
|
||||
mr r4, r29
|
||||
bl dCommon_setLastDeviceErrorToDisk
|
||||
mr r3, r29
|
||||
b _MountPrfFile_L_814D824C
|
||||
_MountPrfFile_L_814D804C:
|
||||
cmplwi r31, 0x1a
|
||||
bge _MountPrfFile_L_814D8114
|
||||
lis r3, l_nandFunc@ha
|
||||
slwi r0, r31, 4
|
||||
addi r3, r3, l_nandFunc@l
|
||||
add r3, r3, r0
|
||||
lwz r12, 0x4(r3)
|
||||
cmpwi r12, 0x0
|
||||
beq _MountPrfFile_L_814D808C
|
||||
mr r3, r27
|
||||
mr r4, r28
|
||||
li r5, 0x3
|
||||
mtctr r12
|
||||
bctrl
|
||||
mr r30, r3
|
||||
b _MountPrfFile_L_814D822C
|
||||
_MountPrfFile_L_814D808C:
|
||||
lis r3, 0x1062
|
||||
lwz r29, VF_nand_retry_max(r0)
|
||||
addi r31, r3, 0x4dd3
|
||||
li r30, 0x0
|
||||
lis r25, 0x8000
|
||||
li r24, 0x0
|
||||
b _MountPrfFile_L_814D8104
|
||||
_MountPrfFile_L_814D80A8:
|
||||
mr r3, r27
|
||||
mr r4, r28
|
||||
li r5, 0x3
|
||||
bl NANDOpen
|
||||
cmpwi r3, -0x3
|
||||
mr r30, r3
|
||||
beq _MountPrfFile_L_814D80D0
|
||||
cmpwi r3, -0x2
|
||||
beq _MountPrfFile_L_814D80D0
|
||||
b _MountPrfFile_L_814D822C
|
||||
_MountPrfFile_L_814D80D0:
|
||||
lwz r0, 0xf8(r25)
|
||||
lwz r6, VF_nand_sleep_msec(r0)
|
||||
srwi r0, r0, 2
|
||||
mulhwu r3, r31, r0
|
||||
srawi r0, r6, 31
|
||||
mullw r4, r24, r6
|
||||
srwi r5, r3, 6
|
||||
mulhwu r3, r5, r6
|
||||
mullw r0, r5, r0
|
||||
add r3, r3, r4
|
||||
mullw r4, r5, r6
|
||||
add r3, r3, r0
|
||||
bl OSSleepTicks
|
||||
_MountPrfFile_L_814D8104:
|
||||
cmpwi r29, 0x0
|
||||
subi r29, r29, 0x1
|
||||
bgt _MountPrfFile_L_814D80A8
|
||||
b _MountPrfFile_L_814D822C
|
||||
_MountPrfFile_L_814D8114:
|
||||
addis r0, r31, 0x1
|
||||
cmplwi r0, 0xfff6
|
||||
bne _MountPrfFile_L_814D81A8
|
||||
lis r3, 0x1062
|
||||
lwz r29, VF_nand_retry_max(r0)
|
||||
addi r31, r3, 0x4dd3
|
||||
li r30, 0x0
|
||||
lis r25, 0x8000
|
||||
li r24, 0x0
|
||||
b _MountPrfFile_L_814D8198
|
||||
_MountPrfFile_L_814D813C:
|
||||
mr r3, r27
|
||||
mr r4, r28
|
||||
li r5, 0x3
|
||||
bl NANDOpen
|
||||
cmpwi r3, -0x3
|
||||
mr r30, r3
|
||||
beq _MountPrfFile_L_814D8164
|
||||
cmpwi r3, -0x2
|
||||
beq _MountPrfFile_L_814D8164
|
||||
b _MountPrfFile_L_814D822C
|
||||
_MountPrfFile_L_814D8164:
|
||||
lwz r0, 0xf8(r25)
|
||||
lwz r6, VF_nand_sleep_msec(r0)
|
||||
srwi r0, r0, 2
|
||||
mulhwu r3, r31, r0
|
||||
srawi r0, r6, 31
|
||||
mullw r4, r24, r6
|
||||
srwi r5, r3, 6
|
||||
mulhwu r3, r5, r6
|
||||
mullw r0, r5, r0
|
||||
add r3, r3, r4
|
||||
mullw r4, r5, r6
|
||||
add r3, r3, r0
|
||||
bl OSSleepTicks
|
||||
_MountPrfFile_L_814D8198:
|
||||
cmpwi r29, 0x0
|
||||
subi r29, r29, 0x1
|
||||
bgt _MountPrfFile_L_814D813C
|
||||
b _MountPrfFile_L_814D822C
|
||||
_MountPrfFile_L_814D81A8:
|
||||
lis r3, 0x1062
|
||||
lwz r29, VF_nand_retry_max(r0)
|
||||
addi r24, r3, 0x4dd3
|
||||
li r30, 0x0
|
||||
lis r25, 0x8000
|
||||
li r31, 0x0
|
||||
b _MountPrfFile_L_814D8220
|
||||
_MountPrfFile_L_814D81C4:
|
||||
mr r3, r27
|
||||
mr r4, r28
|
||||
li r5, 0x3
|
||||
bl NANDPrivateOpen
|
||||
cmpwi r3, -0x3
|
||||
mr r30, r3
|
||||
beq _MountPrfFile_L_814D81EC
|
||||
cmpwi r3, -0x2
|
||||
beq _MountPrfFile_L_814D81EC
|
||||
b _MountPrfFile_L_814D822C
|
||||
_MountPrfFile_L_814D81EC:
|
||||
lwz r0, 0xf8(r25)
|
||||
lwz r6, VF_nand_sleep_msec(r0)
|
||||
srwi r0, r0, 2
|
||||
mulhwu r3, r24, r0
|
||||
srawi r0, r6, 31
|
||||
mullw r4, r31, r6
|
||||
srwi r5, r3, 6
|
||||
mulhwu r3, r5, r6
|
||||
mullw r0, r5, r0
|
||||
add r3, r3, r4
|
||||
mullw r4, r5, r6
|
||||
add r3, r3, r0
|
||||
bl OSSleepTicks
|
||||
_MountPrfFile_L_814D8220:
|
||||
cmpwi r29, 0x0
|
||||
subi r29, r29, 0x1
|
||||
bgt _MountPrfFile_L_814D81C4
|
||||
_MountPrfFile_L_814D822C:
|
||||
cmpwi r30, 0x0
|
||||
bne _MountPrfFile_L_814D823C
|
||||
li r3, 0x0
|
||||
b _MountPrfFile_L_814D824C
|
||||
_MountPrfFile_L_814D823C:
|
||||
mr r3, r26
|
||||
mr r4, r30
|
||||
bl dCommon_setLastDeviceErrorToDisk
|
||||
mr r3, r30
|
||||
_MountPrfFile_L_814D824C:
|
||||
lwz r10, 0x0(r1)
|
||||
mr r11, r10
|
||||
bl _restgpr_23
|
||||
lwz r0, 0x4(r10)
|
||||
mtlr r0
|
||||
mr r1, r10
|
||||
blr
|
||||
}
|
||||
#else
|
||||
static s32 _MountPrfFile(PDM_DISK* p_disk, char* i_fullpath_p) {
|
||||
PR_BINHEADER header ALIGN64;
|
||||
VFSys_drive* drive_p = VFSysPDMDisk2DriveP(p_disk);
|
||||
NANDFileInfo* fileInfo_p;
|
||||
s32 nandError;
|
||||
NANDFileInfo* fileInfo_p = NULL;
|
||||
s32 nandError = NAND_RESULT_OK;
|
||||
u32 handleIdx = dCommon_getHandleIdxFromDisk(p_disk);
|
||||
|
||||
if (!drive_p) {
|
||||
if (drive_p == NULL) {
|
||||
return -20;
|
||||
}
|
||||
fileInfo_p = drive_p->file_p;
|
||||
nandError = VFi_NandOpenSp(i_fullpath_p, fileInfo_p, NAND_ACCESS_READ, handleIdx);
|
||||
if (nandError == 0) {
|
||||
s32 readResult;
|
||||
|
||||
VFipf_memset(&header, 0, 32);
|
||||
readResult = A32_NANDRead(fileInfo_p, &header, 32);
|
||||
if (readResult < NAND_RESULT_OK) {
|
||||
nandError = A32_NANDRead(fileInfo_p, &header, 32);
|
||||
if (nandError < NAND_RESULT_OK) {
|
||||
VFi_NandClose(fileInfo_p);
|
||||
dCommon_setLastDeviceErrorToDisk(p_disk, readResult);
|
||||
return readResult;
|
||||
dCommon_setLastDeviceErrorToDisk(p_disk, nandError);
|
||||
return nandError;
|
||||
}
|
||||
dCommon_PrintSignature(&header);
|
||||
if (!dCommon_IsPrfFile(&header)) {
|
||||
@@ -447,7 +923,7 @@ static s32 _MountPrfFile(PDM_DISK* p_disk, char* i_fullpath_p) {
|
||||
u32 fatType;
|
||||
|
||||
dCommon_setFileSizeToDisk(p_disk,
|
||||
((header.fileSize[2] << 8) | header.fileSize[3]) | ((header.fileSize[0] << 24) | (header.fileSize[1] << 16)));
|
||||
((header.fileSize[0] << 24) | (header.fileSize[1] << 16) | (header.fileSize[2] << 8) | (header.fileSize[3])));
|
||||
fileSize = dCommon_getFileSizeFromDisk(p_disk);
|
||||
dataSize = (fileSize - 0x20);
|
||||
SPU = ((dataSize + 1) >> 9);
|
||||
@@ -470,6 +946,7 @@ static s32 _MountPrfFile(PDM_DISK* p_disk, char* i_fullpath_p) {
|
||||
return nandError;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static u16 _UnmountPrfFile(PDM_DISK* p_disk) {
|
||||
VFSys_drive* drive_p = VFSysPDMDisk2DriveP(p_disk);
|
||||
|
||||
@@ -40,6 +40,8 @@ const u8 scWpaFindOuiPad4 = 0;
|
||||
#define scWpaFindOui0 (*((volatile const u8*)&scWpaFindOui0))
|
||||
#define scWpaFindOui1 (*((volatile const u8*)&scWpaFindOui1))
|
||||
#define scWpaFindOui2 (*((volatile const u8*)&scWpaFindOui2))
|
||||
extern void _savegpr_21();
|
||||
extern void _restgpr_21();
|
||||
|
||||
#define WAIT_FOR_OPERATION(...) \
|
||||
do { \
|
||||
@@ -308,45 +310,80 @@ BOOL WDFindInformationElement(WDInfoElement** outIE, u32* outIELength, WDBssDesc
|
||||
return found;
|
||||
}
|
||||
|
||||
BOOL WDiFindVendorSpecificIE(WDVendorInfoElement** outIE, u32* outIELength, WDBssDesc* bssDesc, int id, u8* data, u8 mode) {
|
||||
u32* lengthResult = outIELength;
|
||||
WDVendorInfoElement** elementResult = outIE;
|
||||
int length;
|
||||
BOOL found = FALSE;
|
||||
|
||||
if (bssDesc != NULL) {
|
||||
s32 offset;
|
||||
u8* ptr = (u8*)(bssDesc + 1);
|
||||
WDVendorInfoElement* infoElement = (WDVendorInfoElement*)ptr;
|
||||
|
||||
length = bssDesc->ieLength;
|
||||
|
||||
for (offset = 0; offset < length; offset += infoElement->length + 2) {
|
||||
infoElement = (WDVendorInfoElement*)(ptr + offset);
|
||||
if (infoElement->id == (u32)id) {
|
||||
u8 elementMode = infoElement->mode;
|
||||
if (memcmp(infoElement->data, data, WD_VENDOR_LENGTH) == 0 && elementMode == mode) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (offset < length) {
|
||||
if (elementResult != NULL) {
|
||||
*elementResult = infoElement + 1;
|
||||
}
|
||||
if (lengthResult != NULL) {
|
||||
*lengthResult = infoElement->length - (sizeof(WDVendorInfoElement) - sizeof(WDInfoElement));
|
||||
}
|
||||
found = TRUE;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
if (elementResult != NULL) {
|
||||
*elementResult = NULL;
|
||||
}
|
||||
if (lengthResult != NULL) {
|
||||
*lengthResult = 0;
|
||||
}
|
||||
}
|
||||
return found;
|
||||
asm BOOL WDiFindVendorSpecificIE(WDVendorInfoElement** outIE, u32* outIELength, WDBssDesc* bssDesc, int id, u8* data, u8 mode) {
|
||||
nofralloc
|
||||
stwu r1, -0x40(r1)
|
||||
mflr r0
|
||||
stw r0, 0x44(r1)
|
||||
addi r11, r1, 0x40
|
||||
bl _savegpr_21
|
||||
cmpwi r5, 0
|
||||
mr r30, r3
|
||||
mr r31, r4
|
||||
mr r21, r6
|
||||
mr r22, r7
|
||||
mr r23, r8
|
||||
li r28, 0
|
||||
beq WDiFindVendorSpecificIE_done
|
||||
addi r26, r5, 0x3e
|
||||
lhz r29, 0x3c(r5)
|
||||
mr r25, r26
|
||||
li r27, 0
|
||||
b WDiFindVendorSpecificIE_loop_check
|
||||
WDiFindVendorSpecificIE_loop:
|
||||
lbzx r0, r26, r27
|
||||
add r25, r26, r27
|
||||
cmplw r0, r21
|
||||
bne WDiFindVendorSpecificIE_next
|
||||
lbz r24, 5(r25)
|
||||
mr r4, r22
|
||||
addi r3, r25, 2
|
||||
li r5, 3
|
||||
bl memcmp
|
||||
cmpwi r3, 0
|
||||
bne WDiFindVendorSpecificIE_next
|
||||
cmplw r24, r23
|
||||
beq WDiFindVendorSpecificIE_found
|
||||
WDiFindVendorSpecificIE_next:
|
||||
lbz r0, 1(r25)
|
||||
add r3, r0, r27
|
||||
addi r27, r3, 2
|
||||
WDiFindVendorSpecificIE_loop_check:
|
||||
cmpw r27, r29
|
||||
blt WDiFindVendorSpecificIE_loop
|
||||
WDiFindVendorSpecificIE_found:
|
||||
cmpw r27, r29
|
||||
bge WDiFindVendorSpecificIE_done
|
||||
cmpwi r30, 0
|
||||
beq WDiFindVendorSpecificIE_no_out
|
||||
addi r0, r25, 6
|
||||
stw r0, 0(r30)
|
||||
WDiFindVendorSpecificIE_no_out:
|
||||
cmpwi r31, 0
|
||||
beq WDiFindVendorSpecificIE_set_found
|
||||
lbz r3, 1(r25)
|
||||
addi r0, r3, -4
|
||||
stw r0, 0(r31)
|
||||
WDiFindVendorSpecificIE_set_found:
|
||||
li r28, 1
|
||||
WDiFindVendorSpecificIE_done:
|
||||
cmpwi r28, 0
|
||||
bne WDiFindVendorSpecificIE_return
|
||||
cmpwi r30, 0
|
||||
beq WDiFindVendorSpecificIE_no_out_null
|
||||
li r0, 0
|
||||
stw r0, 0(r30)
|
||||
WDiFindVendorSpecificIE_no_out_null:
|
||||
cmpwi r31, 0
|
||||
beq WDiFindVendorSpecificIE_return
|
||||
li r0, 0
|
||||
stw r0, 0(r31)
|
||||
WDiFindVendorSpecificIE_return:
|
||||
addi r11, r1, 0x40
|
||||
mr r3, r28
|
||||
bl _restgpr_21
|
||||
lwz r0, 0x44(r1)
|
||||
mtlr r0
|
||||
addi r1, r1, 0x40
|
||||
blr
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
#include <private/dvd.h>
|
||||
#include <private/nand.h>
|
||||
#include <private/os.h>
|
||||
#include <revolution/os/OSBootInfo.h>
|
||||
#include <private/vi.h>
|
||||
#include <private/hollywood/flipper.h>
|
||||
|
||||
@@ -243,63 +242,14 @@ BOOL BS2IsDiagDisc() { return (u8)(*(u8 *)OSPhysicalToCached(OS_ADDR_BOOT_INFO)
|
||||
extern vu32 BS2VideoMode;
|
||||
extern vu32 __DVDLayoutFormat;
|
||||
|
||||
asm void Run(u32 entryPoint, void *start, u32 blockCount, u32 argument) {
|
||||
// clang-format off
|
||||
#ifdef __MWERKS__
|
||||
nofralloc
|
||||
|
||||
mtctr r5
|
||||
mtlr r3
|
||||
|
||||
li r0, 0
|
||||
li r2, 0
|
||||
li r3, 0
|
||||
li r5, 0
|
||||
li r7, 0
|
||||
li r8, 0
|
||||
li r9, 0
|
||||
li r10, 0
|
||||
li r11, 0
|
||||
li r12, 0
|
||||
li r13, 0
|
||||
li r14, 0
|
||||
li r15, 0
|
||||
li r16, 0
|
||||
li r17, 0
|
||||
li r18, 0
|
||||
li r19, 0
|
||||
li r20, 0
|
||||
li r21, 0
|
||||
li r22, 0
|
||||
li r23, 0
|
||||
li r24, 0
|
||||
li r25, 0
|
||||
li r26, 0
|
||||
li r27, 0
|
||||
li r28, 0
|
||||
li r29, 0
|
||||
li r30, 0
|
||||
li r31, 0
|
||||
|
||||
// The application stack is fixed; it is unrelated to the formatter.
|
||||
lis r1, 0x8160
|
||||
ori r1, r1, 0
|
||||
li r6, 0
|
||||
|
||||
b Run_loop_entry
|
||||
Run_loop:
|
||||
dcbz r4, r0
|
||||
dcbf r4, r0
|
||||
addi r4, r4, 0x20
|
||||
bdnz Run_loop
|
||||
b Run_done
|
||||
Run_done:
|
||||
li r4, 0
|
||||
blr
|
||||
Run_loop_entry:
|
||||
b Run_loop
|
||||
#endif
|
||||
// clang-format on
|
||||
void Run(u32 entryPoint, void *start, u32 blockCount, u32 argument) {
|
||||
u8 *block = start;
|
||||
for (; blockCount != 0; --blockCount) {
|
||||
__dcbz(block, 0);
|
||||
__dcbf(block, 0);
|
||||
block += 32;
|
||||
}
|
||||
((void (*)(u32))entryPoint)(argument);
|
||||
}
|
||||
|
||||
BOOL BS2GetLockedTitles(ESTitleId *pTitleIds, u32 *count) {
|
||||
@@ -489,7 +439,7 @@ BOOL BS2StartLoadingTitle(ESTitleId titleId, ESTicketView *pTicketView) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void callback(u32 result) { LowReadResult = result; }
|
||||
void callback(s32 result) { LowReadResult = result; }
|
||||
|
||||
ESError BS2ESGetTicketViews(IOSFd *descriptor, ESTitleId titleId, ESTicketView *views, u32 *count) {
|
||||
struct {
|
||||
@@ -726,7 +676,7 @@ void BS2StartGame() {
|
||||
BS2Report("DVDLowInit done\n");
|
||||
|
||||
LowReadResult = 0;
|
||||
DVDLowReadDiskID(&DiskID, callback);
|
||||
DVDLowReadDiskID(&DiskID, (DVDLowCallback)callback);
|
||||
while (LowReadResult == 0) {
|
||||
}
|
||||
|
||||
@@ -740,7 +690,7 @@ void BS2StartGame() {
|
||||
} else {
|
||||
OSReport("\nDisk error(%d) has occurred", LowReadResult);
|
||||
LowReadResult = 0;
|
||||
DVDLowRequestError(callback);
|
||||
DVDLowRequestError((DVDLowCallback)callback);
|
||||
while (LowReadResult == 0) {
|
||||
}
|
||||
driveError = DVDLowGetImmBufferReg() & 0xFF000000;
|
||||
@@ -770,10 +720,10 @@ disk_done:
|
||||
if (PartitionParams.numTmdBytes != 0) {
|
||||
DVDLowOpenPartitionWithTmdAndTicketView((u32)((DVDPartitionInfo *)GamePartition)->partition, &PartitionParams.ticketView,
|
||||
PartitionParams.numTmdBytes, &PartitionParams.tmd, PartitionParams.numCertBytes,
|
||||
PartitionParams.certificates, callback);
|
||||
PartitionParams.certificates, (DVDLowCallback)callback);
|
||||
} else {
|
||||
DVDLowOpenPartition((u32)((DVDPartitionInfo *)GamePartition)->partition, NULL, 0, NULL, &PartitionParams.tmd,
|
||||
callback);
|
||||
(DVDLowCallback)callback);
|
||||
}
|
||||
while (LowReadResult == 0) {
|
||||
}
|
||||
@@ -791,7 +741,7 @@ disk_done:
|
||||
} else {
|
||||
OSReport("\nDisk error(%d) has occurred", LowReadResult);
|
||||
LowReadResult = 0;
|
||||
DVDLowRequestError(callback);
|
||||
DVDLowRequestError((DVDLowCallback)callback);
|
||||
while (LowReadResult == 0) {
|
||||
}
|
||||
driveError = DVDLowGetImmBufferReg() & 0xFF000000;
|
||||
@@ -853,7 +803,7 @@ void BS2StartGCGame() {
|
||||
OSTime time;
|
||||
|
||||
StartingGame = TRUE;
|
||||
while (CoverBlock.state != DVD_STATE_IDLE) {
|
||||
while (DVDGetCommandBlockStatus(&CoverBlock) != DVD_STATE_IDLE) {
|
||||
}
|
||||
|
||||
soundMode = SCGetSoundMode();
|
||||
@@ -1345,9 +1295,6 @@ BS2State BS2Tick() {
|
||||
char *ticketByte;
|
||||
u32 entryCount;
|
||||
u32 readInterruptsEnabled;
|
||||
u32 readAddress;
|
||||
const char *discTitle;
|
||||
const DVDDiskID *bootDisc;
|
||||
switch (State) {
|
||||
case 0:
|
||||
BS2Report("No Disk : %d\n", BS2NoDisk);
|
||||
@@ -1361,10 +1308,9 @@ BS2State BS2Tick() {
|
||||
(*(u32 *)0x800030d4) = 0;
|
||||
DvdTransferred = 0;
|
||||
DvdTransferLength = 0;
|
||||
status = BS2NoDisk;
|
||||
AudioBufferUnconfigured = 1;
|
||||
CoverBlock.state = 0;
|
||||
if (status != 0)
|
||||
if (BS2NoDisk != 0)
|
||||
State = BS2_STT_NO_DISK;
|
||||
else if (BS2DriveReset != 0)
|
||||
State = BS2_STT_2;
|
||||
@@ -1443,13 +1389,11 @@ BS2State BS2Tick() {
|
||||
case 5:
|
||||
status = CheckBS2CommandStatus();
|
||||
if (status != 0) {
|
||||
if ((((const OSBootInfo *)0x80000000)->consoleType & 0xf0000000) == 0) {
|
||||
__OSDeviceCode = 0x8002;
|
||||
State = BS2_STT_8;
|
||||
} else {
|
||||
__OSDeviceCode = DriveInfo.deviceCode | 0x8000;
|
||||
State = BS2_STT_8;
|
||||
}
|
||||
if (((*(u32 *)0x8000002c) & 0xf0000000) == 0)
|
||||
(*(u16 *)0x800030e6) = 0x8002;
|
||||
else
|
||||
(*(u16 *)0x800030e6) = DriveInfo.deviceCode | 0x8000;
|
||||
State = BS2_STT_8;
|
||||
}
|
||||
break;
|
||||
case 6:
|
||||
@@ -1473,17 +1417,17 @@ BS2State BS2Tick() {
|
||||
break;
|
||||
case 9:
|
||||
case 10: {
|
||||
DVDDiskID *bootDisc;
|
||||
status = CheckBS2CommandStatus();
|
||||
if (status == 0)
|
||||
break;
|
||||
memcpy((void *)0x80000000, &DiskID, sizeof(DVDDiskID));
|
||||
bootDisc = (const DVDDiskID *)0x80000000;
|
||||
bootDisc = (DVDDiskID *)0x80000000;
|
||||
if (bootDisc->rvlMagic == 0x5d1c9ea3) {
|
||||
discTitle = (const char *)0x80000000;
|
||||
status = strncmp(discTitle, "RAAE", 4);
|
||||
if (status == 0 || strncmp(discTitle, "408", 3) == 0 ||
|
||||
strncmp(discTitle, "410", 3) == 0 ||
|
||||
strncmp(discTitle, "410", 3) == 0)
|
||||
status = strncmp((char *)bootDisc, "RAAE", 4);
|
||||
if (status == 0 || strncmp((char *)bootDisc, "408", 3) == 0 ||
|
||||
strncmp((char *)bootDisc, "410", 3) == 0 ||
|
||||
strncmp((char *)bootDisc, "410", 3) == 0)
|
||||
regionMatches = FALSE;
|
||||
else
|
||||
regionMatches = TRUE;
|
||||
@@ -1505,8 +1449,8 @@ BS2State BS2Tick() {
|
||||
State = BS2_STT_11;
|
||||
}
|
||||
case 0xb: {
|
||||
DVDDiskID *bootDisc = (DVDDiskID *)0x80000000;
|
||||
u32 audioBufferSize;
|
||||
bootDisc = (const DVDDiskID *)0x80000000;
|
||||
if (AudioBufferUnconfigured == 0) {
|
||||
State = BS2_STT_GC_GAME;
|
||||
break;
|
||||
@@ -1852,24 +1796,21 @@ invalidRvlRegion:
|
||||
State = BS2_STT_RESET_SYSTEM;
|
||||
break;
|
||||
}
|
||||
if (GamePartition != 0) {
|
||||
State = BS2_STT_37;
|
||||
} else {
|
||||
if (GamePartition == 0) {
|
||||
State = BS2_STT_54;
|
||||
break;
|
||||
}
|
||||
case 0x25: {
|
||||
u32 partitionOffset = (u32)((DVDPartitionInfo *)GamePartition)->partition;
|
||||
State = BS2_STT_37;
|
||||
case 0x25:
|
||||
if (BS2BootFromCache != 0) {
|
||||
BS2Report("Open partition from cache.dat\n");
|
||||
NandPending = 1;
|
||||
BS2NANDDivideReadAsync(&BS2CacheFileInfo, &PartitionParams.tmd, 0x4a00, BS2NANDCallback, &BS2NandBlock);
|
||||
} else
|
||||
DVDOpenPartitionAsync(&Block, &PartitionParams.tmd, partitionOffset, BS2DVDCallback);
|
||||
DVDOpenPartitionAsync(&Block, &PartitionParams.tmd, (u32)((DVDPartitionInfo *)GamePartition)->partition, BS2DVDCallback);
|
||||
PartitionOpen = 1;
|
||||
State = BS2_STT_38;
|
||||
break;
|
||||
}
|
||||
case 0x26: {
|
||||
status = CheckBS2CommandStatus();
|
||||
if (status == 0)
|
||||
@@ -1896,16 +1837,13 @@ invalidRvlRegion:
|
||||
titlePrefix = titleCode >> 0x18;
|
||||
titleCharacters[3] = (u8)titleCode;
|
||||
titleCharacters[0] = (char)(titleCode >> 0x18);
|
||||
switch (titlePrefix) {
|
||||
case 'D':
|
||||
case 'R':
|
||||
case 'S':
|
||||
case 'T':
|
||||
if (titlePrefix < 'R') {
|
||||
if (titlePrefix == 'D')
|
||||
goto check_title_region;
|
||||
} else if (titlePrefix < 'U')
|
||||
goto check_title_region;
|
||||
default:
|
||||
regionMatches = TRUE;
|
||||
goto title_region_checked;
|
||||
}
|
||||
regionMatches = TRUE;
|
||||
goto title_region_checked;
|
||||
{
|
||||
check_title_region:
|
||||
if (titleCharacters[3] == 0x41) {
|
||||
@@ -2028,9 +1966,8 @@ invalidRvlRegion:
|
||||
BS2Report("Addr [0x%x] length [0x%x] offset [0x%x]\n", loaderRead.address, loaderRead.length, loaderRead.offset);
|
||||
readInterruptsEnabled = OSDisableInterrupts();
|
||||
BS2ReadDiskID((void *)loaderRead.address, loaderRead.length, loaderRead.offset >> __DVDLayoutFormat);
|
||||
readAddress = loaderRead.address;
|
||||
LoaderLength = loaderRead.length;
|
||||
LoaderAddress = readAddress;
|
||||
LoaderAddress = loaderRead.address;
|
||||
LoaderOffset = loaderRead.offset;
|
||||
if ((*(s32 *)DvdProgress != 0) && (BS2BootFromCache == 0)) {
|
||||
DvdReadPending = 1;
|
||||
@@ -2064,8 +2001,8 @@ invalidRvlRegion:
|
||||
if (status == 0)
|
||||
OSPanic("BS2Mach.c", 0x12c8, "BS2 ERROR >>> Cannnot alloc 0x%08x from MEMAllocator", bannerFile.length);
|
||||
BannerLength = bannerFile.length;
|
||||
BannerBuffer = BannerAllocation + 32 - BannerAllocation % 32;
|
||||
BS2Report("BannerBufferAddr : %08X\n", BannerBuffer);
|
||||
BannerBuffer = OSRoundDown32B(BannerAllocation) + 32;
|
||||
BS2Report("BannerBufferAddr : %08X\n");
|
||||
} else {
|
||||
if ((BannerBuffer != 0) && (BannerLength != 0)) {
|
||||
if (BannerLength < ((bannerFile.length + 0x1fU) & 0xffffffe0))
|
||||
|
||||
@@ -23,10 +23,10 @@ s32 WADImportDVDForBS(const char* path, void* buffer, u32 length);
|
||||
s32 WADImportDVDExForBS(const char* path, void* buffer, u32 length);
|
||||
|
||||
static BS2UpdateEntry* pEntries = NULL;
|
||||
static volatile u32 EntriesCount = 0;
|
||||
static u32 EntriesCount = 0;
|
||||
static u32* pFlags = NULL;
|
||||
static void* MemAllocator = NULL;
|
||||
volatile int State = 0;
|
||||
int State = 0;
|
||||
BS2UpdateEntry* CurrentEntry = 0;
|
||||
static u32 RebootRequired = 0;
|
||||
static BOOL ContainsSeatTitles = 0;
|
||||
@@ -77,8 +77,7 @@ void BS2UpdateInit(void* allocator) {
|
||||
OSResumeThread(&Thread);
|
||||
}
|
||||
|
||||
static inline u32 BS2SelectUpdateEntries(void) {
|
||||
|
||||
static void* UpdateThread(void* argument) {
|
||||
BOOL missingFile;
|
||||
u32 selectedCount;
|
||||
u32 requiredBytes;
|
||||
@@ -90,6 +89,7 @@ static inline u32 BS2SelectUpdateEntries(void) {
|
||||
u32 selectedSeatCount;
|
||||
BOOL regionValid;
|
||||
u32 titleRegion;
|
||||
s32 importResult;
|
||||
struct {
|
||||
u32 freeChannels;
|
||||
u32 freeBlocks;
|
||||
@@ -102,6 +102,9 @@ static inline u32 BS2SelectUpdateEntries(void) {
|
||||
DVDFileInfo file;
|
||||
} scratch;
|
||||
|
||||
BS2Report("Start update thread\n");
|
||||
StartUpdate = 0;
|
||||
CancelUpdate = 0;
|
||||
missingFile = FALSE;
|
||||
selectedCount = 0;
|
||||
requiredBytes = 0;
|
||||
@@ -159,12 +162,12 @@ product_region_checked:
|
||||
if (!regionValid) {
|
||||
BS2Report("Error: failed to check product region.");
|
||||
selectedCount = 0;
|
||||
goto selection_complete;
|
||||
goto selection_done;
|
||||
}
|
||||
if (!SCGetProductAreaString(scratch.productArea, sizeof(scratch.productArea))) {
|
||||
BS2Report("Error: failed to get product information.");
|
||||
selectedCount = 0;
|
||||
goto selection_complete;
|
||||
goto selection_done;
|
||||
}
|
||||
strcpy(scratch.updatePath, "__update.inf");
|
||||
strcat(scratch.updatePath, ".");
|
||||
@@ -180,46 +183,46 @@ product_region_checked:
|
||||
if (DVDConvertPathToEntrynum(scratch.updatePath) < 0) {
|
||||
BS2Report("Error: update information file is not found.");
|
||||
selectedCount = 0;
|
||||
goto selection_complete;
|
||||
goto selection_done;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
BS2Report("Error: update information file is not found.");
|
||||
selectedCount = 0;
|
||||
goto selection_complete;
|
||||
goto selection_done;
|
||||
}
|
||||
}
|
||||
BS2Report("%s is found.\n", scratch.updatePath);
|
||||
if (!DVDOpen(scratch.updatePath, &scratch.file)) {
|
||||
BS2Report("Error: failed to open update information file.");
|
||||
selectedCount = 0;
|
||||
goto selection_complete;
|
||||
goto selection_done;
|
||||
}
|
||||
if (DVDReadPrio(&scratch.file, &UpdateHeader0, sizeof(UpdateHeader0), 0, 2) < 0) {
|
||||
BS2Report("Error: failed to read update information header.");
|
||||
selectedCount = 0;
|
||||
goto selection_complete;
|
||||
goto selection_done;
|
||||
}
|
||||
if (UpdateHeader0.wadCount == 0) {
|
||||
BS2Report("Error: no entry.");
|
||||
selectedCount = 0;
|
||||
goto selection_complete;
|
||||
goto selection_done;
|
||||
}
|
||||
if (UpdateHeader0.wadCount > 32) {
|
||||
BS2Report("Error: found too many entries.");
|
||||
selectedCount = 0;
|
||||
goto selection_complete;
|
||||
goto selection_done;
|
||||
}
|
||||
UpdateHeader0.wadCount += UpdateHeader0.extraCount;
|
||||
if (UpdateHeader0.wadCount > BS2_UPDATE_ENTRY_COUNT) {
|
||||
BS2Report("Error: found too many extra entries.");
|
||||
selectedCount = 0;
|
||||
goto selection_complete;
|
||||
goto selection_done;
|
||||
}
|
||||
if (DVDReadPrio(&scratch.file, UPDATE_DISC_ENTRIES, UpdateHeader0.wadCount * sizeof(BS2UpdateEntry), 32, 2) < 0) {
|
||||
BS2Report("Error: failed to read update information.");
|
||||
selectedCount = 0;
|
||||
goto selection_complete;
|
||||
goto selection_done;
|
||||
}
|
||||
{
|
||||
BS2UpdateEntry *discEntries = UPDATE_DISC_ENTRIES;
|
||||
@@ -242,7 +245,7 @@ product_region_checked:
|
||||
BS2Report("Cannot get physical MEM2 size\n");
|
||||
State = 5;
|
||||
selectedCount = 0;
|
||||
goto selection_complete;
|
||||
goto selection_done;
|
||||
}
|
||||
if (DVDOpen(discEntries[index].path, &scratch.file) < 0) {
|
||||
BS2Report("%s is not found\n", discEntries[index].path);
|
||||
@@ -302,10 +305,8 @@ product_region_checked:
|
||||
BS2Report("Error: found too many extra entries.");
|
||||
goto seats_done;
|
||||
}
|
||||
seatEntries = UPDATE_DISC_ENTRIES;
|
||||
seatEntries += UpdateHeader0.wadCount;
|
||||
selectedSeats = EntriesToImport;
|
||||
selectedSeats += selectedCount;
|
||||
seatEntries = &UPDATE_DISC_ENTRIES[UpdateHeader0.wadCount];
|
||||
selectedSeats = &EntriesToImport[selectedCount];
|
||||
if (DVDReadPrio(&scratch.file, seatEntries, UpdateHeader1.wadCount * sizeof(BS2UpdateEntry), 32, 2) < 0) {
|
||||
BS2Report("Error: failed to read update information.");
|
||||
goto seats_done;
|
||||
@@ -407,7 +408,7 @@ seats_done:
|
||||
if (missingFile) {
|
||||
State = 5;
|
||||
selectedCount = 0;
|
||||
goto selection_complete;
|
||||
goto selection_done;
|
||||
}
|
||||
pEntries = EntriesToImport;
|
||||
pFlags = Flags1;
|
||||
@@ -423,17 +424,8 @@ seats_done:
|
||||
}
|
||||
}
|
||||
}
|
||||
selection_complete:
|
||||
return selectedCount;
|
||||
}
|
||||
|
||||
static void* UpdateThread(void* argument) {
|
||||
u32 index;
|
||||
s32 importResult;
|
||||
BS2Report("Start update thread\n");
|
||||
StartUpdate = 0;
|
||||
CancelUpdate = 0;
|
||||
EntriesCount = BS2SelectUpdateEntries();
|
||||
selection_done:
|
||||
EntriesCount = selectedCount;
|
||||
if (EntriesCount == 0) {
|
||||
State = 5;
|
||||
StartUpdate = 0;
|
||||
@@ -457,7 +449,7 @@ static void* UpdateThread(void* argument) {
|
||||
UpdateProgress++;
|
||||
continue;
|
||||
}
|
||||
if (((const BS2UpdateEntry *)discEntries)[UpdateProgress].type == 1) {
|
||||
if (discEntries[UpdateProgress].type == 1) {
|
||||
BS2Report("BS2WADImportDVD : ");
|
||||
index = UpdateProgress;
|
||||
if (strcmp(getSuffix(discEntries[index].path), "wad") == 0) {
|
||||
@@ -510,8 +502,8 @@ static void* UpdateThread(void* argument) {
|
||||
} else {
|
||||
State = 3;
|
||||
}
|
||||
CurrentEntry = NULL;
|
||||
UpdateProgress++;
|
||||
CurrentEntry = NULL;
|
||||
break;
|
||||
}
|
||||
} else if (CancelUpdate != 0) {
|
||||
|
||||
@@ -19,10 +19,10 @@
|
||||
typedef struct {
|
||||
u64 work[0xD0 / sizeof(u64)];
|
||||
} NETHMACContext;
|
||||
extern const void* NETGetSHA1Interface(void);
|
||||
extern void NETHMACInit(NETHMACContext* ctx, const void* interface, const void* key, u32 keyLen);
|
||||
extern void NETHMACUpdate(NETHMACContext* ctx, const void* data, u32 len);
|
||||
extern void NETHMACGetDigest(NETHMACContext* ctx, void* digest);
|
||||
static const void* NETGetSHA1Interface(void);
|
||||
static void NETHMACInit(NETHMACContext* ctx, const void* interface, const void* key, u32 keyLen);
|
||||
static void NETHMACUpdate(NETHMACContext* ctx, const void* data, u32 len);
|
||||
static void NETHMACGetDigest(NETHMACContext* ctx, void* digest);
|
||||
extern char VmReportFormat[];
|
||||
|
||||
#define CHANSVmDebugLength 1024
|
||||
@@ -54,6 +54,7 @@ const u64 VmMinusInf = 0xFFF0000000000000ULL;
|
||||
#define VM_READ_BE_U16(b, o) ((u16)((b)[(o)] << 8 | (b)[(o) + 1]))
|
||||
#define VM_READ_BE_U24(b, o) ((u32)((b)[(o)] << 16 | (b)[(o) + 1] << 8 | (b)[(o) + 2]))
|
||||
#define VM_MAKE_U64(hi, lo) ((u64)(u32)(hi) << 32 | (u64)(lo))
|
||||
#define VM_S64_FROM_U64(v) ((s64)(u32)((v) >> 32) << 32 | (u64)(u32)(v))
|
||||
|
||||
void CHANSVmDebugPrintf(const vmString format, ...) {
|
||||
va_list args;
|
||||
@@ -1413,7 +1414,7 @@ CHANSVmErr VmCmpGeq(CHANSVm* vm, CHANSVmObjType type, CHANSVmObjHdr* ret, CHANSV
|
||||
return VmCmpLeq(vm, type, ret, right, left);
|
||||
}
|
||||
|
||||
CHANSVmErr CHANSVmGetBoolean(vmBoolInt* ret, CHANSVmObjHdr* val) {
|
||||
CHANSVmErr CHANSVmGetBoolean(CHANSVmObjHdr* ret, CHANSVmObjHdr* val) {
|
||||
vmBoolInt result;
|
||||
switch (val->type) {
|
||||
case CHANS_VM_OBJ_TYPE_BLANK: {
|
||||
@@ -1447,7 +1448,7 @@ CHANSVmErr CHANSVmGetBoolean(vmBoolInt* ret, CHANSVmObjHdr* val) {
|
||||
}
|
||||
}
|
||||
if (ret != vmNull) {
|
||||
*ret = result;
|
||||
ret->value.bool_v = result;
|
||||
}
|
||||
return CHANS_VM_OK;
|
||||
}
|
||||
@@ -3069,22 +3070,20 @@ VmMethodDefine(String, Search) {
|
||||
return VmStringObjectIndex(VmInst, VmParentObj, VmReturnObj, 1, 1);
|
||||
}
|
||||
|
||||
static inline vmBoolInt VmReplaceStringContents(CHANSVm *VmInst, const CHANSVmObjHdr *VmParentObj, CHANSVmObjHdr *VmReturnObj) {
|
||||
VmMethodDefine(String, Replace) {
|
||||
CHANSVmObjHdr* arg0;
|
||||
vmString replaceStr;
|
||||
vmString searchStr;
|
||||
vmString parentStr;
|
||||
vmString newStr;
|
||||
u32 dstBufLen;
|
||||
u32 replaceLen;
|
||||
u32 dstOffs;
|
||||
CHANSVmObjHdr* arg1;
|
||||
u32 searchLen;
|
||||
u32 srcOffs;
|
||||
vmString parentStr;
|
||||
vmString searchStr;
|
||||
vmString replaceStr;
|
||||
u32 parentLen;
|
||||
u32 srcOffs;
|
||||
u32 dstOffs;
|
||||
u32 searchLen;
|
||||
u32 replaceLen;
|
||||
u32 dstBufLen;
|
||||
vmString newStr;
|
||||
u32 segLen;
|
||||
const vmStringObjVal *parentValue;
|
||||
const vmStringObjVal *searchValue;
|
||||
|
||||
if (((CHANSVmPrivate*)VmInst)->pActiveCtx->argc < 2) {
|
||||
goto return_input;
|
||||
@@ -3099,12 +3098,10 @@ static inline vmBoolInt VmReplaceStringContents(CHANSVm *VmInst, const CHANSVmOb
|
||||
goto return_input;
|
||||
}
|
||||
|
||||
parentValue = VmParentObj->value.string_v;
|
||||
searchValue = arg0->value.string_v;
|
||||
parentLen = parentValue->len;
|
||||
searchLen = searchValue->len;
|
||||
parentStr = parentValue->spData;
|
||||
searchStr = searchValue->spData;
|
||||
parentLen = VmParentObj->value.string_v->len;
|
||||
searchLen = arg0->value.string_v->len;
|
||||
parentStr = VmParentObj->value.string_v->spData;
|
||||
searchStr = arg0->value.string_v->spData;
|
||||
replaceStr = arg1->value.string_v->spData;
|
||||
replaceLen = arg1->value.string_v->len;
|
||||
|
||||
@@ -3172,16 +3169,12 @@ static inline vmBoolInt VmReplaceStringContents(CHANSVm *VmInst, const CHANSVmOb
|
||||
return VmReturnObj->value.string_v->len == dstOffs ? vmTrue : vmFalse;
|
||||
|
||||
return_input:
|
||||
return VmStringObjectDup(VmInst, VmReturnObj, (CHANSVmObjHdr *)VmParentObj) ? vmTrue : vmFalse;
|
||||
return VmStringObjectDup(VmInst, VmReturnObj, VmParentObj) ? vmTrue : vmFalse;
|
||||
|
||||
error:
|
||||
return 0;
|
||||
}
|
||||
|
||||
VmMethodDefine(String, Replace) {
|
||||
return VmReplaceStringContents(VmInst, VmParentObj, VmReturnObj);
|
||||
}
|
||||
|
||||
VmMethodDefine(String, Splice) {
|
||||
CHANSVmObjHdr* arg0;
|
||||
CHANSVmObjHdr* arg1;
|
||||
@@ -4975,24 +4968,6 @@ exit:
|
||||
return curPos;
|
||||
}
|
||||
|
||||
static inline void VmBlobCopyPadded(BlobHeader* parentBlob, const BlobHeader* srcBlob, s32 copySize) {
|
||||
u32 srcOff;
|
||||
u32 dataSize;
|
||||
u8* dest;
|
||||
|
||||
srcOff = srcBlob->offset;
|
||||
dataSize = srcBlob->size - srcOff;
|
||||
dest = parentBlob->pData + parentBlob->offset;
|
||||
if (dataSize > copySize) {
|
||||
dataSize = copySize;
|
||||
}
|
||||
memmove(dest, srcBlob->pData + srcOff, dataSize);
|
||||
if (dataSize < copySize) {
|
||||
memset(dest + dataSize, 0, copySize - dataSize);
|
||||
}
|
||||
parentBlob->offset += copySize;
|
||||
}
|
||||
|
||||
static vmBoolInt VmBlobPackCommon(CHANSVm* VmInst, CHANSVmObjHdr* VmParentObj, CHANSVmObjHdr* VmReturnObj, vmU32 flag) {
|
||||
u32 packBuf[2];
|
||||
BlobHeader* parentBlob;
|
||||
@@ -5008,6 +4983,8 @@ static vmBoolInt VmBlobPackCommon(CHANSVm* VmInst, CHANSVmObjHdr* VmParentObj, C
|
||||
CHANSVmObjHdr* obj;
|
||||
BlobHeader* srcBlob;
|
||||
s32 copySize;
|
||||
u32 dataSize;
|
||||
u32 srcOff;
|
||||
CHANSVmObjHdr* strObj;
|
||||
u8* srcData;
|
||||
u32 charCount;
|
||||
@@ -5156,7 +5133,7 @@ static vmBoolInt VmBlobPackCommon(CHANSVm* VmInst, CHANSVmObjHdr* VmParentObj, C
|
||||
goto error;
|
||||
}
|
||||
argCount++;
|
||||
totalSize += (s32)((u32)count + 1U) / 2;
|
||||
totalSize += (count + 1) / 2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -5229,7 +5206,17 @@ static vmBoolInt VmBlobPackCommon(CHANSVm* VmInst, CHANSVmObjHdr* VmParentObj, C
|
||||
goto error;
|
||||
}
|
||||
|
||||
VmBlobCopyPadded(parentBlob, srcBlob, copySize);
|
||||
srcOff = srcBlob->offset;
|
||||
dataSize = srcBlob->size - srcOff;
|
||||
dest = parentBlob->pData + parentBlob->offset;
|
||||
if (dataSize > copySize) {
|
||||
dataSize = copySize;
|
||||
}
|
||||
memmove(dest, srcBlob->pData + srcOff, dataSize);
|
||||
if (dataSize < copySize) {
|
||||
memset(dest + dataSize, 0, copySize - dataSize);
|
||||
}
|
||||
parentBlob->offset += copySize;
|
||||
break;
|
||||
}
|
||||
case 5: {
|
||||
@@ -5436,7 +5423,7 @@ static vmBoolInt VmBlobPackCommon(CHANSVm* VmInst, CHANSVmObjHdr* VmParentObj, C
|
||||
goto error;
|
||||
}
|
||||
|
||||
bufSize = (s32)((u32)count + 1U) / 2;
|
||||
bufSize = (count + 1) / 2;
|
||||
if (!CHANSVmBlobHasSpace(parentBlob, bufSize)) {
|
||||
goto error;
|
||||
}
|
||||
@@ -5447,20 +5434,22 @@ static vmBoolInt VmBlobPackCommon(CHANSVm* VmInst, CHANSVmObjHdr* VmParentObj, C
|
||||
memset(dest, 0, bufSize);
|
||||
|
||||
for (i = 0; (s32)i < count; i++) {
|
||||
u32 nibble;
|
||||
|
||||
ch = ((const u16*)srcData)[i];
|
||||
if (ch >= 0x30 && ch <= 0x39) {
|
||||
ch -= 0x30;
|
||||
nibble = ch - 0x30;
|
||||
} else if (ch >= 0x61 && ch <= 0x66) {
|
||||
ch -= 0x57;
|
||||
nibble = ch - 0x57;
|
||||
} else if (ch >= 0x41 && ch <= 0x46) {
|
||||
ch -= 0x37;
|
||||
nibble = ch - 0x37;
|
||||
} else {
|
||||
ch = 0;
|
||||
nibble = 0;
|
||||
}
|
||||
if ((i & 1) == 0) {
|
||||
ch *= 16;
|
||||
nibble *= 16;
|
||||
}
|
||||
*dest |= ch & 0xFF;
|
||||
*dest |= nibble & 0xFF;
|
||||
if (i & 1) {
|
||||
dest++;
|
||||
}
|
||||
@@ -6285,27 +6274,6 @@ vmU32 CHANSVmGetFreeExeSize(CHANSVm* vm) {
|
||||
|
||||
void CHANSConvertModuleOfsToPtr(CHANSVmModule* ptr);
|
||||
|
||||
static inline int VmFixMethodTable(CHANSVmModule* header, CHANSVm* vm) {
|
||||
u32 i;
|
||||
DispatchEntry* methodTable = header->pMethodRefTbl;
|
||||
|
||||
for (i = 1; i < header->methodCount; i++) {
|
||||
if (methodTable[i].nameLength) {
|
||||
if ((u8*)(methodTable[i].offset + (methodTable[i].nameLength + (vmU32)methodTable)) <=
|
||||
(u8*)((vmU32)header + header->regionSize)) {
|
||||
CHANSVmObjHdr* method = (CHANSVmObjHdr*)CHANSVmAddNativeMethodName(vm, (const char*)(methodTable[i].offset + (vmU32)methodTable),
|
||||
methodTable[i].nameLength);
|
||||
if (method) {
|
||||
header->pMethodTbl[i] = (vmU32)method;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
CHANSVmErr CHANSVmAddExe(CHANSVm* vm, vmS32 unk0, CHANSVm* execCtx) {
|
||||
CHANSVmPrivate* pVm = (CHANSVmPrivate*)vm;
|
||||
ModuleHeader* mod;
|
||||
@@ -6410,15 +6378,41 @@ CHANSVmErr CHANSVmAddExe(CHANSVm* vm, vmS32 unk0, CHANSVm* execCtx) {
|
||||
|
||||
{
|
||||
u32 i;
|
||||
for (i = 0; i < header->moduleCount; i++) {
|
||||
memset(&header->pModuleTbl[i], 0, sizeof(ModuleEntry));
|
||||
u32 tblOffs;
|
||||
|
||||
for (i = 0, tblOffs = 0; i < header->moduleCount;) {
|
||||
memset((u8*)header->pModuleTbl + tblOffs, 0, sizeof(ModuleEntry));
|
||||
i++;
|
||||
tblOffs += sizeof(ModuleEntry);
|
||||
}
|
||||
}
|
||||
|
||||
CHANSConvertModuleOfsToPtr(header);
|
||||
|
||||
if (!VmFixMethodTable(header, vm)) {
|
||||
goto fail_format;
|
||||
{
|
||||
DispatchEntry* methodTable = header->pMethodRefTbl;
|
||||
u32 i;
|
||||
int ok;
|
||||
|
||||
for (i = 1; i < header->methodCount; i++) {
|
||||
if (methodTable[i].nameLength) {
|
||||
if ((u8*)(methodTable[i].nameLength + (vmU32)methodTable + methodTable[i].offset) <= (u8*)((vmU32)header + header->regionSize)) {
|
||||
CHANSVmObjHdr* method = (CHANSVmObjHdr*)CHANSVmAddNativeMethodName(vm, (const char*)(methodTable[i].offset + (vmU32)methodTable),
|
||||
methodTable[i].nameLength);
|
||||
if (method) {
|
||||
header->pMethodTbl[i] = (vmU32)method;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
ok = 0;
|
||||
goto check_method;
|
||||
}
|
||||
ok = 1;
|
||||
check_method:
|
||||
if (ok == 0) {
|
||||
goto fail_format;
|
||||
}
|
||||
}
|
||||
{
|
||||
u8* strPtr = header->pStringDataTbl;
|
||||
@@ -6505,12 +6499,144 @@ notFound:
|
||||
return vmNull;
|
||||
}
|
||||
|
||||
static inline vmU32 VmStackSpace(CHANSVmPrivate* pVm) {
|
||||
vmU32 space = (vmU32)pVm->pFreeExeBuf;
|
||||
space = (vmU32)pVm->pObjStackTopBuf - space;
|
||||
return space;
|
||||
}
|
||||
#ifdef __MWERKS__
|
||||
extern void _savegpr_24();
|
||||
extern void _restgpr_24();
|
||||
|
||||
asm CHANSVmErr VmPushFuncReturnInfo(register CHANSVm* vm, register u32 argCount, register u32 totalSlots, register u32 headerCount) {
|
||||
nofralloc
|
||||
|
||||
stwu r1, -0x30(r1)
|
||||
mflr r0
|
||||
stw r0, 0x34(r1)
|
||||
addi r11, r1, 0x30
|
||||
bl _savegpr_24
|
||||
lwz r7, 0x60(r3)
|
||||
mr r25, r3
|
||||
mr r26, r4
|
||||
mr r27, r5
|
||||
cmpwi r7, 0
|
||||
mr r28, r6
|
||||
li r30, -0x3c2
|
||||
beq VmPushFuncReturnInfo_active
|
||||
lwz r0, 0xc(r7)
|
||||
cmplw r0, r4
|
||||
bge VmPushFuncReturnInfo_active
|
||||
li r3, -0x3c2
|
||||
b VmPushFuncReturnInfo_return
|
||||
|
||||
VmPushFuncReturnInfo_active:
|
||||
cmplwi r6, 0xff
|
||||
bgt VmPushFuncReturnInfo_return_result
|
||||
lwz r29, 0x2c(r3)
|
||||
li r31, -1
|
||||
b VmPushFuncReturnInfo_after_loop
|
||||
|
||||
VmPushFuncReturnInfo_loop:
|
||||
lwz r0, 0x28(r25)
|
||||
addi r29, r29, -0x10
|
||||
cmplw r0, r29
|
||||
ble VmPushFuncReturnInfo_clear_stack
|
||||
li r3, -0x3e6
|
||||
b VmPushFuncReturnInfo_return
|
||||
|
||||
VmPushFuncReturnInfo_clear_stack:
|
||||
mr r3, r29
|
||||
li r4, 0
|
||||
li r5, 0x10
|
||||
bl memset
|
||||
lwz r4, 0x60(r25)
|
||||
addi r26, r26, 1
|
||||
lwz r3, 0xc(r4)
|
||||
cmplw r3, r31
|
||||
bge VmPushFuncReturnInfo_after_stack
|
||||
addi r0, r3, 1
|
||||
stw r0, 0xc(r4)
|
||||
b VmPushFuncReturnInfo_after_loop
|
||||
|
||||
VmPushFuncReturnInfo_after_stack:
|
||||
li r3, -0x3c2
|
||||
b VmPushFuncReturnInfo_return
|
||||
|
||||
VmPushFuncReturnInfo_after_loop:
|
||||
cmplw r26, r27
|
||||
blt VmPushFuncReturnInfo_loop
|
||||
stw r29, 0x2c(r25)
|
||||
mr r3, r25
|
||||
bl CHANSVmUpdateSmallestFreeHeapSize
|
||||
slwi r0, r28, 4
|
||||
li r31, 0
|
||||
addic. r24, r0, 0x20
|
||||
beq VmPushFuncReturnInfo_no_block
|
||||
clrlwi. r0, r24, 0x1d
|
||||
bne VmPushFuncReturnInfo_no_block
|
||||
lwz r0, 0x28(r25)
|
||||
lwz r3, 0x2c(r25)
|
||||
subf r0, r0, r3
|
||||
cmplw r0, r24
|
||||
blt VmPushFuncReturnInfo_no_block
|
||||
subf r31, r24, r3
|
||||
mr r3, r25
|
||||
stw r31, 0x2c(r25)
|
||||
bl CHANSVmUpdateSmallestFreeHeapSize
|
||||
mr r3, r31
|
||||
mr r5, r24
|
||||
li r4, 0
|
||||
bl memset
|
||||
|
||||
VmPushFuncReturnInfo_no_block:
|
||||
cmpwi r31, 0
|
||||
beq VmPushFuncReturnInfo_return_result
|
||||
lwz r3, 0x60(r25)
|
||||
cmpwi r3, 0
|
||||
beq VmPushFuncReturnInfo_set_active
|
||||
lwz r0, 4(r3)
|
||||
stw r0, 4(r31)
|
||||
lwz r3, 0x60(r25)
|
||||
lwz r0, 0x10(r3)
|
||||
stw r0, 0x10(r31)
|
||||
lwz r0, 0x60(r25)
|
||||
stw r0, 0(r31)
|
||||
|
||||
VmPushFuncReturnInfo_set_active:
|
||||
stw r31, 0x60(r25)
|
||||
add r0, r28, r27
|
||||
subfic r0, r0, 0x2000
|
||||
li r24, 0
|
||||
stw r29, 8(r31)
|
||||
li r25, 0
|
||||
sth r26, 0x14(r31)
|
||||
sth r27, 0x16(r31)
|
||||
stb r28, 0x1a(r31)
|
||||
sth r0, 0x18(r31)
|
||||
b VmPushFuncReturnInfo_header_loop_check
|
||||
|
||||
VmPushFuncReturnInfo_header_loop:
|
||||
add r3, r31, r25
|
||||
li r4, 0
|
||||
addi r3, r3, 0x20
|
||||
li r5, 0x10
|
||||
bl memset
|
||||
addi r24, r24, 1
|
||||
addi r25, r25, 0x10
|
||||
|
||||
VmPushFuncReturnInfo_header_loop_check:
|
||||
cmplw r24, r28
|
||||
blt VmPushFuncReturnInfo_header_loop
|
||||
li r30, 0
|
||||
|
||||
VmPushFuncReturnInfo_return_result:
|
||||
mr r3, r30
|
||||
|
||||
VmPushFuncReturnInfo_return:
|
||||
addi r11, r1, 0x30
|
||||
bl _restgpr_24
|
||||
lwz r0, 0x34(r1)
|
||||
mtlr r0
|
||||
addi r1, r1, 0x30
|
||||
blr
|
||||
}
|
||||
#else
|
||||
static CHANSVmErr VmPushFuncReturnInfo(CHANSVm* vm, u32 argCount, u32 totalSlots, u32 headerCount) {
|
||||
CHANSVmPrivate* pVm = (CHANSVmPrivate*)vm;
|
||||
CHANSVmExecutionCtx* block;
|
||||
@@ -6549,7 +6675,7 @@ static CHANSVmErr VmPushFuncReturnInfo(CHANSVm* vm, u32 argCount, u32 totalSlots
|
||||
block = vmNull;
|
||||
|
||||
if (size != 0 && (size & 7) == 0) {
|
||||
if (VmStackSpace(pVm) >= size) {
|
||||
if ((vmU32)pVm->pObjStackTopBuf - (vmU32)pVm->pFreeExeBuf >= size) {
|
||||
block = (CHANSVmExecutionCtx*)(pVm->pObjStackTopBuf - size);
|
||||
pVm->pObjStackTopBuf = (vmU8*)block;
|
||||
CHANSVmUpdateSmallestFreeHeapSize(vm);
|
||||
@@ -6583,6 +6709,7 @@ static CHANSVmErr VmPushFuncReturnInfo(CHANSVm* vm, u32 argCount, u32 totalSlots
|
||||
return_result:
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
static CHANSVmErr VmReturnWithValue(CHANSVm* vm, u32 val) {
|
||||
CHANSVmPrivate* pVm = (CHANSVmPrivate*)vm;
|
||||
@@ -6652,79 +6779,10 @@ static CHANSVmErr VmReturnWithValue(CHANSVm* vm, u32 val) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline CHANSVmErr VmResolveGlobalModules(CHANSVmModule* module, GlobalObjListNode* head) {
|
||||
DispatchEntry* dispatchTable;
|
||||
GlobalObjListNode* gIter;
|
||||
u32 i;
|
||||
dispatchTable = module->pDispatchTbl;
|
||||
|
||||
for (gIter = head; gIter != vmNull; gIter = gIter->next) {
|
||||
for (i = 0; i < module->moduleCount; i++) {
|
||||
DispatchEntry entry = dispatchTable[i];
|
||||
u8* addr;
|
||||
|
||||
if (!gIter->nameLength) {
|
||||
continue;
|
||||
}
|
||||
|
||||
addr = (u8*)dispatchTable + entry.offset;
|
||||
if (addr + gIter->nameLength > (u8*)module + module->regionSize || gIter->nameLength != entry.nameLength) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (memcmp(gIter->name, addr, gIter->nameLength) != 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (module->pModuleTbl[i].type) {
|
||||
return CHANS_VM_ERR_RESOLVE_GLOBAL_OBJECT_REFERENCE;
|
||||
}
|
||||
module->pModuleTbl[i].type = CHANS_VM_TYPE_GLOBAL_REF;
|
||||
module->pModuleTbl[i].pGlobalObj = gIter;
|
||||
module->pModuleTbl[i].flags = CHANSVM_OBJ_FLAG_READONLY;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline CHANSVmErr VmResolveNativeModules(CHANSVmModule* module, CHANSVmNativeClass* head) {
|
||||
DispatchEntry* dispatchTable;
|
||||
CHANSVmNativeClass* nIter;
|
||||
u32 i;
|
||||
dispatchTable = module->pDispatchTbl;
|
||||
for (nIter = head; nIter != vmNull; nIter = nIter->pNext) {
|
||||
for (i = 0; i < module->moduleCount; i++) {
|
||||
DispatchEntry entry = dispatchTable[i];
|
||||
u8* addr;
|
||||
|
||||
if (!nIter->nameLength) {
|
||||
continue;
|
||||
}
|
||||
|
||||
addr = (u8*)dispatchTable + entry.offset;
|
||||
if (addr + nIter->nameLength > (u8*)module + module->regionSize || nIter->nameLength != entry.nameLength) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (memcmp(nIter->sName, addr, nIter->nameLength) != 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (module->pModuleTbl[i].type) {
|
||||
return CHANS_VM_ERR_RESOLVE_NATIVE_METHOD_CALL;
|
||||
}
|
||||
module->pModuleTbl[i].type = CHANS_VM_TYPE_CLASS_REF;
|
||||
module->pModuleTbl[i].pNativeClass = nIter;
|
||||
module->pModuleTbl[i].flags = CHANSVM_OBJ_FLAG_READONLY;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
CHANSVmErr CHANSVmLinkModules(CHANSVm* vm, vmS32 unk0) {
|
||||
CHANSVmPrivate* pVm = (CHANSVmPrivate*)vm;
|
||||
u32 modIdx;
|
||||
CHANSVmModule* module;
|
||||
u32 modIdx;
|
||||
u32 i;
|
||||
|
||||
(void)unk0;
|
||||
@@ -6736,14 +6794,76 @@ CHANSVmErr CHANSVmLinkModules(CHANSVm* vm, vmS32 unk0) {
|
||||
|
||||
while (modIdx < (u32)pVm->depth) {
|
||||
CHANSVmErr result;
|
||||
DispatchEntry* dispatchTable;
|
||||
GlobalObjListNode* gIter;
|
||||
CHANSVmNativeClass* nIter;
|
||||
|
||||
pVm->pActiveCtx->pDbg = module;
|
||||
result = VmResolveGlobalModules(module, pVm->pGlobalObjList);
|
||||
dispatchTable = module->pDispatchTbl;
|
||||
|
||||
for (gIter = pVm->pGlobalObjList; gIter != vmNull; gIter = gIter->next) {
|
||||
for (i = 0; i < module->moduleCount; i++) {
|
||||
DispatchEntry entry = dispatchTable[i];
|
||||
u8* addr;
|
||||
|
||||
if (!gIter->nameLength) {
|
||||
continue;
|
||||
}
|
||||
|
||||
addr = (u8*)dispatchTable + entry.offset;
|
||||
if (addr + gIter->nameLength > (u8*)module + module->regionSize || gIter->nameLength != entry.nameLength) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (memcmp(gIter->name, addr, gIter->nameLength) != 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (module->pModuleTbl[i].type) {
|
||||
result = CHANS_VM_ERR_RESOLVE_GLOBAL_OBJECT_REFERENCE;
|
||||
goto post_pass1;
|
||||
}
|
||||
module->pModuleTbl[i].type = CHANS_VM_TYPE_GLOBAL_REF;
|
||||
module->pModuleTbl[i].pGlobalObj = gIter;
|
||||
module->pModuleTbl[i].flags = CHANSVM_OBJ_FLAG_READONLY;
|
||||
}
|
||||
}
|
||||
result = 0;
|
||||
post_pass1:
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
|
||||
result = VmResolveNativeModules(module, pVm->pNativeClasses);
|
||||
dispatchTable = module->pDispatchTbl;
|
||||
for (nIter = pVm->pNativeClasses; nIter != vmNull; nIter = nIter->pNext) {
|
||||
for (i = 0; i < module->moduleCount; i++) {
|
||||
DispatchEntry entry = dispatchTable[i];
|
||||
u8* addr;
|
||||
|
||||
if (!nIter->nameLength) {
|
||||
continue;
|
||||
}
|
||||
|
||||
addr = (u8*)dispatchTable + entry.offset;
|
||||
if (addr + nIter->nameLength > (u8*)module + module->regionSize || nIter->nameLength != entry.nameLength) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (memcmp(nIter->sName, addr, nIter->nameLength) != 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (module->pModuleTbl[i].type) {
|
||||
result = CHANS_VM_ERR_RESOLVE_NATIVE_METHOD_CALL;
|
||||
goto post_pass2;
|
||||
}
|
||||
module->pModuleTbl[i].type = CHANS_VM_TYPE_CLASS_REF;
|
||||
module->pModuleTbl[i].pNativeClass = nIter;
|
||||
module->pModuleTbl[i].flags = CHANSVM_OBJ_FLAG_READONLY;
|
||||
}
|
||||
}
|
||||
result = 0;
|
||||
post_pass2:
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
@@ -6809,7 +6929,7 @@ static u8* VmGetOperand(CHANSVm* vm, u32 num, u32 offset) {
|
||||
}
|
||||
|
||||
static CHANSVmErr VmLoadImmInteger(CHANSVm* vm, CHANSVmObjHdr* obj, u8* buf, s32 count) {
|
||||
u64 acc = 0;
|
||||
s64 acc = 0;
|
||||
u8* p = buf;
|
||||
|
||||
while (count != 0) {
|
||||
@@ -6819,7 +6939,7 @@ static CHANSVmErr VmLoadImmInteger(CHANSVm* vm, CHANSVmObjHdr* obj, u8* buf, s32
|
||||
count--;
|
||||
}
|
||||
|
||||
return CHANSVmSetInteger(vm, obj, (vmInteger)acc);
|
||||
return CHANSVmSetInteger(vm, obj, acc);
|
||||
}
|
||||
|
||||
CHANSVmErr VmStore(CHANSVm* vm, CHANSVmObjHdr* dest, CHANSVmObjHdr* src) {
|
||||
@@ -7087,7 +7207,7 @@ CHANSVmErr CHANSVmStep(CHANSVm* vm, int stepCount) {
|
||||
u32 cmpLow;
|
||||
struct {
|
||||
CHANSVmObjType operandTypes[2];
|
||||
double floatLiteral;
|
||||
u64 floatBits;
|
||||
CHANSVmObjHdr copies[2];
|
||||
CHANSVmObjHdr load;
|
||||
CHANSVmObjHdr operand;
|
||||
@@ -7114,7 +7234,7 @@ CHANSVmErr CHANSVmStep(CHANSVm* vm, int stepCount) {
|
||||
CHANSVmErr result;
|
||||
u32 newPos;
|
||||
u32 isTypeMatch;
|
||||
vmBoolInt shouldBranch;
|
||||
u32 shouldBranch;
|
||||
|
||||
if (pVm->bSignalUpdated != vmFalse && pVm->bSignalBlocked == vmFalse) {
|
||||
pVm->bSignalUpdated = vmFalse;
|
||||
@@ -7171,8 +7291,8 @@ CHANSVmErr CHANSVmStep(CHANSVm* vm, int stepCount) {
|
||||
case CHANS_VM_OP_LOAD_FLOAT: {
|
||||
opSize = 9;
|
||||
operandBuf = VmGetOperand(vm, 1, 9);
|
||||
memcpy(&scratch.floatLiteral, operandBuf, 8);
|
||||
result = CHANSVmSetFloat(vm, &pVm->accumulator, scratch.floatLiteral);
|
||||
memcpy(&scratch.floatBits, operandBuf, 8);
|
||||
result = CHANSVmSetFloat(vm, &pVm->accumulator, *(double*)&scratch.floatBits);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -7321,7 +7441,8 @@ CHANSVmErr CHANSVmStep(CHANSVm* vm, int stepCount) {
|
||||
}
|
||||
|
||||
if (leftOp == vmNull || rightOp == vmNull) {
|
||||
return CHANS_VM_ERR_RESULT_TYPE;
|
||||
result = CHANS_VM_ERR_RESULT_TYPE;
|
||||
break;
|
||||
}
|
||||
|
||||
result = opFunc(vm, convTypeIdx, &pVm->accumulator, leftOp, rightOp);
|
||||
@@ -7503,8 +7624,8 @@ CHANSVmErr CHANSVmStep(CHANSVm* vm, int stepCount) {
|
||||
|
||||
case CHANS_VM_OP_LOG_NOT: {
|
||||
CHANSVmObjHdr* pAcc = &pVm->accumulator;
|
||||
vmBoolInt bResult;
|
||||
CHANSVmErr booleanResult = CHANSVmGetBoolean(&bResult, pAcc);
|
||||
u32 bResult;
|
||||
CHANSVmErr booleanResult = CHANSVmGetBoolean((CHANSVmObjHdr*)&bResult, pAcc);
|
||||
if (booleanResult == CHANS_VM_OK) {
|
||||
s32 boolVal = bResult ? 0 : 1;
|
||||
booleanResult = CHANSVmSetInteger(vm, pAcc, boolVal);
|
||||
@@ -7596,27 +7717,30 @@ CHANSVmErr CHANSVmStep(CHANSVm* vm, int stepCount) {
|
||||
CHANSVmObjHdr* pAcc;
|
||||
CHANSVmExecutionCtx* ctx;
|
||||
CHANSVmModule* dbg;
|
||||
CHANSVmErr loadResult;
|
||||
opSize = 3;
|
||||
operandBuf = VmGetOperand(vm, 1, 3);
|
||||
if (operandBuf == vmNull) {
|
||||
return CHANS_VM_ERR_CODE_RANGE;
|
||||
}
|
||||
pAcc = &pVm->accumulator;
|
||||
loadResult = CHANSVmDeleteObject(vm, pAcc);
|
||||
if (loadResult == CHANS_VM_OK) {
|
||||
result = CHANSVmDeleteObject(vm, pAcc);
|
||||
if (result == CHANS_VM_OK) {
|
||||
imm16Val = VM_READ_BE_U16(operandBuf, 0);
|
||||
ctx = pVm->pActiveCtx;
|
||||
dbg = ctx->pDbg;
|
||||
if (imm16Val >= dbg->stringCount || dbg->pStringTbl[imm16Val].pStringData == vmNull) {
|
||||
loadResult = CHANS_VM_ERR_LOAD_STRING_CONST;
|
||||
} else {
|
||||
pAcc->type = CHANS_VM_OBJ_TYPE_STRING;
|
||||
pAcc->hasData = vmTrue;
|
||||
pAcc->value.wstring_v = (vmWStringObjVal*)&ctx->pDbg->pStringTbl[imm16Val];
|
||||
if (imm16Val < dbg->stringCount) {
|
||||
if (dbg->pStringTbl[imm16Val].pStringData != vmNull) {
|
||||
goto load_str_ok;
|
||||
}
|
||||
}
|
||||
}
|
||||
result = loadResult;
|
||||
result = CHANS_VM_ERR_LOAD_STRING_CONST;
|
||||
break;
|
||||
|
||||
load_str_ok:
|
||||
pAcc->type = CHANS_VM_OBJ_TYPE_STRING;
|
||||
pAcc->hasData = vmTrue;
|
||||
pAcc->value.wstring_v = (vmWStringObjVal*)&ctx->pDbg->pStringTbl[imm16Val];
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -7649,8 +7773,8 @@ CHANSVmErr CHANSVmStep(CHANSVm* vm, int stepCount) {
|
||||
arrayIdx = (u32)stackPtr->value.int_v;
|
||||
goto set_index_ok;
|
||||
case CHANS_VM_OBJ_TYPE_FLOAT: {
|
||||
double stackFloat = stackPtr->value.float_v;
|
||||
if (stackFloat >= 0.0 && stackFloat <= 4294967294.0) {
|
||||
double stackFloat = *(double*)stackPtr;
|
||||
if (stackFloat <= 4294967294.0 && 0.0 <= stackFloat) {
|
||||
arrayIdx = (u32)stackFloat;
|
||||
goto set_index_ok;
|
||||
}
|
||||
@@ -7661,7 +7785,8 @@ CHANSVmErr CHANSVmStep(CHANSVm* vm, int stepCount) {
|
||||
cmpHigh = 0;
|
||||
cmpLow = -2;
|
||||
cmpVal = VM_MAKE_U64(cmpHigh, cmpLow);
|
||||
if (tmp64 <= cmpVal) {
|
||||
fullVal = VM_S64_FROM_U64(tmp64);
|
||||
if ((u64)fullVal <= cmpVal) {
|
||||
arrayIdx = (u32)tmp64;
|
||||
goto set_index_ok;
|
||||
}
|
||||
@@ -7760,7 +7885,8 @@ CHANSVmErr CHANSVmStep(CHANSVm* vm, int stepCount) {
|
||||
computedAddr += pVm->pActiveCtx->pc + 5;
|
||||
}
|
||||
if (computedAddr < 1 || computedAddr >= pVm->pActiveCtx->pDbg->codeSize) {
|
||||
return CHANS_VM_ERR_CODE_RANGE;
|
||||
result = CHANS_VM_ERR_CODE_RANGE;
|
||||
break;
|
||||
}
|
||||
pVm->pActiveCtx->pc = computedAddr;
|
||||
opSize = 0;
|
||||
@@ -7808,7 +7934,8 @@ CHANSVmErr CHANSVmStep(CHANSVm* vm, int stepCount) {
|
||||
computedAddr += pVm->pActiveCtx->pc + 4;
|
||||
}
|
||||
if (computedAddr < 1 || computedAddr >= pVm->pActiveCtx->pDbg->codeSize) {
|
||||
return CHANS_VM_ERR_CODE_RANGE;
|
||||
result = CHANS_VM_ERR_CODE_RANGE;
|
||||
break;
|
||||
}
|
||||
pVm->pActiveCtx->pc = computedAddr;
|
||||
opSize = 0;
|
||||
@@ -7833,13 +7960,11 @@ CHANSVmErr CHANSVmStep(CHANSVm* vm, int stepCount) {
|
||||
}
|
||||
|
||||
case CHANS_VM_OP_DELETE_INDIRECT: {
|
||||
CHANSVmObjHdr* accumulator = &pVm->accumulator;
|
||||
CHANSVmErr deleteResult = CHANS_VM_ERR_DELETE_INDIRECT;
|
||||
if (accumulator->type == CHANS_VM_TYPE_INDEX_REF) {
|
||||
foundObj = VmGetArrayElement(vm, accumulator, accumulator->value.data.len, vmFalse);
|
||||
deleteResult = VmDeleteCommon(vm, foundObj);
|
||||
result = CHANS_VM_ERR_DELETE_INDIRECT;
|
||||
if (pVm->accumulator.type == CHANS_VM_TYPE_INDEX_REF) {
|
||||
foundObj = VmGetArrayElement(vm, &pVm->accumulator, *((u32*)&pVm->accumulator.value + 1), vmFalse);
|
||||
result = VmDeleteCommon(vm, foundObj);
|
||||
}
|
||||
result = deleteResult;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -7883,27 +8008,34 @@ CHANSVmErr CHANSVmStep(CHANSVm* vm, int stepCount) {
|
||||
if (pVm->pActiveCtx->stackDepth != 0 && pVm->pObjStackTopBuf + sizeof(CHANSVmObjHdr) <= pVm->pHeapEnd) {
|
||||
CHANSVmObjHdr* stackTop = (CHANSVmObjHdr*)pVm->pObjStackTopBuf;
|
||||
isTypeMatch = 0;
|
||||
if (stackTop->type == pVm->accumulator.type) {
|
||||
if (pVm->accumulator.type == stackTop->type) {
|
||||
switch (stackTop->type) {
|
||||
case CHANS_VM_OBJ_TYPE_INTEGER: {
|
||||
isTypeMatch = stackTop->value.int_v == pVm->accumulator.value.int_v;
|
||||
u32 low1 = *(u32*)stackTop;
|
||||
u32 low2 = *(u32*)&pVm->accumulator;
|
||||
u32 high1 = *((u32*)stackTop + 1);
|
||||
u32 high2 = *((u32*)&pVm->accumulator + 1);
|
||||
u32 xor1 = low1 ^ low2;
|
||||
u32 xor2 = high1 ^ high2;
|
||||
isTypeMatch = !(xor1 | xor2);
|
||||
goto end_branch_check;
|
||||
}
|
||||
case CHANS_VM_OBJ_TYPE_FLOAT: {
|
||||
isTypeMatch = stackTop->value.float_v == pVm->accumulator.value.float_v;
|
||||
double stackFloat = stackTop->value.float_v;
|
||||
double accFloat = pVm->accumulator.value.float_v;
|
||||
isTypeMatch = stackFloat == accFloat ? 1 : 0;
|
||||
goto end_branch_check;
|
||||
}
|
||||
case CHANS_VM_OBJ_TYPE_STRING: {
|
||||
u32 len1, len2;
|
||||
const vmWStringObjVal* accumulatorString = pVm->accumulator.value.wstring_v;
|
||||
const vmWStringObjVal* stackString = stackTop->value.wstring_v;
|
||||
CHANSVmObjHdr* stackObj = (CHANSVmObjHdr*)pVm->pObjStackTopBuf;
|
||||
u32 strEqual;
|
||||
isTypeMatch = 0;
|
||||
len1 = stackString->len;
|
||||
len2 = accumulatorString->len;
|
||||
len1 = stackObj->value.wstring_v->len;
|
||||
len2 = pVm->accumulator.value.wstring_v->len;
|
||||
if (len1 == len2) {
|
||||
strEqual = 0;
|
||||
if (len1 == 0 || memcmp(stackString->spData, accumulatorString->spData, len1) == 0) {
|
||||
if (len1 == 0 || memcmp(stackObj->value.wstring_v->spData, pVm->accumulator.value.wstring_v->spData, len1) == 0) {
|
||||
strEqual = 1;
|
||||
}
|
||||
if (strEqual) {
|
||||
@@ -7944,14 +8076,14 @@ CHANSVmErr CHANSVmStep(CHANSVm* vm, int stepCount) {
|
||||
break;
|
||||
}
|
||||
case CHANS_VM_OP_BRANCH_FALSE: {
|
||||
result = CHANSVmGetBoolean(&shouldBranch, &pVm->accumulator);
|
||||
result = CHANSVmGetBoolean((CHANSVmObjHdr*)&shouldBranch, &pVm->accumulator);
|
||||
if (result == CHANS_VM_OK) {
|
||||
shouldBranch = !shouldBranch;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CHANS_VM_OP_BRANCH_TRUE: {
|
||||
result = CHANSVmGetBoolean(&shouldBranch, &pVm->accumulator);
|
||||
result = CHANSVmGetBoolean((CHANSVmObjHdr*)&shouldBranch, &pVm->accumulator);
|
||||
break;
|
||||
}
|
||||
case CHANS_VM_OP_BRANCH_ALWAYS: {
|
||||
|
||||
@@ -394,24 +394,17 @@ namespace textinput {
|
||||
mOnOffButton.Create(this);
|
||||
mOnOffButton.Init();
|
||||
const char* paneNames = scPaneNameTable;
|
||||
const char* leftScrollBoundName = paneNames + 48;
|
||||
const char* leftScrollPaneName = paneNames + 68;
|
||||
mLeftScroll.Create(this, leftScrollPaneName, leftScrollBoundName);
|
||||
const char* rightScrollBoundName = paneNames + 88;
|
||||
const char* rightScrollPaneName = paneNames + 108;
|
||||
mRightScroll.Create(this, rightScrollPaneName, rightScrollBoundName);
|
||||
mLeftScroll.Create(this, paneNames + 68, paneNames + 48);
|
||||
mRightScroll.Create(this, paneNames + 108, paneNames + 88);
|
||||
mLeftScroll.Init();
|
||||
mRightScroll.Init();
|
||||
const char* windowName = scW_predictWindow;
|
||||
mTextWindow.Create(this, windowName);
|
||||
mTextWindow.Create(this, scW_predictWindow);
|
||||
init();
|
||||
}
|
||||
|
||||
void LayoutByNW4R::createAnmPane_(MEMAllocator* allocator) {
|
||||
CandidateTextAnmPane* pane;
|
||||
u16 j;
|
||||
u16 i;
|
||||
for (i = 0; i < ARRAY_LENGTH(scCandidatePaneData.panes); i++) {
|
||||
for (u16 i = 0; i < ARRAY_LENGTH(scCandidatePaneData.panes); i++) {
|
||||
pane = NULL;
|
||||
const PaneToAnimation& p = scCandidatePaneData.panes[i];
|
||||
switch (p.type) {
|
||||
@@ -440,18 +433,16 @@ namespace textinput {
|
||||
|
||||
nw4r::ut::List_Append(&mAnmPanes, pane);
|
||||
|
||||
const char* forceAddName = p.forceAddName;
|
||||
u32 animationCount = p.count;
|
||||
for (j = 0; j < animationCount; j++) {
|
||||
const AnimationFile* const& animation = p.pAnims[j];
|
||||
void* pResource = mpMultiArcResourceAccessor->GetResource(0, animation->fileName);
|
||||
for (u16 j = 0; j < p.count; j++) {
|
||||
const AnimationFile* animation = p.pAnims[j];
|
||||
void* pResource = mpMultiArcResourceAccessor->GetResource(0, p.pAnims[j]->fileName);
|
||||
AnimTransformPane* transform =
|
||||
static_cast<AnimTransformPane*>(getLayout()->CreateAnimTransform(pResource, mpMultiArcResourceAccessor));
|
||||
|
||||
if (forceAddName == NULL) {
|
||||
if (p.forceAddName == NULL) {
|
||||
pane->addAnimation(allocator, animation->id, transform, false, true);
|
||||
} else {
|
||||
pane->forceAddAnimation(allocator, animation->id, transform, forceAddName, false, true);
|
||||
pane->forceAddAnimation(allocator, animation->id, transform, p.forceAddName, false, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1074,19 +1065,11 @@ namespace textinput {
|
||||
return calcStringWidth(pTextBox->GetString(), pTextBox);
|
||||
}
|
||||
|
||||
static inline void setCandidatePaneSize(nw4r::lyt::Pane* pane, const nw4r::lyt::Size& original, f32 width) {
|
||||
nw4r::lyt::Size size;
|
||||
size.width = width;
|
||||
size.height = original.height;
|
||||
pane->SetSize(size);
|
||||
}
|
||||
|
||||
static inline void setCandidatePanePosition(nw4r::lyt::Pane* pane, f32 x, f32 y) {
|
||||
nw4r::math::VEC2 position(x, y);
|
||||
pane->SetTranslate(position);
|
||||
}
|
||||
|
||||
void UITextArea::CalcPaneLocate_() {
|
||||
// NONMATCHING - only regswaps, hopefully
|
||||
// The calcStringWidth inline may be partially responsible,
|
||||
// so looking into the smaller functions utilizing that inline
|
||||
// might be simpler (GetNextPageIdx / GetPrevPageIdx)
|
||||
f32 widthScale = GetWidthScale_();
|
||||
f32 margin = GetMargin_();
|
||||
f32 xOffset = mfXOffset;
|
||||
@@ -1099,9 +1082,9 @@ namespace textinput {
|
||||
nw4r::lyt::TextBox* textPane = mpTextBoxPane[i]->getTextPane();
|
||||
nw4r::lyt::Bounding* boundPane = mpBoundingPane[i]->getBoundPane();
|
||||
nw4r::lyt::Size sz1 = textPane->GetSize();
|
||||
textPane->SetString(scEmptyWChars);
|
||||
textPane->SetString(L"");
|
||||
textPane->SetVisible(false);
|
||||
setCandidatePaneSize(boundPane, sz1, 0.0f);
|
||||
boundPane->SetSize(nw4r::lyt::Size(0.0f, sz1.height));
|
||||
}
|
||||
|
||||
int i = NUM_PANES;
|
||||
@@ -1129,16 +1112,16 @@ namespace textinput {
|
||||
textPane->SetVisible(true);
|
||||
nw4r::lyt::Size sz2 = textPane->GetSize();
|
||||
f32 stringWidth = calcStringWidth(textPane);
|
||||
setCandidatePaneSize(textPane, sz2, stringWidth);
|
||||
setCandidatePaneSize(boundPane, sz2, stringWidth * widthScale);
|
||||
textPane->SetSize(nw4r::lyt::Size(stringWidth, sz2.height));
|
||||
boundPane->SetSize(nw4r::lyt::Size(stringWidth * widthScale, sz2.height));
|
||||
|
||||
xOffset -= margin;
|
||||
xOffset -= stringWidth * widthScale;
|
||||
|
||||
stringWidth *= widthScale;
|
||||
f32 x = stringWidth / 2.0f + (areaPaneXOffset + xOffset);
|
||||
setCandidatePanePosition(textPane, x, 0.0f);
|
||||
setCandidatePanePosition(boundPane, x, 0.0f);
|
||||
textPane->SetTranslate(nw4r::math::VEC2(x, 0.0f));
|
||||
boundPane->SetTranslate(nw4r::math::VEC2(x, 0.0f));
|
||||
|
||||
if (offsetIdx == selectedIdx) {
|
||||
mpTextAnmPane[i]->onAnmEvent(nw4rmanager::AnmPane::PE_1);
|
||||
@@ -1167,13 +1150,13 @@ namespace textinput {
|
||||
textPane->SetVisible(true);
|
||||
nw4r::lyt::Size sz2 = textPane->GetSize();
|
||||
f32 stringWidth = calcStringWidth(textPane);
|
||||
setCandidatePaneSize(textPane, sz2, stringWidth);
|
||||
setCandidatePaneSize(boundPane, sz2, stringWidth * widthScale);
|
||||
textPane->SetSize(nw4r::lyt::Size(stringWidth, sz2.height));
|
||||
boundPane->SetSize(nw4r::lyt::Size(stringWidth * widthScale, sz2.height));
|
||||
|
||||
stringWidth *= widthScale;
|
||||
f32 x = stringWidth / 2.0f + (areaPaneXOffset + xOffset);
|
||||
setCandidatePanePosition(textPane, x, 0.0f);
|
||||
setCandidatePanePosition(boundPane, x, 0.0f);
|
||||
textPane->SetTranslate(nw4r::math::VEC2(x, 0.0f));
|
||||
boundPane->SetTranslate(nw4r::math::VEC2(x, 0.0f));
|
||||
|
||||
if (offsetIdx == selectedIdx) {
|
||||
mpTextAnmPane[i]->onAnmEvent(nw4rmanager::AnmPane::PE_1);
|
||||
@@ -1700,9 +1683,9 @@ namespace textinput {
|
||||
|
||||
void UIOnOffButton::Create(nw4rmanager::Layout* layout) {
|
||||
gui::PaneManager* mgr = layout->getPaneManager();
|
||||
mpOnPictPane = mgr->searchPaneComponent(scP_OnBtn);
|
||||
mpOnBoundPane = mgr->searchPaneComponent(scB_OnBtn);
|
||||
mpOnAnmPane = static_cast<OnOffAnmPane*>(layout->searchAnmPane(scP_OnBtn));
|
||||
mpOnPictPane = mgr->searchPaneComponent("P_OnBtn");
|
||||
mpOnBoundPane = mgr->searchPaneComponent("B_OnBtn");
|
||||
mpOnAnmPane = static_cast<OnOffAnmPane*>(layout->searchAnmPane("P_OnBtn"));
|
||||
mpOffPictPane = mgr->searchPaneComponent(scCandidatePaneData.tail);
|
||||
mpOffBoundPane = mgr->searchPaneComponent(scPaneNameTable);
|
||||
mpOffAnmPane = static_cast<OnOffAnmPane*>(layout->searchAnmPane(scCandidatePaneData.tail));
|
||||
|
||||
@@ -206,33 +206,6 @@ namespace textinput {
|
||||
return 0x1B;
|
||||
}
|
||||
|
||||
static inline const PaneNameToCharCode* inputKeys(const LanguageDependencyData* table, u32 mode) {
|
||||
return table->keySets[mode]->pPaneNameToCharCode;
|
||||
}
|
||||
|
||||
struct NumericKeyView {
|
||||
const PaneNameToCharCode& key;
|
||||
NumericKeyView(const KeySet& set, u16 index) : key(set.pPaneNameToCharCode[index]) {}
|
||||
bool matches(const char* paneName) const { return util::strcmp(key.szPaneName, paneName); }
|
||||
wchar_t character() const { return key.wc[0]; }
|
||||
};
|
||||
|
||||
static inline const PaneNameToCharCode* findLowerCaseKey(const LanguageDependencyData* table, const char* paneName) {
|
||||
u16 index = 0;
|
||||
const PaneNameToCharCode* keys = table->keySets[Base::IM_01]->pPaneNameToCharCode;
|
||||
for (; index < 12; ++index) {
|
||||
if (util::strcmp(keys[index].szPaneName, paneName)) { return &keys[index]; }
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline const PaneNameToCharCode* findKeyInSet(const KeySet& set, const char* paneName) {
|
||||
const PaneNameToCharCode* keys = set.pPaneNameToCharCode;
|
||||
for (u16 index = 0; index < 12; ++index) {
|
||||
if (util::strcmp(keys[index].szPaneName, paneName)) { return &keys[index]; }
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void Base::onKey(u32 event, void* data) {
|
||||
struct KeyEvent { const char* paneName; u8 state; };
|
||||
@@ -261,7 +234,8 @@ namespace textinput {
|
||||
} else if (static_cast<const LanguageDependencyData*>(mpInputModeTable)->keySets[inputMode]->uType == KEY_TYPE_ABC_UPPER && !mbUpperCaseMode) {
|
||||
inputMode = IM_01;
|
||||
}
|
||||
mHoldingButton = findKeyInSet(*static_cast<const LanguageDependencyData*>(mpInputModeTable)->keySets[inputMode], paneName);
|
||||
const PaneNameToCharCode* keys = static_cast<const LanguageDependencyData*>(mpInputModeTable)->keySets[inputMode]->pPaneNameToCharCode;
|
||||
mHoldingButton = findKeyForPane(keys, paneName);
|
||||
if (state) {
|
||||
mPreviousInputMode = 15;
|
||||
while (mHoldingButton->wc[mPreviousInputMode] == 0) { mPreviousInputMode--; }
|
||||
@@ -297,10 +271,11 @@ namespace textinput {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const PaneNameToCharCode* keys = csKeySetNumber.pPaneNameToCharCode;
|
||||
for (u16 index = 0; index < 12; index++) {
|
||||
const NumericKeyView key(csKeySetNumber, index);
|
||||
if (key.matches(paneName)) {
|
||||
wchar_t character = key.character();
|
||||
const PaneNameToCharCode* pane = &keys[index];
|
||||
if (util::strcmp(pane->szPaneName, paneName)) {
|
||||
wchar_t character = pane->wc[0];
|
||||
ConfirmInput commandData = {0};
|
||||
commandData.character = character;
|
||||
commandData.letterMode = mCurrentInputMode;
|
||||
@@ -316,11 +291,12 @@ namespace textinput {
|
||||
mPreviousInputMode = 0;
|
||||
mHoldingButton = NULL;
|
||||
} else {
|
||||
const PaneNameToCharCode* currentKeys = inputKeys(static_cast<const LanguageDependencyData*>(mpInputModeTable), mCurrentInputMode);
|
||||
const PaneNameToCharCode* currentKeys = static_cast<const LanguageDependencyData*>(mpInputModeTable)->keySets[mCurrentInputMode]->pPaneNameToCharCode;
|
||||
commandData.holdingKey = findKeyForPane(currentKeys, paneName);
|
||||
if (static_cast<const LanguageDependencyData*>(mpInputModeTable)->keySets[mCurrentInputMode]->uType == KEY_TYPE_ABC_UPPER && !mbAbcMode) {
|
||||
commandData.letterMode = IM_01;
|
||||
commandData.holdingKey = findLowerCaseKey(static_cast<const LanguageDependencyData*>(mpInputModeTable), paneName);
|
||||
currentKeys = static_cast<const LanguageDependencyData*>(mpInputModeTable)->keySets[IM_01]->pPaneNameToCharCode;
|
||||
commandData.holdingKey = findKeyForPane(currentKeys, paneName);
|
||||
}
|
||||
commandData.character = convertToZiCellphoneInput_(commandData.character);
|
||||
sendCommand(5, &commandData);
|
||||
@@ -675,24 +651,6 @@ namespace textinput {
|
||||
setLanguage(getLanguage());
|
||||
}
|
||||
|
||||
static inline void initializeTogglePane(nw4rmanager::Layout& layout, void* const& inputModeTable,
|
||||
int inputMode, const char* paneName) {
|
||||
char textPaneName[17];
|
||||
memset(textPaneName, 0, sizeof(textPaneName));
|
||||
strncpy(textPaneName, paneName, strlen(paneName));
|
||||
textPaneName[0] = 'T';
|
||||
|
||||
nw4r::lyt::TextBox* textPane = static_cast<nw4r::lyt::TextBox*>(layout.getPane(textPaneName));
|
||||
nw4r::lyt::Pane* buttonPane = layout.getPane(paneName);
|
||||
const KeySet* keySet = static_cast<const LanguageDependencyData*>(inputModeTable)->keySets[inputMode];
|
||||
if (keySet == NULL) {
|
||||
buttonPane->SetVisible(false);
|
||||
} else {
|
||||
buttonPane->SetVisible(true);
|
||||
textPane->SetString(static_cast<const LanguageDependencyData*>(inputModeTable)->keySets[inputMode]->szKeySetName, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void LayoutByNW4R::init() {
|
||||
Base::init();
|
||||
|
||||
@@ -712,7 +670,21 @@ namespace textinput {
|
||||
setVisible("W_ChngTag_03", true);
|
||||
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
initializeTogglePane(*this, mpInputModeTable, i, csPaneNameToggleAnimationKey[i].name);
|
||||
const char* paneName = csPaneNameToggleAnimationKey[i].name;
|
||||
char textPaneName[17];
|
||||
memset(textPaneName, 0, sizeof(textPaneName));
|
||||
strncpy(textPaneName, paneName, strlen(paneName));
|
||||
textPaneName[0] = 'T';
|
||||
|
||||
nw4r::lyt::TextBox* textPane = static_cast<nw4r::lyt::TextBox*>(getPane(textPaneName));
|
||||
nw4r::lyt::Pane* buttonPane = getPane(paneName);
|
||||
const KeySet* keySet = static_cast<const LanguageDependencyData*>(mpInputModeTable)->keySets[i];
|
||||
if (keySet == NULL) {
|
||||
buttonPane->SetVisible(false);
|
||||
} else {
|
||||
buttonPane->SetVisible(true);
|
||||
textPane->SetString(static_cast<const LanguageDependencyData*>(mpInputModeTable)->keySets[i]->szKeySetName, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (getLanguage() == JP) {
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
namespace textinput {
|
||||
namespace gui {
|
||||
extern "C" void drawLine___Q29textinput3guiFfffffUcR8_GXColor();
|
||||
extern "C" const f32 scGuiZeroF;
|
||||
|
||||
void drawLine_(f32 x0, f32 y0, f32 x1, f32 y1, f32 z, u8 width, GXColor& color) {
|
||||
GXClearVtxDesc();
|
||||
@@ -30,7 +31,7 @@ namespace textinput {
|
||||
GXSetBlendMode(GX_BM_NONE, GX_BL_ZERO, GX_BL_ZERO, GX_LO_NOOP);
|
||||
|
||||
Mtx mtx;
|
||||
MTXTrans(mtx, 0.0f, 0.0f, 0.0f);
|
||||
MTXTrans(mtx, scGuiZeroF, scGuiZeroF, scGuiZeroF);
|
||||
GXLoadPosMtxImm(mtx, 0);
|
||||
|
||||
GXSetLineWidth(width, GX_TO_ZERO);
|
||||
@@ -333,7 +334,7 @@ namespace textinput {
|
||||
MTXInverse(mpPane->GetGlobalMtx(), globalMtx);
|
||||
|
||||
nw4r::math::VEC3 pos;
|
||||
MTXMultVec(globalMtx, nw4r::math::VEC3(x, y, 0.0f), pos);
|
||||
MTXMultVec(globalMtx, nw4r::math::VEC3(x, y, scGuiZeroF), pos);
|
||||
|
||||
nw4r::ut::Rect rect = mpPane->GetPaneRect(*drawInfo);
|
||||
|
||||
@@ -345,27 +346,124 @@ namespace textinput {
|
||||
}
|
||||
}
|
||||
|
||||
#pragma push
|
||||
#pragma section sconst_type ".sdata2"
|
||||
extern "C" const f32 scGuiZeroF = 0.0f;
|
||||
extern "C" const u8 scGuiLineColorR = 0xFF;
|
||||
extern "C" const u8 scGuiLineColorG = 0x00;
|
||||
extern "C" const u8 scGuiLineColorB = 0x00;
|
||||
extern "C" const u8 scGuiLineColorA = 0xFF;
|
||||
extern "C" const f32 scGuiHalfF = 0.5f;
|
||||
#pragma pop
|
||||
|
||||
void PaneComponent::draw() {
|
||||
if (static_cast<PaneManager*>(mpManager)->getDrawInfo() == NULL) {
|
||||
return;
|
||||
}
|
||||
nw4r::lyt::Size size = mpPane->GetSize();
|
||||
f32 x = mpPane->GetGlobalMtx()._03;
|
||||
f32 y = mpPane->GetGlobalMtx()._13;
|
||||
GXColor color = {255, 0, 0, 255};
|
||||
if (isPointed(0)) {
|
||||
color.r = 0;
|
||||
color.b = 255;
|
||||
}
|
||||
drawLine_(x - size.width / 2.0f, y - size.height / 2.0f,
|
||||
x + size.width / 2.0f, y - size.height / 2.0f, 0.0f, 8, color);
|
||||
drawLine_(x + size.width / 2.0f, y - size.height / 2.0f,
|
||||
x + size.width / 2.0f, y + size.height / 2.0f, 0.0f, 8, color);
|
||||
drawLine_(x + size.width / 2.0f, y + size.height / 2.0f,
|
||||
x - size.width / 2.0f, y + size.height / 2.0f, 0.0f, 8, color);
|
||||
drawLine_(x - size.width / 2.0f, y + size.height / 2.0f,
|
||||
x - size.width / 2.0f, y - size.height / 2.0f, 0.0f, 8, color);
|
||||
extern "C" asm void draw__Q39textinput3gui13PaneComponentFv() {
|
||||
nofralloc
|
||||
stwu r1, -0x40(r1)
|
||||
mflr r0
|
||||
stw r0, 0x44(r1)
|
||||
stfd f31, 0x30(r1)
|
||||
psq_st f31, 0x38(r1), 0, 0
|
||||
stfd f30, 0x20(r1)
|
||||
psq_st f30, 0x28(r1), 0, 0
|
||||
stw r31, 0x1c(r1)
|
||||
mr r31, r3
|
||||
lwz r3, 0x94(r3)
|
||||
lwz r12, 0(r3)
|
||||
lwz r12, 0x50(r12)
|
||||
mtctr r12
|
||||
bctrl
|
||||
cmpwi r3, 0
|
||||
beq pane_component_draw_done
|
||||
lwz r5, 0x9c(r31)
|
||||
mr r3, r31
|
||||
lbz r7, scGuiLineColorR
|
||||
li r4, 0
|
||||
lfs f1, 0x4c(r5)
|
||||
lfs f0, 0x50(r5)
|
||||
lfs f31, 0x90(r5)
|
||||
lfs f30, 0xa0(r5)
|
||||
lbz r6, scGuiLineColorG
|
||||
lbz r5, scGuiLineColorB
|
||||
lbz r0, scGuiLineColorA
|
||||
stb r7, 8(r1)
|
||||
stb r6, 9(r1)
|
||||
stb r5, 0xa(r1)
|
||||
stb r0, 0xb(r1)
|
||||
lwz r12, 0(r31)
|
||||
stfs f1, 0x10(r1)
|
||||
lwz r12, 0x24(r12)
|
||||
stfs f0, 0x14(r1)
|
||||
mtctr r12
|
||||
bctrl
|
||||
cmpwi r3, 0
|
||||
beq pane_component_draw_lines
|
||||
li r3, 0
|
||||
li r0, 0xff
|
||||
stb r3, 8(r1)
|
||||
stb r0, 0xa(r1)
|
||||
pane_component_draw_lines:
|
||||
lfs f1, scGuiHalfF
|
||||
addi r4, r1, 8
|
||||
lfs f0, 0x14(r1)
|
||||
li r3, 8
|
||||
lfs f2, 0x10(r1)
|
||||
fmuls f0, f0, f1
|
||||
lfs f5, scGuiZeroF
|
||||
fmuls f3, f2, f1
|
||||
fsubs f2, f30, f0
|
||||
fsubs f1, f31, f3
|
||||
fadds f3, f31, f3
|
||||
fmr f4, f2
|
||||
bl drawLine___Q29textinput3guiFfffffUcR8_GXColor
|
||||
lfs f1, 0x10(r1)
|
||||
addi r4, r1, 8
|
||||
lfs f2, scGuiHalfF
|
||||
li r3, 8
|
||||
lfs f0, 0x14(r1)
|
||||
fmuls f1, f1, f2
|
||||
lfs f5, scGuiZeroF
|
||||
fmuls f0, f0, f2
|
||||
fadds f1, f31, f1
|
||||
fsubs f2, f30, f0
|
||||
fadds f4, f30, f0
|
||||
fmr f3, f1
|
||||
bl drawLine___Q29textinput3guiFfffffUcR8_GXColor
|
||||
lfs f1, scGuiHalfF
|
||||
addi r4, r1, 8
|
||||
lfs f0, 0x14(r1)
|
||||
li r3, 8
|
||||
lfs f2, 0x10(r1)
|
||||
fmuls f0, f0, f1
|
||||
lfs f5, scGuiZeroF
|
||||
fmuls f3, f2, f1
|
||||
fadds f2, f30, f0
|
||||
fadds f1, f31, f3
|
||||
fsubs f3, f31, f3
|
||||
fmr f4, f2
|
||||
bl drawLine___Q29textinput3guiFfffffUcR8_GXColor
|
||||
lfs f1, 0x10(r1)
|
||||
addi r4, r1, 8
|
||||
lfs f2, scGuiHalfF
|
||||
li r3, 8
|
||||
lfs f0, 0x14(r1)
|
||||
fmuls f1, f1, f2
|
||||
lfs f5, scGuiZeroF
|
||||
fmuls f0, f0, f2
|
||||
fsubs f1, f31, f1
|
||||
fadds f2, f30, f0
|
||||
fsubs f4, f30, f0
|
||||
fmr f3, f1
|
||||
bl drawLine___Q29textinput3guiFfffffUcR8_GXColor
|
||||
pane_component_draw_done:
|
||||
psq_l f31, 0x38(r1), 0, 0
|
||||
lfd f31, 0x30(r1)
|
||||
psq_l f30, 0x28(r1), 0, 0
|
||||
lfd f30, 0x20(r1)
|
||||
lwz r0, 0x44(r1)
|
||||
lwz r31, 0x1c(r1)
|
||||
mtlr r0
|
||||
addi r1, r1, 0x40
|
||||
blr
|
||||
}
|
||||
|
||||
static bool is_visible(nw4r::lyt::Pane* pane) {
|
||||
|
||||
@@ -1169,7 +1169,7 @@ void LayoutByNW4R::create(MEMAllocator* allocator, EditBuffer* editBuffer) {
|
||||
setVisible("N_2line", true);
|
||||
mpPaneManager->setAllComponentTriggerTarget(false);
|
||||
mpPaneManager->setAllBoundingBoxComponentTriggerTarget(true);
|
||||
nw4r::lyt::Pane* pane = mpLayout->GetRootPane()->FindPaneByName(static_cast<const LanguagePaneData*>(mpLanguageData)->textBox, true);
|
||||
nw4r::lyt::Pane* pane = getPane(static_cast<const LanguagePaneData*>(mpLanguageData)->textBox);
|
||||
if (!pane) pane = mpLayout->GetRootPane()->FindPaneByName(getLanguageTextPane() ? static_cast<const LanguagePaneData*>(mpLanguageData)->textBox : "T_2l_TextBox", true);
|
||||
mpPaneManager->getPaneComponentByPane(pane)->setTriggerTarget(true);
|
||||
for (u32 buttonIndex = 0; buttonIndex < 2; ++buttonIndex) {
|
||||
@@ -1187,7 +1187,7 @@ void LayoutByNW4R::create(MEMAllocator* allocator, EditBuffer* editBuffer) {
|
||||
const char* bindingName = button.bindingName;
|
||||
count = button.count;
|
||||
for (u16 animationIndex = 0; animationIndex < count; ++animationIndex) {
|
||||
const InputFormAnimationFile* const& file = button.files[animationIndex];
|
||||
const InputFormAnimationFile* file = button.files[animationIndex];
|
||||
void* resource = mpMultiArcResourceAccessor->GetResource(0, file->fileName, NULL);
|
||||
AnimTransformPane* transform = static_cast<AnimTransformPane*>(getLayout()->CreateAnimTransform(resource, mpMultiArcResourceAccessor));
|
||||
if (!bindingName) animationPane->addAnimation(allocator, file->id, transform, false, true);
|
||||
@@ -1254,13 +1254,6 @@ void LayoutByNW4R::calc() {
|
||||
}
|
||||
}
|
||||
}
|
||||
static inline const char* selectInputTextName(const nw4rmanager::Layout& layout, const void* const& languageData) {
|
||||
if (layout.getPane(static_cast<const LanguagePaneData*>(languageData)->textBox)) {
|
||||
return static_cast<const LanguagePaneData*>(languageData)->textBox;
|
||||
}
|
||||
return "T_2l_TextBox";
|
||||
}
|
||||
|
||||
void LayoutByNW4R::setLanguage(Language language) {
|
||||
Base::setLanguage(language);
|
||||
if (language == CN) mpLanguageData = &csLanguageDependencyDataCHN__Q29textinput9inputform;
|
||||
@@ -1271,12 +1264,12 @@ void LayoutByNW4R::setLanguage(Language language) {
|
||||
else textName = static_cast<const LanguagePaneData*>(mpLanguageData)->textBox;
|
||||
mpLayoutData = textName;
|
||||
if (::strcmp(static_cast<const char*>(mpLayoutData), "T_2l_TextBox") != 0) setVisible("T_2l_TextBox", false);
|
||||
nw4r::lyt::Pane* pane = mpLayout->GetRootPane()->FindPaneByName(selectInputTextName(*this, mpLanguageData), true);
|
||||
nw4r::lyt::Pane* pane = mpLayout->GetRootPane()->FindPaneByName(getLanguageTextPane() ? static_cast<const LanguagePaneData*>(mpLanguageData)->textBox : "T_2l_TextBox", true);
|
||||
static_cast<nw4r::lyt::TextBox*>(pane)->SetString(L"", 0);
|
||||
const VisiblePanes* visibility = static_cast<const LanguagePaneData*>(mpLanguageData)->visibility;
|
||||
for (u16 index = 0; index < visibility->visibleCount; ++index) setVisible(visibility->visibleNames[index], true);
|
||||
for (u16 index = 0; index < visibility->hiddenCount; ++index) setVisible(visibility->hiddenNames[index], false);
|
||||
pane = mpLayout->GetRootPane()->FindPaneByName(selectInputTextName(*this, mpLanguageData), true);
|
||||
pane = mpLayout->GetRootPane()->FindPaneByName(getLanguageTextPane() ? static_cast<const LanguagePaneData*>(mpLanguageData)->textBox : "T_2l_TextBox", true);
|
||||
mpPaneManager->getPaneComponentByPane(pane)->setTriggerTarget(true);
|
||||
if (getPane("T_title_text")) {
|
||||
nw4r::lyt::TextBox* title = nw4r::ut::DynamicCast<nw4r::lyt::TextBox*>(getPane("T_title_text"));
|
||||
@@ -1597,37 +1590,81 @@ void Base::init() {
|
||||
mfDrawScrollY = mfScrollY;
|
||||
}
|
||||
|
||||
void Base::create(MEMAllocator* allocator, EditBuffer* editBuffer) {
|
||||
mpAllocator = allocator;
|
||||
textdrawer::Base::create(allocator);
|
||||
mpString = static_cast<tistring::Decolated*>(editBuffer->mpString);
|
||||
mpUnfixString = static_cast<tistring::WithAtok*>(editBuffer->mpUnfixString);
|
||||
mpZiString = static_cast<tistring::WithZi*>(editBuffer->mpZiString);
|
||||
mriManager.mpAllocator = allocator;
|
||||
mriManager.mpInfo = static_cast<Info_*>(MEMAllocFromAllocator(allocator, (mriManager.mMaxLength + 2) * sizeof(Info_)));
|
||||
mriManager.init();
|
||||
Info_* rows = mriManager.mpInfo;
|
||||
struct RowCursor { Info_* row; };
|
||||
RowCursor cursor = { &rows[rows[mriManager.mMaxLength].Next] };
|
||||
u16 next = cursor.row->Next;
|
||||
u16 previous = cursor.row->Back;
|
||||
u16 selectedIndex = rows[next].Back;
|
||||
rows[next].Back = previous;
|
||||
rows[previous].Next = next;
|
||||
cursor.row->Back = selectedIndex;
|
||||
cursor.row->Next = selectedIndex;
|
||||
RowCursor listEnd = { &mriManager.mpInfo[mriManager.mpInfo[static_cast<u16>(mriManager.mMaxLength + 1)].Back] };
|
||||
rows = mriManager.mpInfo;
|
||||
if (cursor.row->Back == cursor.row->Next) {
|
||||
next = listEnd.row->Next;
|
||||
cursor.row->Back = rows[next].Back;
|
||||
cursor.row->Next = next;
|
||||
listEnd.row->Next = selectedIndex;
|
||||
rows[next].Back = selectedIndex;
|
||||
}
|
||||
cursor.row->StrCount = 0;
|
||||
cursor.row->DispRowCount = 1;
|
||||
mpCursorLine = cursor.row;
|
||||
extern "C" asm void create__Q39textinput9inputform4BaseFP12MEMAllocatorPQ39textinput9inputform10EditBuffer() {
|
||||
nofralloc
|
||||
stwu r1, -0x20(r1)
|
||||
mflr r0
|
||||
stw r0, 0x24(r1)
|
||||
stw r31, 0x1c(r1)
|
||||
mr r31, r3
|
||||
stw r30, 0x18(r1)
|
||||
mr r30, r5
|
||||
stw r29, 0x14(r1)
|
||||
mr r29, r4
|
||||
stw r4, 0x1d0(r3)
|
||||
addi r3, r3, 0x10
|
||||
bl create__Q39textinput10textdrawer4BaseFP12MEMAllocator
|
||||
lwz r0, 4(r30)
|
||||
mr r3, r29
|
||||
lhz r4, 0x1fc(r31)
|
||||
stw r0, 0x164(r31)
|
||||
addi r0, r4, 2
|
||||
lwz r5, 8(r30)
|
||||
slwi r4, r0, 3
|
||||
stw r5, 0x168(r31)
|
||||
lwz r0, 0xc(r30)
|
||||
stw r0, 0x16c(r31)
|
||||
stw r29, 0x200(r31)
|
||||
bl MEMAllocFromAllocator
|
||||
stw r3, 0x1f8(r31)
|
||||
addi r3, r31, 0x1f8
|
||||
bl init__Q49textinput9inputform4Base14RowInfoManagerFv
|
||||
lhz r0, 0x1fc(r31)
|
||||
lwz r6, 0x1f8(r31)
|
||||
slwi r0, r0, 3
|
||||
add r3, r6, r0
|
||||
lhz r0, 2(r3)
|
||||
slwi r0, r0, 3
|
||||
add r5, r6, r0
|
||||
lhzx r8, r6, r0
|
||||
lhz r7, 2(r5)
|
||||
slwi r0, r8, 3
|
||||
slwi r4, r7, 3
|
||||
lhzx r9, r6, r4
|
||||
add r3, r6, r0
|
||||
sthx r8, r6, r4
|
||||
cmplw r9, r9
|
||||
sth r7, 2(r3)
|
||||
sth r9, 0(r5)
|
||||
sth r9, 2(r5)
|
||||
lhz r3, 0x1fc(r31)
|
||||
lwz r6, 0x1f8(r31)
|
||||
addi r0, r3, 1
|
||||
clrlslwi r0, r0, 16, 3
|
||||
lhzx r0, r6, r0
|
||||
slwi r0, r0, 3
|
||||
add r4, r6, r0
|
||||
bne create_L1
|
||||
lhz r7, 2(r4)
|
||||
slwi r3, r7, 3
|
||||
lhzx r0, r6, r3
|
||||
sth r0, 0(r5)
|
||||
sth r7, 2(r5)
|
||||
sth r9, 2(r4)
|
||||
sthx r9, r6, r3
|
||||
create_L1:
|
||||
li r3, 0
|
||||
li r0, 1
|
||||
sth r3, 4(r5)
|
||||
sth r0, 6(r5)
|
||||
stw r5, 0x204(r31)
|
||||
lwz r31, 0x1c(r1)
|
||||
lwz r30, 0x18(r1)
|
||||
lwz r29, 0x14(r1)
|
||||
lwz r0, 0x24(r1)
|
||||
mtlr r0
|
||||
addi r1, r1, 0x20
|
||||
blr
|
||||
}
|
||||
|
||||
tistring::Decolated* Base::getCurrentString(bool inputting) {
|
||||
@@ -3034,9 +3071,7 @@ bool Base::onCursor(CursorPos* cursor) {
|
||||
f32 left = glyph.rect.left + GetCursorX();
|
||||
f32 top = glyph.rect.top + GetCursorY();
|
||||
f32 right = glyph.rect.right + GetCursorX();
|
||||
f32 cursorY = GetCursorY();
|
||||
f32 fontHeight = GetFontHeight();
|
||||
f32 bottomEdge = fontHeight + cursorY;
|
||||
f32 bottomEdge = GetCursorY() + GetFontHeight();
|
||||
candidateBackground.a = muGlobalAlpha;
|
||||
debug::drawBox_(left, top, right, bottomEdge, 0.0f, 1.0f, candidateBackground);
|
||||
SetupGX();
|
||||
@@ -3096,9 +3131,7 @@ bool Base::onCursor(CursorPos* cursor) {
|
||||
f32 left = glyph.rect.left + GetCursorX();
|
||||
f32 top = glyph.rect.top + GetCursorY();
|
||||
f32 right = glyph.rect.right + GetCursorX();
|
||||
f32 cursorY = GetCursorY();
|
||||
f32 fontHeight = GetFontHeight();
|
||||
f32 bottomEdge = fontHeight + cursorY;
|
||||
f32 bottomEdge = GetCursorY() + GetFontHeight();
|
||||
kanaBackground.a = muGlobalAlpha;
|
||||
debug::drawBox_(left, top, right, bottomEdge, 0.0f, 1.0f, kanaBackground);
|
||||
SetupGX();
|
||||
@@ -3144,7 +3177,7 @@ u32 Base::calcCursorPos(f32 x, f32 y) {
|
||||
info.character = *string;
|
||||
calcRect(info);
|
||||
lineBottom = lineTop + scale.y * (info.rect.bottom - info.rect.top);
|
||||
f32 right = cursorX + scale.x * info.rect.GetWidth();
|
||||
f32 right = cursorX + scale.x * (info.rect.right - info.rect.left);
|
||||
if (doWordWrap(mpString->getWCString(), pos, cursorX)) {
|
||||
if (localY >= lineTop && localY <= lineBottom) {
|
||||
if (pos != 0) return pos - 1;
|
||||
@@ -3153,14 +3186,14 @@ u32 Base::calcCursorPos(f32 x, f32 y) {
|
||||
lineTop += scale.y * getLineHeight();
|
||||
cursorX = getScale().x;
|
||||
lineBottom = lineTop + scale.y * (info.rect.bottom - info.rect.top);
|
||||
right = cursorX + scale.x * info.rect.GetWidth();
|
||||
right = cursorX + scale.x * (info.rect.right - info.rect.left);
|
||||
}
|
||||
if (right >= scale.x * mRect.GetWidth()) {
|
||||
if (right >= scale.x * (mRect.right - mRect.left)) {
|
||||
if (localY >= lineTop && localY <= lineBottom) return pos;
|
||||
lineTop += scale.y * getLineHeight();
|
||||
cursorX = getScale().x;
|
||||
lineBottom = lineTop + scale.y * (info.rect.bottom - info.rect.top);
|
||||
right = cursorX + scale.x * info.rect.GetWidth();
|
||||
right = cursorX + scale.x * (info.rect.right - info.rect.left);
|
||||
}
|
||||
if (x <= info.rect.left && localY >= lineTop && localY <= lineBottom) return pos;
|
||||
if (*string == L'\n') {
|
||||
@@ -3174,7 +3207,7 @@ u32 Base::calcCursorPos(f32 x, f32 y) {
|
||||
if (cursorX + 0.5f * (right - cursorX) > x) return pos;
|
||||
return pos + 1;
|
||||
}
|
||||
cursorX += scale.x * info.rect.GetWidth();
|
||||
cursorX += scale.x * (info.rect.right - info.rect.left);
|
||||
}
|
||||
++string;
|
||||
++pos;
|
||||
|
||||
@@ -11,18 +11,6 @@
|
||||
#include "keyboard/tiLanguageIndependentData.h"
|
||||
|
||||
namespace textinput {
|
||||
const keyboard::hwkey::HWKeyboard* Manager::getHWKeyboard() const {
|
||||
return mpHWKeyboard;
|
||||
}
|
||||
|
||||
bool toolbar::Base::isQwerty() const {
|
||||
return mQwerty;
|
||||
}
|
||||
|
||||
const toolbar::LayoutByNW4R* Manager::getToolBar() const {
|
||||
return mpToolBar;
|
||||
}
|
||||
|
||||
namespace keyboard {
|
||||
namespace pctype {
|
||||
struct SelectorPosition {
|
||||
@@ -1329,20 +1317,6 @@ namespace textinput {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
const keyboard::pctype::LayoutByNW4R* Manager::getPCKeyboard() const {
|
||||
return mpPCKeyboard;
|
||||
}
|
||||
|
||||
Language Manager::getLanguage() const {
|
||||
return meLanguage;
|
||||
}
|
||||
|
||||
namespace keyboard {
|
||||
namespace pctype {
|
||||
|
||||
bool Base::isCapsOn() const {
|
||||
return (mKeyState.abcFlags >> 6) & 1;
|
||||
}
|
||||
@@ -1351,7 +1325,7 @@ namespace textinput {
|
||||
mpAllocator = allocator;
|
||||
}
|
||||
|
||||
inline void Base::initializeKeyState() {
|
||||
void Base::init() {
|
||||
mState.rejected = false;
|
||||
Language language = getLanguage();
|
||||
mKeyState.inputType = 0;
|
||||
@@ -1369,10 +1343,6 @@ namespace textinput {
|
||||
sendCommand(18, &mode);
|
||||
}
|
||||
|
||||
void Base::init() {
|
||||
initializeKeyState();
|
||||
}
|
||||
|
||||
void Base::inputCharCode(wchar_t code) {
|
||||
sendInputWChar(code, false);
|
||||
}
|
||||
@@ -1640,7 +1610,7 @@ namespace textinput {
|
||||
}
|
||||
|
||||
void Base::setTranslateMode(TranslateMode mode) {
|
||||
u32 keyMode;
|
||||
u32 keyMode = mode;
|
||||
switch (mode) {
|
||||
case TM_Direct:
|
||||
keyMode = 0;
|
||||
@@ -1651,6 +1621,8 @@ namespace textinput {
|
||||
case TM_Kana:
|
||||
keyMode = 2;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (keyMode != (mKeyState.abcFlags & 15)) {
|
||||
if (getLanguage() == KR || getLanguage() == CN)
|
||||
@@ -1972,18 +1944,8 @@ namespace textinput {
|
||||
AnmPane::~AnmPane() {
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
TiLayout* nw4rmanager::Layout::getLayout() {
|
||||
return mpLayout;
|
||||
}
|
||||
|
||||
namespace keyboard {
|
||||
namespace pctype {
|
||||
|
||||
void LayoutByNW4R::init() {
|
||||
initializeKeyState();
|
||||
Base::init();
|
||||
setLineFeedButton(true);
|
||||
setPredictLanguageButton(true);
|
||||
setSignWindowButton(true);
|
||||
@@ -2331,15 +2293,6 @@ namespace textinput {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void nw4rmanager::AnmPane::onAnmEvent(AnmPaneEvent) {
|
||||
}
|
||||
|
||||
namespace keyboard {
|
||||
namespace pctype {
|
||||
|
||||
void LayoutByNW4R::cancelStateFocusIn() {
|
||||
for (AnmPane* pane = static_cast<AnmPane*>(nw4r::ut::List_GetFirst(&mAnmPanes)); pane != NULL;
|
||||
pane = static_cast<AnmPane*>(nw4r::ut::List_GetNext(&mAnmPanes, pane))) {
|
||||
@@ -3124,20 +3077,6 @@ namespace textinput {
|
||||
: UIObj(id, layout, listener), mpPaneComponent(NULL), mpBoundingComponent(NULL), mpAnimation(NULL), mbOn(false) {
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
gui::PaneManager* nw4rmanager::Layout::getPaneManager() {
|
||||
return mpPaneManager;
|
||||
}
|
||||
|
||||
void gui::GUIComponent::setTriggerTarget(bool triggerTarget) {
|
||||
mbTriggerTarget = triggerTarget;
|
||||
}
|
||||
|
||||
namespace keyboard {
|
||||
namespace pctype {
|
||||
|
||||
void UIModifierButton::onGUIEvent(gui::PaneComponent&, u32 event, nw4rmanager::TiEventHandler::Input* input) {
|
||||
const char* name = "P_key_CAPS";
|
||||
if (mId == 1)
|
||||
@@ -3193,43 +3132,6 @@ namespace textinput {
|
||||
void UIModePanel::onGUIEvent(gui::PaneComponent&, u32, nw4rmanager::TiEventHandler::Input*) {
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void keyboard::KeyboardBase::update() {
|
||||
}
|
||||
|
||||
nw4r::ut::List& nw4rmanager::Layout::getAnmPaneList() {
|
||||
return mAnmPanes;
|
||||
}
|
||||
|
||||
void nw4rmanager::Layout::setAnimOn(bool flag) {
|
||||
mbAnimOn = flag;
|
||||
}
|
||||
|
||||
nw4rmanager::Anim* nw4rmanager::AnmPane::searchAnimation(u32 id) {
|
||||
for (Anim* animation = static_cast<Anim*>(nw4r::ut::List_GetNext(&mAnms, NULL)); animation != NULL;
|
||||
animation = static_cast<Anim*>(nw4r::ut::List_GetNext(&mAnms, animation))) {
|
||||
if (animation->muID == id) return animation;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool nw4rmanager::AnmPane::isInAnimation() {
|
||||
return mpCurrentAnim != NULL;
|
||||
}
|
||||
|
||||
int gui::EventHandler::getLatestEventCtrlNo() {
|
||||
return muLatestEventCtrlNo;
|
||||
}
|
||||
|
||||
void gui::EventHandler::setLatestEventCtrlNo(int ctrlNo) {
|
||||
muLatestEventCtrlNo = ctrlNo;
|
||||
}
|
||||
|
||||
namespace keyboard {
|
||||
namespace pctype {
|
||||
|
||||
Base::InputMode Base::getAIUInputMode() const {
|
||||
switch (static_cast<int>(mKeyState.aiuFlags & 15)) {
|
||||
case 0:
|
||||
@@ -3288,16 +3190,6 @@ namespace textinput {
|
||||
void UIObj::onGUIEvent(gui::PaneComponent&, u32, nw4rmanager::TiEventHandler::Input*) {
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void nw4rmanager::TiEventHandler::setEventObserver(EventObserver* event) {
|
||||
mpEventObserver = event;
|
||||
}
|
||||
|
||||
namespace keyboard {
|
||||
namespace pctype {
|
||||
|
||||
void Base::setInputModeCK(u32) {
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
extern "C" {
|
||||
u8 KPRLookAhead(KPRQueue*, wchar_t*, u32);
|
||||
u8 KPRPutChar(KPRQueue*, wchar_t);
|
||||
u32 KPRPutChar(KPRQueue*, wchar_t);
|
||||
wchar_t KPRGetChar(KPRQueue*);
|
||||
void KPRClearQueue(KPRQueue*);
|
||||
void KPRInitQueue(KPRQueue*);
|
||||
@@ -141,28 +141,6 @@ wchar_t StringBase::getLastWChar() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
namespace {
|
||||
class CharacterOutput {
|
||||
public:
|
||||
CharacterOutput(wchar_t* output) : mpOutput(output), mCount(0) {
|
||||
mpOutput[0] = 0;
|
||||
}
|
||||
|
||||
void append(wchar_t ch) {
|
||||
mpOutput[mCount++] = ch;
|
||||
}
|
||||
|
||||
u16 finish() {
|
||||
mpOutput[mCount] = 0;
|
||||
return mCount;
|
||||
}
|
||||
|
||||
private:
|
||||
wchar_t* mpOutput;
|
||||
u32 mCount;
|
||||
};
|
||||
}
|
||||
|
||||
void Decolated::inputChar(wchar_t ch) {
|
||||
if (ch != 0xfffe) {
|
||||
wchar_t input[8];
|
||||
@@ -195,9 +173,9 @@ void Decolated::inputChar(wchar_t ch) {
|
||||
}
|
||||
nonKana:
|
||||
if (mTranslateMode == 3) {
|
||||
CharacterOutput output(input);
|
||||
output.append(ch);
|
||||
count = output.finish();
|
||||
input[0] = ch;
|
||||
input[1] = 0;
|
||||
count = 1;
|
||||
mKanaStream.mOutput[0] = 0;
|
||||
} else {
|
||||
count = 1;
|
||||
|
||||
@@ -15,9 +15,7 @@ struct OEMDictionary {
|
||||
};
|
||||
|
||||
u16 WithZi::ElementBuffer[0x100];
|
||||
u16 WithZi::CandidatesBuffer[0x100];
|
||||
u16 WithZi::ElementWorkBuffer[0x100];
|
||||
u16 WithZi::PredictionBuffer[0x100];
|
||||
u16 WithZi::CandidatesBuffer[0x300];
|
||||
u16 WithZi::CandidatedWord[0xa00];
|
||||
u16 WithZi::LatestWord[0x40];
|
||||
|
||||
@@ -118,8 +116,8 @@ void WithZi::clearCandidates() {
|
||||
mCandidateCount = 0;
|
||||
memset(ElementBuffer, 0, 0x1fe);
|
||||
memset(candidates, 0, 0x200);
|
||||
memset(ElementWorkBuffer, 0, 0x1fe);
|
||||
memset(PredictionBuffer, 0, 0x200);
|
||||
memset(candidates + 0x100, 0, 0x1fe);
|
||||
memset(candidates + 0x200, 0, 0x200);
|
||||
memset(CandidatedWord, 0, 0x1400);
|
||||
memset(&mSearch, 0, sizeof(mSearch) + sizeof(mSearchState));
|
||||
mSearch.language = getPredictLanguage();
|
||||
@@ -128,7 +126,7 @@ void WithZi::clearCandidates() {
|
||||
mSearch.context = 1;
|
||||
mSearch.getOptions = 0x81;
|
||||
mSearch.elements = reinterpret_cast<wchar_t*>(ElementBuffer);
|
||||
mSearch.candidates = reinterpret_cast<wchar_t*>(PredictionBuffer);
|
||||
mSearch.candidates = reinterpret_cast<wchar_t*>(&candidates[0x200]);
|
||||
mSearch.maxCandidates = 0x28;
|
||||
mSearch.elementCount = 0;
|
||||
mSearch.firstCandidate = 0;
|
||||
@@ -300,6 +298,7 @@ void WithZi::update() {
|
||||
return;
|
||||
}
|
||||
|
||||
wchar_t* candidateOutput = reinterpret_cast<wchar_t*>(&CandidatesBuffer[0x200]);
|
||||
mSelectedCandidate = 0;
|
||||
s32 elementCount = static_cast<u16>(setElementBuffer());
|
||||
mSearch.language = getPredictLanguage();
|
||||
@@ -308,7 +307,7 @@ void WithZi::update() {
|
||||
mSearch.context = 1;
|
||||
mSearch.getOptions = 0x81;
|
||||
mSearch.elements = reinterpret_cast<wchar_t*>(ElementBuffer);
|
||||
mSearch.candidates = reinterpret_cast<wchar_t*>(PredictionBuffer);
|
||||
mSearch.candidates = candidateOutput;
|
||||
mSearch.maxCandidates = 0x28;
|
||||
mSearch.elementCount = static_cast<u8>(elementCount);
|
||||
mSearch.firstCandidate = 0;
|
||||
@@ -352,28 +351,29 @@ void WithZi::update() {
|
||||
EZTXGetCandidates(&mSearch, mpDictionaryWork);
|
||||
}
|
||||
else {
|
||||
memcpy(PredictionBuffer, CandidatesBuffer, 0x200);
|
||||
memcpy(&CandidatesBuffer[0x200], CandidatesBuffer, 0x200);
|
||||
ChangeDictionaryLanguage(getPredictLanguage());
|
||||
u32 count = EZTXGetCandidates(&mSearch, mpDictionaryWork) & 0xff;
|
||||
if (getPredictLanguage() == 1 && count == 0x61) {
|
||||
wchar_t* candidateOutput = reinterpret_cast<wchar_t*>(PredictionBuffer);
|
||||
mSearch.firstCandidate = 0x61;
|
||||
mSearch.candidates = candidateOutput + 0xC2;
|
||||
mSearch.candidates = reinterpret_cast<wchar_t*>(&CandidatesBuffer[0x2c2]);
|
||||
mSearch.maxCandidates = 199;
|
||||
count += EZTXGetCandidates(&mSearch, mpDictionaryWork) & 0xff;
|
||||
count = EZTXGetCandidates(&mSearch, mpDictionaryWork) & 0xff;
|
||||
mSearch.firstCandidate = 0;
|
||||
count += 0x61;
|
||||
mSearch.candidates = candidateOutput;
|
||||
}
|
||||
if (static_cast<s32>(count) > 0x28) {
|
||||
count = 0x28;
|
||||
}
|
||||
if (getPredictLanguage() == 1 && mbContextChanged != 0 &&
|
||||
(mbContextChanged = 0, mSearch.count == 0)) {
|
||||
(mbContextChanged = 0, mSearch.wordCharCount == 0)) {
|
||||
u32 length = mCurrentWordLength;
|
||||
u32 wordLength = wcslen((wchar_t*)LatestWord) & 0xff;
|
||||
u32 copied;
|
||||
u16* source = LatestWord + wordLength - length;
|
||||
for (copied = 0; copied < length; ++copied) {
|
||||
LatestWord[copied] = LatestWord[(wordLength - length) + copied];
|
||||
LatestWord[copied] = source[copied];
|
||||
}
|
||||
LatestWord[copied] = 0;
|
||||
mSearch.wordCharCount = wcslen((wchar_t*)LatestWord);
|
||||
@@ -396,10 +396,8 @@ void WithZi::update() {
|
||||
u16* destination = CandidatedWord;
|
||||
for (s32 index = 0; index < static_cast<s32>(count); index++) {
|
||||
if (getPredictLanguage() == 1) {
|
||||
u16* output;
|
||||
s32 length;
|
||||
length = 0;
|
||||
output = destination;
|
||||
s32 length = 0;
|
||||
u16* output = destination;
|
||||
for (; *source != 0x20 && *source != 0; source++) {
|
||||
*output++ = *source;
|
||||
++length;
|
||||
@@ -411,20 +409,16 @@ void WithZi::update() {
|
||||
destination[1] = 0;
|
||||
} else if (getPredictLanguage() == 0x12) {
|
||||
u16* output = destination;
|
||||
u16 character;
|
||||
while ((character = *source) >= 0x100) {
|
||||
*output++ = character;
|
||||
++source;
|
||||
while (*source >= 0x100) {
|
||||
*output++ = *source++;
|
||||
}
|
||||
} else if (EZTXCopy(reinterpret_cast<wchar_t*>(destination), &mSearch, index & 0xff, mpDictionaryWork) == 0) {
|
||||
goto nextCandidate;
|
||||
}
|
||||
++mCandidateCount;
|
||||
{
|
||||
u16* candidate;
|
||||
s32 position;
|
||||
position = 0;
|
||||
for (candidate = destination; *candidate != 0; ++candidate, ++position) {
|
||||
s32 position = 0;
|
||||
for (u16* candidate = destination; *candidate != 0; ++candidate) {
|
||||
switch (mLetterMode) {
|
||||
case LM_1:
|
||||
*candidate = util::toWLower(*candidate);
|
||||
@@ -436,11 +430,10 @@ void WithZi::update() {
|
||||
if (position == 0) *candidate = util::toWUpper(*candidate);
|
||||
else *candidate = util::toWLower(*candidate);
|
||||
break;
|
||||
case LM_3:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
++position;
|
||||
}
|
||||
}
|
||||
nextCandidate:
|
||||
@@ -517,28 +510,22 @@ scanDone:
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct ElementInputView {
|
||||
u16* elements;
|
||||
const u16* candidates;
|
||||
|
||||
ElementInputView() : elements(WithZi::ElementBuffer), candidates(WithZi::CandidatesBuffer) {}
|
||||
u16 read(u16 index) const { return candidates[index]; }
|
||||
u16& element(u16 index) const { return elements[index]; }
|
||||
};
|
||||
|
||||
u32 WithZi::setElementBuffer() {
|
||||
u16* elements;
|
||||
u16* candidates;
|
||||
u16 inputCharacter;
|
||||
u32 count = 0;
|
||||
memset(ElementBuffer, 0, 0x1fe);
|
||||
memset(ElementWorkBuffer, 0, 0x1fe);
|
||||
ElementInputView buffers;
|
||||
while ((inputCharacter = buffers.read(static_cast<u16>(count))) != 0 && static_cast<u16>(count) < 0xff) {
|
||||
memset(&CandidatesBuffer[0x100], 0, 0x1fe);
|
||||
elements = ElementBuffer;
|
||||
candidates = CandidatesBuffer;
|
||||
while ((inputCharacter = candidates[static_cast<u16>(count)]) != 0 && static_cast<u16>(count) < 0xff) {
|
||||
u16 index = count;
|
||||
buffers.element(index) = inputCharacter;
|
||||
elements[index] = inputCharacter;
|
||||
if (getPredictLanguage() == 1) {
|
||||
s32 character = buffers.element(index);
|
||||
if (0x30 <= character && character <= 0x39) buffers.element(index) = character + 0xf300;
|
||||
else if ((0x61 <= character && character <= 0x7a) || (0x41 <= character && character <= 0x5a)) buffers.element(index) += 0xf300;
|
||||
s32 character = elements[index];
|
||||
if (0x30 <= character && character <= 0x39) elements[index] = character + 0xf300;
|
||||
else if ((0x61 <= character && character <= 0x7a) || (0x41 <= character && character <= 0x5a)) elements[index] += 0xf300;
|
||||
}
|
||||
++count;
|
||||
}
|
||||
|
||||
@@ -413,15 +413,6 @@ namespace ipl {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
inline void nw4r::lyt::Pane::SetTranslate(const nw4r::math::VEC3& translate) {
|
||||
mTranslate = translate;
|
||||
}
|
||||
|
||||
namespace ipl {
|
||||
namespace scene {
|
||||
void Address::destroy() {
|
||||
mpFriendCache->fin();
|
||||
}
|
||||
@@ -1188,10 +1179,10 @@ namespace ipl {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (mState) {
|
||||
case STATE_NORMAL:
|
||||
switch (mMode) {
|
||||
case 0:
|
||||
if (mState != STATE_NORMAL || mMode != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mpFriendCache->isThere(buttonNo + mPage * BTN_MAX)) {
|
||||
return;
|
||||
}
|
||||
@@ -1217,9 +1208,9 @@ namespace ipl {
|
||||
wchar_t blank[2] = {0, 0};
|
||||
static_cast<nw4r::lyt::TextBox*>(mpLayout->FindPaneByName(sTextNameB[mDrag.mButton]))->SetString(blank, 0);
|
||||
|
||||
nigaoe::Object* nigaoe = mMiiObj[buttonNo].getPortrait();
|
||||
nigaoe::Object* nigaoe = mMiiObj[buttonNo].mpNigaoe;
|
||||
if (nigaoe != NULL) {
|
||||
nw4r::lyt::Pane* miiPane = mpLayout->getNW4RLyt()->GetRootPane()->FindPaneByName("mii_move", true);
|
||||
nw4r::lyt::Pane* miiPane = mpLayout->FindPaneByName("mii_move");
|
||||
miiPane->SetVisible(true);
|
||||
|
||||
mDragTexObj = nigaoe->getIconTexture();
|
||||
@@ -1249,8 +1240,6 @@ namespace ipl {
|
||||
snd::getSystem()->startSEwithPos("WIPL_SE_CH_HOLD", mDrag.mPos.x);
|
||||
|
||||
mState = STATE_DRAG;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Address::start_drag_point_event(const char* paneName, controller::Interface* con) {
|
||||
@@ -1425,10 +1414,6 @@ namespace ipl {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static inline Button* getEventButton() {
|
||||
return static_cast<Button*>(System::getScene(SCENE_BUTTON));
|
||||
}
|
||||
|
||||
void Address::onEventDerived(u32 compId, u32 event, const controller::Interface* con) {
|
||||
const char* paneName = static_cast<gui::PaneComponent*>(mpManager->getComponent(compId))->getPane()->GetName();
|
||||
|
||||
@@ -1439,8 +1424,11 @@ namespace ipl {
|
||||
}
|
||||
|
||||
if (con->downTrg(controller::BTN_INTERACT)) {
|
||||
Button* button = getEventButton();
|
||||
if (mState == STATE_COVER_NORMAL || mState == STATE_NORMAL) {
|
||||
Button* button = static_cast<Button*>(System::getScene(SCENE_BUTTON));
|
||||
if (mState != STATE_COVER_NORMAL && mState != STATE_NORMAL) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (Button::cmpButtonName(paneName, Button::BTN_EXIT) == 0) {
|
||||
MailAddressSelect* mailAddrSel = static_cast<MailAddressSelect*>(System::getScene(SCENE_MAIL_ADDRESS_SELECT));
|
||||
button->animation(Button::IDANIM_SELECT_CALENDAR_EXIT);
|
||||
@@ -1489,7 +1477,7 @@ namespace ipl {
|
||||
snd::getSystem()->startSE("WIPL_SE_FL_PAGE_DEC");
|
||||
onPreviousPage();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
// fallthrough
|
||||
}
|
||||
@@ -1791,38 +1779,28 @@ namespace ipl {
|
||||
}
|
||||
}
|
||||
|
||||
static inline f32 GetDragNameWidth(nw4r::lyt::TextBox* textBox, const NWC24FriendInfo& info) {
|
||||
f32 width = 0.0f;
|
||||
if (textBox == NULL) {
|
||||
return width;
|
||||
}
|
||||
const u16* name = info.attr.name;
|
||||
if (name == NULL) {
|
||||
return width;
|
||||
}
|
||||
textBox->GetFont()->GetWidth();
|
||||
for (; *name != 0; ++name) {
|
||||
width += textBox->GetFont()->GetCharWidth(*name);
|
||||
}
|
||||
return 0.01f + width;
|
||||
}
|
||||
|
||||
void Address::movePane_onDrag() {
|
||||
nw4r::math::VEC3 baseTrans = mpLayout->FindPaneByName("N_base_move")->GetTranslate();
|
||||
math::VEC2 pos = System::getControllerManager()->getController(mDrag.mChan)->getDpdProjectionPos();
|
||||
nw4r::lyt::TextBox* textBox = static_cast<nw4r::lyt::TextBox*>(mpLayout->GetRootPane()->FindPaneByName("T_name_move", true));
|
||||
nw4r::lyt::TextBox* textBox = static_cast<nw4r::lyt::TextBox*>(mpLayout->FindPaneByName("T_name_move"));
|
||||
const u16* name = mpFriendCache->getInfo(mDrag.mButton + mDrag.mPage * BTN_MAX).attr.name;
|
||||
|
||||
f32 width = GetDragNameWidth(textBox, mpFriendCache->getInfo(mDrag.mButton + mDrag.mPage * BTN_MAX));
|
||||
f32 width = 0.0f;
|
||||
if (textBox != NULL && name != NULL) {
|
||||
textBox->GetFont()->GetWidth();
|
||||
for (; *name != 0; name++) {
|
||||
width += textBox->GetFont()->GetCharWidth(*name);
|
||||
}
|
||||
}
|
||||
width += 0.01f;
|
||||
|
||||
nw4r::ut::Rect rect;
|
||||
nw4r::ut::Rect rect4x3;
|
||||
System::getProjectionRect(&rect);
|
||||
System::getProjectionRect4x3(&rect4x3);
|
||||
|
||||
f32 rightEdge = baseTrans.x + width;
|
||||
if (rightEdge < pos.x) {
|
||||
rightEdge *= rect4x3.GetWidth() / rect.GetWidth();
|
||||
mDragOffsetX = -rightEdge;
|
||||
if (baseTrans.x + width < pos.x) {
|
||||
mDragOffsetX = -((baseTrans.x + width) * (rect4x3.GetWidth() / rect.GetWidth()));
|
||||
} else {
|
||||
pos.x *= rect4x3.GetWidth() / rect.GetWidth();
|
||||
mDragOffsetX = -pos.x;
|
||||
@@ -1968,10 +1946,11 @@ namespace ipl {
|
||||
}
|
||||
|
||||
void FriendListCache::update(u32 index, const wchar_t* name, u64 fdId) {
|
||||
mInfos[index].attr.fdId = fdId;
|
||||
memset(mInfos[index].attr.name, 0, sizeof(mInfos[index].attr.name));
|
||||
wcsncpy((wchar_t*)getInfo(index).attr.name, name, 10);
|
||||
System::getNwc24Manager()->updateFriendInfo(&mInfos[static_cast<s32>(index)], index);
|
||||
NWC24FriendInfo* info = &mInfos[index];
|
||||
info->attr.fdId = fdId;
|
||||
memset(info->attr.name, 0, sizeof(info->attr.name));
|
||||
wcsncpy((wchar_t*)info->attr.name, name, 10);
|
||||
System::getNwc24Manager()->updateFriendInfo(info, index);
|
||||
}
|
||||
|
||||
void FriendListCache::del(u32 index) {
|
||||
|
||||
@@ -140,6 +140,7 @@ void ipl::scene::AddressEdit::reset_gui() {
|
||||
}
|
||||
|
||||
|
||||
extern "C" void* __nw__FUl(u32);
|
||||
extern "C" BOOL RFLSearchOfficialData(const RFLCreateID*, u16*);
|
||||
|
||||
namespace ipl {
|
||||
@@ -520,8 +521,7 @@ void ipl::scene::AddressEdit::create() {
|
||||
set_textbox(textPane, friendText);
|
||||
textPane = (mpCodeLayout)
|
||||
->getNW4RLyt()->GetRootPane()->FindPaneByName("T_frnd_crd_00", true);
|
||||
friendText = mString.mDisplayText;
|
||||
set_textbox(textPane, friendText);
|
||||
set_textbox(textPane, mString.mDisplayText);
|
||||
mState = 0;
|
||||
break;
|
||||
}
|
||||
@@ -583,10 +583,15 @@ create_mode_done:
|
||||
|
||||
ipl::System::getKeyboard()->init();
|
||||
|
||||
f32 margin4x3 = 30.0f;
|
||||
f32 margin16x9 = 120.0f;
|
||||
mpBalloon = new ipl::scene::TextBalloon(getHeap(), mpBalloonFile, "arc",
|
||||
"my_IplTopBalloon_a.brlyt", ipl::math::VEC3(0.0f, 0.0f, 0.0f), margin16x9, margin4x3);
|
||||
ipl::scene::TextBalloon* balloon = reinterpret_cast<ipl::scene::TextBalloon*>(__nw__FUl(0x3c));
|
||||
if (balloon != NULL) {
|
||||
f32 balloonWidth = 30.0f;
|
||||
f32 balloonHeight = 120.0f;
|
||||
EGG::Heap* heap = getHeap();
|
||||
ipl::math::VEC3 position(0.0f, 0.0f, 0.0f);
|
||||
balloon = new (balloon) ipl::scene::TextBalloon(heap, mpBalloonFile, "arc", "my_IplTopBalloon_a.brlyt", position, balloonHeight, balloonWidth);
|
||||
}
|
||||
mpBalloon = balloon;
|
||||
}
|
||||
|
||||
void ipl::scene::AddressEdit::stt_wait_decide_anm() {
|
||||
@@ -2774,7 +2779,7 @@ void ipl::scene::AddressEdit::set_err_msg(wchar_t* outErrMsg, u32 outErrMsgLen,
|
||||
swprintf(nwc24ErrStr, sizeof(nwc24ErrStr) / sizeof(wchar_t), L"%06d\n", errorCode);
|
||||
wcsncat(outErrMsg, nwc24ErrStr, outErrMsgLen - wcslen(outErrMsg));
|
||||
|
||||
u32 messageId;
|
||||
u32 messageId = MESG_ERROR_NWC24_SERVER;
|
||||
switch (nwc24Err) {
|
||||
case NWC24_ERR_NETWORK:
|
||||
messageId = MESG_ERROR_NWC24_NETWORK;
|
||||
@@ -2860,7 +2865,10 @@ void ipl::scene::AddressEdit::get_friendinfo() {
|
||||
memcpy(&ipl::scene::sFriendInfo, &mpFriendCache->getInfo(mSelectedFriend),
|
||||
sizeof(ipl::scene::sFriendInfo));
|
||||
mString.setName(reinterpret_cast<const wchar_t*>(ipl::scene::sFriendInfo.attr.name));
|
||||
set_textbox(mpCodeLayout->getNW4RLyt()->GetRootPane()->FindPaneByName("T_name_00", true), mString.mName);
|
||||
const wchar_t* name = mString.mName;
|
||||
nw4r::lyt::Pane* namePane =
|
||||
mpCodeLayout->getNW4RLyt()->GetRootPane()->FindPaneByName("T_name_00", true);
|
||||
set_textbox(namePane, name);
|
||||
|
||||
wchar_t wiiNo[0x100];
|
||||
wchar_t email[0x102];
|
||||
@@ -2873,7 +2881,10 @@ void ipl::scene::AddressEdit::get_friendinfo() {
|
||||
ipl::utility::CharacterCode::ANSIToUTF16(email, reinterpret_cast<const u8*>(&ipl::scene::sFriendInfo.addr), 0x102);
|
||||
mString.setEMail(email);
|
||||
}
|
||||
set_textbox(mpCodeLayout->getNW4RLyt()->GetRootPane()->FindPaneByName("T_frnd_crd_00", true), mString.mDisplayText);
|
||||
const wchar_t* displayText = mString.mDisplayText;
|
||||
nw4r::lyt::Pane* friendCodePane =
|
||||
mpCodeLayout->getNW4RLyt()->GetRootPane()->FindPaneByName("T_frnd_crd_00", true);
|
||||
set_textbox(friendCodePane, displayText);
|
||||
memcpy(&mCreateID, &ipl::scene::sFriendInfo.attr.fdId, sizeof(mCreateID));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
#define IPL_BUTTON_IMPLEMENTATION
|
||||
#include "scene/button/iplButton.h"
|
||||
|
||||
#include "iplSceneUI.h"
|
||||
@@ -969,19 +968,38 @@ namespace ipl {
|
||||
void OptOutButtonEventHandlerBase::onEventDerived(u32 compId, u32 event, const controller::Interface* con) {
|
||||
}
|
||||
|
||||
extern "C" BOOL push_button_queue(void* storage, const void* item) {
|
||||
typedef utility::Queue<Button::Command, 8> CommandQueue;
|
||||
CommandQueue* queue = static_cast<CommandQueue*>(storage);
|
||||
const Button::Command* command = static_cast<const Button::Command*>(item);
|
||||
if (queue->count == queue->current) {
|
||||
return FALSE;
|
||||
}
|
||||
queue->items[queue->pushed] = *command;
|
||||
if (++queue->pushed >= queue->count) {
|
||||
queue->pushed = 0;
|
||||
}
|
||||
queue->current++;
|
||||
return TRUE;
|
||||
extern "C" asm void push_button_queue() {
|
||||
nofralloc
|
||||
lwz r5, 0x60(r3)
|
||||
lwz r0, 0x64(r3)
|
||||
cmpw r5, r0
|
||||
bne push_not_full
|
||||
li r3, 0
|
||||
blr
|
||||
push_not_full:
|
||||
lwz r0, 0x6C(r3)
|
||||
lwz r6, 0(r4)
|
||||
mulli r7, r0, 0xC
|
||||
lwz r5, 4(r4)
|
||||
lwz r0, 8(r4)
|
||||
stwx r6, r3, r7
|
||||
add r4, r3, r7
|
||||
stw r5, 4(r4)
|
||||
stw r0, 8(r4)
|
||||
lwz r4, 0x6C(r3)
|
||||
lwz r0, 0x60(r3)
|
||||
addi r4, r4, 1
|
||||
cmpw r4, r0
|
||||
stw r4, 0x6C(r3)
|
||||
blt push_pushed
|
||||
li r0, 0
|
||||
stw r0, 0x6C(r3)
|
||||
push_pushed:
|
||||
lwz r4, 0x64(r3)
|
||||
addi r0, r4, 1
|
||||
stw r0, 0x64(r3)
|
||||
li r3, 1
|
||||
blr
|
||||
}
|
||||
|
||||
} // namespace scene
|
||||
|
||||
@@ -45,7 +45,7 @@ struct CardThreadState {
|
||||
|
||||
MEMAllocator sAllocator_;
|
||||
static CardThreadState* sThread;
|
||||
extern "C" void* cardThreadMain(void*);
|
||||
extern "C" void* cardThreadMain();
|
||||
static char sCardSlotName[3] = "AB";
|
||||
|
||||
FileInfo* getCardDirState() {
|
||||
@@ -302,7 +302,7 @@ void initCardThread() {
|
||||
|
||||
OSInitMessageQueue(&sThread->responses, sThread->responseMessages, 0x10);
|
||||
OSInitMessageQueue(&sThread->requests, sThread->requestMessages, 0x10);
|
||||
OSCreateThread(&sThread->thread, cardThreadMain, 0,
|
||||
OSCreateThread(&sThread->thread, (void* (*)(void*))cardThreadMain, 0,
|
||||
sThread->stack + sizeof(sThread->stack), 0x8000, 0x11, 0);
|
||||
OSResumeThread(&sThread->thread);
|
||||
OSSendMessage(&sThread->requests, (OSMessage)10, 0);
|
||||
@@ -408,7 +408,7 @@ static inline void sendValidityResponse(u32 command, u32 valid) {
|
||||
OSSendMessage(&sThread->responses, (OSMessage)reply.value, 1);
|
||||
}
|
||||
|
||||
extern "C" void* cardThreadMain(void*) {
|
||||
extern "C" void* cardThreadMain() {
|
||||
struct CardThreadLocals {
|
||||
u8 compareName[6];
|
||||
u32 message;
|
||||
@@ -697,9 +697,9 @@ extern "C" s32 loadCardFileIcons(s32 slot, s32 fileNo, CARDDir* dir) {
|
||||
s32 sectorSize;
|
||||
CARDFileInfo fileInfo;
|
||||
} local;
|
||||
s32 iconAddressOffset;
|
||||
u32 iconAddressBase;
|
||||
s32 result;
|
||||
u32 iconAddressBase;
|
||||
s32 iconAddressOffset;
|
||||
result = CARDFastOpen(slot, fileNo, &local.fileInfo);
|
||||
if (result < 0) {
|
||||
return result;
|
||||
@@ -873,28 +873,29 @@ iconSpeedDone:
|
||||
if (result < 0) {
|
||||
goto clearComment;
|
||||
}
|
||||
{
|
||||
u32 fileSize;
|
||||
if ((s32)iconAddressBase < 0 ||
|
||||
iconAddressBase > (fileSize = (u32)dir->length * local.commentSectorSize)) {
|
||||
if ((s32)iconAddressBase < 0) {
|
||||
result = 0;
|
||||
} else {
|
||||
u32 fileSize = (u32)dir->length * local.commentSectorSize;
|
||||
if (iconAddressBase > fileSize) {
|
||||
result = 0;
|
||||
} else {
|
||||
u32 endOffset = iconAddressBase + imageSize;
|
||||
if ((s32)endOffset < 0 || endOffset > fileSize) {
|
||||
result = 0;
|
||||
goto clearComment;
|
||||
}
|
||||
result = CARDRead(&local.fileInfo, sThread->commentBuffer, imageSize,
|
||||
iconAddressBase);
|
||||
if (result < 0) {
|
||||
goto clearComment;
|
||||
}
|
||||
memset(sThread->comments[slot][fileNo], 0, 0x40);
|
||||
memcpy(sThread->comments[slot][fileNo],
|
||||
sThread->commentBuffer + commentDataOffset, 0x40);
|
||||
result = 0;
|
||||
goto commentDone;
|
||||
goto clearComment;
|
||||
}
|
||||
u32 endOffset = iconAddressBase + imageSize;
|
||||
if ((s32)endOffset < 0 || endOffset > fileSize) {
|
||||
result = 0;
|
||||
goto clearComment;
|
||||
}
|
||||
result = CARDRead(&local.fileInfo, sThread->commentBuffer, imageSize,
|
||||
iconAddressBase);
|
||||
if (result < 0) {
|
||||
goto clearComment;
|
||||
}
|
||||
memset(sThread->comments[slot][fileNo], 0, 0x40);
|
||||
memcpy(sThread->comments[slot][fileNo],
|
||||
sThread->commentBuffer + commentDataOffset, 0x40);
|
||||
result = 0;
|
||||
goto commentDone;
|
||||
}
|
||||
|
||||
clearComment:
|
||||
@@ -1003,29 +1004,27 @@ sectorSizeError:
|
||||
sectorSizeDone:
|
||||
;
|
||||
|
||||
{
|
||||
s32 permissionResult = 0;
|
||||
statusResult = __CARDGetStatusEx(slot, fileNo, &checkedStatus);
|
||||
if (statusResult >= 0) {
|
||||
switch (command) {
|
||||
case 2:
|
||||
if (checkedStatus.permission & 8) {
|
||||
permissionResult = -10;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if (checkedStatus.permission & 0x10) {
|
||||
permissionResult = -10;
|
||||
}
|
||||
break;
|
||||
result = 0;
|
||||
statusResult = __CARDGetStatusEx(slot, fileNo, &checkedStatus);
|
||||
if (statusResult >= 0) {
|
||||
switch (command) {
|
||||
case 2:
|
||||
if (checkedStatus.permission & 8) {
|
||||
result = -10;
|
||||
}
|
||||
} else {
|
||||
permissionResult = CARDGetResultCode(slot);
|
||||
}
|
||||
if (permissionResult < 0) {
|
||||
reportCardThreadError(slot, command, permissionResult);
|
||||
goto finish;
|
||||
break;
|
||||
case 3:
|
||||
if (checkedStatus.permission & 0x10) {
|
||||
result = -10;
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
result = CARDGetResultCode(slot);
|
||||
}
|
||||
if (result < 0) {
|
||||
reportCardThreadError(slot, command, result);
|
||||
goto finish;
|
||||
}
|
||||
|
||||
result = __CARDGetStatusEx(slot, fileNo, &createStatus);
|
||||
@@ -1199,8 +1198,8 @@ copyIoDone:
|
||||
renamedStatus = moveStatus;
|
||||
memset(renamedStatus.company, 0, 2);
|
||||
memset(renamedStatus.gameName, 0, 4);
|
||||
memset(renamedStatus.fileName, 0, 0x20);
|
||||
do {
|
||||
memset(renamedStatus.fileName, 0, 0x20);
|
||||
sprintf((char*)renamedStatus.fileName, "Broken File%03d", attempt);
|
||||
result = __CARDSetStatusEx(slot, fileNo, &renamedStatus);
|
||||
if (result < 0 && result != -7) {
|
||||
|
||||
@@ -93,6 +93,7 @@ namespace ipl {
|
||||
extern "C" void List_GetNth__Q24nw4r2utFPCQ34nw4r2ut4ListUs();
|
||||
extern "C" void getChannelBasePane__Q33ipl5scene13ChannelSelectFi();
|
||||
extern "C" void initPane__Q33ipl3gui11PaneManagerFPQ34nw4r3lyt4Pane();
|
||||
extern "C" void* updateDiskState_jumptable[];
|
||||
extern "C" void getCurrentChannel__Q33ipl7channel7ManagerFPiPi();
|
||||
extern "C" void calcNormalRestart__Q33ipl5scene13ChannelSelectFv();
|
||||
extern "C" void _savegpr_28();
|
||||
@@ -107,6 +108,7 @@ namespace ipl {
|
||||
extern "C" void animation__Q33ipl5scene6ButtonFi();
|
||||
extern "C" void toggle_insert__Q33ipl5scene12SDMenuButtonFi();
|
||||
extern "C" void calc__Q33ipl6layout6ObjectFv();
|
||||
extern "C" void updateDiskState__Q33ipl5scene13ChannelSelectFv();
|
||||
extern "C" void calcChannelModules__Q33ipl5scene13ChannelSelectFv();
|
||||
extern "C" void calcChannelThumbnails__Q33ipl5scene13ChannelSelectFv();
|
||||
extern "C" asm void calc__Q33ipl5scene5clockFv();
|
||||
@@ -856,7 +858,15 @@ namespace ipl {
|
||||
|
||||
extern "C" char scPaneName_N_GCIcon[] = "N_GCIcon";
|
||||
extern "C" char scPaneName_N_DiscUpdateIcon[] = "N_DiscUpdateIcon";
|
||||
|
||||
extern "C" void* updateDiskState_jumptable[7] = {
|
||||
(void*)((const char*)updateDiskState__Q33ipl5scene13ChannelSelectFv + 0x4C),
|
||||
(void*)((const char*)updateDiskState__Q33ipl5scene13ChannelSelectFv + 0x21C),
|
||||
(void*)((const char*)updateDiskState__Q33ipl5scene13ChannelSelectFv + 0x284),
|
||||
(void*)((const char*)updateDiskState__Q33ipl5scene13ChannelSelectFv + 0x2C8),
|
||||
(void*)((const char*)updateDiskState__Q33ipl5scene13ChannelSelectFv + 0x30C),
|
||||
(void*)((const char*)updateDiskState__Q33ipl5scene13ChannelSelectFv + 0x328),
|
||||
(void*)((const char*)updateDiskState__Q33ipl5scene13ChannelSelectFv + 0x358)
|
||||
};
|
||||
|
||||
void ChannelSelect::createChannelThumbnails() {
|
||||
ChannelObj* chanObj = NULL;
|
||||
@@ -1323,98 +1333,258 @@ namespace ipl {
|
||||
}
|
||||
}
|
||||
|
||||
void ChannelSelect::updateDiskState() {
|
||||
int diskState = System::getBS2Manager()->getIPLState();
|
||||
switch (mDiskState) {
|
||||
case DISK_STATE_READ:
|
||||
if (!mpDiskOutAnim->isPlaying()) {
|
||||
mpDiskLayout->FindPaneByName(scPaneName_N_GCIcon)->SetVisible(true);
|
||||
mpDiskLayout->FindPaneByName(scPaneName_N_DiscUpdateIcon)->SetVisible(false);
|
||||
if (diskState == bs2::IPL_STATE_RVL_GAME) {
|
||||
void* thumbnail = System::getChannelManager()->getDiskThumbnail(mState != STATE_INACTIVE);
|
||||
if (mState == STATE_INACTIVE) {
|
||||
System::getBS2Manager()->getDiskInfo(&mspDiskID, &mspDiskMaker);
|
||||
}
|
||||
if (thumbnail != NULL) {
|
||||
mpDiskChanObj->createDiskLayout(thumbnail);
|
||||
}
|
||||
if (!mbDiskInserted) {
|
||||
startDiskInEvent();
|
||||
}
|
||||
mbDiskInserted = false;
|
||||
mDiskState = DISK_STATE_PLAY_THUMB;
|
||||
} else if (diskState == bs2::IPL_STATE_DISK_UPDATE) {
|
||||
System::getChannelManager()->setDiskChannelReady(false);
|
||||
mpDiskLayout->FindPaneByName(scPaneName_N_GCIcon)->SetVisible(false);
|
||||
mpDiskLayout->FindPaneByName(scPaneName_N_DiscUpdateIcon)->SetVisible(true);
|
||||
ChannelObj::setLangPane(mpDiskLayout);
|
||||
if (mpDiskAnim != NULL) {
|
||||
mpDiskAnim->setAnmType(ANIM_TYPE_LOOP);
|
||||
mpDiskAnim->play();
|
||||
}
|
||||
if (!mbDiskInserted) {
|
||||
startDiskInEvent();
|
||||
}
|
||||
mbDiskInserted = false;
|
||||
mDiskState = DISK_STATE_PLAY_THUMB;
|
||||
} else if (diskState == bs2::IPL_STATE_GC_GAME) {
|
||||
if (!mbDiskInserted) {
|
||||
startDiskInEvent();
|
||||
}
|
||||
mbDiskInserted = false;
|
||||
mDiskState = DISK_STATE_GC_GAME_WAIT;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case DISK_STATE_PLAY_THUMB:
|
||||
if (!mpDiskFadeAnim->isPlaying()) {
|
||||
mpDiskChanObj->resetDiskTitleName();
|
||||
if (diskState == bs2::IPL_STATE_RVL_GAME) {
|
||||
if (mpDiskChanObj->mpThumbAnim != NULL) {
|
||||
mpDiskChanObj->mpThumbAnim->setAnmType(ANIM_TYPE_LOOP);
|
||||
layout::Animator* thumbnailAnim = mpDiskChanObj->mpThumbAnim;
|
||||
thumbnailAnim->play();
|
||||
}
|
||||
mDiskState = DISK_STATE_RVL_GAME;
|
||||
} else {
|
||||
mDiskState = DISK_STATE_DISK_UPDATE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case DISK_STATE_RVL_GAME:
|
||||
if ((diskState != bs2::IPL_STATE_RVL_GAME || System::getChannelManager()->isDiskChannelReady()) && !mpDiskInAnim->isPlaying()) {
|
||||
startDiskOutEvent();
|
||||
mpDiskChanObj->changeDisk();
|
||||
mDiskState = DISK_STATE_DESTROY;
|
||||
}
|
||||
break;
|
||||
case DISK_STATE_DISK_UPDATE:
|
||||
if ((diskState != bs2::IPL_STATE_DISK_UPDATE || System::getChannelManager()->isDiskChannelReady()) && !mpDiskInAnim->isPlaying()) {
|
||||
startDiskOutEvent();
|
||||
mpDiskChanObj->changeDisk();
|
||||
mDiskState = DISK_STATE_DESTROY;
|
||||
}
|
||||
break;
|
||||
case DISK_STATE_GC_GAME_WAIT:
|
||||
if (!mpDiskFadeAnim->isPlaying()) {
|
||||
mDiskState = DISK_STATE_GC_GAME;
|
||||
}
|
||||
break;
|
||||
case DISK_STATE_GC_GAME:
|
||||
if (diskState != bs2::IPL_STATE_GC_GAME && !mpDiskInAnim->isPlaying()) {
|
||||
startDiskOutEvent();
|
||||
mpDiskChanObj->changeDisk();
|
||||
mDiskState = DISK_STATE_DESTROY;
|
||||
}
|
||||
break;
|
||||
case DISK_STATE_DESTROY:
|
||||
if (!mpDiskFadeAnim->isPlaying()) {
|
||||
mpDiskChanObj->destroyDiskLayout();
|
||||
mpDiskChanObj->resetDiskTitleName();
|
||||
mDiskState = DISK_STATE_READ;
|
||||
}
|
||||
break;
|
||||
}
|
||||
extern "C" asm void updateDiskState__Q33ipl5scene13ChannelSelectFv() {
|
||||
nofralloc
|
||||
stwu r1, -0x20(r1)
|
||||
mflr r0
|
||||
stw r0, 0x24(r1)
|
||||
addi r11, r1, 0x20
|
||||
bl _savegpr_27
|
||||
lis r28, smArg__Q23ipl6System@ha
|
||||
lwz r0, 0xf0(r3)
|
||||
addi r28, r28, smArg__Q23ipl6System@l
|
||||
mr r31, r3
|
||||
lwz r4, 0xa8(r28)
|
||||
cmplwi r0, 0x6
|
||||
lwz r27, 0x4(r4)
|
||||
bgt updateDiskState_done
|
||||
lis r4, updateDiskState_jumptable@ha
|
||||
slwi r0, r0, 2
|
||||
addi r4, r4, updateDiskState_jumptable@l
|
||||
lwzx r4, r4, r0
|
||||
mtctr r4
|
||||
bctr
|
||||
updateDiskState_case0:
|
||||
lwz r4, 0xa4(r3)
|
||||
lwz r0, 0x14(r4)
|
||||
cmpwi r0, 0x1
|
||||
beq updateDiskState_done
|
||||
lwz r3, 0x94(r3)
|
||||
lis r29, scPaneName_N_GCIcon@ha
|
||||
addi r4, r29, scPaneName_N_GCIcon@l
|
||||
li r5, 0x1
|
||||
lwz r3, 0x14(r3)
|
||||
lwz r12, 0x0(r3)
|
||||
lwz r12, 0x3c(r12)
|
||||
mtctr r12
|
||||
bctrl
|
||||
li r4, 0x1
|
||||
bl SetVisible__Q34nw4r3lyt4PaneFb
|
||||
lwz r3, 0x94(r31)
|
||||
lis r30, scPaneName_N_DiscUpdateIcon@ha
|
||||
addi r4, r30, scPaneName_N_DiscUpdateIcon@l
|
||||
li r5, 0x1
|
||||
lwz r3, 0x14(r3)
|
||||
lwz r12, 0x0(r3)
|
||||
lwz r12, 0x3c(r12)
|
||||
mtctr r12
|
||||
bctrl
|
||||
li r4, 0x0
|
||||
bl SetVisible__Q34nw4r3lyt4PaneFb
|
||||
cmpwi r27, 0x5
|
||||
bne updateDiskState_case0_diskState3
|
||||
lwz r4, 0xc0(r31)
|
||||
lwz r3, 0x84(r28)
|
||||
subi r4, r4, 0xf
|
||||
subic r0, r4, 0x1
|
||||
subfe r4, r0, r4
|
||||
bl getDiskThumbnail__Q33ipl7channel7ManagerFb
|
||||
lwz r0, 0xc0(r31)
|
||||
mr r27, r3
|
||||
cmpwi r0, 0xf
|
||||
bne updateDiskState_case0_afterThumb
|
||||
lwz r3, 0xa8(r28)
|
||||
addi r4, r31, 0xf8
|
||||
addi r5, r31, 0xfc
|
||||
bl getDiskInfo__Q33ipl3bs27ManagerFPPcPPc
|
||||
updateDiskState_case0_afterThumb:
|
||||
cmpwi r27, 0x0
|
||||
beq updateDiskState_case0_afterLayout
|
||||
lwz r3, 0x90(r31)
|
||||
mr r4, r27
|
||||
bl createDiskLayout__Q33ipl5scene10ChannelObjFPv
|
||||
updateDiskState_case0_afterLayout:
|
||||
lbz r0, 0xf4(r31)
|
||||
cmpwi r0, 0x0
|
||||
bne updateDiskState_case0_afterDiskIn
|
||||
mr r3, r31
|
||||
bl startDiskInEvent__Q33ipl5scene13ChannelSelectFv
|
||||
updateDiskState_case0_afterDiskIn:
|
||||
li r3, 0x0
|
||||
li r0, 0x1
|
||||
stb r3, 0xf4(r31)
|
||||
stw r0, 0xf0(r31)
|
||||
b updateDiskState_done
|
||||
updateDiskState_case0_diskState3:
|
||||
cmpwi r27, 0x3
|
||||
bne updateDiskState_case0_diskState6
|
||||
lwz r3, 0x84(r28)
|
||||
li r0, 0x0
|
||||
addi r4, r29, scPaneName_N_GCIcon@l
|
||||
li r5, 0x1
|
||||
stb r0, 0x1b81(r3)
|
||||
lwz r3, 0x94(r31)
|
||||
lwz r3, 0x14(r3)
|
||||
lwz r12, 0x0(r3)
|
||||
lwz r12, 0x3c(r12)
|
||||
mtctr r12
|
||||
bctrl
|
||||
li r4, 0x0
|
||||
bl SetVisible__Q34nw4r3lyt4PaneFb
|
||||
lwz r3, 0x94(r31)
|
||||
addi r4, r30, scPaneName_N_DiscUpdateIcon@l
|
||||
li r5, 0x1
|
||||
lwz r3, 0x14(r3)
|
||||
lwz r12, 0x0(r3)
|
||||
lwz r12, 0x3c(r12)
|
||||
mtctr r12
|
||||
bctrl
|
||||
li r4, 0x1
|
||||
bl SetVisible__Q34nw4r3lyt4PaneFb
|
||||
lwz r3, 0x94(r31)
|
||||
bl setLangPane__Q33ipl5scene10ChannelObjFPCQ33ipl6layout6Object
|
||||
lwz r3, 0x98(r31)
|
||||
cmpwi r3, 0x0
|
||||
beq updateDiskState_case0_state3_afterAnim
|
||||
li r0, 0x2
|
||||
stw r0, 0x18(r3)
|
||||
lwz r28, 0x98(r31)
|
||||
mr r3, r28
|
||||
bl initFrame__Q33ipl7utility15FrameControllerFv
|
||||
li r0, 0x1
|
||||
stw r0, 0x14(r28)
|
||||
updateDiskState_case0_state3_afterAnim:
|
||||
lbz r0, 0xf4(r31)
|
||||
cmpwi r0, 0x0
|
||||
bne updateDiskState_case0_state3_afterDiskIn
|
||||
mr r3, r31
|
||||
bl startDiskInEvent__Q33ipl5scene13ChannelSelectFv
|
||||
updateDiskState_case0_state3_afterDiskIn:
|
||||
li r3, 0x0
|
||||
li r0, 0x1
|
||||
stb r3, 0xf4(r31)
|
||||
stw r0, 0xf0(r31)
|
||||
b updateDiskState_done
|
||||
updateDiskState_case0_diskState6:
|
||||
cmpwi r27, 0x6
|
||||
bne updateDiskState_done
|
||||
lbz r0, 0xf4(r31)
|
||||
cmpwi r0, 0x0
|
||||
bne updateDiskState_case0_state6_afterDiskIn
|
||||
mr r3, r31
|
||||
bl startDiskInEvent__Q33ipl5scene13ChannelSelectFv
|
||||
updateDiskState_case0_state6_afterDiskIn:
|
||||
li r3, 0x0
|
||||
li r0, 0x4
|
||||
stb r3, 0xf4(r31)
|
||||
stw r0, 0xf0(r31)
|
||||
b updateDiskState_done
|
||||
updateDiskState_case1:
|
||||
lwz r4, 0x8c(r3)
|
||||
lwz r0, 0x14(r4)
|
||||
cmpwi r0, 0x1
|
||||
beq updateDiskState_done
|
||||
lwz r3, 0x90(r3)
|
||||
bl resetDiskTitleName__Q33ipl5scene10ChannelObjFv
|
||||
cmpwi r27, 0x5
|
||||
bne updateDiskState_case1_setState3
|
||||
lwz r3, 0x90(r31)
|
||||
lwz r3, 0x34(r3)
|
||||
cmpwi r3, 0x0
|
||||
beq updateDiskState_case1_setState2
|
||||
li r0, 0x2
|
||||
stw r0, 0x18(r3)
|
||||
lwz r3, 0x90(r31)
|
||||
lwz r27, 0x34(r3)
|
||||
mr r3, r27
|
||||
bl initFrame__Q33ipl7utility15FrameControllerFv
|
||||
li r0, 0x1
|
||||
stw r0, 0x14(r27)
|
||||
updateDiskState_case1_setState2:
|
||||
li r0, 0x2
|
||||
stw r0, 0xf0(r31)
|
||||
b updateDiskState_done
|
||||
updateDiskState_case1_setState3:
|
||||
li r0, 0x3
|
||||
stw r0, 0xf0(r31)
|
||||
b updateDiskState_done
|
||||
updateDiskState_case2:
|
||||
cmpwi r27, 0x5
|
||||
bne updateDiskState_case2_doOut
|
||||
lwz r4, 0x84(r28)
|
||||
lbz r0, 0x1b81(r4)
|
||||
cmpwi r0, 0x0
|
||||
beq updateDiskState_done
|
||||
updateDiskState_case2_doOut:
|
||||
lwz r3, 0xa0(r3)
|
||||
lwz r0, 0x14(r3)
|
||||
cmpwi r0, 0x1
|
||||
beq updateDiskState_done
|
||||
mr r3, r31
|
||||
bl startDiskOutEvent__Q33ipl5scene13ChannelSelectFv
|
||||
lwz r3, 0x90(r31)
|
||||
bl changeDisk__Q33ipl5scene10ChannelObjFv
|
||||
li r0, 0x6
|
||||
stw r0, 0xf0(r31)
|
||||
b updateDiskState_done
|
||||
updateDiskState_case3:
|
||||
cmpwi r27, 0x3
|
||||
bne updateDiskState_case3_doOut
|
||||
lwz r4, 0x84(r28)
|
||||
lbz r0, 0x1b81(r4)
|
||||
cmpwi r0, 0x0
|
||||
beq updateDiskState_done
|
||||
updateDiskState_case3_doOut:
|
||||
lwz r3, 0xa0(r3)
|
||||
lwz r0, 0x14(r3)
|
||||
cmpwi r0, 0x1
|
||||
beq updateDiskState_done
|
||||
mr r3, r31
|
||||
bl startDiskOutEvent__Q33ipl5scene13ChannelSelectFv
|
||||
lwz r3, 0x90(r31)
|
||||
bl changeDisk__Q33ipl5scene10ChannelObjFv
|
||||
li r0, 0x6
|
||||
stw r0, 0xf0(r31)
|
||||
b updateDiskState_done
|
||||
updateDiskState_case4:
|
||||
lwz r4, 0x8c(r3)
|
||||
lwz r0, 0x14(r4)
|
||||
cmpwi r0, 0x1
|
||||
beq updateDiskState_done
|
||||
li r0, 0x5
|
||||
stw r0, 0xf0(r3)
|
||||
b updateDiskState_done
|
||||
updateDiskState_case5:
|
||||
cmpwi r27, 0x6
|
||||
beq updateDiskState_done
|
||||
lwz r4, 0xa0(r3)
|
||||
lwz r0, 0x14(r4)
|
||||
cmpwi r0, 0x1
|
||||
beq updateDiskState_done
|
||||
bl startDiskOutEvent__Q33ipl5scene13ChannelSelectFv
|
||||
lwz r3, 0x90(r31)
|
||||
bl changeDisk__Q33ipl5scene10ChannelObjFv
|
||||
li r0, 0x6
|
||||
stw r0, 0xf0(r31)
|
||||
b updateDiskState_done
|
||||
updateDiskState_case6:
|
||||
lwz r4, 0x8c(r3)
|
||||
lwz r0, 0x14(r4)
|
||||
cmpwi r0, 0x1
|
||||
beq updateDiskState_done
|
||||
lwz r3, 0x90(r3)
|
||||
bl destroyDiskLayout__Q33ipl5scene10ChannelObjFv
|
||||
lwz r3, 0x90(r31)
|
||||
bl resetDiskTitleName__Q33ipl5scene10ChannelObjFv
|
||||
li r0, 0x0
|
||||
stw r0, 0xf0(r31)
|
||||
updateDiskState_done:
|
||||
addi r11, r1, 0x20
|
||||
bl _restgpr_27
|
||||
lwz r0, 0x24(r1)
|
||||
mtlr r0
|
||||
addi r1, r1, 0x20
|
||||
blr
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -147,13 +147,14 @@ bool MemoryCardManager::isMoveEnable(u8 slot, u32 index, long* code) {
|
||||
CardDirectory* dirs = reinterpret_cast<CardDirectory*>(memorycard::getCardDirState());
|
||||
memorycard::CardState* states = memorycard::getCardSlotState();
|
||||
u32 file = mFile[slot][index].fileNo;
|
||||
long result = file;
|
||||
memorycard::FileInfo* dir = NULL;
|
||||
long result;
|
||||
bool enabled = false;
|
||||
if (isDistSlot(slot, NULL) &&
|
||||
dirs[slot][file].canMove != 0 &&
|
||||
((dir = &dirs[slot][file])->canMove != 0) &&
|
||||
states[slot].key == states[slot ^ 1].key &&
|
||||
states[slot ^ 1].freeBlocks >= dirs[slot][file].size && states[slot ^ 1].unk_0x0E != 0 &&
|
||||
dirs[slot][file].unk_0x06 == 0) {
|
||||
states[slot ^ 1].freeBlocks >= dir->size && states[slot ^ 1].unk_0x0E != 0 &&
|
||||
dir->unk_0x06 == 0) {
|
||||
result = -0x15;
|
||||
enabled = true;
|
||||
} else {
|
||||
@@ -166,13 +167,13 @@ bool MemoryCardManager::isMoveEnable(u8 slot, u32 index, long* code) {
|
||||
} else {
|
||||
result = -0x1c;
|
||||
}
|
||||
} else if (dirs[slot][file].canMove == 0) {
|
||||
} else if ((dir = &dirs[slot][file])->canMove == 0) {
|
||||
result = -0x1a;
|
||||
} else if (states[slot].key != states[slot ^ 1].key) {
|
||||
result = -0x1b;
|
||||
} else if (states[slot ^ 1].freeBlocks < dirs[slot][file].size || states[slot ^ 1].unk_0x0E == 0) {
|
||||
} else if (states[slot ^ 1].freeBlocks < dir->size || states[slot ^ 1].unk_0x0E == 0) {
|
||||
result = -0x19;
|
||||
} else if (dirs[slot][file].unk_0x06 != 0) {
|
||||
} else if (dir->unk_0x06 != 0) {
|
||||
result = -0x18;
|
||||
}
|
||||
}
|
||||
@@ -186,13 +187,14 @@ bool MemoryCardManager::isCopyEnable(u8 slot, u32 index, long* code) {
|
||||
CardDirectory* dirs = reinterpret_cast<CardDirectory*>(memorycard::getCardDirState());
|
||||
memorycard::CardState* states = memorycard::getCardSlotState();
|
||||
u32 file = mFile[slot][index].fileNo;
|
||||
long result = file;
|
||||
memorycard::FileInfo* dir = NULL;
|
||||
long result;
|
||||
bool enabled = false;
|
||||
if (isDistSlot(slot, NULL) &&
|
||||
dirs[slot][file].canCopy != 0 &&
|
||||
((dir = &dirs[slot][file])->canCopy != 0) &&
|
||||
states[slot].key == states[slot ^ 1].key &&
|
||||
states[slot ^ 1].freeBlocks >= dirs[slot][file].size && states[slot ^ 1].unk_0x0E != 0 &&
|
||||
dirs[slot][file].unk_0x06 == 0) {
|
||||
states[slot ^ 1].freeBlocks >= dir->size && states[slot ^ 1].unk_0x0E != 0 &&
|
||||
dir->unk_0x06 == 0) {
|
||||
result = -0x15;
|
||||
enabled = true;
|
||||
} else {
|
||||
@@ -205,13 +207,13 @@ bool MemoryCardManager::isCopyEnable(u8 slot, u32 index, long* code) {
|
||||
} else {
|
||||
result = -0x1c;
|
||||
}
|
||||
} else if (dirs[slot][file].canCopy == 0) {
|
||||
} else if ((dir = &dirs[slot][file])->canCopy == 0) {
|
||||
result = -0x1a;
|
||||
} else if (states[slot].key != states[slot ^ 1].key) {
|
||||
result = -0x1b;
|
||||
} else if (states[slot ^ 1].freeBlocks < dirs[slot][file].size || states[slot ^ 1].unk_0x0E == 0) {
|
||||
} else if (states[slot ^ 1].freeBlocks < dir->size || states[slot ^ 1].unk_0x0E == 0) {
|
||||
result = -0x19;
|
||||
} else if (dirs[slot][file].unk_0x06 != 0) {
|
||||
} else if (dir->unk_0x06 != 0) {
|
||||
result = -0x18;
|
||||
}
|
||||
}
|
||||
@@ -235,7 +237,10 @@ bool MemoryCardManager::isIconValidate(u8 slot, s16 index) {
|
||||
|
||||
bool MemoryCardManager::isBannerEnable(u8 slot, s16 index) {
|
||||
CardIcons* icons = reinterpret_cast<CardIcons*>(memorycard::getIconStateArray());
|
||||
return icons[slot][mFile[slot][index].fileNo].bannerEnable != 0;
|
||||
u32 file = mFile[slot][index].fileNo;
|
||||
memorycard::IconState* icon = &icons[slot][file];
|
||||
u8 enabled = icon->bannerEnable;
|
||||
return enabled != 0;
|
||||
}
|
||||
|
||||
void MemoryCardManager::update_icon_anm() {
|
||||
@@ -279,11 +284,7 @@ void MemoryCardManager::update_file_array(u8 slot) {
|
||||
memorycard::CardState* states = memorycard::getCardSlotState();
|
||||
states[slot].changed = 0;
|
||||
sort_file_array(slot);
|
||||
enum CardCommand {
|
||||
NoCommand, Format, Copy, Move, Delete,
|
||||
CopyComplete, MoveComplete, DeleteComplete, FormatComplete
|
||||
};
|
||||
CardCommand command = static_cast<CardCommand>(mLastCmd);
|
||||
long command = mLastCmd;
|
||||
if ((u32)(command - 1) <= 3) {
|
||||
if (mLastResult == -0x15) {
|
||||
mLastResult = memorycard::getCardLastCMDFCmdResult();
|
||||
|
||||
@@ -1266,9 +1266,10 @@ namespace ipl {
|
||||
memoPosition.x = translation.x;
|
||||
memoPosition.y = translation.y;
|
||||
memoPosition.z = translation.z;
|
||||
f32 bodyY = memoPosition.y;
|
||||
mpDialogLayout->FindPaneByName("header_header");
|
||||
nw4r::lyt::Pane* bodyPane = mpDialogLayout->FindPaneByName("header_body");
|
||||
|
||||
f32 bodyY = memoPosition.y;
|
||||
if (bodyY < 500.0f) {
|
||||
mpDialogLayout->draw("header_header");
|
||||
}
|
||||
@@ -1281,11 +1282,11 @@ namespace ipl {
|
||||
++child;
|
||||
}
|
||||
|
||||
s32 lineCount = 0;
|
||||
f32 messageOffset = 0.0f;
|
||||
f32 bodyHeight = bodyPane->GetSize().height;
|
||||
if (mNandTitleCount != 0) {
|
||||
const wchar_t* messageForCount = System::getMessage(0xCB);
|
||||
s32 lineCount = 0;
|
||||
const wchar_t* newline = wcsstr(messageForCount, L"\n");
|
||||
while (newline != NULL) {
|
||||
++lineCount;
|
||||
|
||||
@@ -1341,11 +1341,13 @@ namespace ipl {
|
||||
wchar_t* titleName = System::getChannelManager()->getTitleName(
|
||||
page, channelIndex, 0);
|
||||
memcpy(titleNames + *titleCount * 0x2a, titleName, 0x2a);
|
||||
++*titleCount;
|
||||
u32 nextTitleCount = *titleCount + 1;
|
||||
*titleCount = nextTitleCount;
|
||||
|
||||
if (bytes >= secondUsage[0] && blocks >= secondUsage[1]) {
|
||||
return true;
|
||||
if (bytes < secondUsage[0] || blocks < secondUsage[1]) {
|
||||
continue;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1406,10 +1408,10 @@ namespace ipl {
|
||||
getCurrentTitleUsage(&bytes, &blocks);
|
||||
*titleCount = 0;
|
||||
|
||||
ESTitleId titleId;
|
||||
for (int page = MAX_CHANNEL_PAGE - 1; page >= 0; --page) {
|
||||
for (int order = 0; order < MAX_CHANNEL_INDEX; ++order) {
|
||||
int channelIndex = channelOrder[order];
|
||||
ESTitleId titleId;
|
||||
const channel::SEntry& channelInfo =
|
||||
System::getChannelManager()->mChannels[page][channelIndex];
|
||||
if (channelInfo.loadedBnr) {
|
||||
@@ -2710,19 +2712,23 @@ namespace ipl {
|
||||
nw4r::ut::Rect projection;
|
||||
System::getProjectionRect(&projection);
|
||||
GXRenderModeObj* renderMode = System::getRenderModeObj();
|
||||
f32 scissorX;
|
||||
f32 scissorY;
|
||||
f32 scissorWidth;
|
||||
f32 scissorY;
|
||||
f32 scissorX;
|
||||
f32 scissorHeight;
|
||||
u16 framebufferWidth;
|
||||
u16 framebufferHeight;
|
||||
|
||||
if (mState == 7 || mState == 12 || mState == 14) {
|
||||
nw4r::math::MTX44 matrix;
|
||||
f32 right = mPosition.x + projection.right / mScale.x;
|
||||
f32 left = mPosition.x + projection.left / mScale.x;
|
||||
f32 bottom = mPosition.y - projection.bottom / mScale.y;
|
||||
f32 top = mPosition.y - projection.top / mScale.y;
|
||||
f32 rightScale = projection.right / mScale.x;
|
||||
f32 leftScale = projection.left / mScale.x;
|
||||
f32 bottomScale = projection.bottom / mScale.y;
|
||||
f32 topScale = projection.top / mScale.y;
|
||||
f32 bottom = mPosition.y - bottomScale;
|
||||
f32 right = mPosition.x + rightScale;
|
||||
f32 left = mPosition.x + leftScale;
|
||||
f32 top = mPosition.y - topScale;
|
||||
MTXOrtho(matrix, top, bottom, left, right, -100.0f, 100.0f);
|
||||
|
||||
nw4r::math::VEC4 input(position.x, position.y, 0.0f, 1.0f);
|
||||
@@ -2730,13 +2736,14 @@ namespace ipl {
|
||||
nw4r::math::VEC4Transform(&transformed, &matrix, &input);
|
||||
framebufferWidth = renderMode->fbWidth;
|
||||
framebufferHeight = renderMode->efbHeight;
|
||||
const f32 projectionWidth = projection.GetWidth();
|
||||
scissorX = ((1.0f + transformed.x) * framebufferWidth / 2) -
|
||||
((mThumbOffsetX * mScale.x) * (framebufferWidth / projectionWidth));
|
||||
scissorWidth = projection.GetWidth();
|
||||
scissorY = (framebufferHeight - ((1.0f + transformed.y) * framebufferHeight / 2)) -
|
||||
(mThumbOffsetY * mScale.y);
|
||||
f32 widthScale = framebufferWidth / scissorWidth;
|
||||
scissorX = ((1.0f + transformed.x) * framebufferWidth / 2) -
|
||||
((mThumbOffsetX * mScale.x) * widthScale);
|
||||
scissorWidth = 2.0f * (mThumbOffsetX * mScale.x) *
|
||||
(framebufferWidth / projectionWidth);
|
||||
(framebufferWidth / scissorWidth);
|
||||
scissorHeight = 2.0f * (mThumbOffsetY * mScale.y);
|
||||
} else {
|
||||
framebufferWidth = renderMode->fbWidth;
|
||||
@@ -3406,7 +3413,7 @@ namespace ipl {
|
||||
case ::gui::EventHandler::ON_TRIG:
|
||||
if (mpScene->mState == 1 && controller != NULL) {
|
||||
BOOL writeProtected = mpScene->mpSDWorker->is_sd_write_protected();
|
||||
if (controller->pinchTrg() && iplSDChannelObj_hasAppMeta(channel) &&
|
||||
if (controller->pinchTrg() && SDChannelSelect::isChannelReady(channel) &&
|
||||
!mpScene->mbSDCardBroken) {
|
||||
if (!writeProtected) {
|
||||
mpScene->startDrag(controller, mpScene->mCurrentPage, index);
|
||||
@@ -3420,20 +3427,20 @@ namespace ipl {
|
||||
break;
|
||||
case ::gui::EventHandler::ON_DRAG:
|
||||
if (mpScene->mState == 1 && controller != NULL && controller->decide() &&
|
||||
iplSDChannelObj_hasAppMeta(channel)) {
|
||||
SDChannelSelect::isChannelReady(channel)) {
|
||||
mpScene->selectChannel(channel->getPage(), channel->getIndex());
|
||||
TVRCManager::getHandle()->setEnable(FALSE);
|
||||
}
|
||||
break;
|
||||
case ::gui::EventHandler::ON_POINT:
|
||||
if (mpScene->mState == 1 && iplSDChannelObj_hasAppMeta(channel)) {
|
||||
if (mpScene->mState == 1 && SDChannelSelect::isChannelReady(channel)) {
|
||||
iplSDChannelObj_startAppear(channel, 0);
|
||||
snd::getSystem()->startSE("WIPL_SE_CH_TARGETTING");
|
||||
controller->rumble(1);
|
||||
}
|
||||
break;
|
||||
case ::gui::EventHandler::ON_LEFT:
|
||||
if (mpScene->mState == 1 && iplSDChannelObj_hasAppMeta(channel)) {
|
||||
if (mpScene->mState == 1 && SDChannelSelect::isChannelReady(channel)) {
|
||||
iplSDChannelObj_startDisappear(channel, 0);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -3,10 +3,6 @@
|
||||
#define IPL_SDMEMORY_DIALOG_STATE_ACCESSOR
|
||||
#define IPL_SDMEMORY_COMPLETION_PCT_ACCESSOR
|
||||
|
||||
#define IPL_CHANNEL_TITLE_NOVTABLE
|
||||
#include "math/iplInterporation.h"
|
||||
#undef IPL_CHANNEL_TITLE_NOVTABLE
|
||||
|
||||
#include "scene/sdChannelTitle/iplSDChannelTitle.h"
|
||||
#include "scene/sdChannelSelect/iplSDChannelSelect.h"
|
||||
#include "system/iplSystem.h"
|
||||
@@ -1558,5 +1554,15 @@ void SDChannelTitle::startResetting() {
|
||||
snd::getSystem()->resetAllSound();
|
||||
}
|
||||
|
||||
extern "C" void iplSDChannelTitle_onTitleButtonEvent(SDTitleButtonEventHandler* handler, u32 component,
|
||||
u32 event, const controller::Interface* controller) {
|
||||
handler->onEventDerived(component, event, controller);
|
||||
}
|
||||
|
||||
extern "C" void iplSDChannelTitle_onTitlePaneEvent(SDTitlePaneEventHandler* handler, u32 component,
|
||||
u32 event, const controller::Interface* controller) {
|
||||
handler->onEvent(component, event, const_cast<controller::Interface*>(controller));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -167,11 +167,6 @@ typedef struct AOSSKeySchedule {
|
||||
u32 length;
|
||||
} AOSSKeySchedule;
|
||||
|
||||
typedef struct AOSSKeyMaterial {
|
||||
u8 nonce[2];
|
||||
u8 address[8];
|
||||
} AOSSKeyMaterial;
|
||||
|
||||
typedef struct AOSSReceiveBuffer {
|
||||
s32 socket;
|
||||
u32 length;
|
||||
@@ -262,7 +257,8 @@ static AOSSRuntimeState s_runtime;
|
||||
static AOSSConfigData s_configData;
|
||||
static u8 s_networkBuffer[0x280];
|
||||
static struct {
|
||||
AOSSKeyMaterial key;
|
||||
u8 keyNonce[2];
|
||||
u8 keyAddress[8];
|
||||
u8 payload[0x5e];
|
||||
} s_packetState;
|
||||
static u32 s_crcTable[0x100];
|
||||
@@ -287,10 +283,8 @@ extern int AOSSi_cancel_flag;
|
||||
extern int AOSSi_WLANGetBSSList(void** list);
|
||||
extern int AOSSi_Status(int status);
|
||||
extern int AOSSi_SetNCDIPAddr(u32 ipAddress, u32 netmask, u32 gateway, u32 dns1, u32 dns2);
|
||||
extern void AOSSi_Sleep(u32 duration);
|
||||
struct AOSSConnection;
|
||||
struct AOSSConnectionStatus;
|
||||
extern int AOSSi_WLANConnect(struct AOSSConnection* connection, struct AOSSConnectionStatus* status);
|
||||
extern int AOSSi_Sleep(u32 duration);
|
||||
extern int AOSSi_WLANConnect(void);
|
||||
extern int SOPoll(AOSSPollDescriptor* descriptors, int count, s32 timeoutHigh, s32 timeoutLow);
|
||||
extern int SORecvFrom(int socket, void* buffer, int length, int flags, void* address);
|
||||
extern int SOSendTo(int socket, const void* buffer, int length, int flags, const void* address);
|
||||
@@ -623,20 +617,6 @@ int AOSS_Init_old(AOSSInitInput* input)
|
||||
}
|
||||
resultCode = 0xffffffff;
|
||||
} else {
|
||||
/* The original initialization path repeats this status check. */
|
||||
if (state != 0) {
|
||||
input->status = 0xf;
|
||||
if (s_accessPointConfig) {
|
||||
AOSSi_Free(s_accessPointConfig);
|
||||
s_accessPointConfig = 0;
|
||||
}
|
||||
if (s_accessPointList) {
|
||||
AOSSi_Free(s_accessPointList);
|
||||
s_accessPointList = 0;
|
||||
}
|
||||
resultCode = 0xffffffff;
|
||||
goto finish_initialization;
|
||||
}
|
||||
s_accessPointConfig = (int *)AOSSi_Alloc(0x58);
|
||||
if (s_accessPointConfig == 0) {
|
||||
input->status = 0xf;
|
||||
@@ -744,15 +724,19 @@ handle_initial_link:
|
||||
AOSSi_Free(s_accessPointList);
|
||||
s_accessPointList = 0;
|
||||
}
|
||||
{
|
||||
int recordIndex;
|
||||
for (recordIndex = 0; recordIndex < 3; recordIndex++) {
|
||||
memcpy(requestRecords.records[recordIndex].address, input->optionData, 6);
|
||||
requestRecords.records[recordIndex].transactionId = rand();
|
||||
requestRecords.records[recordIndex].transactionId =
|
||||
SOHtoNs(requestRecords.records[recordIndex].transactionId);
|
||||
}
|
||||
}
|
||||
requestResult = 0;
|
||||
state = 0;
|
||||
do {
|
||||
AOSSRequestRecord* currentRecord = &requestRecords.records[requestResult];
|
||||
u16 transactionId;
|
||||
memcpy(requestRecords.bytes + state,input->optionData,6);
|
||||
transactionId = rand();
|
||||
currentRecord->transactionId = transactionId;
|
||||
receivedLength = SOHtoNs(transactionId);
|
||||
currentRecord->transactionId = receivedLength;
|
||||
requestResult++;
|
||||
state += sizeof(AOSSRequestRecord);
|
||||
} while (requestResult < 3);
|
||||
s_socket = SOSocket(2,2,0);
|
||||
if (s_socket < 0) {
|
||||
input->status = 0xf;
|
||||
@@ -817,7 +801,7 @@ perform_request:
|
||||
if (s_socketStarted == 1) {
|
||||
s_socketStarted = 0;
|
||||
requestResult = SOCleanup();
|
||||
if (requestResult >= 0) goto request_socket_cleanup_complete;
|
||||
if (-1 < requestResult) goto request_socket_cleanup_complete;
|
||||
requestResult = -1;
|
||||
}
|
||||
else {
|
||||
@@ -906,6 +890,7 @@ request_socket_cleanup_complete:
|
||||
resultCode = 0xffffffff;
|
||||
goto finish_initialization;
|
||||
}
|
||||
initialSleep = remainingWait <= 100 ? remainingWait : 100;
|
||||
AOSSi_Sleep(remainingWait > 100 ? 100 : remainingWait);
|
||||
if (remainingWait > 100) initialSleep = 100;
|
||||
else initialSleep = remainingWait;
|
||||
@@ -958,76 +943,73 @@ request_socket_cleanup_complete:
|
||||
goto finish_initialization;
|
||||
}
|
||||
}
|
||||
{
|
||||
int sendResult;
|
||||
int requestSocket = s_socket;
|
||||
switch (protocolState) {
|
||||
case 0:
|
||||
if (s_operationState != 2) {
|
||||
s_operationState = 2;
|
||||
AOSSi_Status(2);
|
||||
}
|
||||
sendResult = AOSSSendDiscoveryRequest(networkAddresses,&requestRecords,requestSocket);
|
||||
break;
|
||||
case 1:
|
||||
if (s_operationState != 3) {
|
||||
s_operationState = 3;
|
||||
AOSSi_Status(3);
|
||||
}
|
||||
sendResult = AOSSSendHelloRequest(networkAddresses,&requestRecords,requestSocket);
|
||||
|
||||
break;
|
||||
case 2:
|
||||
if (s_operationState != 5) {
|
||||
s_operationState = 5;
|
||||
AOSSi_Status(5);
|
||||
}
|
||||
packetWords = s_responseBuffer;
|
||||
memset(s_responseBuffer,0,0x5dc);
|
||||
memcpy(messageIdentity,&requestRecords.records[2],8);
|
||||
manufacturerLength = strlen(s_manufacturer);
|
||||
AOSSXorBufferWithKey(messageIdentity,8,s_manufacturer,manufacturerLength);
|
||||
receivedLength = SOHtoNs(1);
|
||||
packetWords->initialLength = receivedLength;
|
||||
packetWords->initialType = 0;
|
||||
packetWords->initialSequence = 0;
|
||||
packetWords->responseLength = SOHtoNs(0x3000);
|
||||
packetWords->responseType = 0;
|
||||
packetWords->finalLength = SOHtoNs(0);
|
||||
packetWords->finalSequence = SOHtoNs(0);
|
||||
packetWords->reserved = 0;
|
||||
packetWords->messageType = 0x11;
|
||||
memcpy(packetWords->messageIdentity,messageIdentity,8);
|
||||
memset(&replyAddress,0,8);
|
||||
replyAddress.family = 2;
|
||||
replyAddress.port = SOHtoNs(0x5790);
|
||||
replyAddress.address = SOHtoNl(s_runtime.ipAddress);
|
||||
if ((s8)s_runtime.active == 0) {
|
||||
replyAddress.address = 0xffffffff;
|
||||
}
|
||||
replyAddress.length = 8;
|
||||
SOSendTo(requestSocket,packetWords,0x18,0,&replyAddress);
|
||||
sendResult = 0;
|
||||
|
||||
break;
|
||||
default:
|
||||
sendResult = -1;
|
||||
break;
|
||||
requestResult = s_socket;
|
||||
switch (protocolState) {
|
||||
case 0:
|
||||
if (s_operationState != 2) {
|
||||
s_operationState = 2;
|
||||
AOSSi_Status(2);
|
||||
}
|
||||
if (sendResult == -1) {
|
||||
s_errorCode = protocolState + 0x1000;
|
||||
input->status = 0xf;
|
||||
if (s_accessPointConfig) {
|
||||
AOSSi_Free(s_accessPointConfig);
|
||||
s_accessPointConfig = (int *)0x0;
|
||||
}
|
||||
if (s_accessPointList) {
|
||||
AOSSi_Free(s_accessPointList);
|
||||
s_accessPointList = 0;
|
||||
}
|
||||
resultCode = 0xffffffff;
|
||||
goto finish_initialization;
|
||||
requestResult = AOSSSendDiscoveryRequest(networkAddresses,&requestRecords,requestResult);
|
||||
break;
|
||||
case 1:
|
||||
if (s_operationState != 3) {
|
||||
s_operationState = 3;
|
||||
AOSSi_Status(3);
|
||||
}
|
||||
requestResult = AOSSSendHelloRequest(networkAddresses,&requestRecords,requestResult);
|
||||
|
||||
break;
|
||||
case 2:
|
||||
if (s_operationState != 5) {
|
||||
s_operationState = 5;
|
||||
AOSSi_Status(5);
|
||||
}
|
||||
packetWords = s_responseBuffer;
|
||||
memset(s_responseBuffer,0,0x5dc);
|
||||
memcpy(messageIdentity,&requestRecords.records[2],8);
|
||||
manufacturerLength = strlen(s_manufacturer);
|
||||
AOSSXorBufferWithKey(messageIdentity,8,s_manufacturer,manufacturerLength);
|
||||
receivedLength = SOHtoNs(1);
|
||||
packetWords->initialLength = receivedLength;
|
||||
packetWords->initialType = 0;
|
||||
packetWords->initialSequence = 0;
|
||||
packetWords->responseLength = SOHtoNs(0x3000);
|
||||
packetWords->responseType = 0;
|
||||
packetWords->finalLength = SOHtoNs(0);
|
||||
packetWords->finalSequence = SOHtoNs(0);
|
||||
packetWords->reserved = 0;
|
||||
packetWords->messageType = 0x11;
|
||||
memcpy(packetWords->messageIdentity,messageIdentity,8);
|
||||
memset(&replyAddress,0,8);
|
||||
replyAddress.family = 2;
|
||||
replyAddress.port = SOHtoNs(0x5790);
|
||||
replyAddress.address = SOHtoNl(s_runtime.ipAddress);
|
||||
if ((s8)s_runtime.active == 0) {
|
||||
replyAddress.address = 0xffffffff;
|
||||
}
|
||||
replyAddress.length = 8;
|
||||
SOSendTo(requestResult,packetWords,0x18,0,&replyAddress);
|
||||
requestResult = 0;
|
||||
|
||||
break;
|
||||
default:
|
||||
requestResult = -1;
|
||||
break;
|
||||
}
|
||||
if (requestResult == -1) {
|
||||
s_errorCode = protocolState + 0x1000;
|
||||
input->status = 0xf;
|
||||
if (s_accessPointConfig) {
|
||||
AOSSi_Free(s_accessPointConfig);
|
||||
s_accessPointConfig = (int *)0x0;
|
||||
}
|
||||
if (s_accessPointList) {
|
||||
AOSSi_Free(s_accessPointList);
|
||||
s_accessPointList = 0;
|
||||
}
|
||||
resultCode = 0xffffffff;
|
||||
goto finish_initialization;
|
||||
}
|
||||
memset(packetBuffer,0,0x5f8);
|
||||
pollTime.seconds = timeoutMilliseconds / 1000;
|
||||
@@ -1046,12 +1028,10 @@ request_socket_cleanup_complete:
|
||||
if (0 < requestResult) goto process_received_packet;
|
||||
receivedPackets = receivedPackets + 1;
|
||||
if (receivedPackets > attemptCount) {
|
||||
if (protocolState == 0) {
|
||||
s_errorCode = 0xf;
|
||||
} else if (protocolState == 1) {
|
||||
s_errorCode = 0x10;
|
||||
} else {
|
||||
s_errorCode = 0x11;
|
||||
switch (protocolState) {
|
||||
case 0: s_errorCode = 0xf; break;
|
||||
case 1: s_errorCode = 0x10; break;
|
||||
default: s_errorCode = 0x11; break;
|
||||
}
|
||||
protocolResult = -1;
|
||||
goto close_protocol_socket;
|
||||
@@ -1118,7 +1098,8 @@ process_received_packet:
|
||||
}
|
||||
else {
|
||||
if (protocolState != requestResult) {
|
||||
if (requestResult != 2) goto advance_protocol_state;
|
||||
protocolState = requestResult;
|
||||
if (requestResult != 2) goto perform_request;
|
||||
if (s_socket != -1) {
|
||||
SOClose(s_socket);
|
||||
}
|
||||
@@ -1256,8 +1237,7 @@ wait_for_packet:
|
||||
goto finish_initialization;
|
||||
}
|
||||
AOSSi_Sleep(remainingWait > 100 ? 100 : remainingWait);
|
||||
if (remainingWait > 100) initialSleep = 100;
|
||||
else initialSleep = remainingWait;
|
||||
initialSleep = remainingWait <= 100 ? remainingWait : 100;
|
||||
}
|
||||
if (AOSSi_cancel_flag == 1) {
|
||||
input->status = 0xf;
|
||||
@@ -1314,18 +1294,15 @@ wait_for_packet:
|
||||
resultCode = 0xffffffff;
|
||||
goto finish_initialization;
|
||||
}
|
||||
advance_protocol_state:
|
||||
protocolState = requestResult;
|
||||
goto perform_request;
|
||||
}
|
||||
protocolState = requestResult;
|
||||
if (receivedPackets > waitSettings.halfwords.high) {
|
||||
if (requestResult == 0) {
|
||||
s_errorCode = 0xf;
|
||||
} else if (requestResult == 1) {
|
||||
s_errorCode = 0x10;
|
||||
} else {
|
||||
s_errorCode = 0x11;
|
||||
switch (requestResult) {
|
||||
case 0: s_errorCode = 0xf; break;
|
||||
case 1: s_errorCode = 0x10; break;
|
||||
default: s_errorCode = 0x11; break;
|
||||
}
|
||||
protocolResult = -1;
|
||||
goto close_protocol_socket;
|
||||
@@ -1345,7 +1322,8 @@ advance_protocol_state:
|
||||
resultCode = 0xffffffff;
|
||||
goto finish_initialization;
|
||||
}
|
||||
AOSSi_Sleep(retryDelay > 100 ? 100 : retryDelay);
|
||||
if (retryDelay > 100) AOSSi_Sleep(100);
|
||||
else AOSSi_Sleep(retryDelay);
|
||||
if (retryDelay > 100) delayStep = 100;
|
||||
else delayStep = retryDelay;
|
||||
}
|
||||
@@ -1372,7 +1350,7 @@ close_protocol_socket:
|
||||
if (s_socketStarted == 1) {
|
||||
s_socketStarted = 0;
|
||||
state = SOCleanup();
|
||||
if (state >= 0) goto protocol_socket_cleanup_complete;
|
||||
if (-1 < state) goto protocol_socket_cleanup_complete;
|
||||
state = -1;
|
||||
}
|
||||
else {
|
||||
@@ -1851,22 +1829,24 @@ int AOSSHandleFinalReply(int state, AOSSReceiveBuffer* packet, int* count, AOSSR
|
||||
}
|
||||
|
||||
int AOSSDecryptMessage(AOSSDecryptionMessage* message) {
|
||||
struct { u32 expected; u32 actual; } integrity;
|
||||
u32 checksum;
|
||||
u8 manufacturerAddress[8];
|
||||
AOSSKeySchedule schedule;
|
||||
AOSSEncryptedPayload* encrypted = &message->payload.encrypted;
|
||||
u32 firstValue;
|
||||
u32 secondValue;
|
||||
u8* state;
|
||||
u8* decryptedData;
|
||||
u32 controlFlags;
|
||||
u32 dataLength;
|
||||
u32 i;
|
||||
s32 crcIndex;
|
||||
u32 firstIndex;
|
||||
u32 secondIndex;
|
||||
u8* decryptedData;
|
||||
u32 controlFlags;
|
||||
u32 firstValue;
|
||||
u32 secondValue;
|
||||
u32 stateIndex;
|
||||
u32 crc;
|
||||
const u8* inputCursor;
|
||||
u32 dataLength;
|
||||
u8* state;
|
||||
u8* outputCursor;
|
||||
int result;
|
||||
|
||||
memcpy(manufacturerAddress, message->manufacturerAddress, sizeof(manufacturerAddress));
|
||||
@@ -1898,16 +1878,18 @@ int AOSSDecryptMessage(AOSSDecryptionMessage* message) {
|
||||
return 100;
|
||||
}
|
||||
|
||||
integrity.expected = message->checksum;
|
||||
checksum = message->checksum;
|
||||
schedule.bytes = AOSSi_Alloc(dataLength);
|
||||
if (schedule.bytes == 0) {
|
||||
s_errorCode = 2;
|
||||
result = -1;
|
||||
} else {
|
||||
memcpy(s_packetState.key.nonce, &encrypted->keyNonce, sizeof(encrypted->keyNonce));
|
||||
memcpy(s_packetState.key.address, s_accessPointName, sizeof(s_accessPointName));
|
||||
AOSSInitKeySchedule(&schedule, (const u8*)&s_packetState.key, sizeof(s_packetState.key), dataLength);
|
||||
memcpy(s_packetState.keyNonce, &encrypted->keyNonce, sizeof(encrypted->keyNonce));
|
||||
memcpy(s_packetState.keyAddress, s_accessPointName, sizeof(s_accessPointName));
|
||||
AOSSInitKeySchedule(&schedule, s_packetState.keyNonce,
|
||||
sizeof(s_packetState.keyNonce) + sizeof(s_packetState.keyAddress), dataLength);
|
||||
|
||||
outputCursor = decryptedData;
|
||||
inputCursor = encrypted->data;
|
||||
for (i = 0; i < dataLength; i++) {
|
||||
state = schedule.bytes;
|
||||
@@ -1920,18 +1902,15 @@ int AOSSDecryptMessage(AOSSDecryptionMessage* message) {
|
||||
schedule.j = secondIndex;
|
||||
state[secondIndex] = (u8)firstValue;
|
||||
state[firstIndex] = (u8)secondValue;
|
||||
{
|
||||
u8 streamByte = state[stateIndex % schedule.length];
|
||||
decryptedData[i] = streamByte ^ *inputCursor++;
|
||||
}
|
||||
*outputCursor++ = *inputCursor++ ^ state[stateIndex % schedule.length];
|
||||
}
|
||||
|
||||
integrity.actual = 0xffffffff;
|
||||
crc = 0xffffffff;
|
||||
AOSSInitCrc32Table(0, s_crcTable);
|
||||
for (crcIndex = 0; crcIndex < (s32)dataLength; crcIndex++) {
|
||||
integrity.actual = (integrity.actual >> 8) ^ s_crcTable[(integrity.actual ^ decryptedData[crcIndex]) & 0xff];
|
||||
crc = (crc >> 8) ^ s_crcTable[(crc ^ decryptedData[crcIndex]) & 0xff];
|
||||
}
|
||||
if (((integrity.actual ^ 0xffffffff) & 0xff) != integrity.expected) {
|
||||
if (((crc ^ 0xffffffff) & 0xff) != checksum) {
|
||||
s_errorCode = 0x12;
|
||||
AOSSi_Free(schedule.bytes);
|
||||
result = -1;
|
||||
@@ -2337,8 +2316,8 @@ int AOSSSendHelloRequest(void* packet, void* request, int socket) {
|
||||
u16 nonce;
|
||||
u32 stateLength;
|
||||
u32 index;
|
||||
u32 firstIndex;
|
||||
u32 firstByte;
|
||||
u32 firstIndex;
|
||||
u32 secondIndex;
|
||||
u8* state;
|
||||
u8 value;
|
||||
@@ -2380,9 +2359,10 @@ int AOSSSendHelloRequest(void* packet, void* request, int socket) {
|
||||
if (construction.schedule.bytes != 0) {
|
||||
nonce = (u16)rand();
|
||||
memcpy(&payload->encrypted.key.nonce, &nonce, 2);
|
||||
memcpy(s_packetState.key.nonce, payload->encrypted.key.nonceBytes, 2);
|
||||
memcpy(s_packetState.key.address, s_accessPointName, 8);
|
||||
AOSSInitKeySchedule(&construction.schedule, (const u8*)&s_packetState.key, sizeof(s_packetState.key), 8);
|
||||
memcpy(s_packetState.keyNonce, payload->encrypted.key.nonceBytes, 2);
|
||||
memcpy(s_packetState.keyAddress, s_accessPointName, 8);
|
||||
AOSSInitKeySchedule(&construction.schedule, s_packetState.keyNonce,
|
||||
sizeof(s_packetState.keyNonce) + sizeof(s_packetState.keyAddress), 8);
|
||||
for (index = 0; index < 8; index++) {
|
||||
state = construction.schedule.bytes;
|
||||
firstIndex = (construction.schedule.i + 1) % construction.schedule.length & 0xff;
|
||||
@@ -2566,7 +2546,7 @@ int AOSSConnectAndAwaitHost(void* settings, void* config) {
|
||||
s32 connectionAttempts = 0;
|
||||
u32 ticksPerMillisecond;
|
||||
|
||||
if (AOSSi_WLANConnect(settings, config) != 0) {
|
||||
if (AOSSi_WLANConnect() != 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
@@ -126,7 +126,7 @@ int AOSSi_EndLocal(void) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int AOSSi_WLANGetBSSList(void** output) {
|
||||
int AOSSi_WLANGetBSSList(struct AOSSAccessPointList** output) {
|
||||
int result = -1;
|
||||
int startupRetries = 0;
|
||||
WDScanParam scan ATTRIBUTE_ALIGN(32);
|
||||
@@ -338,7 +338,7 @@ void AOSSi_Sleep(u32 milliseconds) {
|
||||
AOSSi_SleepMs(milliseconds);
|
||||
}
|
||||
|
||||
int AOSSi_Status(int status) {
|
||||
int AOSSi_Status(void) {
|
||||
if (statusCallback != NULL) {
|
||||
statusCallback();
|
||||
}
|
||||
|
||||
@@ -357,6 +357,11 @@ extern int SOBind(int socket, void* address);
|
||||
extern int SORecvFrom(int socket, void* buffer, int length, int flags, void* address);
|
||||
extern int SOSendTo(int socket, const void* buffer, int length, int flags, void* address);
|
||||
|
||||
typedef struct {
|
||||
NCDIpConfig ipConfig;
|
||||
NCDIfConfig ifConfig;
|
||||
} AtermNetworkSettings;
|
||||
|
||||
typedef struct {
|
||||
u32 ssidLength;
|
||||
u8 ssid[32];
|
||||
@@ -395,13 +400,10 @@ typedef struct {
|
||||
u8 value[4];
|
||||
} AtermRequestOption8;
|
||||
|
||||
typedef union {
|
||||
struct {
|
||||
u8 firstAddress[6];
|
||||
u8 secondAddress[6];
|
||||
char productName[4];
|
||||
};
|
||||
u8 keyMaterial[16];
|
||||
typedef struct {
|
||||
u8 firstAddress[6];
|
||||
u8 secondAddress[6];
|
||||
char productName[4];
|
||||
} AtermAssociationRequest;
|
||||
|
||||
typedef struct {
|
||||
@@ -458,6 +460,10 @@ typedef struct {
|
||||
u32 securityMode;
|
||||
u8 reserved028[0x80];
|
||||
u8 keyMaterial[0x40];
|
||||
u8 connectionPrefix[0x10];
|
||||
u8 packetBuffer[0x800];
|
||||
u16 responseLength;
|
||||
u8 trailingData[6];
|
||||
} AtermConfigurationResult;
|
||||
|
||||
typedef struct {
|
||||
@@ -467,12 +473,25 @@ typedef struct {
|
||||
} AtermDecodedPayload;
|
||||
|
||||
typedef union {
|
||||
u8 keyMaterial[32];
|
||||
u8 data[0x818];
|
||||
struct {
|
||||
u8 challenge[8];
|
||||
u8 digest[16];
|
||||
};
|
||||
} AtermSession;
|
||||
u8 encryptedOptions[0x7F8];
|
||||
u8 keyMaterial[24];
|
||||
} session;
|
||||
struct {
|
||||
union {
|
||||
u8 payload[0x800];
|
||||
AtermDecodedPayload decoded;
|
||||
};
|
||||
union {
|
||||
struct {
|
||||
u8 challenge[8];
|
||||
u8 digest[16];
|
||||
};
|
||||
u8 keyMaterial[24];
|
||||
};
|
||||
} authentication;
|
||||
} AtermThreadBuffer;
|
||||
|
||||
typedef struct {
|
||||
u32 state[4];
|
||||
@@ -485,15 +504,11 @@ typedef void (*AtermProgressCallback)(void*);
|
||||
typedef void* (*AtermAllocateCallback)(u32);
|
||||
typedef void (*AtermFreeCallback)(void*);
|
||||
|
||||
NCDIpConfig gAtermIpConfig;
|
||||
NCDIfConfig gAtermIfConfig;
|
||||
AtermNetworkSettings gNetworkSettings;
|
||||
char gAccessPointName[0x24];
|
||||
AtermScanSettings gScanSettings;
|
||||
AtermConfigurationResult gAtermConfigurationResult;
|
||||
AtermAssociationRequest gAtermAssociationRequest;
|
||||
u8 gAtermPacketBuffer[0x800];
|
||||
AtermDecodedPayload gAtermDecodedResponse;
|
||||
AtermSession gAtermSession;
|
||||
AtermThreadBuffer gAtermResponseBuffer;
|
||||
static OSThread sAtermThread;
|
||||
u32 gAtermDeadline = 0xFFFFFFFF;
|
||||
u32 gAtermScanLimit = 0x40;
|
||||
@@ -527,7 +542,7 @@ s32 gAtermState;
|
||||
|
||||
void ATERMAlarmWakeQueue(OSAlarm* alarm, OSContext* context);
|
||||
s32 ATERMRunConfigProtocol(void);
|
||||
void ATERMMd5Update(AtermMd5Context* context, u8* input, u32 length);
|
||||
void ATERMMd5Update(AtermMd5Context* context, void* input, u32 length);
|
||||
extern u8 gAtermDigestFill[64];
|
||||
extern u8* gAtermRequestOptions;
|
||||
int ATERMAesKeyWrap(u16* destination, u16* source, u32 length, void* key, u32 keyLength);
|
||||
@@ -554,7 +569,7 @@ int ATERMStartNetworkStack(void) {
|
||||
OSMessage hostQueueBuffer;
|
||||
OSAlarm hostAlarm;
|
||||
|
||||
ipConfig = &gAtermIpConfig;
|
||||
ipConfig = &gNetworkSettings.ipConfig;
|
||||
memset(ipConfig, 0, sizeof(*ipConfig));
|
||||
ipConfig->adjust.maxTransferUnit = 0x514;
|
||||
ipConfig->adjust.tcpRetransTimeout = 100;
|
||||
@@ -568,8 +583,8 @@ int ATERMStartNetworkStack(void) {
|
||||
memcpy(ipConfig->ip.dns2, &gDefaultSecondaryDns, 4);
|
||||
NCDSetIpConfig(ipConfig);
|
||||
|
||||
memset(&gAtermIfConfig, 0, sizeof(gAtermIfConfig));
|
||||
ifConfig = &gAtermIfConfig;
|
||||
memset(&gNetworkSettings.ifConfig, 0, sizeof(gNetworkSettings.ifConfig));
|
||||
ifConfig = &gNetworkSettings.ifConfig;
|
||||
ifConfig->selectedMedia = 1;
|
||||
ifConfig->netif.wireless.rateset = 0;
|
||||
ifConfig->netif.wireless.configMethod = 0;
|
||||
@@ -855,38 +870,6 @@ int ATERMFindChangedApRecord(AtermApRecordSet* currentRecords, AtermApRecordSet*
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline s32 atermFormatHexByte(char* output, u8 byte) {
|
||||
s32 nibbles[2];
|
||||
s32 index;
|
||||
char* encoded = output;
|
||||
nibbles[0] = (byte & 0xF0) >> 4;
|
||||
nibbles[1] = byte & 0xF;
|
||||
for (index = 0; index < 2; index++) {
|
||||
s32 nibble = nibbles[index];
|
||||
if (nibble <= 9) {
|
||||
*encoded++ = nibble + '0';
|
||||
} else {
|
||||
*encoded++ = nibble + '7';
|
||||
}
|
||||
}
|
||||
*encoded = 0;
|
||||
return encoded - output;
|
||||
}
|
||||
|
||||
static inline void atermFormatMacAddress(char* text, const u8* address) {
|
||||
const u8* input = address;
|
||||
char* output = text;
|
||||
s32 index;
|
||||
for (index = 0; index < 6; index++) {
|
||||
u8 byte = *input++;
|
||||
output += atermFormatHexByte(output, byte);
|
||||
if (index < 5) {
|
||||
*output++ = ':';
|
||||
}
|
||||
}
|
||||
*output = 0;
|
||||
}
|
||||
|
||||
int ATERMDiscoverAccessPoints(void) {
|
||||
s32 result = -1;
|
||||
u32 scanBufferBytes;
|
||||
@@ -965,8 +948,8 @@ int ATERMDiscoverAccessPoints(void) {
|
||||
sizeof(currentRecords->entries[recordIndex].bssid));
|
||||
descriptorWords += descriptor->length;
|
||||
ssidCursor += sizeof(AtermApRecord);
|
||||
recordIndex++;
|
||||
bssidCursor += sizeof(AtermApRecord);
|
||||
recordIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -980,7 +963,35 @@ int ATERMDiscoverAccessPoints(void) {
|
||||
memcpy(gAtermSelectedBssid,
|
||||
selectedRecord->bssid,
|
||||
sizeof(selectedRecord->bssid));
|
||||
atermFormatMacAddress(selectedMacText, gAtermSelectedBssid);
|
||||
{
|
||||
u8* addressCursor = gAtermSelectedBssid;
|
||||
s32 addressIndex = 0;
|
||||
char* output = selectedMacText;
|
||||
|
||||
for (addressIndex = 0; ; addressIndex++) {
|
||||
u8 addressByte = *addressCursor++;
|
||||
char* encoded = output;
|
||||
s32 highNibble = (addressByte & 0xF0) >> 4;
|
||||
s32 lowNibble = addressByte & 0xF;
|
||||
if (highNibble <= 9) {
|
||||
*encoded++ = highNibble + '0';
|
||||
} else {
|
||||
*encoded++ = highNibble + '7';
|
||||
}
|
||||
if (lowNibble <= 9) {
|
||||
*encoded++ = lowNibble + '0';
|
||||
} else {
|
||||
*encoded++ = lowNibble + '7';
|
||||
}
|
||||
*encoded = 0;
|
||||
output += encoded - output;
|
||||
if (addressIndex == 5) {
|
||||
break;
|
||||
}
|
||||
*output++ = ':';
|
||||
}
|
||||
*output = '\0';
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -999,18 +1010,18 @@ int ATERMDiscoverAccessPoints(void) {
|
||||
iteration++;
|
||||
}
|
||||
|
||||
if (iteration >= 300) {
|
||||
goto timed_out;
|
||||
}
|
||||
now = (u32)OSTicksToMilliseconds(OSGetTime());
|
||||
if (now > gAtermDeadline) {
|
||||
timed_out:
|
||||
result = -3;
|
||||
} else {
|
||||
result = 1;
|
||||
if (gAtermCancelRequested != 0) {
|
||||
result = -8;
|
||||
if (iteration < 300) {
|
||||
now = (u32)OSTicksToMilliseconds(OSGetTime());
|
||||
if (now > gAtermDeadline) {
|
||||
result = -3;
|
||||
} else {
|
||||
result = 1;
|
||||
if (gAtermCancelRequested != 0) {
|
||||
result = -8;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
result = -3;
|
||||
}
|
||||
|
||||
cleanup:
|
||||
@@ -1132,7 +1143,7 @@ int ATERMParsePacket(AtermPacket* packet, u32* setupType) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ATERMBuildAssociationRequest(AtermAssociationRequest* request, AtermSocketAddress* address) {
|
||||
int ATERMBuildAssociationRequest(AtermAssociationRequest* request) {
|
||||
u8 scanAddress[8];
|
||||
u8 interfaceMacAddress[8];
|
||||
char interfaceMacText[32];
|
||||
@@ -1153,36 +1164,77 @@ int ATERMBuildAssociationRequest(AtermAssociationRequest* request, AtermSocketAd
|
||||
memcpy(request->secondAddress, interfaceMacAddress, 6);
|
||||
}
|
||||
if (gAtermUseSharedAddress != 0) {
|
||||
atermFormatMacAddress(interfaceMacText, interfaceMacAddress);
|
||||
atermFormatMacAddress(scanAddressText, scanAddress);
|
||||
{
|
||||
const u8* addressCursor = interfaceMacAddress;
|
||||
const u8* addressEnd = interfaceMacAddress + 6;
|
||||
int addressIndex;
|
||||
char* textCursor = interfaceMacText;
|
||||
addressIndex = 0;
|
||||
do {
|
||||
u8 addressByte = *addressCursor++;
|
||||
char* encoded = textCursor;
|
||||
s32 highNibble = (addressByte & 0xF0) >> 4;
|
||||
s32 lowNibble = addressByte & 0xF;
|
||||
if (highNibble <= 9) {
|
||||
*encoded++ = highNibble + '0';
|
||||
} else {
|
||||
*encoded++ = highNibble + '7';
|
||||
}
|
||||
if (lowNibble <= 9) {
|
||||
*encoded++ = lowNibble + '0';
|
||||
} else {
|
||||
*encoded++ = lowNibble + '7';
|
||||
}
|
||||
*encoded = 0;
|
||||
textCursor += encoded - textCursor;
|
||||
if (addressIndex < 5) {
|
||||
*textCursor++ = ':';
|
||||
}
|
||||
addressIndex++;
|
||||
} while (addressCursor < addressEnd);
|
||||
*textCursor = '\0';
|
||||
}
|
||||
{
|
||||
const u8* addressCursor = scanAddress;
|
||||
const u8* addressEnd = scanAddress + 6;
|
||||
int addressIndex;
|
||||
char* textCursor = scanAddressText;
|
||||
addressIndex = 0;
|
||||
do {
|
||||
u8 addressByte = *addressCursor++;
|
||||
char* encoded = textCursor;
|
||||
s32 highNibble = (addressByte & 0xF0) >> 4;
|
||||
s32 lowNibble = addressByte & 0xF;
|
||||
if (highNibble <= 9) {
|
||||
*encoded++ = highNibble + '0';
|
||||
} else {
|
||||
*encoded++ = highNibble + '7';
|
||||
}
|
||||
if (lowNibble <= 9) {
|
||||
*encoded++ = lowNibble + '0';
|
||||
} else {
|
||||
*encoded++ = lowNibble + '7';
|
||||
}
|
||||
*encoded = 0;
|
||||
textCursor += encoded - textCursor;
|
||||
if (addressIndex < 5) {
|
||||
*textCursor++ = ':';
|
||||
}
|
||||
addressIndex++;
|
||||
} while (addressCursor < addressEnd);
|
||||
*textCursor = '\0';
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static inline s32 atermEncodeHexByte(char* key, u8 sourceByte) {
|
||||
char* encoded = key;
|
||||
s32 lowNibble = sourceByte & 0xF;
|
||||
s32 highNibble = (sourceByte & 0xF0) >> 4;
|
||||
if (highNibble <= 9) {
|
||||
*encoded++ = highNibble + '0';
|
||||
} else {
|
||||
*encoded++ = highNibble + '7';
|
||||
}
|
||||
if (lowNibble <= 9) {
|
||||
*encoded++ = lowNibble + '0';
|
||||
} else {
|
||||
*encoded++ = lowNibble + '7';
|
||||
}
|
||||
*encoded = 0;
|
||||
return encoded - key;
|
||||
}
|
||||
|
||||
int ATERMParseAssociationResponse(u16* response) {
|
||||
u16* optionCursor = response + 4;
|
||||
u8* optionValue;
|
||||
u16* responseEnd;
|
||||
u32 optionType;
|
||||
s32 optionLength;
|
||||
char* key;
|
||||
u32 value;
|
||||
s32 result = 0;
|
||||
|
||||
@@ -1220,7 +1272,6 @@ int ATERMParseAssociationResponse(u16* response) {
|
||||
case 0x208:
|
||||
case 0x209:
|
||||
{
|
||||
char* key;
|
||||
u32 keyIndex = optionType - 0x206;
|
||||
key = gScanSettings.wirelessKeys[keyIndex].key;
|
||||
memset(key, 0, sizeof(gScanSettings.wirelessKeys[keyIndex].key));
|
||||
@@ -1228,7 +1279,21 @@ int ATERMParseAssociationResponse(u16* response) {
|
||||
s32 byteIndex;
|
||||
for (byteIndex = 0; byteIndex < optionLength; byteIndex++) {
|
||||
u8 sourceByte = *optionValue++;
|
||||
key += atermEncodeHexByte(key, sourceByte);
|
||||
char* encoded = key;
|
||||
s32 highNibble = (sourceByte & 0xF0) >> 4;
|
||||
s32 lowNibble = sourceByte & 0xF;
|
||||
if (highNibble <= 9) {
|
||||
*encoded++ = highNibble + '0';
|
||||
} else {
|
||||
*encoded++ = highNibble + '7';
|
||||
}
|
||||
if (lowNibble <= 9) {
|
||||
*encoded++ = lowNibble + '0';
|
||||
} else {
|
||||
*encoded++ = lowNibble + '7';
|
||||
}
|
||||
*encoded = 0;
|
||||
key += encoded - key;
|
||||
}
|
||||
} else {
|
||||
memcpy(key, optionValue, optionLength);
|
||||
@@ -1368,26 +1433,6 @@ int ATERMApplyScanSecuritySettings(void) {
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline u8* atermAppendOption(u8* cursor, u16 type, u16 length, const void* value) {
|
||||
AtermPacketOption* option = (AtermPacketOption*)cursor;
|
||||
u32 recordSize = (length + 4 + 7) & ~7;
|
||||
memset(option, 0, 4);
|
||||
option->type = SOHtoNs(type);
|
||||
option->length = SOHtoNs(length);
|
||||
memset(option->value, 0, recordSize - 4);
|
||||
memcpy(option->value, value, length);
|
||||
return cursor + recordSize;
|
||||
}
|
||||
|
||||
static inline u8* atermAppendLongOption(AtermRequestOption16* option, u16 type, u16 length, const void* value) {
|
||||
option = memset(option, 0, 4);
|
||||
option->type = SOHtoNs(type);
|
||||
option->length = SOHtoNs(length);
|
||||
memset(option->value, 0, sizeof(option->value));
|
||||
memcpy(option->value, value, length);
|
||||
return (u8*)(option + 1);
|
||||
}
|
||||
|
||||
s32 ATERMRunConfigProtocol(void) {
|
||||
OSMessageQueue waitQueue;
|
||||
OSMessage waitBuffer[1];
|
||||
@@ -1395,29 +1440,20 @@ s32 ATERMRunConfigProtocol(void) {
|
||||
OSAlarm waitAlarm;
|
||||
AtermSocketAddress socketBindAddress;
|
||||
AtermSocketAddress peerAddress;
|
||||
AtermAssociationRequest* request;
|
||||
AtermDecodedPayload* response;
|
||||
AtermPacket* packet;
|
||||
AtermSession* session;
|
||||
s32 socket;
|
||||
s32 result;
|
||||
s32 failed;
|
||||
s32 retries;
|
||||
u32 lastSendTime;
|
||||
AtermThreadBuffer* response = (AtermThreadBuffer*)&gAtermConfigurationResult.responseLength;
|
||||
void* sessionKey = gAtermResponseBuffer.session.keyMaterial;
|
||||
AtermMd5Context digestContext;
|
||||
u8 digestLength[8];
|
||||
s32 socket = 0;
|
||||
s32 result = -5;
|
||||
s32 failed = 0;
|
||||
s32 retries = 0;
|
||||
u32 lastSendTime = 0;
|
||||
u32 now;
|
||||
s32 receivedLength;
|
||||
u32 reciprocal = 0x10624DD3;
|
||||
|
||||
gAtermProtocolState = 1;
|
||||
request = &gAtermAssociationRequest;
|
||||
packet = (AtermPacket*)gAtermPacketBuffer;
|
||||
response = &gAtermDecodedResponse;
|
||||
session = &gAtermSession;
|
||||
socket = 0;
|
||||
result = -5;
|
||||
lastSendTime = 0;
|
||||
retries = 0;
|
||||
failed = 0;
|
||||
while (failed == 0 && gAtermCancelRequested == 0) {
|
||||
OSInitMessageQueue(&waitQueue, waitBuffer, 1);
|
||||
OSCreateAlarm(&waitAlarm);
|
||||
@@ -1490,11 +1526,11 @@ s32 ATERMRunConfigProtocol(void) {
|
||||
break;
|
||||
}
|
||||
peerAddress.length = 8;
|
||||
ATERMBuildAssociationRequest(request, &peerAddress);
|
||||
receivedLength = SORecvFrom(socket, gAtermPacketBuffer,
|
||||
sizeof(gAtermPacketBuffer), 4, &peerAddress);
|
||||
ATERMBuildAssociationRequest((AtermAssociationRequest*)gAtermConfigurationResult.connectionPrefix);
|
||||
receivedLength = SORecvFrom(socket, gAtermConfigurationResult.packetBuffer,
|
||||
sizeof(gAtermConfigurationResult.packetBuffer), 4, &peerAddress);
|
||||
if (receivedLength > 0 &&
|
||||
ATERMParsePacket((AtermPacket*)gAtermPacketBuffer, &gAtermResponseMode)) {
|
||||
ATERMParsePacket((AtermPacket*)gAtermConfigurationResult.packetBuffer, &gAtermResponseMode)) {
|
||||
AtermProgress progress;
|
||||
gAtermDeadline = (u32)(OSGetTime() / (__mulhwu(reciprocal, OS_BUS_CLOCK >> 2) >> 6)) + 30000;
|
||||
gAtermProtocolState = 5;
|
||||
@@ -1511,30 +1547,55 @@ s32 ATERMRunConfigProtocol(void) {
|
||||
break;
|
||||
case 5:
|
||||
{
|
||||
u8* optionEnd = gAtermRequestOptions;
|
||||
AtermRequestOption16* longOptions;
|
||||
u16 enabled = SOHtoNs(1);
|
||||
u8 optionIds[7] = {6, 0, 1, 2, 3, 4, 5};
|
||||
AtermRequestOption8* shortOption = (AtermRequestOption8*)gAtermRequestOptions;
|
||||
AtermRequestOption16* longOption;
|
||||
u16 enabled = SOHtoNs(1);
|
||||
AtermSocketAddress sendAddress;
|
||||
s32 messageLength;
|
||||
optionEnd = atermAppendOption(optionEnd, 1, 2, &enabled);
|
||||
optionEnd = atermAppendOption(optionEnd, 2, 2, &enabled);
|
||||
u8* optionEnd;
|
||||
memset(shortOption, 0, 4);
|
||||
shortOption->type = SOHtoNs(1);
|
||||
shortOption->length = SOHtoNs(2);
|
||||
memset(shortOption->value, 0, sizeof(shortOption->value));
|
||||
memcpy(shortOption->value, &enabled, sizeof(enabled));
|
||||
shortOption++;
|
||||
memset(shortOption, 0, 4);
|
||||
shortOption->type = SOHtoNs(2);
|
||||
shortOption->length = SOHtoNs(2);
|
||||
memset(shortOption->value, 0, sizeof(shortOption->value));
|
||||
memcpy(shortOption->value, &enabled, sizeof(enabled));
|
||||
shortOption++;
|
||||
if (gAtermResponseMode != 0) {
|
||||
optionEnd = atermAppendOption(optionEnd, 5, 2, &enabled);
|
||||
memset(shortOption, 0, 4);
|
||||
shortOption->type = SOHtoNs(5);
|
||||
shortOption->length = SOHtoNs(2);
|
||||
memset(shortOption->value, 0, sizeof(shortOption->value));
|
||||
memcpy(shortOption->value, &enabled, sizeof(enabled));
|
||||
shortOption++;
|
||||
}
|
||||
longOptions = (AtermRequestOption16*)optionEnd;
|
||||
optionEnd = atermAppendLongOption(longOptions, 3, sizeof(optionIds), optionIds);
|
||||
longOption = (AtermRequestOption16*)shortOption;
|
||||
memset(longOption, 0, 4);
|
||||
longOption->type = SOHtoNs(3);
|
||||
longOption->length = SOHtoNs(7);
|
||||
memset(longOption->value, 0, sizeof(longOption->value));
|
||||
memcpy(longOption->value, optionIds, sizeof(optionIds));
|
||||
longOption++;
|
||||
if (gAtermResponseMode != 0) {
|
||||
optionEnd = atermAppendLongOption(longOptions + 1, 4, 6, gAtermAddressBuffer);
|
||||
memset(longOption, 0, 4);
|
||||
longOption->type = SOHtoNs(4);
|
||||
longOption->length = SOHtoNs(6);
|
||||
memset(longOption->value, 0, sizeof(longOption->value));
|
||||
memcpy(longOption->value, gAtermAddressBuffer, 6);
|
||||
longOption++;
|
||||
}
|
||||
messageLength = ATERMBuildEncryptedMessage((u16*)gAtermPacketBuffer, 2,
|
||||
(u16*)response, optionEnd - gAtermRequestOptions + 8, NULL);
|
||||
gAtermMessageLength = messageLength;
|
||||
optionEnd = (u8*)longOption;
|
||||
gAtermMessageLength = ATERMBuildEncryptedMessage((u16*)gAtermConfigurationResult.packetBuffer, 2,
|
||||
(u16*)response->data, optionEnd - gAtermRequestOptions + 8, NULL);
|
||||
sendAddress.length = 8;
|
||||
sendAddress.family = 2;
|
||||
sendAddress.address = 0xFFFFFFFF;
|
||||
sendAddress.port = SOHtoNs(0xE601);
|
||||
SOSendTo(socket, gAtermPacketBuffer, messageLength, 0, &sendAddress);
|
||||
SOSendTo(socket, gAtermConfigurationResult.packetBuffer, gAtermMessageLength, 0, &sendAddress);
|
||||
lastSendTime = (u32)(OSGetTime() / (__mulhwu(reciprocal, OS_BUS_CLOCK >> 2) >> 6));
|
||||
gAtermProtocolState = 6;
|
||||
break;
|
||||
@@ -1547,38 +1608,36 @@ s32 ATERMRunConfigProtocol(void) {
|
||||
failed = 1;
|
||||
break;
|
||||
}
|
||||
receivedLength = SORecvFrom(socket, gAtermPacketBuffer,
|
||||
sizeof(gAtermPacketBuffer), 4, &peerAddress);
|
||||
receivedLength = SORecvFrom(socket, gAtermConfigurationResult.packetBuffer,
|
||||
sizeof(gAtermConfigurationResult.packetBuffer), 4, &peerAddress);
|
||||
if (receivedLength > 0) {
|
||||
u32 checksum = 0;
|
||||
AtermPacket* packet = (AtermPacket*)gAtermConfigurationResult.packetBuffer;
|
||||
s32 sequence = SONtoHs(packet->sequence);
|
||||
s32 payloadLength = SONtoHs(packet->length);
|
||||
u8* cursor = (u8*)packet;
|
||||
u32 checksum = 0;
|
||||
u8* cursor = gAtermConfigurationResult.packetBuffer;
|
||||
u8* packetEnd = packet->payload + payloadLength;
|
||||
u8* payload;
|
||||
u16 packetChecksum;
|
||||
u8* payload = packet->payload;
|
||||
for (; cursor < packetEnd; cursor++) {
|
||||
checksum += *cursor;
|
||||
}
|
||||
packetChecksum = SONtoHs(*(u16*)packetEnd);
|
||||
payload = packet->payload;
|
||||
if ((u16)checksum != packetChecksum) {
|
||||
if ((u16)checksum != SONtoHs(*(u16*)packetEnd)) {
|
||||
payload = NULL;
|
||||
}
|
||||
if (payload == NULL) {
|
||||
payloadLength = 0;
|
||||
} else if (sequence != 3) {
|
||||
payloadLength = 0;
|
||||
} else if (gAtermAssociationRequest.keyMaterial != NULL) {
|
||||
ATERMAesKeyUnwrap((u16*)response, (u16*)payload,
|
||||
payloadLength, gAtermAssociationRequest.keyMaterial, 16);
|
||||
} else if (gAtermConfigurationResult.connectionPrefix != NULL) {
|
||||
ATERMAesKeyUnwrap((u16*)response->authentication.payload, (u16*)payload,
|
||||
payloadLength, gAtermConfigurationResult.connectionPrefix, 16);
|
||||
payloadLength -= 8;
|
||||
} else {
|
||||
memcpy(response, payload, payloadLength);
|
||||
memcpy(response->authentication.payload, payload, payloadLength);
|
||||
}
|
||||
if (payloadLength != 0) {
|
||||
AtermPacketOption* option = (AtermPacketOption*)response->options;
|
||||
u8* optionEnd = (u8*)option + SONtoHs(response->length);
|
||||
AtermPacketOption* option = (AtermPacketOption*)response->authentication.decoded.options;
|
||||
u8* optionEnd = (u8*)option + SONtoHs(response->authentication.decoded.length);
|
||||
s32 optionType;
|
||||
u8* optionValue;
|
||||
if ((u8*)option >= optionEnd) {
|
||||
@@ -1588,26 +1647,24 @@ s32 ATERMRunConfigProtocol(void) {
|
||||
SONtoHs(option->length);
|
||||
optionValue = option->value;
|
||||
}
|
||||
if (optionType != 0x101) {
|
||||
if (optionValue == NULL || optionType != 0x101) {
|
||||
break;
|
||||
}
|
||||
{
|
||||
AtermProgress progress;
|
||||
AtermMd5Context digestContext;
|
||||
u8 digestLength[8];
|
||||
u32 authenticationTime = (u32)(OSGetTime() /
|
||||
(__mulhwu(reciprocal, OS_BUS_CLOCK >> 2) >> 6));
|
||||
u32 index;
|
||||
u32 digestBytes;
|
||||
AtermSession* authentication;
|
||||
authentication = memcpy(session->challenge, optionValue, 8);
|
||||
memcpy(response->authentication.challenge,
|
||||
optionValue, 8);
|
||||
digestContext.bitCountHigh = 0;
|
||||
digestContext.bitCountLow = 0;
|
||||
digestContext.state[0] = 0x67452301;
|
||||
digestContext.state[1] = 0xEFCDAB89;
|
||||
digestContext.state[2] = 0x98BADCFE;
|
||||
digestContext.state[3] = 0x10325476;
|
||||
ATERMMd5Update(&digestContext, (u8*)&authenticationTime, sizeof(authenticationTime));
|
||||
ATERMMd5Update(&digestContext, &authenticationTime, sizeof(authenticationTime));
|
||||
digestLength[0] = digestContext.bitCountLow;
|
||||
digestLength[1] = digestContext.bitCountLow >> 8;
|
||||
digestLength[2] = digestContext.bitCountLow >> 16;
|
||||
@@ -1620,15 +1677,27 @@ s32 ATERMRunConfigProtocol(void) {
|
||||
ATERMMd5Update(&digestContext, gAtermDigestFill,
|
||||
digestBytes < 56 ? 56 - digestBytes : 120 - digestBytes);
|
||||
ATERMMd5Update(&digestContext, digestLength, sizeof(digestLength));
|
||||
for (index = 0; index < 4; index++) {
|
||||
u32 word = digestContext.state[index];
|
||||
authentication->digest[index * 4] = word;
|
||||
authentication->digest[index * 4 + 1] = word >> 8;
|
||||
authentication->digest[index * 4 + 2] = word >> 16;
|
||||
authentication->digest[index * 4 + 3] = word >> 24;
|
||||
}
|
||||
for (index = sizeof(digestContext); index != 0; index--) {
|
||||
((u8*)&digestContext)[index - 1] = 0;
|
||||
response->authentication.digest[0] = digestContext.state[0];
|
||||
response->authentication.digest[1] = digestContext.state[0] >> 8;
|
||||
response->authentication.digest[2] = digestContext.state[0] >> 16;
|
||||
response->authentication.digest[3] = digestContext.state[0] >> 24;
|
||||
response->authentication.digest[4] = digestContext.state[1];
|
||||
response->authentication.digest[5] = digestContext.state[1] >> 8;
|
||||
response->authentication.digest[6] = digestContext.state[1] >> 16;
|
||||
response->authentication.digest[7] = digestContext.state[1] >> 24;
|
||||
response->authentication.digest[8] = digestContext.state[2];
|
||||
response->authentication.digest[9] = digestContext.state[2] >> 8;
|
||||
response->authentication.digest[10] = digestContext.state[2] >> 16;
|
||||
response->authentication.digest[11] = digestContext.state[2] >> 24;
|
||||
response->authentication.digest[12] = digestContext.state[3];
|
||||
response->authentication.digest[13] = digestContext.state[3] >> 8;
|
||||
response->authentication.digest[14] = digestContext.state[3] >> 16;
|
||||
response->authentication.digest[15] = digestContext.state[3] >> 24;
|
||||
{
|
||||
u8* contextByte = (u8*)&digestContext;
|
||||
for (index = 0; index < sizeof(digestContext); index++) {
|
||||
*contextByte++ = 0;
|
||||
}
|
||||
}
|
||||
gAtermProtocolState = 7;
|
||||
gAtermState = 5;
|
||||
@@ -1649,62 +1718,58 @@ s32 ATERMRunConfigProtocol(void) {
|
||||
break;
|
||||
case 7:
|
||||
{
|
||||
AtermRequestOption16* option = (AtermRequestOption16*)response->options;
|
||||
AtermRequestOption16* option = (AtermRequestOption16*)response->authentication.decoded.options;
|
||||
AtermSocketAddress sendAddress;
|
||||
s32 messageLength;
|
||||
memset(response, 0, 8);
|
||||
memset(response->data, 0, 8);
|
||||
memset(option, 0, 4);
|
||||
option->type = SOHtoNs(0x102);
|
||||
option->length = SOHtoNs(8);
|
||||
memset(option->value, 0, sizeof(option->value));
|
||||
memcpy(option->value, session->digest, 8);
|
||||
gAtermReplyLength = (u8*)(option + 1) - (u8*)response;
|
||||
response->length = gAtermReplyLength - 8;
|
||||
messageLength = ATERMBuildEncryptedMessage((u16*)gAtermPacketBuffer, 4,
|
||||
(u16*)response, gAtermReplyLength, gAtermAssociationRequest.keyMaterial);
|
||||
gAtermMessageLength = messageLength;
|
||||
memcpy(option->value, response->authentication.digest, 8);
|
||||
gAtermReplyLength = (u8*)(option + 1) - response->data;
|
||||
response->authentication.decoded.length = gAtermReplyLength - 8;
|
||||
gAtermMessageLength = ATERMBuildEncryptedMessage((u16*)gAtermConfigurationResult.packetBuffer, 4,
|
||||
(u16*)response->data, gAtermReplyLength, gAtermConfigurationResult.connectionPrefix);
|
||||
sendAddress.length = 8;
|
||||
sendAddress.family = 2;
|
||||
sendAddress.address = 0xFFFFFFFF;
|
||||
sendAddress.port = SOHtoNs(0xE601);
|
||||
SOSendTo(socket, gAtermPacketBuffer, messageLength, 0, &sendAddress);
|
||||
SOSendTo(socket, gAtermConfigurationResult.packetBuffer, gAtermMessageLength, 0, &sendAddress);
|
||||
lastSendTime = (u32)(OSGetTime() / (__mulhwu(reciprocal, OS_BUS_CLOCK >> 2) >> 6));
|
||||
memset(&gScanSettings, 0, 0x254);
|
||||
gAtermProtocolState = 8;
|
||||
break;
|
||||
}
|
||||
case 8:
|
||||
receivedLength = SORecvFrom(socket, gAtermPacketBuffer,
|
||||
sizeof(gAtermPacketBuffer), 4, &peerAddress);
|
||||
receivedLength = SORecvFrom(socket, gAtermConfigurationResult.packetBuffer,
|
||||
sizeof(gAtermConfigurationResult.packetBuffer), 4, &peerAddress);
|
||||
if (receivedLength > 0) {
|
||||
u32 checksum = 0;
|
||||
AtermPacket* packet = (AtermPacket*)gAtermConfigurationResult.packetBuffer;
|
||||
s32 sequence = SONtoHs(packet->sequence);
|
||||
s32 payloadLength = SONtoHs(packet->length);
|
||||
u8* cursor = (u8*)packet;
|
||||
u32 checksum = 0;
|
||||
u8* cursor = gAtermConfigurationResult.packetBuffer;
|
||||
u8* packetEnd = packet->payload + payloadLength;
|
||||
u8* payload;
|
||||
u16 packetChecksum;
|
||||
u8* payload = packet->payload;
|
||||
for (; cursor < packetEnd; cursor++) {
|
||||
checksum += *cursor;
|
||||
}
|
||||
packetChecksum = SONtoHs(*(u16*)packetEnd);
|
||||
payload = packet->payload;
|
||||
if ((u16)checksum != packetChecksum) {
|
||||
if ((u16)checksum != SONtoHs(*(u16*)packetEnd)) {
|
||||
payload = NULL;
|
||||
}
|
||||
if (payload == NULL) {
|
||||
payloadLength = 0;
|
||||
} else if (sequence != 5) {
|
||||
payloadLength = 0;
|
||||
} else if (session->keyMaterial != NULL) {
|
||||
ATERMAesKeyUnwrap((u16*)response, (u16*)payload,
|
||||
payloadLength, session->keyMaterial, 16);
|
||||
} else if (sessionKey != NULL) {
|
||||
ATERMAesKeyUnwrap((u16*)response->authentication.payload, (u16*)payload,
|
||||
payloadLength, sessionKey, 16);
|
||||
payloadLength -= 8;
|
||||
} else {
|
||||
memcpy(response, payload, payloadLength);
|
||||
memcpy(response->authentication.payload, payload, payloadLength);
|
||||
}
|
||||
gAtermReplyLength = payloadLength;
|
||||
if (payloadLength != 0 && ATERMParseAssociationResponse((u16*)response)) {
|
||||
if (payloadLength != 0 && ATERMParseAssociationResponse((u16*)response->data)) {
|
||||
gAtermProtocolState = 9;
|
||||
retries = 0;
|
||||
gAtermMode = gScanSettings.ssid[0] != 0;
|
||||
@@ -1724,20 +1789,18 @@ s32 ATERMRunConfigProtocol(void) {
|
||||
break;
|
||||
case 9:
|
||||
{
|
||||
AtermRequestOption8* option = (AtermRequestOption8*)response->options;
|
||||
AtermRequestOption8* option = (AtermRequestOption8*)response->authentication.decoded.options;
|
||||
AtermSocketAddress sendAddress;
|
||||
s32 messageLength;
|
||||
memset(response, 0, 8);
|
||||
memset(response->data, 0, 8);
|
||||
memset(option, 0, 4);
|
||||
option->type = SOHtoNs(0x301);
|
||||
option->length = SOHtoNs(1);
|
||||
memset(option->value, 0, sizeof(option->value));
|
||||
memcpy(option->value, &gAtermMode, 1);
|
||||
gAtermReplyLength = (u8*)(option + 1) - (u8*)response;
|
||||
response->length = gAtermReplyLength - 8;
|
||||
messageLength = ATERMBuildEncryptedMessage((u16*)gAtermPacketBuffer, 6,
|
||||
(u16*)response, gAtermReplyLength, session->keyMaterial);
|
||||
gAtermMessageLength = messageLength;
|
||||
gAtermReplyLength = (u8*)(option + 1) - response->data;
|
||||
response->authentication.decoded.length = gAtermReplyLength - 8;
|
||||
gAtermMessageLength = ATERMBuildEncryptedMessage((u16*)gAtermConfigurationResult.packetBuffer, 6,
|
||||
(u16*)response->data, gAtermReplyLength, sessionKey);
|
||||
if (NCDGetLinkStatus() != 5) {
|
||||
lastSendTime = (u32)(OSGetTime() / (__mulhwu(reciprocal, OS_BUS_CLOCK >> 2) >> 6)) + 1000;
|
||||
retries = 10;
|
||||
@@ -1748,7 +1811,7 @@ s32 ATERMRunConfigProtocol(void) {
|
||||
sendAddress.family = 2;
|
||||
sendAddress.address = 0xFFFFFFFF;
|
||||
sendAddress.port = SOHtoNs(0xE601);
|
||||
SOSendTo(socket, gAtermPacketBuffer, messageLength, 0, &sendAddress);
|
||||
SOSendTo(socket, gAtermConfigurationResult.packetBuffer, gAtermMessageLength, 0, &sendAddress);
|
||||
lastSendTime = (u32)(OSGetTime() / (__mulhwu(reciprocal, OS_BUS_CLOCK >> 2) >> 6));
|
||||
gAtermProtocolState = 10;
|
||||
break;
|
||||
@@ -2262,17 +2325,12 @@ void ATERMAesDecryptBlock(const u32* expandedKey, u32 rounds, const u8* input, u
|
||||
|
||||
void ATERMMd5Transform(u32 state[4], const u8 block[64]);
|
||||
|
||||
static inline void atermMd5Copy(void* output, const void* input, u32 length) {
|
||||
u32 index;
|
||||
for (index = 0; index < length; index++) {
|
||||
((u8*)output)[index] = ((const u8*)input)[index];
|
||||
}
|
||||
}
|
||||
|
||||
void ATERMMd5Update(AtermMd5Context* context, u8* input, u32 length) {
|
||||
void ATERMMd5Update(AtermMd5Context* context, void* input, u32 length) {
|
||||
u8* data = (u8*)input;
|
||||
u32 bufferIndex = (context->bitCountLow >> 3) & 0x3F;
|
||||
u32 bytesToFill;
|
||||
u32 copiedBytes;
|
||||
u32 index;
|
||||
|
||||
context->bitCountLow += length << 3;
|
||||
if (context->bitCountLow < (length << 3)) {
|
||||
@@ -2281,16 +2339,20 @@ void ATERMMd5Update(AtermMd5Context* context, u8* input, u32 length) {
|
||||
context->bitCountHigh += length >> 29;
|
||||
bytesToFill = 64 - bufferIndex;
|
||||
if (length >= bytesToFill) {
|
||||
atermMd5Copy(&context->buffer8[bufferIndex], input, bytesToFill);
|
||||
for (copiedBytes = 0; copiedBytes < bytesToFill; copiedBytes++) {
|
||||
context->buffer8[bufferIndex + copiedBytes] = data[copiedBytes];
|
||||
}
|
||||
ATERMMd5Transform(context->state, context->buffer8);
|
||||
for (copiedBytes = bytesToFill; copiedBytes + 63 < length; copiedBytes += 64) {
|
||||
ATERMMd5Transform(context->state, input + copiedBytes);
|
||||
ATERMMd5Transform(context->state, data + copiedBytes);
|
||||
}
|
||||
bufferIndex = 0;
|
||||
} else {
|
||||
copiedBytes = 0;
|
||||
}
|
||||
atermMd5Copy(&context->buffer8[bufferIndex], &input[copiedBytes], length - copiedBytes);
|
||||
for (index = 0; index < length - copiedBytes; index++) {
|
||||
context->buffer8[bufferIndex + index] = data[copiedBytes + index];
|
||||
}
|
||||
}
|
||||
|
||||
#define ATERM_MD5_STEP(A, B, C, D, WORD, CONSTANT, SHIFT, F) \
|
||||
@@ -2526,7 +2588,7 @@ int ATERMi_ApConfigGetVersion(void) {
|
||||
return 0x106;
|
||||
}
|
||||
|
||||
u8* gAtermRequestOptions = gAtermDecodedResponse.options;
|
||||
u8* gAtermRequestOptions = gAtermResponseBuffer.data;
|
||||
|
||||
u32 gAtermUseSharedAddress = 1;
|
||||
char gAtermProductName[5] = "WARP";
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user