configure all of RVL_SDK

This commit is contained in:
shibbo 2024-10-24 20:11:07 -04:00
parent 6355cf960c
commit a6260ca4d9
4 changed files with 1004 additions and 272 deletions

File diff suppressed because it is too large Load Diff

View File

@ -257,6 +257,37 @@ cflags_nw = [
f"-DVERSION={version_num}",
]
cflags_sdk = [
"-nodefaults",
"-lang c++",
"-proc gekko",
"-align powerpc",
"-enum int",
"-fp hardware",
"-Cpp_exceptions off",
"-O4,p",
"-inline auto",
'-pragma "cats off"',
'-pragma "warn_notinlined off"',
"-maxerrors 1",
"-nosyspath",
"-RTTI off",
"-fp_contract on",
"-str reuse",
"-enc SJIS",
"-ipa file",
"-sdata 8",
"-sdata2 8",
"-i libs/MSL_C++/include",
"-i libs/MSL_C/include",
"-i libs/MetroTRK/include",
"-i libs/RVLFaceLib/include",
"-i libs/RVL_SDK/include",
"-i libs/Runtime/include",
f"-i build/{config.version}/include",
f"-DVERSION={version_num}",
]
# Debug flags
if args.debug:
# Or -sym dwarf-2 for Wii compilers
@ -303,11 +334,11 @@ def NWLib(lib_name: str, objects: List[Object]) -> Dict[str, Any]:
# Helper function for Dolphin libraries
def DolphinLib(lib_name: str, objects: List[Object]) -> Dict[str, Any]:
def SDKLib(lib_name: str, objects: List[Object]) -> Dict[str, Any]:
return {
"lib": lib_name,
"mw_version": "GC/1.2.5n",
"cflags": cflags_base,
"mw_version": "GC/3.0a3",
"cflags": cflags_sdk,
"progress_category": "sdk",
"objects": objects,
}
@ -2131,7 +2162,488 @@ config.libs = [
Object(NonMatching, "Game/Util/TriggerChecker.cpp"),
Object(NonMatching, "Game/Util/ValueControl.cpp")
],
)
),
SDKLib(
"ai",
[
Object(Matching, "RVL_SDK/ai/ai.c")
]
),
SDKLib(
"aralt",
[
Object(NonMatching, "RVL_SDK/aralt/aralt.c")
]
),
SDKLib(
"arc",
[
Object(NonMatching, "RVL_SDK/arc/arc.c")
]
),
SDKLib(
"ax",
[
Object(NonMatching, "RVL_SDK/ax/AXAlloc.c"),
Object(NonMatching, "RVL_SDK/ax/AXAux.c"),
Object(NonMatching, "RVL_SDK/ax/AXCL.c"),
Object(NonMatching, "RVL_SDK/ax/AXVPB.c")
]
),
SDKLib(
"axfx",
[
Object(NonMatching, "RVL_SDK/axfx/AXFXReverbHi.c"),
Object(NonMatching, "RVL_SDK/axfx/AXFXReverbHiExp.c"),
Object(NonMatching, "RVL_SDK/axfx/AXFXHooks.c")
]
),
SDKLib(
"base",
[
Object(NonMatching, "RVL_SDK/base/PPCArch.c")
]
),
SDKLib(
"bte",
[
Object(NonMatching, "RVL_SDK/bte/gki_buffer.c"),
Object(NonMatching, "RVL_SDK/bte/gki_time.c"),
Object(NonMatching, "RVL_SDK/bte/gki_ppc.c"),
Object(NonMatching, "RVL_SDK/bte/hcisu_h2.c"),
Object(NonMatching, "RVL_SDK/bte/bta_dm_cfg.c"),
Object(NonMatching, "RVL_SDK/bte/bta_hh_cfg.c"),
Object(NonMatching, "RVL_SDK/bte/bta_sys_cfg.c"),
Object(NonMatching, "RVL_SDK/bte/uusb_ppc.c"),
Object(NonMatching, "RVL_SDK/bte/bte_hcisu.c"),
Object(NonMatching, "RVL_SDK/bte/bte_init.c"),
Object(NonMatching, "RVL_SDK/bte/bte_logmsg.c"),
Object(NonMatching, "RVL_SDK/bte/bte_main.c"),
Object(NonMatching, "RVL_SDK/bte/btu_task1.c"),
Object(NonMatching, "RVL_SDK/bte/bd.c"),
Object(NonMatching, "RVL_SDK/bte/bta_sys_conn.c"),
Object(NonMatching, "RVL_SDK/bte/bta_sys_main.c"),
Object(NonMatching, "RVL_SDK/bte/ptim.c"),
Object(NonMatching, "RVL_SDK/bte/utl.c"),
Object(NonMatching, "RVL_SDK/bte/bta_dm_act.c"),
Object(NonMatching, "RVL_SDK/bte/bta_dm_api.c"),
Object(NonMatching, "RVL_SDK/bte/bta_dm_main.c"),
Object(NonMatching, "RVL_SDK/bte/bta_dm_pm.c"),
Object(NonMatching, "RVL_SDK/bte/bta_hh_act.c"),
Object(NonMatching, "RVL_SDK/bte/bta_hh_api.c"),
Object(NonMatching, "RVL_SDK/bte/bta_hh_main.c"),
Object(NonMatching, "RVL_SDK/bte/bta_hh_utils.c"),
Object(NonMatching, "RVL_SDK/bte/btm_acl.c"),
Object(NonMatching, "RVL_SDK/bte/btm_dev.c"),
Object(NonMatching, "RVL_SDK/bte/btm_devctl.c"),
Object(NonMatching, "RVL_SDK/bte/btm_discovery.c"),
Object(NonMatching, "RVL_SDK/bte/btm_inq.c"),
Object(NonMatching, "RVL_SDK/bte/btm_main.c"),
Object(NonMatching, "RVL_SDK/bte/btm_pm.c"),
Object(NonMatching, "RVL_SDK/bte/btm_sco.c"),
Object(NonMatching, "RVL_SDK/bte/btm_sec.c"),
Object(NonMatching, "RVL_SDK/bte/btu_hcif.c"),
Object(NonMatching, "RVL_SDK/bte/btu_init.c"),
Object(NonMatching, "RVL_SDK/bte/wbt_ext.c"),
Object(NonMatching, "RVL_SDK/bte/gap_api.c"),
Object(NonMatching, "RVL_SDK/bte/gap_conn.c"),
Object(NonMatching, "RVL_SDK/bte/gap_utils.c"),
Object(NonMatching, "RVL_SDK/bte/hcicmds.c"),
Object(NonMatching, "RVL_SDK/bte/hidd_api.c"),
Object(NonMatching, "RVL_SDK/bte/hidd_conn.c"),
Object(NonMatching, "RVL_SDK/bte/hidd_mgmt.c"),
Object(NonMatching, "RVL_SDK/bte/hidd_pm.c"),
Object(NonMatching, "RVL_SDK/bte/hidh_api.c"),
Object(NonMatching, "RVL_SDK/bte/hidh_conn.c"),
Object(NonMatching, "RVL_SDK/bte/l2c_api.c"),
Object(NonMatching, "RVL_SDK/bte/l2c_csm.c"),
Object(NonMatching, "RVL_SDK/bte/l2c_link.c"),
Object(NonMatching, "RVL_SDK/bte/l2c_main.c"),
Object(NonMatching, "RVL_SDK/bte/l2c_utils.c"),
Object(NonMatching, "RVL_SDK/bte/port_api.c"),
Object(NonMatching, "RVL_SDK/bte/port_rfc.c"),
Object(NonMatching, "RVL_SDK/bte/port_utils.c"),
Object(NonMatching, "RVL_SDK/bte/rfc_l2cap_if.c"),
Object(NonMatching, "RVL_SDK/bte/rfc_mx_fsm.c"),
Object(NonMatching, "RVL_SDK/bte/rfc_port_fsm.c"),
Object(NonMatching, "RVL_SDK/bte/rfc_port_if.c"),
Object(NonMatching, "RVL_SDK/bte/rfc_ts_frames.c"),
Object(NonMatching, "RVL_SDK/bte/rfc_utils.c"),
Object(NonMatching, "RVL_SDK/bte/sdp_api.c"),
Object(NonMatching, "RVL_SDK/bte/sdp_db.c"),
Object(NonMatching, "RVL_SDK/bte/sdp_discovery.c"),
Object(NonMatching, "RVL_SDK/bte/sdp_main.c"),
Object(NonMatching, "RVL_SDK/bte/sdp_server.c"),
Object(NonMatching, "RVL_SDK/bte/sdp_utils.c")
]
),
SDKLib(
"db",
[
Object(NonMatching, "RVL_SDK/db/db.c")
]
),
SDKLib(
"dsp",
[
Object(NonMatching, "RVL_SDK/dsp/dsp.c"),
Object(NonMatching, "RVL_SDK/dsp/dsp_debug.c"),
Object(NonMatching, "RVL_SDK/dsp/dsp_task.c")
]
),
SDKLib(
"dvd",
[
Object(NonMatching, "RVL_SDK/dvd/dvdfs.c"),
Object(NonMatching, "RVL_SDK/dvd/dvd.c"),
Object(NonMatching, "RVL_SDK/dvd/dvdqueue.c"),
Object(NonMatching, "RVL_SDK/dvd/dvderror.c"),
Object(NonMatching, "RVL_SDK/dvd/dvdidutils.c"),
Object(NonMatching, "RVL_SDK/dvd/dvdFatal.c"),
Object(NonMatching, "RVL_SDK/dvd/dvdDeviceError.c"),
Object(NonMatching, "RVL_SDK/dvd/dvd_broadway.c")
]
),
SDKLib(
"esp",
[
Object(NonMatching, "RVL_SDK/esp/esp.c")
]
),
SDKLib(
"euart",
[
Object(NonMatching, "RVL_SDK/euart/euart.c")
]
),
SDKLib(
"exi",
[
Object(NonMatching, "RVL_SDK/exi/EXIBios.c"),
Object(NonMatching, "RVL_SDK/exi/EXIUart.c"),
Object(NonMatching, "RVL_SDK/exi/EXICommon.c")
]
),
SDKLib(
"fs",
[
Object(NonMatching, "RVL_SDK/fs/fs.c")
]
),
SDKLib(
"gd",
[
Object(NonMatching, "RVL_SDK/gd/GDBase.c"),
Object(NonMatching, "RVL_SDK/gd/GDGeometry.c"),
Object(NonMatching, "RVL_SDK/gd/GDIndirect.c"),
Object(NonMatching, "RVL_SDK/gd/GDLight.c"),
Object(NonMatching, "RVL_SDK/gd/GDPixel.c"),
Object(NonMatching, "RVL_SDK/gd/GDTev.c"),
Object(NonMatching, "RVL_SDK/gd/GDTexture.c"),
Object(NonMatching, "RVL_SDK/gd/GDTransform.c")
]
),
SDKLib(
"gx",
[
Object(NonMatching, "RVL_SDK/gx/GXInit.c"),
Object(NonMatching, "RVL_SDK/gx/GXFifo.c"),
Object(NonMatching, "RVL_SDK/gx/GXAttr.c"),
Object(NonMatching, "RVL_SDK/gx/GXMisc.c"),
Object(NonMatching, "RVL_SDK/gx/GXGeometry.c"),
Object(NonMatching, "RVL_SDK/gx/GXFrameBuf.c"),
Object(NonMatching, "RVL_SDK/gx/GXLight.c"),
Object(NonMatching, "RVL_SDK/gx/GXTexture.c"),
Object(NonMatching, "RVL_SDK/gx/GXBump.c"),
Object(NonMatching, "RVL_SDK/gx/GXTev.c"),
Object(NonMatching, "RVL_SDK/gx/GXPixel.c"),
Object(NonMatching, "RVL_SDK/gx/GXDisplayList.c"),
Object(NonMatching, "RVL_SDK/gx/GXTransform.c"),
Object(NonMatching, "RVL_SDK/gx/GXPerf.c")
]
),
SDKLib(
"ipc",
[
Object(NonMatching, "RVL_SDK/ipc/ipcMain.c"),
Object(NonMatching, "RVL_SDK/ipc/ipcclt.c"),
Object(NonMatching, "RVL_SDK/ipc/memory.c"),
Object(NonMatching, "RVL_SDK/ipc/ipcProfile.c")
]
),
SDKLib(
"kpad",
[
Object(NonMatching, "RVL_SDK/kpad/KPAD.c")
]
),
SDKLib(
"mem",
[
Object(NonMatching, "RVL_SDK/mem/mem_heapCommon.c"),
Object(NonMatching, "RVL_SDK/mem/mem_expHeap.c"),
Object(NonMatching, "RVL_SDK/mem/mem_allocator.c"),
Object(NonMatching, "RVL_SDK/mem/mem_list.c"),
]
),
SDKLib(
"mtx",
[
Object(NonMatching, "RVL_SDK/mtx/mtx.c"),
Object(NonMatching, "RVL_SDK/mtx/mtxvec.c"),
Object(NonMatching, "RVL_SDK/mtx/mtx44.c"),
Object(NonMatching, "RVL_SDK/mtx/vec.c"),
Object(NonMatching, "RVL_SDK/mtx/quat.c")
]
),
SDKLib(
"nand",
[
Object(NonMatching, "RVL_SDK/nand/nand.c"),
Object(NonMatching, "RVL_SDK/nand/NANDOpenClose.c"),
Object(NonMatching, "RVL_SDK/nand/NANDCore.c"),
Object(NonMatching, "RVL_SDK/nand/NANDSecret.c"),
Object(NonMatching, "RVL_SDK/nand/NANDCheck.c"),
Object(NonMatching, "RVL_SDK/nand/NANDLogging.c"),
]
),
SDKLib(
"net",
[
Object(NonMatching, "RVL_SDK/net/nettime.c"),
Object(NonMatching, "RVL_SDK/net/NETVersion.c"),
Object(NonMatching, "RVL_SDK/net/netmemcpy.c"),
Object(NonMatching, "RVL_SDK/net/netmemset.c")
]
),
SDKLib(
"nwc24",
[
Object(NonMatching, "RVL_SDK/nwc24/NWC24StdAPI.c"),
Object(NonMatching, "RVL_SDK/nwc24/NWC24FileAPI.c"),
Object(NonMatching, "RVL_SDK/nwc24/NWC24Config.c"),
Object(NonMatching, "RVL_SDK/nwc24/NWC24Utils.c"),
Object(NonMatching, "RVL_SDK/nwc24/NWC24Manage.c"),
Object(NonMatching, "RVL_SDK/nwc24/NWC24MsgObj.c"),
Object(NonMatching, "RVL_SDK/nwc24/NWC24MBoxCtrl.c"),
Object(NonMatching, "RVL_SDK/nwc24/NWC24Mime.c"),
Object(NonMatching, "RVL_SDK/nwc24/NWC24Parser.c"),
Object(NonMatching, "RVL_SDK/nwc24/NWC24MsgCommit.c"),
Object(NonMatching, "RVL_SDK/nwc24/NWC24Schedule.c"),
Object(NonMatching, "RVL_SDK/nwc24/NWC24DateParser.c"),
Object(NonMatching, "RVL_SDK/nwc24/NWC24FriendList.c"),
Object(NonMatching, "RVL_SDK/nwc24/NWC24SecretFList.c"),
Object(NonMatching, "RVL_SDK/nwc24/NWC24UserId.c"),
Object(NonMatching, "RVL_SDK/nwc24/NWC24Time.c"),
Object(NonMatching, "RVL_SDK/nwc24/NWC24Ipc.c"),
Object(NonMatching, "RVL_SDK/nwc24/NWC24Download.c"),
Object(NonMatching, "RVL_SDK/nwc24/NWC24System.c")
]
),
SDKLib(
"os",
[
Object(NonMatching, "RVL_SDK/os/OS.c"),
Object(NonMatching, "RVL_SDK/os/OSAlarm.c"),
Object(NonMatching, "RVL_SDK/os/OSAlloc.c"),
Object(NonMatching, "RVL_SDK/os/OSArena.c"),
Object(NonMatching, "RVL_SDK/os/OSAudioSystem.c"),
Object(NonMatching, "RVL_SDK/os/OSCache.c"),
Object(NonMatching, "RVL_SDK/os/OSContext.c"),
Object(NonMatching, "RVL_SDK/os/OSError.c"),
Object(NonMatching, "RVL_SDK/os/OSExec.c"),
Object(NonMatching, "RVL_SDK/os/OSFatal.c"),
Object(NonMatching, "RVL_SDK/os/OSFont.c"),
Object(NonMatching, "RVL_SDK/os/OSInterrupt.c"),
Object(NonMatching, "RVL_SDK/os/OSLink.c"),
Object(NonMatching, "RVL_SDK/os/OSMessage.c"),
Object(NonMatching, "RVL_SDK/os/OSMemory.c"),
Object(NonMatching, "RVL_SDK/os/OSMutex.c"),
Object(NonMatching, "RVL_SDK/os/OSReboot.c"),
Object(NonMatching, "RVL_SDK/os/OSReset.c"),
Object(NonMatching, "RVL_SDK/os/OSRtc.c"),
Object(NonMatching, "RVL_SDK/os/OSSync.c"),
Object(NonMatching, "RVL_SDK/os/OSThread.c"),
Object(NonMatching, "RVL_SDK/os/OSTime.c"),
Object(NonMatching, "RVL_SDK/os/OSUtf.c"),
Object(NonMatching, "RVL_SDK/os/OSIpc.c"),
Object(NonMatching, "RVL_SDK/os/OSStateTM.c"),
Object(NonMatching, "RVL_SDK/os/OSPlayRecord.c"),
Object(NonMatching, "RVL_SDK/os/OSStateFlags.c"),
Object(NonMatching, "RVL_SDK/os/OSNet.c"),
Object(NonMatching, "RVL_SDK/os/OSNandbootInfo.c"),
Object(NonMatching, "RVL_SDK/os/OSPlayTime.c"),
Object(NonMatching, "RVL_SDK/os/OSLaunch.c"),
Object(NonMatching, "RVL_SDK/os/__ppc_eabi_init.c")
]
),
SDKLib(
"pad",
[
Object(NonMatching, "RVL_SDK/pad/Pad.c")
]
),
SDKLib(
"rso",
[
Object(NonMatching, "RVL_SDK/rso/RSOLink.c")
]
),
SDKLib(
"sc",
[
Object(NonMatching, "RVL_SDK/sc/scsystem.c"),
Object(NonMatching, "RVL_SDK/sc/scapi.c"),
Object(NonMatching, "RVL_SDK/sc/scapi_prdinfo.c"),
]
),
SDKLib(
"si",
[
Object(NonMatching, "RVL_SDK/si/SIBios.c"),
Object(NonMatching, "RVL_SDK/si/SISamplingRate.c")
]
),
SDKLib(
"thp",
[
Object(NonMatching, "RVL_SDK/thp/THPDec.c"),
Object(NonMatching, "RVL_SDK/thp/THPAudio.c")
]
),
SDKLib(
"tpl",
[
Object(NonMatching, "RVL_SDK/tpl/TPL.c")
]
),
SDKLib(
"usb",
[
Object(NonMatching, "RVL_SDK/usb/usb.c")
]
),
SDKLib(
"vf",
[
Object(NonMatching, "RVL_SDK/vf/pf_clib.c"),
Object(NonMatching, "RVL_SDK/vf/pf_code.c"),
Object(NonMatching, "RVL_SDK/vf/pf_service.c"),
Object(NonMatching, "RVL_SDK/vf/pf_str.c"),
Object(NonMatching, "RVL_SDK/vf/pf_w_clib.c"),
Object(NonMatching, "RVL_SDK/vf/pf_driver.c"),
Object(NonMatching, "RVL_SDK/vf/pdm_bpb.c"),
Object(NonMatching, "RVL_SDK/vf/pdm_disk.c"),
Object(NonMatching, "RVL_SDK/vf/pdm_partition.c"),
Object(NonMatching, "RVL_SDK/vf/pdm_mbr.c"),
Object(NonMatching, "RVL_SDK/vf/pdm_dskmng.c"),
Object(NonMatching, "RVL_SDK/vf/pf_cache.c"),
Object(NonMatching, "RVL_SDK/vf/pf_cluster.c"),
Object(NonMatching, "RVL_SDK/vf/pf_dir.c"),
Object(NonMatching, "RVL_SDK/vf/pf_entry.c"),
Object(NonMatching, "RVL_SDK/vf/pf_entry_iterator.c"),
Object(NonMatching, "RVL_SDK/vf/pf_fat.c"),
Object(NonMatching, "RVL_SDK/vf/pf_fat12.c"),
Object(NonMatching, "RVL_SDK/vf/pf_fat16.c"),
Object(NonMatching, "RVL_SDK/vf/pf_fat32.c"),
Object(NonMatching, "RVL_SDK/vf/pf_fatfs.c"),
Object(NonMatching, "RVL_SDK/vf/pf_file.c"),
Object(NonMatching, "RVL_SDK/vf/pf_path.c"),
Object(NonMatching, "RVL_SDK/vf/pf_sector.c"),
Object(NonMatching, "RVL_SDK/vf/pf_volume.c"),
Object(NonMatching, "RVL_SDK/vf/pf_cp932.c"),
Object(NonMatching, "RVL_SDK/vf/pf_api_util.c"),
Object(NonMatching, "RVL_SDK/vf/pf_attach.c"),
Object(NonMatching, "RVL_SDK/vf/pf_detach.c"),
Object(NonMatching, "RVL_SDK/vf/pf_errnum.c"),
Object(NonMatching, "RVL_SDK/vf/pf_fclose.c"),
Object(NonMatching, "RVL_SDK/vf/pf_finfo.c"),
Object(NonMatching, "RVL_SDK/vf/pf_fopen.c"),
Object(NonMatching, "RVL_SDK/vf/pf_fread.c"),
Object(NonMatching, "RVL_SDK/vf/pf_fseek.c"),
Object(NonMatching, "RVL_SDK/vf/pf_fwrite.c"),
Object(NonMatching, "RVL_SDK/vf/pf_getdev.c"),
Object(NonMatching, "RVL_SDK/vf/pf_init_prfile2.c"),
Object(NonMatching, "RVL_SDK/vf/pf_remove.c"),
Object(NonMatching, "RVL_SDK/vf/pf_unmount.c"),
Object(NonMatching, "RVL_SDK/vf/pf_filelock.c"),
Object(NonMatching, "RVL_SDK/vf/pf_system.c"),
Object(NonMatching, "RVL_SDK/vf/d_vf.c"),
Object(NonMatching, "RVL_SDK/vf/d_vf_sys.c"),
Object(NonMatching, "RVL_SDK/vf/d_hash.c"),
Object(NonMatching, "RVL_SDK/vf/d_time.c"),
Object(NonMatching, "RVL_SDK/vf/d_common.c"),
Object(NonMatching, "RVL_SDK/vf/nand_drv.c"),
Object(NonMatching, "RVL_SDK/vf/sd_drv.c")
]
),
SDKLib(
"vi",
[
Object(NonMatching, "RVL_SDK/vi/vi.c"),
Object(NonMatching, "RVL_SDK/vi/i2c.c"),
Object(NonMatching, "RVL_SDK/vi/vi3in1.c")
]
),
SDKLib(
"wenc",
[
Object(NonMatching, "RVL_SDK/wenc/wenc.c")
]
),
SDKLib(
"wpad",
[
Object(NonMatching, "RVL_SDK/wpad/WPAD.c"),
Object(NonMatching, "RVL_SDK/wpad/WPADHIDParser.c"),
Object(NonMatching, "RVL_SDK/wpad/WPADEncrypt.c"),
Object(NonMatching, "RVL_SDK/wpad/debug_msg.c")
]
),
SDKLib(
"wud",
[
Object(NonMatching, "RVL_SDK/wud/WUD.c"),
Object(NonMatching, "RVL_SDK/wud/WUDHidHost.c"),
Object(NonMatching, "RVL_SDK/wud/debug_msg.c")
]
),
]
# Optional extra categories for progress tracking

