diff --git a/Makefile b/Makefile index ea4e45b8..338d7afd 100755 --- a/Makefile +++ b/Makefile @@ -153,7 +153,7 @@ DEF_INC_CFLAGS := $(foreach i,$(INCLUDE_DIRS),-I$(i)) $(C_DEFINES) ASFLAGS = -mtune=vr4300 -march=vr4300 -mabi=32 $(foreach d,$(DEFINES),--defsym $(d)) INCLUDE_CFLAGS := -I include -I $(BUILD_DIR) -I src -I . -I include/libc -CFLAGS = -c -Wab,-r4300_mul -non_shared -G 0 -Xcpluscomm -Xfullwarn -signed $(OPT_FLAGS) $(MIPSISET) $(INCLUDE_CFLAGS) $(DEF_INC_CFLAGS) +CFLAGS = -c -Wab,-r4300_mul -non_shared -G 0 -Xcpluscomm -Xfullwarn -signed -DNDEBUG $(OPT_FLAGS) $(MIPSISET) $(INCLUDE_CFLAGS) $(DEF_INC_CFLAGS) LDFLAGS = undefined_syms.txt -T $(LD_SCRIPT) -Map $(BUILD_DIR)/dkr.map ####################### Other Tools ######################### @@ -195,7 +195,10 @@ ifeq ($(shell getconf LONG_BIT), 64) # Ensure that gcc treats the code as 32-bit CC_CHECK_CFLAGS += -m32 endif -CC_CHECK_CFLAGS := -fsyntax-only -fsigned-char $(INCLUDE_CFLAGS) $(DEF_INC_CFLAGS) -std=gnu90 -Wall -Wextra -Wno-format-security -Wno-main -DNON_MATCHING -DAVOID_UB -D_LANGUAGE_C +CC_CHECK_CFLAGS := -fsyntax-only -fsigned-char $(INCLUDE_CFLAGS) $(DEF_INC_CFLAGS) -std=gnu90 -Wall -Wextra -Wno-format-security -Wno-main -DNON_MATCHING -DAVOID_UB -D_LANGUAGE_C -DNDEBUG + +#Warnings to ignore +CC_CHECK_CFLAGS += -Wno-builtin-declaration-mismatch -Wno-pointer-to-int-cast -Wno-int-to-pointer-cast ####################### ASSETS ######################### diff --git a/asm/non_matchings/controller_pak/func_80076924.s b/asm/non_matchings/controller_pak/func_80076924.s deleted file mode 100644 index 61bfc9f5..00000000 --- a/asm/non_matchings/controller_pak/func_80076924.s +++ /dev/null @@ -1,29 +0,0 @@ -glabel func_80076924 -/* 077524 80076924 00047880 */ sll $t7, $a0, 2 -/* 077528 80076928 27BDFFC8 */ addiu $sp, $sp, -0x38 -/* 07752C 8007692C 01E47823 */ subu $t7, $t7, $a0 -/* 077530 80076930 000F7880 */ sll $t7, $t7, 2 -/* 077534 80076934 AFBF0014 */ sw $ra, 0x14($sp) -/* 077538 80076938 AFA60040 */ sw $a2, 0x40($sp) -/* 07753C 8007693C 01E47821 */ addu $t7, $t7, $a0 -/* 077540 80076940 3C188012 */ lui $t8, %hi(pfs) # $t8, 0x8012 -/* 077544 80076944 ACC00000 */ sw $zero, ($a2) -/* 077548 80076948 27184018 */ addiu $t8, %lo(pfs) # addiu $t8, $t8, 0x4018 -/* 07754C 8007694C 000F78C0 */ sll $t7, $t7, 3 -/* 077550 80076950 01F82021 */ addu $a0, $t7, $t8 -/* 077554 80076954 0C034160 */ jal osPfsFileState -/* 077558 80076958 27A60018 */ addiu $a2, $sp, 0x18 -/* 07755C 8007695C 14400007 */ bnez $v0, .L8007697C -/* 077560 80076960 24020009 */ li $v0, 9 -/* 077564 80076964 8FB90018 */ lw $t9, 0x18($sp) -/* 077568 80076968 8FA80040 */ lw $t0, 0x40($sp) -/* 07756C 8007696C 00001025 */ move $v0, $zero -/* 077570 80076970 10000002 */ b .L8007697C -/* 077574 80076974 AD190000 */ sw $t9, ($t0) -/* 077578 80076978 24020009 */ li $v0, 9 -.L8007697C: -/* 07757C 8007697C 8FBF0014 */ lw $ra, 0x14($sp) -/* 077580 80076980 27BD0038 */ addiu $sp, $sp, 0x38 -/* 077584 80076984 03E00008 */ jr $ra -/* 077588 80076988 00000000 */ nop - diff --git a/asm/non_matchings/unknown_003260/audioNewThread.s b/asm/non_matchings/unknown_003260/audioNewThread.s index 8ec5d4ce..d11e48ce 100644 --- a/asm/non_matchings/unknown_003260/audioNewThread.s +++ b/asm/non_matchings/unknown_003260/audioNewThread.s @@ -150,8 +150,8 @@ glabel audioNewThread /* 003498 80002898 AE420010 */ sw $v0, 0x10($s2) /* 00349C 8000289C 25AD9808 */ addiu $t5, %lo(func_80019808) # addiu $t5, $t5, -0x67f8 /* 0034A0 800028A0 A1000000 */ sb $zero, ($t0) -/* 0034A4 800028A4 3C05800E */ lui $a1, %hi(D_800DC694) # $a1, 0x800e -/* 0034A8 800028A8 8CA5C694 */ lw $a1, %lo(D_800DC694)($a1) +/* 0034A4 800028A4 3C05800E */ lui $a1, %hi(gFunc80019808Length) # $a1, 0x800e +/* 0034A8 800028A8 8CA5C694 */ lw $a1, %lo(gFunc80019808Length)($a1) /* 0034AC 800028AC 01A61823 */ subu $v1, $t5, $a2 /* 0034B0 800028B0 00C33821 */ addu $a3, $a2, $v1 /* 0034B4 800028B4 00008825 */ move $s1, $zero @@ -169,8 +169,8 @@ glabel audioNewThread /* 0034E0 800028E0 1420FFF8 */ bnez $at, .L800028C4 /* 0034E4 800028E4 006E1821 */ addu $v1, $v1, $t6 .L800028E8: -/* 0034E8 800028E8 3C19800E */ lui $t9, %hi(D_800DC690) # $t9, 0x800e -/* 0034EC 800028EC 8F39C690 */ lw $t9, %lo(D_800DC690)($t9) +/* 0034E8 800028E8 3C19800E */ lui $t9, %hi(gFunc80019808Checksum) # $t9, 0x800e +/* 0034EC 800028EC 8F39C690 */ lw $t9, %lo(gFunc80019808Checksum)($t9) /* 0034F0 800028F0 3C108011 */ lui $s0, %hi(D_80115F98) # $s0, 0x8011 /* 0034F4 800028F4 10790003 */ beq $v1, $t9, .L80002904 /* 0034F8 800028F8 26105F98 */ addiu $s0, %lo(D_80115F98) # addiu $s0, $s0, 0x5f98 diff --git a/asm/non_matchings/unknown_032760/func_8003DFCC.s b/asm/non_matchings/unknown_032760/func_8003DFCC.s deleted file mode 100644 index a20f71a6..00000000 --- a/asm/non_matchings/unknown_032760/func_8003DFCC.s +++ /dev/null @@ -1,104 +0,0 @@ -glabel func_8003DFCC -/* 03EBCC 8003DFCC 27BDFFE8 */ addiu $sp, $sp, -0x18 -/* 03EBD0 8003DFD0 AFBF0014 */ sw $ra, 0x14($sp) -/* 03EBD4 8003DFD4 8C8F004C */ lw $t7, 0x4c($a0) -/* 03EBD8 8003DFD8 240E0002 */ li $t6, 2 -/* 03EBDC 8003DFDC A5EE0014 */ sh $t6, 0x14($t7) -/* 03EBE0 8003DFE0 8C99004C */ lw $t9, 0x4c($a0) -/* 03EBE4 8003DFE4 24180004 */ li $t8, 4 -/* 03EBE8 8003DFE8 A3380011 */ sb $t8, 0x11($t9) -/* 03EBEC 8003DFEC 8C89004C */ lw $t1, 0x4c($a0) -/* 03EBF0 8003DFF0 24080014 */ li $t0, 20 -/* 03EBF4 8003DFF4 A1280010 */ sb $t0, 0x10($t1) -/* 03EBF8 8003DFF8 AFA5001C */ sw $a1, 0x1c($sp) -/* 03EBFC 8003DFFC 0C0270C3 */ jal get_filtered_cheats -/* 03EC00 8003E000 AFA40018 */ sw $a0, 0x18($sp) -/* 03EC04 8003E004 8FA40018 */ lw $a0, 0x18($sp) -/* 03EC08 8003E008 8FA5001C */ lw $a1, 0x1c($sp) -/* 03EC0C 8003E00C 00025380 */ sll $t2, $v0, 0xe -/* 03EC10 8003E010 05410003 */ bgez $t2, .L8003E020 -/* 03EC14 8003E014 304B8000 */ andi $t3, $v0, 0x8000 -/* 03EC18 8003E018 10000013 */ b .L8003E068 -/* 03EC1C 8003E01C A0A00009 */ sb $zero, 9($a1) -.L8003E020: -/* 03EC20 8003E020 11600004 */ beqz $t3, .L8003E034 -/* 03EC24 8003E024 00026BC0 */ sll $t5, $v0, 0xf -/* 03EC28 8003E028 240C0001 */ li $t4, 1 -/* 03EC2C 8003E02C 1000000E */ b .L8003E068 -/* 03EC30 8003E030 A0AC0009 */ sb $t4, 9($a1) -.L8003E034: -/* 03EC34 8003E034 05A10004 */ bgez $t5, .L8003E048 -/* 03EC38 8003E038 00027B40 */ sll $t7, $v0, 0xd -/* 03EC3C 8003E03C 240E0002 */ li $t6, 2 -/* 03EC40 8003E040 10000009 */ b .L8003E068 -/* 03EC44 8003E044 A0AE0009 */ sb $t6, 9($a1) -.L8003E048: -/* 03EC48 8003E048 05E10004 */ bgez $t7, .L8003E05C -/* 03EC4C 8003E04C 0002CB00 */ sll $t9, $v0, 0xc -/* 03EC50 8003E050 24180003 */ li $t8, 3 -/* 03EC54 8003E054 10000004 */ b .L8003E068 -/* 03EC58 8003E058 A0B80009 */ sb $t8, 9($a1) -.L8003E05C: -/* 03EC5C 8003E05C 07210002 */ bgez $t9, .L8003E068 -/* 03EC60 8003E060 24080004 */ li $t0, 4 -/* 03EC64 8003E064 A0A80009 */ sb $t0, 9($a1) -.L8003E068: -/* 03EC68 8003E068 90A90008 */ lbu $t1, 8($a1) -/* 03EC6C 8003E06C 00000000 */ nop -/* 03EC70 8003E070 29210006 */ slti $at, $t1, 6 -/* 03EC74 8003E074 14200002 */ bnez $at, .L8003E080 -/* 03EC78 8003E078 00000000 */ nop -/* 03EC7C 8003E07C A0A00008 */ sb $zero, 8($a1) -.L8003E080: -/* 03EC80 8003E080 8C8B0040 */ lw $t3, 0x40($a0) -/* 03EC84 8003E084 808A003A */ lb $t2, 0x3a($a0) -/* 03EC88 8003E088 816C0055 */ lb $t4, 0x55($t3) -/* 03EC8C 8003E08C 00000000 */ nop -/* 03EC90 8003E090 014C082A */ slt $at, $t2, $t4 -/* 03EC94 8003E094 14200002 */ bnez $at, .L8003E0A0 -/* 03EC98 8003E098 00000000 */ nop -/* 03EC9C 8003E09C A080003A */ sb $zero, 0x3a($a0) -.L8003E0A0: -/* 03ECA0 8003E0A0 90AD0009 */ lbu $t5, 9($a1) -/* 03ECA4 8003E0A4 3C014120 */ li $at, 0x41200000 # 10.000000 -/* 03ECA8 8003E0A8 A08D003A */ sb $t5, 0x3a($a0) -/* 03ECAC 8003E0AC 808E003A */ lb $t6, 0x3a($a0) -/* 03ECB0 8003E0B0 44811000 */ mtc1 $at, $f2 -/* 03ECB4 8003E0B4 AC8E0078 */ sw $t6, 0x78($a0) -/* 03ECB8 8003E0B8 90B8000A */ lbu $t8, 0xa($a1) -/* 03ECBC 8003E0BC 3C014280 */ li $at, 0x42800000 # 64.000000 -/* 03ECC0 8003E0C0 44982000 */ mtc1 $t8, $f4 -/* 03ECC4 8003E0C4 44813000 */ mtc1 $at, $f6 -/* 03ECC8 8003E0C8 46802020 */ cvt.s.w $f0, $f4 -/* 03ECCC 8003E0CC 4602003C */ c.lt.s $f0, $f2 -/* 03ECD0 8003E0D0 00000000 */ nop -/* 03ECD4 8003E0D4 45000003 */ bc1f .L8003E0E4 -/* 03ECD8 8003E0D8 00000000 */ nop -/* 03ECDC 8003E0DC 46001006 */ mov.s $f0, $f2 -/* 03ECE0 8003E0E0 00000000 */ nop -.L8003E0E4: -/* 03ECE4 8003E0E4 46060003 */ div.s $f0, $f0, $f6 -/* 03ECE8 8003E0E8 8C990040 */ lw $t9, 0x40($a0) -/* 03ECEC 8003E0EC 8C820064 */ lw $v0, 0x64($a0) -/* 03ECF0 8003E0F0 C728000C */ lwc1 $f8, 0xc($t9) -/* 03ECF4 8003E0F4 00000000 */ nop -/* 03ECF8 8003E0F8 46004282 */ mul.s $f10, $f8, $f0 -/* 03ECFC 8003E0FC E48A0008 */ swc1 $f10, 8($a0) -/* 03ED00 8003E100 C4900008 */ lwc1 $f16, 8($a0) -/* 03ED04 8003E104 A4400004 */ sh $zero, 4($v0) -/* 03ED08 8003E108 E4500000 */ swc1 $f16, ($v0) -/* 03ED0C 8003E10C AC80007C */ sw $zero, 0x7c($a0) -/* 03ED10 8003E110 0C0270C3 */ jal get_filtered_cheats -/* 03ED14 8003E114 AFA40018 */ sw $a0, 0x18($sp) -/* 03ED18 8003E118 8FA40018 */ lw $a0, 0x18($sp) -/* 03ED1C 8003E11C 30480800 */ andi $t0, $v0, 0x800 -/* 03ED20 8003E120 11000004 */ beqz $t0, .L8003E134 -/* 03ED24 8003E124 8FBF0014 */ lw $ra, 0x14($sp) -/* 03ED28 8003E128 0C003FEE */ jal gParticlePtrList_addObject -/* 03ED2C 8003E12C 00000000 */ nop -/* 03ED30 8003E130 8FBF0014 */ lw $ra, 0x14($sp) -.L8003E134: -/* 03ED34 8003E134 27BD0018 */ addiu $sp, $sp, 0x18 -/* 03ED38 8003E138 03E00008 */ jr $ra -/* 03ED3C 8003E13C 00000000 */ nop - diff --git a/include/PR/os_libc.h b/include/PR/os_libc.h index 94111c0b..ce5372fb 100644 --- a/include/PR/os_libc.h +++ b/include/PR/os_libc.h @@ -2,7 +2,6 @@ #define _OS_LIBC_H_ #include "ultratypes.h" - // Old deprecated functions from strings.h, replaced by memcpy/memset. extern void bcopy(const void *, void *, size_t); extern void bzero(void *, size_t); diff --git a/include/PR/os_pi.h b/include/PR/os_pi.h index 34015c8f..49ba94dd 100644 --- a/include/PR/os_pi.h +++ b/include/PR/os_pi.h @@ -94,4 +94,6 @@ s32 osPiRawReadIo(u32 devAddr, u32 *data); s32 osPiRawStartDma(s32 dir, u32 cart_addr, void *dram_addr, size_t size); s32 osEPiRawStartDma(OSPiHandle *piHandle, s32 dir, u32 cart_addr, void *dram_addr, size_t size); +s32 osEPiRawWriteIo(OSPiHandle *, u32 , u32); + #endif diff --git a/include/PR/os_vi.h b/include/PR/os_vi.h index 77d5e756..7a741959 100644 --- a/include/PR/os_vi.h +++ b/include/PR/os_vi.h @@ -87,6 +87,7 @@ void osViSetEvent(OSMesgQueue *mq, OSMesg msg, u32 retraceCount); void osViBlack(u8 active); void osViSetSpecialFeatures(u32 func); void osViSwapBuffer(void *vaddr); +void osYieldThread(void); #define OS_VI_NTSC_LPN1 0 /* NTSC */ diff --git a/include/audio_internal.h b/include/audio_internal.h index 95e104a3..9cb74c0d 100644 --- a/include/audio_internal.h +++ b/include/audio_internal.h @@ -122,6 +122,8 @@ typedef struct ALFilter_s { s32 type; } ALFilter; +void alFilterNew(ALFilter *f, ALCmdHandler h, ALSetParam s, s32 type); + #define AL_MAX_ADPCM_STATES 3 /* Depends on number of subframes * per frame and loop length */ @@ -140,6 +142,11 @@ typedef struct { s32 memin; } ALLoadFilter; +void alLoadNew(ALLoadFilter *f, ALDMANew dma, ALHeap *hp); +Acmd *alAdpcmPull(void *f, s16 *outp, s32 byteCount, s32 sampleOffset, Acmd *p); +Acmd *alRaw16Pull(void *f, s16 *outp, s32 byteCount, s32 sampleOffset, Acmd *p); +s32 alLoadParam(void *filter, s32 paramID, void *param); + typedef struct ALResampler_s { ALFilter filter; RESAMPLE_STATE *state; @@ -188,6 +195,11 @@ typedef struct { ALSetFXParam paramHdl; } ALFx; +void alFxNew(ALFx *r, ALSynConfig *c, s16 bus, ALHeap *hp); +Acmd *alFxPull(void *f, s16 *outp, s32 out, s32 sampleOffset, Acmd *p); +s32 alFxParam(void *filter, s32 paramID, void *param); +s32 alFxParamHdl(void *filter, s32 paramID, void *param); + #define AL_MAX_MAIN_BUS_SOURCES 1 typedef struct ALMainBus_s { ALFilter filter; @@ -196,6 +208,10 @@ typedef struct ALMainBus_s { ALFilter **sources; } ALMainBus; +void alMainBusNew(ALMainBus *m, void *ptr, s32 len); +Acmd *alMainBusPull(void *f, s16 *outp, s32 outCount, s32 sampleOffset, Acmd *p); +s32 alMainBusParam(void *filter, s32 paramID, void *param); + #define AL_MAX_AUX_BUS_SOURCES 8 #define AL_MAX_AUX_BUS_FX 1 typedef struct ALAuxBus_s { @@ -206,12 +222,24 @@ typedef struct ALAuxBus_s { ALFx fx[AL_MAX_AUX_BUS_FX]; } ALAuxBus; +void alAuxBusNew(ALAuxBus *m, void *ptr, s32 len); +Acmd *alAuxBusPull(void *f, s16 *outp, s32 outCount, s32 sampleOffset, Acmd *p); +s32 alAuxBusParam(void *filter, s32 paramID, void *param); + +void alResampleNew(ALResampler *r, ALHeap *hp); +Acmd *alResamplePull(void *f, s16 *outp, s32 out, s32 sampleOffset, Acmd *p); +s32 alResampleParam(void *f, s32 paramID, void *param); + typedef struct ALSave_s { ALFilter filter; s32 dramout; s32 first; } ALSave; +void alSaveNew(ALSave *r); +Acmd *alSavePull(void *f, s16 *outp, s32 outCount, s32 sampleOffset, Acmd *p); +s32 alSaveParam(void *f, s32 paramID, void *param); + typedef struct ALEnvMixer_s { ALFilter filter; ENVMIX_STATE *state; @@ -236,6 +264,10 @@ typedef struct ALEnvMixer_s { s32 motion; } ALEnvMixer; +void alEnvmixerNew(ALEnvMixer *e, ALHeap *hp); +Acmd *alEnvmixerPull(void *f, s16 *outp, s32 out, s32 sampleOffset, Acmd *p); +s32 alEnvmixerParam(void *filter, s32 paramID, void *param); + /* * heap stuff */ diff --git a/include/libc/assert.h b/include/libc/assert.h new file mode 100644 index 00000000..a3736e37 --- /dev/null +++ b/include/libc/assert.h @@ -0,0 +1,54 @@ +#ifndef __ASSERT_H__ +#define __ASSERT_H__ +#ifdef __cplusplus +extern "C" { +#endif +/************************************************************************** + * * + * Copyright (C) 1984, Silicon Graphics, Inc. * + * * + * These coded instructions, statements, and computer programs contain * + * unpublished proprietary information of Silicon Graphics, Inc., and * + * are protected by Federal copyright law. They may not be disclosed * + * to third parties or copied or duplicated in any form, in whole or * + * in part, without the prior written consent of Silicon Graphics, Inc. * + * * + **************************************************************************/ +/* Copyright (c) 1984 AT&T */ +/* All Rights Reserved */ + +/* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T */ +/* The copyright notice above does not evidence any */ +/* actual or intended publication of such source code. */ + +#ident "$Revision: 1.17 $" + +/* ANSI C Notes: + * + * - THE IDENTIFIERS APPEARING OUTSIDE OF #ifdef __EXTENSIONS__ IN THIS + * standard header ARE SPECIFIED BY ANSI! CONFORMANCE WILL BE ALTERED + * IF ANY NEW IDENTIFIERS ARE ADDED TO THIS AREA UNLESS THEY ARE IN ANSI's + * RESERVED NAMESPACE. (i.e., unless they are prefixed by __[a-z] or + * _[A-Z]. For external objects, identifiers with the prefix _[a-z] + * are also reserved.) + */ + +#ifdef NDEBUG +#undef assert +#define assert(EX) ((void)0) + +#else + +extern void __assert(const char *, const char *, int); +#ifdef __ANSI_CPP__ +#define assert(EX) ((EX)?((void)0):__assert( # EX , __FILE__, __LINE__)) +#else +#define assert(EX) ((EX)?((void)0):__assert("EX", __FILE__, __LINE__)) +#endif +#endif /* NDEBUG */ + +#ifdef __cplusplus +} +#endif + +#endif /* !__ASSERT_H__ */ diff --git a/include/sched.h b/include/sched.h index bf7903d2..202ab7a7 100644 --- a/include/sched.h +++ b/include/sched.h @@ -100,7 +100,6 @@ extern OSViMode osViModeTable[]; /*******************************/ void __scYield(OSSched *sc); -static void __scMain(void *arg); void __scExec(OSSched *sc, OSScTask *sp, OSScTask *dp); void osCreateScheduler(OSSched *sc, void *stack, OSPri priority, u8 mode, u8 numFields); void osScAddClient(OSSched *sc, OSScClient *c, OSMesgQueue *msgQ, u8 arg3); @@ -116,6 +115,5 @@ s32 __scTaskComplete(OSSched *sc, OSScTask *t); void __scAppendList(OSSched *sc, OSScTask *t); void __scExec(OSSched *sc, OSScTask *sp, OSScTask *dp); void __scHandleRetrace(OSSched *sc); -static s32 __scSchedule(OSSched *sc, OSScTask **sp, OSScTask **dp, s32 availRCP); #endif diff --git a/include/viint.h b/include/viint.h index 3578fb3e..e366b788 100644 --- a/include/viint.h +++ b/include/viint.h @@ -68,4 +68,6 @@ extern __OSViContext *__osViCurr; extern __OSViContext *__osViNext; __OSViContext *__osViGetCurrentContext(void); void __osViInit(void); +void *osViGetCurrentFramebuffer(void); +void *osViGetNextFramebuffer(void); #endif diff --git a/lib/asm/non_matchings/alFxNew/alFxNew.s b/lib/asm/non_matchings/alFxNew/alFxNew.s deleted file mode 100644 index 9351ec84..00000000 --- a/lib/asm/non_matchings/alFxNew/alFxNew.s +++ /dev/null @@ -1,303 +0,0 @@ -.late_rodata -glabel jpt_800E6EA0 -.word L80064AD8, L80064AE4, L80064AFC, L80064B08, L80064AF0, L80064B14 -glabel D_800E6EB8 -.float 8.320827 -glabel D_800E6EBC -.float 0.04680453 - -.text -glabel alFxNew -/* 065608 80064A08 27BDFFA0 */ addiu $sp, $sp, -0x60 -/* 06560C 80064A0C AFB00038 */ sw $s0, 0x38($sp) -/* 065610 80064A10 00068400 */ sll $s0, $a2, 0x10 -/* 065614 80064A14 AFA60068 */ sw $a2, 0x68($sp) -/* 065618 80064A18 00107403 */ sra $t6, $s0, 0x10 -/* 06561C 80064A1C AFBF005C */ sw $ra, 0x5c($sp) -/* 065620 80064A20 AFB60050 */ sw $s6, 0x50($sp) -/* 065624 80064A24 AFA50064 */ sw $a1, 0x64($sp) -/* 065628 80064A28 AFA7006C */ sw $a3, 0x6c($sp) -/* 06562C 80064A2C 3C068006 */ lui $a2, %hi(alFxParam) # $a2, 0x8006 -/* 065630 80064A30 0080B025 */ move $s6, $a0 -/* 065634 80064A34 01C08025 */ move $s0, $t6 -/* 065638 80064A38 AFBE0058 */ sw $fp, 0x58($sp) -/* 06563C 80064A3C AFB70054 */ sw $s7, 0x54($sp) -/* 065640 80064A40 AFB5004C */ sw $s5, 0x4c($sp) -/* 065644 80064A44 AFB40048 */ sw $s4, 0x48($sp) -/* 065648 80064A48 AFB30044 */ sw $s3, 0x44($sp) -/* 06564C 80064A4C AFB20040 */ sw $s2, 0x40($sp) -/* 065650 80064A50 AFB1003C */ sw $s1, 0x3c($sp) -/* 065654 80064A54 E7BB0030 */ swc1 $f27, 0x30($sp) -/* 065658 80064A58 E7BA0034 */ swc1 $f26, 0x34($sp) -/* 06565C 80064A5C E7B90028 */ swc1 $f25, 0x28($sp) -/* 065660 80064A60 E7B8002C */ swc1 $f24, 0x2c($sp) -/* 065664 80064A64 E7B70020 */ swc1 $f23, 0x20($sp) -/* 065668 80064A68 E7B60024 */ swc1 $f22, 0x24($sp) -/* 06566C 80064A6C E7B50018 */ swc1 $f21, 0x18($sp) -/* 065670 80064A70 E7B4001C */ swc1 $f20, 0x1c($sp) -/* 065674 80064A74 24C63F94 */ addiu $a2, %lo(alFxParam) # addiu $a2, $a2, 0x3f94 -/* 065678 80064A78 24070005 */ li $a3, 5 -/* 06567C 80064A7C 0C03282C */ jal alFilterNew -/* 065680 80064A80 00002825 */ move $a1, $zero -/* 065684 80064A84 8FA20064 */ lw $v0, 0x64($sp) -/* 065688 80064A88 3C0F8006 */ lui $t7, %hi(alFxPull) # $t7, 0x8006 -/* 06568C 80064A8C 3C188006 */ lui $t8, %hi(alFxParamHdl) # $t8, 0x8006 -/* 065690 80064A90 25EF3C30 */ addiu $t7, %lo(alFxPull) # addiu $t7, $t7, 0x3c30 -/* 065694 80064A94 27183FAC */ addiu $t8, %lo(alFxParamHdl) # addiu $t8, $t8, 0x3fac -/* 065698 80064A98 AECF0004 */ sw $t7, 4($s6) -/* 06569C 80064A9C AED80028 */ sw $t8, 0x28($s6) -/* 0656A0 80064AA0 0050C821 */ addu $t9, $v0, $s0 -/* 0656A4 80064AA4 9328001C */ lbu $t0, 0x1c($t9) -/* 0656A8 80064AA8 3C13800E */ lui $s3, %hi(NULL_PARAMS) # $s3, 0x800e -/* 0656AC 80064AAC 2509FFFF */ addiu $t1, $t0, -1 -/* 0656B0 80064AB0 2D210006 */ sltiu $at, $t1, 6 -/* 0656B4 80064AB4 1020001C */ beqz $at, .L80064B28 -/* 0656B8 80064AB8 2673D028 */ addiu $s3, %lo(NULL_PARAMS) # addiu $s3, $s3, -0x2fd8 -/* 0656BC 80064ABC 00094880 */ sll $t1, $t1, 2 -/* 0656C0 80064AC0 3C01800E */ lui $at, %hi(jpt_800E6EA0) # $at, 0x800e -/* 0656C4 80064AC4 00290821 */ addu $at, $at, $t1 -/* 0656C8 80064AC8 8C296EA0 */ lw $t1, %lo(jpt_800E6EA0)($at) -/* 0656CC 80064ACC 00000000 */ nop -/* 0656D0 80064AD0 01200008 */ jr $t1 -/* 0656D4 80064AD4 00000000 */ nop -glabel L80064AD8 -/* 0656D8 80064AD8 3C13800E */ lui $s3, %hi(SMALLROOM_PARAMS) # $s3, 0x800e -/* 0656DC 80064ADC 10000012 */ b .L80064B28 -/* 0656E0 80064AE0 2673CEC0 */ addiu $s3, %lo(SMALLROOM_PARAMS) # addiu $s3, $s3, -0x3140 -glabel L80064AE4 -/* 0656E4 80064AE4 3C13800E */ lui $s3, %hi(BIGROOM_PARAMS) # $s3, 0x800e -/* 0656E8 80064AE8 1000000F */ b .L80064B28 -/* 0656EC 80064AEC 2673CF28 */ addiu $s3, %lo(BIGROOM_PARAMS) # addiu $s3, $s3, -0x30d8 -glabel L80064AF0 -/* 0656F0 80064AF0 3C13800E */ lui $s3, %hi(ECHO_PARAMS) # $s3, 0x800e -/* 0656F4 80064AF4 1000000C */ b .L80064B28 -/* 0656F8 80064AF8 2673CFB0 */ addiu $s3, %lo(ECHO_PARAMS) # addiu $s3, $s3, -0x3050 -glabel L80064AFC -/* 0656FC 80064AFC 3C13800E */ lui $s3, %hi(CHORUS_PARAMS) # $s3, 0x800e -/* 065700 80064B00 10000009 */ b .L80064B28 -/* 065704 80064B04 2673CFD8 */ addiu $s3, %lo(CHORUS_PARAMS) # addiu $s3, $s3, -0x3028 -glabel L80064B08 -/* 065708 80064B08 3C13800E */ lui $s3, %hi(FLANGE_PARAMS) # $s3, 0x800e -/* 06570C 80064B0C 10000006 */ b .L80064B28 -/* 065710 80064B10 2673D000 */ addiu $s3, %lo(FLANGE_PARAMS) # addiu $s3, $s3, -0x3000 -glabel L80064B14 -/* 065714 80064B14 00105080 */ sll $t2, $s0, 2 -/* 065718 80064B18 004A5821 */ addu $t3, $v0, $t2 -/* 06571C 80064B1C 8D730020 */ lw $s3, 0x20($t3) -/* 065720 80064B20 10000002 */ b .L80064B2C -/* 065724 80064B24 8E6C0000 */ lw $t4, ($s3) -.L80064B28: -/* 065728 80064B28 8E6C0000 */ lw $t4, ($s3) -.L80064B2C: -/* 06572C 80064B2C 241E0028 */ li $fp, 40 -/* 065730 80064B30 318E00FF */ andi $t6, $t4, 0xff -/* 065734 80064B34 01DE0019 */ multu $t6, $fp -/* 065738 80064B38 A2CC0024 */ sb $t4, 0x24($s6) -/* 06573C 80064B3C 8E6D0004 */ lw $t5, 4($s3) -/* 065740 80064B40 3C1500FF */ lui $s5, (0x00FFFFFF >> 16) # lui $s5, 0xff -/* 065744 80064B44 36B5FFFF */ ori $s5, (0x00FFFFFF & 0xFFFF) # ori $s5, $s5, 0xffff -/* 065748 80064B48 24110002 */ li $s1, 2 -/* 06574C 80064B4C 02A02825 */ move $a1, $s5 -/* 065750 80064B50 AECD001C */ sw $t5, 0x1c($s6) -/* 065754 80064B54 00002012 */ mflo $a0 -/* 065758 80064B58 0C01C327 */ jal allocate_from_main_pool_safe -/* 06575C 80064B5C 00000000 */ nop -/* 065760 80064B60 8EC4001C */ lw $a0, 0x1c($s6) -/* 065764 80064B64 AEC20020 */ sw $v0, 0x20($s6) -/* 065768 80064B68 00047840 */ sll $t7, $a0, 1 -/* 06576C 80064B6C 01E02025 */ move $a0, $t7 -/* 065770 80064B70 0C01C327 */ jal allocate_from_main_pool_safe -/* 065774 80064B74 02A02825 */ move $a1, $s5 -/* 065778 80064B78 8ED8001C */ lw $t8, 0x1c($s6) -/* 06577C 80064B7C AEC20014 */ sw $v0, 0x14($s6) -/* 065780 80064B80 AEC20018 */ sw $v0, 0x18($s6) -/* 065784 80064B84 1300000B */ beqz $t8, .L80064BB4 -/* 065788 80064B88 00001825 */ move $v1, $zero -.L80064B8C: -/* 06578C 80064B8C 8ED90014 */ lw $t9, 0x14($s6) -/* 065790 80064B90 00034040 */ sll $t0, $v1, 1 -/* 065794 80064B94 03284821 */ addu $t1, $t9, $t0 -/* 065798 80064B98 A5200000 */ sh $zero, ($t1) -/* 06579C 80064B9C 8ECB001C */ lw $t3, 0x1c($s6) -/* 0657A0 80064BA0 24630001 */ addiu $v1, $v1, 1 -/* 0657A4 80064BA4 306AFFFF */ andi $t2, $v1, 0xffff -/* 0657A8 80064BA8 014B082B */ sltu $at, $t2, $t3 -/* 0657AC 80064BAC 1420FFF7 */ bnez $at, .L80064B8C -/* 0657B0 80064BB0 01401825 */ move $v1, $t2 -.L80064BB4: -/* 0657B4 80064BB4 92CC0024 */ lbu $t4, 0x24($s6) -/* 0657B8 80064BB8 0000A025 */ move $s4, $zero -/* 0657BC 80064BBC 19800091 */ blez $t4, .L80064E04 -/* 0657C0 80064BC0 3C013F80 */ li $at, 0x3F800000 # 1.000000 -/* 0657C4 80064BC4 4481C000 */ mtc1 $at, $f24 -/* 0657C8 80064BC8 3C01447A */ li $at, 0x447A0000 # 1000.000000 -/* 0657CC 80064BCC 4481B000 */ mtc1 $at, $f22 -/* 0657D0 80064BD0 3C01800E */ lui $at, %hi(D_800E6EBC) # $at, 0x800e -/* 0657D4 80064BD4 C4356EB8 */ lwc1 $f21, %lo(D_800E6EB8)($at) -/* 0657D8 80064BD8 C4346EBC */ lwc1 $f20, %lo(D_800E6EBC)($at) -/* 0657DC 80064BDC 4480D000 */ mtc1 $zero, $f26 -/* 0657E0 80064BE0 24170001 */ li $s7, 1 -.L80064BE4: -/* 0657E4 80064BE4 029E0019 */ multu $s4, $fp -/* 0657E8 80064BE8 00117880 */ sll $t7, $s1, 2 -/* 0657EC 80064BEC 8ECD0020 */ lw $t5, 0x20($s6) -/* 0657F0 80064BF0 026FC021 */ addu $t8, $s3, $t7 -/* 0657F4 80064BF4 26310001 */ addiu $s1, $s1, 1 -/* 0657F8 80064BF8 8F190000 */ lw $t9, ($t8) -/* 0657FC 80064BFC 3228FFFF */ andi $t0, $s1, 0xffff -/* 065800 80064C00 00084880 */ sll $t1, $t0, 2 -/* 065804 80064C04 02695021 */ addu $t2, $s3, $t1 -/* 065808 80064C08 25110001 */ addiu $s1, $t0, 1 -/* 06580C 80064C0C 322CFFFF */ andi $t4, $s1, 0xffff -/* 065810 80064C10 25910001 */ addiu $s1, $t4, 1 -/* 065814 80064C14 00007012 */ mflo $t6 -/* 065818 80064C18 01AE8021 */ addu $s0, $t5, $t6 -/* 06581C 80064C1C AE190000 */ sw $t9, ($s0) -/* 065820 80064C20 8D4B0000 */ lw $t3, ($t2) -/* 065824 80064C24 000C6880 */ sll $t5, $t4, 2 -/* 065828 80064C28 026D7021 */ addu $t6, $s3, $t5 -/* 06582C 80064C2C AE0B0004 */ sw $t3, 4($s0) -/* 065830 80064C30 8DCF0000 */ lw $t7, ($t6) -/* 065834 80064C34 3238FFFF */ andi $t8, $s1, 0xffff -/* 065838 80064C38 0018C880 */ sll $t9, $t8, 2 -/* 06583C 80064C3C 02794021 */ addu $t0, $s3, $t9 -/* 065840 80064C40 27110001 */ addiu $s1, $t8, 1 -/* 065844 80064C44 A60F000A */ sh $t7, 0xa($s0) -/* 065848 80064C48 8D090000 */ lw $t1, ($t0) -/* 06584C 80064C4C 322AFFFF */ andi $t2, $s1, 0xffff -/* 065850 80064C50 000A5880 */ sll $t3, $t2, 2 -/* 065854 80064C54 026B6021 */ addu $t4, $s3, $t3 -/* 065858 80064C58 25510001 */ addiu $s1, $t2, 1 -/* 06585C 80064C5C A6090008 */ sh $t1, 8($s0) -/* 065860 80064C60 8D8D0000 */ lw $t5, ($t4) -/* 065864 80064C64 322EFFFF */ andi $t6, $s1, 0xffff -/* 065868 80064C68 000E7880 */ sll $t7, $t6, 2 -/* 06586C 80064C6C 026FC021 */ addu $t8, $s3, $t7 -/* 065870 80064C70 A60D000C */ sh $t5, 0xc($s0) -/* 065874 80064C74 8F020000 */ lw $v0, ($t8) -/* 065878 80064C78 01C08825 */ move $s1, $t6 -/* 06587C 80064C7C 1040003B */ beqz $v0, .L80064D6C -/* 065880 80064C80 02205025 */ move $t2, $s1 -/* 065884 80064C84 44822000 */ mtc1 $v0, $f4 -/* 065888 80064C88 8FB90064 */ lw $t9, 0x64($sp) -/* 06588C 80064C8C 468021A0 */ cvt.s.w $f6, $f4 -/* 065890 80064C90 8F280018 */ lw $t0, 0x18($t9) -/* 065894 80064C94 8E0A0004 */ lw $t2, 4($s0) -/* 065898 80064C98 46163203 */ div.s $f8, $f6, $f22 -/* 06589C 80064C9C 44888000 */ mtc1 $t0, $f16 -/* 0658A0 80064CA0 8E0B0000 */ lw $t3, ($s0) -/* 0658A4 80064CA4 468084A1 */ cvt.d.w $f18, $f16 -/* 0658A8 80064CA8 25D10001 */ addiu $s1, $t6, 1 -/* 0658AC 80064CAC 3229FFFF */ andi $t1, $s1, 0xffff -/* 0658B0 80064CB0 014B6023 */ subu $t4, $t2, $t3 -/* 0658B4 80064CB4 01208825 */ move $s1, $t1 -/* 0658B8 80064CB8 00116880 */ sll $t5, $s1, 2 -/* 0658BC 80064CBC 026D7021 */ addu $t6, $s3, $t5 -/* 0658C0 80064CC0 3C0141F0 */ li $at, 0x41F00000 # 30.000000 -/* 0658C4 80064CC4 46004021 */ cvt.d.s $f0, $f8 -/* 0658C8 80064CC8 46200280 */ add.d $f10, $f0, $f0 -/* 0658CC 80064CCC 448C4000 */ mtc1 $t4, $f8 -/* 0658D0 80064CD0 46325103 */ div.d $f4, $f10, $f18 -/* 0658D4 80064CD4 46804421 */ cvt.d.w $f16, $f8 -/* 0658D8 80064CD8 462021A0 */ cvt.s.d $f6, $f4 -/* 0658DC 80064CDC 05810005 */ bgez $t4, .L80064CF4 -/* 0658E0 80064CE0 E6060010 */ swc1 $f6, 0x10($s0) -/* 0658E4 80064CE4 44815800 */ mtc1 $at, $f11 -/* 0658E8 80064CE8 44805000 */ mtc1 $zero, $f10 -/* 0658EC 80064CEC 00000000 */ nop -/* 0658F0 80064CF0 462A8400 */ add.d $f16, $f16, $f10 -.L80064CF4: -/* 0658F4 80064CF4 8DCF0000 */ lw $t7, ($t6) -/* 0658F8 80064CF8 26310001 */ addiu $s1, $s1, 1 -/* 0658FC 80064CFC 448F9000 */ mtc1 $t7, $f18 -/* 065900 80064D00 3238FFFF */ andi $t8, $s1, 0xffff -/* 065904 80064D04 46809120 */ cvt.s.w $f4, $f18 -/* 065908 80064D08 03008825 */ move $s1, $t8 -/* 06590C 80064D0C E6180014 */ swc1 $f24, 0x14($s0) -/* 065910 80064D10 460021A1 */ cvt.d.s $f6, $f4 -/* 065914 80064D14 00000000 */ nop -/* 065918 80064D18 46343203 */ div.d $f8, $f6, $f20 -/* 06591C 80064D1C AE000018 */ sw $zero, 0x18($s0) -/* 065920 80064D20 24040034 */ li $a0, 52 -/* 065924 80064D24 02A02825 */ move $a1, $s5 -/* 065928 80064D28 46304282 */ mul.d $f10, $f8, $f16 -/* 06592C 80064D2C 462054A0 */ cvt.s.d $f18, $f10 -/* 065930 80064D30 0C01C327 */ jal allocate_from_main_pool_safe -/* 065934 80064D34 E612001C */ swc1 $f18, 0x1c($s0) -/* 065938 80064D38 AE020024 */ sw $v0, 0x24($s0) -/* 06593C 80064D3C 24040020 */ li $a0, 32 -/* 065940 80064D40 0C01C327 */ jal allocate_from_main_pool_safe -/* 065944 80064D44 02A02825 */ move $a1, $s5 -/* 065948 80064D48 8E190024 */ lw $t9, 0x24($s0) -/* 06594C 80064D4C 00000000 */ nop -/* 065950 80064D50 AF220014 */ sw $v0, 0x14($t9) -/* 065954 80064D54 8E080024 */ lw $t0, 0x24($s0) -/* 065958 80064D58 00000000 */ nop -/* 06595C 80064D5C E51A0020 */ swc1 $f26, 0x20($t0) -/* 065960 80064D60 8E090024 */ lw $t1, 0x24($s0) -/* 065964 80064D64 10000005 */ b .L80064D7C -/* 065968 80064D68 AD370024 */ sw $s7, 0x24($t1) -.L80064D6C: -/* 06596C 80064D6C 25510002 */ addiu $s1, $t2, 2 -/* 065970 80064D70 322BFFFF */ andi $t3, $s1, 0xffff -/* 065974 80064D74 AE000024 */ sw $zero, 0x24($s0) -/* 065978 80064D78 01608825 */ move $s1, $t3 -.L80064D7C: -/* 06597C 80064D7C 00116080 */ sll $t4, $s1, 2 -/* 065980 80064D80 026C9021 */ addu $s2, $s3, $t4 -/* 065984 80064D84 8E4D0000 */ lw $t5, ($s2) -/* 065988 80064D88 24040030 */ li $a0, 48 -/* 06598C 80064D8C 11A00013 */ beqz $t5, .L80064DDC -/* 065990 80064D90 00000000 */ nop -/* 065994 80064D94 0C01C327 */ jal allocate_from_main_pool_safe -/* 065998 80064D98 02A02825 */ move $a1, $s5 -/* 06599C 80064D9C AE020020 */ sw $v0, 0x20($s0) -/* 0659A0 80064DA0 24040008 */ li $a0, 8 -/* 0659A4 80064DA4 0C01C327 */ jal allocate_from_main_pool_safe -/* 0659A8 80064DA8 02A02825 */ move $a1, $s5 -/* 0659AC 80064DAC 8E0E0020 */ lw $t6, 0x20($s0) -/* 0659B0 80064DB0 26310001 */ addiu $s1, $s1, 1 -/* 0659B4 80064DB4 ADC20028 */ sw $v0, 0x28($t6) -/* 0659B8 80064DB8 8E180020 */ lw $t8, 0x20($s0) -/* 0659BC 80064DBC 8E4F0000 */ lw $t7, ($s2) -/* 0659C0 80064DC0 3239FFFF */ andi $t9, $s1, 0xffff -/* 0659C4 80064DC4 A70F0000 */ sh $t7, ($t8) -/* 0659C8 80064DC8 8E040020 */ lw $a0, 0x20($s0) -/* 0659CC 80064DCC 0C019254 */ jal init_lpfilter -/* 0659D0 80064DD0 03208825 */ move $s1, $t9 -/* 0659D4 80064DD4 10000006 */ b .L80064DF0 -/* 0659D8 80064DD8 92CA0024 */ lbu $t2, 0x24($s6) -.L80064DDC: -/* 0659DC 80064DDC 26310001 */ addiu $s1, $s1, 1 -/* 0659E0 80064DE0 3228FFFF */ andi $t0, $s1, 0xffff -/* 0659E4 80064DE4 AE000020 */ sw $zero, 0x20($s0) -/* 0659E8 80064DE8 01008825 */ move $s1, $t0 -/* 0659EC 80064DEC 92CA0024 */ lbu $t2, 0x24($s6) -.L80064DF0: -/* 0659F0 80064DF0 26940001 */ addiu $s4, $s4, 1 -/* 0659F4 80064DF4 3289FFFF */ andi $t1, $s4, 0xffff -/* 0659F8 80064DF8 012A082A */ slt $at, $t1, $t2 -/* 0659FC 80064DFC 1420FF79 */ bnez $at, .L80064BE4 -/* 065A00 80064E00 0120A025 */ move $s4, $t1 -.L80064E04: -/* 065A04 80064E04 8FBF005C */ lw $ra, 0x5c($sp) -/* 065A08 80064E08 C7B50018 */ lwc1 $f21, 0x18($sp) -/* 065A0C 80064E0C C7B4001C */ lwc1 $f20, 0x1c($sp) -/* 065A10 80064E10 C7B70020 */ lwc1 $f23, 0x20($sp) -/* 065A14 80064E14 C7B60024 */ lwc1 $f22, 0x24($sp) -/* 065A18 80064E18 C7B90028 */ lwc1 $f25, 0x28($sp) -/* 065A1C 80064E1C C7B8002C */ lwc1 $f24, 0x2c($sp) -/* 065A20 80064E20 C7BB0030 */ lwc1 $f27, 0x30($sp) -/* 065A24 80064E24 C7BA0034 */ lwc1 $f26, 0x34($sp) -/* 065A28 80064E28 8FB00038 */ lw $s0, 0x38($sp) -/* 065A2C 80064E2C 8FB1003C */ lw $s1, 0x3c($sp) -/* 065A30 80064E30 8FB20040 */ lw $s2, 0x40($sp) -/* 065A34 80064E34 8FB30044 */ lw $s3, 0x44($sp) -/* 065A38 80064E38 8FB40048 */ lw $s4, 0x48($sp) -/* 065A3C 80064E3C 8FB5004C */ lw $s5, 0x4c($sp) -/* 065A40 80064E40 8FB60050 */ lw $s6, 0x50($sp) -/* 065A44 80064E44 8FB70054 */ lw $s7, 0x54($sp) -/* 065A48 80064E48 8FBE0058 */ lw $fp, 0x58($sp) -/* 065A4C 80064E4C 03E00008 */ jr $ra -/* 065A50 80064E50 27BD0060 */ addiu $sp, $sp, 0x60 - diff --git a/lib/asm/non_matchings/unknown_0CA9A0/alLoadPull.s b/lib/asm/non_matchings/unknown_0CA9A0/alAdpcmPull.s similarity index 99% rename from lib/asm/non_matchings/unknown_0CA9A0/alLoadPull.s rename to lib/asm/non_matchings/unknown_0CA9A0/alAdpcmPull.s index be1ca25e..a2642779 100644 --- a/lib/asm/non_matchings/unknown_0CA9A0/alLoadPull.s +++ b/lib/asm/non_matchings/unknown_0CA9A0/alAdpcmPull.s @@ -1,4 +1,4 @@ -glabel alLoadPull +glabel alAdpcmPull /* 0CC7EC 800CBBEC 27BDFF50 */ addiu $sp, $sp, -0xb0 /* 0CC7F0 800CBBF0 AFB70044 */ sw $s7, 0x44($sp) /* 0CC7F4 800CBBF4 AFA700BC */ sw $a3, 0xbc($sp) diff --git a/lib/asm/non_matchings/unknown_0CA9A0/alEnvMixerPull.s b/lib/asm/non_matchings/unknown_0CA9A0/alEnvMixerPull.s index 9dea0b46..cf37e638 100644 --- a/lib/asm/non_matchings/unknown_0CA9A0/alEnvMixerPull.s +++ b/lib/asm/non_matchings/unknown_0CA9A0/alEnvMixerPull.s @@ -17,7 +17,7 @@ glabel jpt_800E95B0 .word L800CA870, L800CA8C4, L800CA8C4, L800CA8C4, L800CA8C4, L800CA8C4, L800CA8C4, L800CA8C4, L800CA8C4, L800CA8C4, L800CA8C4, L800CA460, L800CA460, L800CA22C, L800CA7A8, L800CA828, L800CA460 .text -glabel alEnvMixerPull +glabel alEnvmixerPull /* 0CACD0 800CA0D0 27BDFFA0 */ addiu $sp, $sp, -0x60 /* 0CACD4 800CA0D4 AFBF001C */ sw $ra, 0x1c($sp) /* 0CACD8 800CA0D8 AFA40060 */ sw $a0, 0x60($sp) diff --git a/lib/asm/non_matchings/unknown_0CA9A0/alLoadParam.s b/lib/asm/non_matchings/unknown_0CA9A0/alLoadParam.s index ec0bbd7b..7079fa0c 100644 --- a/lib/asm/non_matchings/unknown_0CA9A0/alLoadParam.s +++ b/lib/asm/non_matchings/unknown_0CA9A0/alLoadParam.s @@ -10,7 +10,7 @@ glabel alLoadParam /* 0CC160 800CB560 AC860028 */ sw $a2, 0x28($a0) /* 0CC164 800CB564 8CCE0000 */ lw $t6, ($a2) /* 0CC168 800CB568 AC800038 */ sw $zero, 0x38($a0) -/* 0CC16C 800CB56C 3C0F800D */ lui $t7, %hi(alLoadPull) # $t7, 0x800d +/* 0CC16C 800CB56C 3C0F800D */ lui $t7, %hi(alAdpcmPull) # $t7, 0x800d /* 0CC170 800CB570 AC8E0044 */ sw $t6, 0x44($a0) /* 0CC174 800CB574 90C20008 */ lbu $v0, 8($a2) /* 0CC178 800CB578 50400007 */ beql $v0, $zero, .L800CB598 @@ -22,7 +22,7 @@ glabel alLoadParam /* 0CC190 800CB590 8FBF0014 */ lw $ra, 0x14($sp) /* 0CC194 800CB594 8CE20028 */ lw $v0, 0x28($a3) .L800CB598: -/* 0CC198 800CB598 25EFBBEC */ addiu $t7, %lo(alLoadPull) # addiu $t7, $t7, -0x4414 +/* 0CC198 800CB598 25EFBBEC */ addiu $t7, %lo(alAdpcmPull) # addiu $t7, $t7, -0x4414 /* 0CC19C 800CB59C ACEF0004 */ sw $t7, 4($a3) /* 0CC1A0 800CB5A0 8C580004 */ lw $t8, 4($v0) /* 0CC1A4 800CB5A4 24050009 */ li $a1, 9 diff --git a/lib/src/al/global_asm/unknown_0CA9A0.c b/lib/src/al/global_asm/unknown_0CA9A0.c index a97ce015..2a1fc0d6 100644 --- a/lib/src/al/global_asm/unknown_0CA9A0.c +++ b/lib/src/al/global_asm/unknown_0CA9A0.c @@ -41,8 +41,8 @@ GLOBAL_ASM("lib/asm/non_matchings/unknown_0CA9A0/func_800CB2D4.s") GLOBAL_ASM("lib/asm/non_matchings/unknown_0CA9A0/func_800CB498.s") GLOBAL_ASM("lib/asm/non_matchings/unknown_0CA9A0/alLoadParam.s") GLOBAL_ASM("lib/asm/non_matchings/unknown_0CA9A0/alRaw16Pull.s") -//Called by alLoadPull +//Called by alAdpcmPull. _decodeChunk? GLOBAL_ASM("lib/asm/non_matchings/unknown_0CA9A0/func_800CBAC0.s") -GLOBAL_ASM("lib/asm/non_matchings/unknown_0CA9A0/alLoadPull.s") +GLOBAL_ASM("lib/asm/non_matchings/unknown_0CA9A0/alAdpcmPull.s") GLOBAL_ASM("lib/asm/non_matchings/unknown_0CA9A0/alResampleParam.s") GLOBAL_ASM("lib/asm/non_matchings/unknown_0CA9A0/alResamplePull.s") diff --git a/lib/src/libc/ldiv.c b/lib/src/libc/ldiv.c index 395591ee..8d13b556 100644 --- a/lib/src/libc/ldiv.c +++ b/lib/src/libc/ldiv.c @@ -3,7 +3,7 @@ #include "macros.h" #include -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT //This needs to be compiled with mips3, which isn't yet supported ldiv_t ldiv(long num, long denom) { diff --git a/lib/src/mips1/al/alFxNew.c b/lib/src/mips1/al/alFxNew.c index f505bad8..6987fc3d 100644 --- a/lib/src/mips1/al/alFxNew.c +++ b/lib/src/mips1/al/alFxNew.c @@ -1,10 +1,31 @@ /* The comment below is needed for this file to be picked up by generate_ld */ /* RAM_POS: 0x80064950 */ +/*==================================================================== + * drvrNew.c + * + * Copyright 1993, Silicon Graphics, Inc. + * All Rights Reserved. + * + * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, + * Inc.; the contents of this file may not be disclosed to third + * parties, copied or duplicated in any form, in whole or in part, + * without the prior written permission of Silicon Graphics, Inc. + * + * RESTRICTED RIGHTS LEGEND: + * Use, duplication or disclosure by the Government is subject to + * restrictions as set forth in subdivision (c)(1)(ii) of the Rights + * in Technical Data and Computer Software clause at DFARS + * 252.227-7013, and/or in similar or successor clauses in the FAR, + * DOD or NASA FAR Supplement. Unpublished - rights reserved under the + * Copyright Laws of the United States. + *====================================================================*/ #include "types.h" #include "macros.h" #include "libultra_internal.h" #include "audio_internal.h" +#include "audio.h" +#include "src/memory.h" /* * WARNING: THE FOLLOWING CONSTANT MUST BE KEPT IN SYNC @@ -18,7 +39,8 @@ */ #define ms *(((s32)((f32)44.1))&~0x7) -s32 SMALLROOM_PARAMS[26] = { + +static s32 SMALLROOM_PARAMS[26] = { /* sections length */ 3, 100 ms, /* chorus chorus filter @@ -28,7 +50,7 @@ s32 SMALLROOM_PARAMS[26] = { 0, 60 ms, 5000, 0, 0, 0, 0, 0x5000 }; -s32 BIGROOM_PARAMS[34] = { +static s32 BIGROOM_PARAMS[34] = { /* sections length */ 4, 100 ms, /* chorus chorus filter @@ -39,7 +61,7 @@ s32 BIGROOM_PARAMS[34] = { 0, 94 ms, 8000, 0, 0, 0, 0, 0x5000 }; -s32 ECHO_PARAMS[10] = { +static s32 ECHO_PARAMS[10] = { /* sections length */ 1, 200 ms, /* chorus chorus filter @@ -47,7 +69,7 @@ s32 ECHO_PARAMS[10] = { 0, 179 ms, 12000, 0, 0x7fff, 0, 0, 0 }; -s32 CHORUS_PARAMS[10] = { +static s32 CHORUS_PARAMS[10] = { /* sections length */ 1, 20 ms, /* chorus chorus filter @@ -55,7 +77,7 @@ s32 CHORUS_PARAMS[10] = { 0, 5 ms, 0x4000, 0, 0x7fff, 7600, 700, 0 }; -s32 FLANGE_PARAMS[10] = { +static s32 FLANGE_PARAMS[10] = { /* sections length */ 1, 20 ms, /* chorus chorus filter @@ -63,26 +85,13 @@ s32 FLANGE_PARAMS[10] = { 0, 5 ms, 0, 0x5fff, 0x7fff, 380, 500, 0 }; -s32 NULL_PARAMS[10] = { +static s32 NULL_PARAMS[10] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; -extern s32 alAuxBusPull; -extern s32 alAuxBusParam; -extern s32 alEnvMixerPull; -extern s32 alEnvmixerParam; -extern s32 alLoadParam; -extern s32 alLoadPull; -extern s32 alResampleParam; -extern s32 alResamplePull; -extern s32 alMainBusParam; -extern s32 alMainBusPull; -extern s32 alSaveParam; -extern s32 alSavePull; -void init_lpfilter(ALLowPass *lp) -{ +void init_lpfilter(ALLowPass *lp) { s32 i, temp; s16 fc; f64 ffc, fcoef; @@ -104,11 +113,86 @@ void init_lpfilter(ALLowPass *lp) } } -GLOBAL_ASM("lib/asm/non_matchings/alFxNew/alFxNew.s") +//This function differs from libreultra's, but still mostly the same +void alFxNew(ALFx *r, ALSynConfig *c, s16 bus, UNUSED ALHeap *hp) { + u16 i, j, k; + s32 *param = 0; + ALFilter *f = (ALFilter *) r; + ALDelay *d; + alFilterNew(f, 0, alFxParam, AL_FX); + f->handler = alFxPull; + r->paramHdl = (ALSetFXParam)alFxParamHdl; + switch (c->fxType[bus]) { + case AL_FX_SMALLROOM: param = SMALLROOM_PARAMS; break; + case AL_FX_BIGROOM: param = BIGROOM_PARAMS; break; + case AL_FX_ECHO: param = ECHO_PARAMS; break; + case AL_FX_CHORUS: param = CHORUS_PARAMS; break; + case AL_FX_FLANGE: param = FLANGE_PARAMS; break; + case AL_FX_CUSTOM: param = (&c->params)[bus]; break; + default: param = NULL_PARAMS; break; + } + j = 0; + r->section_count = param[j++]; + r->length = param[j++]; + r->delay = allocate_from_main_pool_safe(sizeof(ALDelay) * r->section_count, COLOR_TAG_CYAN); + r->base = allocate_from_main_pool_safe(sizeof(s16) * r->length, COLOR_TAG_CYAN); + r->input = r->base; + for ( k=0; k < r->length; k++) + r->base[k] = 0; + for ( i=0; isection_count; i++ ) { + d = &r->delay[i]; + d->input = param[j++]; + d->output = param[j++]; + d->fbcoef = param[j++]; + d->ffcoef = param[j++]; + d->gain = param[j++]; + if (param[j]) { + #define RANGE 2.0 + //d->rsinc = ((f32) param[j++])/0xffffff; + d->rsinc = ((((f32)param[j++])/1000) * RANGE)/c->outputRate; + /* + * the following constant is derived from: + * + * ratio = 2^(cents/1200) + * + * and therefore for hundredths of a cent + * x + * ln(ratio) = --------------- + * (120,000)/ln(2) + * where + * 120,000/ln(2) = 173123.40... + */ + #define CONVERT 173123.404906676 + #define LENGTH (d->output - d->input) + d->rsgain = (((f32) param[j++])/CONVERT) * LENGTH; + d->rsval = 1.0; + d->rsdelta = 0.0; + d->rs = allocate_from_main_pool_safe(sizeof(ALResampler), COLOR_TAG_CYAN); + d->rs->state = allocate_from_main_pool_safe(sizeof(RESAMPLE_STATE), COLOR_TAG_CYAN); + d->rs->delta = 0.0; + d->rs->first = 1; + } else { + d->rs = 0; + j++; + j++; + } + if (param[j]) { + d->lp = allocate_from_main_pool_safe(sizeof(ALLowPass), COLOR_TAG_CYAN); + d->lp->fstate = allocate_from_main_pool_safe(sizeof(POLEF_STATE), COLOR_TAG_CYAN); + d->lp->fc = param[j++]; + init_lpfilter(d->lp); + } else { + d->lp = 0; + j++; + } + } +} + +void alEnvmixerNew(ALEnvMixer *e, ALHeap *hp) { + alFilterNew((ALFilter *) e, alEnvmixerPull, alEnvmixerParam, AL_ENVMIX); + + e->state = alHeapAlloc(hp, 1, sizeof(ENVMIX_STATE)); -void alEnvmixerNew(ALEnvMixer *e, s32 arg1) { - alFilterNew(e, &alEnvMixerPull, &alEnvmixerParam, 4); - e->state = alHeapDBAlloc(0, 0, arg1, 1, 0x50); e->first = 1; e->motion = AL_STOPPED; e->volume = 1; @@ -120,6 +204,8 @@ void alEnvmixerNew(ALEnvMixer *e, s32 arg1) { e->wetamt = 0; e->lratm = 1; e->lratl = 0; + e->lratm = 1; + e->lratl = 0; e->delta = 0; e->segEnd = 0; e->pan = 0; @@ -128,44 +214,72 @@ void alEnvmixerNew(ALEnvMixer *e, s32 arg1) { e->sources = 0; } -void alLoadNew(ALLoadFilter *arg0, s32 (*arg1)(s32*), s32 arg2) { - alFilterNew(arg0, &alLoadPull, &alLoadParam, 0); - arg0->state = alHeapDBAlloc(0, 0, arg2, 1, 0x20); - arg0->lstate = alHeapDBAlloc(0, 0, arg2, 1, 0x20); - arg0->dma = arg1(&arg0->dmaState); - arg0->lastsam = 0; - arg0->first = 1; - arg0->memin = 0; +void alLoadNew(ALLoadFilter *f, ALDMANew dmaNew, ALHeap *hp) { + UNUSED s32 i; + + /* + * init filter superclass + */ + + alFilterNew((ALFilter *) f, alAdpcmPull, alLoadParam, AL_ADPCM); + + f->state = alHeapAlloc(hp, 1, sizeof(ADPCM_STATE)); + f->lstate = alHeapAlloc(hp, 1, sizeof(ADPCM_STATE)); + + f->dma = dmaNew(&f->dmaState); + + /* + * init the adpcm state + */ + f->lastsam = 0; + f->first = 1; + f->memin = 0; } void alResampleNew(ALResampler *r, ALHeap *hp) { - alFilterNew(r, &alResamplePull, &alResampleParam, 1); - r->state = alHeapDBAlloc(0, 0, hp, 1, 0x20); - r->first = 1; + alFilterNew((ALFilter *) r, alResamplePull, alResampleParam, AL_RESAMPLE); + + /* + * Init resampler state + */ + r->state = alHeapAlloc(hp, 1, sizeof(RESAMPLE_STATE)); + r->delta = 0.0; + r->first = 1; r->motion = AL_STOPPED; + r->ratio = 1.0; r->upitch = 0; r->ctrlList = 0; r->ctrlTail = 0; - r->delta = 0.0f; - r->ratio = 1.0f; + + /* state in the ucode is initialized by the A_INIT flag */ } void alAuxBusNew(ALAuxBus *m, void *sources, s32 maxSources) { - alFilterNew(m, &alAuxBusPull, &alAuxBusParam, 6); + alFilterNew((ALFilter *) m, alAuxBusPull, alAuxBusParam, AL_AUXBUS); m->sourceCount = 0; m->maxSources = maxSources; - m->sources = sources; + m->sources = (ALFilter **)sources; } void alMainBusNew(ALMainBus *m, void *sources, s32 maxSources) { - alFilterNew(m, &alMainBusPull, &alMainBusParam, 7); + alFilterNew((ALFilter *) m, alMainBusPull, alMainBusParam, AL_MAINBUS); m->sourceCount = 0; m->maxSources = maxSources; - m->sources = sources; + m->sources = (ALFilter **)sources; } void alSaveNew(ALSave *f) { - alFilterNew(f, &alSavePull, &alSaveParam, AL_SAVE); + /* + * init filter superclass + */ + + alFilterNew((ALFilter *) f, alSavePull, alSaveParam, AL_SAVE); + + /* + * init the save state, which is a virtual dram address + */ + f->dramout = 0; f->first = 1; + } diff --git a/lib/src/mips1/al/alSynAllocFX.c b/lib/src/mips1/al/alSynAllocFX.c index ba08be57..b3da0476 100644 --- a/lib/src/mips1/al/alSynAllocFX.c +++ b/lib/src/mips1/al/alSynAllocFX.c @@ -5,14 +5,11 @@ #include "macros.h" #include "audio_internal.h" -#ifdef NON_MATCHING -void alFxNew(ALFx *r, ALSynConfig *c, s16 bus); -s32 alFxParam(void *filter, s32 paramID, void *param); -s32 alMainBusParam(void *filter, s32 paramID, void *param); +#ifdef NON_EQUIVALENT // This is very close to matching. ALFxRef *alSynAllocFX(ALSynth *s, s16 bus, ALSynConfig *c, ALHeap *hp) { - alFxNew(s->auxBus[bus].fx, c, bus); + alFxNew(s->auxBus[bus].fx, c, bus, hp); alFxParam(s->auxBus[bus].fx, AL_FILTER_SET_SOURCE, &s->auxBus[bus]); alMainBusParam(s->mainBus, AL_FILTER_ADD_SOURCE, s->auxBus[bus].fx); diff --git a/lib/src/mips1/al/synthesizer.c b/lib/src/mips1/al/synthesizer.c index 5396d50f..f7d7eebb 100644 --- a/lib/src/mips1/al/synthesizer.c +++ b/lib/src/mips1/al/synthesizer.c @@ -5,7 +5,7 @@ #include "audio_internal.h" #include "macros.h" -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT s32 __nextSampleTime(ALSynth *drvr, ALPlayer **client); s32 _timeToSamplesNoRound(ALSynth *ALSynth, s32 micros); diff --git a/lib/src/mips1/os/osCreatePiManager.c b/lib/src/mips1/os/osCreatePiManager.c index 60f73842..c72bcecb 100644 --- a/lib/src/mips1/os/osCreatePiManager.c +++ b/lib/src/mips1/os/osCreatePiManager.c @@ -4,11 +4,11 @@ #include "types.h" #include "libultra_internal.h" #include "stacks.h" +#include "lib/src/os/piint.h" extern OSMesgQueue __osPiAccessQueue; extern u32 __osPiAccessQueueEnabled; extern OSDevMgr __osPiDevMgr; -void __osDevMgrMain(void); // bss variables OSThread piThread; diff --git a/lib/src/mips1/sc/sched.c b/lib/src/mips1/sc/sched.c index 7dd7d928..4d644169 100644 --- a/lib/src/mips1/sc/sched.c +++ b/lib/src/mips1/sc/sched.c @@ -1,11 +1,13 @@ /* The comment below is needed for this file to be picked up by generate_ld */ /* RAM_POS: 0x80079350 */ +#include #include "sched.h" #include "types.h" #include "macros.h" #include "f3ddkr.h" #include "libultra_internal.h" +#include "viint.h" /* * private typedefs and defines @@ -68,6 +70,9 @@ s32 D_80126128[18]; /*******************************/ +static void __scMain(void *arg); +static s32 __scSchedule(OSSched *sc, OSScTask **sp, OSScTask **dp, s32 availRCP); + void osCreateScheduler(OSSched *sc, void *stack, OSPri priority, u8 mode, u8 numFields) { sc->curRSPTask = 0; sc->curRDPTask = 0; @@ -542,7 +547,7 @@ static s32 __scSchedule(OSSched *sc, OSScTask **sp, OSScTask **dp, s32 availRCP) *dp = gfx; avail &= ~OS_SC_DP; - if (avail & OS_SC_DP == 0) + if ((avail & OS_SC_DP) == 0) assert(sc->curRDPTask == gfx); } diff --git a/lib/src/os/__osSpRawStartDma.c b/lib/src/os/__osSpRawStartDma.c index a887f301..0a3359fe 100644 --- a/lib/src/os/__osSpRawStartDma.c +++ b/lib/src/os/__osSpRawStartDma.c @@ -2,6 +2,7 @@ /* RAM_POS: 0x800D6440 */ #include "libultra_internal.h" +#include "osint.h" s32 __osSpRawStartDma(s32 direction, u32 devAddr, void *dramAddr, u32 size) { if (__osSpDeviceBusy()) diff --git a/lib/src/os/__osViSwapContext.c b/lib/src/os/__osViSwapContext.c index cc2153af..38b8e1b4 100644 --- a/lib/src/os/__osViSwapContext.c +++ b/lib/src/os/__osViSwapContext.c @@ -16,8 +16,8 @@ struct __osThreadTail __osThreadTail = {0, -1}; OSThread *__osRunQueue = (OSThread *)&__osThreadTail; OSThread *__osActiveQueue = (OSThread *)&__osThreadTail; -extern OSThread *__osRunningThread = NULL; -extern OSThread *__osFaultedThread = NULL; +OSThread *__osRunningThread = NULL; +OSThread *__osFaultedThread = NULL; void __osViSwapContext() { register OSViMode *vm; diff --git a/lib/src/os/contreaddata.c b/lib/src/os/contreaddata.c index 4d7ced8e..175bfca8 100644 --- a/lib/src/os/contreaddata.c +++ b/lib/src/os/contreaddata.c @@ -5,6 +5,7 @@ #include "macros.h" #include "libultra_internal.h" #include "controller.h" +#include "siint.h" static void __osPackReadData(void); s32 osContStartReadData(OSMesgQueue *mq) { diff --git a/lib/src/os/controller.c b/lib/src/os/controller.c index 23108dec..43643f56 100644 --- a/lib/src/os/controller.c +++ b/lib/src/os/controller.c @@ -5,6 +5,7 @@ #include "macros.h" #include "libultra_internal.h" #include "controller.h" +#include "siint.h" #define HALF_MIL_CYLCES 500000U #define ONE_MIL_CYLCES 1000000U diff --git a/lib/src/os/devmgr.c b/lib/src/os/devmgr.c index 9cbfb466..5fa26c91 100644 --- a/lib/src/os/devmgr.c +++ b/lib/src/os/devmgr.c @@ -3,6 +3,7 @@ #include "libultra_internal.h" #include "piint.h" +#include "osint.h" void __osDevMgrMain(void *args) { OSIoMesg *mb; diff --git a/lib/src/os/osAiSetNextBuffer.c b/lib/src/os/osAiSetNextBuffer.c index 55b71eae..458a7a6b 100644 --- a/lib/src/os/osAiSetNextBuffer.c +++ b/lib/src/os/osAiSetNextBuffer.c @@ -3,6 +3,7 @@ #include "types.h" #include "libultra_internal.h" +#include "osint.h" u8 hdwrBugFlag = 0; diff --git a/lib/src/os/osEepromProbe.c b/lib/src/os/osEepromProbe.c index 20c176c0..351e8e7e 100644 --- a/lib/src/os/osEepromProbe.c +++ b/lib/src/os/osEepromProbe.c @@ -2,6 +2,7 @@ /* RAM_POS: 0x800CE210 */ #include "libultra_internal.h" +#include "siint.h" s32 __osEepStatus(OSMesgQueue *mq, OSContStatus *data); diff --git a/lib/src/os/osJamMesg.c b/lib/src/os/osJamMesg.c index bb142355..e033215f 100644 --- a/lib/src/os/osJamMesg.c +++ b/lib/src/os/osJamMesg.c @@ -3,6 +3,7 @@ /* RAM_POS: 0x800D36A0 */ #include "libultra_internal.h" +#include "osint.h" extern OSThread *__osRunningThread; diff --git a/lib/src/os/osRecvMesg.c b/lib/src/os/osRecvMesg.c index 9d817688..5f77c9fa 100644 --- a/lib/src/os/osRecvMesg.c +++ b/lib/src/os/osRecvMesg.c @@ -4,6 +4,7 @@ #include "types.h" #include "macros.h" #include "libultra_internal.h" +#include "osint.h" extern OSThread *__osRunningThread; diff --git a/lib/src/os/osSendMesg.c b/lib/src/os/osSendMesg.c index 5120f52a..2017a20f 100644 --- a/lib/src/os/osSendMesg.c +++ b/lib/src/os/osSendMesg.c @@ -1,7 +1,7 @@ /* The comment below is needed for this file to be picked up by generate_ld */ /* RAM_POS: 0x800C8E30 */ #include "libultra_internal.h" - +#include "osint.h" extern OSThread *__osRunningThread; s32 osSendMesg(OSMesgQueue *mq, OSMesg msg, s32 flags) { diff --git a/lib/src/os/osSetThreadPri.c b/lib/src/os/osSetThreadPri.c index 7c9a704a..041d8e1b 100644 --- a/lib/src/os/osSetThreadPri.c +++ b/lib/src/os/osSetThreadPri.c @@ -2,6 +2,7 @@ /* RAM_POS: 0x800CC840 */ #include "libultra_internal.h" +#include "osint.h" extern OSThread *__osRunningThread; extern OSThread *__osRunQueue; diff --git a/lib/src/os/osStartThread.c b/lib/src/os/osStartThread.c index 753e304b..ca2cbb1b 100644 --- a/lib/src/os/osStartThread.c +++ b/lib/src/os/osStartThread.c @@ -2,6 +2,7 @@ /* RAM_POS: 0x800C89A0 */ #include "libultra_internal.h" +#include "osint.h" extern OSThread *__osRunningThread; extern OSThread *__osRunQueue; diff --git a/lib/src/os/osStopThread.c b/lib/src/os/osStopThread.c index 5e163766..d1b4aa68 100644 --- a/lib/src/os/osStopThread.c +++ b/lib/src/os/osStopThread.c @@ -2,6 +2,7 @@ /* RAM_POS: 0x800C8AF0 */ #include "libultra_internal.h" +#include "osint.h" extern OSThread *__osRunningThread; diff --git a/lib/src/os/osTimer.c b/lib/src/os/osTimer.c index 7eaa0272..62238420 100644 --- a/lib/src/os/osTimer.c +++ b/lib/src/os/osTimer.c @@ -15,7 +15,7 @@ extern u32 __osTimerCounter; OSTime __osInsertTimer(OSTimer *t); -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT //Seems to be a mismatch based on where __osCurrentTime is defined. //Scratch proving that: https://decomp.me/scratch/OB3iP void __osTimerServicesInit(void) { diff --git a/lib/src/os/osViGetCurrentFramebuffer.c b/lib/src/os/osViGetCurrentFramebuffer.c index 9929a6d8..001a05a9 100644 --- a/lib/src/os/osViGetCurrentFramebuffer.c +++ b/lib/src/os/osViGetCurrentFramebuffer.c @@ -4,7 +4,7 @@ #include "libultra_internal.h" #include "viint.h" -void *osViGetCurrentFramebuffer(void){ +void *osViGetCurrentFramebuffer(void) { register u32 saveMask; void *framep; diff --git a/lib/src/os/osViGetNextFramebuffer.c b/lib/src/os/osViGetNextFramebuffer.c index a2419c6c..da39319f 100644 --- a/lib/src/os/osViGetNextFramebuffer.c +++ b/lib/src/os/osViGetNextFramebuffer.c @@ -4,7 +4,7 @@ #include "libultra_internal.h" #include "viint.h" -void *osViGetNextFramebuffer(void){ +void *osViGetNextFramebuffer(void) { register u32 saveMask; void *framep; diff --git a/lib/src/os/osViMgr.c b/lib/src/os/osViMgr.c index 0789aec4..b518ab5f 100644 --- a/lib/src/os/osViMgr.c +++ b/lib/src/os/osViMgr.c @@ -5,6 +5,7 @@ #include "macros.h" #include "libultra_internal.h" #include "viint.h" +#include "osint.h" extern OSTime __osCurrentTime; extern u32 __osBaseCounter; @@ -64,7 +65,7 @@ void osCreateViManager(OSPri pri) { } } -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT void __osTimerInterrupt(void); //Fails due to how retrace is declared. Not sure how to fix it. void viMgrMain(void *arg) { diff --git a/lib/src/os/osVirtualToPhysical.c b/lib/src/os/osVirtualToPhysical.c index 24844b0b..c65c128f 100644 --- a/lib/src/os/osVirtualToPhysical.c +++ b/lib/src/os/osVirtualToPhysical.c @@ -1,9 +1,8 @@ /* The comment below is needed for this file to be picked up by generate_ld */ /* RAM_POS: 0x800C8CF0 */ -#include "types.h" -#include "macros.h" -#include "PR/R4300.h" +#include "libultra_internal.h" +#include "osint.h" u32 osVirtualToPhysical(void *addr) { if (IS_KSEG0(addr)) { diff --git a/lib/src/os/pfsreadwritefile.c b/lib/src/os/pfsreadwritefile.c index 122087a6..edd54dbb 100644 --- a/lib/src/os/pfsreadwritefile.c +++ b/lib/src/os/pfsreadwritefile.c @@ -64,8 +64,9 @@ s32 osPfsReadWriteFile(OSPfs *pfs, s32 file_no, u8 flag, int offset, int size_in return PFS_ERR_INCONSISTENT; } - if (flag == PFS_READ && (dir.status & DIR_STATUS_OCCUPIED) == 0) + if (flag == PFS_READ && (dir.status & DIR_STATUS_OCCUPIED) == 0) { return PFS_ERR_BAD_DATA; + } bank = -1; cur_block = offset / BLOCKSIZE; diff --git a/lib/src/os/piacs.c b/lib/src/os/piacs.c index 34b49c3a..cd163c65 100644 --- a/lib/src/os/piacs.c +++ b/lib/src/os/piacs.c @@ -36,21 +36,21 @@ void __osPiRelAccess(void) { const du P_cosf[] = { -{0x3ff00000, 0x00000000}, -{0xbfc55554, 0xbc83656d}, -{0x3f8110ed, 0x3804c2a0}, -{0xbf29f6ff, 0xeea56814}, -{0x3ec5dbdf, 0x0e314bfe}, +{{0x3ff00000, 0x00000000}}, +{{0xbfc55554, 0xbc83656d}}, +{{0x3f8110ed, 0x3804c2a0}}, +{{0xbf29f6ff, 0xeea56814}}, +{{0x3ec5dbdf, 0x0e314bfe}}, }; const du rpi_cosf = -{0x3fd45f30, 0x6dc9c883}; +{{0x3fd45f30, 0x6dc9c883}}; const du pihi_cosf = -{0x400921fb, 0x50000000}; +{{0x400921fb, 0x50000000}}; const du pilo_cosf = -{0x3e6110b4, 0x611a6263}; +{{0x3e6110b4, 0x611a6263}}; const fu zero_cosf = {0x00000000}; @@ -61,21 +61,21 @@ const int COSF_FILE_PADDING[3] = { 0 }; const du P_sinf[] = { -{0x3ff00000, 0x00000000}, -{0xbfc55554, 0xbc83656d}, -{0x3f8110ed, 0x3804c2a0}, -{0xbf29f6ff, 0xeea56814}, -{0x3ec5dbdf, 0x0e314bfe}, +{{0x3ff00000, 0x00000000}}, +{{0xbfc55554, 0xbc83656d}}, +{{0x3f8110ed, 0x3804c2a0}}, +{{0xbf29f6ff, 0xeea56814}}, +{{0x3ec5dbdf, 0x0e314bfe}}, }; const du rpi_sinf = -{0x3fd45f30, 0x6dc9c883}; +{{0x3fd45f30, 0x6dc9c883}}; const du pihi_sinf = -{0x400921fb, 0x50000000}; +{{0x400921fb, 0x50000000}}; const du pilo_sinf = -{0x3e6110b4, 0x611a6263}; +{{0x3e6110b4, 0x611a6263}}; const fu zero_sinf = {0x00000000}; diff --git a/lib/src/os/sptask.c b/lib/src/os/sptask.c index 61523176..1c5f23c7 100644 --- a/lib/src/os/sptask.c +++ b/lib/src/os/sptask.c @@ -4,6 +4,8 @@ #include "libultra_internal.h" #include "viint.h" #include "PR/sptask.h" +#include "osint.h" +#include "macros.h" #define _osVirtualToPhysical(ptr) \ if (ptr != NULL) { \ @@ -40,19 +42,19 @@ void osSpTaskLoad(OSTask *intp) { while (__osSpSetPc(SP_IMEM_START) == -1) ; - while (__osSpRawStartDma(1, (SP_IMEM_START - sizeof(*tp)), tp, + while (__osSpRawStartDma(OS_WRITE, (SP_IMEM_START - sizeof(*tp)), tp, sizeof(OSTask)) == -1) ; while (__osSpDeviceBusy()) ; - while (__osSpRawStartDma(1, SP_IMEM_START, tp->t.ucode_boot, + while (__osSpRawStartDma(OS_WRITE, SP_IMEM_START, tp->t.ucode_boot, tp->t.ucode_boot_size) == -1) ; } -void osSpTaskStartGo(OSTask *tp) { +void osSpTaskStartGo(UNUSED OSTask *tp) { while (__osSpDeviceBusy()); __osSpSetStatus(SP_SET_INTR_BREAK | SP_CLR_SSTEP | SP_CLR_BROKE | SP_CLR_HALT); diff --git a/src/asset_loading.c b/src/asset_loading.c index e2887511..e3263520 100644 --- a/src/asset_loading.c +++ b/src/asset_loading.c @@ -56,7 +56,7 @@ s32 *load_asset_section_from_rom(u32 assetIndex) { return out; } -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT // Unused. // This has regalloc & stack issues. u8 *load_compressed_asset_from_rom(u32 assetIndex, s32 arg1) { diff --git a/src/camera.c b/src/camera.c index 628841dc..9ba7b4c9 100644 --- a/src/camera.c +++ b/src/camera.c @@ -144,7 +144,7 @@ u8 sPlayerID[16]; /******************************/ -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT extern s32 D_B0000578; void func_80065EA0(void) { @@ -362,7 +362,7 @@ void func_800665E8(s32 arg0) { } } -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT // Has regalloc/stack issues // Proposed name: init_viewports @@ -574,10 +574,10 @@ UNUSED void copy_framebuffer_size_to_coords(s32 *x1, s32 *y1, s32 *x2, s32 *y2) *y2 = GET_VIDEO_HEIGHT(widthAndHeight); } -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT // Still a work-in-progress but it doesn't seem to cause any problems, -// which is why it is labeled under NON_MATCHING +// which is why it is labeled under NON_EQUIVALENT #define SCISSOR_INTERLACE G_SC_NON_INTERLACE @@ -889,7 +889,7 @@ void func_80069F28(f32 arg0) { } } -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT /** * Unused function that prints out the passed matrix values to the debug output. * This function prints in fixed point. diff --git a/src/controller_pak.c b/src/controller_pak.c index 42b11312..bd326e81 100644 --- a/src/controller_pak.c +++ b/src/controller_pak.c @@ -96,7 +96,7 @@ void func_80072298(u8 arg0) { func_80072708(); } -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT // Unused. Has regalloc issues. s32 func_800722E8(s16 arg0) { if (arg0 < 0 || arg0 >= 4) { @@ -118,7 +118,7 @@ void func_80072708(void) { GLOBAL_ASM("asm/non_matchings/controller_pak/func_80072718.s") -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT s32 func_80072C54(s32 arg0) { // v0 v1 a1 a2 a3 t0 t1 t2 t3 t4 t5 t6 t7 t8 u32 v0; @@ -340,7 +340,7 @@ GLOBAL_ASM("asm/non_matchings/controller_pak/func_8007480C.s") GLOBAL_ASM("asm/non_matchings/controller_pak/func_80074874.s") -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT s64 func_8007480C(u64 arg0); // regalloc issues s32 func_8007497C(u64 *arg0) { @@ -359,7 +359,7 @@ s32 func_8007497C(u64 *arg0) { GLOBAL_ASM("asm/non_matchings/controller_pak/func_8007497C.s") #endif -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT // regalloc issues s16 func_80074A4C(GhostHeader *ghostHeader) { s16 i; @@ -388,7 +388,7 @@ void func_80074AA8(GhostHeader *ghostHeader, s16 characterID, s16 time, s16 node ghostHeader->checksum = func_80074A4C(ghostHeader); } -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT s32 func_80074B1C(void) { return (0x1100 * 6) + 0x100; // -O2 optimizes this down to "return 0x6700;". } @@ -493,7 +493,7 @@ s32 func_80076194(s32 controllerIndex, s32 *arg1, s32 *arg2) { return phi_v1; } -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT // regalloc & stack issues // Rename delete_file_from_controller_pak? s32 func_800762C8(s32 controllerIndex, s32 fileNum) { @@ -552,23 +552,17 @@ s32 read_data_from_controller_pak(s32 controllerIndex, s32 fileNum, u8 *data, s3 GLOBAL_ASM("asm/non_matchings/controller_pak/func_800766D4.s") -#ifdef NON_MATCHING -// Stack issues s32 func_80076924(s32 controllerIndex, s32 arg1, s32 *arg2) { - s32 sp18; + OSPfsState state; *arg2 = 0; - if (!osPfsFileState(&pfs[controllerIndex], arg1, &sp18)) { - *arg2 = sp18; + if (osPfsFileState(&pfs[controllerIndex], arg1, &state) == 0) { + *arg2 = state.file_size; return 0; } return 9; } -#else -GLOBAL_ASM("asm/non_matchings/controller_pak/func_80076924.s") -#endif - GLOBAL_ASM("asm/non_matchings/controller_pak/func_8007698C.s") GLOBAL_ASM("asm/non_matchings/controller_pak/func_80076A38.s") diff --git a/src/fade_transition.c b/src/fade_transition.c index e96cf9fb..fceee67b 100644 --- a/src/fade_transition.c +++ b/src/fade_transition.c @@ -230,7 +230,7 @@ u32 func_800C018C(void) { } } -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT // Regalloc issue. s32 func_800C01D8(FadeTransition *transition) { @@ -438,7 +438,7 @@ void render_fade_barndoor_vertical(Gfx **dlist, UNUSED s32 arg1, UNUSED s32 arg2 GLOBAL_ASM("asm/non_matchings/fade_transition/func_800C15D4.s") GLOBAL_ASM("asm/non_matchings/fade_transition/func_800C1EE8.s") -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT void render_fade_circle(Gfx **dlist, s32 arg1, s32 arg2) { u8 *addr, *addr2; func_8007B3D0(dlist); @@ -497,7 +497,7 @@ void render_fade_barndoor_diagonal(Gfx **dlist, s32 arg1, s32 arg2) { GLOBAL_ASM("asm/non_matchings/fade_transition/func_800C2640.s") -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT void func_800C27A0(s32 updateRate) { //do { if (sTransitionFadeTimer > 0) { diff --git a/src/font.c b/src/font.c index bd15a94d..098ec934 100644 --- a/src/font.c +++ b/src/font.c @@ -155,7 +155,7 @@ void func_800C4164(s32 arg0) { D_8012A7F0 = arg0; } -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT // Mostly has regalloc issues. void func_800C4170(s32 arg0) { if (arg0 < gNumberOfFonts) { @@ -178,7 +178,7 @@ void func_800C4170(s32 arg0) { GLOBAL_ASM("asm/non_matchings/font/func_800C4170.s") #endif -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT // Mostly has regalloc issues. void func_800C422C(s32 fontID) { if (fontID < gNumberOfFonts) { @@ -213,7 +213,7 @@ void set_text_font(s32 fontID) { } } -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT // Unused. Has regalloc issues TextureHeader *func_800C4318(s32 font, u8 arg1) { @@ -292,7 +292,7 @@ void func_800C4510(Gfx **displayList, s32 arg1, s32 xpos, s32 ypos, char *text, GLOBAL_ASM("asm/non_matchings/font/func_800C45A4.s") // Should be functionally equivalent. -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT s32 func_800C4DA0(u8 *text, s32 x, s32 font) { s32 diffX, thisDiffX; FontData *fontData; @@ -575,7 +575,7 @@ void render_dialogue_boxes(Gfx *dlist, Gfx *mat, VertexList *verts) { } } -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT void s32_to_string(char **outString, s32 number) { u8 digit; s32 i; diff --git a/src/main.c b/src/main.c index 727c8a8b..6ad5d4ee 100644 --- a/src/main.c +++ b/src/main.c @@ -8,7 +8,7 @@ /************ .rodata ************/ -#ifndef NON_MATCHING +#ifndef NON_EQUIVALENT // Remove this when func_80065E30 is matching. const char D_800E6ED0[] = "WARNING: Stack overflow/underflow!!!\n"; #endif @@ -37,7 +37,7 @@ void main(void) { osStartThread(&gThread1); } -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT void func_80065D98(s32 arg0) { func_800B6F50(); osCreateThread(&gThread3, 3, (OSId)&thread3_main, 0, &gThread3StackPointer, (OSPri)10); @@ -53,7 +53,7 @@ void func_80065D98(s32 arg0) { GLOBAL_ASM("asm/non_matchings/main/func_80065D98.s") #endif -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT void func_80065E30(void) { s32 temp, temp2, temp3, temp4; temp = D_8011D758[2049] + 1; diff --git a/src/memory.c b/src/memory.c index 27a389df..8bd97cfc 100644 --- a/src/memory.c +++ b/src/memory.c @@ -78,7 +78,7 @@ MemoryPoolSlot *new_sub_memory_pool(s32 poolDataSize, s32 numSlots) { return newPool; } -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT MemoryPoolSlot *new_memory_pool(MemoryPoolSlot *slots, s32 poolSize, s32 numSlots) { s32 i; MemoryPool *pool; @@ -138,7 +138,7 @@ MemoryPoolSlot *allocate_from_main_pool(s32 size, u32 colorTag) { return allocate_from_memory_pool(0, size, colorTag); } -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT MemoryPoolSlot *allocate_from_memory_pool(s32 memoryPoolIndex, s32 size, u32 colorTag) { MemoryPool *pool; MemoryPoolSlot *curSlot; @@ -190,7 +190,7 @@ void *allocate_from_pool_containing_slots(MemoryPoolSlot *slots, s32 size) { return (void *)NULL; } -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT void *allocate_at_address_in_main_pool(s32 size, u8 *address, u32 colorTag) { s32 *sp38; s32 s0; @@ -285,7 +285,7 @@ void clear_free_queue(void) { func_8006F53C(sp28); } -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT void free_slot_containing_address(u8 *address) { s32 poolIndex; s32 slotIndex; @@ -410,7 +410,7 @@ s32 get_memory_pool_index_containing_address(u8 *address) { return i; } -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT // Regalloc issues void free_memory_pool_slot(s32 poolIndex, s32 slotIndex) { s32 nextIndex, prevIndex, tempNextIndex; @@ -463,7 +463,7 @@ MemoryPoolSlot *func_80071774(s32 poolIndex) { GLOBAL_ASM("asm/non_matchings/memory/free_memory_pool_slot.s") #endif -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT s32 allocate_memory_pool_slot(s32 memoryPoolIndex, s32 slotIndex, s32 size, s32 slotIsTaken, s32 newSlotIsTaken, u32 colorTag) { s32 slotSize; s32 newIndex; @@ -537,7 +537,7 @@ u8 *align4(u8 *address) { GLOBAL_ASM("asm/non_matchings/memory/func_800718A4.s") -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT s32 get_memory_color_tag_count(s32 arg0) { s32 i, count; count = 0; @@ -586,7 +586,7 @@ void render_memory_color_tags(void) { render_printf("ORANGE %d\n\n", get_memory_color_tag_count(COLOR_TAG_ORANGE)); } -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT // Unused. Does nothing? void func_80071C74(void) { s32 i, flags; diff --git a/src/menu.c b/src/menu.c index b8aeb175..97841e2a 100644 --- a/src/menu.c +++ b/src/menu.c @@ -67,7 +67,17 @@ s8 D_80126430; s8 D_80126431; s32 D_80126434; s32 D_80126438[4]; + +//Seems to be a set of flags +//bit 0 = Adventure Two is Unlocked +//bit 1 = Used to set the CHEAT_MIRRORED_TRACKS magic code flag +//bits 2-3 = Current language value +//bits 4-23 = Used to set the CHEAT_CONTROL_DRUMSTICK magic code flag +//bit 24 = Unknown +//bit 25 = Seems to be a flag for whether subtitles are enabled or not. +//bits 26-63 = Unknown s64 D_80126448; + f32 sBootScreenTimer; s8 gControllersXAxisDelay[4]; s8 gControllersYAxisDelay[4]; @@ -1479,7 +1489,7 @@ const char D_800E8250[] = "loadFrontEndItem() - Item no %d out of range 0-%d\n"; /*********************************/ -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT // Should be functionally equivalent void load_menu_text(s32 language) { @@ -1660,7 +1670,7 @@ void func_80080E6C(void) { GLOBAL_ASM("asm/non_matchings/menu/func_80080E90.s") -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT // Should be functionally equivalent. void func_80081218(void) { s32 numLevels; // sp34 @@ -1956,7 +1966,7 @@ void func_80081E54(s32 arg0, f32 arg1, f32 arg2, f32 arg3, s32 arg4, s32 arg5) { GLOBAL_ASM("asm/non_matchings/menu/func_80081F4C.s") -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT void draw_menu_elements(s32 arg0, MenuElement *elem, f32 arg2) { s32 s5; @@ -2370,7 +2380,7 @@ void func_800841B8(s32 arg0) { } } -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT // Should be functionally equivalent s32 menu_options_loop(s32 arg0) { s32 buttonsPressed; @@ -2519,7 +2529,7 @@ void menu_audio_options_init(void) { GLOBAL_ASM("asm/non_matchings/menu/func_80084854.s") -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT // Almost matching, should be functionally equivalent s32 menu_audio_options_loop(s32 arg0) { @@ -2765,7 +2775,7 @@ void func_800861C8(unk800861C8 *arg0, s32 *arg1) { GLOBAL_ASM("asm/non_matchings/menu/func_800862C4.s") GLOBAL_ASM("asm/non_matchings/menu/func_800867D4.s") -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT void func_80086A48(s32 arg0) { f32 temp, temp2; temp = D_80126BD4; @@ -2875,7 +2885,7 @@ void menu_boot_init(void) { D_80126C18 = 0; // D_80126C18 is a timer for the boot screen, counts up to 0x8C frames. } -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT s32 menu_boot_loop(s32 arg0) { // arg0 = sp30 s32 out; // sp2C @@ -3014,7 +3024,7 @@ void menu_magic_codes_init(void) { func_800C4170(2); } -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT // Close to matching, but should be functionally equivalent. void render_magic_codes_ui(s32 arg0) { @@ -3161,7 +3171,7 @@ void menu_magic_codes_list_init(void) { } } -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT // Should be functionally equivalent void render_magic_codes_list_menu_text(s32 arg0) { @@ -3230,7 +3240,7 @@ void func_8008A8F8(s32 arg0, s32 arg1, s32 arg2) { } } -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT s32 menu_magic_codes_list_loop(s32 arg0) { s32 phi_a2; s32 sp48; @@ -3346,7 +3356,7 @@ void func_8008AD1C(void) { func_800C422C(2); } -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT extern u8 *__ROM_END; @@ -3506,7 +3516,7 @@ GLOBAL_ASM("asm/non_matchings/menu/func_8008B358.s") GLOBAL_ASM("asm/non_matchings/menu/func_8008B4C8.s") GLOBAL_ASM("asm/non_matchings/menu/func_8008B758.s") -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT // Should be functionally equivalent void randomize_ai_racer_slots(s32 arg0) { @@ -3725,7 +3735,7 @@ void unload_large_font(void) { func_800C422C(FONT_LARGE); } -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT void menu_game_select_init(void) { s32 i; @@ -3770,7 +3780,7 @@ void menu_game_select_init(void) { GLOBAL_ASM("asm/non_matchings/menu/menu_game_select_init.s") #endif -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT void func_8008C698(s32 arg0) { s32 fade; s32 i; @@ -3811,7 +3821,7 @@ void func_8008C698(s32 arg0) { GLOBAL_ASM("asm/non_matchings/menu/func_8008C698.s") #endif -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT s32 menu_game_select_loop(s32 arg0) { s32 playerInputs; @@ -3974,7 +3984,7 @@ void render_menu_image(s32 imageID, s32 xOffset, s32 yOffset, s32 red, s32 green func_8009CA60(imageID); } -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT // Shouldn't have any major issues. void render_file_select_menu(UNUSED s32 updateRate) { s32 s2; @@ -4220,7 +4230,7 @@ GLOBAL_ASM("asm/non_matchings/menu/func_8008E4EC.s") GLOBAL_ASM("asm/non_matchings/menu/menu_track_select_init.s") GLOBAL_ASM("asm/non_matchings/menu/func_8008F00C.s") -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT // Close to done with this function. Just a regalloc issue remains. s32 menu_track_select_loop(s32 arg0) { @@ -4344,7 +4354,7 @@ void func_80090ED8(s32 arg0) { } } -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT // Somewhat close to matching, but should be functionally equivalent. void render_track_select_setup_ui(s32 arg0) { @@ -4729,7 +4739,7 @@ void menu_5_init(void) { GLOBAL_ASM("asm/non_matchings/menu/func_80092E94.s") -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT // Regalloc issues s32 menu_5_loop(s32 arg0) { s32 temp0; @@ -4911,7 +4921,7 @@ void func_80094C14(s32 arg0) { GLOBAL_ASM("asm/non_matchings/menu/func_80094D28.s") -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT void func_80095624(s32 arg0) { switch (arg0 & 0xFF) { case 1: @@ -5069,7 +5079,7 @@ s32 compress_filename_string(unsigned char *filename, s32 length) { return output; } -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT // Not matching, but functionally equivalent. // Trims the trailing end of the string, so that spaces won't show up at the end. @@ -5213,7 +5223,7 @@ void func_80098754(void) { GLOBAL_ASM("asm/non_matchings/menu/func_80098774.s") GLOBAL_ASM("asm/non_matchings/menu/menu_trophy_race_rankings_init.s") -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT void func_80098EBC(s32 arg0) { s32 test; s32 fade; @@ -5261,7 +5271,7 @@ s32 get_trophy_race_world_id(void) { GLOBAL_ASM("asm/non_matchings/menu/func_8009963C.s") GLOBAL_ASM("asm/non_matchings/menu/func_800998E0.s") -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT // Should be functionally equivalent void menu_ghost_data_init(void) { @@ -5327,7 +5337,7 @@ GLOBAL_ASM("asm/non_matchings/menu/menu_ghost_data_init.s") GLOBAL_ASM("asm/non_matchings/menu/func_80099E8C.s") -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT // Regalloc issue: v0 & v1 need to swap! s32 menu_ghost_data_loop(s32 arg0) { s32 i; @@ -5637,7 +5647,7 @@ void reset_controller_sticks(void) { } } -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT #define STICK_DEADZONE 35 #define STICK_DELAY_AMOUNT 15 @@ -6291,7 +6301,7 @@ s32 dialogue_race_defeat(void) { return state; } -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT // Has a couple minor issues, but should be functionally equivalent. s32 tt_menu_loop(void) { diff --git a/src/object_models.c b/src/object_models.c index d83ab093..8b1b46d8 100644 --- a/src/object_models.c +++ b/src/object_models.c @@ -10,8 +10,8 @@ /************ .data ************/ -s32 D_800DCEA0 = 116315; //func_80024D54 checksum -s32 D_800DCEA4 = 1980; +s32 gFunc80024D54Checksum = 116315; +s32 gFunc80024D54Length = 1980; /*******************************/ @@ -63,10 +63,10 @@ void func_8005F850(void) { // Anti-tamper check. checksum = 0; - for (i = 0; i < D_800DCEA4; i++) { + for (i = 0; i < gFunc80024D54Length; i++) { checksum += *(u8 *)(((s32)&func_80024D54) + i); } - if (checksum != D_800DCEA0) { + if (checksum != gFunc80024D54Checksum) { func_8005C25C(); } } @@ -111,7 +111,7 @@ void func_8005FF40(ObjectModel **modelPtr) { GLOBAL_ASM("asm/non_matchings/object_models/func_8005FF40.s") #endif -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT // Regalloc issues. void free_object_model(ObjectModel *model) { s32 i; diff --git a/src/object_models.h b/src/object_models.h index 77def6e7..b47d2f15 100644 --- a/src/object_models.h +++ b/src/object_models.h @@ -11,8 +11,8 @@ typedef struct unk8011D624 { ObjectModel *model; } unk8011D624; -extern s32 D_800DCEA0; -extern s32 D_800DCEA4; +extern s32 gFunc80024D54Checksum; +extern s32 gFunc80024D54Length; void func_8005F850(void); void func_800619F4(s32 arg0); diff --git a/src/particles.c b/src/particles.c index 9b41a5ce..ceae9e6e 100644 --- a/src/particles.c +++ b/src/particles.c @@ -270,7 +270,7 @@ void func_800AE490(void) { gParticleBehaviorsAssetTable = NULL; } } -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT void init_particle_assets(void) { s32 i; @@ -521,7 +521,7 @@ void func_800AF29C(unk800AF29C *arg0, s32 arg1, s32 arg2, s16 arg3, s16 arg4, s1 } } -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT // Should be functionally equivalent. void func_800AF404(s32 arg0) { @@ -584,7 +584,7 @@ void func_800B2260(unk800B2260 *arg0) { GLOBAL_ASM("asm/non_matchings/particles/func_800B22FC.s") -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT // Has regalloc issues. void func_800B263C(unk800B2260_C *arg0) { diff --git a/src/printf.c b/src/printf.c index a2b6d427..53bc8e8f 100644 --- a/src/printf.c +++ b/src/printf.c @@ -135,7 +135,7 @@ void set_render_printf_background_color(u8 red, u8 green, u8 blue, u8 alpha) { RENDER_PRINTF_CMD_SET_BACKGROUND_COLOR(red, green, blue, alpha) } -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT void set_render_printf_position(u16 xpos, u16 ypos) { RENDER_PRINTF_CMD_SET_POSITION(xpos, ypos) } diff --git a/src/screen_asset.c b/src/screen_asset.c index baaeb7fd..f00c395a 100644 --- a/src/screen_asset.c +++ b/src/screen_asset.c @@ -15,12 +15,12 @@ Gfx gRdpSetModeScreenAsset[] = { * Returns the address of the screen asset, or 0x80100000 if no screen assets were found. * Unused. */ -UNUSED u8 *load_screen(s32 screenIndex) { - u8 *someAddr; +UNUSED void *load_screen(s32 screenIndex) { + s32 *someAddr; s32 screenTableCount, start, size; s32 *screenTable; - screenTable = (u8 *)load_asset_section_from_rom(ASSET_SCREENS_TABLE); + screenTable = load_asset_section_from_rom(ASSET_SCREENS_TABLE); screenTableCount = 0; while (screenTable[screenTableCount] != -1) { @@ -33,7 +33,7 @@ UNUSED u8 *load_screen(s32 screenIndex) { // since there are no screen assets in the ROM. if (screenTableCount == 0) { free_from_memory_pool(screenTable); - return 0x80100000; + return (void *)0x80100000; } else { if (screenIndex < 0 || screenIndex >= screenTableCount) { rmonPrintf("SCREEN: No out of range!!\n"); diff --git a/src/screen_asset.h b/src/screen_asset.h index f9ad7914..1d20476f 100644 --- a/src/screen_asset.h +++ b/src/screen_asset.h @@ -11,7 +11,7 @@ #define SCREEN_HEIGHT_PART 6 -UNUSED u8 *load_screen(s32 screenIndex); +UNUSED void *load_screen(s32 screenIndex); UNUSED void render_screen(Gfx **dlist, u8 *screenAddress); #endif diff --git a/src/textures_sprites.c b/src/textures_sprites.c index 91f32a8c..6cc66ac0 100644 --- a/src/textures_sprites.c +++ b/src/textures_sprites.c @@ -917,7 +917,7 @@ s32 func_8007AE64(void) { return D_80126354; } -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT // Minor matching issues with loops, but should be functionally the same. TextureHeader *load_texture(s32 arg0) { s32 assetSection; @@ -1033,7 +1033,7 @@ TextureHeader *load_texture(s32 arg0) { GLOBAL_ASM("asm/non_matchings/textures_sprites/load_texture.s") #endif -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT void free_texture(TextureHeader *tex) { s32 i; if (tex != NULL) { @@ -1057,7 +1057,7 @@ void func_8007B374(s32 arg0) { gTexColorTag = arg0; } -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT // Unused. TextureHeader *func_8007B380(s32 arg0) { if ((arg0 < 0) || (arg0 >= gNumberOfLoadedTextures)) { @@ -1111,7 +1111,7 @@ void func_8007BF1C(s32 arg0) { GLOBAL_ASM("asm/non_matchings/textures_sprites/func_8007BF34.s") GLOBAL_ASM("asm/non_matchings/textures_sprites/func_8007C12C.s") -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT // Mostly has regalloc issues. s32 get_texture_size_from_id(s32 arg0) { s32 assetIndex; @@ -1146,7 +1146,7 @@ GLOBAL_ASM("asm/non_matchings/textures_sprites/get_texture_size_from_id.s") GLOBAL_ASM("asm/non_matchings/textures_sprites/func_8007C660.s") -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT // Unused s32 func_8007C860(s32 spriteIndex) { if ((spriteIndex < 0) || (spriteIndex >= D_80126358)) { @@ -1159,7 +1159,7 @@ s32 func_8007C860(s32 spriteIndex) { GLOBAL_ASM("asm/non_matchings/textures_sprites/func_8007C860.s") #endif -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT s32 load_sprite_info(s32 spriteIndex, s32 *numOfInstancesOut, s32 *unkOut, s32 *numFramesOut, s32 *formatOut, s32 *sizeOut) { TextureHeader *tex; s32 i, j; @@ -1200,7 +1200,7 @@ GLOBAL_ASM("asm/non_matchings/textures_sprites/load_sprite_info.s") GLOBAL_ASM("asm/non_matchings/textures_sprites/func_8007CA68.s") -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT void free_sprite(Sprite *sprite) { s32 i, j, index; if (sprite != NULL) { @@ -1289,7 +1289,7 @@ void update_pulsating_light_data(PulsatingLightData *data, s32 timeDelta) { } } -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT void func_8007F594(Gfx **dlist, u32 index, u32 primitiveColor, u32 environmentColor) { if (index >= 2) { index = 2; diff --git a/src/thread0_epc.c b/src/thread0_epc.c index 35d1e1e8..5c9c5223 100644 --- a/src/thread0_epc.c +++ b/src/thread0_epc.c @@ -96,7 +96,7 @@ void func_800B6F30(s32 arg0, s32 arg1, s32 arg2) { void func_800B6F40(s32 arg0, s32 arg1, s32 arg2) { } -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT void func_800B6F50(void) { s32 i; @@ -114,7 +114,7 @@ void func_800B6F50(void) { GLOBAL_ASM("asm/non_matchings/thread0_epc/func_800B6F50.s") #endif -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT void thread0_Main(s32 arg0) { // Has regalloc issues s32 sp34; s32 s0 = 0; diff --git a/src/unknown_003260.c b/src/unknown_003260.c index ada655a2..e2229e53 100644 --- a/src/unknown_003260.c +++ b/src/unknown_003260.c @@ -44,8 +44,8 @@ u32 audFrameCt = 0; // Currently unknown, might be a different type. s32 D_800DC684 = 0; // Currently unknown, might be a different type. s32 D_800DC688 = 0; // Currently unknown, might be a different type. s32 D_800DC68C = 0; // Currently unknown, might be a different type. -s32 D_800DC690 = 0x35281; // Checksum of func_80019808 -s32 D_800DC694 = 0xFD0; // Size of func_80019808 (for checksum). +s32 gFunc80019808Checksum = 0x35281; +s32 gFunc80019808Length = 0xFD0; s32 D_800DC698 = 0; // Currently unknown, might be a different type. s32 D_800DC69C = 0; // Currently unknown, might be a different type. s32 D_800DC6A0 = 1; // Currently unknown, might be a different type. diff --git a/src/unknown_003260.h b/src/unknown_003260.h index e65d2f78..dcacce3b 100644 --- a/src/unknown_003260.h +++ b/src/unknown_003260.h @@ -85,8 +85,8 @@ extern u32 audFrameCt; extern s32 D_800DC684; extern s32 D_800DC688; extern s32 D_800DC68C; -extern s32 D_800DC690; -extern s32 D_800DC694; +extern s32 gFunc80019808Checksum; +extern s32 gFunc80019808Length; extern s32 D_800DC698; extern s32 D_800DC69C; extern s32 D_800DC6A0; diff --git a/src/unknown_00BC20.c b/src/unknown_00BC20.c index 8900eea2..9a41c623 100644 --- a/src/unknown_00BC20.c +++ b/src/unknown_00BC20.c @@ -601,7 +601,7 @@ void func_8000E1EC(Object *object, s32 arg1) { gObjectCount = 0; } -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT typedef struct LevelObjectEntry8000E2B4 { LevelObjectEntryCommon common; s16 unk8; @@ -1769,7 +1769,7 @@ void func_800238BC(Object *arg0, void *arg1) { } } -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT s32 func_80023E30(s32 arg0) { switch (arg0 - 1) { case 0x00: diff --git a/src/unknown_0255E0.c b/src/unknown_0255E0.c index daef1b60..dccfdaf5 100644 --- a/src/unknown_0255E0.c +++ b/src/unknown_0255E0.c @@ -345,7 +345,7 @@ void func_80028FA0(s32 arg0) { D_8011B0FC = arg0; } -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT // Regalloc & stack issues. void render_level_geometry_and_objects(void) { @@ -506,8 +506,7 @@ void render_level_geometry_and_objects(void) { GLOBAL_ASM("asm/non_matchings/unknown_0255E0/render_level_geometry_and_objects.s") #endif -// Breaks on everdrive. -#if 0 +#ifdef NON_EQUIVALENT // nonOpaque: 0 for solid geometry, 1 for transparent geometry. void render_level_segment(s32 segmentId, s32 nonOpaque) { LevelModelSegment *segment = &gCurrentLevelModel->segments[segmentId]; // spAC @@ -610,7 +609,7 @@ void render_level_segment(s32 segmentId, s32 nonOpaque) { GLOBAL_ASM("asm/non_matchings/unknown_0255E0/render_level_segment.s") #endif -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT // Regalloc issues. void traverse_segments_bsp_tree(s32 nodeIndex, s32 segmentIndex, s32 segmentIndex2, u8 *segmentsOrder, u32 *segmentsOrderIndex) { BspTreeNode *curNode; @@ -674,7 +673,7 @@ void add_segment_to_order(s32 segmentIndex, u32 *segmentsOrderIndex, u8 *segment } } -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT // Unused. Has regalloc issues. s32 func_80029DE0(Object *obj, s32 segmentIndex) { LevelModelSegmentBoundingBox *bb; @@ -698,7 +697,7 @@ s32 func_80029DE0(Object *obj, s32 segmentIndex) { GLOBAL_ASM("asm/non_matchings/unknown_0255E0/func_80029DE0.s") #endif -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT // Has regalloc issues. s32 get_level_segment_index_from_position(f32 xPos, f32 yPos, f32 zPos) { LevelModelSegmentBoundingBox *bb; @@ -795,7 +794,7 @@ LevelModelSegmentBoundingBox *func_8002A2DC(s32 arg0) { GLOBAL_ASM("asm/non_matchings/unknown_0255E0/func_8002A31C.s") -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT // Has some minor issues, but should be functionally equivalent. s32 func_8002A5F8(LevelModelSegmentBoundingBox *bb) { s64 sp48; @@ -919,7 +918,7 @@ GLOBAL_ASM("asm/non_matchings/unknown_0255E0/func_8002C7D4.s") GLOBAL_ASM("asm/non_matchings/unknown_0255E0/func_8002C954.s") GLOBAL_ASM("asm/non_matchings/unknown_0255E0/func_8002CC30.s") -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT typedef struct unk8002D30C_a0 { u8 pad00[0x04]; @@ -962,7 +961,7 @@ GLOBAL_ASM("asm/non_matchings/unknown_0255E0/func_8002FF6C.s") GLOBAL_ASM("asm/non_matchings/unknown_0255E0/func_800304C8.s") -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT // Should be functionally equivalent. void func_80030664(s32 arg0, s16 arg1, s16 arg2, u8 arg3, u8 arg4, u8 arg5) { diff --git a/src/unknown_032760.c b/src/unknown_032760.c index 24e2c1b6..a6559663 100644 --- a/src/unknown_032760.c +++ b/src/unknown_032760.c @@ -40,7 +40,7 @@ void func_80031B60(void) { D_800DC958 = 0; } -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT // Regalloc issues void func_80031BB8(s32 count) { s32 i; @@ -135,7 +135,7 @@ s32 func_80032C6C(void) { return D_800DC95C; } -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT // Close to matching. Should be functionally equivalent. void func_80032C7C(Object *object) { @@ -295,7 +295,7 @@ void func_80032C7C(Object *object) { GLOBAL_ASM("asm/non_matchings/unknown_032760/func_80032C7C.s") #endif -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT // Has regalloc issues void func_800337E4(void) { diff --git a/src/unknown_0348C0.c b/src/unknown_0348C0.c index 858b02a0..e268f394 100644 --- a/src/unknown_0348C0.c +++ b/src/unknown_0348C0.c @@ -130,7 +130,7 @@ s16 D_8011D4E2; /******************************/ -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT typedef struct LevelObjectEntry80033CC0 { LevelObjectEntryCommon common; u8 unk8; @@ -571,7 +571,7 @@ void func_80038248(Object *arg0, s32 arg1) { arg0->unk4C->unk12 = 0; } -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT // Regalloc issues void func_8003827C(Object *obj, s32 arg1) { Object_64_8003827C *obj64 = obj->unk64; @@ -725,7 +725,7 @@ void func_80038AD4(Object *arg0, s32 arg1) { } } -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT // regalloc issues void func_80038B74(Object *obj, unk80038B74 *arg1) { s32 temp; @@ -1168,59 +1168,66 @@ void obj_loop_world_key(Object *worldKeyObj, s32 speed) { worldKeyObj->y_rotation += speed * 256; } -#ifdef NON_MATCHING -typedef struct unknown_struct_8003DFCC { - u8 pad0[8]; +typedef struct Object_64_8003DFCC { + f32 unk0; + s16 unk4; + char unk6[0x2]; u8 unk8; u8 unk9; u8 unkA; -} unknown_struct_8003DFCC; +} Object_64_8003DFCC; -void func_8003DFCC(Object *arg0, unknown_struct_8003DFCC *arg1) { - f32 temp_f0; - s32 temp_v0; - Object_64 *temp_v0_2; - f32 phi_f0; +void func_8003DFCC(Object *arg0, Object_64_8003DFCC *arg1) { + s32 cheats; + Object_64_8003DFCC *obj; + f32 temp; arg0->unk4C->unk14 = 2; arg0->unk4C->unk11 = 4; arg0->unk4C->unk10 = 0x14; - temp_v0 = get_filtered_cheats(); - if (temp_v0 & CHEAT_ALL_BALLOONS_ARE_BLUE) { - arg1->unk9 = 0U; - } else if (temp_v0 & CHEAT_ALL_BALLOONS_ARE_RED) { - arg1->unk9 = 1U; - } else if (temp_v0 & CHEAT_ALL_BALLOONS_ARE_GREEN) { - arg1->unk9 = 2U; - } else if (temp_v0 & CHEAT_ALL_BALLOONS_ARE_YELLOW) { - arg1->unk9 = 3U; - } else if (temp_v0 & CHEAT_ALL_BALLOONS_ARE_RAINBOW) { - arg1->unk9 = 4U; + + cheats = get_filtered_cheats(); + + if (cheats & CHEAT_ALL_BALLOONS_ARE_BLUE) { + arg1->unk9 = 0; + } else if (cheats & CHEAT_ALL_BALLOONS_ARE_RED) { + arg1->unk9 = 1; + } else if (cheats & CHEAT_ALL_BALLOONS_ARE_GREEN) { + arg1->unk9 = 2; + } else if (cheats & CHEAT_ALL_BALLOONS_ARE_YELLOW) { + arg1->unk9 = 3; + } else if (cheats & CHEAT_ALL_BALLOONS_ARE_RAINBOW) { + arg1->unk9 = 4; } - if ((s32) arg1->unk8 >= 6) { - arg1->unk8 = 0U; + + if (arg1->unk8 >= 6) { + arg1->unk8 = 0; } - if ((s32) arg0->unk3A >= (s32) arg0->descriptor_ptr->unk55) { + + if (arg0->unk3A >= arg0->descriptor_ptr->unk55) { arg0->unk3A = 0; } - arg0->unk3A = (s8) arg1->unk9; - arg0->unk78 = (s32) arg0->unk3A; - phi_f0 = arg1->unkA; - if (arg1->unkA < 10.0f) { - phi_f0 = 10.0f; + + arg0->unk3A = arg1->unk9; + arg0->unk78 = arg0->unk3A; + + temp = arg1->unkA & 0xFF; + if (temp < 10) { + temp = 10; } - temp_f0 = phi_f0 / 64.0f; - arg0->scale = (f32) (arg0->descriptor_ptr->unkC * temp_f0); - arg0->unk64->unk4 = 0; - arg0->unk64->unk0_a.unk0 = arg0->scale; + temp /= 64; + + obj = (Object_64_8003DFCC*)arg0->unk64; + + arg0->scale = arg0->descriptor_ptr->unkC * temp; + obj->unk0 = arg0->scale; + obj->unk4 = 0; arg0->unk7C.word = 0; + if (get_filtered_cheats() & CHEAT_DISABLE_WEAPONS) { gParticlePtrList_addObject(arg0); } } -#else -GLOBAL_ASM("asm/non_matchings/unknown_032760/func_8003DFCC.s") -#endif GLOBAL_ASM("asm/non_matchings/unknown_032760/func_8003E140.s") @@ -1271,7 +1278,7 @@ void func_8003F0DC(void) { GLOBAL_ASM("asm/non_matchings/unknown_032760/func_8003F0F8.s") GLOBAL_ASM("asm/non_matchings/unknown_032760/func_8003F2E8.s") -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT // Regalloc issues void func_8003FC44(f32 arg0, f32 arg1, f32 arg2, s32 arg3, s32 arg4, f32 arg5, s32 arg6) { Object *someObj; diff --git a/src/unknown_043920.c b/src/unknown_043920.c index 8414f44f..ef9c0fa9 100644 --- a/src/unknown_043920.c +++ b/src/unknown_043920.c @@ -21,7 +21,7 @@ /************ .data ************/ -s32 D_800DCB50 = 0x310; +s32 gFunc8003B4BCLength = 0x310; s16 D_800DCB54 = 0; s32 D_800DCB58 = 0; // Currently unknown, might be a different type. s32 D_800DCB5C = 0; // Currently unknown, might be a different type. @@ -111,7 +111,7 @@ s16 D_800DCDB0[16] = { }; // Checksum count for func_8003B4BC -s32 D_800DCDD0 = 42391; +s32 gFunc8003B4BCChecksum = 42391; s16 D_800DCDD4[4] = { 0, 0, 0x32, -1 @@ -450,7 +450,7 @@ void func_8004F77C(unk8004F77C *arg0) { GLOBAL_ASM("asm/non_matchings/unknown_043920/func_8004F7F4.s") -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT typedef struct Object_64_80050754 { u8 unk0[0x2C]; @@ -679,7 +679,7 @@ void func_800570A4(Object *obj, s32 arg1, s32 arg2) { temp->unk210 = arg2; } -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT typedef struct Object_64_800570B8 { u8 pad0[3]; s8 unk3; @@ -788,7 +788,7 @@ GLOBAL_ASM("asm/non_matchings/unknown_043920/func_800581E8.s") GLOBAL_ASM("asm/non_matchings/unknown_043920/func_80058B84.s") GLOBAL_ASM("asm/non_matchings/unknown_043920/func_80058D5C.s") -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT void func_80058F44(f32 arg0, Object *arg1, Object *arg2) { s32 temp0, temp1; temp0 = (s32)arg0; @@ -922,11 +922,11 @@ void func_8005A3D0(void) { s32 count = 0; u8 *temp = (u8 *)&func_8003B4BC; - for (i = 0; i < D_800DCB50; i++) { + for (i = 0; i < gFunc8003B4BCLength; i++) { count += temp[i]; } - if (count != D_800DCDD0) { + if (count != gFunc8003B4BCChecksum) { D_800DCB54 = 0x800; } } diff --git a/src/unknown_043920.h b/src/unknown_043920.h index 8fc6c2ad..a0c5670d 100644 --- a/src/unknown_043920.h +++ b/src/unknown_043920.h @@ -147,7 +147,7 @@ typedef struct unk8005C270 { s8 unk193; } unk8005C270; -extern s32 D_800DCB50; +extern s32 gFunc8003B4BCLength; extern s16 D_800DCB54; extern s32 D_800DCB58; extern s32 D_800DCB5C; @@ -185,7 +185,7 @@ extern s8 D_800DCDA8[8]; // Unused? extern s16 D_800DCDB0[16]; -extern s32 D_800DCDD0; +extern s32 gFunc8003B4BCChecksum; extern s16 D_800DCDD4[4]; diff --git a/src/unknown_05CEF0.c b/src/unknown_05CEF0.c index 60821ec1..d48113ad 100644 --- a/src/unknown_05CEF0.c +++ b/src/unknown_05CEF0.c @@ -39,7 +39,7 @@ void func_8005C2F0(Object *object, unk8005C2F0 *arg1) { arg1->unkC = 0.0f; D_8011D5C0 = object->y_position; if (arg1->unk118 != 0) { - func_80006AC8(); + func_80006AC8(object); } D_8011D5C4 = 0; } diff --git a/src/unknown_06B2B0.c b/src/unknown_06B2B0.c index ac3acc6d..1995dc32 100644 --- a/src/unknown_06B2B0.c +++ b/src/unknown_06B2B0.c @@ -176,7 +176,7 @@ s32 D_80123560[8]; /******************************/ -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT void func_8006A6B0(void) { s32 i, count, checksumCount; s32 temp; @@ -341,7 +341,7 @@ s32 func_8006B240(void) { } // This isn't matching, but there shouldn't be any issues (hopefully). -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT void load_level(s32 levelId, s32 numberOfPlayers, s32 entranceId, s32 vehicleId, s32 cutsceneId) { s32 maxLevelCount; @@ -1037,7 +1037,7 @@ void func_8006CC14(void) { set_free_queue_state(2); } -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT // Almost matching except for a couple minor issues. void func_8006CCF0(s32 updateRate) { s32 i, buttonHeldInputs, sp40, sp3C, buttonPressedInputs, phi_v1_2; @@ -1505,7 +1505,7 @@ void func_8006DC58(s32 updateRate) { } } -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT // Minor & regalloc issues. void func_8006DCF8(s32 updateRate) { s32 menuLoopResult, temp, temp2, tempResult; @@ -1871,7 +1871,7 @@ s32 func_8006EFB8(void) { return TRUE; } -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT // Not close to matching, but should be the same functionality-wise. void func_8006EFDC(void) { diff --git a/src/unknown_077C50.c b/src/unknown_077C50.c index f52c4328..4749bc95 100644 --- a/src/unknown_077C50.c +++ b/src/unknown_077C50.c @@ -9,7 +9,7 @@ #include "structs.h" #include "f3ddkr.h" -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT // Draws the borders/negative space for multiplayer. Has regalloc issues void render_borders_for_multiplayer(Gfx **dlist) { diff --git a/src/unknown_078050.c b/src/unknown_078050.c index 424e2c8d..06fc41a4 100644 --- a/src/unknown_078050.c +++ b/src/unknown_078050.c @@ -6,6 +6,7 @@ #include "structs.h" #include "macros.h" #include "video.h" +#include "camera.h" //#include "lib/src/unknown_0D24D0.h" /************ .data ************/ @@ -204,11 +205,11 @@ void set_background_prim_colour(u8 red, u8 green, u8 blue) { * Uses RGBA5551 */ void set_background_fill_colour(s32 red, s32 green, s32 blue) { - sBackgroundFillColour = ((red << 8) & 0xF800) | ((green * 8) & 0x7C0) | ((blue >> 2) & 0x3E) | 1; + sBackgroundFillColour = GPACK_RGBA5551(red, green, blue, 1); sBackgroundFillColour |= (sBackgroundFillColour << 16); } -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT // Stack issues void render_background(Gfx **dlist, s32 *arg1, s32 arg2) { s32 x1; @@ -220,8 +221,8 @@ void render_background(Gfx **dlist, s32 *arg1, s32 arg2) { s32 rgba16Color; widthAndHeight = get_video_width_and_height_as_s32(); - w = widthAndHeight & 0xFFFF; - h = widthAndHeight >> 0x10; + w = GET_VIDEO_WIDTH(widthAndHeight); + h = GET_VIDEO_HEIGHT(widthAndHeight); gDPPipeSync((*dlist)++); gDPSetScissor((*dlist)++, 0, 0, 0, w - 1, h - 1); @@ -259,8 +260,8 @@ void render_background(Gfx **dlist, s32 *arg1, s32 arg2) { D_800DE4D0.function(dlist, arg1); } else { //Also has an issue here. - rgba16Color = ((sBackgroundPrimColourR << 8) & 0xF800) | ((sBackgroundPrimColourG * 8) & 0x7C0) | ((sBackgroundPrimColourB >> 2) & 0x3E) | 1; - rgba16Color |= rgba16Color << 0x10; + rgba16Color = GPACK_RGBA5551(sBackgroundPrimColourR, sBackgroundPrimColourG, sBackgroundPrimColourB, 1); + rgba16Color |= rgba16Color << 16; gDPSetFillColor((*dlist)++, rgba16Color); gDPFillRectangle((*dlist)++, 0, 0, w - 1, h - 1); } @@ -332,7 +333,7 @@ void func_80078AAC(void *arg0) { D_800DE4D0.ptr = arg0; } -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT // Regalloc & stack issues. void render_textured_rectangle(Gfx **dlist, DrawTexture *arg1, s32 arg2, s32 arg3, u8 red, u8 green, u8 blue, u8 alpha) { diff --git a/src/video.c b/src/video.c index 5afa44d4..3a6a6fa6 100644 --- a/src/video.c +++ b/src/video.c @@ -257,7 +257,7 @@ void func_8007A974(void) { D_80126309 = 2; } -#ifdef NON_MATCHING +#ifdef NON_EQUIVALENT // regalloc & stack issues s32 func_8007A98C(s32 arg0) { s32 tempUpdateRate; diff --git a/tools/python/calc_func_checksums.py b/tools/python/calc_func_checksums.py index 7111832b..1bca8970 100644 --- a/tools/python/calc_func_checksums.py +++ b/tools/python/calc_func_checksums.py @@ -11,10 +11,11 @@ MAP_FILEPATH = BUILD_DIR + '/dkr.map' ROM_FILEPATH = BUILD_DIR + '/dkr.z64' FUNCTIONS_TO_CALC = [ - ('func_80019808', 'D_800DC690'), - ('func_80024D54', 'D_800DCEA0'), - ('func_8003B4BC', 'D_800DCDD0'), - ('func_80068158', 'gFunc80068158Checksum') + # function checksum variable func size variable + ('func_80019808', 'gFunc80019808Checksum', 'gFunc80019808Length'), + ('func_80024D54', 'gFunc80024D54Checksum', 'gFunc80024D54Length'), + ('func_8003B4BC', 'gFunc8003B4BCChecksum', 'gFunc8003B4BCLength'), + ('func_80068158', 'gFunc80068158Checksum', 'gFunc80068158Length') ] def getMatches(string, regex): @@ -30,18 +31,20 @@ rom = FileUtil.get_bytes_from_file(ROM_FILEPATH) mapFile = {} RAM_TO_ROM = None -def write_checksum_to_rom(romOffset, value): +def write_word_to_rom(romOffset, value): global rom rom[romOffset + 0] = (value >> 24) & 0xFF rom[romOffset + 1] = (value >> 16) & 0xFF rom[romOffset + 2] = (value >> 8) & 0xFF rom[romOffset + 3] = value & 0xFF -def calculate_checksum_for_function(funcLabel, varLabel): +def calculate_checksum_for_function(funcLabel, varLabel, funcSizeLabel): if funcLabel not in mapFile: raise Exception('Label "' + funcLabel + '" does not exist in the map file!') if varLabel not in mapFile: raise Exception('Label "' + varLabel + '" does not exist in the map file!') + if funcSizeLabel not in mapFile: + raise Exception('Label "' + funcSizeLabel + '" does not exist in the map file!') funcEntry = mapFile[funcLabel] funcAddress = funcEntry['value'] funcLength = funcEntry['length'] @@ -49,11 +52,16 @@ def calculate_checksum_for_function(funcLabel, varLabel): count = 0 for i in range(0, funcLength): count += rom[funcRomOffset + i] + # Save function checksum. varEntry = mapFile[varLabel] varAddress = varEntry['value'] varRomOffset = varAddress - RAM_TO_ROM - write_checksum_to_rom(varRomOffset, count) - # print('The checksum count for "' + funcLabel + '" is: ' + hex(count)) + write_word_to_rom(varRomOffset, count) + # Save function size. + sizeEntry = mapFile[funcSizeLabel] + sizeAddress = sizeEntry['value'] + sizeRomOffset = sizeAddress - RAM_TO_ROM + write_word_to_rom(sizeRomOffset, funcLength) def calculate_matches(): global mapFile, RAM_TO_ROM @@ -71,7 +79,7 @@ def calculate_matches(): def main(): calculate_matches() for entry in FUNCTIONS_TO_CALC: - calculate_checksum_for_function(entry[0], entry[1]) + calculate_checksum_for_function(entry[0], entry[1], entry[2]) FileUtil.write_bytes_to_file(ROM_FILEPATH, rom) main()