Compare commits

...

6 Commits

Author SHA1 Message Date
Devin AI
adc268a27f axfx: decompile AXFXReverbHiExpDpl2, AXFXReverbStdExp, AXFXChorusExp
AXFXReverbHiExpDpl2 and AXFXReverbStdExp: whole-unit 100%, flipped to
Matching (DOL hash verified). AXFXChorusExp stays NonMatching: 6/7 fns
byte-exact, __InitParams has a 1-insn fmuls operand-order tie-break
(upstream reconstruction emits the same order).

Co-Authored-By: wch <usernamecole7@gmail.com>
2026-09-30 06:08:43 +00:00
coah
b1fd404137 Improve iplBoard and iplChannelSelect matching (#223)
* feat: improve iplBoard matching

Restructure calc, stt_wait_fadeaway and edge_arrow with early returns
and split conditions, iterate hovered objects with an explicit next
pointer, and add the VEC3 add helper used by calc_board_object. 93/94
functions now match; appendRecord still differs because the original
keeps the interrupt state on the stack.

Ported from agent/continue0923/src_scene_board_iplboard without its
string-pool and volatile workarounds.

* feat: improve iplChannelSelect matching

Build the constructor with an initializer list, specialize
HermiteIntp<VEC3>::get and HermiteIntp<f32>::get in the forms this unit
inlines, keep only the three zoom frames setChanZoomOrtho reads, compute
the drag delta as a VEC2 with an explicit zero-speed branch, and give
setChannelScissor its ortho bounds as named locals. 101/102 functions
now match.

Ported from agent/continue0923/src_scene_channelselect_iplchannelselect
without its IPL_CHANNEL_TITLE_NOVTABLE define, hand-placed lbl_ data,
volatile constant loads or register keywords.
2026-09-28 00:09:53 -05:00
coah
9a9f937e9e fix: link RevoEX ncdsystem (#222)
NCDiGetWirelessMacAddress is global in the original (net/wireless_macaddr.c
calls it), and the two .sbss statics are defined in reverse so MWCC emits
ncdInitialized first.
2026-09-28 00:05:58 -05:00
coah
0792087bf1 Salvage CDBAttr, CDBSystem, nand_drv, iplGraphics and RFL_NANDAccess matches (#221)
* feat: match CDBAttr unit

Make CDBAttrGetDescOffset static and fold the IV generation into
CDBAttrInitIV with a function-local seed, then link the unit.

Salvaged from agent/hard0928/clibs.

* feat: match CDBSystem unit

Implement the database and record pool functions, give the CDB work
buffer pointer a real name (shared with CDBDatabase), size s_mutex as a
plain OSMutex, and link the unit.

Salvaged from agent/hard0928/clibs.

* feat: match VF develop nand_drv unit

Make the NAND write/seek/create/delete wrappers inline so they fold into
_CreatePrfFile, test the override callbacks directly, fix the order of
the retry and sleep globals, size l_nandFunc without the trailing
padding, and link the unit. _MountPrfFile stays the existing asm.

Salvaged from agent/hard0928/clibs and
agent/continue0923/libs_revoex_src_vf_develop_nand_drv.

* feat: match iplGraphics unit

Compute the ortho projection bounds in the original order, size
Graphics::mArg without the trailing .bss padding, and link the unit.

Salvaged from agent/continue0923/src_utility_iplgraphics (without its
struct padding member).

* feat: complete RFL_NANDAccess data

Inline the NAND command block helpers so they no longer leave extab
entries, bringing extabindex to 100%.

Salvaged from agent/continue0924/rfl-nandaccess-data.

* feat: add eZiText zkokeyp source

Decompile the Korean keypad candidate functions. The unit stays
NonMatching: Zi8_81483118 matches exactly and the rest differ only by
register allocation or larger control-flow differences.

Salvaged from agent/hard0928/clibs.
2026-09-28 00:00:39 -05:00
coah
1542f73080 feat: link tiPredictLang unit (#220)
Declare the predictlang Sample class with its inline constructors so the
LayoutByNW4R thunks are emitted in the original order, and link the unit.
2026-09-27 23:50:01 -05:00
coah
d51e34beb2 Link iplLetterWriter as matching (#219)
Use string literals instead of hand-placed pool arrays so sendToPC addresses the pool base, emit calcFadeout before onEventDerived, and force-active the NigaoeEventObserver vtable that the original link keeps.
2026-09-27 23:47:34 -05:00
26 changed files with 2291 additions and 250 deletions

View File

@@ -20,6 +20,7 @@ force_active:
- padding__Q23ipl5scene
- lbl_81695063
- lbl_81695067
- __vt__Q49textinput6extend4memo19NigaoeEventObserver
# textinput::toolbar::csPaneToAnimation points one past the end of csAninationFile.
block_relocations:

View File

@@ -7,7 +7,7 @@ mMac__Q33ipl6socket13SocketSetting = .bss:0x81089720; // type:object size:0x40
_database__7LibTVRC = .bss:0x81089760; // type:object size:0x20 data:4byte
_alarm__7LibTVRC = .bss:0x81089780; // type:object size:0x30
_tickWait__7LibTVRC = .bss:0x810897B0; // type:object size:0x10 data:4byte
mArg__Q33ipl7utility8Graphics = .bss:0x810897C0; // type:object size:0x88
mArg__Q33ipl7utility8Graphics = .bss:0x810897C0; // type:object size:0x84
unk__Q23ipl3snd = .bss:0x81089848; // type:object size:0xC
_seBlk__Q23ipl3snd = .bss:0x81089854; // type:object size:0xD8 data:4byte
sSystem__Q23ipl3snd = .bss:0x8108992C; // type:object size:0x63C data:4byte
@@ -123,7 +123,7 @@ CDB_SD_ROOT_PATH_LS = .bss:0x810C8A08; // type:object size:0x20
CDB_SD_VFF_FILE_NAME = .bss:0x810C8A28; // type:object size:0x48
lbl_810C8A80 = .bss:0x810C8A80; // type:object size:0x40 align:32
lbl_810C8AC0 = .bss:0x810C8AC0; // type:object size:0x40 align:32
s_mutex = .bss:0x810C8B00; // type:object size:0x20 scope:local
s_mutex = .bss:0x810C8B00; // type:object size:0x18 scope:local
s_cdbWiiId = .bss:0x810C8B20; // type:object size:0x40 scope:local
ncdMutex = .bss:0x810C8B60; // type:object size:0x20
ncdCommonResult = .bss:0x810C8B80; // type:object size:0x20 align:32 data:4byte
@@ -161,7 +161,7 @@ l_dev_init_info_table = .bss:0x810F55C0; // type:object size:0xD0 scope:local
l_tmpWName = .bss:0x810F5690; // type:object size:0x10 scope:local data:2byte
hashTable = .bss:0x810F56A0; // type:object size:0x22E scope:local data:byte
l_driveInfo = .bss:0x810F58D0; // type:object size:0x208 scope:local data:4byte
l_nandFunc = .bss:0x810F5AD8; // type:object size:0x1A8 scope:local
l_nandFunc = .bss:0x810F5AD8; // type:object size:0x1A0 scope:local
l_event = .bss:0x810F5C80; // type:object size:0x340 scope:local
l_sddrv_info = .bss:0x810F5FC0; // type:object size:0x80 scope:local
sZeroBuffer__Q44nw4r3snd6detail9AxManager = .bss:0x810F6040; // type:object size:0x100
@@ -23523,7 +23523,7 @@ s_fatalVFFlag = .sbss:0x81698D7C; // type:object size:0x4 scope:local data:4byte
CDBPrintDebugLevel = .sbss:0x81698D80; // type:object size:0x4 data:4byte
s_lastNANDError = .sbss:0x81698D84; // type:object size:0x4 scope:local data:4byte
s_lastVFError = .sbss:0x81698D88; // type:object size:0x4 scope:local data:4byte
lbl_81698D8C = .sbss:0x81698D8C; // type:object size:0x4 scope:local data:4byte
CDBDatabaseWorkBuf = .sbss:0x81698D8C; // type:object size:0x4 data:4byte
s_recordPool = .sbss:0x81698D90; // type:object size:0x4 scope:local data:4byte
s_databasePool = .sbss:0x81698D94; // type:object size:0x4 scope:local data:4byte
lbl_81698D98 = .sbss:0x81698D98; // type:object size:0x4 data:4byte

View File

@@ -671,7 +671,7 @@ config.libs = [
Object(Matching, "utility/iplTVRCUtils.cpp"),
Object(Matching, "utility/iplTree.cpp"),
Object(Matching, "utility/iplFrameController.cpp"),
Object(Equivalent, "utility/iplGraphics.cpp"),
Object(Matching, "utility/iplGraphics.cpp"),
Object(Matching, "utility/iplCapture.cpp"),
Object(Matching, "utility/iplUtility.cpp"),
Object(Matching, "utility/iplThread.cpp"),
@@ -788,7 +788,7 @@ config.libs = [
]
),
IPLSection("letterWriter", [
Object(Equivalent, "scene/letterWriter/iplLetterWriter.cpp"),
Object(Matching, "scene/letterWriter/iplLetterWriter.cpp"),
]
),
IPLSection("limitOver", [
@@ -912,7 +912,7 @@ config.libs = [
Object(NonMatching, "keyboard/tiInputForm.cpp", extra_cflags=["-O4,p"]),
Object(NonMatching, "keyboard/tiCandidateBox.cpp", extra_cflags=["-O4,p"]),
Object(Matching, "keyboard/tiToolBar.cpp", extra_cflags=["-O4,p"]),
Object(NonMatching, "keyboard/tiPredictLang.cpp", extra_cflags=["-O4,p"]),
Object(Matching, "keyboard/tiPredictLang.cpp", extra_cflags=["-O4,p"]),
Object(NonMatching, "keyboard/tiSignWindow.cpp", extra_cflags=["-O4,p"]),
Object(NonMatching, "keyboard/tiString.cpp", extra_cflags=["-O4,p"]),
Object(NonMatching, "keyboard/tiAtokString.cpp", extra_cflags=["-O4,p"]), # for 4.3J
@@ -1025,8 +1025,8 @@ config.libs = [
Object(Matching, "cdb/CDBRecordFile.c"),
Object(Matching, "cdb/CDBRecordKey.c"),
Object(NonMatching, "cdb/CDBIntArray.c"),
Object(NonMatching, "cdb/CDBSystem.c"),
Object(Equivalent, "cdb/CDBAttr.c"),
Object(Matching, "cdb/CDBSystem.c"),
Object(Matching, "cdb/CDBAttr.c"),
Object(Matching, "cdb/CDBFBridge.c"),
Object(Matching, "cdb/CDBFBridgeVF.c"),
Object(Matching, "cdb/CDBFBridgeSD.c"),
@@ -1035,7 +1035,7 @@ config.libs = [
]
),
RevoEXLib("ncd", [
Object(NonMatching, "ncd/ncdsystem.c"),
Object(Matching, "ncd/ncdsystem.c"),
Object(NonMatching, "ncd/ncdsleep.c"),
]
),
@@ -1163,7 +1163,7 @@ config.libs = [
Object(Matching, "vf/develop/d_hash.c"),
Object(Matching, "vf/develop/d_time.c"),
Object(Matching, "vf/develop/d_common.c"),
Object(NonMatching, "vf/develop/nand_drv.c"),
Object(Matching, "vf/develop/nand_drv.c"),
Object(Matching, "vf/develop/sd_drv.c"),
]
),
@@ -1447,10 +1447,10 @@ config.libs = [
Object(Matching, "axfx/AXFXReverbHi.c"),
Object(Matching, "axfx/AXFXReverbHiDpl2.c"),
Object(Matching, "axfx/AXFXReverbHiExp.c"),
Object(NonMatching, "axfx/AXFXReverbHiExpDpl2.c"),
Object(Matching, "axfx/AXFXReverbHiExpDpl2.c"),
Object(Matching, "axfx/AXFXDelay.c"),
Object(Matching, "axfx/AXFXReverbStd.c"),
Object(NonMatching, "axfx/AXFXReverbStdExp.c"),
Object(Matching, "axfx/AXFXReverbStdExp.c"),
Object(Matching, "axfx/AXFXChorus.c"),
Object(NonMatching, "axfx/AXFXChorusExp.c"),
Object(Matching, "axfx/AXFXLfoTable.c"),

View File

@@ -14,6 +14,10 @@ namespace textinput {
class Base : public CommandSender {
public:
#ifdef TI_PREDICTLANG_SAMPLE_CLASS
Base(Manager* manager) : mePredictMode(inputform::Base::PM_USEn), mpAllocator(NULL), mpManager(manager) {}
#endif
virtual void create(MEMAllocator* allocator) override { mpAllocator = allocator; }
virtual void setPredictMode(inputform::Base::PredictMode mode) { mePredictMode = mode; }
@@ -28,6 +32,12 @@ namespace textinput {
class LayoutByNW4R : public Base, public nw4rmanager::Layout, public nw4rmanager::AnmObserver {
public:
#ifdef TI_PREDICTLANG_SAMPLE_CLASS
LayoutByNW4R(Manager* manager, nw4r::lyt::MultiArcResourceAccessor* resAccessor, EventObserver* observer)
: Base(manager), nw4rmanager::Layout(resAccessor, "fs_prdicSelWidw_a.brlyt", observer), mbActive(false), mbInput(false),
mpEventHandler(NULL), meDestination(DST_US), mpCaller(NULL) {}
#endif
virtual ~LayoutByNW4R();
virtual void create(MEMAllocator* allocator) override;
virtual void init() override;
@@ -58,6 +68,15 @@ namespace textinput {
keyboard::KeyboardBase* mpCaller; // 0xD4
};
#ifdef TI_PREDICTLANG_SAMPLE_CLASS
class Sample : public LayoutByNW4R {
public:
Sample(Manager* manager, nw4r::lyt::MultiArcResourceAccessor* resAccessor, EventObserver* observer)
: LayoutByNW4R(manager, resAccessor, observer) {}
virtual ~Sample() {}
};
#endif
class EventHandler : public nw4rmanager::TiEventHandler {
public:
EventHandler(LayoutByNW4R* layout) : mpLayoutByNW4R(layout) {}

View File

@@ -133,7 +133,7 @@ void RFLiEndWorking(RFLErrcode errcode) {
RFLiEndWorkingReason(errcode, 0);
}
NANDCommandBlock* RFLiSetCommandBlock(RFLiFileType type, RFLiAsyncTag tag) {
inline NANDCommandBlock* RFLiSetCommandBlock(RFLiFileType type, RFLiAsyncTag tag) {
NANDCommandBlock* block = &RFLiGetAccInfo(type)->commandBlock;
RFLiCallbackTag* store = &RFLiGetAccInfo(type)->callbackTag;
@@ -147,7 +147,7 @@ NANDCommandBlock* RFLiSetCommandBlock(RFLiFileType type, RFLiAsyncTag tag) {
return block;
}
RFLiAsyncTag RFLiGetTag(NANDCommandBlock* block) {
inline RFLiAsyncTag RFLiGetTag(NANDCommandBlock* block) {
RFLiCallbackTag* stored;
RFLi_ASSERTLINE_NULL(block, 312);
@@ -159,7 +159,7 @@ RFLiAsyncTag RFLiGetTag(NANDCommandBlock* block) {
return stored->tag;
}
RFLiFileType RFLiGetType(NANDCommandBlock* block) {
inline RFLiFileType RFLiGetType(NANDCommandBlock* block) {
RFLiCallbackTag* stored;
RFLi_ASSERTLINE_NULL(block, 335);
@@ -171,7 +171,7 @@ RFLiFileType RFLiGetType(NANDCommandBlock* block) {
return stored->type;
}
NANDFileInfo* RFLiGetWorkingFile(RFLiFileType type) {
inline NANDFileInfo* RFLiGetWorkingFile(RFLiFileType type) {
RFLi_ASSERTLINE_RANGE(type, RFLiFileType_Database, RFLiFileType_Max, 356);
if (!RFLAvailable()) {

View File

@@ -0,0 +1,534 @@
#include <zi8clib/zierror.h>
extern ziU16 Zi8GetTableCount(ziU8 lang, ziU8 tableIdx ZI_NEED_WORK);
extern ziU32 Zi8GetTableAddress(ziU8 lang, ziU8 tableIdx ZI_NEED_WORK);
ziU32 Zi8_8148302C(ziU16 key, ziU8* table ZI_NEED_WORK) {
ziU32 value;
ziU16 count;
ziU32 i;
count = Zi8GetTableCount(ZI8_LANG_KO, 9, ZI_WORK);
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 (key == value) {
Zi8LogError(0x64, ZI_WORK);
return i;
}
}
Zi8LogError(0x96A, ZI_WORK);
return 0xFFFF;
}
void Zi8_81483118(ziGetParam* param, ziU8* output) {
ziU8 i;
for (i = 0; i < 5; i++) {
output[i] = 0;
}
switch (param->elementCount) {
case 9:
output[4] |= (ziU8)((param->elements[8] & 0xF) << 4);
case 8:
output[3] = param->elements[7] & 0xF;
case 7:
output[3] |= (ziU8)((param->elements[6] & 0xF) << 4);
case 6:
output[2] = param->elements[5] & 0xF;
case 5:
output[2] |= (ziU8)((param->elements[4] & 0xF) << 4);
case 4:
output[1] = param->elements[3] & 0xF;
case 3:
output[1] |= (ziU8)((param->elements[2] & 0xF) << 4);
case 2:
output[0] = param->elements[1] & 0xF;
case 1:
output[0] |= (ziU8)((param->elements[0] & 0xF) << 4);
case 0:
break;
}
}
ziU32 Zi8_81483264(const ziGetParam* param ZI_NEED_WORK) {
ziU8 i;
if (param->scratch == ZI8_NULL) {
Zi8LogError(0x164, ZI_WORK);
return 1;
}
for (i = 0; i < param->maxCandidates; i++) {
((ziU16*)param->scratch)[i] = 0;
}
Zi8LogError(0x64, ZI_WORK);
return 0;
}
ziU32 Zi8_81483308(ziGetParam* param, ziU16 key, ziU8* count ZI_NEED_WORK) {
ziU8 i;
Zi8LogError(0x64, ZI_WORK);
if (param->scratch == ZI8_NULL) {
Zi8ReplaceLastError(0x164, ZI_WORK);
return 1;
}
for (i = 0; i < param->maxCandidates; i++) {
if (key == ((ziU16*)param->scratch)[i]) {
return 1;
}
}
((ziU16*)param->scratch)[*count] = key;
if (++*count >= param->maxCandidates) {
*count = 0;
}
return 0;
}
ziBool Zi8_814833F0(const ziGetParam* param, ziU16 key ZI_NEED_WORK) {
ziU8 i;
Zi8LogError(0x64, ZI_WORK);
if (param->scratch == ZI8_NULL) {
Zi8ReplaceLastError(0x164, ZI_WORK);
return 0;
}
for (i = 0; i < param->maxCandidates; i++) {
if (key == ((ziU16*)param->scratch)[i]) {
return 1;
}
}
return 0;
}
ziU32 Zi8_814834AC(ziGetParam* param, ziU16* remaining, ziU8* count,
ziU8* inserted ZI_NEED_WORK) {
ziBool matches;
ziS32 entry;
ziS32 tableA;
ziS32 tableB;
ziU16 tableCount;
ziU8 matched;
ziU32 j;
ziS32 i;
ziU8 candidateIndex;
union {
ziU32 words[13];
ziU8 bytes[52];
} local;
matched = 0;
local.words[0] = 0;
local.bytes[4] = 0;
Zi8LogError(0x64, ZI_WORK);
if (param->elementCount == 0) {
if (*remaining >= *count) {
for (i = 0; i < *count; i++) {
Zi8_81483308(param, param->candidates[i], inserted, ZI_WORK);
}
*remaining = *remaining - *count;
*count = 0;
} else {
for (i = 0; i < *remaining; i++) {
Zi8_81483308(param, param->candidates[i], inserted, ZI_WORK);
}
for (i = 0; i < ((ziS32)*count - (ziS32)*remaining); i++) {
param->candidates[i] = param->candidates[(ziU32)*remaining + i];
}
*count = *count - (ziU8)*remaining;
*remaining = 0;
}
return 1;
} else if (param->elementCount <= 9) {
tableA = Zi8GetTableAddress(param->language, 9, ZI_WORK);
tableB = Zi8GetTableAddress(param->language, 10, ZI_WORK);
if (tableA == 0) {
Zi8ReplaceLastError(0x76C, ZI_WORK);
return 0;
} else if (tableB == 0) {
Zi8ReplaceLastError(0x776, ZI_WORK);
return 0;
} else {
tableCount = Zi8GetTableCount(ZI8_LANG_KO, 9, ZI_WORK);
Zi8_81483118(param, local.bytes);
i = 0;
while (i < tableCount && matched < *count) {
matches = ZI8_TRUE;
entry = (i << 3) + tableA + i;
j = 0;
if (param->elementCount > 1) {
for (j = 0; (j & 0xFF) < (ziU32)(param->elementCount >> 1); j++) {
if (local.bytes[j & 0xFF] != *((ziU8*)entry + (j & 0xFF))) {
matches = ZI8_FALSE;
break;
}
}
}
if (matches && (param->elementCount & 1) != 0 &&
((local.bytes[j & 0xFF] & 0xF0) != (*((ziU8*)entry + (j & 0xFF)) & 0xF0))) {
matches = ZI8_FALSE;
}
if (matches) {
for (candidateIndex = 0; candidateIndex < *count; candidateIndex++) {
if (param->candidates[candidateIndex] ==
(ziU16)((*((ziU8*)entry + 7) << 8) | *((ziU8*)entry + 8))) {
matched++;
param->candidates[candidateIndex] =
param->candidates[candidateIndex] & 0x7FFF;
break;
}
}
}
i++;
}
if ((ziU16)matched >= *remaining) {
matched = *count;
*count = 0;
for (i = 0; i < matched; i++) {
if ((param->candidates[i] & 0x8000) == 0) {
param->candidates[i] = param->candidates[i] | 0x8000;
if (*remaining == 0) {
if (*count != i) {
param->candidates[*count] = param->candidates[i];
}
*count = *count + 1;
} else {
*remaining = *remaining - 1;
Zi8_81483308(param, param->candidates[i], inserted, ZI_WORK);
}
}
}
*remaining = 0;
} else {
for (i = 0; i < *count; i++) {
if ((param->candidates[i] & 0x8000) == 0) {
param->candidates[i] = param->candidates[i] | 0x8000;
Zi8_81483308(param, param->candidates[i], inserted, ZI_WORK);
}
}
*remaining = *remaining - (ziU16)matched;
*count = 0;
}
}
} else {
*count = 0;
return 0;
}
return 0;
}
ziU32 Zi8GetKOcandidates(ziGetParam* param, ziU8* options ZI_NEED_WORK) {
ziBool bVar1;
ziU8 bVar2;
ziS32 iVar4;
ziU32 uVar6;
ziU8* pbVar7;
union {
ziU32 words[10];
ziU8 bytes[40];
} local_28;
ziU8 local_57;
ziU8 local_56;
ziU8 local_55;
ziU8 local_54;
ziU8 local_53;
ziS8 local_52;
ziU16 local_50;
ziU16 local_4E;
ziU16 local_4C;
ziU16 local_4A;
ziU16 local_48;
ziS32 local_44;
ziS32 local_2C;
ziS32 local_30;
ziU32 local_34;
ziU32 local_38;
ziU32 local_3C;
ziU32 local_40;
local_4E = 0xFFFF;
local_34 = 0;
local_28.words[0] = 0;
local_28.bytes[4] = 0;
local_52 = 0;
local_53 = 0;
local_54 = 0;
local_55 = 0;
local_50 = param->firstCandidate;
local_3C = 0;
local_40 = 0;
local_57 = 0;
Zi8LogError(100, ZI_WORK);
Zi8_81483264(param, ZI_WORK);
iVar4 = Zi8GetTableAddress(ZI8_LANG_KO, 9, ZI_WORK);
local_2C = Zi8GetTableAddress(ZI8_LANG_KO, 10, ZI_WORK);
if (iVar4 == 0) {
Zi8ReplaceLastError(0x76C, ZI_WORK);
uVar6 = 0;
} else {
if (local_2C == 0) {
Zi8ReplaceLastError(0x776, ZI_WORK);
uVar6 = 0;
goto LAB_000114C4;
}
if (*options == 0) {
param->letters = 0;
param->count = 0;
param->candidates[0] = 0;
}
Zi8LogError(100, ZI_WORK);
if (param->wordCharCount != 0) {
local_48 = Zi8_8148302C(param->currentWord[0], (ziU8*)iVar4, ZI_WORK);
if ((local_48 != 0xFFFF) &&
((((ziU8*)iVar4)[((ziU32)local_48 * 9) + 4] & 8) != 0)) {
local_38 = (ziU32)((ziU8*)iVar4)[((ziU32)local_48 * 9) + 6] |
((ziU32)((ziU8*)iVar4)[((ziU32)local_48 * 9) + 4] & 3) << 16 |
(ziU32)((ziU8*)iVar4)[((ziU32)local_48 * 9) + 5] << 8;
local_52 = param->wordCharCount - 1;
local_53 = 1;
pbVar7 = (ziU8*)(local_2C + local_38);
LAB_00010D44:
if (local_52 != 0) {
local_48 = Zi8_8148302C(param->currentWord[local_53], (ziU8*)iVar4, ZI_WORK);
if (local_48 == (ziU16)((*pbVar7 & 0x1F) << 8 | pbVar7[1])) {
local_52 = local_52 - 1;
local_53 = local_53 + 1;
if ((*pbVar7 & 0x40) == 0) {
pbVar7 = pbVar7 + 2;
goto LAB_00010D44;
}
local_52 = param->wordCharCount - 1;
local_53 = 1;
} else {
local_53 = 1;
local_52 = param->wordCharCount - 1;
}
}
if (local_52 == 0) {
local_48 = (*pbVar7 & 0x1F) << 8 | pbVar7[1];
local_4C = (ziU16)(((ziU8*)((ziU32)local_48 * 9 + (ziU32)local_48 + (ziU32)iVar4))[7] << 8 |
((ziU8*)((ziU32)local_48 * 9 + (ziU32)local_48 + (ziU32)iVar4))[8]);
if (param->wordCharCount == 1) {
if (local_48 == local_4E) {
for (; (*pbVar7 & 0x40) == 0; pbVar7 = pbVar7 + 2) {
}
local_52 = param->wordCharCount;
goto LAB_00011114;
}
local_4E = local_48;
if (param->elementCount == 0) {
if (local_50 == 0) {
if (*options != 0) {
local_3C = local_3C + 1;
if ((ziS32)local_3C < *(ziS32*)(options + 0xC)) {
goto LAB_000110E8;
}
uVar6 = *(ziU32*)(options + 0xC);
goto LAB_000114C4;
}
param->candidates[local_54] = local_4C;
local_54 = local_54 + 1;
param->count = param->count + 1;
bVar2 = param->letters + 1;
param->letters = bVar2;
if (param->maxCandidates <= bVar2) {
uVar6 = param->letters;
goto LAB_000114C4;
}
} else {
local_50 = local_50 + -1;
}
} else {
param->candidates[local_54] = local_4C;
local_54 = local_54 + 1;
param->count = param->count + 1;
bVar2 = param->letters + 1;
param->letters = bVar2;
if (param->maxCandidates <= bVar2) {
Zi8_814834AC(param, &local_50, &local_54, &local_57, ZI_WORK);
param->count = local_54;
param->letters = local_54;
if (param->maxCandidates <= local_54) {
if (*options == 0) {
uVar6 = local_54;
goto LAB_000114C4;
}
local_3C = local_3C + local_54;
if (*(ziS32*)(options + 0xC) <= (ziS32)local_3C) {
uVar6 = *(ziU32*)(options + 0xC);
goto LAB_000114C4;
}
param->count = 0;
param->letters = 0;
local_54 = 0;
}
}
}
} else {
for (local_40 = 0;
(local_40 < local_54 &&
(local_4C != param->candidates[local_40]));
local_40 = local_40 + 1) {
}
if ((local_40 == local_54) &&
(Zi8_814833F0(param, local_4C, ZI_WORK) == 0)) {
param->candidates[local_54] = local_4C;
local_54 = local_54 + 1;
param->count = param->count + 1;
bVar2 = param->letters + 1;
param->letters = bVar2;
if (bVar2 < param->maxCandidates) {
goto LAB_000110E8;
}
Zi8_814834AC(param, &local_50, &local_54, &local_57, ZI_WORK);
param->count = local_54;
param->letters = local_54;
if (param->maxCandidates <= local_54) {
if (*options == 0) {
uVar6 = local_54;
goto LAB_000114C4;
}
local_3C = local_3C + local_54;
if (*(ziS32*)(options + 0xC) <= (ziS32)local_3C) {
uVar6 = *(ziU32*)(options + 0xC);
goto LAB_000114C4;
}
param->count = 0;
param->letters = 0;
local_54 = 0;
}
}
}
}
LAB_000110E8:
for (; (*pbVar7 & 0x40) == 0; pbVar7 = pbVar7 + 2) {
}
local_52 = param->wordCharCount;
LAB_00011114:
local_52 = local_52 + -1;
local_53 = 1;
pbVar7 = pbVar7 + 2;
if ((*pbVar7 & 0x80) != 0) {
goto LAB_00011124;
}
goto LAB_00010D44;
}
}
LAB_00011124:
local_34 = local_3C;
if (local_54 != 0) {
Zi8_814834AC(param, &local_50, &local_54, &local_57, ZI_WORK);
uVar6 = local_34;
if ((*options != 0) &&
(local_3C = local_3C + local_54, uVar6 = local_3C,
*(ziS32*)(options + 0xC) <= (ziS32)local_3C)) {
uVar6 = *(ziU32*)(options + 0xC);
goto LAB_000114C4;
}
local_34 = uVar6;
param->count = local_54;
param->letters = local_54;
}
if (param->elementCount < 10) {
if ((param->elementCount == 0) || (*options != 0)) {
local_56 = 1;
} else {
local_56 = 0;
}
local_4A = Zi8GetTableCount(ZI8_LANG_KO, 9, ZI_WORK);
Zi8_81483118(param, local_28.bytes);
do {
for (local_30 = 0; local_30 < (ziS32)(ziU32)local_4A; local_30 = local_30 + 1) {
bVar1 = ZI8_TRUE;
local_44 = iVar4 + local_30 * 9;
local_55 = 0;
if (1 < param->elementCount) {
for (local_55 = 0;
(ziU32)local_55 < (ziU32)((ziS32)(ziU32)param->elementCount >> 1);
local_55 = local_55 + 1) {
if (local_28.bytes[local_55] != *(ziU8*)(local_44 + local_55)) {
bVar1 = ZI8_FALSE;
break;
}
}
}
if ((bVar1 && ((param->elementCount & 1) != 0)) &&
((local_28.bytes[local_55] & 0xF0) !=
(*(ziU8*)(local_44 + local_55) & 0xF0))) {
bVar1 = ZI8_FALSE;
}
if (bVar1) {
bVar2 = local_56;
if ((param->elementCount & 1) == 0) {
if ((*(ziU8*)(local_44 + local_55) & 0xF0) == 0) {
if (local_56 == 0) {
goto LAB_000113B0;
}
bVar2 = *options;
}
if (bVar2 == 0) {
goto LAB_00011478;
}
} else {
if ((*(ziU8*)(local_44 + local_55) & 0xF) != 0) {
goto LAB_000113AC;
}
if (local_56 != 0) {
bVar2 = *options;
goto LAB_000113AC;
}
}
LAB_000113AC:
if (bVar2 == 0) {
goto LAB_00011478;
}
LAB_000113B0:
if (local_50 == 0) {
if (*options == 0) {
param->candidates[local_54] =
(ziU16)((*(ziU8*)(local_30 * 9 + iVar4 + 7) << 8) |
*(ziU8*)(local_30 * 9 + iVar4 + 8));
local_54 = local_54 + 1;
bVar2 = param->letters + 1;
param->letters = bVar2;
if (param->maxCandidates <= bVar2) {
uVar6 = param->letters;
goto LAB_000114C4;
}
} else {
local_34 = local_34 + 1;
if (*(ziS32*)(options + 0xC) <= (ziS32)local_34) {
uVar6 = *(ziU32*)(options + 0xC);
goto LAB_000114C4;
}
}
} else {
local_50 = local_50 + -1;
}
}
LAB_00011478:
;
}
local_56 = local_56 + 1;
} while (local_56 < 2);
uVar6 = local_34;
if (*options == 0) {
uVar6 = param->letters;
}
} else {
param->letters = 0;
uVar6 = 0;
}
}
LAB_000114C4:
return uVar6;
}

View File

@@ -14,7 +14,7 @@ typedef struct AXFX_CHORUS {
u32 period; // 0xA8
} AXFX_CHORUS;
u32 AXFXChorusGetMemSize(const AXFX_CHORUS* fx);
u32 AXFXChorusGetMemSize(AXFX_CHORUS* fx);
BOOL AXFXChorusInit(AXFX_CHORUS* fx);
BOOL AXFXChorusShutdown(AXFX_CHORUS* fx);
BOOL AXFXChorusSettings(AXFX_CHORUS* fx);

View File

@@ -45,11 +45,11 @@ typedef struct AXFX_CHORUS_EXP {
f32 sendGain; // 0x9C
} AXFX_CHORUS_EXP;
u32 AXFXChorusExpGetMemSize(const AXFX_CHORUS_EXP* fx);
u32 AXFXChorusExpGetMemSize(AXFX_CHORUS_EXP* fx);
BOOL AXFXChorusExpInit(AXFX_CHORUS_EXP* fx);
void AXFXChorusExpShutdown(AXFX_CHORUS_EXP* fx);
BOOL AXFXChorusExpSettings(AXFX_CHORUS_EXP* fx);
void AXFXChorusExpCallback(AXFX_BUFFERUPDATE* update, AXFX_CHORUS_EXP* fx);
void AXFXChorusExpCallback(AXFX_BUS* update, AXFX_CHORUS_EXP* fx);
#ifdef __cplusplus
}

View File

@@ -7,6 +7,8 @@
extern "C" {
#endif
#define AXFX_STEREO_CHANNEL_MAX 3
typedef struct AXFX_BUS {
s32* left; // 0x00
s32* right; // 0x04
@@ -19,6 +21,13 @@ typedef struct AXFX_BUFFERUPDATE {
s32* surround; // 0x08
} AXFX_BUFFERUPDATE;
typedef struct AXFX_BUS_DPL2 {
s32* left; // 0x00
s32* right; // 0x04
s32* left_surround; // 0x08
s32* right_surround; // 0x0C
} AXFX_BUS_DPL2;
typedef struct AXFX_BUFFERUPDATE_DPL2 {
s32* left; // 0x00
s32* right; // 0x04

View File

@@ -49,13 +49,13 @@ typedef struct AXFX_REVERBHI_EXP_DPL2 {
f32 crosstalk; // 0x15C
f32 earlyGain; // 0x160
f32 fusedGain; // 0x164
AXFX_BUS* busIn; // 0x168
AXFX_BUS* busOut; // 0x16C
AXFX_BUS_DPL2* busIn; // 0x168
AXFX_BUS_DPL2* busOut; // 0x16C
f32 outGain; // 0x170
f32 sendGain; // 0x174
} AXFX_REVERBHI_EXP_DPL2;
u32 AXFXReverbHiExpGetMemSizeDpl2(const AXFX_REVERBHI_EXP_DPL2* fx);
u32 AXFXReverbHiExpGetMemSizeDpl2(AXFX_REVERBHI_EXP_DPL2* fx);
BOOL AXFXReverbHiExpInitDpl2(AXFX_REVERBHI_EXP_DPL2* fx);
void AXFXReverbHiExpShutdownDpl2(AXFX_REVERBHI_EXP_DPL2* fx);
BOOL AXFXReverbHiExpSettingsDpl2(AXFX_REVERBHI_EXP_DPL2* fx);

View File

@@ -49,11 +49,11 @@ typedef struct AXFX_REVERBSTD_EXP {
f32 sendGain; // 0xE4
} AXFX_REVERBSTD_EXP;
u32 AXFXReverbStdExpGetMemSize(const AXFX_REVERBSTD_EXP* fx);
u32 AXFXReverbStdExpGetMemSize(AXFX_REVERBSTD_EXP* fx);
BOOL AXFXReverbStdExpInit(AXFX_REVERBSTD_EXP* fx);
void AXFXReverbStdExpShutdown(AXFX_REVERBSTD_EXP* fx);
BOOL AXFXReverbStdExpSettings(AXFX_REVERBSTD_EXP* fx);
void AXFXReverbStdExpCallback(void* chans, AXFX_REVERBSTD_EXP* context);
void AXFXReverbStdExpCallback(AXFX_BUS* update, AXFX_REVERBSTD_EXP* fx);
#ifdef __cplusplus
}

View File

@@ -2,7 +2,7 @@
static void __ParamConvert(AXFX_CHORUS* fx);
u32 AXFXChorusGetMemSize(const AXFX_CHORUS* fx) {
u32 AXFXChorusGetMemSize(AXFX_CHORUS* fx) {
return AXFXChorusExpGetMemSize(&fx->chorusInner);
}
@@ -22,7 +22,7 @@ BOOL AXFXChorusSettings(AXFX_CHORUS* fx) {
}
void AXFXChorusCallback(void* chans, void* context) {
AXFXChorusExpCallback((AXFX_BUFFERUPDATE*)chans, (AXFX_CHORUS_EXP*)context);
AXFXChorusExpCallback((AXFX_BUS*)chans, (AXFX_CHORUS_EXP*)context);
}
static void __ParamConvert(AXFX_CHORUS* fx) {

View File

@@ -0,0 +1,368 @@
#include <private/axfx.h>
#include <revolution/axfx.h>
#include <revolution/ax.h>
#include <revolution/os.h>
#include <math.h>
#include <string.h>
static BOOL __AllocDelay(AXFX_CHORUS_EXP* chorus);
static BOOL __InitDelay(AXFX_CHORUS_EXP* chorus);
static void __FreeDelay(AXFX_CHORUS_EXP* chorus);
static BOOL __InitParams(AXFX_CHORUS_EXP* chorus);
static void __CalcLFO(s32* lfoBuf, AXFX_CHORUS_EXP_LFO* lfo);
u32 AXFXChorusExpGetMemSize(AXFX_CHORUS_EXP* chorus) {
return 0x3200 * AXFX_STEREO_CHANNEL_MAX;
}
BOOL AXFXChorusExpInit(AXFX_CHORUS_EXP* chorus) {
BOOL result;
BOOL enabled;
enabled = OSDisableInterrupts();
chorus->active |= 1;
result = __AllocDelay(chorus);
if (result == FALSE) {
AXFXChorusExpShutdown(chorus);
OSRestoreInterrupts(enabled);
return FALSE;
}
result = __InitDelay(chorus);
if (result == FALSE) {
AXFXChorusExpShutdown(chorus);
OSRestoreInterrupts(enabled);
return FALSE;
}
result = __InitParams(chorus);
if (result == FALSE) {
AXFXChorusExpShutdown(chorus);
OSRestoreInterrupts(enabled);
return FALSE;
}
chorus->active &= ~1;
OSRestoreInterrupts(enabled);
return TRUE;
}
BOOL AXFXChorusExpSettings(AXFX_CHORUS_EXP* chorus) {
BOOL result;
BOOL enabled = OSDisableInterrupts();
chorus->active |= 1;
AXFXChorusExpShutdown(chorus);
result = AXFXChorusExpInit(chorus);
if (!result) {
AXFXChorusExpShutdown(chorus);
OSRestoreInterrupts(enabled);
return FALSE;
}
chorus->active |= 2;
chorus->active &= ~1;
OSRestoreInterrupts(enabled);
return result;
}
void AXFXChorusExpShutdown(AXFX_CHORUS_EXP* reverb) {
BOOL enabled = OSDisableInterrupts();
reverb->active |= 1;
__FreeDelay(reverb);
OSRestoreInterrupts(enabled);
}
void AXFXChorusExpCallback(AXFX_BUS* bus, AXFX_CHORUS_EXP* chorus) {
u32 ch;
u32 samp;
s32* input[3];
s32* inBusData[3];
s32* outBusData[3];
s32 lfoOut[96];
s32 pos;
s32 diff;
u32 steps;
u32 frac;
u32 walk;
u32 histIdx;
u32 i;
f32* coef;
f32 data;
f32 fir;
AXFX_CHORUS_EXP* fx;
fx = chorus;
if (fx->active != 0) {
fx->active &= ~2;
return;
}
input[0] = bus->left;
input[1] = bus->right;
input[2] = bus->surround;
if (fx->busIn != NULL) {
inBusData[0] = fx->busIn->left;
inBusData[1] = fx->busIn->right;
inBusData[2] = fx->busIn->surround;
}
if (fx->busOut != NULL) {
outBusData[0] = fx->busOut->left;
outBusData[1] = fx->busOut->right;
outBusData[2] = fx->busOut->surround;
}
__CalcLFO(lfoOut, &fx->lfo);
for (samp = 0; samp < 96; samp++) {
pos = fx->delay.outPos + lfoOut[samp];
if (pos >= (s32)fx->delay.sizeFP) {
pos -= fx->delay.sizeFP;
} else if (pos < 0) {
pos += fx->delay.sizeFP;
}
diff = pos - fx->delay.lastPos;
if (diff < 0) {
diff += fx->delay.sizeFP;
}
steps = (u32)(diff >> 16) & 0xFFFF;
frac = diff & 0xFFFF;
walk = fx->delay.lastPos >> 16;
histIdx = fx->histIndex;
while (steps--) {
fx->history[0][histIdx] = fx->delay.line[0][walk];
fx->history[1][histIdx] = fx->delay.line[1][walk];
fx->history[2][histIdx++] = fx->delay.line[2][walk++];
histIdx &= 3;
if (walk >= fx->delay.size) {
walk = 0;
}
}
fx->delay.lastPos = pos & 0xFFFF0000;
coef = __AXFXGetSrcCoef((frac >> 9) & 0x7F);
for (ch = 0; ch < 3; ch++) {
fir = 0.0f;
fir += coef[0] * fx->history[ch][histIdx++];
histIdx &= 3;
fir += coef[1] * fx->history[ch][histIdx++];
histIdx &= 3;
fir += coef[2] * fx->history[ch][histIdx++];
histIdx &= 3;
fir += coef[3] * fx->history[ch][histIdx++];
histIdx &= 3;
if (fx->busIn != NULL) {
data = (f32)(*(input[ch]) + *(inBusData[ch]++));
} else {
data = (f32)(*input[ch]);
}
fx->delay.line[ch][fx->delay.inPos] = data + fir * fx->feedback;
*(input[ch]++) = (s32)(fir * fx->outGain);
if (fx->busOut != NULL) {
*(outBusData[ch]++) = (s32)(fir * fx->sendGain);
}
}
fx->histIndex = histIdx;
if (++fx->delay.inPos >= fx->delay.size) {
fx->delay.inPos = 0;
}
fx->delay.outPos += 0x10000;
if (fx->delay.outPos >= fx->delay.sizeFP) {
fx->delay.outPos = 0;
}
}
}
static BOOL __AllocDelay(AXFX_CHORUS_EXP* chorus) {
AXFX_CHORUS_EXP* pChorus = chorus;
u32 i;
pChorus->delay.size = 0xC80;
for (i = 0; i < AXFX_STEREO_CHANNEL_MAX; i++) {
pChorus->delay.line[i] = __AXFXAlloc(pChorus->delay.size * 4);
ASSERTMSGLINE(443, pChorus->delay.line[i], "Can't allocate the memory.");
if (!pChorus->delay.line[i]) {
return FALSE;
}
}
return TRUE;
}
static BOOL __InitDelay(AXFX_CHORUS_EXP* chorus) {
AXFX_CHORUS_EXP* pChorus = chorus;
u32 i;
for (i = 0; i < AXFX_STEREO_CHANNEL_MAX; i++) {
ASSERTMSGLINE(469, pChorus->delay.line[i], "Buffer is not allocated.");
if (!pChorus->delay.line[i]) {
return FALSE;
}
memset(pChorus->delay.line[i], 0, pChorus->delay.size * 4);
}
pChorus->delay.inPos = 0;
pChorus->delay.outPos = pChorus->delay.size - (u32)(32.0f * chorus->delayTime);
pChorus->delay.outPos <<= 0x10;
pChorus->delay.lastPos = pChorus->delay.outPos;
pChorus->delay.sizeFP = pChorus->delay.size << 0x10;
return TRUE;
}
static void __FreeDelay(AXFX_CHORUS_EXP* chorus) {
u32 i;
AXFX_CHORUS_EXP* pChorus;
pChorus = chorus;
for (i = 0; i < AXFX_STEREO_CHANNEL_MAX; i++) {
if (pChorus->delay.line[i]) {
__AXFXFree(pChorus->delay.line[i]);
}
pChorus->delay.line[i] = NULL;
}
}
static BOOL __InitParams(AXFX_CHORUS_EXP* chorus) {
u32 i, j;
f32 var_f28;
f32 var_f30;
f32 var_f29;
f32 var_f31;
ASSERTMSGLINE(767, chorus->delayTime >= 0.1f && chorus->delayTime <= 50.0f, "The value of specified parameter is out of range.");
if (chorus->delayTime < 0.1f || chorus->delayTime > 50.0f) {
return FALSE;
}
ASSERTMSGLINE(767, chorus->depth >= 0.0f && chorus->depth <= 1.0f, "The value of specified parameter is out of range.");
if (chorus->depth < 0.0f || chorus->depth > 1.0f) {
return FALSE;
}
ASSERTMSGLINE(767, chorus->rate >= 0.1f && chorus->rate <= 2.0f, "The value of specified parameter is out of range.");
if (chorus->rate < 0.1f || chorus->rate > 2.0f) {
return FALSE;
}
ASSERTMSGLINE(767, chorus->feedback >= 0.0f && chorus->feedback < 1.0f, "The value of specified parameter is out of range.");
if (chorus->feedback < 0.0f || chorus->feedback >= 1.0f) {
return FALSE;
}
ASSERTMSGLINE(767, chorus->outGain >= 0.0f && chorus->outGain <= 1.0f, "The value of specified parameter is out of range.");
if (chorus->outGain < 0.0f || chorus->outGain > 1.0f) {
return FALSE;
}
ASSERTMSGLINE(767, chorus->sendGain >= 0.0f && chorus->sendGain <= 1.0f, "The value of specified parameter is out of range.");
if (chorus->sendGain < 0.0f || chorus->sendGain > 1.0f) {
return FALSE;
}
chorus->lfo.table = __AXFXGetLfoSinTable();
var_f30 = 32.0f * chorus->delayTime;
var_f31 = var_f30 * chorus->depth;
if (var_f31 >= var_f30) {
var_f31 -= 1.0f;
if (var_f31 < 0.0f) {
var_f31 = 0.0f;
}
}
chorus->lfo.depthSamp = (65536.0f * var_f31);
chorus->lfo.phaseAdd = (65536.0f * ((256.0f * chorus->rate) / 32000.0f));
var_f29 = (32000.0f / chorus->rate) * 0.00390625f;
chorus->lfo.stepSamp = (65536.0f * var_f29);
var_f28 = var_f31 / var_f29;
chorus->lfo.gradFactor = (65536.0f * var_f28);
chorus->lfo.phase = 0;
chorus->lfo.sign = 0;
chorus->lfo.lastNum = -1;
chorus->lfo.lastValue = 0;
chorus->lfo.grad = 0;
for (i = 0; i < AXFX_STEREO_CHANNEL_MAX; i++) {
for (j = 0; j < 4; j++) {
chorus->history[i][j] = 0.0f;
}
}
chorus->histIndex = 0;
return TRUE;
}
static void __CalcLFO(s32* lfoBuf, AXFX_CHORUS_EXP_LFO* lfo) {
u32 i;
s32 srcCoefIndex;
s32 var_r24;
s32 var_r25;
u32 histIndex;
s64 var_r31;
s64 var_r28;
var_r31 = 0;
for (i = 0; i < 96; i++) {
histIndex = lfo->phase & 0xFFFF0000;
if (histIndex != lfo->lastNum) {
lfo->lastNum = histIndex;
histIndex = histIndex >> 0x10U;
var_r25 = histIndex + 1;
var_r25 &= 0x7F;
var_r24 = lfo->table[histIndex];
srcCoefIndex = lfo->table[var_r25];
var_r28 = srcCoefIndex - var_r24;
var_r28 = var_r28 * lfo->gradFactor;
var_r28 = var_r28 >> 0x18;
lfo->grad = var_r28;
var_r31 = (s64)var_r24 * (s64)lfo->depthSamp;
var_r31 = var_r31 >> 0x18;
} else {
var_r31 = lfo->lastValue + lfo->grad;
}
lfo->lastValue = var_r31;
if (lfo->sign >= 1) {
var_r31 *= -1;
}
lfo->phase += lfo->phaseAdd;
if ((lfo->phase & 0xFF800000) != 0) {
lfo->phase &= 0x7FFFFF;
lfo->sign ^= 1;
}
lfoBuf[i] = var_r31;
}
}

View File

@@ -0,0 +1,461 @@
#include <private/axfx.h>
#include <revolution/AXFX.h>
#include <revolution/MEM.h>
#include <revolution/OS.h>
#include <revolution/ax.h>
#include <math.h>
#include <string.h>
static BOOL __AllocDelayLine(AXFX_REVERBHI_EXP_DPL2* fx);
static void __BzeroDelayLines(AXFX_REVERBHI_EXP_DPL2* fx);
static void __FreeDelayLine(AXFX_REVERBHI_EXP_DPL2* fx);
static BOOL __InitParams(AXFX_REVERBHI_EXP_DPL2* fx);
static u32 __EarlySizeTable[8][3] = {{157, 479, 829}, {317, 809, 1117}, {479, 941, 1487}, {641, 1259, 1949},
{797, 1667, 2579}, {967, 1901, 2903}, {1123, 2179, 3413}, {1279, 2477, 3889}};
static f32 __EarlyCoefTable[8][3] = {{0.4f, -1.0f, 0.3f}, {0.5f, -0.95f, 0.3f}, {0.6f, -0.9f, 0.3f}, {0.75f, -0.85f, 0.3f},
{-0.9f, 0.8f, 0.3f}, {-1.0f, 0.7f, 0.3f}, {-1.0f, 0.7f, 0.3f}, {-1.0f, 0.7f, 0.3f}};
static u32 __FilterSizeTable[7][9] = {{1789, 1999, 2333, 433, 149, 47, 73, 67, 71}, {149, 293, 449, 251, 103, 47, 73, 67, 71},
{947, 1361, 1531, 433, 137, 47, 73, 67, 71}, {1279, 1531, 1973, 509, 149, 47, 73, 67, 71},
{1531, 1847, 2297, 563, 179, 47, 73, 67, 71}, {1823, 2357, 2693, 571, 137, 47, 73, 67, 71},
{1823, 2357, 2693, 571, 179, 47, 73, 67, 71}};
u32 AXFXReverbHiExpGetMemSizeDpl2(AXFX_REVERBHI_EXP_DPL2* fx) {
u32 sum = 0;
u32 i = 0;
sum += __EarlySizeTable[7][2];
sum += (int)(fx->preDelayTimeMax * 32000);
for (i = 0; i < 5; i++) {
sum += __FilterSizeTable[6][i];
}
sum *= 4;
for (i = 5; i < 9; i++) {
sum += __FilterSizeTable[6][i];
}
sum *= 4;
return sum;
}
BOOL AXFXReverbHiExpInitDpl2(AXFX_REVERBHI_EXP_DPL2* fx) {
u32 ch, i;
BOOL result = TRUE;
BOOL mask = OSDisableInterrupts();
if (AXGetMode() != AX_OUTPUT_DPL2) {
OSRestoreInterrupts(mask);
return FALSE;
}
fx->active = 1;
if (fx->preDelayTimeMax < 0.0f) {
AXFXReverbHiExpShutdownDpl2(fx);
OSRestoreInterrupts(mask);
return FALSE;
}
fx->earlyMaxLength = __EarlySizeTable[8 - 1][2];
fx->preDelayMaxLength = (u32)(fx->preDelayTimeMax * 32000);
for (i = 0; i < 3; i++) {
fx->combMaxLength[i] = __FilterSizeTable[6][i];
}
for (i = 0; i < 2; i++) {
fx->allpassMaxLength[i] = __FilterSizeTable[6][3 + i];
}
for (ch = 0; ch < 4; ch++) {
fx->lastAllpassMaxLength[ch] = __FilterSizeTable[6][5 + ch];
}
result = __AllocDelayLine(fx);
if (result == FALSE) {
AXFXReverbHiExpShutdownDpl2(fx);
OSRestoreInterrupts(mask);
return FALSE;
}
__BzeroDelayLines(fx);
result = __InitParams(fx);
if (result == FALSE) {
AXFXReverbHiExpShutdownDpl2(fx);
OSRestoreInterrupts(mask);
return FALSE;
}
fx->active &= ~1;
OSRestoreInterrupts(mask);
return TRUE;
}
BOOL AXFXReverbHiExpSettingsDpl2(AXFX_REVERBHI_EXP_DPL2* fx) {
BOOL mask = OSDisableInterrupts();
fx->active = fx->active | 1;
AXFXReverbHiExpShutdownDpl2(fx);
if (!AXFXReverbHiExpInitDpl2(fx)) {
AXFXReverbHiExpShutdownDpl2(fx);
OSRestoreInterrupts(mask);
return FALSE;
} else {
fx->active |= 2;
fx->active &= ~1;
OSRestoreInterrupts(mask);
return TRUE;
}
}
void AXFXReverbHiExpShutdownDpl2(AXFX_REVERBHI_EXP_DPL2* fx) {
BOOL mask = OSDisableInterrupts();
fx->active |= 1;
__FreeDelayLine(fx);
OSRestoreInterrupts(mask);
}
void AXFXReverbHiExpCallbackDpl2(AXFX_BUFFERUPDATE_DPL2* bufferUpdate, AXFX_REVERBHI_EXP_DPL2* fx) {
u32 ch, i;
u32 samp;
s32* input[4];
f32 data;
f32 output[4];
f32* earlyLine;
f32 earlyOut;
f32* preDelayLine;
f32 preDelayOut;
f32 filterOut;
f32* combLine;
f32 combOutOne;
f32* allpass;
f32 outTmp;
f32 allpassIn;
f32 allpassCoef;
f32 lpfOut;
f32 lpfCoef1;
f32 lpfCoef2;
f32 fusedOut[4];
f32 fusedGain;
f32 crosstalkGain;
f32 crosstalkL;
f32 crosstalkR;
f32 crosstalkLs;
f32 crosstalkRs;
s32* inBusData[4];
s32* outBusData[4];
if (fx->active != 0) {
fx->active &= ~2;
return;
}
input[0] = bufferUpdate->left;
input[1] = bufferUpdate->right;
input[2] = bufferUpdate->left_surround;
input[3] = bufferUpdate->right_surround;
if (fx->busIn != NULL) {
inBusData[0] = fx->busIn->left;
inBusData[1] = fx->busIn->right;
inBusData[2] = fx->busIn->left_surround;
inBusData[3] = fx->busIn->right_surround;
}
if (fx->busOut != NULL) {
outBusData[0] = fx->busOut->left;
outBusData[1] = fx->busOut->right;
outBusData[2] = fx->busOut->left_surround;
outBusData[3] = fx->busOut->right_surround;
}
lpfCoef1 = 1.0f - fx->lpfCoef;
lpfCoef2 = fx->lpfCoef;
allpassCoef = fx->allpassCoef;
fusedGain = fx->fusedGain * 0.6f;
crosstalkGain = fx->crosstalk * 0.333333f;
for (samp = 0; samp < 96; samp++) {
for (ch = 0; ch < 4; ch++) {
if (fx->busIn != NULL) {
data = (f32)(*(input[ch]) + *(inBusData[ch]++));
} else {
data = (f32)(*input[ch]);
}
earlyLine = fx->earlyLine[ch];
earlyOut = earlyLine[fx->earlyPos[0]] * fx->earlyCoef[0] + earlyLine[fx->earlyPos[1]] * fx->earlyCoef[1] +
earlyLine[fx->earlyPos[2]] * fx->earlyCoef[2];
earlyLine[fx->earlyPos[2]] = data;
if (fx->preDelayLength != 0) {
preDelayLine = fx->preDelayLine[ch];
preDelayOut = preDelayLine[fx->preDelayPos];
preDelayLine[fx->preDelayPos] = data;
} else {
preDelayOut = data;
}
filterOut = 0.0f;
for (i = 0; i < 3; i++) {
combLine = fx->combLine[ch][i];
combOutOne = combLine[fx->combPos[i]];
combLine[fx->combPos[i]] = preDelayOut + (combOutOne * fx->combCoef[i]);
filterOut += combOutOne;
}
for (i = 0; i < 2; i++) {
allpass = fx->allpassLine[ch][i];
outTmp = allpass[fx->allpassPos[i]];
allpassIn = filterOut + outTmp * allpassCoef;
allpass[fx->allpassPos[i]] = allpassIn;
filterOut = outTmp - allpassIn * allpassCoef;
}
lpfOut = lpfCoef1 * filterOut + lpfCoef2 * fx->lastLpfOut[ch];
fx->lastLpfOut[ch] = lpfOut;
allpass = fx->lastAllpassLine[ch];
outTmp = allpass[fx->lastAllpassPos[ch]];
allpassIn = lpfOut + outTmp * allpassCoef;
allpass[fx->lastAllpassPos[ch]] = allpassIn;
fusedOut[ch] = outTmp - allpassIn * allpassCoef;
if (++fx->lastAllpassPos[ch] >= fx->lastAllpassLength[ch]) {
fx->lastAllpassPos[ch] = 0;
}
fusedOut[ch] *= fusedGain;
fusedOut[ch] += earlyOut;
}
crosstalkL = fusedOut[1] + fusedOut[2] + fusedOut[3];
crosstalkR = fusedOut[0] + fusedOut[2] + fusedOut[3];
crosstalkLs = fusedOut[0] + fusedOut[1] + fusedOut[3];
crosstalkRs = fusedOut[0] + fusedOut[1] + fusedOut[2];
output[0] = fusedOut[0] + crosstalkL * crosstalkGain;
output[1] = fusedOut[1] + crosstalkR * crosstalkGain;
output[2] = fusedOut[2] + crosstalkLs * crosstalkGain;
output[3] = fusedOut[3] + crosstalkRs * crosstalkGain;
*(input[0]++) = (s32)(output[0] * fx->outGain);
*(input[1]++) = (s32)(output[1] * fx->outGain);
*(input[2]++) = (s32)(output[2] * fx->outGain);
*(input[3]++) = (s32)(output[3] * fx->outGain);
if (fx->busOut != NULL) {
*(outBusData[0]++) = (s32)(output[0] * fx->sendGain);
*(outBusData[1]++) = (s32)(output[1] * fx->sendGain);
*(outBusData[2]++) = (s32)(output[2] * fx->sendGain);
*(outBusData[3]++) = (s32)(output[3] * fx->sendGain);
}
for (i = 0; i < 3; i++) {
if (++fx->earlyPos[i] >= fx->earlyLength) {
fx->earlyPos[i] = 0;
}
}
if (fx->preDelayLength != 0) {
if (++fx->preDelayPos >= fx->preDelayLength) {
fx->preDelayPos = 0;
}
}
for (i = 0; i < 3; i++) {
if (++fx->combPos[i] >= fx->combLength[i]) {
fx->combPos[i] = 0;
}
}
for (i = 0; i < 2; i++) {
if (++fx->allpassPos[i] >= fx->allpassLength[i]) {
fx->allpassPos[i] = 0;
}
}
}
}
static BOOL __AllocDelayLine(AXFX_REVERBHI_EXP_DPL2* fx) {
u32 ch, i;
for (ch = 0; ch < 4; ch++) {
fx->earlyLine[ch] = (f32*)__AXFXAlloc(sizeof(f32) * fx->earlyMaxLength);
if (fx->earlyLine[ch] == NULL)
return FALSE;
if (fx->preDelayMaxLength != 0) {
fx->preDelayLine[ch] = (f32*)__AXFXAlloc(sizeof(f32) * fx->preDelayMaxLength);
if (fx->preDelayLine[ch] == NULL)
return FALSE;
} else {
fx->preDelayLine[ch] = NULL;
}
for (i = 0; i < 3; i++) {
fx->combLine[ch][i] = (f32*)__AXFXAlloc(sizeof(f32) * fx->combMaxLength[i]);
if (fx->combLine[ch][i] == NULL)
return FALSE;
}
for (i = 0; i < 2; i++) {
fx->allpassLine[ch][i] = (f32*)__AXFXAlloc(sizeof(f32) * fx->allpassMaxLength[i]);
if (fx->allpassLine[ch][i] == NULL)
return FALSE;
}
fx->lastAllpassLine[ch] = (f32*)__AXFXAlloc(sizeof(f32) * fx->lastAllpassMaxLength[ch]);
if (fx->lastAllpassLine[ch] == NULL)
return FALSE;
}
return TRUE;
}
static void __BzeroDelayLines(AXFX_REVERBHI_EXP_DPL2* fx) {
u32 ch, i;
for (ch = 0; ch < 4; ch++) {
if (fx->earlyLine[ch] != NULL) {
memset(fx->earlyLine[ch], 0, sizeof(f32) * fx->earlyMaxLength);
}
if (fx->preDelayLine[ch] != NULL) {
memset(fx->preDelayLine[ch], 0, sizeof(f32) * fx->preDelayMaxLength);
}
for (i = 0; i < 3; i++) {
if (fx->combLine[ch][i] != NULL) {
memset(fx->combLine[ch][i], 0, sizeof(f32) * fx->combMaxLength[i]);
}
}
for (i = 0; i < 2; i++) {
if (fx->allpassLine[ch][i] != NULL) {
memset(fx->allpassLine[ch][i], 0, sizeof(f32) * fx->allpassMaxLength[i]);
}
}
if (fx->lastAllpassLine[ch] != NULL) {
memset(fx->lastAllpassLine[ch], 0, sizeof(f32) * fx->lastAllpassMaxLength[ch]);
}
}
}
static void __FreeDelayLine(AXFX_REVERBHI_EXP_DPL2* fx) {
u32 ch, i;
for (ch = 0; ch < 4; ch++) {
if (fx->earlyLine[ch] != NULL) {
__AXFXFree(fx->earlyLine[ch]);
fx->earlyLine[ch] = NULL;
}
if (fx->preDelayLine[ch] != NULL) {
__AXFXFree(fx->preDelayLine[ch]);
fx->preDelayLine[ch] = NULL;
}
for (i = 0; i < 3; i++) {
if (fx->combLine[ch][i] != NULL) {
__AXFXFree(fx->combLine[ch][i]);
fx->combLine[ch][i] = NULL;
}
}
for (i = 0; i < 2; i++) {
if (fx->allpassLine[ch][i] != NULL) {
__AXFXFree(fx->allpassLine[ch][i]);
fx->allpassLine[ch][i] = NULL;
}
}
if (fx->lastAllpassLine[ch] != NULL) {
__AXFXFree(fx->lastAllpassLine[ch]);
fx->lastAllpassLine[ch] = NULL;
}
}
}
DECOMP_FORCE_LITERAL(AXFXReverbHiExpDpl2_c, -3.0f, 10.0);
static BOOL __InitParams(AXFX_REVERBHI_EXP_DPL2* reverb) {
u32 ch, i;
if (reverb->earlyMode >= 8)
return FALSE;
if (reverb->preDelayTime < 0.0f || reverb->preDelayTime > reverb->preDelayTimeMax)
return FALSE;
if (reverb->fusedMode >= 6)
return FALSE;
if (reverb->fusedTime < 0.0f)
return FALSE;
if (reverb->coloration < 0.0f || reverb->coloration > 1.0f)
return FALSE;
if (reverb->damping < 0.0f || reverb->damping > 1.0f)
return FALSE;
if (reverb->crosstalk < 0.0f || reverb->crosstalk > 1.0f)
return FALSE;
if (reverb->earlyGain < 0.0f || reverb->earlyGain > 1.0f)
return FALSE;
if (reverb->fusedGain < 0.0f || reverb->fusedGain > 1.0f)
return FALSE;
if (reverb->outGain < 0.0f || reverb->outGain > 1.0f)
return FALSE;
if (reverb->sendGain < 0.0f || reverb->sendGain > 1.0f)
return FALSE;
reverb->earlyLength = __EarlySizeTable[reverb->earlyMode][2];
for (i = 0; i < 3; i++) {
reverb->earlyPos[i] = reverb->earlyLength - __EarlySizeTable[reverb->earlyMode][i];
reverb->earlyCoef[i] = __EarlyCoefTable[reverb->earlyMode][i] * reverb->earlyGain * 0.6f;
}
reverb->preDelayPos = 0;
reverb->preDelayLength = (u32)(reverb->preDelayTime * (f32)32000);
for (i = 0; i < 3; i++) {
reverb->combPos[i] = 0;
reverb->combLength[i] = __FilterSizeTable[reverb->fusedMode][i];
reverb->combCoef[i] = pow(10.0f, (-3.0f * (f32)(reverb->combLength[i]) / (f32)(reverb->fusedTime * 32000)));
}
for (i = 0; i < 2; i++) {
reverb->allpassPos[i] = 0;
reverb->allpassLength[i] = __FilterSizeTable[reverb->fusedMode][3 + i];
}
for (ch = 0; ch < 4; ch++) {
reverb->lastAllpassPos[ch] = 0;
reverb->lastAllpassLength[ch] = __FilterSizeTable[reverb->fusedMode][5 + ch];
}
reverb->allpassCoef = reverb->coloration;
reverb->lpfCoef = 1.0f - reverb->damping;
if (reverb->lpfCoef > 0.95f)
reverb->lpfCoef = 0.95f;
for (ch = 0; ch < 4; ch++) {
reverb->lastLpfOut[ch] = 0.0f;
}
return TRUE;
}

View File

@@ -23,7 +23,7 @@ BOOL AXFXReverbStdSettings(AXFX_REVERBSTD* fx) {
}
void AXFXReverbStdCallback(void* chans, void* context) {
AXFXReverbStdExpCallback((AXFX_BUFFERUPDATE*)chans, (AXFX_REVERBSTD_EXP*)context);
AXFXReverbStdExpCallback((AXFX_BUS*)chans, (AXFX_REVERBSTD_EXP*)context);
}
static void __ParamConvert(AXFX_REVERBSTD* fx) {

View File

@@ -0,0 +1,397 @@
#include <private/axfx.h>
#include <revolution/AXFX.h>
#include <revolution/MEM.h>
#include <revolution/OS.h>
#include <revolution/ax.h>
#include <math.h>
#include <string.h>
static BOOL __AllocDelayLine(AXFX_REVERBSTD_EXP* fx);
static void __BzeroDelayLines(AXFX_REVERBSTD_EXP* fx);
static void __FreeDelayLine(AXFX_REVERBSTD_EXP* fx);
static BOOL __InitParams(AXFX_REVERBSTD_EXP* fx);
static u32 __EarlySizeTable[8] = {163, 317, 479, 641, 797, 967, 1123, 1283};
static u32 __FilterSizeTable[7][4] = {{1789, 1999, 433, 149}, {149, 293, 251, 103}, {947, 1361, 433, 137},
{1279, 1531, 509, 149}, {1531, 1847, 563, 179}, {1823, 2357, 571, 137},
{1823, 2357, 571, 179}};
u32 AXFXReverbStdExpGetMemSize(AXFX_REVERBSTD_EXP* fx) {
u32 sum = 0;
u32 i = 0;
sum += __EarlySizeTable[7];
sum += (int)(fx->preDelayTimeMax * 32000);
for (i = 0; i < 4; i++) {
sum += __FilterSizeTable[6][i];
}
sum *= 3;
sum *= 4;
return sum;
}
BOOL AXFXReverbStdExpInit(AXFX_REVERBSTD_EXP* fx) {
u32 ch, i;
BOOL result = TRUE;
BOOL mask = OSDisableInterrupts();
fx->active = 1;
if (fx->preDelayTimeMax < 0.0f) {
AXFXReverbStdExpShutdown(fx);
OSRestoreInterrupts(mask);
return FALSE;
}
fx->earlyMaxLength = __EarlySizeTable[8 - 1];
fx->preDelayMaxLength = (u32)(fx->preDelayTimeMax * 32000);
for (i = 0; i < 2; i++) {
fx->combMaxLength[i] = __FilterSizeTable[6][i];
}
for (i = 0; i < 2; i++) {
fx->allpassMaxLength[i] = __FilterSizeTable[6][2 + i];
}
result = __AllocDelayLine(fx);
if (result == FALSE) {
AXFXReverbStdExpShutdown(fx);
OSRestoreInterrupts(mask);
return FALSE;
}
__BzeroDelayLines(fx);
result = __InitParams(fx);
if (result == FALSE) {
AXFXReverbStdExpShutdown(fx);
OSRestoreInterrupts(mask);
return FALSE;
}
fx->active &= ~1;
OSRestoreInterrupts(mask);
return TRUE;
}
BOOL AXFXReverbStdExpSettings(AXFX_REVERBSTD_EXP* fx) {
BOOL mask = OSDisableInterrupts();
fx->active = fx->active | 1;
AXFXReverbStdExpShutdown(fx);
if (!AXFXReverbStdExpInit(fx)) {
AXFXReverbStdExpShutdown(fx);
OSRestoreInterrupts(mask);
return FALSE;
} else {
fx->active |= 2;
fx->active &= ~1;
OSRestoreInterrupts(mask);
return TRUE;
}
}
void AXFXReverbStdExpShutdown(AXFX_REVERBSTD_EXP* fx) {
BOOL mask = OSDisableInterrupts();
fx->active |= 1;
__FreeDelayLine(fx);
OSRestoreInterrupts(mask);
}
void AXFXReverbStdExpCallback(AXFX_BUS* bus, AXFX_REVERBSTD_EXP* reverb) {
u32 i, j;
s32* busParam[AXFX_STEREO_CHANNEL_MAX];
s32* busIn[AXFX_STEREO_CHANNEL_MAX];
s32* busOut[AXFX_STEREO_CHANNEL_MAX];
u32 earlyPos;
u32 preDelayPos;
u32 combPos0;
u32 combPos1;
u32 allpassPos0;
u32 allpassPos1;
f32 sp64;
f32 sp60;
f32* earlyLine;
f32 sp58;
f32 earlyCoef;
f32* preDelayLine;
f32 sp4C;
f32* combLine0;
f32* combLine1;
f32 sp40;
f32 sp3C;
f32 sp38;
f32 combCoef0;
f32 combCoef1;
f32 sp2C;
f32 sp28;
f32 sp24;
f32 sp20;
f32 allpassCoef;
f32 sp18;
f32 sp14;
f32 lpfCoef;
f32 spC;
f32 sp8;
f32* allpassLine;
if (reverb->active != 0) {
reverb->active &= ~2;
return;
}
busParam[AX_STEREO_L] = bus->left;
busParam[AX_STEREO_R] = bus->right;
busParam[AX_STEREO_S] = bus->surround;
if (reverb->busIn) {
busIn[AX_STEREO_L] = reverb->busIn->left;
busIn[AX_STEREO_R] = reverb->busIn->right;
busIn[AX_STEREO_S] = reverb->busIn->surround;
}
if (reverb->busOut) {
busOut[AX_STEREO_L] = reverb->busOut->left;
busOut[AX_STEREO_R] = reverb->busOut->right;
busOut[AX_STEREO_S] = reverb->busOut->surround;
}
sp14 = 1.0f - reverb->lpfCoef;
lpfCoef = reverb->lpfCoef;
earlyCoef = reverb->earlyCoef;
combCoef0 = reverb->combCoef[0];
combCoef1 = reverb->combCoef[1];
allpassCoef = reverb->allpassCoef;
spC = 0.6f * reverb->earlyGain;
sp8 = 0.6f * reverb->fusedGain;
for (i = 0; i < 96; i++) {
earlyPos = reverb->earlyPos;
preDelayPos = reverb->preDelayPos;
combPos0 = reverb->combPos[0];
combPos1 = reverb->combPos[1];
allpassPos0 = reverb->allpassPos[0];
allpassPos1 = reverb->allpassPos[1];
for (j = 0; j < AXFX_STEREO_CHANNEL_MAX; j++) {
if (reverb->busIn) {
sp64 = *busParam[j] + *busIn[j]++;
} else {
sp64 = *busParam[j];
}
earlyLine = reverb->earlyLine[j];
sp58 = earlyLine[earlyPos];
earlyLine[earlyPos] = sp64 + (sp58 * earlyCoef);
if (reverb->preDelayLength != 0) {
preDelayLine = reverb->preDelayLine[j];
sp4C = preDelayLine[preDelayPos];
preDelayLine[preDelayPos] = sp64;
} else {
sp4C = sp64;
}
combLine0 = reverb->combLine[j][0];
sp40 = combLine0[combPos0];
combLine0[combPos0] = sp4C + (sp40 * combCoef0);
combLine1 = reverb->combLine[j][1];
sp3C = combLine1[combPos1];
combLine1[combPos1] = sp4C + (sp3C * combCoef1);
sp38 = sp40 + sp3C;
allpassLine = reverb->allpassLine[j][0];
sp2C = allpassLine[allpassPos0];
sp28 = sp38 + (sp2C * allpassCoef);
allpassLine[allpassPos0] = sp28;
sp24 = sp2C - (sp28 * allpassCoef);
sp18 = (sp14 * sp24) + (lpfCoef * reverb->lastLpfOut[j]);
reverb->lastLpfOut[j] = sp18;
allpassLine = reverb->allpassLine[j][1];
sp2C = allpassLine[allpassPos1];
sp28 = sp18 + (sp2C * allpassCoef);
allpassLine[allpassPos1] = sp28;
sp20 = sp2C - (sp28 * allpassCoef);
sp60 = (sp58 * spC) + (sp20 * sp8);
*busParam[j]++ = (sp60 * reverb->outGain);
if (reverb->busOut) {
*busOut[j]++ = (sp60 * reverb->sendGain);
}
}
if (++reverb->earlyPos >= reverb->earlyLength) {
reverb->earlyPos = 0;
}
if (reverb->preDelayLength != 0) {
if (++reverb->preDelayPos >= reverb->preDelayLength) {
reverb->preDelayPos = 0;
}
}
if (++reverb->combPos[0] >= reverb->combLength[0]) {
reverb->combPos[0] = 0;
}
if (++reverb->combPos[1] >= reverb->combLength[1]) {
reverb->combPos[1] = 0;
}
if (++reverb->allpassPos[0] >= reverb->allpassLength[0]) {
reverb->allpassPos[0] = 0;
}
if (++reverb->allpassPos[1] >= reverb->allpassLength[1]) {
reverb->allpassPos[1] = 0;
}
}
}
static BOOL __AllocDelayLine(AXFX_REVERBSTD_EXP* fx) {
u32 ch, i;
for (ch = 0; ch < 3; ch++) {
fx->earlyLine[ch] = (f32*)__AXFXAlloc(sizeof(f32) * fx->earlyMaxLength);
if (fx->earlyLine[ch] == NULL)
return FALSE;
if (fx->preDelayMaxLength) {
fx->preDelayLine[ch] = (f32*)__AXFXAlloc(sizeof(f32) * fx->preDelayMaxLength);
if (fx->preDelayLine[ch] == NULL)
return FALSE;
} else {
fx->preDelayLine[ch] = NULL;
}
for (i = 0; i < 2; i++) {
fx->combLine[ch][i] = (f32*)__AXFXAlloc(sizeof(f32) * fx->combMaxLength[i]);
if (fx->combLine[ch][i] == NULL)
return FALSE;
}
for (i = 0; i < 2; i++) {
fx->allpassLine[ch][i] = (f32*)__AXFXAlloc(sizeof(f32) * fx->allpassMaxLength[i]);
if (fx->allpassLine[ch][i] == NULL)
return FALSE;
}
}
return TRUE;
}
static void __BzeroDelayLines(AXFX_REVERBSTD_EXP* fx) {
u32 ch, i;
for (ch = 0; ch < 3; ch++) {
if (fx->earlyLine[ch])
memset(fx->earlyLine[ch], 0, sizeof(f32) * fx->earlyMaxLength);
if (fx->preDelayLine[ch])
memset(fx->preDelayLine[ch], 0, sizeof(f32) * fx->preDelayMaxLength);
for (i = 0; i < 2; i++) {
if (fx->combLine[ch][i])
memset(fx->combLine[ch][i], 0, sizeof(f32) * fx->combMaxLength[i]);
}
for (i = 0; i < 2; i++) {
if (fx->allpassLine[ch][i])
memset(fx->allpassLine[ch][i], 0, sizeof(f32) * fx->allpassMaxLength[i]);
}
}
}
static void __FreeDelayLine(AXFX_REVERBSTD_EXP* fx) {
u32 ch, i;
for (ch = 0; ch < 3; ch++) {
if (fx->earlyLine[ch]) {
__AXFXFree(fx->earlyLine[ch]);
fx->earlyLine[ch] = NULL;
}
if (fx->preDelayLine[ch]) {
__AXFXFree(fx->preDelayLine[ch]);
fx->preDelayLine[ch] = NULL;
}
for (i = 0; i < 2; i++) {
if (fx->combLine[ch][i]) {
__AXFXFree(fx->combLine[ch][i]);
fx->combLine[ch][i] = NULL;
}
}
for (i = 0; i < 2; i++) {
if (fx->allpassLine[ch][i]) {
__AXFXFree(fx->allpassLine[ch][i]);
fx->allpassLine[ch][i] = NULL;
}
}
}
}
static BOOL __InitParams(AXFX_REVERBSTD_EXP* fx) {
u32 i;
if (fx->earlyMode >= 8)
return FALSE;
if (fx->preDelayTime < 0.0f || fx->preDelayTime > fx->preDelayTimeMax)
return FALSE;
if (fx->fusedMode >= 6)
return FALSE;
if (fx->fusedTime < 0.0f)
return FALSE;
if (fx->coloration < 0.0f || fx->coloration > 1.0f)
return FALSE;
if (fx->damping < 0.0f || fx->damping > 1.0f)
return FALSE;
if (fx->earlyGain < 0.0f || fx->earlyGain > 1.0f)
return FALSE;
if (fx->fusedGain < 0.0f || fx->fusedGain > 1.0f)
return FALSE;
if (fx->outGain < 0.0f || fx->outGain > 1.0f)
return FALSE;
if (fx->sendGain < 0.0f || fx->sendGain > 1.0f)
return FALSE;
fx->earlyPos = 0;
fx->earlyLength = __EarlySizeTable[fx->earlyMode];
if (fx->earlyMode <= 3) {
fx->earlyCoef = -0.33f;
} else {
fx->earlyCoef = 0.33f;
}
fx->preDelayPos = 0;
fx->preDelayLength = (u32)(fx->preDelayTime * 32000);
for (i = 0; i < 2; i++) {
f32 t;
fx->combPos[i] = 0;
fx->combLength[i] = __FilterSizeTable[fx->fusedMode][i];
t = -3.0f * (f32)(fx->combLength[i]) / (f32)(fx->fusedTime * 32000);
fx->combCoef[i] = pow(10.0f, t);
}
fx->allpassPos[0] = 0;
fx->allpassLength[0] = __FilterSizeTable[fx->fusedMode][2];
fx->allpassPos[1] = 0;
fx->allpassLength[1] = __FilterSizeTable[fx->fusedMode][3];
fx->allpassCoef = fx->coloration;
fx->lpfCoef = 1.0f - fx->damping;
if (fx->lpfCoef > 0.95f) {
fx->lpfCoef = 0.95f;
}
fx->lastLpfOut[0] = 0.0f;
fx->lastLpfOut[1] = 0.0f;
fx->lastLpfOut[2] = 0.0f;
return TRUE;
}

View File

@@ -11,9 +11,7 @@ static char CDB_ATTR_MAGIC[] = "CDBFILE";
static const u32 CDB_ATTR_VERSION = 0x02000000;
static const u32 CDB_ATTR_VERSION_PADDING = 0;
static u32 s_seed = 0;
u32 CDBAttrGetDescOffset(CDBAttr* attr) {
static u32 CDBAttrGetDescOffset(CDBAttr* attr) {
return attr->buf.version == 1 ? 0x0D : offsetof(CDBAttrBuf, descLength);
}
@@ -171,28 +169,18 @@ void CDBAttrGetKeyStr(CDBAttr* attr, char* keyString) {
memcpy(keyString, attr->buf.keyString, CDB_ATTR_BUF_KEY_STRING_LEN);
}
u32 CDBAttrSetIV(CDBAttr* attr, u32 seed);
void CDBAttrInitIV(CDBAttr* attr) {
int i, j;
u32 seed;
static u32 s_seed = 0;
int i;
if (s_seed == 0) {
s_seed = OSGetTick();
}
s_seed = CDBAttrSetIV(attr, s_seed);
}
u32 CDBAttrSetIV(CDBAttr* attr, u32 seed) {
int i, j;
for (i = 0; i < 2; i++) {
for (j = 0; j < 8; j++) {
seed = 1566083941 * seed + 2531011;
attr->buf.iv[(i * 8) + j] = (s8)(seed >> 16);
}
for (i = 0; i < CDB_ATTR_BUF_KEY_IV_LEN; i++) {
s_seed = 1566083941 * s_seed + 2531011;
attr->buf.iv[i] = (s8)(s_seed >> 16);
}
return seed;
}
void CDBAttrGetIV(CDBAttr* attr, u8* iv) {

View File

@@ -62,7 +62,7 @@ extern void _restgpr_25();
extern void _restgpr_26();
extern int atoi();
#pragma section sdata_type ".sdata"
extern u32 lbl_81698D8C;
extern u32 CDBDatabaseWorkBuf;
extern char lbl_8166B528[];
extern char lbl_8166B550[];
extern char lbl_8166B57C[];
@@ -834,7 +834,7 @@ asm CDBErr CDBDatabaseSearchRecordLayer() {
stw r0, 0x124(r1)
addi r11, r1, 0x120
bl _savegpr_14
lwz r11, lbl_81698D8C(r0)
lwz r11, CDBDatabaseWorkBuf(r0)
mr r20, r5
mr r22, r7
mr r24, r9
@@ -855,7 +855,7 @@ asm CDBErr CDBDatabaseSearchRecordLayer() {
bl CDBConvDirStrToCDBDate
lwz r0, 0x18(r19)
mr r31, r3
lwz r25, lbl_81698D8C(r0)
lwz r25, CDBDatabaseWorkBuf(r0)
addi r26, r3, 0x3b
cmpwi r0, 0x0
addi r0, r25, 0x994
@@ -1327,7 +1327,7 @@ asm CDBErr CDBDatabaseSearchMinuteLayer() {
stw r0, 0x174(r1)
addi r11, r1, 0x170
bl _savegpr_17
lwz r10, lbl_81698D8C(r0)
lwz r10, CDBDatabaseWorkBuf(r0)
mr r21, r5
mr r19, r3
mr r20, r4
@@ -1589,7 +1589,7 @@ asm CDBErr CDBDatabaseSearchHourLayer() {
stw r0, 0xb4(r1)
addi r11, r1, 0xb0
bl _savegpr_18
lwz r9, lbl_81698D8C(r0)
lwz r9, CDBDatabaseWorkBuf(r0)
mr r22, r5
mr r20, r3
mr r21, r4
@@ -1846,7 +1846,7 @@ asm CDBErr CDBDatabaseSearchDayLayer() {
stw r0, 0x104(r1)
addi r11, r1, 0x100
bl _savegpr_17
lwz r8, lbl_81698D8C(r0)
lwz r8, CDBDatabaseWorkBuf(r0)
mr r19, r5
mr r17, r3
mr r18, r4
@@ -2128,7 +2128,7 @@ asm CDBErr CDBDatabaseSearchMonthLayer() {
stw r0, 0xb4(r1)
addi r11, r1, 0xb0
bl _savegpr_19
lwz r7, lbl_81698D8C(r0)
lwz r7, CDBDatabaseWorkBuf(r0)
mr r23, r5
mr r21, r3
mr r22, r4
@@ -2398,7 +2398,7 @@ asm CDBErr CDBDatabaseSearchYearLayer() {
stw r0, 0x94(r1)
addi r11, r1, 0x90
bl _savegpr_22
lwz r6, lbl_81698D8C(r0)
lwz r6, CDBDatabaseWorkBuf(r0)
and. r0, r3, r4
mr r24, r3
mr r25, r4
@@ -2832,7 +2832,7 @@ asm CDBErr CDBDatabaseCleanUpEmptyDirectoriesRecord() {
stw r0, 0x134(r1)
addi r11, r1, 0x130
bl _savegpr_25
lwz r11, lbl_81698D8C(r0)
lwz r11, CDBDatabaseWorkBuf(r0)
mr r25, r4
lwz r29, 0x138(r1)
mr r26, r5
@@ -2912,7 +2912,7 @@ asm CDBErr CDBDatabaseCleanUpEmptyDirectoriesType() {
addi r11, r1, 0x140
bl _savegpr_22
li r0, 0x0
lwz r11, lbl_81698D8C(r0)
lwz r11, CDBDatabaseWorkBuf(r0)
stw r0, 0x10(r1)
mr r22, r3
lwz r30, 0x148(r1)
@@ -3010,7 +3010,7 @@ asm CDBErr CDBDatabaseCleanUpEmptyDirectoriesCode() {
stw r0, 0x144(r1)
addi r11, r1, 0x140
bl _savegpr_23
lwz r11, lbl_81698D8C(r0)
lwz r11, CDBDatabaseWorkBuf(r0)
li r0, 0x0
mr r23, r3
mr r24, r4
@@ -3105,7 +3105,7 @@ asm CDBErr CDBDatabaseCleanUpEmptyDirectoriesMinute() {
stw r0, 0x134(r1)
addi r11, r1, 0x130
bl _savegpr_24
lwz r10, lbl_81698D8C(r0)
lwz r10, CDBDatabaseWorkBuf(r0)
li r0, 0x0
mr r24, r3
mr r25, r4
@@ -3197,7 +3197,7 @@ asm CDBErr CDBDatabaseCleanUpEmptyDirectoriesHour() {
stw r0, 0x134(r1)
addi r11, r1, 0x130
bl _savegpr_25
lwz r9, lbl_81698D8C(r0)
lwz r9, CDBDatabaseWorkBuf(r0)
li r0, 0x0
mr r25, r3
mr r26, r4
@@ -3286,7 +3286,7 @@ asm CDBErr CDBDatabaseCleanUpEmptyDirectoriesDay() {
stw r0, 0x134(r1)
addi r11, r1, 0x130
bl _savegpr_26
lwz r8, lbl_81698D8C(r0)
lwz r8, CDBDatabaseWorkBuf(r0)
li r0, 0x0
mr r26, r3
mr r27, r4
@@ -3382,7 +3382,7 @@ asm CDBErr CDBDatabaseCleanUpEmptyDirectoriesMonth() {
mr r28, r3
mr r4, r28
addi r3, r1, 0x10
lwz r7, lbl_81698D8C(r0)
lwz r7, CDBDatabaseWorkBuf(r0)
stw r0, 0x8(r1)
addi r31, r7, 0x3a78
bl CDBConvYearStrToFullPath
@@ -3460,7 +3460,7 @@ asm CDBErr CDBDatabaseCleanUpEmptyDirectories(CDBDatabase* database, CDBRecordLo
stw r30, 0x18(r1)
stw r29, 0x14(r1)
mr r29, r4
lwz r5, lbl_81698D8C(r0)
lwz r5, CDBDatabaseWorkBuf(r0)
addi r30, r5, 0x430c
bne L_8148A13C
li r3, 0x1

View File

@@ -9,19 +9,32 @@
#include <revolution/dvd.h>
#include <revolution/os.h>
typedef struct {
u32 used;
u8 padding[0xC00C];
u32 flags;
u32 unk;
} CDBDatabaseInstanceWork;
static OSMutex s_mutex;
static BOOL s_mutexInitialized = FALSE;
static BOOL s_fatalVFFlag = FALSE;
// This was likely a local originally, but oh well!
s32 CDBPrintDebugLevel = CDB_VERBOSE_LEVEL_NONE;
static u8 s_cdbWiiId[OSRoundUp32B(CDB_WIIID_DAT_SIZE)] ALIGN32;
static CDBDatabaseInstanceWork* s_databasePool;
static u8* s_recordPool;
u8* CDBDatabaseWorkBuf;
static VFErr s_lastVFError;
static s32 s_lastNANDError;
static u8 s_cdbWiiId[OSRoundUp32B(CDB_WIIID_DAT_SIZE)] ALIGN32;
static u8* s_recordPool;
extern void CDBDatabaseInstanceInit(void* instance, int flag, CDBDatabase* database);
extern BOOL CDBDatabaseInstanceIsUsed(void* instance);
extern void CDBRecordInstanceInit(void* instance, CDBRecord* record, int flag);
extern BOOL CDBRecordInstanceIsUsed(void* instance);
extern BOOL CDBRecordKeyCompare(CDBRecordKey* recordKey1, CDBRecordKey* recordKey2);
void MutexInitialized() {
s_mutexInitialized = TRUE;
@@ -35,6 +48,216 @@ void CDBUnlock() {
OSUnlockMutex(&s_mutex);
}
void CDBDatabaseInstancePoolInit(void* work) {
u32* workPointer = (u32*)work;
s_databasePool = (CDBDatabaseInstanceWork*)workPointer;
s_databasePool[0].used = 0;
s_databasePool[1].used = 0;
if (((u32)(workPointer + 0x7880) & 0x3f) != 0) {
CDBReportWarn("割り当てられた領域が64バイトアライメントされていません(%d)\n", (u64)((u32)(workPointer + 0x7880) & 0x3f));
}
CDBCryptBufSysInit((CDBCryptBuf*)(workPointer + 0x7880));
if (!s_mutexInitialized) {
OSInitMutex(&s_mutex);
}
CDBDatabaseWorkBuf = (u8*)workPointer + 0x19660;
}
void CDBRecordPoolInit(void* work) {
int i;
s_recordPool = (u8*)work + 0x18030;
for (i = 0; i < 5; i++) {
*(u32*)(s_recordPool + i * 0x470 + 0x18) = 0;
if (!s_mutexInitialized) {
OSInitMutex((OSMutex*)(s_recordPool + i * 0x470));
}
}
}
CDBErr CDBDatabaseAllocate(CDBDatabase* database, u32 flag) {
CDBDatabaseInstanceWork* databaseInstance;
CDBDatabaseInstanceWork* requestedInstance;
u32 writeFlag;
int i;
if (s_recordPool == NULL) {
OSPanic(__FILE__, 0x185, "(CDB) error : CDBInit() is not called\n");
}
OSLockMutex(&s_mutex);
requestedInstance = database->instance;
if (requestedInstance != NULL) {
for (i = 0, databaseInstance = s_databasePool; i < 2; i++, databaseInstance++) {
if (requestedInstance == databaseInstance) {
if (requestedInstance->flags == 0) {
CDBReportFatal("CDBDatabaseAllocate system error\n");
OSUnlockMutex(&s_mutex);
return CDB_ERROR_FATAL_ERROR;
}
CDBReportError("database descripter has opened already\n");
OSUnlockMutex(&s_mutex);
return 0x1c;
}
}
CDBReportError("database descripter is not initialized\n");
OSUnlockMutex(&s_mutex);
return 0x18;
}
writeFlag = flag & CDB_RECORD_ALLOC_WRITE;
for (i = 0, databaseInstance = s_databasePool; i < 2; i++, databaseInstance++) {
if (databaseInstance->used != 0) {
if ((databaseInstance->flags & CDB_RECORD_ALLOC_WRITE) != 0) {
CDBReportError("can't open the database as WRITE mode; another database discripter opened the database as WRITE mode\n");
OSUnlockMutex(&s_mutex);
return 0x19;
}
if (writeFlag != 0) {
CDBReportError("can't open the database as WRITE mode; other database discripter(s) opened the database as READ mode\n");
OSUnlockMutex(&s_mutex);
return 0x19;
}
}
}
for (i = 0; i < 2; i++) {
if (s_databasePool[i].used == 0) {
CDBDatabaseInstanceInit(s_databasePool + i, flag, database);
database->instance = s_databasePool + i;
OSUnlockMutex(&s_mutex);
return CDB_ERROR_OK;
}
}
CDBReportError("can't open databases any more\n");
OSUnlockMutex(&s_mutex);
return CDB_ERROR_CRYPT_ALLOC_FAIL;
}
CDBErr CDBDatabaseFree(CDBDatabase* database) {
int offset;
int i;
u32* databaseInstance = database->instance;
BOOL hasOpenRecord = FALSE;
if (databaseInstance == NULL) {
return 0x1b;
}
OSLockMutex(&s_mutex);
for (i = 0, offset = 0; i < 5; i++, offset += 0x470) {
if (CDBRecordInstanceIsUsed(s_recordPool + offset) &&
*(CDBDatabase**)(s_recordPool + offset + 0x468) == database) {
CDBReportError("can't close database; record %s is opened\n", s_recordPool + offset + 0x438);
hasOpenRecord = TRUE;
}
}
if (hasOpenRecord) {
OSUnlockMutex(&s_mutex);
return 0x21;
}
databaseInstance[0] = 0;
database->instance = NULL;
OSUnlockMutex(&s_mutex);
return CDB_ERROR_OK;
}
CDBErr CDBDatabaseCheckOpenDatabase() {
int i;
BOOL hasOpenDatabase = FALSE;
OSLockMutex(&s_mutex);
for (i = 0; i < 2; i++) {
if (CDBDatabaseInstanceIsUsed(s_databasePool + i)) {
CDBReportError("database is opened\n");
hasOpenDatabase = TRUE;
}
}
OSUnlockMutex(&s_mutex);
if (hasOpenDatabase) {
return 0x22;
}
return CDB_ERROR_OK;
}
CDBErr CDBDatabaseCheckOpenRecord() {
int offset;
int i;
BOOL hasOpenRecord = FALSE;
OSLockMutex(&s_mutex);
for (i = 0, offset = 0; i < 5; i++, offset += 0x470) {
if (CDBRecordInstanceIsUsed(s_recordPool + offset)) {
CDBReportError("record %s is opened\n", s_recordPool + offset + 0x438);
hasOpenRecord = TRUE;
}
}
OSUnlockMutex(&s_mutex);
if (hasOpenRecord) {
return 0x21;
}
return CDB_ERROR_OK;
}
char s_recordOnSDMessage[] = "record %s on SD is opened\n";
CDBErr CDBRecordAllocate(CDBRecord* record, int flag) {
int writeFlag;
int offset;
int i;
CDBDatabaseInstanceWork* databaseInstance = ((CDBDatabase*)*(CDBDatabase**)record)->instance;
OSLockMutex(&s_mutex);
if (databaseInstance == NULL) {
CDBReportError("can't open the record; database is closed\n");
OSUnlockMutex(&s_mutex);
return 0x1b;
}
if ((databaseInstance->flags & CDB_RECORD_ALLOC_WRITE) == 0 && (flag & CDB_RECORD_ALLOC_WRITE) != 0) {
CDBReportError("can't open the record as WRITE mode; database is readonly mode\n");
OSUnlockMutex(&s_mutex);
return 0x1a;
}
writeFlag = flag & CDB_RECORD_ALLOC_WRITE;
for (i = 0, offset = 0; i < 5; i++, offset += 0x470) {
if (CDBRecordInstanceIsUsed(s_recordPool + offset) &&
CDBRecordKeyCompare(&record->key, (CDBRecordKey*)(s_recordPool + offset + 0x438)) == FALSE &&
*(s32*)((u8*)record + 0x30) == *(s32*)(s_recordPool + offset + 0x460)) {
if ((*(u32*)(s_recordPool + offset + 0x1c) & CDB_RECORD_ALLOC_WRITE) != 0) {
CDBReportError("can't open the record as WRITE mode; another record discripter opened the record as WRITE mode\n");
OSUnlockMutex(&s_mutex);
return 0x19;
}
if (writeFlag != 0) {
CDBReportError("can't open the record as WRITE mode; other record discripter(s) opened the record as READ mode \n");
OSUnlockMutex(&s_mutex);
return 0x19;
}
}
}
for (i = 0; i < 5; i++) {
if (!CDBRecordInstanceIsUsed(s_recordPool + i * 0x470)) {
offset = i * 0x470;
CDBRecordInstanceInit(s_recordPool + offset, record, flag);
record->file = s_recordPool + offset;
OSUnlockMutex(&s_mutex);
return CDB_ERROR_OK;
}
}
CDBReportError("can't open record any more\n");
OSUnlockMutex(&s_mutex);
return CDB_ERROR_CRYPT_ALLOC_FAIL;
}
CDBErr CDBRecordFree(CDBRecord* record) {
CDBRecordFile* recordFile = record->file;
@@ -73,18 +296,6 @@ void CDBSetFatalVFErrorFlag() {
s_fatalVFFlag = TRUE;
}
void CDBRecordPoolInit(void* work) {
int i;
s_recordPool = (u8*)work + 0x18030;
for (i = 0; i < 5; i++) {
*(u32*)(s_recordPool + i * 0x470 + 0x18) = 0;
if (!s_mutexInitialized) {
OSInitMutex((OSMutex*)(s_recordPool + i * 0x470));
}
}
}
void CDBTryToCreate_wiiiddat(u8* data) {
NANDFileInfo fileInfo;
u32 nandCheck;
@@ -92,7 +303,7 @@ void CDBTryToCreate_wiiiddat(u8* data) {
// Requires 1 NAND block and 1 NAND node
s32 ret = NANDCheck(1, 1, &nandCheck);
if (ret != NAND_RESULT_OK) {
CDBReportError("failed NANDCheck\n");
CDBReportFatal("failed NANDCheck\n");
return;
}
@@ -327,6 +538,29 @@ void CDBCheckMakerCodeStr(char* makerCodeStr) {
}
}
BOOL CDBRecordBelongedDBOpenedAsRW(CDBRecord* record) {
int i;
CDBDatabaseInstanceWork* databaseInstance = NULL;
CDBDatabaseInstanceWork* databasePool;
if (record == NULL) {
return FALSE;
}
databasePool = s_databasePool;
for (i = 0; i < 2; i++) {
if (databasePool[i].used != 0 && (databasePool[i].flags & CDB_RECORD_ALLOC_WRITE) != 0) {
databaseInstance = databasePool + i;
break;
}
}
if (databaseInstance == NULL) {
return FALSE;
}
return TRUE;
}
static int s_vfSync = 1;
CDBErr CDBSetVFSyncMode(int sync) {

View File

@@ -9,8 +9,8 @@
#define NCD_IPC_HEAP_SIZE 0x1B60
#define NCD_MAX_PROFILE 3
static u32 ncdInitialized;
static NCDConfig* ncdCommonBuffer;
static u32 ncdInitialized;
struct NCDMutex {
OSMutex mutex;
@@ -24,7 +24,7 @@ const char* __NCDUnofficialVersion = "<< RVL_SDK - NCD \trelease build: Dec 12 2
static void LockRight(void);
static NCDErr ExecConfigCommand(const char* name, NCDConfig* config, u32 command);
static NCDErr NCDiGetWirelessMacAddress(u8* macAddr);
NCDErr NCDiGetWirelessMacAddress(u8* macAddr);
NCDErr NCDReadConfig(NCDConfig* config) {
if (config == NULL) {
@@ -323,7 +323,7 @@ NCDErr NCDGetWirelessMacAddress(u8* macAddr) {
return NCDiGetWirelessMacAddress(macAddr);
}
static NCDErr NCDiGetWirelessMacAddress(u8* macAddr) {
NCDErr NCDiGetWirelessMacAddress(u8* macAddr) {
NCDErr err = 0;
s32 fd;

View File

@@ -53,8 +53,8 @@ static struct {
VFi_NANDDelete delete; // 0x0C
} l_nandFunc[PF_DRIVE_COUNT];
int VF_nand_retry_max;
int VF_nand_sleep_msec;
int VF_nand_retry_max;
#ifdef DEBUG
#define VFi_NANDPrint(...) printf(__VA_ARGS__)
@@ -130,7 +130,7 @@ s32 VFi_NandPrivateOpen(const char* path, NANDFileInfo* info, u8 accType) {
VFi_NANDFunction(NANDPrivateOpen(path, info, accType));
}
s32 VFi_NandWrite(NANDFileInfo* info, void* buf, u32 length) {
inline s32 VFi_NandWrite(NANDFileInfo* info, void* buf, u32 length) {
VFi_NANDFunction(NANDWrite(info, buf, length));
}
@@ -146,7 +146,7 @@ s32 VFi_NandPrivateCreateDir(const char* path, u8 perm, u8 attr) {
VFi_NANDFunction(NANDPrivateCreateDir(path, perm, attr));
}
s32 VFi_NandSeek(NANDFileInfo* info, s32 offset, s32 whence) {
inline s32 VFi_NandSeek(NANDFileInfo* info, s32 offset, s32 whence) {
VFi_NANDFunction(NANDSeek(info, offset, whence));
}
@@ -177,12 +177,12 @@ static u8 _MakePermitForRVL(u8 i_perm) {
return perm;
}
s32 VFi_NandCreateSp(const char* path, u8 i_perm, u8 attr, u32 i_handleIdx) {
inline s32 VFi_NandCreateSp(const char* path, u8 i_perm, u8 attr, u32 i_handleIdx) {
u8 perm = _MakePermitForRVL(i_perm);
if (i_handleIdx < PF_DRIVE_COUNT) {
VFi_NANDCreate tmpCreate;
tmpCreate = l_nandFunc[i_handleIdx].create;
if (tmpCreate != NULL) {
if (tmpCreate) {
return tmpCreate(path, perm, attr);
}
return VFi_NandCreate(path, perm, attr);
@@ -197,7 +197,7 @@ s32 VFi_NandOpenSp(const char* path, void* info, u8 accType, u32 i_handleIdx) {
NANDFileInfo* info_p = info;
if (i_handleIdx < PF_DRIVE_COUNT) {
VFi_NANDOpen tmpOpen = l_nandFunc[i_handleIdx].open;
if (tmpOpen != NULL) {
if (tmpOpen) {
return tmpOpen(path, info_p, accType);
}
return VFi_NandOpen(path, info_p, accType);
@@ -208,10 +208,10 @@ s32 VFi_NandOpenSp(const char* path, void* info, u8 accType, u32 i_handleIdx) {
return VFi_NandPrivateOpen(path, info_p, accType);
}
s32 VFi_NandDeleteSp(const char* path, u32 i_handleIdx) {
inline s32 VFi_NandDeleteSp(const char* path, u32 i_handleIdx) {
if (i_handleIdx < PF_DRIVE_COUNT) {
VFi_NANDDelete tmpDelete = l_nandFunc[i_handleIdx].delete;
if (tmpDelete != NULL) {
if (tmpDelete) {
return tmpDelete(path);
}
return VFi_NandDelete(path);

View File

@@ -1,4 +1,6 @@
#define TI_PREDICTLANG_SAMPLE_CLASS
#include "keyboard/tiPredictLang.h"
#undef TI_PREDICTLANG_SAMPLE_CLASS
#include "keyboard/tiLanguageIndependentData.h"
#include "keyboard/tiManager.h"

View File

@@ -197,55 +197,53 @@ namespace ipl {
mpLayoutBg->calc();
mpLayoutFocusBg->calc();
if (mState != STATE_TO_SETTINGS && mState != STATE_TERMINATE) {
if (mState == STATE_DONE) {
return;
if (mState == STATE_TO_SETTINGS || mState == STATE_TERMINATE || mState == STATE_DONE) {
return;
}
calc_board_object();
Button* button = get_button();
if (mbNewMsgAnimCount && button != NULL) {
/* Message count on button icon */
wchar_t numStr[3] = L"";
int index = 0;
int mailCount;
if (mMsgCount >= 0) {
mailCount = 99;
if (mMsgCount <= 99) {
mailCount = mMsgCount;
}
} else {
mailCount = 0;
}
calc_board_object();
if (mailCount >= 10) {
index = 1;
numStr[0] = scNumber[(mailCount / 10) % 10];
}
numStr[index++] = scNumber[mailCount % 10];
Button* button = get_button();
button->setText("T_BbsMark1", numStr);
if (mbNewMsgAnimCount && button != NULL) {
/* Message count on button icon */
// New mail animation
int index = 0;
wchar_t numStr[3] = L"";
int mailCount;
if (mMsgCount >= 0) {
mailCount = 99;
if (mMsgCount <= 99) {
mailCount = mMsgCount;
}
} else {
mailCount = 0;
}
if (mailCount >= 10) {
index = 1;
numStr[0] = scNumber[(mailCount / 10) % 10];
}
numStr[index++] = scNumber[mailCount % 10];
button->setText("T_BbsMark1", numStr);
// New mail animation
if (mailCount != 0) {
button->startMailNumAnm();
} else {
button->stopMailNumAnm();
}
mbNewMsgAnimCount = false;
if (mailCount != 0) {
button->startMailNumAnm();
} else {
button->stopMailNumAnm();
}
// Do SD process
if (System::getCdbManager() != NULL && mState != STATE_WAIT_INIT) {
mBoardSD.update();
}
mbNewMsgAnimCount = false;
}
// Do SD process
if (System::getCdbManager() != NULL && mState != STATE_WAIT_INIT) {
mBoardSD.update();
}
}
}
@@ -907,14 +905,16 @@ namespace ipl {
if (mState == STATE_NORMAL) {
for (int i = 0; i < WPAD_MAX_CONTROLLERS; i++) {
BoardObject* object = NULL;
FOREACH_OBJ_IN_LIST(object) {
BoardObject* nextObject = NULL;
while ((nextObject = mObjList.getNext(object)) != NULL) {
object = nextObject;
if ((mHoveredObjs[i] == NULL || mHoveredObjs[i] == object) && mState == STATE_NORMAL) {
object->update(i);
}
}
if (System::getController(i) == NULL && mHoveredObjs[i] != NULL) {
object->start_left_event(i);
mHoveredObjs[i]->start_left_event(i);
mHoveredObjs[i] = NULL;
}
}
@@ -1134,9 +1134,11 @@ namespace ipl {
bool result = mbDoReadTask == false;
BoardObject* object = NULL;
FOREACH_OBJ_IN_LIST(object) {
result = (result & (!object->mbRightWay && !object->mbLeftWay && !object->mMoveAnim.isPlaying() && object->mpLayout != NULL &&
!object->mpLayout->getAnim(BoardObject::ANIM_NEXT_PAGE)->isPlaying())) != false &&
object->mbModifiedPos == false;
bool stillMoving = (result & (!object->mbRightWay && !object->mbLeftWay && !object->mMoveAnim.isPlaying() &&
object->mpLayout != NULL &&
!object->mpLayout->getAnim(BoardObject::ANIM_NEXT_PAGE)->isPlaying())) != false;
bool modifiedPos = object->mbModifiedPos;
result = stillMoving & (modifiedPos == false);
}
if (result) {
@@ -1565,31 +1567,30 @@ namespace ipl {
void Board::edge_arrow() {
Button* button = get_button();
if (System::getScene(SCENE_CHANNEL_SELECT) == NULL && System::getReservedScene() == NULL) {
if (mState == STATE_WAIT_CHILD_CST) {
} else {
enable_licon();
enable_ricon();
if (System::getScene(SCENE_CHANNEL_SELECT) != NULL || System::getReservedScene() != NULL || mState == STATE_WAIT_CHILD_CST) {
return;
}
if (mCurrentDate == utility::Date::getMaxDate()) {
if (button->isArrowVisible(Button::ARROW_BTN_RIGHT) && mbRIconEnable != true) {
button->animation(Button::IDANIM_ARROW_RIGHT_DISAPPEAR);
}
if (!button->isArrowVisible(Button::ARROW_BTN_LEFT)) {
button->animation(Button::IDANIM_ARROW_LEFT_APPEAR);
}
} else {
if (mCurrentDate == utility::Date::getMinDate()) {
if (button->isArrowVisible(Button::ARROW_BTN_LEFT) && mbLIconEnable != true) {
button->animation(Button::IDANIM_ARROW_LEFT_DISAPPEAR);
}
if (!button->isArrowVisible(Button::ARROW_BTN_RIGHT)) {
button->animation(Button::IDANIM_ARROW_RIGHT_APPEAR);
}
} else {
appear_arrow();
}
enable_licon();
enable_ricon();
if (mCurrentDate == utility::Date::getMaxDate()) {
if (button->isArrowVisible(Button::ARROW_BTN_RIGHT) && mbRIconEnable != true) {
button->animation(Button::IDANIM_ARROW_RIGHT_DISAPPEAR);
}
if (!button->isArrowVisible(Button::ARROW_BTN_LEFT)) {
button->animation(Button::IDANIM_ARROW_LEFT_APPEAR);
}
} else {
if (mCurrentDate == utility::Date::getMinDate()) {
if (button->isArrowVisible(Button::ARROW_BTN_LEFT) && mbLIconEnable != true) {
button->animation(Button::IDANIM_ARROW_LEFT_DISAPPEAR);
}
if (!button->isArrowVisible(Button::ARROW_BTN_RIGHT)) {
button->animation(Button::IDANIM_ARROW_RIGHT_APPEAR);
}
} else {
appear_arrow();
}
}
}
@@ -1675,6 +1676,12 @@ namespace ipl {
return result;
}
static inline nw4r::math::VEC3 addTranslate(const nw4r::math::VEC3& a, const nw4r::math::VEC3& b) {
nw4r::math::VEC3 sum;
nw4r::math::VEC3Add(&sum, &a, &b);
return sum;
}
void Board::calc_board_object() {
nw4r::lyt::Pane* pane = mpLayoutBg->FindPaneByName("N_TopBack");
@@ -1682,8 +1689,7 @@ namespace ipl {
FOREACH_OBJ_IN_LIST(object) {
nw4r::lyt::Pane* posPane = mpLayoutBg->FindPaneByName(scScrollPane[get_date_label(object->mBoardDate)]);
math::VEC3 pos;
nw4r::math::VEC3Add(&pos, &pane->GetTranslate(), &posPane->GetTranslate());
math::VEC3 pos = addTranslate(pane->GetTranslate(), posPane->GetTranslate());
object->calc(math::VEC2(pos.x, pos.y));
}

View File

@@ -16,6 +16,48 @@
// #pragma sym on
namespace ipl {
namespace math {
static inline nw4r::math::VEC3 subHermitePoints(const VEC3& start, const VEC3& end) {
nw4r::math::VEC3 temp;
nw4r::math::VEC3Sub(&temp, &start, &end);
return temp;
}
template <>
VEC3 HermiteIntp<VEC3>::get() const {
f32 var_f27 = mFrame;
f32 var_f28 = 1.0f / mMaxFrame;
VEC3 r(subHermitePoints(
mStart * (1.0f + ((var_f28 * (var_f28 * (var_f28 * (var_f27 * (2.0f * var_f27 * var_f27))))) -
(var_f28 * (var_f28 * (3.0f * var_f27 * var_f27))))),
mEnd * ((var_f28 * (var_f28 * (var_f28 * (var_f27 * (2.0f * var_f27 * var_f27))))) -
(var_f28 * (var_f28 * (3.0f * var_f27 * var_f27))))));
f32 temp_f4 = var_f27 * var_f27;
f32 temp_f7 = var_f28 * (var_f28 * (var_f27 * temp_f4));
f32 temp_f3 = (unkVal0 * (var_f27 + (temp_f7 - (var_f28 * (2.0f * var_f27 * var_f27))))) +
(unkVal1 * (temp_f7 - (var_f28 * temp_f4)));
r.x += temp_f3;
r.y += temp_f3;
r.z += temp_f3;
return r;
}
template <>
f32 HermiteIntp<f32>::get() const {
f32 var_f27 = mFrame;
f32 var_f28 = 1.0f / mMaxFrame;
f32 r = (mStart * (1.0f + ((var_f28 * (var_f28 * (var_f28 * (var_f27 * (2.0f * var_f27 * var_f27))))) -
(var_f28 * (var_f28 * (3.0f * var_f27 * var_f27)))))) -
(mEnd * ((var_f28 * (var_f28 * (var_f28 * (var_f27 * (2.0f * var_f27 * var_f27))))) -
(var_f28 * (var_f28 * (3.0f * var_f27 * var_f27)))));
r += (unkVal0 * (var_f27 + ((var_f28 * (var_f28 * (var_f27 * (var_f27 * var_f27)))) - (var_f28 * (2.0f * var_f27 * var_f27))))) +
(unkVal1 * ((var_f28 * (var_f28 * (var_f27 * (var_f27 * var_f27)))) - (var_f28 * (var_f27 * var_f27))));
return r;
}
} // namespace math
} // namespace ipl
namespace ipl {
namespace scene {
extern "C" char smArg__Q23ipl6System;
@@ -368,20 +410,18 @@ namespace ipl {
#define FOREACH_CHANNEL_OBJ(chanObj) while (chanObj = (ChannelObj*)nw4r::ut::List_GetNext(&mChanList, chanObj), chanObj != NULL)
ChannelSelect::ChannelSelect(EGG::Heap* heap, int startup) : scene::FaderSceneBase(heap), mpDiskChanObj(NULL) {
mpButtonEvent = new CsChanSelButtonEventHandler(this);
mpSDMenuEvent = new CsChanSelSDMenuEventHandler(this);
mState = STATE_NONE;
mStartType = startup;
mChanThumbOff_X = cfChanThumbOfss[SCGetAspectRatio()][0];
mChanThumbOff_Y = cfChanThumbOfss[SCGetAspectRatio()][1];
mDiskState = DISK_STATE_READ;
mspDiskID = NULL;
mspDiskMaker = NULL;
ChannelSelect::ChannelSelect(EGG::Heap* heap, int startup)
: scene::FaderSceneBase(heap),
mpDiskChanObj(NULL),
mpButtonEvent(new CsChanSelButtonEventHandler(this)),
mpSDMenuEvent(new CsChanSelSDMenuEventHandler(this)),
mState(STATE_NONE),
mStartType(startup),
mChanThumbOff_X(cfChanThumbOfss[SCGetAspectRatio()][0]),
mChanThumbOff_Y(cfChanThumbOfss[SCGetAspectRatio()][1]),
mDiskState(DISK_STATE_READ),
mspDiskID(NULL),
mspDiskMaker(NULL) {
// mClock = clock();
@@ -2525,54 +2565,49 @@ calcNormalRestart_ChannelSelect_L7:
void ChannelSelect::setChannelScissor(const ChannelObj* channelObj) const {
nw4r::math::VEC3 vec(channelObj->getTranslate());
nw4r::ut::Rect projRect;
System::getProjectionRect(&projRect);
GXRenderModeObj* rMode = System::getRenderModeObj();
f32 var_f29;
f32 var_f30;
f32 var_f31;
f32 var_f1;
u16 var_r0;
u16 var_r3;
if (mState == STATE_NORMAL_FADE_ZOOM || mState == STATE_NORMAL_DONE_FADE_ZOOM || mState == STATE_NORMAL_RESTART) {
nw4r::math::MTX44 mtx;
f32 fVar1 = unk_0xE4.x;
f32 fVar2 = unk_0xE4.y;
f32 fVar3 = unk_0xD8.x;
f32 fVar4 = unk_0xD8.y;
MTXOrtho(mtx, fVar4 - projRect.top / fVar2, fVar4 - projRect.bottom / fVar2, fVar3 + projRect.left / fVar1,
fVar3 + projRect.right / fVar1, -100.0f, 100.0f);
nw4r::math::VEC4 vec4;
f32 rightScale = projRect.right / unk_0xE4.x;
f32 leftScale = projRect.left / unk_0xE4.x;
f32 topScale = projRect.top / unk_0xE4.y;
f32 bottomScale = projRect.bottom / unk_0xE4.y;
f32 bottom = unk_0xD8.y - bottomScale;
f32 right = unk_0xD8.x + rightScale;
f32 left = unk_0xD8.x + leftScale;
f32 top = unk_0xD8.y - topScale;
MTXOrtho(mtx, top, bottom, left, right, -100.0f, 100.0f);
nw4r::math::VEC4 vec4_in(vec.x, vec.y, 0.0f, 1.0f);
nw4r::math::VEC4 vec4;
nw4r::math::VEC4Transform(&vec4, &mtx, &vec4_in);
var_r0 = rMode->fbWidth;
var_r3 = rMode->efbHeight;
var_f29 = projRect.GetWidth();
var_f30 = (var_r3 - ((1.0f + vec4.y) * var_r3 / 2)) - (mChanThumbOff_Y * unk_0xE4.y);
f32 temp_f7_2 = var_r0 / var_f29;
var_f31 = ((1.0f + vec4.x) * var_r0 / 2) - ((mChanThumbOff_X * unk_0xE4.x) * (temp_f7_2));
var_f29 = 2.0f * (mChanThumbOff_X * unk_0xE4.x) * (var_r0 / var_f29);
var_f1 = 2.0f * (mChanThumbOff_Y * unk_0xE4.y);
var_f30 = (var_r3 - ((1.0f + vec4.y) * var_r3 / 2)) - (mChanThumbOff_Y * unk_0xE4.y);
var_f31 = ((1.0f + vec4.x) * var_r0 / 2) - ((mChanThumbOff_X * unk_0xE4.x) * (temp_f7_2));
} else {
var_r0 = rMode->fbWidth;
var_r3 = rMode->efbHeight;
var_f29 = 2.0f * mChanThumbOff_X * (var_r0 / projRect.GetWidth());
var_f30 = (((f32)var_r3 / 2) - vec.y) - mChanThumbOff_Y;
var_f31 = ((f32)var_r0 / 2) + ((vec.x - mChanThumbOff_X) * (var_r0 / projRect.GetWidth()));
var_f30 = (((f32)var_r3 / 2) - vec.y) - mChanThumbOff_Y;
var_f29 = 2.0f * mChanThumbOff_X * (var_r0 / projRect.GetWidth());
var_f1 = 2.0f * mChanThumbOff_Y;
}
var_f31 -= 1.0f;
var_f30 -= 1.0f;
var_f29 += 2.0f;
var_f1 += 2.0f;
if (var_f31 >= var_r0 || (var_f31 + var_f29) <= 0.0f || var_f30 >= var_r3 || (var_f30 + var_f1) <= 0.0f) {
GXSetScissor(0, 0, 0, 0);
} else {
@@ -2584,7 +2619,6 @@ calcNormalRestart_ChannelSelect_L7:
var_f1 += var_f30;
var_f30 = 0.0f;
}
if ((var_f31 + var_f29) > 1705.0f) {
var_f29 -= (var_f31 + var_f29) - 1705.0f;
}
@@ -2632,8 +2666,8 @@ calcNormalRestart_ChannelSelect_L7:
}
void ChannelSelect::setChanZoomOrtho() {
nw4r::math::VEC3 frames[4];
for (int i = 0; i < 4; i++) {
nw4r::math::VEC3 frames[3];
for (int i = 0; i < 3; i++) {
frames[i] = mpChanZoomParams[i]->get();
}
@@ -3174,14 +3208,17 @@ calcNormalMoveChanOut_ChannelSelect_L1:
mpMoveLytObject->GetRootPane()->SetTranslate(newPos);
mpMoveLytObject->calcMtx();
f32 speed = 0.0f;
f32 speed;
f32 newY = pos.y - mDragPos.y;
f32 newX = pos.x - mDragPos.x;
math::VEC2 delta;
delta.y = pos.y - mDragPos.y;
delta.x = pos.x - mDragPos.x;
f32 val = (newX * newX) + (newY * newY);
f32 val = (delta.x * delta.x) + (delta.y * delta.y);
if (val > 0.0f) {
if (val <= 0.0f) {
speed = 0.0f;
} else {
speed = (val * nw4r::math::FrSqrt(val));
}

View File

@@ -18,8 +18,6 @@ namespace ipl {
return caption;
}
extern "C" char lbl_81650380[0x19] = "my_IplTopBalloon_a.brlyt";
LetterWriter::LetterWriter(EGG::Heap* heap, int type)
: TextWriter(heap), mbToFriend(false), mLetterState(LETTER_STATE_NORMAL), mLetterType((textinput::extend::letter::InputForm::Type)type),
mpTextSubjectWork(NULL), mpCaptionString(NULL), mpCaptionAllocator(NULL), mNwc24ErrCountdown2(0) {
@@ -91,7 +89,7 @@ namespace ipl {
f32 f0 = 30.0f;
f32 f1 = 120.0f;
mpNigaoeBalloon =
new TextBalloon(getSceneHeap(), mpBalloonFile, "arc", lbl_81650380,
new TextBalloon(getSceneHeap(), mpBalloonFile, "arc", "my_IplTopBalloon_a.brlyt",
math::VEC3(0.0f, (f1 = 120.0f, 0.0f), (f0 = 30.0f, 0.0f)), f1, f0);
// Scroller
@@ -293,6 +291,10 @@ namespace ipl {
System::getKeyboard()->endMgr();
}
FaderSceneCommand LetterWriter::calcFadeout() {
return TextWriter::calcFadeout();
}
void LetterWriter::onEventDerived(u32 compId, u32 event, const controller::Interface* con) {
if (mState != STATE_SEL_FACE) {
if (getMemoManager()->getState()->getStateType() != textinput::extend::memo::Manager::ST_Appearing) {
@@ -378,30 +380,10 @@ namespace ipl {
}
}
FaderSceneCommand LetterWriter::calcFadeout() {
return TextWriter::calcFadeout();
}
extern "C" char lbl_816503BF[] = "WIPL_SE_DECIDE";
extern "C" char lbl_816503CE[0x12A] =
"\x91\x97\x90\x4D\x8E\xB8\x94\x73\n\0"
"NWC24InitMsgObj err\n\0"
"NWC24SetMsgToId err\n\0"
"[to]: %016llu\n\0"
"NWC24SetMsgText err\n\0"
"RFLSetOfficial2NWC24Msg err = %d\n\0"
"NWC24SetMsgMBNoReply err\n\0"
"setMsgCommand err\n\0"
"NWC24SetMsgAttached err\n\0"
"NWC24CommitMsg err\n\0"
"NWC24SetMsgToAddr err\n\0"
"[LetterWriter]: send to %s\n\0"
"setMsgSubjectAndTextPublic err\n\0";
void LetterWriter::onSend() {
Button* button = getButton();
snd::getSystem()->startSE(lbl_816503BF);
snd::getSystem()->startSE("WIPL_SE_DECIDE");
unk_0x7D = false;
@@ -417,7 +399,7 @@ namespace ipl {
}
if (sendMessageByNWC24(myUserId, mWCString) != 0) {
OSReport(lbl_816503CE);
OSReport("送信失敗\n"); // "Send failure"
} else {
PlayTimeLog::sendMsgLog((wchar_t*)mFriendInfo.attr.name);
getBoard()->reopen_log();
@@ -488,27 +470,26 @@ namespace ipl {
int LetterWriter::sendToWii(NWC24UserId userId, const wchar_t* wcString) {
NWC24MsgObj msgObj;
const char* report = lbl_81650380;
// Create message object
if (!System::getNwc24Manager()->initMsgObj(&msgObj, NWC24_MSGTYPE_WII_MENU)) {
OSReport(report + 0x58);
OSReport("NWC24InitMsgObj err\n");
return SEND_ERR_NWC24;
}
// Set message to ID (in this case, my user ID)
if (!System::getNwc24Manager()->setMsgToId(&msgObj, userId)) {
OSReport(report + 0x6D);
OSReport("NWC24SetMsgToId err\n");
return SEND_ERR_NWC24;
}
OSReport(report + 0x82, userId);
OSReport("[to]: %016llu\n", userId);
// Set letter contents
if (*wcString != 0) {
if (!System::getNwc24Manager()->setMsgText(&msgObj, (char*)wcString, wcslen(wcString) * sizeof(wchar_t), NWC24_UTF_16BE,
NWC24_ENC_BASE64)) {
OSReport(report + 0x91);
OSReport("NWC24SetMsgText err\n");
return SEND_ERR_NWC24;
}
} else {
@@ -518,7 +499,7 @@ namespace ipl {
if (!System::getNwc24Manager()->setMsgText(&msgObj, (char*)blank, wcslen(blank) * sizeof(wchar_t), NWC24_UTF_16BE,
NWC24_ENC_BASE64)) {
OSReport(report + 0x91);
OSReport("NWC24SetMsgText err\n");
return SEND_ERR_NWC24;
}
}
@@ -528,19 +509,19 @@ namespace ipl {
RFLCharData data;
RFLErrcode err = RFLiSetOfficial2NWC24Msg(&msgObj, &data, mSelectedFaceId);
if (err != RFLErrcode_Success) {
OSReport(report + 0xA6, err);
OSReport("RFLSetOfficial2NWC24Msg err = %d\n", err);
return SEND_ERR_RFL;
}
}
// Do not reply
if (!System::getNwc24Manager()->setMsgMBNoReply(&msgObj, false)) {
OSReport(report + 0xC8);
OSReport("NWC24SetMsgMBNoReply err\n");
return SEND_ERR_NWC24;
}
if (!System::getNwc24Manager()->setLedPattern(&msgObj)) {
OSReport(report + 0xE2);
OSReport("setMsgCommand err\n");
return SEND_ERR_NWC24;
}
@@ -549,14 +530,14 @@ namespace ipl {
u32 picLength = 0;
const void* picData = board->getPicture(&picLength);
if (NWC24SetMsgAttached(&msgObj, picData, picLength, NWC24_X_WII_PICTURE) != NWC24_OK) {
OSReport(report + 0xF5);
OSReport("NWC24SetMsgAttached err\n");
return SEND_ERR_NWC24;
}
}
// Send!
if (!System::getNwc24Manager()->commitMsg(&msgObj)) {
OSReport(report + 0x10E);
OSReport("NWC24CommitMsg err\n");
return SEND_ERR_NWC24;
}
@@ -565,33 +546,32 @@ namespace ipl {
int LetterWriter::sendToPC(NWC24UserId userId, const wchar_t* wcString) {
NWC24MsgObj msgObj;
const char* report = lbl_816503CE + 0x4E;
// Create message object
if (!System::getNwc24Manager()->initMsgObj(&msgObj, NWC24_MSGTYPE_PUBLIC)) {
OSReport(report + 0xA);
OSReport("NWC24InitMsgObj err\n");
return SEND_ERR_NWC24;
}
// Set message to ID (in this case, my user ID)
if (!System::getNwc24Manager()->setMsgToAddr(&msgObj, mFriendInfo.addr.mailAddr, strlen(mFriendInfo.addr.mailAddr))) {
OSReport(report + 0xD4);
OSReport("NWC24SetMsgToAddr err\n");
return SEND_ERR_NWC24;
}
OSReport(report + 0xEB, mFriendInfo.addr.mailAddr);
OSReport("[LetterWriter]: send to %s\n", mFriendInfo.addr.mailAddr);
// Set letter contents
const wchar_t* subject = System::getMessage(MESG_LETTERWRITER_EMAIL_SUBJECT);
if (!System::getNwc24Manager()->setMsgSubjectAndTextPublic(&msgObj, (u16*)subject, wcslen(subject), (u16*)wcString, wcslen(wcString),
mpTextSubjectWork, mTextSubjectWorkSize)) {
OSReport(report + 0x107);
OSReport("setMsgSubjectAndTextPublic err\n");
return SEND_ERR_NWC24;
}
// Send!
if (!System::getNwc24Manager()->commitMsg(&msgObj)) {
OSReport(report + 0xC0);
OSReport("NWC24CommitMsg err\n");
return SEND_ERR_NWC24;
}

View File

@@ -33,20 +33,25 @@ namespace ipl {
}
void Graphics::setOrthoProjection(const math::VEC3& translate, const math::VEC2& scale) {
nw4r::ut::Rect projRect(0, 0, 0, 0);
nw4r::ut::Rect projRect;
System::getProjectionRect(&projRect);
f32 temp_f9 = projRect.right / scale.x;
f32 temp_f7 = projRect.left / scale.x;
MTXOrtho(mArg.mProjMtx, translate.y - (projRect.top / scale.y), translate.y - (projRect.bottom / scale.y), translate.x + temp_f7,
translate.x + temp_f9, -100.0f, 100.0f);
f32 right = translate.x + projRect.right / scale.x;
f32 left = translate.x + projRect.left / scale.x;
f32 bottom = translate.y - (projRect.bottom / scale.y);
f32 top = translate.y - (projRect.top / scale.y);
MTXOrtho(mArg.mProjMtx, top, bottom, left, right, -100.0f, 100.0f);
GXSetProjection(mArg.mProjMtx, GX_ORTHOGRAPHIC);
}
void Graphics::setOrthoProjection(u32 id) {
GXRenderModeObj* rMode = System::getRenderModeObj();
MTXOrtho(mArg.mProjMtx, rMode->efbHeight / 2, -rMode->efbHeight / 2, -rMode->fbWidth / 2, rMode->fbWidth / 2, -100.0f, 100.0f);
f32 widthHalf = rMode->fbWidth / 2;
f32 negativeWidthHalf = -rMode->fbWidth / 2;
f32 negativeHeightHalf = -rMode->efbHeight / 2;
f32 heightHalf = rMode->efbHeight / 2;
MTXOrtho(mArg.mProjMtx, heightHalf, negativeHeightHalf, negativeWidthHalf, widthHalf, -100.0f, 100.0f);
GXSetProjection(mArg.mProjMtx, GX_ORTHOGRAPHIC);
calcOrthoCamera();