├── .flake8 ├── .gitattributes ├── .github └── workflows │ └── build.yml ├── .gitignore ├── LICENSE ├── README.md ├── config └── GTYE69 │ ├── build.sha1 │ ├── config.example.yml │ ├── config.yml │ ├── splits.txt │ └── symbols.txt ├── configure.py ├── ctx.py ├── generate_progress.py ├── include ├── Dolphin │ ├── CARDPriv.h │ ├── DVDPriv.h │ ├── OSRtcPriv.h │ ├── PPCArch.h │ ├── __ppc_eabi_init.h │ ├── __start.h │ ├── ai.h │ ├── card.h │ ├── db.h │ ├── dsp.h │ ├── dtk.h │ ├── dvd.h │ ├── gx.h │ ├── gx │ │ ├── GXBump.h │ │ ├── GXCommandList.h │ │ ├── GXCull.h │ │ ├── GXDispList.h │ │ ├── GXEnum.h │ │ ├── GXFifo.h │ │ ├── GXFrameBuffer.h │ │ ├── GXGeometry.h │ │ ├── GXGet.h │ │ ├── GXLighting.h │ │ ├── GXManage.h │ │ ├── GXPixel.h │ │ ├── GXStruct.h │ │ ├── GXTev.h │ │ ├── GXTexture.h │ │ ├── GXTransform.h │ │ └── GXVert.h │ ├── hw_regs.h │ ├── os.h │ ├── os │ │ ├── OSAlarm.h │ │ ├── OSAlloc.h │ │ ├── OSArena.h │ │ ├── OSBootInfo.h │ │ ├── OSCache.h │ │ ├── OSContext.h │ │ ├── OSError.h │ │ ├── OSException.h │ │ ├── OSExpansion.h │ │ ├── OSFastCast.h │ │ ├── OSFont.h │ │ ├── OSInterrupt.h │ │ ├── OSMemory.h │ │ ├── OSMessage.h │ │ ├── OSModule.h │ │ ├── OSMutex.h │ │ ├── OSPriv.h │ │ ├── OSReset.h │ │ ├── OSResetSW.h │ │ ├── OSSerial.h │ │ ├── OSThread.h │ │ └── OSTime.h │ ├── pad.h │ ├── stl.h │ ├── thp.h │ ├── thp │ │ ├── THPAudio.h │ │ ├── THPAudioDecode.h │ │ ├── THPBuffer.h │ │ ├── THPDraw.h │ │ ├── THPFile.h │ │ ├── THPInfo.h │ │ ├── THPPlayer.h │ │ ├── THPRead.h │ │ └── THPVideoDecode.h │ ├── types.h │ ├── vi.h │ ├── vifuncs.h │ └── vitypes.h ├── __ppc_eabi_linker.h ├── common │ ├── Animation.h │ ├── Blitter.h │ ├── Camera.h │ ├── Collision.h │ ├── Crc.h │ ├── Debug.h │ ├── DirectLight.h │ ├── DiscErrors.h │ ├── File.h │ ├── FileSys.h │ ├── Font.h │ ├── GC_ByteFixup.h │ ├── Heap.h │ ├── Input.h │ ├── KromeIni.h │ ├── MKAnimScript.h │ ├── MKGrass.h │ ├── MKPackage.h │ ├── MKParticleGen.h │ ├── MKRumble.h │ ├── MKSceneManager.h │ ├── MKShadow.h │ ├── Material.h │ ├── Matrix.h │ ├── Model.h │ ├── ParticleSystem.h │ ├── ParticleSystemManager.h │ ├── PtrList.h │ ├── PtrListDL.h │ ├── QuatRotation.h │ ├── StdMath.h │ ├── Str.h │ ├── System_GC.h │ ├── Texture.h │ ├── Timer.h │ ├── Translation.h │ ├── Translations.h │ ├── Utils.h │ ├── Vector.h │ ├── Video.h │ ├── View.h │ ├── Water_GC.h │ ├── demoinit.h │ └── system_extras.h ├── ty │ ├── AutoTargetStruct.h │ ├── BoomerangManager.h │ ├── BoundingRegion.h │ ├── CollisionObject.h │ ├── CommonGameObjectFlags.h │ ├── DDA.h │ ├── DataVal.h │ ├── ExtendedAnalogControl.h │ ├── FinishLine.h │ ├── GameData.h │ ├── GameObject.h │ ├── GameObjectManager.h │ ├── GuideParticle.h │ ├── Hero.h │ ├── ImmediateFSM.h │ ├── Kinematics.h │ ├── Lasso.h │ ├── LensFlare.h │ ├── LevelObjective.h │ ├── LineOfSight.h │ ├── MessageIds.h │ ├── MessageMap.h │ ├── Messages.h │ ├── Mist.h │ ├── NodeOverride.h │ ├── ParticleEngine.h │ ├── Path.h │ ├── Quadratic.h │ ├── RangeCheck.h │ ├── RenderTexture.h │ ├── Script.h │ ├── Shadow.h │ ├── SignPost.h │ ├── Spline.h │ ├── StateMachine.h │ ├── StructList.h │ ├── Torch.h │ ├── Ty.h │ ├── TyHealth.h │ ├── UserInterface.h │ ├── WobbleTexture.h │ ├── boomerang.h │ ├── bunyip.h │ ├── camera │ │ ├── CameraOverride.h │ │ ├── GameCamera.h │ │ └── GameCameraTools.h │ ├── controlval.h │ ├── effects │ │ ├── Bubble.h │ │ ├── ChronorangEffects.h │ │ ├── Explosion.h │ │ ├── Flame.h │ │ ├── RainbowEffect.h │ │ └── Trails.h │ ├── friends │ │ └── friend.h │ ├── frontend │ │ ├── FrontEnd.h │ │ ├── ProgressBar.h │ │ └── UITools.h │ ├── global.h │ ├── heatflare.h │ ├── props │ │ ├── AnimatingProp.h │ │ ├── Aquarang.h │ │ ├── BunyipStone.h │ │ ├── Collapsible.h │ │ ├── D1_Prop.h │ │ ├── DDACheckpoint.h │ │ ├── Picture.h │ │ ├── Platform.h │ │ ├── Projectile.h │ │ ├── RangStone.h │ │ ├── Shatterable.h │ │ ├── SoundProp.h │ │ ├── SpawnPoint.h │ │ ├── StaticProp.h │ │ ├── Talisman.h │ │ ├── WaterVolume.h │ │ ├── WeatherProp.h │ │ ├── Z1_RainbowScales.h │ │ └── gem.h │ ├── soundbank.h │ ├── tools.h │ └── tytypes.h └── types.h ├── makeSource.py ├── old_ppcdis ├── common.py ├── config │ ├── analysis_overrides.yml │ ├── assets.yml │ ├── disasm_overrides.yml │ ├── dol.lcf │ ├── dol.yml │ ├── dol_slices.yml │ ├── file_flags.yml │ └── symbols.yml ├── configure.py ├── orig │ └── main.dol.sha1 ├── progress.py ├── requirements.txt └── tools │ ├── 1.2.5n │ └── README.md │ ├── ppcdis │ ├── LICENSE.md │ ├── README.md │ ├── TOOLS.md │ ├── analyser.py │ ├── assetinc.py │ ├── assetrip.py │ ├── binarydiff.py │ ├── disassembler.py │ ├── elf2dol.py │ ├── elf2rel.py │ ├── forceactivegen.py │ ├── forcefilesgen.py │ ├── include │ │ ├── macros.inc │ │ └── ppcdis.h │ ├── makesrc.py │ ├── orderfloats.py │ ├── orderstrings.py │ ├── ppcdis │ │ ├── __init__.py │ │ ├── analyser.py │ │ ├── assets.py │ │ ├── binarybase.py │ │ ├── binarydiff.py │ │ ├── binarydol.py │ │ ├── binarylect.py │ │ ├── binaryrel.py │ │ ├── binaryyml.py │ │ ├── csutil.py │ │ ├── disassembler.py │ │ ├── elf2dol.py │ │ ├── elf2rel.py │ │ ├── fastelf.py │ │ ├── fileutil.py │ │ ├── instrcats.py │ │ ├── lcf.py │ │ ├── orderdata.py │ │ ├── overrides.py │ │ ├── relextern.py │ │ ├── relocs.py │ │ ├── slices.py │ │ └── symbols.py │ ├── progress.py │ ├── pyproject.toml │ ├── relextern.py │ ├── requirements.txt │ ├── setup.py │ ├── slices.py │ └── symbols.py │ └── sjis.py ├── orig └── GTYE69 │ └── .gitkeep ├── rodata_pooling.txt ├── src ├── Dolphin │ ├── __ppc_eabi_init.s │ ├── card │ │ ├── CARDBios.c │ │ ├── CARDBlock.c │ │ ├── CARDCheck.c │ │ ├── CARDDir.c │ │ ├── CARDMount.c │ │ ├── CARDRdwr.c │ │ └── CARDUnlock.c │ ├── dtk.c │ ├── linker_info.s │ ├── os │ │ ├── OS.c │ │ ├── OSArena.c │ │ ├── OSAudioSystem.c │ │ ├── OSContext.c │ │ ├── OSError.c │ │ ├── OSInterrupt.c │ │ ├── OSLink.c │ │ ├── OSReset.c │ │ ├── OSRtc.c │ │ ├── OSThread.c │ │ ├── __ppc_eabi_init.cpp │ │ └── __start.c │ └── thp │ │ └── THPDec.c ├── Runtime │ ├── Gecko_ExceptionPPC.cp │ ├── NMWException.cp │ ├── NMWException.h │ ├── __init_cpp_exceptions.cpp │ ├── __mem.c │ ├── abort_exit.c │ ├── global_destructor_chain.c │ ├── ptmf.c │ ├── rand.c │ └── string.h ├── common │ ├── Debug.cpp │ ├── Source │ │ ├── Animation.cpp │ │ ├── Camera.cpp │ │ ├── Collision.cpp │ │ ├── Crc.cpp │ │ ├── DirectLight.cpp │ │ ├── FileSys.cpp │ │ ├── Font.cpp │ │ ├── Heap.cpp │ │ ├── KromeIni.cpp │ │ ├── MKAnimScript.cpp │ │ ├── MKPackage.cpp │ │ ├── MKParticleGen.cpp │ │ ├── MKRumble.cpp │ │ ├── MKSceneManager.cpp │ │ ├── Matrix.cpp │ │ ├── Model.cpp │ │ ├── ParticleSystem.cpp │ │ ├── ParticleSystemManager.cpp │ │ ├── QuatRotation.cpp │ │ ├── StdMath.cpp │ │ ├── Str.cpp │ │ ├── Timer.cpp │ │ ├── Translation.cpp │ │ ├── Utils.cpp │ │ └── Vector.cpp │ └── gc │ │ ├── Blitter.cpp │ │ ├── DiscErrors.cpp │ │ ├── File.cpp │ │ ├── Grass_GC.cpp │ │ ├── Input_GC.cpp │ │ ├── MKShadow_GC.cpp │ │ ├── Material_GC.cpp │ │ ├── ModelGC.cpp │ │ ├── System_GC.cpp │ │ ├── THPAudioDecode.c │ │ ├── Texture.cpp │ │ ├── Video.cpp │ │ ├── View_GC.cpp │ │ ├── Water_GC.cpp │ │ ├── demoinit.cpp │ │ └── system_extras.cpp └── ty │ └── source │ ├── BoundingRegion.cpp │ ├── CollisionObject.cpp │ ├── DDA.cpp │ ├── DataVal.cpp │ ├── ExtendedAnalogControl.cpp │ ├── GameData.cpp │ ├── GameObject.cpp │ ├── GameObjectManager.cpp │ ├── GuideParticle.cpp │ ├── Kinematics.cpp │ ├── LensFlare.cpp │ ├── LevelObjective.cpp │ ├── LineOfSight.cpp │ ├── MessageMap.cpp │ ├── Messages.cpp │ ├── Mist.cpp │ ├── NodeOverride.cpp │ ├── Path.cpp │ ├── RangeCheck.cpp │ ├── Script.cpp │ ├── Shadow.cpp │ ├── SignPost.cpp │ ├── Spline.cpp │ ├── Torch.cpp │ ├── UserInterface.cpp │ ├── WobbleTexture.cpp │ ├── boomerang.cpp │ ├── boomerangManager.cpp │ ├── bunyip.cpp │ ├── camera │ ├── CameraOverride.cpp │ ├── GameCamera.cpp │ └── GameCameraTools.cpp │ ├── controlval.cpp │ ├── effects │ ├── Bubble.cpp │ ├── ChronorangEffects.cpp │ ├── Explosion.cpp │ ├── Flame.cpp │ ├── RainbowEffect.cpp │ └── Trails.cpp │ ├── finishline.cpp │ ├── friends │ └── Friend.cpp │ ├── frontend │ ├── ProgressBar.cpp │ └── UITools.cpp │ ├── global.cpp │ ├── heatflare.cpp │ ├── lasso.cpp │ ├── particleengine.cpp │ ├── props │ ├── AnimatingProp.cpp │ ├── Aquarang.cpp │ ├── BunyipStone.cpp │ ├── Collapsible.cpp │ ├── D1_Prop.cpp │ ├── DDACheckpoint.cpp │ ├── Picture.cpp │ ├── Platform.cpp │ ├── Projectile.cpp │ ├── RangStone.cpp │ ├── Shatterable.cpp │ ├── SoundProp.cpp │ ├── SpawnPoint.cpp │ ├── StaticProp.cpp │ ├── Talisman.cpp │ ├── WaterVolume.cpp │ ├── WeatherProp.cpp │ ├── Z1_RainbowScales.cpp │ └── gem.cpp │ ├── quadratic.cpp │ ├── renderTexture.cpp │ ├── setup.cpp │ └── tools.cpp ├── tools ├── __init__.py ├── decompctx.py ├── download_tool.py ├── ninja_syntax.py ├── project.py ├── transform_dep.py └── upload_progress.py └── upload_progress.py /.flake8: -------------------------------------------------------------------------------- 1 | [flake8] 2 | # E203: whitespace before ':' 3 | # E501: line too long 4 | extend-ignore = E203,E501 5 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Explicitly declare text files 5 | *.py text 6 | 7 | # Enforce platform-specific encodings 8 | *.bat text eol=crlf 9 | *.sh text eol=lf 10 | *.sha1 text eol=lf 11 | 12 | # decomp-toolkit writes files with LF 13 | config/**/*.txt text eol=lf 14 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # IDE folders 2 | .idea/ 3 | .vs/ 4 | .vscode/ 5 | 6 | # Caches 7 | __pycache__ 8 | .mypy_cache 9 | .cache/ 10 | 11 | # Original files 12 | orig/*/* 13 | !orig/*/.gitkeep 14 | 15 | # Build files 16 | build/ 17 | .ninja_* 18 | build.ninja 19 | 20 | # decompctx output 21 | ctx.* 22 | *.ctx 23 | 24 | # Generated configs 25 | objdiff.json 26 | compile_commands.json 27 | report*.json 28 | 29 | # Miscellaneous 30 | *.exe 31 | *.dll 32 | *.dol 33 | # *.txt 34 | 35 | cli.py 36 | cli.ini 37 | 38 | expected 39 | out/ 40 | asm/ 41 | pickles/ 42 | assets/ 43 | -------------------------------------------------------------------------------- /config/GTYE69/build.sha1: -------------------------------------------------------------------------------- 1 | c398adeba17e80b18e7b25d13dbc30c2939479c5 build/GTYE69/main.dol 2 | -------------------------------------------------------------------------------- /config/GTYE69/config.yml: -------------------------------------------------------------------------------- 1 | # See config.example.yml for documentation. 2 | object: orig/GTYE69/sys/main.dol 3 | hash: c398adeba17e80b18e7b25d13dbc30c2939479c5 4 | symbols: config/GTYE69/symbols.txt 5 | splits: config/GTYE69/splits.txt 6 | # Change this to match the linker verison. 7 | # See config.example.yml for a list. 8 | mw_comment_version: 10 9 | 10 | symbols_known: false 11 | fill_gaps: false 12 | 13 | extract: 14 | - symbol: rawCaptureTexData 15 | binary: assets/Material_GC/rawCaptureTexData.bin 16 | header: assets/Material_GC/rawCaptureTexData.inc 17 | header_type: symbol 18 | 19 | block_relocations: 20 | - source: .data:0x8025517C # Remove relocation in buttonType1 object 21 | - source: .data:0x80255180 # Remove relocation in buttonType1 object 22 | 23 | - source: .text:0x800C35A0 # Remove false relocation from FrontEnd_Gallery_Init__Fv 24 | - source: .text:0x800C35A8 # Remove false relocation from FrontEnd_Gallery_Init__Fv -------------------------------------------------------------------------------- /generate_progress.py: -------------------------------------------------------------------------------- 1 | from argparse import ArgumentParser 2 | import os.path 3 | import pickle 4 | import json 5 | from typing import Dict, Tuple 6 | 7 | import common as c 8 | 9 | def load_progress_info(ctx: c.SourceContext, asm_list: str 10 | ) -> Tuple[Dict[str, int], Dict[str, int]]: 11 | assert os.path.exists(ctx.labels), "Error: analysis has not ran!" 12 | 13 | # Get data 14 | raw = c.get_cmd_stdout(f"{c.PROGRESS} {ctx.binary} {ctx.labels} {ctx.slices}") 15 | dat = json.loads(raw) 16 | assert dat.get("version") == 2, "Outdated progress json version, try a clean & rebuild" 17 | decomp_sizes = dat["decomp_slices_sizes"] 18 | total_sizes = dat["total_sizes"] 19 | symbol_sizes = dat["symbol_sizes"] 20 | 21 | # Subtract undecompiled functions in decompiled slices 22 | # TODO: this assumes none of .init is decompiled 23 | with open(asm_list, 'rb') as f: 24 | funcs = pickle.load(f) 25 | for func in funcs: 26 | decomp_sizes[".text"] -= symbol_sizes[str(func)] 27 | 28 | return decomp_sizes, total_sizes 29 | 30 | def generate_frogress_json(dol_size, dol_total): 31 | return json.dumps({ 32 | "Code": { 33 | "code": dol_size, 34 | "code/total": dol_total 35 | } 36 | }) 37 | 38 | if __name__=="__main__": 39 | decomp_sizes, total_sizes = load_progress_info(c.DOL_CTX, c.DOL_ASM_LIST) 40 | json_str = generate_frogress_json(decomp_sizes[".text"], total_sizes[".text"]) 41 | with open("out/progress.json", "w") as f: 42 | f.write(json_str) -------------------------------------------------------------------------------- /include/Dolphin/DVDPriv.h: -------------------------------------------------------------------------------- 1 | #ifndef _DOLPHIN_DVDPRIV 2 | #define _DOLPHIN_DVDPRIV 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | 12 | typedef struct DVDDriveInfo { 13 | u16 revisionLevel; 14 | u16 deviceCode; 15 | u32 releaseDate; 16 | u8 padding[24]; 17 | } DVDDriveInfo; 18 | 19 | typedef struct DVDBB1 { 20 | u32 appLoaderLength; 21 | void* appLoaderFunc1; 22 | void* appLoaderFunc2; 23 | void* appLoaderFunc3; 24 | } DVDBB1; 25 | 26 | typedef struct DVDBB2 { 27 | u32 bootFilePosition; 28 | u32 FSTPosition; 29 | u32 FSTLength; 30 | u32 FSTMaxLength; 31 | void* FSTAddress; 32 | u32 userPosition; 33 | u32 userLength; 34 | 35 | u32 padding0; 36 | } DVDBB2; 37 | 38 | typedef void (*DVDOptionalCommandChecker)(DVDCommandBlock* block, void (*cb)(u32 intType)); 39 | typedef void (*DVDLowCallback)(u32 intType); 40 | extern DVDDiskID* DVDGetCurrentDiskID(); 41 | DVDLowCallback DVDLowClearCallback(); 42 | BOOL DVDLowSeek(u32 offset, DVDLowCallback callback); 43 | void __DVDLowSetWAType(u32 type, u32 location); 44 | DVDCommandBlock* __DVDPopWaitingQueue(); 45 | 46 | #ifdef __cplusplus 47 | } 48 | #endif // _DOLPHIN_DVDPRIV 49 | 50 | #endif __DVDPRIV_H__ 51 | -------------------------------------------------------------------------------- /include/Dolphin/OSRtcPriv.h: -------------------------------------------------------------------------------- 1 | #ifndef _DOLPHIN_OSRTCPRIV 2 | #define _DOLPHIN_OSRTCPRIV 3 | 4 | #include 5 | 6 | typedef struct OSSram { 7 | u16 checkSum; 8 | u16 checkSumInv; 9 | u32 ead0; 10 | u32 ead1; 11 | u32 counterBias; 12 | s8 displayOffsetH; 13 | u8 ntd; 14 | u8 language; 15 | u8 flags; 16 | } OSSram; 17 | 18 | typedef struct OSSramEx { 19 | u8 flashID[2][12]; 20 | u32 wirelessKeyboardID; 21 | u16 wirelessPadID[4]; 22 | u8 dvdErrorCode; 23 | u8 _padding0; 24 | u8 flashIDCheckSum[2]; 25 | u16 gbs; 26 | u8 _padding1[2]; 27 | } OSSramEx; 28 | 29 | OSSram* __OSLockSram(); 30 | OSSramEx* __OSLockSramEx(); 31 | void OSSetWirelessID(s32 chan, u16 id); 32 | u16 OSGetWirelessID(s32 chan); 33 | 34 | #endif // _DOLPHIN_OSRTCPRIV 35 | -------------------------------------------------------------------------------- /include/Dolphin/__ppc_eabi_init.h: -------------------------------------------------------------------------------- 1 | #ifndef _DOLPHIN__PPC_EABI_INIT 2 | #define _DOLPHIN__PPC_EABI_INIT 3 | 4 | #include "types.h" 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | __declspec(section ".init") void __init_hardware(void); 10 | __declspec(section ".init") void __flush_cache(register void* address, register unsigned int size); 11 | 12 | void __init_user(void); 13 | void __init_cpp(void); 14 | 15 | #ifdef __cplusplus 16 | } 17 | #endif 18 | 19 | #endif // _DOLPHIN__PPC_EABI_INIT -------------------------------------------------------------------------------- /include/Dolphin/__start.h: -------------------------------------------------------------------------------- 1 | #ifndef _DOLPHIN__START 2 | #define _DOLPHIN__START 3 | 4 | #include "Dolphin/db.h" 5 | #include "types.h" 6 | 7 | #define PAD3_BUTTON_ADDR 0x800030E4 8 | #define OS_RESET_RESTART 0 9 | #define EXCEPTIONMASK_ADDR 0x80000044 10 | #define BOOTINFO2_ADDR 0x800000F4 11 | #define OS_BI2_DEBUGFLAG_OFFSET 0xC 12 | #define ARENAHI_ADDR 0x80000034 13 | #define DEBUGFLAG_ADDR 0x800030E8 14 | #define DVD_DEVICECODE_ADDR 0x800030E6 15 | 16 | #define MSR_FP 0x2000 17 | 18 | extern void InitMetroTRK(); 19 | 20 | u16 Pad3Button : PAD3_BUTTON_ADDR; 21 | // static u8 Debug_BBA = 0; 22 | 23 | extern void memset(void*, int, int); 24 | extern int main(int argc, char* argv[]); 25 | extern void exit(int); 26 | extern void __init_user(void); 27 | extern void OSInit(void); 28 | extern void DBInit(void); 29 | extern void OSResetSystem(BOOL reset, u32 resetCode, BOOL forceMenu); 30 | extern void __OSCacheInit(void); 31 | extern void __OSPSInit(void); 32 | 33 | __declspec(section ".init") extern void __check_pad3(void); 34 | __declspec(section ".init") extern void __start(void); 35 | __declspec(section ".init") extern void __init_registers(void); 36 | __declspec(section ".init") extern void __init_data(void); 37 | __declspec(section ".init") extern void __init_hardware(void); 38 | __declspec(section ".init") extern void __flush_cache(void* address, unsigned int size); 39 | 40 | __declspec(section ".init") extern char _stack_addr[]; 41 | __declspec(section ".init") extern char _SDA_BASE_[]; 42 | __declspec(section ".init") extern char _SDA2_BASE_[]; 43 | 44 | #endif // _DOLPHIN__START -------------------------------------------------------------------------------- /include/Dolphin/ai.h: -------------------------------------------------------------------------------- 1 | #ifndef _DOLPHIN_AI 2 | #define _DOLPHIN_AI 3 | 4 | #include "types.h" 5 | 6 | typedef void (*AISCallback)(u32 count); 7 | typedef void (*AIDCallback)(); 8 | 9 | AIDCallback AIRegisterDMACallback(AIDCallback callback); 10 | void AIInitDMA(u32 start_addr, u32 length); 11 | BOOL AIGetDMAEnableFlag(); 12 | void AIStartDMA(); 13 | void AIStopDMA(); 14 | u32 AIGetDMABytesLeft(); 15 | u32 AIGetDMAStartAddr(); 16 | u32 AIGetDMALength(); 17 | u32 AIGetDSPSampleRate(); 18 | void AISetDSPSampleRate(u32 rate); 19 | AISCallback AIRegisterStreamCallback(AISCallback callback); 20 | u32 AIGetStreamSampleCount(); 21 | void AIResetStreamSampleCount(); 22 | void AISetStreamTrigger(u32 trigger); 23 | u32 AIGetStreamTrigger(); 24 | void AISetStreamPlayState(u32 state); 25 | u32 AIGetStreamPlayState(); 26 | void AISetStreamSampleRate(u32 rate); 27 | u32 AIGetStreamSampleRate(); 28 | void AISetStreamVolLeft(u8 vol); 29 | void AISetStreamVolRight(u8 vol); 30 | u8 AIGetStreamVolLeft(); 31 | u8 AIGetStreamVolRight(); 32 | void AIInit(u8* stack); 33 | BOOL AICheckInit(); 34 | void AIReset(); 35 | 36 | #endif // _DOLPHIN_AI 37 | -------------------------------------------------------------------------------- /include/Dolphin/db.h: -------------------------------------------------------------------------------- 1 | #ifndef _DOLPHIN_DB 2 | #define _DOLPHIN_DB 3 | 4 | #include "types.h" 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | #define OS_DBINTERFACE_ADDR 0x00000040 11 | 12 | typedef struct DBInterface 13 | { 14 | u32 bPresent; 15 | u32 exceptionMask; 16 | void (*ExceptionDestination) ( void ); 17 | void *exceptionReturn; 18 | } DBInterface; 19 | 20 | extern DBInterface* __DBInterface; 21 | 22 | void DBInit(void); 23 | void DBInitComm(int* inputFlagPtr, int* mtrCallback); 24 | static void __DBExceptionDestination(void); 25 | void DBPrintf(char* format, ...); 26 | 27 | #ifdef __cplusplus 28 | } 29 | #endif 30 | 31 | #endif // _DOLPHIN_DB -------------------------------------------------------------------------------- /include/Dolphin/dsp.h: -------------------------------------------------------------------------------- 1 | #ifndef _DOLPHIN_DSP 2 | #define _DOLPHIN_DSP 3 | 4 | #include "types.h" 5 | #include 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | #define DSP_TASK_FLAG_CLEARALL 0x00000000 12 | #define DSP_TASK_FLAG_ATTACHED 0x00000001 13 | #define DSP_TASK_FLAG_CANCEL 0x00000002 14 | 15 | #define DSP_TASK_STATE_INIT 0 16 | #define DSP_TASK_STATE_RUN 1 17 | #define DSP_TASK_STATE_YIELD 2 18 | #define DSP_TASK_STATE_DONE 3 19 | 20 | typedef void (*DSPCallback)(void* task); 21 | 22 | typedef struct STRUCT_DSP_TASK { 23 | vu32 state; 24 | vu32 priority; 25 | vu32 flags; 26 | u16* iram_mmem_addr; 27 | u32 iram_length; 28 | u32 iram_addr; 29 | 30 | u16* dram_mmem_addr; 31 | u32 dram_length; 32 | u32 dram_addr; 33 | 34 | u16 dsp_init_vector; 35 | u16 dsp_resume_vector; 36 | 37 | DSPCallback init_cb; 38 | DSPCallback res_cb; 39 | DSPCallback done_cb; 40 | DSPCallback req_cb; 41 | 42 | struct STRUCT_DSP_TASK* next; 43 | struct STRUCT_DSP_TASK* prev; 44 | 45 | OSTime t_context; 46 | OSTime t_task; 47 | 48 | } DSPTaskInfo; 49 | 50 | void DSPInit(); 51 | void DSPReset(); 52 | void DSPHalt(); 53 | void DSPSendMailToDSP(u32 mail); 54 | u32 DSPCheckMailToDSP(); 55 | u32 DSPCheckMailFromDSP(); 56 | u32 DSPGetDMAStatus(); 57 | 58 | DSPTaskInfo* DSPAddTask(DSPTaskInfo* task); 59 | 60 | void __DSP_exec_task(DSPTaskInfo* curr, DSPTaskInfo* next); 61 | void __DSP_boot_task(DSPTaskInfo* task); 62 | void __DSP_remove_task(DSPTaskInfo* task); 63 | void __DSP_add_task(DSPTaskInfo* task); 64 | void __DSP_debug_printf(const char* fmt, ...); 65 | 66 | #ifdef __cplusplus 67 | } 68 | #endif 69 | 70 | #endif // _DOLPHIN_DSP 71 | -------------------------------------------------------------------------------- /include/Dolphin/dtk.h: -------------------------------------------------------------------------------- 1 | #ifndef _DOLPHIN_DTK 2 | #define _DOLPHIN_DTK 3 | 4 | #include 5 | #include 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | typedef void (*DTKCallback)(u32 eventMask); 11 | typedef void (*DTKFlushCallback)(void); 12 | 13 | typedef struct DTKTrack { 14 | struct DTKTrack* prev; 15 | struct DTKTrack* next; 16 | char* fileName; 17 | u32 eventMask; 18 | DTKCallback callback; 19 | DVDFileInfo dvdFileInfo; 20 | 21 | } DTKTrack; 22 | 23 | void DTKInit(void); 24 | void DTKShutdown(void); 25 | u32 DTKQueueTrack(char* fileName, DTKTrack* track, u32 eventMask, DTKCallback callback); 26 | u32 DTKRemoveTrack(DTKTrack* track); 27 | void DTKFlushTracks(DTKFlushCallback callback); 28 | void DTKSetSampleRate(u32 samplerate); 29 | u32 DTKGetSampleRate(void); 30 | void DTKSetInterruptFrequency(u32 samples); 31 | u32 DTKGetInterruptFrequency(void); 32 | void DTKSetRepeatMode(u32 repeat); 33 | u32 DTKGetRepeatMode(void); 34 | void DTKSetState(u32 state); 35 | u32 DTKGetState(void); 36 | void DTKNextTrack(void); 37 | void DTKPrevTrack(void); 38 | u32 DTKGetPosition(void); 39 | DTKTrack* DTKGetCurrentTrack(void); 40 | void DTKSetVolume(u8 left, u8 right); 41 | u16 DTKGetVolume(void); 42 | 43 | #ifdef __cplusplus 44 | } 45 | #endif 46 | 47 | #endif // _DOLPHIN_DTK 48 | -------------------------------------------------------------------------------- /include/Dolphin/gx.h: -------------------------------------------------------------------------------- 1 | #ifndef _DOLPHIN_GX 2 | #define _DOLPHIN_GX 3 | 4 | // Not sure where this would go 5 | // void GXSetProjectionv(float*); 6 | 7 | struct Mtx44 { 8 | float data[4][4]; 9 | }; 10 | 11 | struct Mtx23 { 12 | float data[2][3]; 13 | }; 14 | 15 | struct Mtx24 { 16 | float data[2][4]; 17 | }; 18 | 19 | #include 20 | #include 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | // #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | // #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | 40 | #endif // _DOLPHIN_GX 41 | -------------------------------------------------------------------------------- /include/Dolphin/gx/GXBump.h: -------------------------------------------------------------------------------- 1 | #ifndef _DOLPHIN_GXBUMP 2 | #define _DOLPHIN_GXBUMP 3 | 4 | #include 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | void GXSetTevDirect(GXTevStageID tev_stage); 11 | void GXSetNumIndStages(u8 nIndStages); 12 | #ifdef TARGET_PC 13 | void GXSetIndTexMtx(GXIndTexMtxID mtx_sel, const void* offset, s8 scale_exp); 14 | #else 15 | void GXSetIndTexMtx(GXIndTexMtxID mtx_sel, f32 offset[2][3], s8 scale_exp); 16 | #endif 17 | void GXSetIndTexOrder(GXIndTexStageID ind_stage, GXTexCoordID tex_coord, GXTexMapID tex_map); 18 | void GXSetTevIndirect(GXTevStageID tev_stage, GXIndTexStageID ind_stage, GXIndTexFormat format, 19 | GXIndTexBiasSel bias_sel, GXIndTexMtxID matrix_sel, GXIndTexWrap wrap_s, 20 | GXIndTexWrap wrap_t, GXBool add_prev, GXBool ind_lod, 21 | GXIndTexAlphaSel alpha_sel); 22 | void GXSetTevIndWarp(GXTevStageID tev_stage, GXIndTexStageID ind_stage, GXBool signed_offsets, 23 | GXBool replace_mode, GXIndTexMtxID matrix_sel); 24 | void GXSetIndTexCoordScale(GXIndTexStageID ind_state, GXIndTexScale scale_s, GXIndTexScale scale_t); 25 | 26 | #ifdef __cplusplus 27 | } 28 | #endif 29 | 30 | #endif // _DOLPHIN_GXBUMP 31 | -------------------------------------------------------------------------------- /include/Dolphin/gx/GXCommandList.h: -------------------------------------------------------------------------------- 1 | #ifndef _DOLPHIN_GXCOMMANDLIST 2 | #define _DOLPHIN_GXCOMMANDLIST 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #define GX_NOP 0x00 9 | #define GX_DRAW_QUADS 0x80 10 | #define GX_DRAW_TRIANGLES 0x90 11 | #define GX_DRAW_TRIANGLE_STRIP 0x98 12 | #define GX_DRAW_TRIANGLE_FAN 0xA0 13 | #define GX_DRAW_LINES 0xA8 14 | #define GX_DRAW_LINE_STRIP 0xB0 15 | #define GX_DRAW_POINTS 0xB8 16 | 17 | #define GX_LOAD_BP_REG 0x61 18 | #define GX_LOAD_CP_REG 0x08 19 | #define GX_LOAD_XF_REG 0x10 20 | #define GX_LOAD_INDX_A 0x20 21 | #define GX_LOAD_INDX_B 0x28 22 | #define GX_LOAD_INDX_C 0x30 23 | #define GX_LOAD_INDX_D 0x38 24 | 25 | #define GX_CMD_CALL_DL 0x40 26 | #define GX_CMD_INVL_VC 0x48 27 | 28 | #define GX_OPCODE_MASK 0xF8 29 | #define GX_VAT_MASK 0x07 30 | 31 | #ifdef __cplusplus 32 | } 33 | #endif 34 | 35 | #endif // _DOLPHIN_GXCOMMANDLIST 36 | -------------------------------------------------------------------------------- /include/Dolphin/gx/GXCull.h: -------------------------------------------------------------------------------- 1 | #ifndef _DOLPHIN_GXCULL 2 | #define _DOLPHIN_GXCULL 3 | 4 | #include 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | // xOrig, yOrig, wd, ht 11 | void GXSetScissor(u32 left, u32 top, u32 wd, u32 ht); 12 | void GXSetCullMode(GXCullMode mode); 13 | void GXSetCoPlanar(GXBool enable); 14 | 15 | #ifdef __cplusplus 16 | } 17 | #endif 18 | 19 | #endif // _DOLPHIN_GXCULL 20 | -------------------------------------------------------------------------------- /include/Dolphin/gx/GXDispList.h: -------------------------------------------------------------------------------- 1 | #ifndef _DOLPHIN_GXDISPLIST 2 | #define _DOLPHIN_GXDISPLIST 3 | 4 | #include 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | void GXBeginDisplayList(void* list, u32 size); 11 | u32 GXEndDisplayList(void); 12 | void GXCallDisplayList(const void* list, u32 nbytes); 13 | 14 | #ifdef __cplusplus 15 | } 16 | #endif 17 | 18 | #endif // _DOLPHIN_GXDISPLIST 19 | -------------------------------------------------------------------------------- /include/Dolphin/gx/GXFifo.h: -------------------------------------------------------------------------------- 1 | #ifndef _DOLPHIN_GXFIFO 2 | #define _DOLPHIN_GXFIFO 3 | 4 | #include 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | typedef struct { 11 | u8 pad[128]; 12 | } GXFifoObj; 13 | 14 | typedef void (*GXBreakPtCallback)(void); 15 | 16 | void GXInitFifoBase(GXFifoObj* fifo, void* base, u32 size); 17 | void GXInitFifoPtrs(GXFifoObj* fifo, void* readPtr, void* writePtr); 18 | void GXGetFifoPtrs(GXFifoObj* fifo, void** readPtr, void** writePtr); 19 | GXFifoObj* GXGetCPUFifo(void); 20 | GXFifoObj* GXGetGPFifo(void); 21 | void GXSetCPUFifo(GXFifoObj* fifo); 22 | void GXSetGPFifo(GXFifoObj* fifo); 23 | void GXSaveCPUFifo(GXFifoObj* fifo); 24 | void GXGetFifoStatus(GXFifoObj* fifo, GXBool* overhi, GXBool* underlow, u32* fifoCount, 25 | GXBool* cpu_write, GXBool* gp_read, GXBool* fifowrap); 26 | void GXGetGPStatus(GXBool* overhi, GXBool* underlow, GXBool* readIdle, GXBool* cmdIdle, 27 | GXBool* brkpt); 28 | void GXInitFifoLimits(GXFifoObj* fifo, u32 hiWaterMark, u32 loWaterMark); 29 | GXBreakPtCallback GXSetBreakPtCallback(GXBreakPtCallback cb); 30 | void GXEnableBreakPt(void* breakPt); 31 | void GXDisableBreakPt(void); 32 | 33 | #ifdef __cplusplus 34 | } 35 | #endif 36 | 37 | #endif // _DOLPHIN_GXFIFO -------------------------------------------------------------------------------- /include/Dolphin/gx/GXGeometry.h: -------------------------------------------------------------------------------- 1 | #ifndef _DOLPHIN_GXGEOMETRY 2 | #define _DOLPHIN_GXGEOMETRY 3 | 4 | #include 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | void GXSetVtxDesc(GXAttr attr, GXAttrType type); 11 | void GXSetVtxDescv(GXVtxDescList* list); 12 | void GXClearVtxDesc(void); 13 | void GXSetVtxAttrFmt(GXVtxFmt vtxfmt, GXAttr attr, GXCompCnt cnt, GXCompType type, u8 frac); 14 | void GXSetNumTexGens(u8 nTexGens); 15 | void GXBegin(GXPrimitive type, GXVtxFmt vtxfmt, u16 nverts); 16 | void GXSetTexCoordGen2(GXTexCoordID dst_coord, GXTexGenType func, GXTexGenSrc src_param, u32 mtx, 17 | GXBool normalize, u32 postmtx); 18 | void GXSetLineWidth(u8 width, GXTexOffset texOffsets); 19 | void GXSetPointSize(u8 pointSize, GXTexOffset texOffsets); 20 | void GXEnableTexOffsets(GXTexCoordID coord, GXBool line_enable, GXBool point_enable); 21 | #ifdef TARGET_PC 22 | void GXSetArray(GXAttr attr, const void* data, u32 size, u8 stride); 23 | #else 24 | void GXSetArray(GXAttr attr, const void* data, u8 stride); 25 | #endif 26 | void GXInvalidateVtxCache(void); 27 | 28 | static inline void GXSetTexCoordGen(GXTexCoordID dst_coord, GXTexGenType func, 29 | GXTexGenSrc src_param, u32 mtx) { 30 | GXSetTexCoordGen2(dst_coord, func, src_param, mtx, GX_FALSE, GX_PTIDENTITY); 31 | } 32 | 33 | #ifdef __cplusplus 34 | } 35 | #endif 36 | 37 | #endif // _DOLPHIN_GXGEOMETRY 38 | -------------------------------------------------------------------------------- /include/Dolphin/gx/GXGet.h: -------------------------------------------------------------------------------- 1 | #ifndef _DOLPHIN_GXGET 2 | #define _DOLPHIN_GXGET 3 | 4 | #include 5 | #include 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | GXBool GXGetTexObjMipMap(const GXTexObj* obj); 12 | GXTexFmt GXGetTexObjFmt(const GXTexObj* obj); 13 | u16 GXGetTexObjHeight(const GXTexObj* obj); 14 | u16 GXGetTexObjWidth(const GXTexObj* obj); 15 | GXTexWrapMode GXGetTexObjWrapS(const GXTexObj* obj); 16 | GXTexWrapMode GXGetTexObjWrapT(const GXTexObj* obj); 17 | void* GXGetTexObjData(const GXTexObj* obj); 18 | void GXGetProjectionv(f32* p); 19 | void GXSetProjectionv(f32* p); 20 | void GXGetLightPos(const GXLightObj* lt_obj, f32* x, f32* y, f32* z); 21 | void GXGetLightColor(const GXLightObj* lt_obj, GXColor* color); 22 | void GXGetVtxAttrFmt(GXVtxFmt idx, GXAttr attr, GXCompCnt* compCnt, GXCompType* compType, 23 | u8* shift); 24 | 25 | #ifdef __cplusplus 26 | } 27 | #endif 28 | 29 | #endif // _DOLPHIN_GXGET 30 | -------------------------------------------------------------------------------- /include/Dolphin/gx/GXLighting.h: -------------------------------------------------------------------------------- 1 | #ifndef _DOLPHIN_GXLIGHTING 2 | #define _DOLPHIN_GXLIGHTING 3 | 4 | #include 5 | #include 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | void GXSetNumChans(u8 nChans); 12 | // void GXSetChanCtrl(GXChannelID chan, GXBool enable, GXColorSrc amb_src, GXColorSrc mat_src, 13 | // u32 light_mask, GXDiffuseFn diff_fn, GXAttnFn attn_fn); 14 | void GXSetChanCtrl(GXChannelID chan, int enable, GXColorSrc amb_src, GXColorSrc mat_src, 15 | u32 light_mask, GXDiffuseFn diff_fn, GXAttnFn attn_fn); 16 | void GXSetChanAmbColor(GXChannelID chan, GXColor amb_color); 17 | void GXSetChanMatColor(GXChannelID chan, GXColor mat_color); 18 | 19 | void GXInitLightSpot(GXLightObj* lt_obj, f32 cutoff, GXSpotFn spot_func); 20 | void GXInitLightDistAttn(GXLightObj* lt_obj, f32 ref_distance, f32 ref_brightness, 21 | GXDistAttnFn dist_func); 22 | void GXInitLightPos(GXLightObj* lt_obj, f32 x, f32 y, f32 z); 23 | void GXInitLightDir(GXLightObj* lt_obj, f32 nx, f32 ny, f32 nz); 24 | void GXInitLightColor(GXLightObj* lt_obj, GXColor color); 25 | void GXInitLightAttn(GXLightObj* lt_obj, f32 a0, f32 a1, f32 a2, f32 k0, f32 k1, f32 k2); 26 | void GXInitLightAttnA(GXLightObj* lt_obj, f32 a0, f32 a1, f32 a2); 27 | void GXInitLightAttnK(GXLightObj* lt_obj, f32 k0, f32 k1, f32 k2); 28 | void GXLoadLightObjImm(GXLightObj* lt_obj, GXLightID light); 29 | 30 | #ifdef __cplusplus 31 | } 32 | #endif 33 | 34 | #endif // _DOLPHIN_GXLIGHTING 35 | -------------------------------------------------------------------------------- /include/Dolphin/gx/GXManage.h: -------------------------------------------------------------------------------- 1 | #ifndef _DOLPHIN_GXMANAGE 2 | #define _DOLPHIN_GXMANAGE 3 | 4 | #include 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | typedef void (*GXDrawDoneCallback)(void); 11 | 12 | GXFifoObj* GXInit(void* base, u32 size); 13 | GXDrawDoneCallback GXSetDrawDoneCallback(GXDrawDoneCallback cb); 14 | void GXDrawDone(void); 15 | void GXSetDrawDone(void); 16 | void GXFlush(void); 17 | void GXPixModeSync(void); 18 | void GXSetMisc(GXMiscToken token, u32 val); 19 | 20 | #ifdef __cplusplus 21 | } 22 | #endif 23 | 24 | #endif // _DOLPHIN_GXMANAGE 25 | -------------------------------------------------------------------------------- /include/Dolphin/gx/GXPixel.h: -------------------------------------------------------------------------------- 1 | #ifndef _DOLPHIN_GXPIXEL 2 | #define _DOLPHIN_GXPIXEL 3 | 4 | #include 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | void GXSetFog(GXFogType type, f32 startz, f32 endz, f32 nearz, f32 farz, GXColor color); 11 | void GXSetFogColor(GXColor color); 12 | // ? GXSetFogRangeAdj(); 13 | void GXSetBlendMode(GXBlendMode type, GXBlendFactor src_factor, GXBlendFactor dst_factor, 14 | GXLogicOp op); 15 | void GXSetColorUpdate(GXBool update_enable); 16 | void GXSetAlphaUpdate(GXBool update_enable); 17 | void GXSetZMode(GXBool compare_enable, GXCompare func, GXBool update_enable); 18 | // void GXSetZCompLoc(GXBool before_tex); 19 | void GXSetZCompLoc(int before_tex); 20 | void GXSetPixelFmt(GXPixelFmt pix_fmt, GXZFmt16 z_fmt); 21 | void GXSetDither(GXBool dither); 22 | void GXSetDstAlpha(GXBool enable, u8 alpha); 23 | // ? GXSetFieldMask(); 24 | // ? GXSetFieldMode(); 25 | 26 | #ifdef __cplusplus 27 | } 28 | #endif 29 | 30 | #endif // _DOLPHIN_GXPIXEL 31 | -------------------------------------------------------------------------------- /include/Dolphin/gx/GXTev.h: -------------------------------------------------------------------------------- 1 | #ifndef _DOLPHIN_GXTEV 2 | #define _DOLPHIN_GXTEV 3 | 4 | #include 5 | #include 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | void GXSetTevOp(GXTevStageID id, GXTevMode mode); 12 | void GXSetTevColorIn(GXTevStageID stage, GXTevColorArg a, GXTevColorArg b, GXTevColorArg c, 13 | GXTevColorArg d); 14 | void GXSetTevAlphaIn(GXTevStageID stage, GXTevAlphaArg a, GXTevAlphaArg b, GXTevAlphaArg c, 15 | GXTevAlphaArg d); 16 | void GXSetTevColorOp(GXTevStageID stage, GXTevOp op, GXTevBias bias, GXTevScale scale, GXBool clamp, 17 | GXTevRegID out_reg); 18 | void GXSetTevAlphaOp(GXTevStageID stage, GXTevOp op, GXTevBias bias, GXTevScale scale, GXBool clamp, 19 | GXTevRegID out_reg); 20 | void GXSetTevColor(GXTevRegID id, GXColor color); 21 | void GXSetTevColorS10(GXTevRegID id, GXColorS10 color); 22 | void GXSetTevKColor(GXTevKColorID id, GXColor color); 23 | void GXSetTevKColorSel(GXTevStageID stage, GXTevKColorSel sel); 24 | void GXSetTevKAlphaSel(GXTevStageID stage, GXTevKAlphaSel sel); 25 | void GXSetTevSwapMode(GXTevStageID stage, GXTevSwapSel ras_sel, GXTevSwapSel tex_sel); 26 | void GXSetTevSwapModeTable(GXTevSwapSel table, GXTevColorChan red, GXTevColorChan green, 27 | GXTevColorChan blue, GXTevColorChan alpha); 28 | void GXSetAlphaCompare(GXCompare comp0, u8 ref0, GXAlphaOp op, GXCompare comp1, u8 ref1); 29 | void GXSetZTexture(GXZTexOp op, GXTexFmt fmt, u32 bias); 30 | void GXSetTevOrder(GXTevStageID stage, GXTexCoordID coord, GXTexMapID map, GXChannelID color); 31 | void GXSetNumTevStages(u8 nStages); 32 | 33 | #ifdef __cplusplus 34 | } 35 | #endif 36 | 37 | #endif // _DOLPHIN_GXTEV 38 | -------------------------------------------------------------------------------- /include/Dolphin/gx/GXTexture.h: -------------------------------------------------------------------------------- 1 | #ifndef _DOLPHIN_GXTEXTURE 2 | #define _DOLPHIN_GXTEXTURE 3 | 4 | #include 5 | #include 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | typedef GXTexRegion* (*GXTexRegionCallback)(const GXTexObj* obj, GXTexMapID id); 12 | 13 | void GXInitTexObj(GXTexObj* obj, const void* data, u16 width, u16 height, u32 format, 14 | GXTexWrapMode wrapS, GXTexWrapMode wrapT, GXBool mipmap); 15 | void GXInitTexObjCI(GXTexObj* obj, const void* data, u16 width, u16 height, GXCITexFmt format, 16 | GXTexWrapMode wrapS, GXTexWrapMode wrapT, GXBool mipmap, u32 tlut); 17 | void GXInitTexObjData(GXTexObj* obj, const void* data); 18 | void GXInitTexObjLOD(GXTexObj* obj, GXTexFilter min_filt, GXTexFilter mag_filt, f32 min_lod, 19 | f32 max_lod, f32 lod_bias, GXBool bias_clamp, GXBool do_edge_lod, 20 | GXAnisotropy max_aniso); 21 | void GXLoadTexObj(GXTexObj* obj, GXTexMapID id); 22 | void GXGetTexObjAll(GXTexObj*, void**, u16*, u16*, u8*, u8*, u8*, u8*); 23 | u32 GXGetTexBufferSize(u16 width, u16 height, u32 format, GXBool mipmap, u8 max_lod); 24 | void GXInvalidateTexAll(); 25 | void GXInitTexObjWrapMode(GXTexObj* obj, GXTexWrapMode s, GXTexWrapMode t); 26 | void GXInitTlutObj(GXTlutObj* obj, const void* data, GXTlutFmt format, u16 entries); 27 | void GXLoadTlut(const GXTlutObj* obj, GXTlut idx); 28 | void GXSetTexCoordScaleManually(GXTexCoordID coord, GXBool enable, u16 ss, u16 ts); 29 | void GXInitTexCacheRegion(GXTexRegion* region, GXBool is_32b_mipmap, u32 tmem_even, 30 | GXTexCacheSize size_even, u32 tmem_odd, GXTexCacheSize size_odd); 31 | GXTexRegionCallback GXSetTexRegionCallback(GXTexRegionCallback callback); 32 | void GXInvalidateTexRegion(const GXTexRegion* region); 33 | 34 | #ifdef __cplusplus 35 | } 36 | #endif 37 | 38 | #endif // _DOLPHIN_GXTEXTURE 39 | -------------------------------------------------------------------------------- /include/Dolphin/gx/GXTransform.h: -------------------------------------------------------------------------------- 1 | #ifndef _DOLPHIN_GXTRANSFORM 2 | #define _DOLPHIN_GXTRANSFORM 3 | 4 | #include 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | #define GX_PROJECTION_SZ 7 11 | 12 | #ifdef TARGET_PC 13 | void GXSetProjection(const void* mtx, GXProjectionType type); 14 | void GXLoadPosMtxImm(const void* mtx, u32 id); 15 | void GXLoadNrmMtxImm(const void* mtx, u32 id); 16 | void GXLoadTexMtxImm(const void* mtx, u32 id, GXTexMtxType type); 17 | #else 18 | void GXSetProjection(f32 mtx[4][4], GXProjectionType type); 19 | void GXLoadPosMtxImm(f32 mtx[3][4], u32 id); 20 | void GXLoadNrmMtxImm(f32 mtx[3][4], u32 id); 21 | void GXLoadTexMtxImm(f32 mtx[][4], u32 id, GXTexMtxType type); 22 | #endif 23 | void GXSetViewport(f32 left, f32 top, f32 wd, f32 ht, f32 nearz, f32 farz); 24 | void GXSetCurrentMtx(u32 id); 25 | void GXSetViewportJitter(f32 left, f32 top, f32 wd, f32 ht, f32 nearz, f32 farz, u32 field); 26 | void GXSetScissorBoxOffset(s32 x_off, s32 y_off); 27 | void GXSetClipMode(GXClipMode mode); 28 | 29 | #ifdef __cplusplus 30 | } 31 | #endif 32 | 33 | #endif // _DOLPHIN_GXTRANSFORM 34 | -------------------------------------------------------------------------------- /include/Dolphin/gx/GXVert.h: -------------------------------------------------------------------------------- 1 | #ifndef _DOLPHIN_GXVERT 2 | #define _DOLPHIN_GXVERT 3 | 4 | #include 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | #define GXFIFO_ADDR 0xCC008000 11 | 12 | typedef union { 13 | u8 u8; 14 | u16 u16; 15 | u32 u32; 16 | u64 u64; 17 | s8 s8; 18 | s16 s16; 19 | s32 s32; 20 | s64 s64; 21 | f32 f32; 22 | f64 f64; 23 | } PPCWGPipe; 24 | 25 | volatile PPCWGPipe GXWGFifo : GXFIFO_ADDR; 26 | 27 | extern volatile union { 28 | u8 c; 29 | short s; 30 | int i; 31 | void * p; 32 | float f; 33 | } WGPIPE : 0xcc008000; 34 | 35 | static inline void GXPosition3f32(f32 x, f32 y, f32 z) { 36 | GXWGFifo.f32 = x; 37 | GXWGFifo.f32 = y; 38 | GXWGFifo.f32 = z; 39 | } 40 | 41 | static inline void GXColor4u8(u8 r, u8 g, u8 b, u8 a) { 42 | GXWGFifo.u8 = r; 43 | GXWGFifo.u8 = g; 44 | GXWGFifo.u8 = b; 45 | GXWGFifo.u8 = a; 46 | } 47 | 48 | static inline void GXTexCoord2f32(f32 s, f32 t) { 49 | GXWGFifo.f32 = s; 50 | GXWGFifo.f32 = t; 51 | } 52 | 53 | static inline void GXColor1u16(u16 v) { 54 | GXWGFifo.u16 = v; 55 | } 56 | 57 | static inline void GXColor1u32(const u32 v) { 58 | GXWGFifo.u32 = v; 59 | } 60 | 61 | static inline void GXEnd(void) {} 62 | 63 | #ifdef __cplusplus 64 | } 65 | #endif 66 | 67 | #endif // _DOLPHIN_GXVERT 68 | -------------------------------------------------------------------------------- /include/Dolphin/hw_regs.h: -------------------------------------------------------------------------------- 1 | #ifndef _DOLPHIN_HW_REGS 2 | #define _DOLPHIN_HW_REGS 3 | 4 | #include "types.h" 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | #ifdef __MWERKS__ 11 | vu16 __VIRegs[59] : 0xCC002000; 12 | vu32 __PIRegs[12] : 0xCC003000; 13 | vu16 __MEMRegs[64] : 0xCC004000; 14 | vu16 __DSPRegs[32] : 0xCC005000; 15 | vu32 __DIRegs[16] : 0xCC006000; 16 | vu32 __SIRegs[64] : 0xCC006400; 17 | vu32 __EXIRegs[16] : 0xCC006800; 18 | vu32 __AIRegs[8] : 0xCC006C00; 19 | 20 | #else 21 | #define __VIRegs ((vu16*)0xCC002000) 22 | #define __PIRegs ((vu32*)0xCC003000) 23 | #define __MEMRegs ((vu16*)0xCC004000) 24 | #define __DSPRegs ((vu16*)0xCC005000) 25 | #define __DIRegs ((vu32*)0xCC006000) 26 | #define __SIRegs ((vu32*)0xCC006400) 27 | #define __EXIRegs ((vu32*)0xCC006800) 28 | #define __AIRegs ((vu32*)0xCC006C00) 29 | #endif 30 | 31 | #ifdef __cplusplus 32 | } 33 | #endif 34 | 35 | #endif // _DOLPHIN_HW_REGS 36 | -------------------------------------------------------------------------------- /include/Dolphin/os/OSAlarm.h: -------------------------------------------------------------------------------- 1 | #ifndef _DOLPHIN_OSALARM 2 | #define _DOLPHIN_OSALARM 3 | 4 | #include 5 | #include 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | typedef struct OSAlarm OSAlarm; 12 | typedef void (*OSAlarmHandler)(OSAlarm* alarm, OSContext* context); 13 | 14 | struct OSAlarm { 15 | OSAlarmHandler handler; 16 | u32 tag; 17 | OSTime fire; 18 | OSAlarm* prev; 19 | OSAlarm* next; 20 | OSTime period; 21 | OSTime start; 22 | }; 23 | 24 | void OSInitAlarm(void); 25 | void OSSetAlarm(OSAlarm* alarm, OSTime tick, OSAlarmHandler handler); 26 | void OSSetAlarmTag(OSAlarm* alarm, u32 tag); 27 | void OSSetAbsAlarm(OSAlarm* alarm, OSTime time, OSAlarmHandler handler); 28 | void OSSetPeriodicAlarm(OSAlarm* alarm, OSTime start, OSTime period, OSAlarmHandler handler); 29 | void OSCreateAlarm(OSAlarm* alarm); 30 | void OSCancelAlarm(OSAlarm* alarm); 31 | void OSCancelAlarms(u32 tag); 32 | 33 | BOOL OSCheckAlarmQueue(void); 34 | 35 | #ifdef __cplusplus 36 | } 37 | #endif 38 | 39 | #endif // _DOLPHIN_OSALARM 40 | -------------------------------------------------------------------------------- /include/Dolphin/os/OSAlloc.h: -------------------------------------------------------------------------------- 1 | #ifndef __DOLPHIN_OSALLOC_H_ 2 | #define __DOLPHIN_OSALLOC_H_ 3 | 4 | //#include 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | typedef struct _HeapCell 11 | { 12 | struct _HeapCell *prev; 13 | struct _HeapCell *next; 14 | u32 size; 15 | } HeapCell; 16 | 17 | typedef struct _Heap 18 | { 19 | s32 size; 20 | struct _HeapCell *free; // linked list of free cells 21 | struct _HeapCell *allocated; // linked list of allocated cells 22 | } Heap; 23 | 24 | typedef int OSHeapHandle; 25 | 26 | extern volatile OSHeapHandle __OSCurrHeap; 27 | 28 | void *OSInitAlloc(void* arenaStart, void* arenaEnd, int maxHeaps); 29 | OSHeapHandle OSCreateHeap(void *, void *); 30 | void OSDestroyHeap(size_t idx); 31 | OSHeapHandle OSSetCurrentHeap(OSHeapHandle); 32 | void *OSAllocFromHeap(OSHeapHandle, int); 33 | long OSCheckHeap(OSHeapHandle); 34 | void OSFreeToHeap(OSHeapHandle heap, void *ptr); 35 | 36 | #define OSAlloc(size) OSAllocFromHeap(__OSCurrHeap, (size)) 37 | #define OSFree(ptr) OSFreeToHeap(__OSCurrHeap, (ptr)) 38 | #ifdef __cplusplus 39 | } 40 | #endif 41 | 42 | #endif // __DOLPHIN_OSALLOC_H_ 43 | -------------------------------------------------------------------------------- /include/Dolphin/os/OSArena.h: -------------------------------------------------------------------------------- 1 | #ifndef _DOLPHIN_OSARENA 2 | #define _DOLPHIN_OSARENA 3 | 4 | #include 5 | 6 | void* OSGetArenaHi(void); 7 | void* OSGetArenaLo(void); 8 | void OSSetArenaHi(void* addr); 9 | void OSSetArenaLo(void* addr); 10 | void* OSAllocFromArenaLo(u32 size, u32 align); 11 | void* OSAllocFromArenaLo(u32 size, u32 align); 12 | 13 | #endif // _DOLPHIN_OSARENA 14 | -------------------------------------------------------------------------------- /include/Dolphin/os/OSBootInfo.h: -------------------------------------------------------------------------------- 1 | #ifndef _DOLPHIN_OSBOOTINFO 2 | #define _DOLPHIN_OSBOOTINFO 3 | 4 | typedef struct OSBootInfo { 5 | DVDDiskID DVDDiskID; 6 | u32 magic; 7 | u32 version; 8 | u32 memorySize; 9 | u32 consoleType; 10 | void* arenaLo; 11 | void* arenaHi; 12 | void* FSTLocation; 13 | u32 FSTMaxLength; 14 | } OSBootInfo; 15 | 16 | typedef struct { 17 | BOOL valid; 18 | u32 restartCode; 19 | u32 bootDol; 20 | void* regionStart; 21 | void* regionEnd; 22 | BOOL argsUseDefault; 23 | void* argsAddr; // valid only when argsUseDefault = FALSE 24 | 25 | } OSExecParams; 26 | 27 | typedef struct BI2Debug { 28 | s32 debugMonSize; // 0x0 29 | s32 simMemSize; // 0x4 30 | u32 argOffset; // 0x8 31 | u32 debugFlag; // 0xC 32 | int trackLocation; // 0x10 33 | int trackSize; // 0x14 34 | u32 countryCode; // 0x18 35 | u8 unk[8]; // 0x1C 36 | u32 padSpec; // 0x24 37 | } BI2Debug; 38 | 39 | #endif // _DOLPHIN_OSBOOTINFO 40 | -------------------------------------------------------------------------------- /include/Dolphin/os/OSCache.h: -------------------------------------------------------------------------------- 1 | #ifndef _DOLPHIN_OSCACHE 2 | #define _DOLPHIN_OSCACHE 3 | 4 | #include "dolphin/types.h" 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | void DCInvalidateRange(void* addr, u32 nBytes); 11 | void DCFlushRange(void* addr, u32 nBytes); 12 | void DCStoreRange(void* addr, u32 nBytes); 13 | void DCFlushRangeNoSync(void* addr, u32 nBytes); 14 | void DCStoreRangeNoSync(void* addr, u32 nBytes); 15 | void DCZeroRange(void* addr, u32 nBytes); 16 | void DCTouchRange(void* addr, u32 nBytes); 17 | void ICInvalidateRange(void* addr, u32 nBytes); 18 | 19 | #define LC_BASE_PREFIX 0xE000 20 | #define LC_BASE (LC_BASE_PREFIX << 16) 21 | #define LCGetBase() ((void*)LC_BASE) 22 | 23 | void LCEnable(); 24 | void LCDisable(void); 25 | void LCLoadBlocks(void* destTag, void* srcAddr, u32 numBlocks); 26 | void LCStoreBlocks(void* destAddr, void* srcTag, u32 numBlocks); 27 | u32 LCLoadData(void* destAddr, void* srcAddr, u32 nBytes); 28 | u32 LCStoreData(void* destAddr, void* srcAddr, u32 nBytes); 29 | u32 LCQueueLength(void); 30 | void LCQueueWait(u32 len); 31 | void LCFlushQueue(void); 32 | 33 | #ifdef __cplusplus 34 | } 35 | #endif 36 | 37 | #endif // _DOLPHIN_OSCACHE 38 | -------------------------------------------------------------------------------- /include/Dolphin/os/OSError.h: -------------------------------------------------------------------------------- 1 | #ifndef _DOLPHIN_OSERROR 2 | #define _DOLPHIN_OSERROR 3 | 4 | #include 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | #define OS_ERROR_SYSTEM_RESET 0 11 | #define OS_ERROR_MACHINE_CHECK 1 12 | #define OS_ERROR_DSI 2 13 | #define OS_ERROR_ISI 3 14 | #define OS_ERROR_EXTERNAL_INTERRUPT 4 15 | #define OS_ERROR_ALIGNMENT 5 16 | #define OS_ERROR_PROGRAM 6 17 | #define OS_ERROR_FLOATING_POINT 7 18 | #define OS_ERROR_DECREMENTER 8 19 | #define OS_ERROR_SYSTEM_CALL 9 20 | #define OS_ERROR_TRACE 10 21 | #define OS_ERROR_PERFORMACE_MONITOR 11 22 | #define OS_ERROR_BREAKPOINT 12 23 | #define OS_ERROR_SYSTEM_INTERRUPT 13 24 | #define OS_ERROR_THERMAL_INTERRUPT 14 25 | #define OS_ERROR_PROTECTION 15 26 | #define OS_ERROR_FPE 16 27 | 28 | #define OS_ERROR_MAX (OS_ERROR_FPE) 29 | 30 | 31 | typedef u16 OSError; 32 | typedef void (*OSErrorHandler)( OSError error, OSContext* context, ... ); 33 | 34 | extern OSErrorHandler __OSErrorTable[OS_ERROR_MAX]; 35 | 36 | OSErrorHandler OSSetErrorHandler(OSError code, OSErrorHandler handler); 37 | 38 | #ifdef __cplusplus 39 | } 40 | #endif 41 | 42 | #endif // _DOLPHIN_OSERROR 43 | -------------------------------------------------------------------------------- /include/Dolphin/os/OSFastCast.h: -------------------------------------------------------------------------------- 1 | #ifndef _DOLPHIN_OSFASTCAST 2 | #define _DOLPHIN_OSFASTCAST 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #define OS_GQR_F32 0x0000 9 | #define OS_GQR_U8 0x0004 10 | #define OS_GQR_U16 0x0005 11 | #define OS_GQR_S8 0x0006 12 | #define OS_GQR_S16 0x0007 13 | 14 | #define OS_FASTCAST_U8 2 15 | #define OS_FASTCAST_U16 3 16 | #define OS_FASTCAST_S16 5 17 | // clang-format off 18 | static inline void OSInitFastCast(void) { 19 | #ifdef __MWERKS__ 20 | asm 21 | { 22 | li r3, OS_GQR_U8 23 | oris r3, r3, OS_GQR_U8 24 | mtspr GQR2, r3 25 | 26 | li r3, OS_GQR_U16 27 | oris r3, r3, OS_GQR_U16 28 | mtspr GQR3, r3 29 | 30 | li r3, OS_GQR_S8 31 | oris r3, r3, OS_GQR_S8 32 | mtspr GQR4, r3 33 | 34 | li r3, OS_GQR_S16 35 | oris r3, r3, OS_GQR_S16 36 | mtspr GQR5, r3 37 | } 38 | #else 39 | 40 | #endif 41 | } 42 | // clang-format off 43 | 44 | #ifdef __cplusplus 45 | } 46 | #endif 47 | 48 | #endif // _DOLPHIN_OSFASTCAST 49 | -------------------------------------------------------------------------------- /include/Dolphin/os/OSFont.h: -------------------------------------------------------------------------------- 1 | #ifndef _DOLPHIN_OSFONT 2 | #define _DOLPHIN_OSFONT 3 | 4 | #include 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | #define OS_FONT_ENCODE_ANSI 0u 11 | #define OS_FONT_ENCODE_SJIS 1u 12 | #define OS_FONT_ENCODE_UTF8 3u // UTF-8 [RFC 3629] 13 | #define OS_FONT_ENCODE_UTF16 4u // UTF-16BE [RFC 2781] 14 | #define OS_FONT_ENCODE_UTF32 5u // UTF-32 15 | #define OS_FONT_ENCODE_MAX 5u 16 | #define OS_FONT_ENCODE_VOID 0xffffu 17 | 18 | #define OS_FONT_PROPORTIONAL FALSE 19 | #define OS_FONT_FIXED TRUE 20 | 21 | u16 OSGetFontEncode(void); 22 | u16 OSSetFontEncode(u16 encode); 23 | 24 | #ifdef __cplusplus 25 | } 26 | #endif 27 | 28 | #endif // _DOLPHIN_OSFONT 29 | -------------------------------------------------------------------------------- /include/Dolphin/os/OSMemory.h: -------------------------------------------------------------------------------- 1 | #ifndef _DOLPHIN_OSMEMORY 2 | #define _DOLPHIN_OSMEMORY 3 | 4 | #include "types.h" 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | #define OS_PROTECT_CHAN0 0 11 | #define OS_PROTECT_CHAN1 1 12 | #define OS_PROTECT_CHAN2 2 13 | #define OS_PROTECT_CHAN3 3 14 | 15 | #define OS_PROTECT_CONTROL_NONE 0x00 16 | #define OS_PROTECT_CONTROL_READ 0x01 17 | #define OS_PROTECT_CONTROL_WRITE 0x02 18 | #define OS_PROTECT_CONTROL_RDWR (OS_PROTECT_CONTROL_READ | OS_PROTECT_CONTROL_WRITE) 19 | 20 | void OSProtectRange(u32 chan, void* addr, u32 nBytes, u32 control); 21 | 22 | #ifdef __cplusplus 23 | } 24 | #endif 25 | 26 | #endif // _DOLPHIN_OSMEMORY 27 | -------------------------------------------------------------------------------- /include/Dolphin/os/OSMessage.h: -------------------------------------------------------------------------------- 1 | #ifndef _DOLPHIN_OSMESSAGE 2 | #define _DOLPHIN_OSMESSAGE 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include 9 | typedef struct OSMessageQueue OSMessageQueue; 10 | typedef void* OSMessage; 11 | 12 | struct OSMessageQueue { 13 | OSThreadQueue queueSend; 14 | OSThreadQueue queueReceive; 15 | OSMessage* msgArray; 16 | s32 msgCount; 17 | s32 firstIndex; 18 | s32 usedCount; 19 | }; 20 | 21 | // Flags to turn blocking on/off when sending/receiving message 22 | #define OS_MESSAGE_NOBLOCK 0 23 | #define OS_MESSAGE_BLOCK 1 24 | 25 | void OSInitMessageQueue(OSMessageQueue* mq, OSMessage* msgArray, s32 msgCount); 26 | BOOL OSSendMessage(OSMessageQueue* mq, OSMessage msg, s32 flags); 27 | BOOL OSJamMessage(OSMessageQueue* mq, OSMessage msg, s32 flags); 28 | BOOL OSReceiveMessage(OSMessageQueue* mq, OSMessage* msg, s32 flags); 29 | 30 | #ifdef __cplusplus 31 | } 32 | #endif 33 | 34 | #endif // _DOLPHIN_OSMESSAGE 35 | -------------------------------------------------------------------------------- /include/Dolphin/os/OSMutex.h: -------------------------------------------------------------------------------- 1 | #ifndef _DOLPHIN_OSMUTEX 2 | #define _DOLPHIN_OSMUTEX 3 | 4 | #include "types.h" 5 | 6 | #include "Dolphin/os/OSThread.h" 7 | 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | 12 | struct OSMutex { 13 | OSThreadQueue queue; 14 | OSThread* thread; // the current owner 15 | s32 count; // lock count 16 | OSMutexLink link; // for OSThread.queueMutex 17 | }; 18 | 19 | struct OSCond { 20 | OSThreadQueue queue; 21 | }; 22 | 23 | void OSInitMutex(OSMutex* mutex); 24 | void OSLockMutex(OSMutex* mutex); 25 | void OSUnlockMutex(OSMutex* mutex); 26 | BOOL OSTryLockMutex(OSMutex* mutex); 27 | void OSInitCond(OSCond* cond); 28 | void OSWaitCond(OSCond* cond, OSMutex* mutex); 29 | void OSSignalCond(OSCond* cond); 30 | 31 | #ifdef __cplusplus 32 | } 33 | #endif 34 | 35 | #endif // _DOLPHIN_OSMUTEX 36 | -------------------------------------------------------------------------------- /include/Dolphin/os/OSPriv.h: -------------------------------------------------------------------------------- 1 | #ifndef _DOLPHIN_OSPRIV 2 | #define _DOLPHIN_OSPRIV 3 | 4 | #include "dolphin/os.h" 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | __OSExceptionHandler __OSGetExceptionHandler(__OSException exception); 11 | OSTime __OSGetSystemTime(); 12 | OSTime __OSTimeToSystemTime(OSTime); 13 | 14 | #ifdef __cplusplus 15 | } 16 | #endif 17 | 18 | #endif // _DOLPHIN_OSPRIV 19 | -------------------------------------------------------------------------------- /include/Dolphin/os/OSReset.h: -------------------------------------------------------------------------------- 1 | #ifndef _DOLPHIN_OSRESET 2 | #define _DOLPHIN_OSRESET 3 | 4 | #include 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | #define OS_RESETCODE_RESTART 0x80000000 11 | #define OS_RESETCODE_SYSTEM 0x40000000 12 | 13 | #define OS_RESETCODE_EXEC 0xC0000000 14 | #define OS_RESETCODE_NETCONFIG 0xC0010000 15 | 16 | #define OS_RESET_TIMEOUT OSMillisecondsToTicks(1000) 17 | 18 | #define OS_RESET_RESTART 0 19 | #define OS_RESET_HOTRESET 1 20 | #define OS_RESET_SHUTDOWN 2 21 | 22 | #define OS_RESET_PRIO_SO 110 23 | #define OS_RESET_PRIO_IP 111 24 | #define OS_RESET_PRIO_CARD 127 25 | #define OS_RESET_PRIO_PAD 127 26 | #define OS_RESET_PRIO_GX 127 27 | #define OS_RESET_PRIO_ALARM 4294967295 28 | 29 | typedef BOOL (*OSResetFunction)(BOOL final); 30 | typedef struct OSResetFunctionInfo OSResetFunctionInfo; 31 | 32 | struct OSResetFunctionInfo { 33 | // public 34 | OSResetFunction func; 35 | u32 priority; 36 | 37 | // private 38 | OSResetFunctionInfo* next; 39 | OSResetFunctionInfo* prev; 40 | }; 41 | 42 | #ifdef __cplusplus 43 | } 44 | #endif 45 | 46 | #endif // _DOLPHIN_OSRESET 47 | -------------------------------------------------------------------------------- /include/Dolphin/os/OSResetSW.h: -------------------------------------------------------------------------------- 1 | #ifndef _DOLPHIN_OSRESETSW 2 | #define _DOLPHIN_OSRESETSW 3 | 4 | #include 5 | #include 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | typedef void (*OSResetCallback)(void); 12 | 13 | BOOL OSGetResetButtonState(void); 14 | 15 | BOOL OSGetResetSwitchState(void); 16 | OSResetCallback OSSetResetCallback(OSResetCallback callback); 17 | 18 | #ifdef __cplusplus 19 | } 20 | #endif 21 | 22 | #endif // _DOLPHIN_OSRESETSW 23 | -------------------------------------------------------------------------------- /include/Dolphin/os/OSTime.h: -------------------------------------------------------------------------------- 1 | #include "types.h" 2 | 3 | typedef s64 OSTime; 4 | typedef u32 OSTick; 5 | 6 | typedef struct OSCalendarTime 7 | { 8 | int sec; // seconds after the minute [0, 61] 9 | int min; // minutes after the hour [0, 59] 10 | int hour; // hours since midnight [0, 23] 11 | int mday; // day of the month [1, 31] 12 | int mon; // month since January [0, 11] 13 | int year; // years in AD [1, ...] 14 | int wday; // days since Sunday [0, 6] 15 | int yday; // days since January 1 [0, 365] 16 | 17 | int msec; // milliseconds after the second [0,999] 18 | int usec; // microseconds after the millisecond [0,999] 19 | } OSCalendarTime; 20 | 21 | //void OSTicksToCalendarTime(OSTime ticks, OSCalendarTime* td); 22 | //OSTime OSGetTime(void); 23 | //OSTick OSGetTick(void); -------------------------------------------------------------------------------- /include/Dolphin/thp/THPAudio.h: -------------------------------------------------------------------------------- 1 | #ifndef _DOLPHIN_THPAUDIO 2 | #define _DOLPHIN_THPAUDIO 3 | 4 | #include "dolphin/types.h" 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | typedef struct THPAudioRecordHeader { 11 | u32 offsetNextChannel; 12 | u32 sampleSize; 13 | s16 lCoef[8][2]; 14 | s16 rCoef[8][2]; 15 | s16 lYn1; 16 | s16 lYn2; 17 | s16 rYn1; 18 | s16 rYn2; 19 | } THPAudioRecordHeader; 20 | 21 | typedef struct THPAudioDecodeInfo { 22 | u8* encodeData; 23 | u32 offsetNibbles; 24 | u8 predictor; 25 | u8 scale; 26 | s16 yn1; 27 | s16 yn2; 28 | } THPAudioDecodeInfo; 29 | 30 | u32 THPAudioDecode(s16* audioBuffer, u8* audioFrame, s32 flag); 31 | static s32 __THPAudioGetNewSample(THPAudioDecodeInfo* info); 32 | static void __THPAudioInitialize(THPAudioDecodeInfo* info, u8* ptr); 33 | 34 | #ifdef __cplusplus 35 | } 36 | #endif 37 | 38 | #endif // _DOLPHIN_THPAUDIO 39 | -------------------------------------------------------------------------------- /include/Dolphin/thp/THPAudioDecode.h: -------------------------------------------------------------------------------- 1 | #ifndef _THP_THPAUDIODECODE_H 2 | #define _THP_THPAUDIODECODE_H 3 | 4 | #include "Dolphin/os.h" 5 | #include "Dolphin/thp/THPAudio.h" 6 | #include "Dolphin/thp/THPBuffer.h" 7 | 8 | static void* AudioDecoderForOnMemory(void* bufPtr); 9 | static void* AudioDecoder(void* _); 10 | static void AudioDecode(THPReadBuffer* readBuffer); 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | BOOL CreateAudioDecodeThread(OSPriority prio, void* param); 17 | void AudioDecodeThreadStart(); 18 | void AudioDecodeThreadCancel(); 19 | 20 | void PushFreeAudioBuffer(void* buf); 21 | void PushDecodedAudioBuffer(void* buf); 22 | 23 | void* PopFreeAudioBuffer(); 24 | void* PopDecodedAudioBuffer(s32 flags); 25 | 26 | #ifdef __cplusplus 27 | } 28 | #endif 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /include/Dolphin/thp/THPBuffer.h: -------------------------------------------------------------------------------- 1 | #ifndef _THP_THPBUFFER_H 2 | #define _THP_THPBUFFER_H 3 | 4 | #include "types.h" 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | // Size 0x10 11 | typedef struct THPTextureSet { 12 | u8* mYTexture; // _00 13 | u8* mUTexture; // _04 14 | u8* mVTexture; // _08 15 | s32 mFrameNumber; // _0C 16 | } THPTextureSet; 17 | 18 | // Size 0xC 19 | typedef struct THPAudioBuffer { 20 | s16* mBuffer; // _00 21 | s16* mCurPtr; // _04 22 | u32 mValidSample; // _08 23 | } THPAudioBuffer; 24 | 25 | // Size 0xC 26 | typedef struct THPReadBuffer { 27 | u8* mPtr; // _00 28 | s32 mFrameNumber; // _04 29 | BOOL mIsValid; // _08 30 | } THPReadBuffer; 31 | 32 | #ifdef __cplusplus 33 | } 34 | #endif 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /include/Dolphin/thp/THPDraw.h: -------------------------------------------------------------------------------- 1 | #ifndef _THP_THPDRAW_H 2 | #define _THP_THPDRAW_H 3 | 4 | #include "types.h" 5 | // #include "Dolphin/gx/GXTypes.h" 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif // ifdef __cplusplus 10 | 11 | void THPGXRestore(void); 12 | // void THPGXYuv2RgbSetup(GXRenderModeObj* obj); 13 | void THPGXYuv2RgbDraw(u32* yImage, u32* uImage, u32* vImage, s16 x, s16 y, s16 texWidth, s16 texHeight, s16 polyWidth, s16 polyHeight); 14 | void THPPlayerStop(); 15 | BOOL THPPlayerSetVolume(int, int); 16 | 17 | #ifdef __cplusplus 18 | }; 19 | #endif // ifdef __cplusplus 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /include/Dolphin/thp/THPFile.h: -------------------------------------------------------------------------------- 1 | #ifndef _THP_THPFILE_H 2 | #define _THP_THPFILE_H 3 | 4 | #include "types.h" 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | // Size 0x30 11 | typedef struct THPHeader { 12 | char mMagic[4]; // _00 13 | u32 mVersion; // _04 14 | u32 mBufferSize; // _08 15 | u32 mAudioMaxSamples; // _0C 16 | f32 mFrameRate; // _10 17 | u32 mNumFrames; // _14 18 | u32 mFirstFrameSize; // _18 19 | u32 mMovieDataSize; // _1C 20 | u32 mCompInfoDataOffsets; // _20 21 | u32 mOffsetDataOffsets; // _24 22 | u32 mMovieDataOffsets; // _28 23 | u32 mFinalFrameDataOffsets; // _2C 24 | } THPHeader; 25 | 26 | #ifdef __cplusplus 27 | } 28 | #endif 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /include/Dolphin/thp/THPInfo.h: -------------------------------------------------------------------------------- 1 | #ifndef _THP_THPINFO_H 2 | #define _THP_THPINFO_H 3 | 4 | #include "types.h" 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | // Size 0xC 11 | typedef struct THPVideoInfo { 12 | u32 mXSize; // _00 13 | u32 mYSize; // _04 14 | u32 mVideoType; // _08 15 | } THPVideoInfo; 16 | 17 | // Size 0x10 18 | typedef struct THPAudioInfo { 19 | u32 mSndChannels; // _00 20 | u32 mSndFrequency; // _04 21 | u32 mSndNumSamples; // _08 22 | u32 mSndNumTracks; // _0C 23 | } THPAudioInfo; 24 | 25 | // Size 0x14 26 | typedef struct THPFrameCompInfo { 27 | u32 mNumComponents; // _00 28 | u8 mFrameComp[16]; // _04 29 | } THPFrameCompInfo; 30 | 31 | #ifdef __cplusplus 32 | } 33 | #endif 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /include/Dolphin/thp/THPRead.h: -------------------------------------------------------------------------------- 1 | #ifndef _THP_THPREAD_H 2 | #define _THP_THPREAD_H 3 | 4 | #include "dolphin/thp/THPBuffer.h" 5 | #include "dolphin/os.h" 6 | 7 | static void* Reader(void* arg); 8 | 9 | #ifdef __cplusplus 10 | extern "C" { 11 | #endif // ifdef __cplusplus 12 | 13 | BOOL CreateReadThread(OSPriority priority); 14 | void ReadThreadStart(); 15 | void ReadThreadCancel(); 16 | OSMessage PopReadedBuffer(); 17 | BOOL PushReadedBuffer(OSMessage*); 18 | OSMessage PopFreeReadBuffer(); 19 | BOOL PushFreeReadBuffer(OSMessage*); 20 | OSMessage PopReadedBuffer2(); 21 | BOOL PushReadedBuffer2(OSMessage*); 22 | 23 | extern u8 gTHPReaderDvdAccess; 24 | #ifdef __cplusplus 25 | }; 26 | #endif 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /include/Dolphin/thp/THPVideoDecode.h: -------------------------------------------------------------------------------- 1 | #ifndef _DOLPHIN_THPVIDEODECODE 2 | #define _DOLPHIN_THPVIDEODECODE 3 | 4 | #include "Dolphin/thp/THPRead.h" 5 | 6 | static void* VideoDecoder(void*); 7 | static void* VideoDecoderForOnMemory(void*); 8 | static void VideoDecode(THPReadBuffer*); 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif // ifdef __cplusplus 13 | s32 THPVideoDecode(void* file, void* tileY, void* tileU, void* tileV, void* work); 14 | BOOL CreateVideoDecodeThread(OSPriority priority, void* task); 15 | void VideoDecodeThreadStart(); 16 | void VideoDecodeThreadCancel(); 17 | OSMessage PopFreeTextureSet(); 18 | BOOL PushFreeTextureSet(OSMessage*); 19 | OSMessage PopDecodedTextureSet(s32 flags); 20 | BOOL PushDecodedTextureSet(OSMessage*); 21 | 22 | extern BOOL VideoDecodeThreadCreated; 23 | extern OSMessageQueue FreeTextureSetQueue; 24 | extern OSMessageQueue DecodedTextureSetQueue; 25 | extern OSThread VideoDecodeThread; 26 | 27 | #ifdef __cplusplus 28 | }; 29 | #endif 30 | 31 | #endif // _DOLPHIN_THPVIDEODECODE 32 | -------------------------------------------------------------------------------- /include/Dolphin/types.h: -------------------------------------------------------------------------------- 1 | #ifndef _DOLPHIN_TYPES 2 | #define _DOLPHIN_TYPES 3 | 4 | typedef signed char s8; 5 | typedef signed short int s16; 6 | typedef signed long s32; 7 | typedef signed long long int s64; 8 | typedef unsigned char u8; 9 | typedef unsigned short int u16; 10 | typedef unsigned long u32; 11 | typedef unsigned long long int u64; 12 | 13 | typedef volatile u8 vu8; 14 | typedef volatile u16 vu16; 15 | typedef volatile u32 vu32; 16 | typedef volatile u64 vu64; 17 | 18 | typedef volatile s8 vs8; 19 | typedef volatile s16 vs16; 20 | typedef volatile s32 vs32; 21 | typedef volatile s64 vs64; 22 | 23 | typedef float f32; 24 | typedef double f64; 25 | 26 | typedef volatile f32 vf32; 27 | typedef volatile f64 vf64; 28 | 29 | typedef int BOOL; 30 | 31 | #ifndef FALSE 32 | #define FALSE 0 33 | #endif 34 | 35 | #ifndef TRUE 36 | #define TRUE 1 37 | #endif 38 | 39 | #ifndef NULL 40 | #define NULL 0 41 | #endif 42 | 43 | #if !defined(__cplusplus) || __cplusplus < 201103L 44 | #ifndef nullptr 45 | #define nullptr NULL 46 | #endif 47 | 48 | #if defined(__MWERKS__) 49 | #ifndef override 50 | #define override 51 | #endif 52 | #endif 53 | 54 | #endif 55 | 56 | #ifndef ATTRIBUTE_ALIGN 57 | #if defined(__MWERKS__) || defined(__GNUC__) 58 | #define ATTRIBUTE_ALIGN(num) __attribute__((aligned(num))) 59 | #elif defined(_MSC_VER) 60 | #define ATTRIBUTE_ALIGN(num) 61 | #else 62 | #error unknown compiler 63 | #endif 64 | #endif 65 | 66 | #endif // _DOLPHIN_TYPES 67 | -------------------------------------------------------------------------------- /include/Dolphin/vi.h: -------------------------------------------------------------------------------- 1 | #ifndef _DOLPHIN_VI 2 | #define _DOLPHIN_VI 3 | 4 | #include 5 | #include 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | void VIInit(void); 12 | void VIConfigure(GXRenderModeObj* rm); 13 | void VIFlush(void); 14 | u32 VIGetTvFormat(void); 15 | void VISetNextFrameBuffer(void* fb); 16 | void VIWaitForRetrace(void); 17 | void VISetBlack(BOOL black); 18 | 19 | #ifdef __cplusplus 20 | } 21 | #endif 22 | 23 | #endif // _DOLPHIN_VI 24 | -------------------------------------------------------------------------------- /include/Dolphin/vifuncs.h: -------------------------------------------------------------------------------- 1 | #ifndef _DOLPHIN_VIFUNCS 2 | #define _DOLPHIN_VIFUNCS 3 | 4 | #include 5 | 6 | #include 7 | 8 | #ifdef __cplusplus 9 | extern "C" { 10 | #endif 11 | 12 | u32 VIGetNextField(void); 13 | VIRetraceCallback VISetPreRetraceCallback(VIRetraceCallback callback); 14 | VIRetraceCallback VISetPostRetraceCallback(VIRetraceCallback callback); 15 | u32 VIGetDTVStatus(void); 16 | 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | 21 | #endif // _DOLPHIN_VIFUNCS 22 | -------------------------------------------------------------------------------- /include/Dolphin/vitypes.h: -------------------------------------------------------------------------------- 1 | #ifndef _DOLPHIN_VITYPES 2 | #define _DOLPHIN_VITYPES 3 | 4 | #include 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | typedef void (*VIRetraceCallback)(u32 retraceCount); 11 | 12 | #ifdef __cplusplus 13 | } 14 | #endif 15 | 16 | #endif // _DOLPHIN_VITYPES 17 | -------------------------------------------------------------------------------- /include/common/Camera.h: -------------------------------------------------------------------------------- 1 | #ifndef COMMON_CAMERA 2 | #define COMMON_CAMERA 3 | 4 | #include "common/Input.h" 5 | #include "common/Vector.h" 6 | 7 | enum Camera_Mode { 8 | CM_FIRST = 0, 9 | // 10 | CM_COUNT = 3, 11 | }; 12 | 13 | enum Camera_Direction { 14 | 15 | }; 16 | 17 | struct KeyMap { 18 | int button; 19 | bool unk4; // bool? 20 | bool bEnabled; // bool? 21 | }; 22 | 23 | struct Camera { 24 | static void InitModule(void); 25 | static void DeinitModule(void); 26 | void Init(void); 27 | void Deinit(void); 28 | 29 | void Reposition(Camera_Mode camMode, Vector* pPosition, Vector* pTarget); 30 | 31 | float GetAnalogButtonState(InputDevices, int); 32 | float CalcAnalogCameraProp(InputDevices, float, bool, int); 33 | float CalcCameraProp(InputDevices, float, bool, int, int); 34 | 35 | void SetFixedDir(Camera_Direction); 36 | void SetMode(Camera_Mode); 37 | 38 | void DrawDebug(float x, float* pY); 39 | 40 | bool Update(InputDevices device, Vector*); 41 | 42 | Camera_Mode mode; 43 | int unk4; 44 | KeyMap* pMap; 45 | float unkC; 46 | Vector pos; 47 | Vector target; 48 | Vector dir; 49 | Vector unk40; 50 | 51 | static KeyMap keyMapDS[22]; 52 | static bool flipYAxis; 53 | }; 54 | 55 | #endif // COMMON_CAMERA 56 | -------------------------------------------------------------------------------- /include/common/Crc.h: -------------------------------------------------------------------------------- 1 | #ifndef COMMON_CRC 2 | #define COMMON_CRC 3 | 4 | u32 Crc_Calculate(const void*, int); 5 | 6 | #endif // COMMON_CRC -------------------------------------------------------------------------------- /include/common/Debug.h: -------------------------------------------------------------------------------- 1 | #ifndef COMMON_DEBUG 2 | #define COMMON_DEBUG 3 | 4 | #include "common/Font.h" 5 | #include "common/Str.h" 6 | 7 | inline char* FormatVector(Vector* pVec) { 8 | return Str_Printf("(%5.3f, %5.3f, %5.3f)", pVec->x, pVec->y, pVec->z); 9 | } 10 | 11 | // inline char* PrintVector(Vector* pVec) { 12 | // return Str_Printf("(%5.3f, %5.3f, %5.3f, %5.3f)", pVec->x, pVec->y, pVec->z, pVec->w); 13 | // } 14 | 15 | #ifndef BARBIE_ICESKATING 16 | #define BARBIE_ICESKATING (0) 17 | #endif // BARBIE_ICESKATING 18 | 19 | #ifndef MK_DEBUG 20 | #define MK_DEBUG 0 21 | #endif // MK_DEBUG 22 | 23 | #if MK_DEBUG == 1 24 | 25 | void Debug_Assert(char*, char*, char*, int); 26 | #ifndef ASSERT 27 | #define ASSERT(cond, msg, file, line) if (!(cond)) Debug_Assert(#cond, msg, file, line) 28 | #endif // ASSERT 29 | 30 | #else 31 | 32 | #ifndef ASSERT 33 | #define ASSERT(cond, msg, file, line) 34 | #endif // ASSERT 35 | 36 | #endif 37 | 38 | void Debug_InitModule(void); 39 | void Debug_DeinitModule(void); 40 | void Debug_SetFont(Font* mDebugFont); 41 | 42 | extern Font* gpDebugFont; 43 | 44 | #endif // COMMON_DEBUG 45 | -------------------------------------------------------------------------------- /include/common/DirectLight.h: -------------------------------------------------------------------------------- 1 | #ifndef COMMON_DIRECTLIGHT 2 | #define COMMON_DIRECTLIGHT 3 | 4 | #include "common/Vector.h" 5 | #include "common/Matrix.h" 6 | 7 | struct DirectLight { 8 | Matrix mDirMatrix; 9 | 10 | Vector mNewColors[3]; 11 | Vector mNewAmbient; 12 | 13 | Vector mLightDirs[3]; 14 | Vector mLightColors[3]; 15 | Vector mAmbient; 16 | 17 | static void InitModule(void); 18 | static void DeinitModule(void); 19 | void Init(void); 20 | void Set(Vector*); 21 | void SetLight(int, Vector*, Vector*); 22 | void SetAmbient(Vector*); 23 | void RecalcMatrices(void); 24 | 25 | static DirectLight* pDefaultLight; 26 | 27 | static DirectLight* GetDefault(void) { 28 | return pDefaultLight; 29 | } 30 | }; 31 | 32 | #endif // COMMON_DIRECTLIGHT 33 | -------------------------------------------------------------------------------- /include/common/DiscErrors.h: -------------------------------------------------------------------------------- 1 | #ifndef COMMON_DISCERRORS 2 | #define COMMON_DISCERRORS 3 | 4 | void DiscErr_SetError(int error); 5 | bool DiscErr_IsError(void); 6 | void DiscErr_ClearError(void); 7 | char* DiscErr_GetErrorString(void); 8 | void DiscErr_DrawErrorString(void); 9 | void DiscErr_DrawString(char* pErrStr); 10 | 11 | #endif // COMMON_DISCERRORS 12 | -------------------------------------------------------------------------------- /include/common/File.h: -------------------------------------------------------------------------------- 1 | #ifndef COMMON_FILE 2 | #define COMMON_FILE 3 | 4 | #include "Dolphin/dvd.h" 5 | 6 | // Seek Values 7 | 8 | // Set the position relative to the beginning 9 | #define SEEK_SET (0) 10 | 11 | // Set the position relative to current position (current += seek_offset) 12 | #define SEEK_CUR (1) 13 | 14 | // Set the position relative to the end (seek_offset <(=?) file_length, current += seek_offset) 15 | #define SEEK_END (2) 16 | 17 | struct FileEntry { 18 | DVDFileInfo fileInfo; 19 | DVDCallback callback; 20 | void* unk40; 21 | void* unk44; 22 | int streamOffset; 23 | int unk4C; 24 | int unk50; 25 | int unk54; 26 | }; 27 | 28 | void File_InitModule(void); 29 | int File_Open(char* filepath, int openMode); 30 | int File_Close(int fd); 31 | int File_Read(int fd, void* buf, int size, int arg3); 32 | void File_ReadCallback(s32, DVDFileInfo*); 33 | int File_Seek(int fd, int offset, int seekType); 34 | int File_Length(char* filename); 35 | char* File_FileServerFilename(char* pFilename); 36 | int File_Sync(int fd, int); 37 | bool File_IsAnyBusy(void); 38 | char* File_FileServerOutputFilename(char* name); 39 | int File_Write(int fd, void* pData, int len); 40 | 41 | #endif // COMMON_FILE 42 | -------------------------------------------------------------------------------- /include/common/GC_ByteFixup.h: -------------------------------------------------------------------------------- 1 | #ifndef GC_BYTEFIXUP_H 2 | #define GC_BYTEFIXUP_H 3 | 4 | #include "types.h" 5 | #include "common/Vector.h" 6 | 7 | void ByteReverseVector(Vector&); 8 | 9 | template 10 | void ByteReverse(T& start) 11 | { 12 | char *buffer = (char*)(&start); 13 | int size = sizeof(T); 14 | 15 | for (int i = 0; i < size / 2; i++) { 16 | char tmp = buffer[i]; 17 | buffer[i] = buffer[size - i - 1]; 18 | buffer[size - i - 1] = tmp; 19 | } 20 | } 21 | 22 | template 23 | static void Fixup(T*& data, int baseAddress) { 24 | if (data != NULL) { 25 | ByteReverse(data); 26 | data = (T*)((int)data + baseAddress); 27 | } 28 | } 29 | 30 | /*template <> 31 | static void Fixup(Vector*& data, int baseAddress) { 32 | if (data != NULL) { 33 | ByteReverse(data); 34 | data = (Vector*)((int)data + baseAddress); 35 | } 36 | } 37 | 38 | template <> 39 | static void Fixup(AnimationData::Node::KeyFrame*& data, int baseAddress) { 40 | if (data != NULL) { 41 | ByteReverse(data); 42 | data = (AnimationData::Node::KeyFrame*)((int)data + baseAddress); 43 | } 44 | } 45 | 46 | template <> 47 | static void Fixup(AnimDef*& data, int baseAddress) { 48 | if (data != NULL) { 49 | ByteReverse(data); 50 | data = (AnimDef*)((int)data + baseAddress); 51 | } 52 | } 53 | 54 | template <> 55 | static void Fixup(AnimationData::Node*& data, int baseAddress) { 56 | if (data != NULL) { 57 | ByteReverse(data); 58 | data = (AnimationData::Node*)((int)data + baseAddress); 59 | } 60 | }*/ 61 | 62 | #endif // GC_BYTEFIXUP_H -------------------------------------------------------------------------------- /include/common/Heap.h: -------------------------------------------------------------------------------- 1 | #ifndef COMMON_HEAP 2 | #define COMMON_HEAP 3 | 4 | void Heap_InitModule(int); 5 | void Heap_DeinitModule(void); 6 | int Heap_MemoryUsed(void); 7 | void* Heap_MemAllocAligned(int size, int alignment); // alignment is unused 8 | void Heap_MemFreeAligned(void* ptr); 9 | void* Heap_MemAlloc(int size); 10 | void Heap_MemFree(void* ptr); 11 | int Heap_Check(char* file, int lineNumber); 12 | 13 | #endif // COMMON_HEAP 14 | -------------------------------------------------------------------------------- /include/common/Input.h: -------------------------------------------------------------------------------- 1 | #ifndef COMMON_INPUT 2 | #define COMMON_INPUT 3 | 4 | #include "Dolphin/pad.h" 5 | 6 | // might be IDEV_JOY%d and IDEV_JOYALL? 7 | enum InputDevices { 8 | CHAN_0 = 0, 9 | CHAN_1 = 1, 10 | CHAN_2 = 2, 11 | CHAN_3 = 3, 12 | ALL_CHANS = 4, 13 | MAX_CHANS = 5 14 | }; 15 | 16 | // "Stick" is the left joystick on the controller 17 | // "C-stick" is the right stick (C-stick) 18 | 19 | // TODO document all fields 20 | struct Input_Joypad { 21 | PADStatus* pPad; 22 | 23 | u16 mPrevButtonFlags; // Previous frame inputs 24 | u16 mCurrButtonFlags; // Current frame inputs 25 | 26 | // Current Frame Stick Fields 27 | int mCurrStickX; // Stick X 28 | int mCurrStickY; // Stick Y 29 | int mCurrSubStickX; // C-stick X 30 | int mCurrSubStickY; // C-stick Y 31 | 32 | // Previous Frame Stick Fields 33 | int mPrevStickX; // Stick X 34 | int mPrevStickY; // Stick Y 35 | int mPrevSubStickX; // C-stick X 36 | int mPrevSubStickY; // C-stick Y 37 | 38 | u8 triggerL; // Left analog trigger 39 | u8 triggerR; // Right analog trigger 40 | }; 41 | 42 | void Input_InitModule(void); 43 | void Input_DeinitModule(void); 44 | void Input_Update(bool bReadInputs); 45 | int Input_GetDeviceStatus(InputDevices deviceID); 46 | int Input_GetButtonState(InputDevices deviceID, int button, InputDevices* pFoundDevice); 47 | bool Input_WasButtonPressed(InputDevices deviceID, int button, InputDevices* pFoundDevice); 48 | void Input_Vibrate(InputDevices deviceID, int r4, bool r5); 49 | void Input_ClearPadData(void); 50 | bool Input_HasAnyButtonChanged(void); 51 | void Input_EnableKeyMapping(bool bEnableKeyMapping); 52 | bool Input_IsKeyMappingEnabled(void); 53 | void Input_StopAllVibration(void); 54 | bool Input_IsButtonStick(int buttonVal); 55 | void PADClampCircle(PADStatus* status); 56 | 57 | #endif // COMMON_INPUT 58 | -------------------------------------------------------------------------------- /include/common/MKGrass.h: -------------------------------------------------------------------------------- 1 | #ifndef COMMON_MKGRASS 2 | #define COMMON_MKGRASS 3 | 4 | #include "common/Model.h" 5 | 6 | #define MAX_GRASS_ENTRIES (22) 7 | 8 | struct GrassInfo { 9 | int clumpSize; 10 | int density; 11 | float minHeight; 12 | float maxHeight; 13 | float width; 14 | float movement; 15 | float animSpeed; 16 | float maxPushAway; 17 | float pushAwayRadius; 18 | int numTextures; 19 | float upVector; 20 | float textureAnimSpeed; 21 | float unk30; 22 | int unk34; 23 | float maxVisibleRadius; 24 | Material* pMat; 25 | char materialName[32]; 26 | }; 27 | 28 | void Grass_DrawGC(Model* pModel, u8* pStripData, int stripMaxOffset, int grassIndex, float f1, float f2); 29 | 30 | void MKGrass_InitTypes(char* pName); 31 | void MKGrass_DeinitTypes(void); 32 | 33 | void MKGrass_Deinit(void); 34 | 35 | void MKGrass_Update(void); 36 | void MKGrass_Draw(void); 37 | 38 | void MKGrass_Init(void); 39 | 40 | void MKGrassGC_LoadTextures(char** ppTextureNames); 41 | void MKGrassGC_UnloadTextures(void); 42 | 43 | void MKGrass_AddModel(Model* pModel); 44 | 45 | void MKGrass_SetPushAwayPos(Vector*, int pushAwayIndex); 46 | 47 | extern Vector* pGrassPushAway; 48 | extern float GrassGCMaxRadius; 49 | 50 | #endif // COMMON_MKGRASS 51 | -------------------------------------------------------------------------------- /include/common/MKPackage.h: -------------------------------------------------------------------------------- 1 | #ifndef COMMON_MKPACKAGE 2 | #define COMMON_MKPACKAGE 3 | 4 | void MKPackage_InitModule(void); 5 | void MKPackage_DeinitModule(void); 6 | void MKPackage_Update(void); 7 | void MKPackage_Load(char* pPackageName, bool bLoadFilesAsync); 8 | void MKPackage_LoadDynamic(char* pFilename, bool bLoadFilesAsync); 9 | bool MKPackage_IsLoaded(float* pProgress); 10 | void MKPackage_Cancel(void); 11 | int MKPackage_Free(void); 12 | 13 | struct AutoEntry { 14 | char name[0x20]; 15 | }; 16 | 17 | struct PackageEntry { 18 | char* pFilename; 19 | int fileOffset; 20 | int fileSize; 21 | void* pFileData; 22 | }; 23 | 24 | #endif // COMMON_MKPACKAGE 25 | -------------------------------------------------------------------------------- /include/common/MKParticleGen.h: -------------------------------------------------------------------------------- 1 | #ifndef COMMON_MKPARTICLEGEN_H 2 | #define COMMON_MKPARTICLEGEN_H 3 | 4 | #include "common/View.h" 5 | #include "common/Vector.h" 6 | #include "common/Material.h" 7 | 8 | struct MKParticleGenType { 9 | struct Envelope { 10 | float unk0; 11 | float unk4; 12 | float unk8; 13 | float unkC; 14 | float unk10; 15 | float unk14; 16 | }; 17 | float alpha; 18 | float radius; 19 | int primitiveType; 20 | float halfWidth; 21 | float halfHeight; 22 | 23 | // Color Vectors 24 | Vector color0; 25 | Vector color1; 26 | Vector color2; 27 | Vector color3; 28 | 29 | float xVel; 30 | float yVel; 31 | float zVel; 32 | int nmbrOfParticles; 33 | char* pMatName; 34 | Envelope* pEnvelopes; 35 | float numEnvEntries; 36 | float envAnimRate; 37 | float unk74; 38 | float unk78; 39 | 40 | void Init(void); // Stripped 41 | void SetEnvelope(MKParticleGenType::Envelope*, int); 42 | void SetAnimRate(float animRate) { 43 | envAnimRate = animRate; 44 | } 45 | }; 46 | 47 | struct MKParticleGen { 48 | MKParticleGenType* pType; 49 | Material* pMat; 50 | float unk8; 51 | float unkC; 52 | float unk10; 53 | float xPos; 54 | float yPos; 55 | float zPos; 56 | float unk20; 57 | float unk24; 58 | Vector mSrcPos; 59 | 60 | void Init(MKParticleGenType* _pType, Material* _pMat); 61 | void Deinit(void); 62 | void Update(void); 63 | void Draw(View* pView, Vector*, Vector*); 64 | void DrawDebugInfo(View* pView); 65 | void DrawLines(View* pView, Vector*); 66 | void DrawQuads(View* pView, Vector*); 67 | }; 68 | 69 | #endif // COMMON_MKPARTICLEGEN_H 70 | -------------------------------------------------------------------------------- /include/common/MKRumble.h: -------------------------------------------------------------------------------- 1 | #ifndef COMMON_MKRUMBLE 2 | #define COMMON_MKRUMBLE 3 | 4 | #include "common/Input.h" 5 | 6 | #define NUM_VIBRA_EFFECTS (8) 7 | 8 | struct InputDeviceStruct { 9 | int unk0; 10 | bool unk4; 11 | float unk8; 12 | }; 13 | 14 | struct VibrationEffect { 15 | float unk0; 16 | float unk4; 17 | float unk8; 18 | float unkC; 19 | char flags; 20 | int unk14; 21 | float unk18; 22 | }; 23 | 24 | void MKRumble_Reset(void); 25 | void MKRumble_Update(void); 26 | void MKRumble_Pause(void); 27 | void MKRumble_Resume(void); 28 | void MKRumble_Play(InputDevices, float, float, float, char effectFlags, float); 29 | void MKRumble_Stop(InputDevices targetDevice); 30 | 31 | #endif // COMMON_MKRUMBLE 32 | -------------------------------------------------------------------------------- /include/common/MKShadow.h: -------------------------------------------------------------------------------- 1 | #ifndef COMMON_MKSHADOW 2 | #define COMMON_MKSHADOW 3 | 4 | #include "common/Model.h" 5 | #include "common/View.h" 6 | 7 | #define MKSHADOW_POLY_COUNT (1024) 8 | #define MKSHADOW_VERTEX_COUNT (MKSHADOW_POLY_COUNT * 3) 9 | 10 | #define MKSHADOW_DETAIL_COUNT (3) 11 | 12 | struct MKShadowDetail { 13 | int unk0; 14 | int unk4; 15 | Material* pMaterial0; 16 | Material* pMaterial1; 17 | View detailView; 18 | }; 19 | 20 | /// @brief Contains information about individual vertices in an MKShadow 21 | struct MKShadowVert { 22 | float x; 23 | float y; 24 | float z; 25 | int matrixIndex; 26 | Vector mNormal; 27 | }; 28 | 29 | /// @brief Contains vertex indices for each polygon in an MKShadow 30 | struct MKShadowPoly { 31 | int vertex0_index; 32 | int vertex1_index; 33 | int vertex2_index; 34 | }; 35 | 36 | struct MKShadow_Animated { 37 | MKShadowPoly* pPolys; 38 | int numberOfPolys; 39 | MKShadowVert* pVerts; 40 | int numberOfVertices; 41 | 42 | int AddVert(MKShadowVert* pNewVert); 43 | int AddPoly(MKShadowVert* pVert0, MKShadowVert* pVert1, MKShadowVert* pVert2); 44 | void Build(char*); 45 | }; 46 | 47 | enum MKShadow_Type { 48 | MKSHADOW_ANIMATED = 0, 49 | MKSHADOW_STATIC = 1 50 | }; 51 | 52 | struct MKShadow { 53 | MKShadow_Type mType; 54 | MKShadow_Animated* mpAnimatedShadow; 55 | }; 56 | 57 | void MKShadow_InitModule(void); 58 | void MKShadow_DeinitModule(void); 59 | void MKShadow_DetectEdges(MKShadow*, Vector*, Model*, Vector*); 60 | void MKShadow_Render(MKShadow*, Vector*, Vector*, float, int, uint*, Vector*); 61 | void MKShadow_RenderStretchBlurEffect(MKShadow*, Vector*, Vector*, float, int*); 62 | void MKShadow_EndScene(void); 63 | MKShadow* MKShadow_CreateAnimatedFromModel(char* pName); 64 | void MKShadow_Destroy(MKShadow*); 65 | void MKShadow_BeginScene(int); 66 | void MKShadow_CaptureZBuffer(void); 67 | void MKShadow_ClearBuffer(void); 68 | void MKShadow_BlitBuffer(int, int); 69 | 70 | #endif // COMMON_MKSHADOW 71 | -------------------------------------------------------------------------------- /include/common/QuatRotation.h: -------------------------------------------------------------------------------- 1 | #ifndef COMMON_QUATROTATION 2 | #define COMMON_QUATROTATION 3 | 4 | #include "common/Vector.h" 5 | 6 | struct AxisRotation { 7 | Vector rot; 8 | float unk10; 9 | }; 10 | 11 | struct QuatRotation { 12 | Vector quat; 13 | void ConvertRotation(AxisRotation* pRotation); 14 | void ConvertNormal(Vector* pNormal, float); 15 | void ConvertVector(Vector* pVector); 16 | void Multiply(QuatRotation* pQuaternion1, QuatRotation* pQuaternion2); 17 | 18 | void Multiply(QuatRotation* pOther) { 19 | Multiply(this, pOther); 20 | } 21 | 22 | float Dot(QuatRotation* pOther) { 23 | return quat.x * pOther->quat.x + quat.y * pOther->quat.y + 24 | quat.z * pOther->quat.z + quat.w * pOther->quat.w; 25 | } 26 | 27 | void Scale(QuatRotation* pOther, float scalar) { 28 | quat.x = scalar * pOther->quat.x; 29 | quat.y = scalar * pOther->quat.y; 30 | quat.z = scalar * pOther->quat.z; 31 | quat.w = scalar * pOther->quat.w; 32 | } 33 | 34 | void Scale(float scalar) { 35 | Scale(this, scalar); 36 | } 37 | 38 | void SetIdentity(void) { 39 | quat.x = quat.y = quat.z = 0.0f; 40 | quat.w = 1.0f; 41 | } 42 | }; 43 | 44 | #endif // COMMON_QUATROTATION 45 | -------------------------------------------------------------------------------- /include/common/Str.h: -------------------------------------------------------------------------------- 1 | #ifndef COMMON_STR 2 | #define COMMON_STR 3 | 4 | extern bool gAssertBool; 5 | extern char gNullStr[]; 6 | 7 | char* Str_Printf(char* fmt, ...); 8 | char* Str_CopyString(char* string, int len); 9 | char* Str_FindChar(char* str, int val); 10 | 11 | #define STR_BUFFER_SIZE 0x4000 12 | 13 | #endif // COMMON_STR 14 | -------------------------------------------------------------------------------- /include/common/Texture.h: -------------------------------------------------------------------------------- 1 | #ifndef COMMON_TEXTURE 2 | #define COMMON_TEXTURE 3 | 4 | #include "types.h" 5 | #include "common/Vector.h" 6 | #include "Dolphin/gx.h" 7 | 8 | extern Vector Texture_Color; 9 | extern bool Texture_bColourKey; 10 | extern int Texture_filterType; 11 | extern bool Texture_IsAlias; 12 | 13 | struct TexFile { 14 | int fmt; 15 | int width; 16 | int height; 17 | char padding[20]; 18 | u16 unk20; 19 | }; 20 | 21 | struct Texture { 22 | char name[0x20]; 23 | int width; 24 | int height; 25 | int referenceCount; 26 | bool bMpegTarget; // only set to true by CreateMpegTarget 27 | void* pYData; // Pointer to Y data of Video YUV data 28 | void* pUData; // Pointer to U data of Video YUV data 29 | void* pVData; // Pointer to V data of Video YUV data 30 | void* pFileData; 31 | bool bTlut; 32 | GXTexObj texObj; 33 | GXTlutObj tlutObj; 34 | int unk70; 35 | static bool initialised; 36 | 37 | static void InitModule(void); 38 | static void DeinitModule(void); 39 | static Texture* Create(char*); 40 | void Destroy(void); 41 | void Use(void); 42 | static Texture* Find(char*); 43 | static Texture* CreateRenderTarget(char*, int, int, int); 44 | static Texture* CreateFromRawData(char* pName, void* pRawData, int format, int width, int height); 45 | static Texture* CreateMpegTarget(char*, void*, int, int); 46 | }; 47 | 48 | #endif // COMMON_TEXTURE -------------------------------------------------------------------------------- /include/common/Timer.h: -------------------------------------------------------------------------------- 1 | #ifndef COMMON_TIMER 2 | #define COMMON_TIMER 3 | 4 | #include "types.h" 5 | 6 | #define MINUTES_TO_SECONDS 60 7 | #define HOURS_TO_SECONDS 3600 8 | #define DAYS_TO_SECONDS 86400 9 | #define MONTH_TO_SECONDS (30 * DAYS_TO_SECONDS) 10 | 11 | struct TimerInfo { 12 | int hours; 13 | int minutes; 14 | int seconds; 15 | int milliseconds; 16 | int day; 17 | int month; 18 | int year; 19 | }; 20 | 21 | void Timer_GetSystemTime(TimerInfo*); 22 | int Timer_GetDHMSInSeconds(TimerInfo*); 23 | void Timer_GetDifference(TimerInfo*, TimerInfo*, TimerInfo*); 24 | 25 | #endif // COMMON_TIMER 26 | -------------------------------------------------------------------------------- /include/common/Translation.h: -------------------------------------------------------------------------------- 1 | #ifndef COMMON_TRANSLATION 2 | #define COMMON_TRANSLATION 3 | 4 | struct Language { 5 | char* localName; 6 | char* languageName; 7 | char* languageCode; 8 | char* fileName; 9 | int size; 10 | }; 11 | 12 | enum TranslationLanguage { 13 | Language_NotSet = -1, 14 | LANGUAGE_ENGLISH = 0, 15 | Language_American = 1, 16 | Language_French = 2, 17 | Language_Spanish = 3, 18 | Language_German = 4, 19 | Language_Italian = 5, 20 | Language_Dutch = 6, 21 | LANGUAGE_NMBR_OF_LANGUAGES = 8, 22 | }; 23 | 24 | enum Translation_Platform { 25 | Platform_NotSet, 26 | Platform_PS2, 27 | Platform_GCN, 28 | Platform_XBOX 29 | }; 30 | 31 | void Translation_InitModule(void); 32 | void Translation_DeinitModule(void); 33 | TranslationLanguage Translation_GetLanguage(void); 34 | TranslationLanguage Translation_GetDefaultLanguage(void); 35 | void Translation_SetLanguage(TranslationLanguage language); 36 | bool Translation_IsLanguageAvailable(TranslationLanguage language); 37 | char* Translation_GetLanguageName(TranslationLanguage language); 38 | char* Translation_GetLanguageLocalName(TranslationLanguage language); 39 | char* Translation_GetLanguageCode(TranslationLanguage language); 40 | 41 | #define MAX_TRANSLATION_STRINGS (0x400) 42 | 43 | extern char* gpTranslation_StringArray[1025]; 44 | 45 | #endif // COMMON_TRANSLATION 46 | -------------------------------------------------------------------------------- /include/common/Translations.h: -------------------------------------------------------------------------------- 1 | #ifndef TRANSLATIONS_H 2 | #define TRANSLATIONS_H 3 | 4 | // Header file with string translation ids 5 | 6 | // TODO: Future work 7 | 8 | #define TEXT_TITLE (0) 9 | #define TEXT_COPYRIGHT (1) 10 | 11 | #define TEXT_LEVELS (2) 12 | #define TEXT_LEVEL_Z1 (TEXT_LEVELS + 0) // Rainbow Cliffs 13 | #define TEXT_LEVEL_Z2 (TEXT_LEVELS + 1) // Rainbow Cliffs 14 | #define TEXT_LEVEL_Z3 (TEXT_LEVELS + 2) 15 | #define TEXT_LEVEL_Z4 (TEXT_LEVELS + 3) 16 | 17 | #define TEXT_LEVEL_A1 (TEXT_LEVELS + 4) // Two Up 18 | #define TEXT_LEVEL_A2 (TEXT_LEVELS + 5) // Walk in the Park 19 | #define TEXT_LEVEL_A3 (TEXT_LEVELS + 6) // Ship Rex 20 | #define TEXT_LEVEL_A4 (TEXT_LEVELS + 7) // Bull's Pen 21 | 22 | #define TEXT_LEVEL_B1 (TEXT_LEVELS + 8) // Bridge on the River TY 23 | #define TEXT_LEVEL_B2 (TEXT_LEVELS + 9) // Snow Worries 24 | #define TEXT_LEVEL_B3 (TEXT_LEVELS + 10) // Outback Safari 25 | #define TEXT_LEVEL_B4 (TEXT_LEVELS + 11) 26 | 27 | #define TEXT_LEVEL_C1 (TEXT_LEVELS + 12) // Lyre, Lyre Pants on Fire 28 | #define TEXT_LEVEL_C2 (TEXT_LEVELS + 13) // Beyond the Black Stump 29 | #define TEXT_LEVEL_C3 (TEXT_LEVELS + 14) // Rex Marks The Spot 30 | #define TEXT_LEVEL_C4 (TEXT_LEVELS + 15) // Fluffy's Fjord 31 | 32 | // everything before here is correct in my msvc code 33 | #define TEXT_LEVEL_D1 (TEXT_LEVELS + 16) 34 | #define TEXT_LEVEL_D2 (TEXT_LEVELS + 17) // Cass' Crest 35 | #define TEXT_LEVEL_D3 (TEXT_LEVELS + 18) 36 | #define TEXT_LEVEL_D4 (TEXT_LEVELS + 19) // Crikey's Cove 37 | 38 | #define TEXT_LEVEL_E1 (TEXT_LEVELS + 20) // Cass' Pass 39 | #define TEXT_LEVEL_E2 (TEXT_LEVELS + 21) // Bonus World 40 | #define TEXT_LEVEL_E3 (TEXT_LEVELS + 22) // Bonus World 41 | #define TEXT_LEVEL_E4 (TEXT_LEVELS + 23) // Final Battle 42 | 43 | 44 | #endif // TRANSLATIONS_H 45 | -------------------------------------------------------------------------------- /include/common/Utils.h: -------------------------------------------------------------------------------- 1 | #ifndef COMMON_UTILS 2 | #define COMMON_UTILS 3 | 4 | #include "types.h" 5 | 6 | void* Util_BinarySearch(void* valueToFind, void* arr, int count, int elemSize, int (*compareFunc)(void*, void*)); 7 | bool Util_WildcardPatternMatch(char* str, char* pattern); 8 | 9 | #endif // COMMON_UTILS 10 | -------------------------------------------------------------------------------- /include/common/Video.h: -------------------------------------------------------------------------------- 1 | #ifndef COMMON_VIDEO 2 | #define COMMON_VIDEO 3 | 4 | #include "Dolphin/thp/THPPlayer.h" 5 | #include "common/Material.h" 6 | 7 | struct Video { 8 | bool bActive; 9 | void* pMem; 10 | THPVideoInfo videoInfo; 11 | THPAudioInfo audioInfo; 12 | Material* pVideoMat; 13 | }; 14 | 15 | void Video_InitModule(void); 16 | void Video_DeinitModule(void); 17 | Video* Video_CreateStreaming(char* pName, Material* pMaterial, bool, int track); 18 | bool Video_Update(Video* pVideo); 19 | void Video_Destroy(Video* pVideo); 20 | void Video_Draw(Video* pVideo, float z, float f2); 21 | 22 | #endif // COMMON_VIDEO 23 | -------------------------------------------------------------------------------- /include/common/Water_GC.h: -------------------------------------------------------------------------------- 1 | #ifndef COMMOM_WATERGC_H 2 | #define COMMOM_WATERGC_H 3 | 4 | #include "Dolphin/gx.h" 5 | 6 | #define WATER_TEX_WIDTH (0x20) 7 | #define WATER_TEX_HEIGHT (0x20) 8 | 9 | extern char waterIndTexData[WATER_TEX_HEIGHT][WATER_TEX_WIDTH]; // 2D array? 10 | extern GXTexObj waterIndTexObj; 11 | extern bool bWaterUpdate; 12 | 13 | void Water_InitModule(void); 14 | void Water_DeinitModule(void); 15 | void Water_Update(void); 16 | 17 | #endif // COMMOM_WATERGC_H 18 | -------------------------------------------------------------------------------- /include/common/demoinit.h: -------------------------------------------------------------------------------- 1 | #ifndef COMMON_DEMOINIT 2 | #define COMMON_DEMOINIT 3 | 4 | #include "Dolphin/gx.h" 5 | 6 | extern u32 gCPUCycles; 7 | extern u32 gGXCycles; 8 | 9 | extern "C" void DEMOInit(_GXRenderModeObj* prmodeObj); 10 | extern "C" void DEMOBeforeRender(void); 11 | extern "C" void DEMODoneRender(void); 12 | extern "C" GXRenderModeObj* DEMOGetRenderModeObj(void); 13 | extern "C" void* DEMOGetCurrentBuffer(void); 14 | 15 | #endif // COMMON_DEMOINIT 16 | -------------------------------------------------------------------------------- /include/common/system_extras.h: -------------------------------------------------------------------------------- 1 | #ifndef SYSTEMEXTRAS_H 2 | #define SYSTEMEXTRAS_H 3 | 4 | extern "C" int stricmp(char*, char*); 5 | extern "C" int strcmpi(char*, char*); 6 | extern "C" char* strlwr(char*); 7 | extern "C" char* strupr(char*); 8 | int strnicmp(const char* s1, const char* s2, int n); 9 | 10 | #endif // SYSTEMEXTRAS_H 11 | -------------------------------------------------------------------------------- /include/ty/AutoTargetStruct.h: -------------------------------------------------------------------------------- 1 | #ifndef AUTOTARGETSTRUCT_H 2 | #define AUTOTARGETSTRUCT_H 3 | 4 | #include "common/Model.h" 5 | #include "common/Vector.h" 6 | 7 | enum TargetPriority { 8 | TP_1 = 1, 9 | TP_3 = 3 10 | }; 11 | 12 | struct AutoTargetSubStruct { 13 | float unk0; 14 | Vector unk4; 15 | int unk14; 16 | }; 17 | 18 | struct AutoVisible { 19 | Vector* unk0[10]; 20 | float unk28[10]; 21 | int numItems; 22 | Vector unk54; 23 | 24 | void AddToList(Vector*, Model*); 25 | }; 26 | 27 | struct AutoTargetStruct { 28 | AutoTargetSubStruct unk0[3]; 29 | float unk48; 30 | float unk4C; 31 | float unk50; 32 | float unk54; 33 | float unk58; 34 | float unk5C; 35 | float unk60; 36 | Vector tyRot; 37 | AutoVisible unk74; 38 | AutoVisible unkD8; 39 | AutoVisible unk13C; 40 | Vector targetPos; 41 | Vector unk1B0; 42 | Vector unk1C0; 43 | Vector unk1D0; 44 | Model* unk1E0; 45 | Model* unk1E4; // targetedModel? 46 | Model* unk1E8; 47 | int unk1EC; 48 | int unk1F0; 49 | int targetPriority; // closestType? 50 | Vector unk1F8; 51 | int unk208; 52 | 53 | void Set(TargetPriority, Vector*, Vector*, Vector*, Model*); 54 | void SetNearestTargetEnemy(Vector*, Model*, Vector*); 55 | void Reset(void); 56 | 57 | void SetUnk208(int val) { 58 | unk208 = val; 59 | } 60 | 61 | Vector* GetTargetPos(void) { 62 | return unk1F0 ? &targetPos : NULL; 63 | } 64 | }; 65 | 66 | #endif // AUTOTARGETSTRUCT_H 67 | -------------------------------------------------------------------------------- /include/ty/BoundingRegion.h: -------------------------------------------------------------------------------- 1 | #ifndef BOUNDINGREGION_H 2 | #define BOUNDINGREGION_H 3 | 4 | #include "ty/Path.h" 5 | 6 | struct RectXZ { 7 | float minPoint[2]; 8 | float maxPoint[2]; 9 | }; 10 | 11 | struct BoundingRegion { 12 | PathSegment* pPath; 13 | RectXZ rect; 14 | 15 | void Init(PathSegment*); 16 | bool IsPointWithin(Vector*); 17 | bool IsPointInBoundaryRect(Vector*); 18 | bool ArePointsWithinAndAdjacent(Vector*, Vector*); 19 | bool setPolyBoundingRect(RectXZ*, PathSegment*); // return is never used? 20 | int getIntersectCount(Vector*, Vector*); 21 | bool isIntersect(Vector*, Vector*, Vector*, Vector*); 22 | bool isCounterClockWise(Vector*, Vector*, Vector*); 23 | }; 24 | 25 | #endif // BOUNDINGREGION_H 26 | -------------------------------------------------------------------------------- /include/ty/ExtendedAnalogControl.h: -------------------------------------------------------------------------------- 1 | #ifndef EXTENDEDANALOGCONTROL_H 2 | #define EXTENDEDANALOGCONTROL_H 3 | 4 | #include "types.h" 5 | 6 | struct ExtendedAnalogControl { 7 | float unk0; // normalized 8 | float unk4; // normalized 9 | 10 | float unk8; 11 | 12 | float unkC; 13 | float unk10; 14 | 15 | float magnitude; 16 | 17 | float unk18; 18 | float unk1C; 19 | 20 | float unk20; 21 | float unk24; 22 | 23 | float unk28; 24 | float magnitudeDifference; 25 | 26 | void Init(float, float); 27 | void Update(float, float); 28 | void Draw(void); 29 | 30 | void Reset(void) { 31 | unk18 = unk1C = 0.0f; 32 | unk28 = magnitudeDifference = 0.0f; 33 | unk10 = magnitude = 0.0f; 34 | unk0 = unk4 = unk8 = unkC = 0.0f; 35 | } 36 | }; 37 | 38 | #endif // EXTENDEDANALOGCONTROL_H 39 | -------------------------------------------------------------------------------- /include/ty/FinishLine.h: -------------------------------------------------------------------------------- 1 | #ifndef FINISHLINE_H 2 | #define FINISHLINE_H 3 | 4 | #include "ty/GameObject.h" 5 | #include "common/MKAnimScript.h" 6 | 7 | void FinishLine_Show(void); 8 | void FinishLine_Hide(void); 9 | bool FinishLine_IsCrossedBy(Vector*); 10 | 11 | enum FinishLineState { 12 | FLS_0 = 0, 13 | FLS_1 = 1, 14 | FLS_2 = 2, 15 | }; 16 | 17 | /// @brief Finish Line object in Time Attacks 18 | struct FinishLineStruct : GameObject { 19 | bool bOn; 20 | FinishLineState state; 21 | char padding[8]; 22 | MKAnimScript animScript; 23 | Matrix mtx; 24 | Vector scale; 25 | bool unkBC; 26 | 27 | void Idle(void); 28 | void PostFinish(void); 29 | void SetState(FinishLineState); 30 | bool IsCrossedBy(Vector*); 31 | 32 | virtual void Init(GameObjDesc* pDesc); 33 | virtual void Deinit(void); 34 | virtual bool LoadLine(KromeIniLine* pLine); 35 | virtual void LoadDone(void); 36 | virtual void Update(void); 37 | virtual void Draw(void); 38 | virtual void Reset(void); 39 | virtual void Message(MKMessage* pMsg); 40 | }; 41 | 42 | #endif // FINISHLINE_H 43 | -------------------------------------------------------------------------------- /include/ty/GameObjectManager.h: -------------------------------------------------------------------------------- 1 | #ifndef GAMEOBJECTMANAGER_H 2 | #define GAMEOBJECTMANAGER_H 3 | 4 | #include "common/MKSceneManager.h" 5 | #include "ty/GameObject.h" 6 | 7 | struct GameObjectManager { 8 | GameObjDesc* pDescs; 9 | bool bLevelInitialised; 10 | void* pObjectMem; 11 | int objectMemSize; 12 | 13 | void Init(void); 14 | void Deinit(void); 15 | void InitLevel(void); 16 | void DeinitLevel(void); 17 | void LoadLevel(KromeIni*); 18 | void AddObject(GameObject*, Matrix*, BoundingVolume*); 19 | void AddObject(GameObject*, Model*); 20 | void RemoveObject(GameObject*); 21 | void UpdateModules(void); 22 | void DrawModules(void); 23 | void SendMessage(MKMessage*, uint, Vector*, float, bool); 24 | void SendMessageToAll(MKMessage* pMsg, int mask); 25 | GameObject* GetObjectFromID(uint id); 26 | void AddDescriptor(GameObjDesc*); 27 | GameObjDesc* FindDescriptor(char*); 28 | int GetObjectsInRange(GameObject** pObjects, int maxCount, Vector* pPt, float radius, int searchMask); 29 | GameObject* GetClosestObjectInRange(Vector* pPt, float radius, int searchMask); 30 | DescriptorIterator Begin(void); 31 | int CountEntities(KromeIni*, KromeIniLine*); 32 | }; 33 | 34 | extern GameObjectManager objectManager; 35 | 36 | #endif // GAMEOBJECTMANAGER_H 37 | -------------------------------------------------------------------------------- /include/ty/GuideParticle.h: -------------------------------------------------------------------------------- 1 | #ifndef GUIDEPARTICLE_H 2 | #define GUIDEPARTICLE_H 3 | 4 | #include "ty/GameObject.h" 5 | 6 | void GuideParticle_LoadResources(KromeIni* pIni); 7 | void GuideParticle_Show(void); 8 | void GuideParticle_Hide(void); 9 | bool GuideParticle_HasPassedThoughAll(void); 10 | 11 | /// @brief Time attack ring object 12 | struct GuideParticle : GameObject { 13 | float unk3C; 14 | Matrix unk40; 15 | int gateOrderIndex; 16 | int unk84; 17 | 18 | int unk88; 19 | 20 | static int gateTimeOutCounter; 21 | 22 | virtual void Init(GameObjDesc* pDesc); 23 | virtual void Deinit(void); 24 | virtual bool LoadLine(KromeIniLine* pLine); 25 | virtual void LoadDone(void); 26 | virtual void Reset(void); 27 | virtual void Update(void); 28 | virtual void Draw(void); 29 | 30 | static void UpdateModule(void); 31 | }; 32 | 33 | #endif // GUIDEPARTICLE_H 34 | -------------------------------------------------------------------------------- /include/ty/Hero.h: -------------------------------------------------------------------------------- 1 | #ifndef HERO_H 2 | #define HERO_H 3 | 4 | #include "ty/GameObject.h" 5 | #include "ty/Shadow.h" 6 | #include "ty/effects/RainbowEffect.h" 7 | #include "ty/TyHealth.h" 8 | 9 | // Hero might be at least 0x104 bytes long as Ty and Bushpig both have a 10 | // CheckpointStruct pointer at 0x100 11 | 12 | struct SpecialPickupStruct; 13 | struct CheckpointStruct; 14 | struct WakeStruct; 15 | 16 | struct OpalMagnetData { 17 | char padding[0x3C]; 18 | 19 | void Init(void); 20 | void Deinit(void); 21 | void Reset(void); 22 | void Draw(void); 23 | void Activate(void); 24 | bool IsActive(void); 25 | }; 26 | 27 | struct GlowParticleData { 28 | char padding[0x44]; 29 | }; 30 | 31 | struct TySounds { 32 | char padding[0xA4]; 33 | }; 34 | 35 | // Made up enum for type 36 | enum HeroType { 37 | HERO_TY = 0, 38 | HERO_BUSHPIG = 1 39 | }; 40 | 41 | struct Hero : GameObject { 42 | Model* pReflectionModel; 43 | Vector pos; 44 | Vector lastPos; // last safe position 45 | // fixed velocity vector 46 | // velocity vector which points towards where ty will go when on contact with collision 47 | Vector velocity; 48 | Vector diveVec; 49 | Shadow shadow; 50 | CheckpointStruct* pLastCheckPoint; 51 | float radius; 52 | float objectRadiusAdjustment; 53 | HeroType mType; 54 | WakeStruct* pWake; 55 | int unkE8; 56 | RainbowEffect rainbowEffect; 57 | int invicibilityFrames; 58 | TyHealth tyHealth; 59 | OpalMagnetData opalMagnetData; 60 | GlowParticleData glowParticleData; 61 | TySounds tySounds; 62 | 63 | virtual bool IsBiting(void) = 0; 64 | virtual bool InWater(void) = 0; 65 | virtual bool IsClaiming(void) = 0; 66 | virtual void SetFindItem(Vector*, SpecialPickupStruct*) = 0; 67 | 68 | bool IsTy(void) { 69 | return mType == HERO_TY; 70 | } 71 | 72 | bool IsBushPig(void) { 73 | return mType == HERO_BUSHPIG; 74 | } 75 | }; 76 | 77 | extern Hero* pHero; 78 | 79 | #endif // HERO_H 80 | -------------------------------------------------------------------------------- /include/ty/Kinematics.h: -------------------------------------------------------------------------------- 1 | #ifndef KINEMATICS_H 2 | #define KINEMATICS_H 3 | 4 | float Kin_GetInitialVelocity(float*, float*, float*, float*); 5 | float Kin_GetDiscreteDistance(float*, float*, float*, float*); 6 | float Kin_GetDiscreteInitialVelocity(float*, float*, float*, float*); 7 | float Kin_GetDiscreteFinalVelocity(float*, float*, float*, float*); 8 | float Kin_GetDiscreteAcceleration(float*, float*, float*, float*); 9 | 10 | #endif // KINEMATICS_H 11 | -------------------------------------------------------------------------------- /include/ty/LensFlare.h: -------------------------------------------------------------------------------- 1 | #ifndef LENSFLARE_H 2 | #define LENSFLARE_H 3 | 4 | void LensFlare_Init(void); 5 | void LensFlare_Deinit(void); 6 | void LensFlare_Update(void); 7 | void LensFlare_Draw(void); 8 | 9 | #endif // LENSFLARE_H 10 | -------------------------------------------------------------------------------- /include/ty/LevelObjective.h: -------------------------------------------------------------------------------- 1 | #ifndef LEVELOBJECTIVE_H 2 | #define LEVELOBJECTIVE_H 3 | 4 | #include "ty/GameObject.h" 5 | #include "ty/Messages.h" 6 | 7 | struct LevelObjective : GameObject { 8 | EventMessage OnSuccess; 9 | EventMessage OnFailure; 10 | EventMessage OnIncrement; 11 | EventMessage OnStart; 12 | EventMessage OnAbort; 13 | bool bActive; 14 | bool bComplete; 15 | short unk66; 16 | short unk68; 17 | short unk6A; 18 | char* pMatName; 19 | Material* pMaterial; 20 | Vector pos; 21 | bool unk84; 22 | 23 | virtual bool LoadLine(KromeIniLine* pLine); 24 | virtual void LoadDone(void); 25 | virtual void Reset(void); 26 | virtual void Message(MKMessage* pMsg); 27 | virtual void Init(GameObjDesc* pDesc); 28 | virtual void Deinit(void); 29 | virtual void Failure(void); 30 | virtual void Success(void); 31 | virtual void Increment(void); 32 | virtual void Abort(void); 33 | virtual void Activate(void); 34 | virtual void Deactivate(void); 35 | 36 | static bool GetStatus(short*, short*, Material**, bool); 37 | 38 | static LevelObjective* pCurObjective; 39 | }; 40 | 41 | #endif // LEVELOBJECTIVE_H 42 | -------------------------------------------------------------------------------- /include/ty/LineOfSight.h: -------------------------------------------------------------------------------- 1 | #ifndef LINEOFSIGHT_H 2 | #define LINEOFSIGHT_H 3 | 4 | #include "types.h" 5 | #include "common/Vector.h" 6 | 7 | extern float ApproxMag(Vector*, Vector*); // should be in Tools.h? 8 | 9 | struct LineOfSightObject { 10 | u8 flags; 11 | int unk4; // this needs to be set manually by the caller of Update to reset? 12 | float length; // Length of direction vector (target - source).length() 13 | float unkC; 14 | float radius; 15 | float unk14; 16 | float fovRatio; // Must be within [-1.0f, 1.0f] 17 | float normalizedYDir; // (target.y - source.y) / length(target - source) 18 | float unk20; 19 | Vector startPos; 20 | Vector rotation; 21 | Vector targetPos; 22 | // horizontal direction between targetPos and startPos 23 | // calculated by (targetPos - startPos).Normalise() 24 | Vector horizDir; // y element should be set to 0.0f 25 | int unk64; 26 | float maxRayMag; 27 | float unk6C; 28 | float unk70; 29 | float unk74; 30 | void Init(u8, float, float, float, float, float, float, float); 31 | bool Update(Vector* pStartPos, Vector* pTargetPos, Vector* pRotation); 32 | bool OutsideGOV(void); 33 | void Reset(Vector* pStartPos, Vector* pTargetPos, Vector* pRotation); // maybe declared within the header? 34 | }; 35 | 36 | #endif // LINEOFSIGHT_H 37 | -------------------------------------------------------------------------------- /include/ty/MessageIds.h: -------------------------------------------------------------------------------- 1 | #ifndef MESSAGEIDS_H 2 | #define MESSAGEIDS_H 3 | 4 | enum MESSAGE_ID { 5 | MSG_Resolve = 1, 6 | 7 | MSG_UNK_2 = 2, // Start? Think this may be a GOMSG, GOMSG_Start? 8 | 9 | // Platform attachment related messages 10 | MSG_UpdateAttachment = 3, 11 | MSG_AttachObject = 4, 12 | MSG_DetachObject = 5, 13 | 14 | MSG_UNK_6 = 6, 15 | MSG_UNK_7 = 7, 16 | 17 | MSG_BoomerangMsg = 8, 18 | MSG_ExplosionMsg = 9, 19 | 20 | // GOMSG_Last = 10, 21 | 22 | // Activate/Deactivate message ids 23 | MSG_Activate = 10, 24 | MSG_Deactivate = 11, 25 | 26 | // Enable/Disable message ids 27 | MSG_Enable = 12, 28 | MSG_Disable = 13, 29 | 30 | // Visibility message ids 31 | MSG_Show = 14, 32 | MSG_Hide = 15, 33 | 34 | MSG_UNK_16 = 16, 35 | MSG_UNK_17 = 17, 36 | MSG_UNK_18 = 18, 37 | MSG_UNK_19 = 19, 38 | 39 | MSG_UNK_20 = 20, 40 | 41 | MSG_ObjectiveIncrement = 22, 42 | 43 | MSG_GotBothRangs = 25, 44 | 45 | // Weather? 46 | MSG_UNK_26 = 26, 47 | MSG_UNK_27 = 27, 48 | MSG_UNK_28 = 28, 49 | MSG_UNK_29 = 29, 50 | MSG_UNK_30 = 30, 51 | MSG_UNK_31 = 31, 52 | 53 | MSG_Abort = 48, 54 | }; 55 | 56 | #endif // MESSAGEIDS_H 57 | -------------------------------------------------------------------------------- /include/ty/MessageMap.h: -------------------------------------------------------------------------------- 1 | #ifndef MESSAGEMAP_H 2 | #define MESSAGEMAP_H 3 | 4 | // figure out names 5 | struct MessageMap { 6 | int ids; 7 | int nmbrOfMessages; 8 | char** ppMessages; 9 | int GetIdFromString(char* pString) const; 10 | char* GetStringFromId(int) const; // Unused / Stripped 11 | }; 12 | 13 | #endif // MESSAGEMAP_H 14 | -------------------------------------------------------------------------------- /include/ty/Messages.h: -------------------------------------------------------------------------------- 1 | #ifndef MESSAGES_H 2 | #define MESSAGES_H 3 | 4 | #include "ty/GameObject.h" 5 | 6 | struct EventMessage { 7 | union { 8 | GameObject* pTargetObj; 9 | int targetId; // this is used initially and then never used once the message has been resolved 10 | }; 11 | int message; 12 | 13 | void Init(void); 14 | bool LoadLine(KromeIniLine*, const char*); 15 | void Resolve(void); 16 | void Send(void); 17 | }; 18 | 19 | #endif // MESSAGES_H 20 | -------------------------------------------------------------------------------- /include/ty/Mist.h: -------------------------------------------------------------------------------- 1 | #ifndef MIST_H 2 | #define MIST_H 3 | 4 | void Mist_Init(void); 5 | void Mist_Deinit(void); 6 | void Mist_Update(void); 7 | void Mist_Draw(void); 8 | 9 | #endif // MIST_H 10 | -------------------------------------------------------------------------------- /include/ty/NodeOverride.h: -------------------------------------------------------------------------------- 1 | #ifndef NODEOVERRIDE_H 2 | #define NODEOVERRIDE_H 3 | 4 | #include "common/Animation.h" 5 | #include "common/Model.h" 6 | #include "common/Matrix.h" 7 | 8 | struct NodeOverride { 9 | // these could be int bitfields 10 | u8 b1 : 1; 11 | u8 b0 : 1; 12 | 13 | Vector unk4; 14 | Vector unk14; 15 | float unk24; 16 | float unk28; 17 | int nodeNr; 18 | Animation* pAnimation; 19 | Matrix* pLocalToWorldMatrix; 20 | Model* pModel; 21 | float unk3C; 22 | int state; 23 | int unk44; 24 | void (*HeadTurningCallback)(void); 25 | }; 26 | 27 | void NodeOverride_Init(NodeOverride* pNodeOverride, Animation* pAnimation, Matrix* pLocalToWorldMatrix, int nodeNr); 28 | void NodeOverride_SetTarget(NodeOverride* pNodeOverride, Vector* pVec, Model* pModel); 29 | void NodeOverride_Update(NodeOverride* pNodeOverride); 30 | 31 | #endif // NODEOVERRIDE_H 32 | -------------------------------------------------------------------------------- /include/ty/Quadratic.h: -------------------------------------------------------------------------------- 1 | #ifndef QUADRATIC_H 2 | #define QUADRATIC_H 3 | 4 | #include "common/Vector.h" 5 | 6 | // represents a 3D quadratic equation ax^2 + bx + c 7 | struct Quadratic { 8 | Vector pos; 9 | Vector coeffsX; // X coefficients 10 | Vector coeffsY; // Y coefficients 11 | Vector coeffsZ; // Z coefficients 12 | 13 | float GetClosestTime(Vector* pPoint); 14 | void Init(void); 15 | void SetPoints(Vector*, Vector*, Vector*); 16 | void Update(float t) { 17 | float t2 = t * t; 18 | pos.x = (coeffsX.x * t2) + (coeffsX.y * t) + coeffsX.z; 19 | pos.y = (coeffsY.x * t2) + (coeffsY.y * t) + coeffsY.z; 20 | pos.z = (coeffsZ.x * t2) + (coeffsZ.y * t) + coeffsZ.z; 21 | } 22 | }; 23 | 24 | #endif // QUADRATIC_H 25 | -------------------------------------------------------------------------------- /include/ty/RangeCheck.h: -------------------------------------------------------------------------------- 1 | #ifndef RANGECHECK_H 2 | #define RANGECHECK_H 3 | 4 | #include "common/Model.h" 5 | #include "common/KromeIni.h" 6 | 7 | #define LODFlags_Alpha 1 8 | #define LODFlags_CameraFade 2 9 | #define LODFlags_Scissor 4 10 | #define LODFlags_AlphaProp 8 11 | 12 | void LOD_Deinit(void); 13 | int Range_WhichZone(Vector* point, float*); 14 | bool Range_IsVisible(Vector*); 15 | void Range_ModelSetAlpha(Model*, int, float, float, float, float, int); 16 | void Range_Update(void); 17 | 18 | struct LODEntry { 19 | char name[0x20]; 20 | int subObjectFlags; 21 | int subObjectIndex; 22 | int unk28; 23 | 24 | void Init(Model*); 25 | bool CheckFlags(int); 26 | }; 27 | 28 | struct LODDescriptor { 29 | int flags; 30 | LODEntry* pEntries; 31 | int nmbrOfEntries; 32 | int shadowFlags; 33 | int particleFlags; 34 | int soundFlags; 35 | int scissorFlags; 36 | float radius; 37 | float height; 38 | int invisibleZone; 39 | float minalpha; 40 | float maxScissorDist; 41 | 42 | void Init(KromeIni*, char*); 43 | void ParseIni(KromeIni*, KromeIniLine*); 44 | LODEntry* GetEntryFromString(char* name); 45 | void ResolveSubObjects(Model*); 46 | void ReplicateLODData(int, int); 47 | }; 48 | 49 | struct LODManager { 50 | LODDescriptor* pDescriptor; 51 | int subobjectEnableFlags; 52 | int unk8; 53 | 54 | void Init(Model*, int, LODDescriptor*); 55 | void InternalUpdate(Model*, int, float); 56 | bool Draw(Model*, int, float, float, bool); 57 | void EnableSubObjects(Model*); 58 | 59 | bool TestLOD(int testFlag) { 60 | return testFlag & ((subobjectEnableFlags >= 0) ? (1 << subobjectEnableFlags) : 0x40000000); 61 | } 62 | }; 63 | 64 | #endif // RANGECHECK_H 65 | -------------------------------------------------------------------------------- /include/ty/RenderTexture.h: -------------------------------------------------------------------------------- 1 | #ifndef RENDERTEXTURE_H 2 | #define RENDERTEXTURE_H 3 | 4 | #include "common/View.h" 5 | #include "common/KromeIni.h" 6 | 7 | struct RenderTexture { 8 | Material* pRenderMat; 9 | View mView; 10 | int OverlayStage; 11 | bool bHasRenderTarget; 12 | 13 | void Deinit(void); 14 | void LoadLine(KromeIniLine* pLine); 15 | 16 | virtual void Render(void) = 0; 17 | }; 18 | 19 | struct WaterSlideEffect : RenderTexture { 20 | Material* pUnderlay; 21 | Material* pOverlay; 22 | 23 | void Deinit(void); 24 | void LoadLine(KromeIniLine* pLine); 25 | void Update(void); 26 | 27 | virtual void Render(void); 28 | }; 29 | 30 | struct CausticEffect : RenderTexture { 31 | float unkData[3]; 32 | Material* pMat; 33 | 34 | void Deinit(void); 35 | void LoadLine(KromeIniLine* pLine); 36 | void LoadDone(void); 37 | void Update(void); 38 | 39 | virtual void Render(void); 40 | }; 41 | 42 | struct LavaEffect : RenderTexture { 43 | Material* pMaterials[3]; 44 | 45 | void Deinit(void); 46 | void LoadLine(KromeIniLine* pLine); 47 | void Update(void); 48 | 49 | virtual void Render(void); 50 | }; 51 | 52 | void RenderTexture_LoadResources(void); 53 | void RenderTexture_Init(void); 54 | void RenderTexture_Deinit(void); 55 | 56 | void RenderTexture_ResetWaterBlendValues(void); 57 | 58 | void RenderTexture_RenderWater(void); 59 | 60 | void RenderTexture_SetWaterLow(char*, float height); 61 | void RenderTexture_SetWaterHigh(char*, float height); 62 | void RenderTexture_SetWaterOutput(char* pOutputName); 63 | 64 | void RenderTexture_WaterSlideLine(KromeIniLine*); 65 | void RenderTexture_WaterSlideEnd(void); 66 | 67 | void RenderTexture_CausticsLine(KromeIniLine*); 68 | void RenderTexture_CausticsEnd(void); 69 | 70 | void RenderTexture_LavaLine(KromeIniLine*); 71 | void RenderTexture_LavaEnd(void); 72 | 73 | void RenderTexture_RenderForOverlay(int); 74 | void RenderTexture_ResetVRam(void); 75 | 76 | 77 | #endif // RENDERTEXTURE_H 78 | -------------------------------------------------------------------------------- /include/ty/Script.h: -------------------------------------------------------------------------------- 1 | #ifndef SCRIPT_H 2 | #define SCRIPT_H 3 | 4 | #include "ty/GameObject.h" 5 | #include "ty/Messages.h" 6 | 7 | #define MessageCount 10 8 | 9 | struct ScriptProp : GameObject { 10 | virtual bool LoadLine(KromeIniLine*); 11 | virtual void LoadDone(void); 12 | virtual void Reset(void); 13 | virtual void Update(void); 14 | virtual void Message(MKMessage*); 15 | virtual void Init(GameObjDesc*); 16 | void Execute(void); 17 | 18 | float Delay; 19 | float unk40; 20 | bool bActive; 21 | bool bDelayEachMessage; 22 | bool bEnabled; 23 | bool bDefaultEnabled; // Default Enable/Disable setting used when prop is reset 24 | char currentMessageIndex; 25 | EventMessage messages[MessageCount]; 26 | // size 0x9C 27 | }; 28 | 29 | struct ConditionalScriptProp : ScriptProp { 30 | virtual bool LoadLine(KromeIniLine*); 31 | virtual void Message(MKMessage*); 32 | virtual void Init(GameObjDesc*); 33 | bool CheckConditions(void); 34 | 35 | int condition; 36 | bool bExecuteOnStart; 37 | bool bNegative; 38 | // size 0xA4 39 | }; 40 | 41 | #define Conditon_LearntToSwim (0) 42 | #define Conditon_HasBothRangs (1) 43 | #define Conditon_GameComplete (9) 44 | #define Conditon_GotAquarang (10) 45 | #define Conditon_DefaultTrue (16) 46 | 47 | #endif // SCRIPT_H 48 | -------------------------------------------------------------------------------- /include/ty/Shadow.h: -------------------------------------------------------------------------------- 1 | #ifndef SHADOW_H 2 | #define SHADOW_H 3 | 4 | #include "common/MKShadow.h" 5 | #include "ty/StructList.h" 6 | #include "common/Model.h" 7 | #include "common/Blitter.h" 8 | 9 | void Shadow_Init(void); 10 | void Shadow_Deinit(void); 11 | 12 | void Shadow_DrawAnimatingShadows(void); 13 | 14 | void Shadow_BeginDraw(void); 15 | void Shadow_EndDraw(void); 16 | 17 | struct Shadow { 18 | Model* pModel; 19 | 20 | float unk4; 21 | float unk8; 22 | float unkC; 23 | Vector unk10; 24 | Vector unk20; 25 | 26 | MKShadow* pMKShadow; 27 | 28 | bool bDraw; 29 | bool unk35; 30 | 31 | float unk38; 32 | float unk3C; 33 | float unk40; 34 | 35 | Vector mLightPos; 36 | 37 | void Init(char*, Model* pShadowModel, float, Vector*); 38 | void Deinit(void); 39 | 40 | void AddAnimatingShadow(char*, Model*, float, Vector*); 41 | 42 | void GetLightPos(Vector* pLightPos); 43 | 44 | void Draw(void); 45 | void Draw(Vector*, bool); 46 | 47 | bool CheckForShadowShift(float, Vector*, float, Vector*); 48 | }; 49 | 50 | struct DropShadow { 51 | Matrix mMatrix; 52 | Blitter_TriStrip mStrips[4]; 53 | 54 | void Init(Vector*, Vector*, Vector*, Vector*, float, bool); 55 | 56 | void SetRadius(float); 57 | void SetColor(Vector*); 58 | 59 | void Draw(void); 60 | }; 61 | 62 | #endif // SHADOW_H 63 | -------------------------------------------------------------------------------- /include/ty/SignPost.h: -------------------------------------------------------------------------------- 1 | #ifndef SIGNPOST_H 2 | #define SIGNPOST_H 3 | 4 | #include "ty/props/StaticProp.h" 5 | #include "common/MKAnimScript.h" 6 | 7 | struct DetourData { 8 | MKAnimScript anim; 9 | char padding[0x8]; 10 | }; 11 | 12 | extern DetourData detourData; 13 | 14 | void SignPost_LoadResources(KromeIni* pIni); 15 | void SignPost_HideAll(void); 16 | void SignPost_ShowAll(void); 17 | 18 | // May not have been an enum 19 | enum SignPostType { 20 | SP_TYPE_0 = 0, 21 | SP_TYPE_1 = 1, 22 | SP_DETOUR = 2, 23 | SP_CONSTRUCTION = 3, 24 | SP_DIRECTION2 = 4, 25 | SP_DIRECTION = 5, 26 | SP_BILLBOARD = 6 27 | }; 28 | 29 | struct SignPostDesc : StaticPropDescriptor { 30 | SignPostType type; 31 | }; 32 | 33 | enum SignPostState { 34 | SPS_0 = 0, 35 | SPS_1 = 1, 36 | SPS_2 = 2, 37 | }; 38 | 39 | struct SignPost : StaticProp { 40 | Vector mRot; // Current rotation 41 | Vector mDefaultRot; // Default Rotation 42 | int light1_index; 43 | int light2_index; 44 | int mRotSetting; 45 | int unk84; 46 | int unk88; 47 | int unk8C; 48 | float mRotInc; 49 | bool unk94; 50 | bool unk95; 51 | SignPostState mState; 52 | Vector centrePos; 53 | 54 | virtual void LoadDone(void); 55 | virtual void Reset(void); 56 | virtual void Update(void); 57 | virtual void Draw(void); 58 | virtual void Message(MKMessage* pMsg); 59 | virtual void Init(GameObjDesc* pDesc); 60 | 61 | void Idle(void); 62 | void Hit(void); 63 | 64 | void CheckForHit(void); 65 | 66 | void SetState(SignPostState); 67 | 68 | SignPostDesc* GetDesc(void) { 69 | return descr_cast(pDescriptor); 70 | } 71 | }; 72 | 73 | struct TaSignPost : SignPost { 74 | virtual void LoadDone(void); 75 | virtual void Reset(void); 76 | virtual void Update(void); 77 | virtual void Draw(void); 78 | }; 79 | 80 | #endif // SIGNPOST_H 81 | -------------------------------------------------------------------------------- /include/ty/Spline.h: -------------------------------------------------------------------------------- 1 | #ifndef SPLINE_H 2 | #define SPLINE_H 3 | 4 | #include "common/Vector.h" 5 | #include "common/Matrix.h" 6 | 7 | Vector Spline_GetPosition(Vector*, Vector*, Vector*, Vector*, float); 8 | Vector Spline_GetVelocity(Vector*, Vector*, Vector*, Vector*, float); 9 | 10 | // Related: 11 | // https://decomp.me/scratch/PbMFN 12 | // https://decomp.me/scratch/4PTkP 13 | 14 | struct SplinePoint { 15 | Vector mPos; 16 | Vector unk10; 17 | }; 18 | 19 | struct Spline { 20 | int mNumPoints; // Maximum number of points 21 | int nodeIndex; // Current Node Index 22 | SplinePoint* mpPoints; 23 | bool unkC; // seems to relate to normalizing? 24 | 25 | void Init(int numPoints, bool); 26 | void Reset(void); 27 | bool AddNode(Vector* pVec); 28 | Vector GetPosition(float time); 29 | Vector GetVelocity(float time); 30 | void Deinit(void); 31 | bool MergeEnds(void); 32 | void Smooth(void); 33 | }; 34 | 35 | struct UniformSplinePoint { 36 | Vector mPos; 37 | Vector unk10; 38 | float unk20; 39 | }; 40 | 41 | struct UniformSpline { 42 | int mNumPoints; 43 | int nodeIndex; 44 | float unk8; 45 | UniformSplinePoint* mpPoints; 46 | bool unk10; // seems to relate to normalizing? 47 | 48 | void Init(int numPoints, bool); 49 | void Reset(void); 50 | bool AddNode(Vector*); 51 | Vector GetPosition(float time); 52 | Vector GetVelocity(float time); 53 | void Deinit(void); 54 | bool MergeEnds(void); 55 | void RegulateSpeed(void); 56 | }; 57 | 58 | #endif // SPLINE_H 59 | -------------------------------------------------------------------------------- /include/ty/Torch.h: -------------------------------------------------------------------------------- 1 | #ifndef TORCH_H 2 | #define TORCH_H 3 | 4 | #include "ty/props/StaticProp.h" 5 | #include "ty/WobbleTexture.h" 6 | #include "ty/soundbank.h" 7 | #include "ty/heatflare.h" 8 | 9 | struct ParticleSystem; 10 | 11 | extern int pTorchPlayingSFX; 12 | 13 | void Torch_LoadResources(KromeIni* pIni); 14 | 15 | enum TorchState { 16 | TORCH_IDLE = 1, 17 | TORCH_HIT = 2 18 | }; 19 | 20 | enum TorchRotationSpeed {}; 21 | 22 | struct Torch : StaticProp { 23 | virtual void Init(GameObjDesc* pDesc); 24 | virtual void LoadDone(void); 25 | virtual void Deinit(void); 26 | virtual void Reset(void); 27 | virtual void Update(void); 28 | virtual void Draw(void); 29 | virtual void Message(MKMessage*); 30 | 31 | void Idle(void); 32 | void Hit(void); 33 | void SetState(TorchState, int); 34 | void EmitFire(void); 35 | void UpdateShadow(void); 36 | void CheckForHit(void); 37 | 38 | Vector mRot; 39 | Vector mDefaultRot; 40 | Vector mDefaultScale; // X component is used for flames 41 | Vector mFlamePos; // Flame Position 42 | float mRotInc; // How much rotation is updated by 43 | float mFloorY; // not exactly? 44 | float mCeilingY; // not exactly? 45 | float mWaterY; // Water Y position below the Torch 46 | float unkA8; 47 | int unkAC; 48 | int unkB0; 49 | int mFrozenTimer; 50 | int mFlameRefIndex; 51 | SoundEventHelper mSoundHelper; 52 | int mRotSpeedSetting; // Setting to determine how fast/slow the rotation should change 53 | bool bEmitFire; // shadow/sound related?? 54 | bool bFoundWater; 55 | TorchState mState; 56 | int unkCC; // Unset field!! 57 | HeatFlareInfo* pHeatFlare; 58 | ParticleSystem* mpParticleSys0; 59 | ParticleSystem* mpParticleSys1; 60 | int unkDC; 61 | Material* mpWobbleTexMat; 62 | WobbleTexture mWobbleTex; 63 | Vector mLightCol; 64 | float unk10C; 65 | bool bEmitFire2; // Not sure why this is used? 66 | }; 67 | 68 | #endif // TORCH_H 69 | -------------------------------------------------------------------------------- /include/ty/TyHealth.h: -------------------------------------------------------------------------------- 1 | #ifndef TYHEALTH_H 2 | #define TYHEALTH_H 3 | 4 | #include "common/Vector.h" 5 | 6 | enum TyHealthType { 7 | 8 | }; 9 | 10 | enum HurtType { 11 | HURT_TYPE_5 = 5 12 | }; 13 | 14 | struct HealthInfo { 15 | char padding[0x24]; 16 | }; 17 | 18 | struct TyHealth { 19 | char padding[0x24]; 20 | 21 | void Init(TyHealthType); 22 | void Deinit(void); 23 | bool Hurt(HurtType); 24 | void Gain(int); 25 | void SetHealthType(TyHealthType); 26 | void SetNumSymbols(int); 27 | void DrawLooseFX(Vector); 28 | void DrawHudElement(Vector); 29 | void DoLoseFX(void); 30 | 31 | static HealthInfo heathInfo[3]; 32 | }; 33 | 34 | #endif // TYHEALTH_H 35 | -------------------------------------------------------------------------------- /include/ty/WobbleTexture.h: -------------------------------------------------------------------------------- 1 | #ifndef WOBBLETEXURE_H 2 | #define WOBBLETEXURE_H 3 | 4 | #include "common/Vector.h" 5 | #include "common/Material.h" 6 | #include "common/Blitter.h" 7 | 8 | struct WobbleEntry { 9 | Vector mPos; 10 | char padding_0x10[0x20]; 11 | float unk30; 12 | float unk34; 13 | Vector mColor; 14 | float unk48; 15 | float unk4C; 16 | }; 17 | 18 | struct WobbleTexture { 19 | // 2D array of WobbleEntry structs 20 | WobbleEntry* mpEntries; 21 | float unk4; 22 | int mWidth; 23 | int mHeight; 24 | float unk10; 25 | Blitter_TriStrip* mpTriStrips; 26 | 27 | void Init(int _width, int _height); 28 | void Deinit(void); 29 | float SetUpGrid(Vector*, float, float, float); 30 | void WobbleUVs(float); 31 | void Draw(Material*, bool); 32 | 33 | /// @brief Returns the WobbleEntry at (i, j) of mpEntries 34 | WobbleEntry* GetWobbleEntry(int i, int j) { 35 | return &mpEntries[j * mWidth] + i; 36 | } 37 | 38 | void IncrementUnk4(void) { 39 | unk4 += 1.0f; 40 | } 41 | }; 42 | 43 | #endif // WOBBLETEXURE_H 44 | -------------------------------------------------------------------------------- /include/ty/bunyip.h: -------------------------------------------------------------------------------- 1 | #ifndef BUNYIP_H 2 | #define BUNYIP_H 3 | 4 | #include "ty/props/AnimatingProp.h" 5 | 6 | void Bunyip_LoadResources(KromeIni*); 7 | 8 | bool Bunyip_On(void); 9 | bool Bunyip_Activate(void); 10 | int Bunyip_GetLastEvent(void); 11 | bool Bunyip_IsLastEventGroundHit(void); 12 | 13 | enum BunyipState { 14 | BUNYIP_STATE_0 = 0, 15 | BUNYIP_APPEAR = 1, 16 | BUNYIP_IDLE = 2, 17 | BUNYIP_STATE_3 = 3, 18 | BUNYIP_STATE_4 = 4, 19 | BUNYIP_ROAR = 5, 20 | BUNYIP_PUNCH = 6, 21 | BUNYIP_STATE_7 = 7, 22 | BUNYIP_DISAPPEAR = 8, 23 | }; 24 | 25 | /// @brief Bunyip object used when Ty is in the Bunyip state 26 | struct Bunyip : AnimatingProp { 27 | Vector mRot; 28 | Vector mDefaultPos; 29 | Vector unkB0; 30 | 31 | char unkC0[4]; 32 | 33 | int unkC4; 34 | int mHandIndex; // Punching hand node index 35 | int bunyipLifeSpan; 36 | 37 | char unkD0[4]; 38 | 39 | float mScale; 40 | bool unkD8; 41 | bool unkD9; // state change flag? 42 | bool unkDA; 43 | char unkDB; 44 | SoundEventHelper mSoundHelper; 45 | BunyipState mState; 46 | int unkE4; 47 | 48 | virtual void LoadDone(void); 49 | virtual void Reset(void); 50 | virtual void Update(void); 51 | virtual void Draw(void); 52 | virtual void Message(MKMessage* pMsg); 53 | virtual void Init(GameObjDesc* pDesc); 54 | 55 | void Appear(void); 56 | void Idle(void); 57 | void Roar(void); 58 | void PunchCombo(void); 59 | void Disappear(void); 60 | void SetState(BunyipState); 61 | void UpdatePos(Vector* pPos, Vector* pRot); 62 | void CheckEvents(void); 63 | bool HasPunched(Vector* pPoint, float radius); 64 | 65 | int StateInline(void) { 66 | return (mState > 1 && mState != BUNYIP_DISAPPEAR) ? true : false; 67 | } 68 | }; 69 | 70 | #endif // BUNYIP_H 71 | -------------------------------------------------------------------------------- /include/ty/camera/GameCamera.h: -------------------------------------------------------------------------------- 1 | #ifndef GAMECAMERA_H 2 | #define GAMECAMERA_H 3 | 4 | #endif // GAMECAMERA_H 5 | -------------------------------------------------------------------------------- /include/ty/controlval.h: -------------------------------------------------------------------------------- 1 | #ifndef CONTROLVAL_H 2 | #define CONTROLVAL_H 3 | 4 | struct ControlVal { 5 | // come up with a better names 6 | int activeControls[8]; 7 | int buttonVals[(0x7C-0x20) / 4]; 8 | 9 | void Init(int); 10 | void UseControlConfig(int); 11 | }; 12 | 13 | extern ControlVal tyControl; 14 | 15 | #endif // CONTROLVAL_H 16 | -------------------------------------------------------------------------------- /include/ty/effects/Bubble.h: -------------------------------------------------------------------------------- 1 | #ifndef BUBBLE_H 2 | #define BUBBLE_H 3 | 4 | #include "common/ParticleSystem.h" 5 | 6 | /// @brief Bubble particle structure 7 | struct Bubble { 8 | ParticleSystem* mpSystem; 9 | 10 | static Material* pBubbleMat; 11 | static ParticleSystemType bubbleType; 12 | 13 | void Init(Vector* pPos, BoundingVolume* pVolume, float f1); 14 | void Deinit(void); 15 | void Create(Vector* pPos, float f1, float f2, float f3, float f4); 16 | }; 17 | 18 | void Bubble_LoadResources(void); 19 | void Bubble_CustomUpdate(ParticleSystem* pSys); 20 | 21 | #endif // BUBBLE_H 22 | -------------------------------------------------------------------------------- /include/ty/effects/ChronorangEffects.h: -------------------------------------------------------------------------------- 1 | #ifndef CHRONORANG_EFFECTS_H 2 | #define CHRONORANG_EFFECTS_H 3 | 4 | #include "common/ParticleSystem.h" 5 | 6 | void ChronorangEffects_LoadResources(void); 7 | 8 | void Pollen_Update(ParticleSystem* pSys); 9 | void SleepyDust_Update(ParticleSystem* pSys); 10 | 11 | struct Pollen { 12 | ParticleSystem* pSystem; 13 | 14 | static Material* pPollenMat; 15 | static ParticleSystemType pollenType; 16 | 17 | void Init(Vector* pPos); 18 | void Deinit(void); 19 | void Spawn(Vector* pPos, Vector* arg2, float f1); 20 | void SetVel(Vector* pVel); 21 | }; 22 | 23 | struct SleepyDustEntry { 24 | Matrix matrix; 25 | Model* pModel; 26 | bool unk0; 27 | bool unk1; 28 | float yaw; 29 | }; 30 | 31 | // 10 dynamic particle entries 32 | #define NUM_DUST_ENTRIES (10) 33 | 34 | struct SleepyDust { 35 | ParticleSystem* pSystem; 36 | 37 | char padding0[0x284 - 0x4]; 38 | 39 | SleepyDustEntry dustEntries[NUM_DUST_ENTRIES]; 40 | 41 | static Material* pSleepyDustMat; 42 | static ParticleSystemType sleepyDustType; 43 | 44 | void Init(void); 45 | void Update(void); 46 | }; 47 | 48 | void SleepyDust_Init(void); 49 | void SleepyDust_Deinit(void); 50 | void SleepyDust_Reset(void); 51 | void SleepyDust_UpdateAll(void); 52 | void SleepyDust_Update(Model* pModel); 53 | void SleepyDust_AddNewUser(Model* pModel); 54 | void SleepyDust_RemoveUser(Model* pModel); 55 | 56 | #endif // CHRONORANG_EFFECTS_H 57 | -------------------------------------------------------------------------------- /include/ty/effects/Explosion.h: -------------------------------------------------------------------------------- 1 | #ifndef EXPLOSION_H 2 | #define EXPLOSION_H 3 | 4 | #include "common/Vector.h" 5 | #include "common/Model.h" 6 | #include "common/ParticleSystem.h" 7 | #include "ty/effects/Bubble.h" 8 | #include "ty/StructList.h" 9 | 10 | void Explosion_LoadResources(void); 11 | void Explosion_Update(void); 12 | void Explosion_Deinit(void); 13 | void Explosion_Draw(void); 14 | 15 | struct Tendril { 16 | Vector unk0; 17 | 18 | int refPointIndex; 19 | Model* pModel; 20 | 21 | float mPitch; 22 | float mYaw; 23 | float mRoll; 24 | 25 | float unk24; 26 | float unk28; 27 | float unk2C; 28 | float unk30; 29 | float unk34; 30 | 31 | void Setup(float yaw, Vector* pPos); 32 | void Update(float, Vector* pPos, float); 33 | }; 34 | 35 | struct Cloud { 36 | Vector unk0; 37 | Vector unk10; 38 | Vector unk20; 39 | float unk30; 40 | float unk34; 41 | Model* pModel; 42 | 43 | void Setup(Vector*, float); 44 | float GetRandom(float min, float max); 45 | void Update(float, float); 46 | }; 47 | 48 | #define NUM_CLOUDS (6) 49 | #define NUM_TENDRILS (10) 50 | 51 | struct Explosion { 52 | ParticleSystem* mpSystem; 53 | Material* pMaterial; 54 | float unk8; 55 | Vector mPos; 56 | Bubble mBubble; 57 | bool unk20; 58 | bool unk21; 59 | float unk24; 60 | Cloud mClouds[NUM_CLOUDS]; 61 | Model* pExploRing; 62 | Tendril mTendrils[NUM_TENDRILS]; 63 | int unk3C4; 64 | float unk3C8; 65 | float unk3CC; 66 | float unk3D0; 67 | float mParticleColor; 68 | float unk3D8; 69 | Vector mRingRot; 70 | bool unk3EC; 71 | 72 | void Init(Vector* pPos, bool, float); 73 | void Deinit(void); 74 | void Explode(Vector*, float); 75 | void Update(void); 76 | void Draw(void); 77 | }; 78 | 79 | extern StructList activeSet; 80 | 81 | #endif // EXPLOSION_H 82 | -------------------------------------------------------------------------------- /include/ty/effects/Flame.h: -------------------------------------------------------------------------------- 1 | #ifndef FLAME_H 2 | #define FLAME_H 3 | 4 | #include "common/ParticleSystem.h" 5 | 6 | void Flame_LoadResources(void); 7 | 8 | /// @brief Flame particle structure 9 | struct Flame { 10 | ParticleSystem* mpSystem; 11 | float unk4; 12 | 13 | static ParticleSystemType type; 14 | static ParticleEnvelope envelope[3]; 15 | 16 | void Init(Vector* pPos, BoundingVolume* pVolume, float f1, float f2); 17 | void Deinit(void); 18 | void Create(Vector* pDir, float dirLen, Vector* pColor); 19 | void Reset(void); 20 | }; 21 | 22 | void Flame_CustomUpdate(ParticleSystem* pSys); 23 | 24 | #endif // FLAME_H 25 | -------------------------------------------------------------------------------- /include/ty/effects/RainbowEffect.h: -------------------------------------------------------------------------------- 1 | #ifndef RAINBOW_EFFECT_H 2 | #define RAINBOW_EFFECT_H 3 | 4 | #include "common/ParticleSystem.h" 5 | #include "ty/Spline.h" 6 | 7 | void RainbowEffect_LoadResources(void); 8 | 9 | void RainbowEffect_Update(ParticleSystem* pSys); 10 | 11 | struct RainbowEffectSubStruct { 12 | Spline spline; 13 | bool unk4; 14 | int unk8; 15 | int unkC; 16 | float unk10[3]; 17 | float particleColor[3]; // RGB 18 | }; 19 | 20 | #define NUM_RAINBOWEFFECT_SUBS (4) 21 | 22 | struct RainbowEffect { 23 | float unk0; 24 | float unk4; 25 | float unk8; 26 | float unkC; 27 | float unk10; 28 | ParticleSystem* pSys; 29 | RainbowEffectSubStruct subs[NUM_RAINBOWEFFECT_SUBS]; 30 | 31 | static Material* pRainbowMat; 32 | static ParticleSystemType rainbowEffectType; 33 | 34 | void Init(Vector* pPos); 35 | void Deinit(void); 36 | void Reset(void); 37 | void Update(float f1); 38 | void Spawn(Vector* pPos, Vector* pColor); 39 | }; 40 | 41 | #endif // RAINBOW_EFFECT_H 42 | -------------------------------------------------------------------------------- /include/ty/effects/Trails.h: -------------------------------------------------------------------------------- 1 | #ifndef TRAILS_H 2 | #define TRAILS_H 3 | 4 | #include "ty/tools.h" 5 | #include "common/Blitter.h" 6 | 7 | struct TrailNode { 8 | Vector pos0; // Position of first point 9 | Vector pos1; // Position of second point 10 | }; 11 | 12 | /// @brief Object used for boomerang trails 13 | struct BoomerangTrail { 14 | int unk0; 15 | CircularQueue queue; 16 | Vector vec0; 17 | Vector vec1; 18 | Material* pMaterial; 19 | float color; // Value of RGB colors for tristrips (color, color, color, 1.0f) 20 | int unk3C; 21 | 22 | void Init(char* pTrailName, float rgb); 23 | void Deinit(void); 24 | void Reset(void); 25 | void Update(Vector* pos0, Vector* pos1); 26 | void Draw(void); 27 | }; 28 | 29 | #endif // TRAILS_H 30 | -------------------------------------------------------------------------------- /include/ty/frontend/FrontEnd.h: -------------------------------------------------------------------------------- 1 | #ifndef FRONTEND_H 2 | #define FRONTEND_H 3 | 4 | #include "ty/frontend/UITools.h" 5 | #include "ty/tools.h" 6 | #include "common/View.h" 7 | #include "common/Font.h" 8 | #include "common/Blitter.h" 9 | 10 | enum tagFrontEndScreen { 11 | 12 | }; 13 | 14 | // Called ScreenData in July 1st and debug builds 15 | struct ScreenFaderObject : FaderObject { 16 | uint baseColor; 17 | Blitter_UntexturedImage image; 18 | 19 | void Init(Vector* pColour, float, float); 20 | bool Update(void); 21 | void Draw(void); 22 | }; 23 | 24 | struct FrontEndCommonResources { 25 | bool bInitialised; 26 | int state; 27 | Font* pFont; 28 | DirectLight mDirectLight; 29 | View mView; 30 | Blitter_UntexturedImage mUntexturedImage; 31 | ScreenFaderObject mFader; 32 | UIText mText; 33 | 34 | bool ControllerRemoved(void); 35 | }; 36 | 37 | extern FrontEndCommonResources gFERes; 38 | 39 | #endif // FRONTEND_H 40 | -------------------------------------------------------------------------------- /include/ty/heatflare.h: -------------------------------------------------------------------------------- 1 | #ifndef HEATFLARE_H 2 | #define HEATFLARE_H 3 | 4 | #include "common/Vector.h" 5 | 6 | struct HeatFlareInfo { 7 | Vector unk0; 8 | float unk10; 9 | float unk14; 10 | int unk18; 11 | }; 12 | 13 | void HeatFlare_LoadResources(void); 14 | void HeatFlare_Init(void); 15 | void HeatFlare_Deinit(void); 16 | void HeatFlare_Update(void); 17 | void HeatFlare_Draw(void); 18 | void HeatFlare_Unlock(void); 19 | 20 | HeatFlareInfo* HeatFlare_Add(Vector*, float); 21 | 22 | void HeatFlare_On(void*, int); 23 | 24 | #endif // HEATFLARE_H 25 | -------------------------------------------------------------------------------- /include/ty/props/Aquarang.h: -------------------------------------------------------------------------------- 1 | #ifndef AQUARANG_H 2 | #define AQUARANG_H 3 | 4 | #include "ty/props/StaticProp.h" 5 | 6 | struct AquarangProp : StaticProp { 7 | bool bCurrVisible; // Current visibility 8 | Blitter_Particle particle; 9 | float randAngle; 10 | float yaw; 11 | float yawUpdateVal; 12 | bool bVisible; // Default visibility setting for this object 13 | 14 | virtual bool LoadLine(KromeIniLine* pLine); 15 | virtual void LoadDone(void); 16 | virtual void Reset(void); 17 | virtual void Update(void); 18 | virtual void Draw(void); 19 | virtual void Message(MKMessage* pMsg); 20 | 21 | static Material* pGlow; // Material used for the glow 22 | }; 23 | 24 | void AquarangProp_LoadResources(KromeIni* pIni); 25 | 26 | #endif // AQUARANG_H 27 | -------------------------------------------------------------------------------- /include/ty/props/BunyipStone.h: -------------------------------------------------------------------------------- 1 | #ifndef BUNYIPSTONE_H 2 | #define BUNYIPSTONE_H 3 | 4 | #include "ty/props/StaticProp.h" 5 | 6 | void BunyipStone_LoadResources(KromeIni* pIni); 7 | 8 | enum BunyipStone_BallState { 9 | BS_BALLSTATE_SHOW = 0, // Balls rise out of the stone 10 | BS_BALLSTATE_UPDATE = 1, // Balls wobble and rotate 11 | BS_BALLSTATE_HIDE = 2, // Balls drop into the stone 12 | }; 13 | 14 | // Object used to activate the Bunyip when Ty walks over it 15 | struct BunyipStone : StaticProp { 16 | Vector mBallRot1; 17 | Vector mBallRot2; 18 | 19 | int cooldownTimer; 20 | 21 | // 0 is the larger center ball 22 | // 1 and 2 are the smaller balls that rotate around the center 23 | int stoneMatrixIndices[3]; 24 | 25 | float centerBallYWobble; // Angle that controls the Y position of the center ball 26 | 27 | float unk8C; 28 | float unk90; 29 | float unk94; 30 | float unk98; 31 | 32 | BunyipStone_BallState mBallState; 33 | 34 | virtual void LoadDone(void); 35 | virtual void Init(GameObjDesc* pDesc); 36 | virtual void Reset(void); 37 | virtual void Update(void); 38 | void UpdateBalls(void); 39 | void OrbitBalls(void); 40 | }; 41 | 42 | #endif // BUNYIPSTONE_H 43 | -------------------------------------------------------------------------------- /include/ty/props/Collapsible.h: -------------------------------------------------------------------------------- 1 | #ifndef COLLAPSIBLE_H 2 | #define COLLAPSIBLE_H 3 | 4 | #include "ty/props/StaticProp.h" 5 | #include "common/KromeIni.h" 6 | 7 | // move this to the proper header 8 | struct ShatterStruct { 9 | char padding_0x0[0x24]; 10 | Model* pModel; 11 | void Fall(void); 12 | }; 13 | ShatterStruct* Shatter_Add(Model*, float, float, int); 14 | 15 | enum CollapsibleState { 16 | COLLAPSIBLE_STATE_0 = 0, 17 | COLLAPSIBLE_STATE_1 = 1, 18 | COLLAPSIBLE_STATE_2 = 2, 19 | COLLAPSIBLE_STATE_3 = 3, 20 | COLLAPSIBLE_STATE_4 = 4, 21 | }; 22 | 23 | struct Collapsible : StaticProp { 24 | CollapsibleState state; 25 | int unk5C; 26 | Vector defaultTrans; // model translation 27 | Vector scale; 28 | Vector defaultRot; 29 | ShatterStruct* shatter; 30 | 31 | virtual void LoadDone(void); 32 | 33 | virtual void Reset(void) { 34 | pModel->matrices[0].SetTranslation(&defaultTrans); 35 | pModel->matrices[0].SetRotationPYR(&defaultRot); 36 | pModel->matrices[0].Scale(&scale); 37 | state = COLLAPSIBLE_STATE_0; 38 | unk5C = 0; 39 | collisionInfo.bEnabled = true; 40 | collisionInfo.flags = 0; 41 | collisionInfo.pProp = NULL; 42 | } 43 | 44 | virtual void Update(void); 45 | 46 | virtual void Draw(void) { 47 | if (!Hidden()) { 48 | // if the Collapsible isn't hidden, draw it 49 | StaticProp::Draw(); 50 | } 51 | } 52 | 53 | virtual void Init(GameObjDesc* pDesc) { 54 | StaticProp::Init(pDesc); 55 | state = COLLAPSIBLE_STATE_0; 56 | shatter = Shatter_Add(pModel, 1.0f, 0.7f, 0x78); 57 | Reset(); 58 | } 59 | 60 | bool Hidden(void) { 61 | return state == COLLAPSIBLE_STATE_3 || state == COLLAPSIBLE_STATE_2; 62 | } 63 | }; 64 | 65 | void Collapsible_LoadResources(KromeIni* pIni); 66 | 67 | #endif // COLLAPSIBLE_H 68 | -------------------------------------------------------------------------------- /include/ty/props/D1_Prop.h: -------------------------------------------------------------------------------- 1 | #ifndef D1PROP_H 2 | #define D1PROP_H 3 | 4 | #include "ty/GameObject.h" 5 | #include "common/KromeIni.h" 6 | #include "ty/Messages.h" 7 | 8 | struct D1Prop : GameObject { 9 | bool bActive; 10 | bool unk3D; 11 | EventMessage OnCompletion100; 12 | EventMessage OnCompletion; 13 | 14 | virtual bool LoadLine(KromeIniLine* pLine); 15 | virtual void LoadDone(void); 16 | virtual void Reset(void); 17 | virtual void Update(void); 18 | virtual void Draw(void); 19 | virtual void Message(MKMessage* pMsg); 20 | virtual void Init(GameObjDesc* pDesc); 21 | virtual void Deinit(void); 22 | }; 23 | 24 | void D1_Prop_LoadResource(KromeIni*); 25 | void D1PropEndOfCredits(void); 26 | 27 | #endif // D1PROP_H -------------------------------------------------------------------------------- /include/ty/props/DDACheckpoint.h: -------------------------------------------------------------------------------- 1 | #ifndef DDACHECKPOINT_H 2 | #define DDACHECKPOINT_H 3 | 4 | #include "ty/GameObjectManager.h" 5 | 6 | void DDACheckpoint_LoadResources(KromeIni* pIni); 7 | 8 | struct DDACheckpoint : GameObject { 9 | int Number; 10 | 11 | virtual bool LoadLine(KromeIniLine*); 12 | virtual void Message(MKMessage*); 13 | virtual void Init(GameObjDesc*); 14 | }; 15 | 16 | #endif // DDACHECKPOINT_H -------------------------------------------------------------------------------- /include/ty/props/Picture.h: -------------------------------------------------------------------------------- 1 | #ifndef PICTURE_H 2 | #define PICTURE_H 3 | 4 | #include "ty/props/StaticProp.h" 5 | #include "ty/Quadratic.h" 6 | 7 | void Picture_LoadResources(KromeIni* pIni); 8 | 9 | /// @brief Picture object dropped by InvisiCrate 10 | struct Picture : StaticProp { 11 | Vector pos; 12 | float unk68; 13 | float mQuadraticTime; // time for quadratic equation 14 | float unk70; 15 | float unk74; 16 | float angle; 17 | int mFrameNumber; 18 | bool unk80; // bInitialised is set to this when the Picture is reset 19 | bool bInitialised; 20 | bool bShow; // TODO: Rename / not bShow but bCollected(?) 21 | bool unk83; 22 | Quadratic mQuadratic; // Quadratic equation for falling movement 23 | 24 | virtual bool LoadLine(KromeIniLine* pLine); 25 | virtual void LoadDone(void); 26 | virtual void Reset(void); 27 | virtual void Update(void); 28 | virtual void Draw(void); 29 | virtual void Init(GameObjDesc* pDesc); 30 | 31 | static Picture* Create(Vector* pPos); 32 | void Spawn(int frameNumber, Vector* pPos); 33 | void Destroy(void); 34 | 35 | static void PostDraw(void*); 36 | 37 | bool IsShowing(void) { 38 | return bShow; 39 | } 40 | }; 41 | 42 | #endif // PICTURE_H 43 | -------------------------------------------------------------------------------- /include/ty/props/Projectile.h: -------------------------------------------------------------------------------- 1 | #ifndef PROJECTILE_H 2 | #define PROJECTILE_H 3 | 4 | #include "ty/GameObject.h" 5 | 6 | enum ProjectileState { 7 | PROJECTILE_STATE_0 = 0, 8 | PROJECTILE_STATE_2 = 2 9 | }; 10 | 11 | /// @brief Projectile Descriptor 12 | struct ProjectileDesc : GameObjDesc { 13 | // No Load function, fields must be set when loading resources 14 | int unk84; 15 | float unk88; 16 | float unk8C; 17 | int groundHitSound; 18 | int hitSound; 19 | float unk98; 20 | }; 21 | 22 | struct Projectile : GameObject { 23 | Vector mPosDiff; 24 | // {pitch, yaw, roll, rot spin speed scale} 25 | Vector mRot; 26 | Vector unk5C; 27 | int unk6C; 28 | int unk70; 29 | bool unk74; 30 | bool unk75; 31 | ProjectileState mState; 32 | 33 | virtual void Update(void); 34 | virtual void Message(MKMessage* pMsg); 35 | virtual void Init(GameObjDesc* pDesc); 36 | virtual void Deinit(void); 37 | virtual void Fire(Vector*); 38 | virtual void UpdatePhysics(void); 39 | virtual void DamageTy(void); 40 | virtual void KnockBackTy(void); 41 | virtual bool ResolveHit(void); 42 | virtual void CheckForHit(void); 43 | virtual void AddSpin(void); 44 | 45 | void EndLife(void); 46 | void FireAtTarget(Vector*, Vector*); 47 | bool CheckShotPossible(Vector*, Vector*); 48 | void SetState(ProjectileState); 49 | void SetPos(Vector*); 50 | 51 | ProjectileDesc* GetDesc(void) { 52 | return descr_cast(pDescriptor); 53 | } 54 | }; 55 | 56 | #endif // PROJECTILE_H 57 | -------------------------------------------------------------------------------- /include/ty/props/RangStone.h: -------------------------------------------------------------------------------- 1 | #ifndef RANGSTONE_H 2 | #define RANGSTONE_H 3 | 4 | #include "ty/props/StaticProp.h" 5 | #include "ty/Messages.h" 6 | 7 | struct RangStone : StaticProp { 8 | EventMessage OnSuccess; 9 | int rangHidden; // 0 = rang shown, 1 = rang hidden 10 | 11 | virtual bool LoadLine(KromeIniLine* pLine); 12 | virtual void Message(MKMessage* pMsg); 13 | virtual void Init(GameObjDesc* pDesc); 14 | void HideRang(void); 15 | }; 16 | 17 | void RangStone_LoadResources(KromeIni* pIni); 18 | 19 | #endif // RANGSTONE_H 20 | -------------------------------------------------------------------------------- /include/ty/props/SoundProp.h: -------------------------------------------------------------------------------- 1 | #ifndef SOUNDPROP_H 2 | #define SOUNDPROP_H 3 | 4 | #include "types.h" 5 | #include "ty/soundbank.h" 6 | #include "common/Vector.h" 7 | #include "ty/GameObject.h" 8 | #include "ty/CommonGameObjectFlags.h" 9 | 10 | struct SoundProp : GameObject { 11 | Matrix localToWorld; 12 | SoundEventHelper unk7C; 13 | int unk80; 14 | int unk84; 15 | int unk88; 16 | int minDelay; 17 | int maxDelay; 18 | CommonGameObjFlagsComponent gameObjFlags; 19 | 20 | virtual bool LoadLine(KromeIniLine* pLine); 21 | virtual void LoadDone(void); 22 | virtual void Reset(void); 23 | virtual void Update(void); 24 | virtual void Message(MKMessage* pMsg); 25 | virtual void Init(GameObjDesc* pDesc); 26 | virtual void Deinit(void); 27 | void Play(void); 28 | Vector* GetPos(void) { 29 | return localToWorld.Row3(); 30 | } 31 | }; 32 | 33 | void SoundProp_LoadResources(KromeIni*); 34 | 35 | #endif // SOUNDPROP_H 36 | -------------------------------------------------------------------------------- /include/ty/props/SpawnPoint.h: -------------------------------------------------------------------------------- 1 | #ifndef SPAWNPOINT_H 2 | #define SPAWNPOINT_H 3 | 4 | #include "ty/GameObject.h" 5 | 6 | void SpawnPoint_LoadResources(KromeIni* pIni); 7 | 8 | // Object to hold information about where ty spawns in a level such as position and rotation 9 | struct SpawnPoint : GameObject { 10 | int fromLevel; // default = 0 11 | Vector tySpawnPos; // default = 0, 0, 0 12 | Vector tySpawnRot; // default = 0, 0, 0 13 | 14 | virtual bool LoadLine(KromeIniLine* pLine); 15 | virtual void LoadDone(void); 16 | virtual void Message(MKMessage* pMsg); 17 | virtual void Init(GameObjDesc* pDesc); 18 | }; 19 | 20 | #endif // SPAWNPOINT_H 21 | -------------------------------------------------------------------------------- /include/ty/props/Talisman.h: -------------------------------------------------------------------------------- 1 | #ifndef TALISMAN_H 2 | #define TALISMAN_H 3 | 4 | #include "ty/props/StaticProp.h" 5 | #include "common/ParticleSystem.h" 6 | 7 | void Talisman_LoadResources(KromeIni* pIni); 8 | 9 | #define TALISMAN_COUNT 5 10 | 11 | // Contains information about Talisman props such as the model's name and the descriptor's name 12 | struct TalismanInfo { 13 | char* pModelName; // Model name 14 | char* pDescrName; // Descriptor name 15 | }; 16 | 17 | struct Talisman : StaticProp { 18 | ParticleSystem* pParticleSystem; 19 | bool bCurrentVisible; // Current visibility 20 | bool bVisible; // Default visibility setting for this talisman 21 | 22 | virtual bool LoadLine(KromeIniLine* pLine); 23 | virtual void LoadDone(void); 24 | virtual void Reset(void); 25 | virtual void Update(void); 26 | virtual void Draw(void); 27 | virtual void Message(MKMessage* pMsg); 28 | virtual void Init(GameObjDesc* pDesc); 29 | virtual void Deinit(void); 30 | }; 31 | 32 | #endif // TALISMAN_H 33 | -------------------------------------------------------------------------------- /include/ty/props/WaterVolume.h: -------------------------------------------------------------------------------- 1 | #ifndef WATERVOLUME_H 2 | #define WATERVOLUME_H 3 | 4 | #include "ty/GameObjectManager.h" 5 | 6 | // Generic LoadResources function for WaterVolume 7 | void WaterVolume_LoadResources(KromeIni* pIni); 8 | 9 | // Checks if a point is within a WaterVolume 10 | // Iterates over all WaterVolumes within a level 11 | bool WaterVolume_IsWithin(Vector* point, float*); 12 | 13 | /// @brief Object used to determine whether an object is in water or not 14 | struct WaterVolume : GameObject { 15 | 16 | // Inverse Matrix 17 | Matrix mInvMtx; // worldToLocal matrix 18 | 19 | // Object World matrix 20 | Matrix mWorldMtx; // pos in ini is Row3 of this matrix 21 | 22 | float mMinY; // Minimum y point of volume 23 | float mMaxY; // Maximum y point of volume 24 | 25 | virtual bool LoadLine(KromeIniLine* pLine); 26 | virtual void LoadDone(void); 27 | virtual void Init(GameObjDesc* pDesc); 28 | virtual void Deinit(void); 29 | }; 30 | 31 | #endif // WATERVOLUME_H 32 | -------------------------------------------------------------------------------- /include/ty/props/WeatherProp.h: -------------------------------------------------------------------------------- 1 | #include "ty/GameObjectManager.h" 2 | 3 | void WeatherProp_LoadResources(KromeIni*); 4 | void WeatherProp_Init(void); 5 | 6 | struct WeatherProp : GameObject { 7 | int bEnabled; 8 | int unk40; 9 | int bWater; 10 | int unk48; 11 | int type; 12 | int unk50; 13 | int sound; 14 | 15 | virtual bool LoadLine(KromeIniLine* pLine); 16 | virtual void LoadDone(void); 17 | virtual void Reset(void); 18 | virtual void Update(void); 19 | virtual void Message(MKMessage* pMsg); 20 | virtual void Init(GameObjDesc* pDesc); 21 | virtual void Deinit(void); 22 | 23 | void Activate(void); 24 | void Deactivate(void); 25 | void SetType(int); 26 | }; -------------------------------------------------------------------------------- /include/ty/props/Z1_RainbowScales.h: -------------------------------------------------------------------------------- 1 | #ifndef Z1RAINBOWSCALES_H 2 | #define Z1RAINBOWSCALES_H 3 | 4 | #include "ty/LevelObjective.h" 5 | 6 | void Z1RainbowScaleObjective_LoadResources(KromeIni* pIni); 7 | 8 | struct RainbowScaleObjective : LevelObjective { 9 | bool bStarted; 10 | 11 | virtual void Reset(void); 12 | virtual void Update(void); 13 | virtual void Message(MKMessage* pMsg); 14 | virtual void Init(GameObjDesc* pDesc); 15 | }; 16 | 17 | #endif // Z1RAINBOWSCALES_H 18 | -------------------------------------------------------------------------------- /include/ty/soundbank.h: -------------------------------------------------------------------------------- 1 | #ifndef SOUNDBANK_H 2 | #define SOUNDBANK_H 3 | 4 | #include "types.h" 5 | #include "ty/GameObject.h" 6 | 7 | extern int SoundBank_Play(int, Vector*, uint); 8 | extern void SoundBank_Stop(int*); 9 | 10 | struct SoundEventHelper { 11 | int unk0; 12 | 13 | void Update(int, bool, bool, GameObject*, Vector*, float, int); 14 | void Message(MKMessage*); 15 | 16 | void Init(void) { 17 | unk0 = -1; 18 | } 19 | 20 | void Deinit(void) { 21 | SoundBank_Stop(&unk0); 22 | } 23 | 24 | void Stop(void) { 25 | SoundBank_Stop(&unk0); 26 | } 27 | 28 | void Reset(void) { 29 | SoundBank_Stop(&unk0); 30 | } 31 | }; 32 | 33 | #endif // SOUNDBANK_H 34 | -------------------------------------------------------------------------------- /include/ty/tytypes.h: -------------------------------------------------------------------------------- 1 | #ifndef TYTYPES_H 2 | #define TYTYPES_H 3 | 4 | #include "ty/tools.h" 5 | #include "common/Vector.h" 6 | #include "common/Collision.h" 7 | 8 | struct Rotation { 9 | float unk0; 10 | float unk4; // yaw? 11 | float unk8; // roll? 12 | float unkC; 13 | float unk10; 14 | 15 | Vector* GetFrontVector(void) { 16 | static Vector v; 17 | v.Set(unkC, 0.0f, unk10); 18 | return &v; 19 | } 20 | 21 | Vector* GetRotVector(void) { 22 | static Vector v; 23 | v.Set(unk0, unk4, unk8); 24 | return &v; 25 | } 26 | 27 | float GetUnk0(void) { 28 | return unk0; 29 | } 30 | 31 | float GetUnk4(void) { 32 | return unk4; 33 | } 34 | 35 | float GetUnk8(void) { 36 | return unk8; 37 | } 38 | 39 | float GetUnkC(void) { 40 | return unkC; 41 | } 42 | 43 | float GetUnk10(void) { 44 | return unk10; 45 | } 46 | 47 | void UnknownInline(float f1) { 48 | // unk4 = NormaliseAngle(f1) 49 | // unkC = _table_cosf(unk4 - PI/2) 50 | // unk10 = _table_sinf(unk4 - PI/2) 51 | } 52 | 53 | void SetUnk0(float val) { 54 | unk0 = val; 55 | } 56 | 57 | void SetUnk8(float val) { 58 | unk8 = val; 59 | } 60 | 61 | void SetRotByVec(Vector* pRot) { 62 | SetUnk0(pRot->x); 63 | UnknownInline(pRot->y); 64 | SetUnk8(pRot->z); 65 | } 66 | 67 | void IncreaseUnk4(float val) { 68 | UnknownInline(unk4 + val); 69 | } 70 | }; 71 | 72 | #ifndef KEEP_DATA_POOLING 73 | 74 | struct UnknownColorVectorStruct { 75 | Vector* GetColor(void) { 76 | static Vector colorVec = {0.0f, 0.0f, 0.0f, 0.0f}; 77 | return &colorVec; 78 | } 79 | }; 80 | 81 | #endif // KEEP_DATA_POOLING 82 | 83 | #endif // TYTYPES_H 84 | -------------------------------------------------------------------------------- /include/types.h: -------------------------------------------------------------------------------- 1 | #ifndef TYPES_H 2 | #define TYPES_H 3 | 4 | typedef signed char s8; 5 | typedef signed short s16; 6 | typedef signed long s32; 7 | typedef signed long long s64; 8 | typedef unsigned char u8; 9 | typedef unsigned short u16; 10 | typedef unsigned long u32; 11 | typedef unsigned long size_t; 12 | typedef unsigned long long u64; 13 | 14 | typedef unsigned short ushort; 15 | typedef unsigned int uint; 16 | 17 | typedef volatile u8 vu8; 18 | typedef volatile u16 vu16; 19 | typedef volatile u32 vu32; 20 | typedef volatile u64 vu64; 21 | typedef volatile s8 vs8; 22 | typedef volatile s16 vs16; 23 | typedef volatile s32 vs32; 24 | typedef volatile s64 vs64; 25 | 26 | typedef float f32; 27 | typedef double f64; 28 | typedef volatile f32 vf32; 29 | typedef volatile f64 vf64; 30 | 31 | typedef int BOOL; 32 | #define TRUE 1 33 | #define FALSE 0 34 | 35 | struct MTX34 36 | { 37 | float mMtx[3][4]; 38 | }; 39 | 40 | #ifndef nullptr 41 | #define nullptr 0 42 | #endif 43 | 44 | #ifndef NULL 45 | #define NULL 0 46 | #endif 47 | 48 | // Array size define 49 | #define ARRAY_SIZE(o) (sizeof((o)) / sizeof(*(o))) 50 | 51 | #endif // !TYPES_H 52 | -------------------------------------------------------------------------------- /old_ppcdis/config/analysis_overrides.yml: -------------------------------------------------------------------------------- 1 | blocked_pointers: 2 | - 0x801fdcc0 3 | - 0x801fdd94 4 | 5 | forced_types: 6 | 0x801fc300: FUNCTION # TRKExceptionHandler 7 | 0x801fc460: FUNCTION # TRKInterruptHandlerEnableInterrupts 8 | 9 | # these should probably be aligned too 10 | sdata_sizes: 11 | - [0x803fae48, 8] 12 | # - [0x803FAD48, 8] 13 | - [0x803fadc0, 8] 14 | # - [0x803FAE80, 8] 15 | # - [0x803FAEB0, 8] 16 | # - [0x803FAF30, 8] 17 | - [0x803fb4e0, 8] 18 | - [0x803fb4f0, 8] 19 | - [0x803ff4b0, 8] -------------------------------------------------------------------------------- /old_ppcdis/config/assets.yml: -------------------------------------------------------------------------------- 1 | #asset config file 2 | 3 | config/dol.yml: 4 | 5 | materialgc_rawCaptureData: 6 | addrs: [0x80276A80, 0x80296a80] -------------------------------------------------------------------------------- /old_ppcdis/config/disasm_overrides.yml: -------------------------------------------------------------------------------- 1 | forced_types: 2 | 0x801fc300: FUNCTION # TRKExceptionHandler 3 | 0x801fc460: FUNCTION # TRKInterruptHandlerEnableInterrupts 4 | 5 | trim_ctors: true 6 | 7 | symbol_aligns: 8 | 0x802eaa60: 32 # pBuffer from demoinit.cpp 9 | 0x802d4dc0: 32 # Header from OSReboot.c 10 | 0x803fb1a0: 32 # Gbase from THPDec.c 11 | 0x803fb1c0: 32 # Gwid from THPDec.c 12 | 0x803fb1e0: 32 # Gq from THPDec.c 13 | 0x803f04c0: 32 # ActivePlayer from THPPlayer.c 14 | 0x803fb0e0: 32 # Ydchuff from THPDec.c 15 | 0x803fb100: 32 # Udchuff from THPDec.c 16 | 0x803fb120: 32 # Vdchuff from THPDec.c 17 | 0x803fb140: 32 # Yachuff from THPDec.c 18 | 0x803fb160: 32 # Uachuff from THPDec.c 19 | 0x803fb180: 32 # Vachuff from THPDec.c 20 | 0x803fb1a0: 32 # Gbase from THPDec.c 21 | 0x803fb1c0: 32 # Gwid from THPDec.c 22 | 0x803fb1e0: 32 # Gq from THPDec.c 23 | 0x80271CA0: 32 # CardData from CARDUnlock.c 24 | # 0x802c38e0: 32 # ? __AXStudio from AXSPB.c 25 | # 0x8026ce20: 32 # ? __AXCompressorTable from AXComp.c 26 | 0x8038dde0: 32 # effectData from ModelGC.cpp 27 | # 0x80276A80: 32 # rawCaptureTexData from Material_GC.cpp 28 | # 0x80298020: 32 # XFontBitmap 29 | # 0x802DBC20: 32 # __THPIDCTWorkspace 30 | # 0x8036F760: 32 # materialIni from Material_GC.cpp 31 | # 0x8036F7A0: 16 # restorationTexObj 32 | # 0x803F33C0: 32 # lo$433 from View_GC.cpp 33 | # 0x803F3420: 32 # ortho_old from View_GC.cpp 34 | # 0x803FAFD8: 8 # bound_32KHz 35 | # 0x803FB4E0: 8 # timePadLast$863 from System_GC.cpp 36 | # 0x803FB4F0: 8 # timeDiscClosed$866 from System_GC.cpp -------------------------------------------------------------------------------- /old_ppcdis/config/dol.lcf: -------------------------------------------------------------------------------- 1 | MEMORY 2 | { 3 | text : origin = 0x80003100 4 | forcestrip : origin = 0 5 | } 6 | 7 | SECTIONS 8 | { 9 | GROUP: 10 | { 11 | .init ALIGN(0x20) : {} 12 | extab ALIGN(0x20) : {} 13 | extabindex ALIGN(0x20) : {} 14 | .text ALIGN(0x20) : {} 15 | .ctors ALIGN(0x20) : {} 16 | .dtors ALIGN(0x20) : {} 17 | .BINARY ALIGN(0x20) : {} 18 | .rodata ALIGN(0x20) : {} 19 | .data ALIGN(0x20) : {} 20 | .bss ALIGN(0x20) : {} 21 | .sdata ALIGN(0x20) : {} 22 | .sbss ALIGN(0x20) : {} 23 | .sdata2 ALIGN(0x20) : {} 24 | .sbss2 ALIGN(0x20) : {} 25 | .stack ALIGN(0x100) : {} 26 | } > text 27 | GROUP:{ 28 | forcestrip ALIGN(0x20):{} 29 | } > forcestrip 30 | 31 | _stack_addr = (_f_sbss2 + SIZEOF(.sbss2) + 65536 + 0x7) & ~0x7; 32 | _stack_end = _f_sbss2 + SIZEOF(.sbss2); 33 | _db_stack_addr = (_stack_addr + 0x2000); 34 | _db_stack_end = _stack_addr; 35 | __ArenaLo = (_db_stack_addr + 0x1f) & ~0x1f; 36 | __ArenaHi = 0x81700000; 37 | _eti_init_info = 0x80005658; 38 | } 39 | 40 | FORCEFILES 41 | { 42 | PPCDIS_FORCEFILES 43 | } 44 | 45 | __dummy_str = 0; 46 | __dummy_float = 0; 47 | __dummy_double = 0; 48 | __dummy_pointer = 0; -------------------------------------------------------------------------------- /old_ppcdis/config/dol.yml: -------------------------------------------------------------------------------- 1 | path: orig/main.dol 2 | r13: 0x803fb860 3 | r2: 0x804035a0 4 | 5 | section_defs: 6 | text: 7 | - name: .init 8 | - name: .text 9 | data: 10 | - name: extab 11 | attr: a 12 | - name: extabindex 13 | attr: a 14 | - name: .ctors 15 | balign: 0 16 | - name: .dtors 17 | balign: 0 18 | - name: .rodata 19 | - name: .data 20 | - name: .sdata 21 | - name: .sdata2 22 | bss: 23 | - name: .bss 24 | - name: .sbss 25 | - name: .sbss2 26 | nobits: true 27 | 28 | label_prefix: ".L" 29 | -------------------------------------------------------------------------------- /old_ppcdis/config/file_flags.yml: -------------------------------------------------------------------------------- 1 | 2 | 3 | # any files that have extra flags are placed here with the flags 4 | # these flags will be added to the default flags 5 | 6 | common/gc/THPAudioDecode.c: 7 | .flags: "-lang c" 8 | 9 | Dolphin/os/__start.c: 10 | .flags: "-lang c" 11 | .compiler: "1.2.5" 12 | 13 | Runtime/abort_exit.c: 14 | .flags: "-lang=c" -------------------------------------------------------------------------------- /old_ppcdis/orig/main.dol.sha1: -------------------------------------------------------------------------------- 1 | c398adeba17e80b18e7b25d13dbc30c2939479c5 *out/main.dol -------------------------------------------------------------------------------- /old_ppcdis/requirements.txt: -------------------------------------------------------------------------------- 1 | -r ./tools/ppcdis/requirements.txt 2 | 3 | ninja_syntax 4 | prettytable -------------------------------------------------------------------------------- /old_ppcdis/tools/ppcdis/LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Seeky 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /old_ppcdis/tools/ppcdis/analyser.py: -------------------------------------------------------------------------------- 1 | """ 2 | Analyser for initial project creation 3 | """ 4 | 5 | from argparse import ArgumentParser 6 | 7 | from ppcdis import Analyser, load_binary_yml 8 | 9 | if __name__ == "__main__": 10 | hex_int = lambda s: int(s, 16) 11 | parser = ArgumentParser(description="Analyse a binary for its labels and relocations") 12 | parser.add_argument("binary_path", type=str, help="Binary input yml path") 13 | parser.add_argument("labels_path", type=str, help="Labels pickle output path") 14 | parser.add_argument("relocs_path", type=str, help="Relocs pickle output path") 15 | parser.add_argument("-l", "--extra-labels", nargs='+', help="List of extra label paths") 16 | parser.add_argument("-o", "--overrides", help="Overrides yml path") 17 | parser.add_argument("--thorough", action="store_true", help="Thorough pointer following") 18 | parser.add_argument("-q", "--quiet", action="store_true", help="Don't print log") 19 | args = parser.parse_args() 20 | 21 | binary = load_binary_yml(args.binary_path) 22 | 23 | anl = Analyser(binary, args.overrides, args.extra_labels, args.thorough, args.quiet) 24 | anl.output(args.labels_path, args.relocs_path) 25 | -------------------------------------------------------------------------------- /old_ppcdis/tools/ppcdis/assetinc.py: -------------------------------------------------------------------------------- 1 | """ 2 | Generate an array include from an asset 3 | """ 4 | 5 | from argparse import ArgumentParser 6 | 7 | from ppcdis import format_bytes 8 | 9 | if __name__ == "__main__": 10 | hex_int = lambda s: int(s, 16) 11 | parser = ArgumentParser(description="Rip an asset from a binary") 12 | parser.add_argument("asset_path", type=str, help="Binary asset input path") 13 | parser.add_argument("out_path", type=str, help="Include file output path") 14 | parser.add_argument("-w", "--width", type=str, default=16, help="Output line width in bytes") 15 | args = parser.parse_args() 16 | 17 | # Load asset 18 | with open(args.asset_path, 'rb') as f: 19 | dat = f.read() 20 | 21 | # Make text 22 | txt = format_bytes(dat, args.width) 23 | 24 | # Output include 25 | with open(args.out_path, 'w') as f: 26 | f.write(txt) 27 | -------------------------------------------------------------------------------- /old_ppcdis/tools/ppcdis/assetrip.py: -------------------------------------------------------------------------------- 1 | """ 2 | Rips an asset from a binary 3 | """ 4 | 5 | from argparse import ArgumentParser 6 | 7 | from ppcdis import load_binary_yml, rip_asset 8 | 9 | if __name__ == "__main__": 10 | hex_int = lambda s: int(s, 16) 11 | parser = ArgumentParser(description="Rip an asset from a binary") 12 | parser.add_argument("binary_path", type=str, help="Binary input yml path") 13 | parser.add_argument("start_addr", type=hex_int, help="Asset start address") 14 | parser.add_argument("end_addr", type=hex_int, help="Asset end address") 15 | parser.add_argument("out_path", type=str, help="Binary output path") 16 | args = parser.parse_args() 17 | 18 | # Read asset 19 | binary = load_binary_yml(args.binary_path) 20 | dat = rip_asset(binary, args.start_addr, args.end_addr) 21 | 22 | # Output 23 | with open(args.out_path, 'wb') as f: 24 | f.write(dat) 25 | -------------------------------------------------------------------------------- /old_ppcdis/tools/ppcdis/binarydiff.py: -------------------------------------------------------------------------------- 1 | """ 2 | Diffs the sections and relocations (where possible) of a dol/rel file 3 | """ 4 | 5 | from argparse import ArgumentParser 6 | import colorama as col 7 | 8 | from ppcdis import diff_secs, diff_relocs, load_binary_yml, RelReader 9 | 10 | if __name__ == "__main__": 11 | hex_int = lambda s: int(s, 16) 12 | parser = ArgumentParser(description="Diff the sections and relocations of dol/rel files") 13 | parser.add_argument("good", type=str, help="Path to good binary yml") 14 | parser.add_argument("test", type=str, help="Path to test binary") 15 | parser.add_argument("-n", "--max-reloc-diffs", type=int, default=-1, 16 | help="Maximum number of rel relocation diffs to print") 17 | args = parser.parse_args() 18 | 19 | # Init colorama 20 | col.init() 21 | 22 | # Load binaries 23 | good = load_binary_yml(args.good) 24 | test = good.load_other(args.test) 25 | 26 | # Do diff 27 | ret = diff_secs(good, test) 28 | if not ret and isinstance(good, RelReader): 29 | diff_relocs(good, test, args.max_reloc_diffs) 30 | -------------------------------------------------------------------------------- /old_ppcdis/tools/ppcdis/elf2dol.py: -------------------------------------------------------------------------------- 1 | """ 2 | Converts an ELF to a DOL file 3 | """ 4 | 5 | from argparse import ArgumentParser 6 | 7 | from ppcdis import elf_to_dol 8 | 9 | if __name__ == "__main__": 10 | parser = ArgumentParser(description="Convert ELF to DOL") 11 | parser.add_argument("input", type=str, help="ELF input path") 12 | parser.add_argument("-o", "--out", type=str, help="DOL output path") 13 | args = parser.parse_args() 14 | 15 | in_path = args.input 16 | 17 | if args.out is None: 18 | if in_path.endswith(".elf"): 19 | out_path = in_path.replace(".elf", ".dol") 20 | else: 21 | out_path = in_path + ".dol" 22 | else: 23 | out_path = args.out 24 | 25 | elf_to_dol(in_path, out_path) 26 | -------------------------------------------------------------------------------- /old_ppcdis/tools/ppcdis/forceactivegen.py: -------------------------------------------------------------------------------- 1 | """ 2 | Add forceactive entries to an LCF file from relextern output 3 | """ 4 | 5 | from argparse import ArgumentParser 6 | 7 | from ppcdis import apply_forceactive, load_binary_yml 8 | 9 | if __name__ == "__main__": 10 | hex_int = lambda s: int(s, 16) 11 | parser = ArgumentParser(description="Add relextern labels to forceactive in an LCF file") 12 | parser.add_argument("lcf_path", type=str, help="LCF input path") 13 | parser.add_argument("binary_path", type=str, help="Binary input yml path") 14 | parser.add_argument("labels_path", type=str, help="Labels pickle input path") 15 | parser.add_argument("symbols_path", type=str, help="Symbols yml input path") 16 | parser.add_argument("externs_path", type=str, help="Extern abels pickle input path") 17 | parser.add_argument("out_path", type=str, help="LCF output path") 18 | args = parser.parse_args() 19 | 20 | with open(args.lcf_path) as f: 21 | txt = f.read() 22 | 23 | binary = load_binary_yml(args.binary_path) 24 | txt = apply_forceactive(binary, args.symbols_path, args.labels_path, args.externs_path, txt) 25 | 26 | with open(args.out_path, 'w') as f: 27 | f.write(txt) 28 | -------------------------------------------------------------------------------- /old_ppcdis/tools/ppcdis/forcefilesgen.py: -------------------------------------------------------------------------------- 1 | """ 2 | Add forcefiles entries to an LCF file 3 | """ 4 | 5 | from argparse import ArgumentParser 6 | 7 | from ppcdis import apply_forcefiles 8 | 9 | if __name__ == "__main__": 10 | hex_int = lambda s: int(s, 16) 11 | parser = ArgumentParser(description="Add forcefiles entries to an LCF file") 12 | parser.add_argument("lcf_path", type=str, help="LCF input path") 13 | parser.add_argument("out_path", type=str, help="LCF output path") 14 | parser.add_argument("forcefiles", type=str, nargs='*', help="LCF output path") 15 | args = parser.parse_args() 16 | 17 | with open(args.lcf_path) as f: 18 | txt = f.read() 19 | 20 | txt = apply_forcefiles(txt, args.forcefiles) 21 | 22 | with open(args.out_path, 'w') as f: 23 | f.write(txt) 24 | -------------------------------------------------------------------------------- /old_ppcdis/tools/ppcdis/include/macros.inc: -------------------------------------------------------------------------------- 1 | /* Register name macros */ 2 | .set r0, 0 3 | .set r1, 1 4 | .set r2, 2 5 | .set r3, 3 6 | .set r4, 4 7 | .set r5, 5 8 | .set r6, 6 9 | .set r7, 7 10 | .set r8, 8 11 | .set r9, 9 12 | .set r10, 10 13 | .set r11, 11 14 | .set r12, 12 15 | .set r13, 13 16 | .set r14, 14 17 | .set r15, 15 18 | .set r16, 16 19 | .set r17, 17 20 | .set r18, 18 21 | .set r19, 19 22 | .set r20, 20 23 | .set r21, 21 24 | .set r22, 22 25 | .set r23, 23 26 | .set r24, 24 27 | .set r25, 25 28 | .set r26, 26 29 | .set r27, 27 30 | .set r28, 28 31 | .set r29, 29 32 | .set r30, 30 33 | .set r31, 31 34 | .set f0, 0 35 | .set f1, 1 36 | .set f2, 2 37 | .set f3, 3 38 | .set f4, 4 39 | .set f5, 5 40 | .set f6, 6 41 | .set f7, 7 42 | .set f8, 8 43 | .set f9, 9 44 | .set f10, 10 45 | .set f11, 11 46 | .set f12, 12 47 | .set f13, 13 48 | .set f14, 14 49 | .set f15, 15 50 | .set f16, 16 51 | .set f17, 17 52 | .set f18, 18 53 | .set f19, 19 54 | .set f20, 20 55 | .set f21, 21 56 | .set f22, 22 57 | .set f23, 23 58 | .set f24, 24 59 | .set f25, 25 60 | .set f26, 26 61 | .set f27, 27 62 | .set f28, 28 63 | .set f29, 29 64 | .set f30, 30 65 | .set f31, 31 66 | .set qr0, 0 67 | .set qr1, 1 68 | .set qr2, 2 69 | .set qr3, 3 70 | .set qr4, 4 71 | .set qr5, 5 72 | .set qr6, 6 73 | .set qr7, 7 74 | -------------------------------------------------------------------------------- /old_ppcdis/tools/ppcdis/makesrc.py: -------------------------------------------------------------------------------- 1 | """ 2 | Disassembler for assembly code (re)generation 3 | """ 4 | 5 | from argparse import ArgumentParser 6 | 7 | from ppcdis import Disassembler, load_binary_yml 8 | from ppcdis.slices import load_slice_yaml 9 | 10 | if __name__ == "__main__": 11 | hex_int = lambda s: int(s, 16) 12 | parser = ArgumentParser(description="Disassemble a binary") 13 | parser.add_argument("binary_path", type=str, help="Binary input yml path") 14 | parser.add_argument("labels_path", type=str, help="Labels pickle input path") 15 | parser.add_argument("relocs_path", type=str, help="Relocs pickle input path") 16 | parser.add_argument("slices_path", type=str, help="Slices yml input path") 17 | parser.add_argument("source_name", type=str, help="Source file name") 18 | parser.add_argument("-m", "--symbol-map-path", type=str, help="Symbol map input path") 19 | parser.add_argument("-o", "--overrides", help="Overrides yml path") 20 | parser.add_argument("-q", "--quiet", action="store_true", help="Don't print log") 21 | parser.add_argument("-d", "--data", action="store_true", help="Include data") 22 | parser.add_argument("-p", "--base_path", type=str, default='', 23 | help="Base path to add to source paths in yml") 24 | args = parser.parse_args() 25 | 26 | binary = load_binary_yml(args.binary_path) 27 | sources = load_slice_yaml(args.slices_path, binary.sections, args.base_path) 28 | 29 | src = None 30 | for s in sources: 31 | if s.source == args.source_name: 32 | src = s 33 | break 34 | assert src is not None, f"Slices for {args.source_name} not found" 35 | 36 | dis = Disassembler(binary, args.labels_path, args.relocs_path, args.symbol_map_path, 37 | args.overrides, args.source_name, args.quiet) 38 | dis.output_skeleton(args.source_name, src, args.data) 39 | -------------------------------------------------------------------------------- /old_ppcdis/tools/ppcdis/orderfloats.py: -------------------------------------------------------------------------------- 1 | """ 2 | Generates a float/double order dummy for a file 3 | """ 4 | 5 | from argparse import ArgumentParser 6 | 7 | from ppcdis import load_binary_yml, order_floats 8 | 9 | if __name__ == "__main__": 10 | hex_int = lambda s: int(s, 16) 11 | parser = ArgumentParser(description="Generate a float/double order workaround") 12 | parser.add_argument("binary_path", type=str, help="Binary input yml path") 13 | parser.add_argument("start_addr", type=hex_int, help="Floats start address") 14 | parser.add_argument("end_addr", type=hex_int, help="Floats end address") 15 | parser.add_argument("out_path", type=str, help="Text output path") 16 | parser.add_argument("--double", action='store_true', help="Double mode") 17 | parser.add_argument("--sda", action='store_true', help="Signals floats should be in sdata2") 18 | parser.add_argument("--asm", action='store_true', help="Declare the floats in inline asm") 19 | args = parser.parse_args() 20 | 21 | binary = load_binary_yml(args.binary_path) 22 | 23 | txt = order_floats(binary, args.start_addr, args.end_addr, args.asm, args.sda, args.double) 24 | 25 | with open(args.out_path, 'w', encoding="shift-jis") as f: 26 | f.write(txt) 27 | -------------------------------------------------------------------------------- /old_ppcdis/tools/ppcdis/orderstrings.py: -------------------------------------------------------------------------------- 1 | """ 2 | Generates a string order dummy for a file 3 | """ 4 | 5 | from argparse import ArgumentParser 6 | 7 | from ppcdis import load_binary_yml, order_strings 8 | 9 | if __name__ == "__main__": 10 | hex_int = lambda s: int(s, 16) 11 | parser = ArgumentParser(description="Generate a string order workaround") 12 | parser.add_argument("binary_path", type=str, help="Binary input yml path") 13 | parser.add_argument("start_addr", type=hex_int, help="Stringbase start address") 14 | parser.add_argument("end_addr", type=hex_int, help="Stringbase end address") 15 | parser.add_argument("out_path", type=str, help="Text output path") 16 | parser.add_argument("--enc", "-e", type=str, default="utf8", 17 | help="String & output file encoding") 18 | parser.add_argument("--pool", "-p", action="store_true", 19 | help="Expect '-str pool' format strings") 20 | parser.add_argument("--sda", action='store_true', help="Signals strings should be in sdata2") 21 | args = parser.parse_args() 22 | 23 | binary = load_binary_yml(args.binary_path) 24 | 25 | txt = order_strings(binary, args.start_addr, args.end_addr, args.pool, args.enc, args.sda) 26 | 27 | with open(args.out_path, 'w', encoding=args.enc) as f: 28 | f.write(txt) 29 | -------------------------------------------------------------------------------- /old_ppcdis/tools/ppcdis/ppcdis/__init__.py: -------------------------------------------------------------------------------- 1 | from .analyser import Analyser 2 | from .disassembler import Disassembler 3 | from .assets import format_bytes, rip_asset 4 | from .binarybase import BinaryReader, BinarySection, SectionType 5 | from .binarydiff import diff_relocs, diff_secs 6 | from .binarydol import DolReader 7 | from .binaryrel import RelBinarySection, RelReader, RelReloc 8 | from .binaryyml import load_binary_yml 9 | from .disassembler import Disassembler 10 | from .elf2dol import elf_to_dol 11 | from .elf2rel import RelLinker 12 | from .fileutil import (dump_to_pickle, load_from_pickle, dump_to_yaml, load_from_yaml, 13 | dump_to_json_str) 14 | from .lcf import apply_forceactive, apply_forcefiles 15 | from .orderdata import order_floats, order_strings 16 | from .relextern import dump_rel_externs, label_rel_externs 17 | from .relocs import RelocGetter 18 | from .slices import (Slice, Source, SourceDesc, calc_progress_info, fill_sections, 19 | find_containing_source, load_slice_yaml, order_sources) 20 | from .symbols import LabelManager, SymbolGetter, lookup, reverse_lookup 21 | -------------------------------------------------------------------------------- /old_ppcdis/tools/ppcdis/ppcdis/assets.py: -------------------------------------------------------------------------------- 1 | """ 2 | Helpers for binary asset processing 3 | """ 4 | 5 | from .binarybase import BinaryReader 6 | 7 | def rip_asset(binary: BinaryReader, start_addr: int, end_addr: int) -> bytes: 8 | """Rips an asset from a binary""" 9 | 10 | return binary.read(start_addr, end_addr - start_addr) 11 | 12 | def format_bytes(dat: bytes, width: int) -> str: 13 | """Outputs data as a C byte array""" 14 | 15 | return ', \n'.join( 16 | ', '.join( 17 | f"0x{x:02x}" for x in dat[i:i+width] 18 | ) 19 | for i in range(0, len(dat), width) 20 | ) 21 | -------------------------------------------------------------------------------- /old_ppcdis/tools/ppcdis/ppcdis/fileutil.py: -------------------------------------------------------------------------------- 1 | """ 2 | YAML / JSON file helpers 3 | """ 4 | 5 | import json 6 | import pickle 7 | from typing import Dict 8 | 9 | import yaml 10 | try: 11 | from yaml import CLoader as Loader 12 | except ImportError: 13 | from yaml import Loader 14 | 15 | ######## 16 | # Yaml # 17 | ######## 18 | 19 | def dump_to_yaml(path: str, data): 20 | """Dumps an object to a yaml file""" 21 | 22 | with open(path, 'w') as f: 23 | f.write(yaml.dump(data)) 24 | 25 | def load_from_yaml(path: str, default=None): 26 | """Loads an object from a yaml file""" 27 | 28 | if default is None: 29 | default = {} 30 | with open(path) as f: 31 | ret = yaml.load(f.read(), Loader) 32 | if ret is None: 33 | ret = default 34 | return ret 35 | 36 | def load_from_yaml_str(s: str, default=None): 37 | """Loads an object from a yaml string""" 38 | 39 | if default is None: 40 | default = {} 41 | ret = yaml.load(s, Loader) 42 | if ret is None: 43 | ret = default 44 | return ret 45 | 46 | ########## 47 | # Pickle # 48 | ########## 49 | 50 | def dump_to_pickle(path: str, data: Dict): 51 | """Dumps an object to a pickle file""" 52 | 53 | with open(path, 'wb') as f: 54 | pickle.dump(data, f) 55 | 56 | def load_from_pickle(path: str) -> Dict: 57 | """Loads an object from a pickle file""" 58 | 59 | with open(path, 'rb') as f: 60 | return pickle.load(f) 61 | 62 | ######## 63 | # Json # 64 | ######## 65 | 66 | def dump_to_json_str(data: Dict): 67 | """Dumps an object to a json string""" 68 | 69 | return json.dumps(data) 70 | -------------------------------------------------------------------------------- /old_ppcdis/tools/ppcdis/ppcdis/lcf.py: -------------------------------------------------------------------------------- 1 | """ 2 | Tools for LCF preprocessing 3 | """ 4 | 5 | from typing import List 6 | 7 | from .binarybase import BinaryReader 8 | from .symbols import LabelManager, SymbolGetter 9 | 10 | def apply_forceactive(binary: BinaryReader, symbols_path: str, labels_path: str, externs_path: str, 11 | txt: str) -> str: 12 | """Add forceactive entries to an LCF file from relextern output""" 13 | 14 | sym = SymbolGetter(symbols_path, None, labels_path, binary) 15 | externs = LabelManager(externs_path) 16 | 17 | return txt.replace( 18 | "PPCDIS_FORCEACTIVE", 19 | '\n'.join( 20 | sym.get_name(addr) 21 | 22 | for addr in externs.get_addrs() 23 | if binary.contains_addr(addr) 24 | ) 25 | ) 26 | 27 | def apply_forcefiles(txt: str, files: List[str]) -> str: 28 | """Add forcefiles entries to an LCF file""" 29 | 30 | return txt.replace("PPCDIS_FORCEFILES", '\n'.join(files)) 31 | -------------------------------------------------------------------------------- /old_ppcdis/tools/ppcdis/ppcdis/overrides.py: -------------------------------------------------------------------------------- 1 | """ 2 | Handling of user-provided hints 3 | """ 4 | 5 | from abc import ABC, abstractmethod 6 | from typing import Dict, List 7 | 8 | from .fileutil import load_from_yaml 9 | 10 | class OverrideManager(ABC): 11 | """Class to handle user-provided information""" 12 | 13 | def __init__(self, path: str): 14 | # Load yml if given 15 | if path is not None: 16 | yml = load_from_yaml(path) 17 | else: 18 | yml = {} 19 | 20 | self.load_yml(yml) 21 | 22 | @abstractmethod 23 | def load_yml(self, yml: Dict): 24 | """Loads data from an overrides yaml file""" 25 | 26 | raise NotImplementedError 27 | 28 | def _make_ranges(self, ranges: List[List[int]]) -> List[range]: 29 | """Converts a list of start-end pairs into ranges""" 30 | 31 | return [ 32 | range(start, end) 33 | for start, end in ranges 34 | ] 35 | 36 | def _make_size_ranges(self, ranges: List[List[int]]) -> List[range]: 37 | """Converts a list of start-size pairs into ranges""" 38 | 39 | return [ 40 | range(start, start + size) 41 | for start, size in ranges 42 | ] 43 | 44 | def _check_range(self, ranges: List[range], val: int) -> bool: 45 | """Checks if any range in a list contains a value""" 46 | 47 | return any(val in r for r in ranges) 48 | 49 | def _find_ranges(self, ranges: List[range], val: int) -> List[range]: 50 | """Finds the ranges in a list containing a value""" 51 | 52 | return [r for r in ranges if val in r] 53 | -------------------------------------------------------------------------------- /old_ppcdis/tools/ppcdis/ppcdis/relextern.py: -------------------------------------------------------------------------------- 1 | """ 2 | Rel external label preprocessor 3 | """ 4 | 5 | from typing import List 6 | 7 | from .binarybase import SectionType 8 | from .binaryrel import RelReader, RelType 9 | from .symbols import LabelManager, LabelType 10 | from .analyser import AnalysisOverrideManager 11 | 12 | def label_rel_externs(dest: LabelManager, rel: RelReader): 13 | for rlc in rel.ordered_relocs: 14 | # Skip local relocs 15 | if rlc.target_module == rel.module_id: 16 | continue 17 | 18 | # Skip non-reference relocs 19 | if rlc.t in [RelType.RVL_NONE, RelType.RVL_SECT, RelType.RVL_STOP]: 20 | continue 21 | 22 | # Check known reloc type 23 | assert rlc.t in [RelType.ADDR32, RelType.ADDR16_LO, RelType.ADDR16_HA, RelType.REL24], \ 24 | f"Unsupported relocation type {rlc.t}" 25 | 26 | # Get target 27 | target = rel.get_reloc_target(rlc) 28 | 29 | # Set type 30 | if rel.find_section_containing(target).type == SectionType.TEXT: 31 | dest.set_type(target, LabelType.FUNCTION) 32 | else: 33 | dest.set_type(target, LabelType.DATA) 34 | 35 | def dump_rel_externs(path: str, rels: List[RelReader], overrides_path=None): 36 | # Get overrides 37 | ovr = AnalysisOverrideManager(overrides_path) 38 | 39 | # Get labels 40 | labels = LabelManager() 41 | for rel in rels: 42 | label_rel_externs(labels, rel) 43 | 44 | # Apply overrides 45 | for addr, t in ovr.get_forced_types(): 46 | labels.set_type(addr, t) 47 | 48 | # Output 49 | labels.output(path) 50 | -------------------------------------------------------------------------------- /old_ppcdis/tools/ppcdis/progress.py: -------------------------------------------------------------------------------- 1 | """ 2 | Utility for progress calculation 3 | """ 4 | 5 | from argparse import ArgumentParser 6 | 7 | from ppcdis import calc_progress_info, dump_to_json_str, load_binary_yml, load_slice_yaml 8 | 9 | PROGRESS_JSON_VERSION = 2 10 | 11 | if __name__ == "__main__": 12 | parser = ArgumentParser(description="Calculate progress info for a project") 13 | parser.add_argument("binary_path", type=str, help="Binary input yml path") 14 | parser.add_argument("labels_path", type=str, help="Labels pickle input path") 15 | parser.add_argument("slices_path", type=str, help="Slices yml input path") 16 | args = parser.parse_args() 17 | 18 | # Load data 19 | binary = load_binary_yml(args.binary_path) 20 | sources = load_slice_yaml(args.slices_path, binary.sections) 21 | 22 | decomp_slices_sizes, total_sizes, symbol_sizes = calc_progress_info(binary, sources, 23 | args.labels_path) 24 | 25 | # Output 26 | print(dump_to_json_str({ 27 | # Protocol version 28 | "version": PROGRESS_JSON_VERSION, 29 | # Size of all slices coming from C code in each section 30 | "decomp_slices_sizes": decomp_slices_sizes, 31 | # Size of all slices in each section 32 | "total_sizes": total_sizes, 33 | # Size of each symbol 34 | "symbol_sizes": symbol_sizes 35 | })) 36 | -------------------------------------------------------------------------------- /old_ppcdis/tools/ppcdis/pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = ["setuptools", "wheel", "setuptools-git-versioning"] 3 | build-backend = "setuptools.build_meta" 4 | 5 | [tool.setuptools-git-versioning] 6 | enabled = true 7 | -------------------------------------------------------------------------------- /old_ppcdis/tools/ppcdis/relextern.py: -------------------------------------------------------------------------------- 1 | """ 2 | Rel external label preprocessor 3 | """ 4 | 5 | from argparse import ArgumentParser 6 | 7 | from ppcdis import dump_rel_externs, load_binary_yml 8 | 9 | if __name__ == "__main__": 10 | parser = ArgumentParser(description="Analyse rel binaries for their external labels") 11 | parser.add_argument("output_path", type=str, help="Labels output path") 12 | parser.add_argument("binary_paths", type=str, nargs='+', help="Binary input yml paths") 13 | args = parser.parse_args() 14 | 15 | # Load rels 16 | rels = [ 17 | load_binary_yml(path) 18 | for path in args.binary_paths 19 | ] 20 | 21 | # Dump externs 22 | dump_rel_externs(args.output_path, rels) 23 | 24 | -------------------------------------------------------------------------------- /old_ppcdis/tools/ppcdis/requirements.txt: -------------------------------------------------------------------------------- 1 | colorama 2 | capstone 3 | pyelftools 4 | pylibyaml 5 | PyYAML 6 | -------------------------------------------------------------------------------- /old_ppcdis/tools/ppcdis/setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup 2 | 3 | setup( 4 | name='ppcdis', 5 | author="Seeky", 6 | classifiers=[ 7 | "License :: OSI Approved :: MIT License" 8 | ], 9 | packages=["ppcdis"], 10 | python_requires=">=3.8", 11 | install_requires=[ 12 | 'colorama', 13 | 'capstone', 14 | 'pyelftools', 15 | 'pylibyaml', 16 | 'PyYAML' 17 | ], 18 | ) 19 | -------------------------------------------------------------------------------- /old_ppcdis/tools/ppcdis/slices.py: -------------------------------------------------------------------------------- 1 | """ 2 | Helpers for disassembly splitting 3 | """ 4 | 5 | from argparse import ArgumentParser 6 | 7 | from ppcdis import (dump_to_json_str, find_containing_source, load_binary_yml, load_slice_yaml, 8 | order_sources) 9 | 10 | if __name__ == "__main__": 11 | hex_int = lambda s: int(s, 16) 12 | parser = ArgumentParser(description="Query a slice yml") 13 | parser.add_argument("binary_path", type=str, help="Binary input yml path") 14 | parser.add_argument("slices_path", type=str, help="Slices yml input path") 15 | parser.add_argument("-o", "--order-sources", action="store_true", 16 | help="Output the ordered source files in json") 17 | parser.add_argument("-c", "--containing", type=hex_int, 18 | help="Output the source containing an address") 19 | parser.add_argument("-p", "--base_path", type=str, default='', 20 | help="Base path to add to source paths in yml") 21 | args = parser.parse_args() 22 | 23 | # Load slices 24 | binary = load_binary_yml(args.binary_path) 25 | sources = load_slice_yaml(args.slices_path, binary.sections, args.base_path) 26 | 27 | if args.order_sources: 28 | assert args.containing is None, "Order sources mode and containing mode are incompatible" 29 | 30 | # Output source order 31 | sources = order_sources(sources) 32 | print(dump_to_json_str(sources)) 33 | 34 | elif args.containing is not None: 35 | assert not args.order_sources, "Order sources mode and containing mode are incompatible" 36 | 37 | sl = find_containing_source(sources, args.containing) 38 | print(dump_to_json_str(sl)) 39 | 40 | else: 41 | assert 0, "Either --order-sources or --containing must be used, see -h for more" 42 | -------------------------------------------------------------------------------- /old_ppcdis/tools/ppcdis/symbols.py: -------------------------------------------------------------------------------- 1 | """ 2 | Helpers for address naming 3 | """ 4 | 5 | from argparse import ArgumentParser 6 | 7 | from ppcdis import dump_to_json_str, load_binary_yml, load_from_yaml, lookup, reverse_lookup 8 | 9 | if __name__ == "__main__": 10 | parser = ArgumentParser(description="Query a symbols yml file") 11 | hex_int = lambda s: int(s, 16) 12 | parser.add_argument("symbol_map_path", type=str, help="Symbol map input path") 13 | parser.add_argument("--get-name", type=hex_int, help="Get symbol name for address") 14 | parser.add_argument("--get-addr", type=str, help="Get address for symbol name") 15 | parser.add_argument("-b", "--binary", type=str, help="Binary input yml path") 16 | parser.add_argument("-n", "--source-name", type=str, help="Source C/C++ file name") 17 | parser.add_argument("-r", "--readable", action="store_true", 18 | help="Output as text rather than json") 19 | args = parser.parse_args() 20 | 21 | assert (args.get_name, args.get_addr).count(None) == 1, \ 22 | "One of --get-name and --get-addr is required" 23 | 24 | # Load binary 25 | binary = load_binary_yml(args.binary).name if args.binary is not None else None 26 | 27 | # Load symbols 28 | yml = load_from_yaml(args.symbol_map_path) 29 | 30 | if args.get_addr is not None: 31 | addr = reverse_lookup(yml, binary, args.source_name, args.get_addr) 32 | if args.readable: 33 | assert addr is not None, "Not found" 34 | print(hex(addr)) 35 | else: 36 | print(dump_to_json_str(addr)) 37 | else: 38 | name = lookup(yml, binary, args.source_name, args.get_name) 39 | if args.readable: 40 | assert name is not None, "Not found" 41 | print(name) 42 | else: 43 | print(dump_to_json_str(name)) 44 | -------------------------------------------------------------------------------- /old_ppcdis/tools/sjis.py: -------------------------------------------------------------------------------- 1 | from argparse import ArgumentParser 2 | 3 | parser = ArgumentParser() 4 | parser.add_argument("input") 5 | parser.add_argument("output") 6 | args = parser.parse_args() 7 | 8 | with open(args.input, encoding="utf-8") as f: 9 | txt = f.read() 10 | 11 | with open(args.output, 'w', encoding="shift-jis") as f: 12 | f.write(txt) 13 | 14 | #with open(args.output, 'w', encoding="cp1252") as f: 15 | # f.write(txt) -------------------------------------------------------------------------------- /orig/GTYE69/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1superchip/ty-decomp/1853c53406e02413632abfdf56702dc70efb99c1/orig/GTYE69/.gitkeep -------------------------------------------------------------------------------- /src/Dolphin/__ppc_eabi_init.s: -------------------------------------------------------------------------------- 1 | #needed to decompile files with ctors 2 | # this is __init_cpp 3 | 4 | .include "macros.inc" 5 | 6 | .global func_801dc058 7 | func_801dc058: 8 | /* 801DC058 7C0802A6 */ mflr r0 9 | /* 801DC05C 90010004 */ stw r0, 4(r1) 10 | /* 801DC060 9421FFF0 */ stwu r1, -0x10(r1) 11 | /* 801DC064 93E1000C */ stw r31, 0xc(r1) 12 | /* 801DC068 3C608024 */ lis r3, _ctors@ha 13 | /* 801DC06C 3803C780 */ addi r0, r3, _ctors@l 14 | /* 801DC070 7C1F0378 */ mr r31, r0 15 | /* 801DC074 48000004 */ b lbl_801dc078 16 | lbl_801dc078: 17 | /* 801DC078 48000004 */ b lbl_801dc07c 18 | lbl_801dc07c: 19 | /* 801DC07C 48000010 */ b lbl_801dc08c 20 | lbl_801dc080: 21 | /* 801DC080 7D8803A6 */ mtlr r12 22 | /* 801DC084 4E800021 */ blrl 23 | /* 801DC088 3BFF0004 */ addi r31, r31, 0x4 24 | lbl_801dc08c: 25 | /* 801DC08C 819F0000 */ lwz r12, 0(r31) 26 | /* 801DC090 280C0000 */ cmplwi r12, 0 27 | /* 801DC094 4082FFEC */ bne+ lbl_801dc080 28 | /* 801DC098 80010014 */ lwz r0, 0x14(r1) 29 | /* 801DC09C 83E1000C */ lwz r31, 0xc(r1) 30 | /* 801DC0A0 38210010 */ addi r1, r1, 0x10 31 | /* 801DC0A4 7C0803A6 */ mtlr r0 32 | /* 801DC0A8 4E800020 */ blr -------------------------------------------------------------------------------- /src/Dolphin/linker_info.s: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /src/Dolphin/os/OSArena.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define ROUND(n, a) (((u32)(n) + (a)-1) & ~((a)-1)) 4 | #define TRUNC(n, a) (((u32)(n)) & ~((a)-1)) 5 | 6 | void* __OSArenaHi; 7 | void* __OSArenaLo = (void*)-1; 8 | 9 | void* OSGetArenaHi(void) { return __OSArenaHi; } 10 | 11 | void* OSGetArenaLo(void) { return __OSArenaLo; } 12 | 13 | void OSSetArenaHi(void* addr) { __OSArenaHi = addr; } 14 | 15 | void OSSetArenaLo(void* addr) { __OSArenaLo = addr; } 16 | 17 | void* OSAllocFromArenaLo(u32 size, u32 align) { 18 | void* ptr; 19 | u8* arenaLo; 20 | 21 | ptr = OSGetArenaLo(); 22 | arenaLo = ptr = (void*)ROUND(ptr, align); 23 | arenaLo += size; 24 | arenaLo = (u8*)ROUND(arenaLo, align); 25 | OSSetArenaLo(arenaLo); 26 | return ptr; 27 | } 28 | 29 | void* OSAllocFromArenaHi(u32 size, u32 align) { 30 | void* ptr; 31 | u8* arenaHi; 32 | 33 | arenaHi = OSGetArenaHi(); 34 | arenaHi = (u8*)TRUNC(arenaHi, align); 35 | arenaHi -= size; 36 | arenaHi = ptr = (void*)TRUNC(arenaHi, align); 37 | OSSetArenaHi(arenaHi); 38 | return ptr; 39 | } -------------------------------------------------------------------------------- /src/Dolphin/os/OSLink.c: -------------------------------------------------------------------------------- 1 | #define OS_MODULE_LIST_ADDR 0x800030C8 2 | #define OS_STRING_TABLE_ADDR 0x800030D0 3 | #define OS_BASE_CACHED 0x80003000 4 | 5 | struct OSModuleQueue { /* Relocatable Module Queue @ 800030c8 */ 6 | int* pFirst; 7 | int* pLast; 8 | }; 9 | 10 | struct OSModuleQueue __OSModuleInfoList : (OS_BASE_CACHED | OS_MODULE_LIST_ADDR); 11 | const void* __OSStringTable : (OS_BASE_CACHED | OS_STRING_TABLE_ADDR); 12 | 13 | void __OSModuleInit(void) 14 | { 15 | __OSModuleInfoList.pLast = 0; 16 | __OSModuleInfoList.pFirst = 0; 17 | __OSStringTable = 0; 18 | } -------------------------------------------------------------------------------- /src/Dolphin/os/__ppc_eabi_init.cpp: -------------------------------------------------------------------------------- 1 | #include "Dolphin/__ppc_eabi_init.h" 2 | #include "Dolphin/PPCArch.h" 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | void __OSPSInit(); 8 | void __OSCacheInit(); 9 | 10 | asm void __init_hardware(void) { 11 | // clang-format off 12 | nofralloc 13 | mfmsr r0 14 | ori r0, r0, 0x2000 15 | mtmsr r0 16 | 17 | mflr r31 18 | bl __OSPSInit 19 | bl __OSCacheInit 20 | mtlr r31 21 | blr 22 | // clang-format on 23 | } 24 | 25 | asm void __flush_cache(register void* address, register unsigned int size) { 26 | // clang-format off 27 | nofralloc 28 | lis r5, ~0 29 | ori r5, r5, ~14 30 | and r5, r5, r3 31 | subf r3, r5, r3 32 | add r4, r4, r3 33 | 34 | loop: 35 | dcbst r0, r5 36 | sync 37 | icbi r0, r5 38 | addic r5, r5, 8 39 | subic. r4, r4, 8 40 | bge loop 41 | isync 42 | blr 43 | // clang-format on 44 | } 45 | 46 | void __init_user() { __init_cpp(); } 47 | 48 | typedef void (*voidfunctionptr)(void); // pointer to function returning void 49 | __declspec(section ".init") extern voidfunctionptr _ctors[]; 50 | __declspec(section ".init") extern voidfunctionptr _dtors[]; 51 | 52 | void __init_cpp(void) { 53 | voidfunctionptr* constructor; 54 | 55 | /* 56 | * call static initializers 57 | */ 58 | for (constructor = _ctors; *constructor; constructor++) { 59 | (*constructor)(); 60 | } 61 | } 62 | 63 | void _ExitProcess(void) { PPCHalt(); } 64 | 65 | #ifdef __cplusplus 66 | } 67 | #endif -------------------------------------------------------------------------------- /src/Runtime/Gecko_ExceptionPPC.cp: -------------------------------------------------------------------------------- 1 | #include "__ppc_eabi_linker.h" 2 | #include "../src/Runtime/NMWException.h" 3 | 4 | #if __MWERKS__ 5 | #pragma exceptions on 6 | #endif 7 | 8 | typedef struct ProcessInfo { 9 | __eti_init_info* exception_info; 10 | char* TOC; 11 | int active; 12 | } ProcessInfo; 13 | 14 | static ProcessInfo fragmentinfo[1]; 15 | 16 | int __register_fragment(struct __eti_init_info* info, char* TOC) { 17 | ProcessInfo* f; 18 | int i; 19 | 20 | for (i = 0, f = fragmentinfo; i < 1; ++i, ++f) { 21 | if (f->active == 0) { 22 | f->exception_info = info; 23 | f->TOC = TOC; 24 | f->active = 1; 25 | return (i); 26 | } 27 | } 28 | 29 | return (-1); 30 | } 31 | 32 | void __unregister_fragment(int fragmentId) { 33 | ProcessInfo* f; 34 | if (fragmentId >= 0 && fragmentId < 1) { 35 | f = &fragmentinfo[fragmentId]; 36 | f->exception_info = 0; 37 | f->TOC = 0; 38 | f->active = 0; 39 | } 40 | } -------------------------------------------------------------------------------- /src/Runtime/NMWException.cp: -------------------------------------------------------------------------------- 1 | #include "../src/Runtime/NMWException.h" 2 | #pragma exceptions on 3 | 4 | class __partial_array_destructor { 5 | private: 6 | void* p; 7 | size_t size; 8 | size_t n; 9 | void* dtor; 10 | 11 | public: 12 | size_t i; 13 | 14 | __partial_array_destructor(void* array, size_t elementsize, size_t nelements, void* destructor) { 15 | p = array; 16 | size = elementsize; 17 | n = nelements; 18 | dtor = destructor; 19 | i = n; 20 | } 21 | 22 | ~__partial_array_destructor() { 23 | char* ptr; 24 | 25 | if (i < n && dtor) { 26 | for (ptr = (char*)p + size * i; i > 0; i--) { 27 | ptr -= size; 28 | DTORCALL_COMPLETE(dtor, ptr); 29 | } 30 | } 31 | } 32 | }; 33 | 34 | extern "C" void __construct_array(void* ptr, void* ctor, void* dtor, size_t size, size_t n) { 35 | __partial_array_destructor pad(ptr, size, n, dtor); 36 | char* p; 37 | 38 | for (pad.i = 0, p = (char*)ptr; pad.i < n; pad.i++, p += size) 39 | CTORCALL_COMPLETE(ctor, p); 40 | } 41 | 42 | extern "C" void __destroy_arr(void* block, void* dtor, size_t size, size_t n) { 43 | char* p; 44 | 45 | for (p = (char*)block + size * n; n > 0; n--) { 46 | p -= size; 47 | DTORCALL_COMPLETE(dtor, p); 48 | } 49 | } -------------------------------------------------------------------------------- /src/Runtime/NMWException.h: -------------------------------------------------------------------------------- 1 | #ifndef _NMWEXCEPTION 2 | #define _NMWEXCEPTION 3 | 4 | // #include 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | #define offsetof(type, member) ((size_t) & (((type*)0)->member)) 11 | 12 | /* These break 1.2.5 */ 13 | //typedef __typeof__(sizeof(0)) size_t; 14 | //typedef __typeof__((char*)0 - (char*)0) ptrdiff_t; 15 | typedef unsigned long size_t; 16 | typedef long ptrdiff_t; 17 | #ifndef NULL 18 | #define NULL 0L 19 | #endif 20 | 21 | #ifdef __cplusplus 22 | } 23 | #endif 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | #define CTORARG_TYPE int 30 | #define CTORARG_PARTIAL (0) 31 | #define CTORARG_COMPLETE (1) 32 | 33 | #define CTORCALL_COMPLETE(ctor, objptr) \ 34 | (((void (*)(void*, CTORARG_TYPE))ctor)(objptr, CTORARG_COMPLETE)) 35 | 36 | #define DTORARG_TYPE int 37 | 38 | #define DTORCALL_COMPLETE(dtor, objptr) (((void (*)(void*, DTORARG_TYPE))dtor)(objptr, -1)) 39 | 40 | typedef struct DestructorChain { 41 | struct DestructorChain* next; 42 | void* destructor; 43 | void* object; 44 | } DestructorChain; 45 | 46 | void __unregister_fragment(int fragmentID); 47 | int __register_fragment(struct __eti_init_info* info, char* TOC); 48 | void* __register_global_object(void* object, void* destructor, void* regmem); 49 | void __destroy_global_chain(void); 50 | 51 | #ifdef __cplusplus 52 | } 53 | #endif 54 | 55 | #endif // _NMWEXCEPTION 56 | -------------------------------------------------------------------------------- /src/Runtime/__init_cpp_exceptions.cpp: -------------------------------------------------------------------------------- 1 | #include "NMWException.h" 2 | #include "__ppc_eabi_linker.h" 3 | 4 | static int fragmentID = -2; 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | extern void __init_cpp_exceptions(void); 11 | extern void __fini_cpp_exceptions(void); 12 | extern void suspend(void); 13 | 14 | #ifdef __cplusplus 15 | } 16 | #endif 17 | 18 | /* clang-format off */ 19 | static asm char* GetR2() { 20 | nofralloc; 21 | mr r3, r2 22 | blr 23 | } 24 | /* clang-format on */ 25 | 26 | extern void __init_cpp_exceptions(void) { 27 | char* R2; 28 | if (fragmentID == -2) { 29 | 30 | R2 = GetR2(); 31 | 32 | /* HACK: TODO: _eti_init_info should be _eti_init_info, we can't use the appropriate name yet due to the 33 | * linker not being able to generate it*/ 34 | fragmentID = __register_fragment(_eti_init_info, R2); 35 | } 36 | } 37 | 38 | extern void __fini_cpp_exceptions(void) { 39 | if (fragmentID != -2) { 40 | __unregister_fragment(fragmentID); 41 | fragmentID = -2; 42 | } 43 | } 44 | 45 | __declspec(section 46 | ".ctors") static void* const __init_cpp_exceptions_reference = __init_cpp_exceptions; 47 | __declspec(section 48 | ".dtors") static void* const __destroy_global_chain_reference = __destroy_global_chain; 49 | __declspec(section 50 | ".dtors") static void* const __fini_cpp_exceptions_reference = __fini_cpp_exceptions; 51 | -------------------------------------------------------------------------------- /src/Runtime/__mem.c: -------------------------------------------------------------------------------- 1 | #include "../src/Runtime/string.h" 2 | 3 | void* memcpy(void* dst, const void* src, size_t n) { 4 | const char* p; 5 | char* q; 6 | int rev = ((unsigned long)src < (unsigned long)dst); 7 | 8 | if (!rev) { 9 | 10 | for (p = (const char*)src - 1, q = (char*)dst - 1, n++; --n;) 11 | *++q = *++p; 12 | 13 | } else { 14 | for (p = (const char*)src + n, q = (char*)dst + n, n++; --n;) 15 | *--q = *--p; 16 | } 17 | return (dst); 18 | } 19 | 20 | #define cps ((unsigned char*)src) 21 | #define cpd ((unsigned char*)dst) 22 | #define lps ((unsigned long*)src) 23 | #define lpd ((unsigned long*)dst) 24 | #define deref_auto_inc(p) *++(p) 25 | 26 | void __fill_mem(void* dst, int val, size_t n) { 27 | unsigned long v = (unsigned char)val; 28 | unsigned long i; 29 | 30 | cpd = ((unsigned char*)dst) - 1; 31 | 32 | if (n >= 32) { 33 | i = (~(unsigned long)dst) & 3; 34 | 35 | if (i) { 36 | n -= i; 37 | 38 | do 39 | deref_auto_inc(cpd) = v; 40 | while (--i); 41 | } 42 | 43 | if (v) 44 | v |= v << 24 | v << 16 | v << 8; 45 | 46 | lpd = ((unsigned long*)(cpd + 1)) - 1; 47 | 48 | i = n >> 5; 49 | 50 | if (i) 51 | do { 52 | deref_auto_inc(lpd) = v; 53 | deref_auto_inc(lpd) = v; 54 | deref_auto_inc(lpd) = v; 55 | deref_auto_inc(lpd) = v; 56 | deref_auto_inc(lpd) = v; 57 | deref_auto_inc(lpd) = v; 58 | deref_auto_inc(lpd) = v; 59 | deref_auto_inc(lpd) = v; 60 | } while (--i); 61 | 62 | i = (n & 31) >> 2; 63 | 64 | if (i) 65 | do 66 | deref_auto_inc(lpd) = v; 67 | while (--i); 68 | 69 | cpd = ((unsigned char*)(lpd + 1)) - 1; 70 | 71 | n &= 3; 72 | } 73 | 74 | if (n) 75 | do 76 | deref_auto_inc(cpd) = v; 77 | while (--n); 78 | 79 | return; 80 | } 81 | 82 | void* memset(void* str, int c, size_t n) { 83 | __fill_mem(str, c, n); 84 | return str; 85 | } -------------------------------------------------------------------------------- /src/Runtime/abort_exit.c: -------------------------------------------------------------------------------- 1 | // #include 2 | 3 | #define NULL ((void*)0) 4 | 5 | void __destroy_global_chain(void); 6 | void _ExitProcess(void); 7 | 8 | extern void (*_dtors[])(void); 9 | 10 | static void (*__console_exit)(void); 11 | void (*__stdio_exit)(void); 12 | static int __atexit_curr_func; 13 | int __aborting; 14 | 15 | static void (*__atexit_funcs[64])(void); 16 | 17 | void exit(int status) { 18 | int i; 19 | void (**dtor)(void); 20 | 21 | if (!__aborting) { 22 | __destroy_global_chain(); 23 | dtor = _dtors; 24 | while (*dtor != NULL) { 25 | (*dtor)(); 26 | dtor++; 27 | } 28 | if (__stdio_exit != NULL) { 29 | __stdio_exit(); 30 | __stdio_exit = NULL; 31 | } 32 | } 33 | while (__atexit_curr_func > 0) 34 | __atexit_funcs[--__atexit_curr_func](); 35 | if (__console_exit != NULL) { 36 | __console_exit(); 37 | __console_exit = NULL; 38 | } 39 | _ExitProcess(); 40 | } -------------------------------------------------------------------------------- /src/Runtime/global_destructor_chain.c: -------------------------------------------------------------------------------- 1 | #include "../src/Runtime/NMWException.h" 2 | 3 | 4 | 5 | DestructorChain* __global_destructor_chain; 6 | 7 | extern void* __register_global_object(void* object, void* destructor, void* regmem) { 8 | ((DestructorChain*)regmem)->next = __global_destructor_chain; 9 | ((DestructorChain*)regmem)->destructor = destructor; 10 | ((DestructorChain*)regmem)->object = object; 11 | __global_destructor_chain = (DestructorChain*)regmem; 12 | 13 | return object; 14 | } 15 | 16 | void __destroy_global_chain(void) { 17 | DestructorChain* iter; 18 | 19 | while ((iter=__global_destructor_chain) != 0) { 20 | __global_destructor_chain = iter->next; 21 | DTORCALL_COMPLETE(iter->destructor, iter->object); 22 | } 23 | } 24 | 25 | __declspec(section 26 | ".dtors") static void* const __destroy_global_chain_reference = __destroy_global_chain; -------------------------------------------------------------------------------- /src/Runtime/ptmf.c: -------------------------------------------------------------------------------- 1 | 2 | typedef struct PTMF { 3 | long this_delta; // delta to this pointer 4 | long vtbl_offset; // offset in vtable (-1: not a virtual function) 5 | union { 6 | void* func_addr; //nonvirtual function address 7 | long ventry_offset; // of virtual function entry in vtable 8 | } func_data; 9 | } PTMF; 10 | 11 | const PTMF __ptmf_null = {0, 0, 0}; 12 | 13 | /* clang-format off */ 14 | asm long __ptmf_test(register PTMF* ptmf) { 15 | nofralloc 16 | 17 | lwz r5, PTMF.this_delta(ptmf) 18 | lwz r6, PTMF.vtbl_offset(ptmf) 19 | lwz r7, PTMF.func_data(ptmf) 20 | li r3, 1 21 | cmpwi cr0, r5, 0 22 | cmpwi cr6, r6, 0 23 | cmpwi cr7, r7, 0 24 | bnelr cr0 25 | bnelr cr6 26 | bnelr cr7 27 | li r3, 0 28 | blr 29 | } 30 | 31 | asm long __ptmf_cmpr(register PTMF* ptmf, register PTMF* ptmf1) { 32 | nofralloc 33 | 34 | lwz r5, PTMF.this_delta(ptmf) 35 | lwz r6, PTMF.this_delta(ptmf1) 36 | lwz r7, PTMF.vtbl_offset(ptmf) 37 | lwz r8, PTMF.vtbl_offset(ptmf1) 38 | lwz r9, PTMF.func_data(ptmf) 39 | lwz r10, PTMF.func_data(ptmf1) 40 | li r3, 1 41 | cmpw cr0, r5, r6 42 | cmpw cr6, r7, r8 43 | cmpw cr7, r9, r10 44 | bnelr cr0 45 | bnelr cr6 46 | bnelr cr7 47 | li r3, 0 48 | blr 49 | } 50 | 51 | asm void __ptmf_scall(...) { 52 | nofralloc 53 | lwz r0, PTMF.this_delta(r12) 54 | lwz r11, PTMF.vtbl_offset(r12) 55 | lwz r12, PTMF.func_data(r12) 56 | add r3, r3, r0 57 | cmpwi r11, 0 58 | blt @1 59 | lwzx r12, r3, r12 60 | lwzx r12, r12, r11 61 | @1 62 | mtctr r12 63 | bctr 64 | } 65 | /* clang-format - on*/ 66 | -------------------------------------------------------------------------------- /src/Runtime/rand.c: -------------------------------------------------------------------------------- 1 | 2 | static unsigned long int next = 1; 3 | 4 | int rand(void) { 5 | next = (next * 0x41c64e6d) + 0x3039; 6 | return (next >> 16) & 0x7FFF; 7 | } 8 | -------------------------------------------------------------------------------- /src/Runtime/string.h: -------------------------------------------------------------------------------- 1 | #ifndef _STRING_H_ 2 | #define _STRING_H_ 3 | 4 | // #include 5 | 6 | #ifdef __cplusplus 7 | extern "C" { 8 | #endif 9 | 10 | #define offsetof(type, member) ((size_t) & (((type*)0)->member)) 11 | 12 | /* These break 1.2.5 */ 13 | //typedef __typeof__(sizeof(0)) size_t; 14 | //typedef __typeof__((char*)0 - (char*)0) ptrdiff_t; 15 | typedef unsigned long size_t; 16 | typedef long ptrdiff_t; 17 | #ifndef NULL 18 | #define NULL 0L 19 | #endif 20 | 21 | #ifdef __cplusplus 22 | } 23 | #endif 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | #pragma section code_type ".init" 30 | void* memcpy(void* dst, const void* src, size_t n); 31 | void* memset(void* dst, int val, size_t n); 32 | void __fill_mem(void* dst, int val, size_t n); 33 | #pragma section code_type 34 | 35 | size_t strlen(const char* s); 36 | char* strcpy(char* dest, const char* src); 37 | char* strncpy(char* dest, const char* src, size_t num); 38 | int strcmp(const char* s1, const char* s2); 39 | int strncmp(const char* s1, const char* s2, size_t n); 40 | char* strncat(char* dest, const char* src, size_t n); 41 | 42 | #ifdef __cplusplus 43 | } 44 | #endif 45 | 46 | #endif -------------------------------------------------------------------------------- /src/common/Debug.cpp: -------------------------------------------------------------------------------- 1 | #include "types.h" 2 | #include "common/Debug.h" 3 | 4 | Font* gpDebugFont; 5 | 6 | void Debug_InitModule(void) { 7 | gpDebugFont = NULL; 8 | } 9 | 10 | void Debug_DeinitModule(void) { 11 | 12 | } 13 | 14 | void Debug_SetFont(Font* mDebugFont) { 15 | gpDebugFont = mDebugFont; 16 | } 17 | -------------------------------------------------------------------------------- /src/common/Source/Crc.cpp: -------------------------------------------------------------------------------- 1 | #include "types.h" 2 | #include "common/Crc.h" 3 | 4 | static bool crcTableComputed = false; 5 | static int crcTable[0x100]; 6 | 7 | static void Crc_MakeTable(void) { 8 | uint c; 9 | // compute crcTable 10 | for (int i = 0; i < 256; i++) { 11 | c = i; 12 | for (int j = 0; j < 8; j++) { 13 | if (c & 1) { 14 | c = (c >> 1) ^ 0xEDB88320; 15 | } else { 16 | c >>= 1; 17 | } 18 | } 19 | crcTable[i] = c; 20 | } 21 | // set it to computed so it isn't computed again 22 | crcTableComputed = true; 23 | } 24 | 25 | uint Crc_Update(uint crc, const void* buf, int len) { 26 | if (!crcTableComputed) { // only compute CRC table if it hasn't been computed 27 | Crc_MakeTable(); 28 | } 29 | for (int i = 0; i < len; i++) { 30 | crc = crcTable[(crc ^ ((u8*)buf)[i]) & 0xff] ^ (crc >> 8); 31 | } 32 | return crc; 33 | } 34 | 35 | u32 Crc_Calculate(const void *buf, int len) { 36 | return Crc_Update(0xFFFFFFFF, buf, len) ^ 0xFFFFFFFF; 37 | } -------------------------------------------------------------------------------- /src/common/Source/Heap.cpp: -------------------------------------------------------------------------------- 1 | #include "common/Heap.h" 2 | #include "types.h" 3 | #include "Dolphin/os/OSAlloc.h" 4 | 5 | extern "C" int OSGetConsoleSimulatedMemSize(void); 6 | extern "C" void printf(char*, ...); 7 | extern "C" void exit(int); 8 | 9 | 10 | static bool heapInitialised = false; 11 | 12 | void Heap_InitModule(int arg0) { 13 | heapInitialised = true; 14 | } 15 | 16 | void Heap_DeinitModule(void) { 17 | heapInitialised = false; 18 | } 19 | 20 | /// @brief Returns the current amount of used memory 21 | /// @param None 22 | /// @return Current amount of used memory 23 | int Heap_MemoryUsed(void) { 24 | return OSGetConsoleSimulatedMemSize() - OSCheckHeap(0); 25 | } 26 | 27 | /// @brief Allocates a block of memory, does not use alignment 28 | /// @param size size of block to allocate 29 | /// @param alignment Unused parameter for alignment 30 | /// @return Allocated block of memory 31 | void* Heap_MemAllocAligned(int size, int alignment) { 32 | return OSAllocFromHeap(__OSCurrHeap, size); 33 | } 34 | 35 | /// @brief Frees an aligned memory block 36 | /// @param ptr Memory to free 37 | void Heap_MemFreeAligned(void* ptr) { 38 | OSFreeToHeap(__OSCurrHeap, ptr); 39 | } 40 | 41 | void* Heap_MemAlloc(int size) { 42 | int simulatedMemSize; 43 | void* pMem; 44 | 45 | pMem = OSAllocFromHeap(__OSCurrHeap, size); 46 | if (pMem == NULL) { 47 | printf("Heap Alloc Failed: %d bytes attempted, %d used\n", size, OSGetConsoleSimulatedMemSize() - OSCheckHeap(0)); 48 | } 49 | 50 | return pMem; 51 | } 52 | 53 | void Heap_MemFree(void* ptr) { 54 | OSFreeToHeap(__OSCurrHeap, ptr); 55 | } 56 | 57 | /// @brief Checks the heap 58 | /// @param file Filename to print 59 | /// @param lineNumber Line number to print 60 | /// @return Returns 0 if no error occurs otherwise exits the program 61 | int Heap_Check(char* file, int lineNumber) { 62 | if ((int)OSCheckHeap(0) == -1) { 63 | printf("\nCorrupt HEAP\n"); 64 | printf("%s Line: %d\n", file, lineNumber); 65 | exit(0); 66 | } 67 | 68 | return 0; 69 | } 70 | -------------------------------------------------------------------------------- /src/common/Source/QuatRotation.cpp: -------------------------------------------------------------------------------- 1 | #include "types.h" 2 | #include "common/QuatRotation.h" 3 | #include "common/StdMath.h" 4 | 5 | void QuatRotation::ConvertRotation(AxisRotation* pRotation) { 6 | float rot = pRotation->unk10; 7 | float sin = _table_sinf(rot * 0.5f); 8 | quat.x = sin * pRotation->rot.x; 9 | quat.y = sin * pRotation->rot.y; 10 | quat.z = sin * pRotation->rot.z; 11 | quat.w = _table_cosf(rot * 0.5f); 12 | } 13 | 14 | void QuatRotation::ConvertNormal(Vector* pNormal, float r) { 15 | float sin = _table_sinf(r * 0.5f); 16 | quat.x = sin * pNormal->x; 17 | quat.y = sin * pNormal->y; 18 | quat.z = sin * pNormal->z; 19 | quat.w = _table_cosf(r * 0.5f); 20 | } 21 | 22 | void QuatRotation::ConvertVector(Vector* pVector) { 23 | float vecMag = pVector->Magnitude(); 24 | if (vecMag > 0.000001f) { 25 | float norm = _table_sinf(vecMag * 0.5f) / vecMag; 26 | quat.x = norm * pVector->x; 27 | quat.y = norm * pVector->y; 28 | quat.z = norm * pVector->z; 29 | quat.w = _table_cosf(vecMag * 0.5f); 30 | } else { 31 | SetIdentity(); 32 | } 33 | } 34 | 35 | void QuatRotation::Multiply(QuatRotation *pQuaternion1, QuatRotation *pQuaternion2) { 36 | Vector sp0; 37 | Vector sp10; 38 | sp0.w = (pQuaternion2->quat.w * pQuaternion1->quat.w) - pQuaternion2->quat.Dot(&pQuaternion1->quat); 39 | sp0.Scale(&pQuaternion1->quat, pQuaternion2->quat.w); 40 | sp10.Scale(&pQuaternion2->quat, pQuaternion1->quat.w); 41 | sp0.Add(&sp10); 42 | sp10.Cross(&pQuaternion2->quat, &pQuaternion1->quat); 43 | sp0.Add((Vector*)&sp0, &sp10); // cast is needed to force stack usage 44 | quat = sp0; 45 | quat.w = sp0.w; 46 | } 47 | -------------------------------------------------------------------------------- /src/common/Source/Str.cpp: -------------------------------------------------------------------------------- 1 | #include "types.h" 2 | #include "common/Str.h" 3 | #include "Dolphin/stl.h" 4 | 5 | static char buffer[STR_BUFFER_SIZE]; 6 | 7 | char gNullStr[4] = ""; 8 | 9 | bool gAssertBool; 10 | static int bufferIndex = 0; 11 | 12 | extern "C" int strlen(char*); 13 | 14 | // bufferIndex inline 15 | 16 | // Returns a pointer to the formatted string 17 | // fmt is the format "%s" 18 | char* Str_Printf(char* fmt, ...) { 19 | // this function can overflow the string buffer 20 | // bufferIndex is set to 0 when (bufferIndex + 0x400) > STR_BUFFER_SIZE 21 | // meaning that if bufferIndex <= (STR_BUFFER_SIZE - 0x400) before printing a string 22 | // longer than the remaining space in the buffer (STR_BUFFER_SIZE - bufferIndex) 23 | // the buffer overflows 24 | 25 | char* currStr = &buffer[bufferIndex]; 26 | va_list args; 27 | 28 | va_start(args, fmt); 29 | vsprintf(currStr, fmt, args); 30 | 31 | int len = strlen(currStr); 32 | bufferIndex += (len + 0x10) & ~0xF; 33 | if (bufferIndex + 0x400 > STR_BUFFER_SIZE) { 34 | bufferIndex = 0; 35 | } 36 | 37 | va_end(args); 38 | return currStr; 39 | } 40 | 41 | char* Str_CopyString(char* string, int len) { 42 | // same buffer overflow as Str_Printf 43 | 44 | char* bufString = &buffer[bufferIndex]; 45 | int idx = 0; 46 | 47 | while (idx < len && string[idx] != '\0') { 48 | bufString[idx] = string[idx]; 49 | idx++; 50 | } 51 | 52 | bufString[idx] = '\0'; 53 | 54 | // round up to a multiple of 16 55 | // if idx is a multiple of 16, idx is rounded to the next (0 -> 16, 16 -> 32) 56 | bufferIndex += (idx + 0x10) & ~(0x10 - 1); 57 | 58 | if (bufferIndex + 0x400 > STR_BUFFER_SIZE) { 59 | bufferIndex = 0; 60 | } 61 | 62 | return bufString; 63 | } 64 | 65 | char* Str_FindChar(char* str, int val) { 66 | while (*str != '\0') { 67 | if (*str == val) { 68 | return str; 69 | } 70 | str++; 71 | } 72 | return NULL; 73 | } 74 | -------------------------------------------------------------------------------- /src/common/Source/Timer.cpp: -------------------------------------------------------------------------------- 1 | #include "common/Timer.h" 2 | #include "Dolphin/os.h" 3 | 4 | void Timer_GetSystemTime(TimerInfo* pTimerInfo) { 5 | OSCalendarTime calendarTime; 6 | 7 | OSTicksToCalendarTime(OSGetTime(), &calendarTime); 8 | pTimerInfo->hours = calendarTime.hour; 9 | pTimerInfo->minutes = calendarTime.min; 10 | pTimerInfo->seconds = calendarTime.sec; 11 | pTimerInfo->milliseconds = calendarTime.msec; 12 | pTimerInfo->day = calendarTime.mday; 13 | pTimerInfo->month = calendarTime.mon; 14 | pTimerInfo->year = calendarTime.year; 15 | }; 16 | 17 | int Timer_GetDHMSInSeconds(TimerInfo* pTimerInfo) { 18 | int ret = pTimerInfo->day * DAYS_TO_SECONDS; 19 | ret += pTimerInfo->hours * HOURS_TO_SECONDS; 20 | ret += pTimerInfo->minutes * MINUTES_TO_SECONDS; 21 | ret += pTimerInfo->seconds; 22 | return ret; 23 | } 24 | 25 | inline void Timer_SetDHMSInSeconds(TimerInfo* pTimerInfo, int time) { 26 | pTimerInfo->seconds = time % 60; 27 | time /= 60; 28 | pTimerInfo->minutes = time % 60; 29 | time /= 60; 30 | pTimerInfo->hours = time % 24; 31 | pTimerInfo->day = time / 24; 32 | } 33 | 34 | void Timer_GetDifference(TimerInfo* pTimeDiff, TimerInfo* param_2, TimerInfo* param_3) { 35 | int time = Timer_GetDHMSInSeconds(param_2); 36 | int time2 = Timer_GetDHMSInSeconds(param_3); 37 | 38 | pTimeDiff->milliseconds = 0; 39 | pTimeDiff->month = 0; 40 | pTimeDiff->year = 0; 41 | Timer_SetDHMSInSeconds(pTimeDiff, time2 - time); 42 | return; 43 | } 44 | -------------------------------------------------------------------------------- /src/common/gc/system_extras.cpp: -------------------------------------------------------------------------------- 1 | #include "types.h" 2 | #include "common/system_extras.h" 3 | 4 | extern u8 __lower_map[256]; 5 | extern u8 __upper_map[256]; 6 | 7 | inline char GetLower(s8 s) { 8 | return (s == -1) ? -1 : __lower_map[s & 0xff]; 9 | } 10 | inline char GetUpper(s8 s) { 11 | return (s == -1) ? -1 : __upper_map[s & 0xff]; 12 | } 13 | 14 | extern "C" int stricmp(char* s1, char* s2) { 15 | while (1) { 16 | char s = GetLower(*s1++); 17 | char s_ = GetLower(*s2++); 18 | if (s < s_) { 19 | return -1; 20 | } 21 | if (s > s_) { 22 | return 1; 23 | } 24 | if (s == '\0') return 0; 25 | } 26 | } 27 | 28 | extern "C" int strcmpi(char* s1, char* s2) { 29 | while (1) { 30 | char s = GetLower(*s1++); 31 | char s_ = GetLower(*s2++); 32 | if (s < s_) { 33 | return -1; 34 | } 35 | if (s > s_) { 36 | return 1; 37 | } 38 | if (s == '\0') return 0; 39 | } 40 | } 41 | 42 | int strnicmp(const char* s1, const char* s2, int n) { 43 | for (int i = 0; i < n; i++) { 44 | char s = GetLower(*s1++); 45 | char s_ = GetLower(*s2++); 46 | if (s < s_) { 47 | return -1; 48 | } 49 | if (s > s_) { 50 | return 1; 51 | } 52 | if (s == '\0') { 53 | return 0; 54 | } 55 | } 56 | return 0; 57 | } 58 | 59 | extern "C" char* strlwr(char* s1) { 60 | char* s = s1; 61 | while (*s != '\0') { 62 | *s = GetLower(*s); 63 | s++; 64 | } 65 | return s1; 66 | } 67 | 68 | extern "C" char* strupr(char* s1) { 69 | char* s = s1; 70 | while (*s != '\0') { 71 | *s = GetUpper(*s); 72 | s++; 73 | } 74 | return s1; 75 | } 76 | -------------------------------------------------------------------------------- /src/ty/source/LensFlare.cpp: -------------------------------------------------------------------------------- 1 | #include "types.h" 2 | #include "common/Model.h" 3 | #include "common/Material.h" 4 | #include "ty/LensFlare.h" 5 | #include "common/System_GC.h" 6 | #include "common/Blitter.h" 7 | 8 | // https://decomp.me/scratch/DcZyE 9 | 10 | static char* LF_TEXTURE_NAME = "fx_081"; 11 | static char* LF_SUNTEXTURE_NAME = "fx_083"; 12 | 13 | static Material* pMaterial; 14 | static Material* pSunMaterial; 15 | static ZCheckRequest* pZRequest; 16 | static int wait; 17 | 18 | static ZCheckRequest zRequestLast; 19 | 20 | /* 21 | // these are unused variables that would have been used by code that was either stripped or unimplemented 22 | static Vector centre = {320.0f, 256.0f, 0.0f, 0.0f}; 23 | float targetBlend = 1.0f; 24 | static int flares[7] = { 0, 1, 2, 3, 2, 1, 0 }; // i think this are actually 7 not 8 25 | static Blitter_Image lensFlareImages[4]; 26 | static Blitter_Image sunImage; 27 | static float scales[7] = { 28 | 0.5f, 1.7f, 1.0f, 1.0f, 1.3f, 2.0f, 3.0f 29 | }; 30 | */ 31 | 32 | void LensFlare_Init(void) { 33 | wait = 0; 34 | if (pMaterial == NULL) { 35 | pMaterial = Material::Create(LF_TEXTURE_NAME); 36 | pSunMaterial = Material::Create(LF_SUNTEXTURE_NAME); 37 | pZRequest = System_CreateZRequest(); 38 | pZRequest->depth = 1.0f; 39 | } 40 | } 41 | 42 | void LensFlare_Deinit(void) { 43 | if (pMaterial != NULL) { 44 | pSunMaterial->Destroy(); 45 | pSunMaterial = NULL; 46 | pMaterial->Destroy(); 47 | pMaterial = NULL; 48 | System_DestroyZRequest(pZRequest); 49 | pZRequest = NULL; 50 | } 51 | } 52 | 53 | void LensFlare_Update(void) { 54 | if (wait <= 0) { 55 | zRequestLast = *pZRequest; 56 | return; 57 | } 58 | wait--; 59 | } 60 | 61 | void LensFlare_Draw(void) { 62 | return; 63 | } 64 | -------------------------------------------------------------------------------- /src/ty/source/MessageMap.cpp: -------------------------------------------------------------------------------- 1 | #include "types.h" 2 | #include "ty/MessageMap.h" 3 | 4 | extern "C" int stricmp(char*, char*); 5 | 6 | // Unused / Stripped 7 | char* MessageMap::GetStringFromId(int id) const { 8 | int unk = ids; 9 | if ((unk <= id) && (id < unk + nmbrOfMessages)) { 10 | return ppMessages[id - unk]; 11 | } 12 | return 0; 13 | } 14 | 15 | int MessageMap::GetIdFromString(char* pString) const { 16 | for (int i = 0; i < nmbrOfMessages; i++) { 17 | if (stricmp(pString, ppMessages[i]) == 0) { 18 | return i + ids; 19 | } 20 | } 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /src/ty/source/Mist.cpp: -------------------------------------------------------------------------------- 1 | #include "ty/Mist.h" 2 | #include "ty/global.h" 3 | #include "common/Model.h" 4 | 5 | Vector* GameCamera_GetPos(void); 6 | 7 | static Model* envMist = NULL; 8 | static Material* envMat = NULL; 9 | 10 | void Mist_Init(void) { 11 | if (gb.level.bDisplayMist) { 12 | if (envMist == NULL) { 13 | envMist = Model::Create("env_mist", NULL); 14 | envMist->renderType = 3; 15 | } 16 | if (envMat == NULL) { 17 | envMat = Material::Create("mist_01"); 18 | } 19 | } 20 | } 21 | 22 | void Mist_Deinit(void) { 23 | if (envMist != NULL) { 24 | envMist->Destroy(); 25 | envMist = NULL; 26 | } 27 | if (envMat != NULL) { 28 | envMat->Destroy(); 29 | envMat = NULL; 30 | } 31 | } 32 | 33 | void Mist_Update(void) { 34 | Vector trans; 35 | Vector scale; 36 | if (gb.level.bDisplayMist) { 37 | envMist->matrices[0].SetIdentity(); 38 | trans = *GameCamera_GetPos(); 39 | trans.y = 0.0f; 40 | envMist->matrices[0].SetTranslation(&trans); 41 | scale.Set(3.0f, 1.5f, 3.0f); 42 | envMist->matrices[0].Scale(&scale); 43 | } 44 | } 45 | 46 | void Mist_Draw(void) { 47 | if (gb.level.bDisplayMist) { 48 | envMist->Draw(NULL); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/ty/source/camera/GameCamera.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1superchip/ty-decomp/1853c53406e02413632abfdf56702dc70efb99c1/src/ty/source/camera/GameCamera.cpp -------------------------------------------------------------------------------- /src/ty/source/heatflare.cpp: -------------------------------------------------------------------------------- 1 | #include "ty/heatflare.h" 2 | #include "common/PtrListDL.h" 3 | #include "common/Material.h" 4 | #include "ty/global.h" 5 | 6 | Material* pCaptureMaterial; 7 | static PtrListDL heatFlares; 8 | static bool bHeatFlares = false; 9 | static bool bScreenGrabbed = false; 10 | 11 | void HeatFlare_LoadResources(void) { 12 | pCaptureMaterial = Material::Create("capture"); 13 | } 14 | 15 | void HeatFlare_Init(void) { 16 | if (!bHeatFlares) { 17 | heatFlares.Init(200, sizeof(HeatFlareInfo)); 18 | bHeatFlares = true; 19 | } 20 | } 21 | 22 | void HeatFlare_Deinit(void) { 23 | if (bHeatFlares) { 24 | heatFlares.Deinit(); 25 | bHeatFlares = false; 26 | } 27 | } 28 | 29 | // Stripped function 30 | HeatFlareInfo* HeatFlare_Add(Vector* pVec, float f1) { 31 | if (!bHeatFlares) { 32 | return NULL; 33 | } 34 | 35 | if (!heatFlares.IsFull()) { 36 | HeatFlareInfo* pFlare = heatFlares.GetNextEntry(); 37 | 38 | pFlare->unk0 = *pVec; 39 | pFlare->unk0.y += 200.0f; 40 | pFlare->unk10 = f1; 41 | pFlare->unk14 = 0.0f; 42 | pFlare->unk18 = 1; 43 | 44 | return pFlare; 45 | } else { 46 | return NULL; 47 | } 48 | } 49 | 50 | // Stripped function 51 | // Enables a HeatFlare? 52 | // void HeatFlare_On(void* pVoidHeatFlare, int a1) { 53 | // if (bHeatFlares) { 54 | // HeatFlareInfo* pHeatFlare = (HeatFlareInfo*)pVoidHeatFlare; 55 | // pHeatFlare->unk18 = a1; 56 | // } 57 | // } 58 | 59 | void HeatFlare_Update(void) { 60 | bScreenGrabbed = false; 61 | if (bHeatFlares) { 62 | 63 | } 64 | } 65 | 66 | void HeatFlare_Draw(void) { 67 | if (!bHeatFlares) { 68 | return; 69 | } 70 | } 71 | 72 | void HeatFlare_Unlock(void) { 73 | return; 74 | } 75 | -------------------------------------------------------------------------------- /src/ty/source/props/DDACheckpoint.cpp: -------------------------------------------------------------------------------- 1 | #include "types.h" 2 | #include "ty/props/DDACheckpoint.h" 3 | #include "ty/DDA.h" 4 | 5 | static GameObjDesc ddaCheckpointDesc; 6 | static ModuleInfo ddaCheckpointModule; 7 | 8 | void DDACheckpoint_LoadResources(KromeIni* pIni) { 9 | ddaCheckpointDesc.Init(&ddaCheckpointModule, "DDACheckpoint", "DDACheckpoint", 0, 0); 10 | objectManager.AddDescriptor(&ddaCheckpointDesc); 11 | } 12 | 13 | void DDACheckpoint::Init(GameObjDesc* pDesc) { 14 | GameObject::Init(pDesc); 15 | Number = -1; 16 | } 17 | 18 | bool DDACheckpoint::LoadLine(KromeIniLine* pLine) { 19 | return LoadLevel_LoadInt(pLine, "Number", &Number) || GameObject::LoadLine(pLine); 20 | } 21 | 22 | void DDACheckpoint::Message(MKMessage* pMsg) { 23 | switch (pMsg->unk0) { 24 | case MSG_Activate: 25 | dda.NewCheckpoint(Number); 26 | break; 27 | default: 28 | GameObject::Message(pMsg); 29 | break; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/ty/source/props/RangStone.cpp: -------------------------------------------------------------------------------- 1 | #include "ty/props/RangStone.h" 2 | #include "ty/GameObjectManager.h" 3 | #include "ty/global.h" 4 | 5 | static ModuleInfo RangStoneModuleInfo; 6 | static StaticPropDescriptor RangStoneDesc; 7 | 8 | static char* szRangObj = "A_rang"; 9 | 10 | void RangStone_LoadResources(KromeIni* pIni) { 11 | RangStoneDesc.Init(&RangStoneModuleInfo, "prop_0531_RangStone", "RangStone", 1, 0); 12 | RangStoneDesc.Load(pIni); 13 | objectManager.AddDescriptor(&RangStoneDesc); 14 | } 15 | 16 | void RangStone::Init(GameObjDesc* pDesc) { 17 | collide = true; 18 | collisionInfo.Enable(); 19 | StaticProp::Init(pDesc); 20 | lodManager.Init(pModel, 0, &GetDesc()->lodDesc); 21 | OnSuccess.Init(); 22 | rangHidden = 0; 23 | } 24 | 25 | bool RangStone::LoadLine(KromeIniLine* pLine) { 26 | return OnSuccess.LoadLine(pLine, "OnSuccess") || StaticProp::LoadLine(pLine); 27 | } 28 | 29 | void RangStone::Message(MKMessage* pMsg) { 30 | switch (pMsg->unk0) { 31 | case MSG_Resolve: 32 | OnSuccess.Resolve(); 33 | break; 34 | case MSG_UNK_2: 35 | if (gb.mGameData.HasBothRangs()) { 36 | HideRang(); 37 | } 38 | break; 39 | case MSG_GotBothRangs: 40 | if (rangHidden == 0) { 41 | HideRang(); 42 | OnSuccess.Send(); 43 | } 44 | break; 45 | } 46 | 47 | GameObject::Message(pMsg); 48 | } 49 | 50 | void RangStone::HideRang(void) { 51 | int n; // subobject index 52 | 53 | if (pModel->SubObjectExists(szRangObj, &n)) { 54 | pModel->EnableSubObject(n, false); 55 | } 56 | 57 | rangHidden = 1; 58 | } 59 | -------------------------------------------------------------------------------- /src/ty/source/props/SpawnPoint.cpp: -------------------------------------------------------------------------------- 1 | #include "ty/props/SpawnPoint.h" 2 | #include "ty/GameObjectManager.h" 3 | #include "ty/global.h" 4 | #include "ty/Ty.h" 5 | 6 | static GameObjDesc spawnDesc; 7 | static ModuleInfo spawnModInfo; 8 | char* spawnname = "spawnpoint"; 9 | 10 | void SpawnPoint_LoadResources(KromeIni* pIni) { 11 | spawnDesc.Init(&spawnModInfo, spawnname, spawnname, 8, 2); 12 | objectManager.AddDescriptor(&spawnDesc); 13 | } 14 | 15 | void SpawnPoint::Init(GameObjDesc* pDesc) { 16 | GameObject::Init(pDesc); 17 | fromLevel = 0; // default fromLevel to 0 18 | tySpawnPos.SetZero(); // default spawn position to 0, 0, 0 19 | tySpawnRot.SetZero(); // default spawn rotation to 0, 0, 0 20 | } 21 | 22 | bool SpawnPoint::LoadLine(KromeIniLine* pLine) { 23 | return GameObject::LoadLine(pLine) || LoadLevel_LoadVector(pLine, "pos", &tySpawnPos) || 24 | LoadLevel_LoadVector(pLine, "rot", &tySpawnRot) || 25 | LoadLevel_LoadInt(pLine, "fromLevel", &fromLevel); 26 | } 27 | 28 | void SpawnPoint::LoadDone(void) { 29 | GameObject::LoadDone(); 30 | objectManager.AddObject(this, NULL, NULL); 31 | } 32 | 33 | void SpawnPoint::Message(MKMessage* pMsg) { 34 | switch (pMsg->unk0) { 35 | case MSG_Resolve: 36 | if (fromLevel == gb.mGameData.pSaveData->previousLevel) { 37 | ty.mSpawnPos = tySpawnPos; 38 | ty.mSpawnRot = tySpawnRot; 39 | } 40 | break; 41 | } 42 | GameObject::Message(pMsg); 43 | } 44 | -------------------------------------------------------------------------------- /src/ty/source/quadratic.cpp: -------------------------------------------------------------------------------- 1 | #include "types.h" 2 | #include "ty/Quadratic.h" 3 | 4 | float OrderFloatQuadratic(float x) { 5 | return 4.0f * x; 6 | } 7 | 8 | float Quadratic::GetClosestTime(Vector *pPoint) { 9 | float f1 = 10.0f; 10 | float closestDist = 100000000.0f; 11 | float t = 0.0f; 12 | float distSq; 13 | 14 | while (t <= 1.0f) { 15 | Update(t); 16 | distSq = SquareDistance(pPoint, &pos); 17 | if (distSq < closestDist) { 18 | closestDist = distSq; 19 | f1 = t; 20 | } 21 | t += 0.1f; 22 | } 23 | 24 | if (f1 <= 1.0f) { 25 | closestDist = 100000000.0f; 26 | 27 | for (float t = f1 - 0.05f; t <= f1 + 0.05f; t += 0.01f) { 28 | if (!(t < 0.0f) && !(t > 1.0f)) { 29 | Update(t); 30 | distSq = SquareDistance(pPoint, &pos); 31 | if (distSq < closestDist) { 32 | closestDist = distSq; 33 | f1 = t; 34 | } 35 | } 36 | } 37 | 38 | return f1; 39 | } 40 | return 0.0f; 41 | } 42 | 43 | void Quadratic::Init(void) { 44 | pos.Set(0.0f, 0.0f, 0.0f); 45 | pos.w = 1.0f; 46 | 47 | coeffsX = coeffsY = coeffsZ = pos; 48 | } 49 | 50 | // calculate equation coefficients from 3 points 51 | void Quadratic::SetPoints(Vector* arg0, Vector* arg1, Vector* arg2) { 52 | Vector p3; 53 | Vector p2; 54 | p2.Sub(arg1, arg0); 55 | p3.Sub(arg2, arg0); 56 | 57 | coeffsX.y = 4.0f * p2.x - p3.x; 58 | coeffsX.x = p3.x - coeffsX.y; 59 | coeffsX.z = arg0->x; 60 | 61 | coeffsY.y = 4.0f * p2.y - p3.y; 62 | coeffsY.x = p3.y - coeffsY.y; 63 | coeffsY.z = arg0->y; 64 | 65 | coeffsZ.y = 4.0f * p2.z - p3.z; 66 | coeffsZ.x = p3.z - coeffsZ.y; 67 | coeffsZ.z = arg0->z; 68 | 69 | pos.SetZero(); 70 | } 71 | -------------------------------------------------------------------------------- /tools/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1superchip/ty-decomp/1853c53406e02413632abfdf56702dc70efb99c1/tools/__init__.py --------------------------------------------------------------------------------