View File

@ -1,6 +1,6 @@
def convert_entry(entry):
obj_name = entry.split("[")[1].split(".o")[0]
new_path = f"nw4r/lyt/{obj_name}.cpp"
new_path = f"RVL_SDK/vf/{obj_name}.c"
return f'Object(NonMatching, "{new_path}"),'
def process_file(input_filename, output_filename):

219
src/RVL_SDK/ai/ai.c Normal file
View File

@ -0,0 +1,219 @@
#include <revolution/ai.h>
#include <revolution/os.h>
#include <private/flipper.h>
static AIDCallback __AID_Callback;
static u8* __CallbackStack;
static u8* __OldStack;
static volatile BOOL __AI_init_flag = 0;
static volatile BOOL __AID_Active = 0;
static void __AIDHandler(__OSInterrupt, OSContext *);
static void __AICallbackStackSwitch(register void *);
static void __AI_SRC_INIT(void);
const char* __AIVersion = "<< RVL_SDK - AI \trelease build: Aug 8 2007 01:58:12 (0x4199_60831) >>";
AIDCallback AIRegisterDMACallback(AIDCallback cb) {
AIDCallback old;
BOOL intr;
old = __AID_Callback;
intr = OSDisableInterrupts();
__AID_Callback = cb;
OSRestoreInterrupts(intr);
return old;
}
void AIInitDMA(u32 start, u32 len) {
BOOL intr;
intr = OSDisableInterrupts();
__DSPRegs[0x18] = (__DSPRegs[0x18] & ~0x1FFF) | (start >> 16);
__DSPRegs[0x19] = (__DSPRegs[0x19] & ~0xFFE0) | (0xFFFF & start);
__DSPRegs[0x1B] = (__DSPRegs[0x1B] & ~0x7FFF) | ((len >> 5) & 0xFFFF);
OSRestoreInterrupts(intr);
}
void AIStartDMA(void) {
__DSPRegs[0x1B] |= 0x8000;
}
void AIStopDMA(void) {
__DSPRegs[0x1B] &= ~0x8000;
}
u32 AIGetDMAStartAddr(void) {
return (((__DSPRegs[0x1B] & 0x1FFF) << 16) | (__DSPRegs[0x19] & 0xFFE0));
}
u32 AIGetDMALength(void) {
return ((__DSPRegs[0x1B] & 0x7FFF) << 5);
}
// this ends up being inlined into AISetDSPSampleRate in the condition
u32 AIGetDSPSampleRate(void) {
return ((__AIRegs[0] & 0x40) >> 6) ^ 1;
}
void AISetDSPSampleRate(u32 sample_rate) {
BOOL intr;
if (sample_rate != AIGetDSPSampleRate()) {
__AIRegs[0] &= ~0x40;
if (sample_rate == 0) {
intr = OSDisableInterrupts();
__AI_SRC_INIT();
__AIRegs[0] |= 0x40;
OSRestoreInterrupts(intr);
}
}
}
static OSTime bound_32KHz;
static OSTime bound_48KHz;
static OSTime min_wait;
static OSTime max_wait;
static OSTime buffer;
void AIInit(u8 *pStack) {
u32 reg;
if (__AI_init_flag == 1) {
return;
}
OSRegisterVersion(__AIVersion);
bound_32KHz = OSNanosecondsToTicks(31524);
bound_48KHz = OSNanosecondsToTicks(42024);
min_wait = OSNanosecondsToTicks(42000);
max_wait = OSNanosecondsToTicks(63000);
buffer = OSNanosecondsToTicks(3000);
reg = __AIRegs[0];
reg &= ~(0x1 | 0x4 | 0x10);
__AIRegs[0] = reg;
__AIRegs[1] = 0;
__AIRegs[3] = 0;
__AIRegs[0] = (__AIRegs[0] & ~0x20) | (0x1 << 5);
AISetDSPSampleRate(0);
__AID_Callback = NULL;
__CallbackStack = pStack;
__OSSetInterruptHandler(5, __AIDHandler);
__OSUnmaskInterrupts(0x4000000);
__AI_init_flag = 1;
}
static void __AIDHandler(__OSInterrupt intr, OSContext *pContext) {
OSContext context;
u16 reg;
reg = __DSPRegs[5];
reg = (reg & ~(0x80 | 0x20) | 0x8);
__DSPRegs[5] = reg;
OSClearContext(&context);
OSSetCurrentContext(&context);
if (__AID_Callback) {
if (!__AID_Active) {
__AID_Active = 1;
if (__CallbackStack != NULL) {
__AICallbackStackSwitch(__AID_Callback);
}
else {
(*__AID_Callback)();
}
__AID_Active = 0;
}
}
OSClearContext(&context);
OSSetCurrentContext(pContext);
}
/* this function is written in assembly due to the direct stack changes */
asm static void __AICallbackStackSwitch(register void *cb) {
fralloc
lis r5, __OldStack@ha
addi r5, r5, __OldStack@l
stw r1, 0(r5)
lis r5, __CallbackStack@ha
addi r5, r5, __CallbackStack@l
lwz r1, 0(r5)
subi r1, r1, 8
mtlr cb
blrl
lis r5, __OldStack@ha
addi r5, r5, __OldStack@l
lwz r1, 0(r5)
frfree
blr
}
/* honestly I have no idea what's going on here */
void __AI_SRC_INIT(void) {
OSTime v0 = 0;
OSTime v1 = 0;
OSTime v2 = 0;
OSTime v4;
u32 v5;
u32 v6;
u32 isDone = 0;
u32 i = 0;
u32 v8 = 0;
v8 = 0;
i = 0;
v4 = 0;
while(isDone == 0) {
SET_FLAG(__AIRegs[0], 1, 0x20, 5);
SET_FLAG(__AIRegs[0], 0, 2, 1);
SET_FLAG(__AIRegs[0], 1, 1, 0);
v5 = GET_FLAG(__AIRegs[2], 0x7FFFFFFF, 0);
while(v5 == GET_FLAG(__AIRegs[2], 0x7FFFFFFF, 0)) { }
v0 = OSGetTime();
SET_FLAG(__AIRegs[0], 1, 2, 1);
SET_FLAG(__AIRegs[0], 1, 1, 0);
v6 = GET_FLAG(__AIRegs[2], 0x7FFFFFFF, 0);
while (v6 == GET_FLAG(__AIRegs[2], 0x7FFFFFFF, 0)) { }
v1 = OSGetTime();
v2 = v1 - v0;
SET_FLAG(__AIRegs[0], 0, 2, 1);
SET_FLAG(__AIRegs[0], 0, 1, 0);
if (v2 < bound_32KHz - buffer) {
v4 = min_wait;
isDone = 1;
i++;
}
else {
if (v2 >= (bound_32KHz + buffer) && v2 < (bound_48KHz - buffer)) {
v4 = max_wait;
isDone = 1;
i++;
}
else {
isDone = 0;
v8 = 1;
i++;
}
}
}
while ((v1 + v4) > OSGetTime()) { }
}