diff --git a/.clang-format b/.clang-format new file mode 100644 index 00000000..068a6d45 --- /dev/null +++ b/.clang-format @@ -0,0 +1,23 @@ +IndentWidth: 4 +Language: Cpp +UseTab: Never +ColumnLimit: 0 +PointerAlignment: Right +BreakBeforeBraces: Attach +SpaceAfterCStyleCast: false +Cpp11BracedListStyle: false +IndentCaseLabels: true +BinPackArguments: false +BinPackParameters: false +AlignAfterOpenBracket: Align +AlignOperands: true +BreakBeforeTernaryOperators: true +BreakBeforeBinaryOperators: None +AllowShortBlocksOnASingleLine: true +AllowShortIfStatementsOnASingleLine: false +AllowShortLoopsOnASingleLine: false +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: false +AlignEscapedNewlines: Left +AlignTrailingComments: true +SortIncludes: false \ No newline at end of file diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 00000000..db861ad8 --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,5 @@ +Checks: '-*,readability-braces-around-statements' +WarningsAsErrors: '' +HeaderFilterRegex: '(src|include)\/.*\.h$' +FormatStyle: 'file' +CheckOptions: \ No newline at end of file diff --git a/asm/non_matchings/particles/func_800AF134.s b/asm/non_matchings/particles/func_800AF134.s deleted file mode 100644 index d425e215..00000000 --- a/asm/non_matchings/particles/func_800AF134.s +++ /dev/null @@ -1,49 +0,0 @@ -glabel func_800AF134 -/* 0AFD34 800AF134 3C0E800E */ lui $t6, %hi(gParticlesAssetTableCount) # $t6, 0x800e -/* 0AFD38 800AF138 8DCE2CE8 */ lw $t6, %lo(gParticlesAssetTableCount)($t6) -/* 0AFD3C 800AF13C 27BDFFE0 */ addiu $sp, $sp, -0x20 -/* 0AFD40 800AF140 00CE082A */ slt $at, $a2, $t6 -/* 0AFD44 800AF144 AFBF001C */ sw $ra, 0x1c($sp) -/* 0AFD48 800AF148 14200002 */ bnez $at, .L800AF154 -/* 0AFD4C 800AF14C AFA7002C */ sw $a3, 0x2c($sp) -/* 0AFD50 800AF150 00003025 */ move $a2, $zero -.L800AF154: -/* 0AFD54 800AF154 3C0F800E */ lui $t7, %hi(gParticleBehaviorsAssetTableCount) # $t7, 0x800e -/* 0AFD58 800AF158 8DEF2CF4 */ lw $t7, %lo(gParticleBehaviorsAssetTableCount)($t7) -/* 0AFD5C 800AF15C 3C18800E */ lui $t8, %hi(gParticleBehaviorsAssetTable) # $t8, 0x800e -/* 0AFD60 800AF160 00AF082A */ slt $at, $a1, $t7 -/* 0AFD64 800AF164 14200002 */ bnez $at, .L800AF170 -/* 0AFD68 800AF168 00000000 */ nop -/* 0AFD6C 800AF16C 00002825 */ move $a1, $zero -.L800AF170: -/* 0AFD70 800AF170 8F182CFC */ lw $t8, %lo(gParticleBehaviorsAssetTable)($t8) -/* 0AFD74 800AF174 0005C880 */ sll $t9, $a1, 2 -/* 0AFD78 800AF178 84890008 */ lh $t1, 8($a0) -/* 0AFD7C 800AF17C 03194021 */ addu $t0, $t8, $t9 -/* 0AFD80 800AF180 8D020000 */ lw $v0, ($t0) -/* 0AFD84 800AF184 14C90005 */ bne $a2, $t1, .L800AF19C -/* 0AFD88 800AF188 00000000 */ nop -/* 0AFD8C 800AF18C 8C8A0000 */ lw $t2, ($a0) -/* 0AFD90 800AF190 00000000 */ nop -/* 0AFD94 800AF194 104A000F */ beq $v0, $t2, .L800AF1D4 -/* 0AFD98 800AF198 8FBF001C */ lw $ra, 0x1c($sp) -.L800AF19C: -/* 0AFD9C 800AF19C AFA40020 */ sw $a0, 0x20($sp) -/* 0AFDA0 800AF1A0 AFA50024 */ sw $a1, 0x24($sp) -/* 0AFDA4 800AF1A4 0C02C898 */ jal func_800B2260 -/* 0AFDA8 800AF1A8 AFA60028 */ sw $a2, 0x28($sp) -/* 0AFDAC 800AF1AC 87AB0032 */ lh $t3, 0x32($sp) -/* 0AFDB0 800AF1B0 87AC0036 */ lh $t4, 0x36($sp) -/* 0AFDB4 800AF1B4 8FA40020 */ lw $a0, 0x20($sp) -/* 0AFDB8 800AF1B8 8FA50024 */ lw $a1, 0x24($sp) -/* 0AFDBC 800AF1BC 8FA60028 */ lw $a2, 0x28($sp) -/* 0AFDC0 800AF1C0 87A7002E */ lh $a3, 0x2e($sp) -/* 0AFDC4 800AF1C4 AFAB0010 */ sw $t3, 0x10($sp) -/* 0AFDC8 800AF1C8 0C02BCA7 */ jal func_800AF29C -/* 0AFDCC 800AF1CC AFAC0014 */ sw $t4, 0x14($sp) -/* 0AFDD0 800AF1D0 8FBF001C */ lw $ra, 0x1c($sp) -.L800AF1D4: -/* 0AFDD4 800AF1D4 27BD0020 */ addiu $sp, $sp, 0x20 -/* 0AFDD8 800AF1D8 03E00008 */ jr $ra -/* 0AFDDC 800AF1DC 00000000 */ nop - diff --git a/format.sh b/format.sh new file mode 100755 index 00000000..4d410481 --- /dev/null +++ b/format.sh @@ -0,0 +1,28 @@ +#!/usr/bin/env bash + +FORMAT_OPTS="-i -style=file" +TIDY_OPTS="-p . --fix --fix-errors" +COMPILER_OPTS="-fno-builtin -std=gnu90 -Iinclude -Isrc -D_LANGUAGE_C -DNON_MATCHING" + +shopt -s globstar + +if (( $# > 0 )); then + echo "Formatting file(s) $*" + echo "Running clang-format..." + clang-format-11 ${FORMAT_OPTS} "$@" + echo "Running clang-tidy..." + clang-tidy ${TIDY_OPTS} "$@" -- ${COMPILER_OPTS} &> /dev/null + echo "Adding missing final new lines..." + sed -i -e '$a\' "$@" + echo "Done formatting file(s) $*" + exit +fi + +echo "Formatting C files. This will take a bit" +echo "Running clang-format..." +clang-format ${FORMAT_OPTS} src/**/*.c +echo "Running clang-tidy..." +#clang-tidy ${TIDY_OPTS} src/**/*.c -- ${COMPILER_OPTS} &> /dev/null +echo "Adding missing final new lines..." +find src/ -type f -name "*.c" -exec sed -i -e '$a\' {} \; +echo "Done formatting all files." \ No newline at end of file diff --git a/lib/src/mips1/sc/sched.h b/include/sched.h similarity index 100% rename from lib/src/mips1/sc/sched.h rename to include/sched.h diff --git a/include/viint.h b/include/viint.h index 608e16a4..74cee418 100644 --- a/include/viint.h +++ b/include/viint.h @@ -1,6 +1,6 @@ #ifndef _VIINT_H #define _VIINT_H -#include +#include "libultra_internal.h" #define OS_TV_TYPE_PAL 0 #define OS_TV_TYPE_NTSC 1 diff --git a/lib/src/os/viint.h b/lib/src/os/viint.h deleted file mode 100644 index 74cee418..00000000 --- a/lib/src/os/viint.h +++ /dev/null @@ -1,70 +0,0 @@ -#ifndef _VIINT_H -#define _VIINT_H -#include "libultra_internal.h" - -#define OS_TV_TYPE_PAL 0 -#define OS_TV_TYPE_NTSC 1 -#define OS_TV_TYPE_MPAL 2 - -//TODO: figure out what this is -#define VI_STATE_01 0x01 -#define VI_STATE_XSCALE_UPDATED 0x02 -#define VI_STATE_YSCALE_UPDATED 0x04 -#define VI_STATE_08 0x08 //related to control regs changing -#define VI_STATE_10 0x10 //swap buffer -#define VI_STATE_BLACK 0x20 //probably related to a black screen -#define VI_STATE_REPEATLINE 0x40 //repeat line? -#define VI_STATE_FADE 0x80 //fade - -#define VI_CTRL_ANTIALIAS_MODE_3 0x00300 /* Bit [9:8] anti-alias mode */ -#define VI_CTRL_ANTIALIAS_MODE_2 0x00200 /* Bit [9:8] anti-alias mode */ -#define VI_CTRL_ANTIALIAS_MODE_1 0x00100 /* Bit [9:8] anti-alias mode */ - -#define VI_SCALE_MASK 0xfff //see rcp scale_x/scale_y -#define VI_2_10_FPART_MASK 0x3ff -#define VI_SUBPIXEL_SH 0x10 - -#define BURST(hsync_width, color_width, vsync_width, color_start) \ - (hsync_width | (color_width << 8) | (vsync_width << 16) | (color_start << 20)) -#define WIDTH(v) v -#define VSYNC(v) v -#define HSYNC(duration, leap) (duration | (leap << 16)) -#define LEAP(upper, lower) ((upper << 16) | lower) -#define START(start, end) ((start << 16) | end) - -#define FTOFIX(val, i, f) ((u32)(val * (f32)(1 << f)) & ((1 << (i + f)) - 1)) - -#define F210(val) FTOFIX(val, 2, 10) -#define SCALE(scaleup, off) (F210((1.0f / (f32)scaleup)) | (F210((f32)off) << 16)) - -#define VCURRENT(v) v //seemingly unused -#define ORIGIN(v) v -#define VINTR(v) v -#define HSTART START - -typedef struct -{ - /* 0x0 */ f32 factor; - /* 0x4 */ u16 offset; - /* 0x8 */ u32 scale; -} __OSViScale; - -typedef struct -{ - /* 0x0 */ u16 state; - /* 0x2 */ u16 retraceCount; - /* 0x4 */ void *framep; - /* 0x8 */ OSViMode *modep; - /* 0xC */ u32 control; - /* 0x10 */ OSMesgQueue *msgq; - /* 0x14 */ OSMesg msg; - /* 0x18 */ __OSViScale x; - /* 0x24 */ __OSViScale y; -} __OSViContext; - -void __osViSwapContext(void); -extern __OSViContext *__osViCurr; -extern __OSViContext *__osViNext; -__OSViContext *__osViGetCurrentContext(void); -void __osViInit(void); -#endif diff --git a/src/asset_loading.c b/src/asset_loading.c index 83240201..730b95d4 100644 --- a/src/asset_loading.c +++ b/src/asset_loading.c @@ -22,18 +22,18 @@ s32 *gAssetsLookupTable; // These are both defined in the generated dkr.ld file. extern u8 __ASSETS_LUT_START, __ASSETS_LUT_END; // __ASSETS_LUT_START = 0xECB60, _END = 0xECC30 - + void func_80076BA0(void) { u32 assetTableSize; osCreateMesgQueue(&D_80124278, &D_80124238, 16); osCreateMesgQueue(&D_80124220, &D_80124218, 1); - osCreatePiManager((OSPri) 150, &D_80124278, &D_80124238, 16); + osCreatePiManager((OSPri)150, &D_80124278, &D_80124238, 16); assetTableSize = &__ASSETS_LUT_END - &__ASSETS_LUT_START; - gAssetsLookupTable = (s32*)allocate_from_main_pool_safe(assetTableSize, COLOR_TAG_GRAY); + gAssetsLookupTable = (s32 *)allocate_from_main_pool_safe(assetTableSize, COLOR_TAG_GRAY); func_80071478(gAssetsLookupTable); dmacopy(&__ASSETS_LUT_START, gAssetsLookupTable, assetTableSize); } - + /** * Returns the memory address containing an asset section loaded from ROM. */ @@ -49,7 +49,7 @@ s32 *load_asset_section_from_rom(u32 assetIndex) { index = assetIndex + gAssetsLookupTable; start = *index; size = *(index + 1) - start; - out = (s32*)allocate_from_main_pool_safe(size, COLOR_TAG_GRAY); + out = (s32 *)allocate_from_main_pool_safe(size, COLOR_TAG_GRAY); if (out == NULL) { return NULL; } @@ -73,20 +73,20 @@ u8 *load_compressed_asset_from_rom(u32 assetIndex, s32 arg1) { if (gAssetsLookupTable[0] < assetIndex) { return NULL; } - + assetIndex++; index = assetIndex + gAssetsLookupTable; start = *index; size = *(index + 1) - start; - - temp_v0_2 = (u8*)allocate_from_main_pool_safe(8, COLOR_TAG_WHITE); + + temp_v0_2 = (u8 *)allocate_from_main_pool_safe(8, COLOR_TAG_WHITE); temp_a0 = start + &__ASSETS_LUT_END; - + dmacopy(temp_a0, temp_v0_2, 8); sp2C = byteswap32(temp_v0_2) + arg1; free_from_memory_pool(temp_v0_2); - temp_v0_3 = (u8*)allocate_from_main_pool_safe(sp2C + arg1, COLOR_TAG_GRAY); - + temp_v0_3 = (u8 *)allocate_from_main_pool_safe(sp2C + arg1, COLOR_TAG_GRAY); + if (temp_v0_3 == NULL) { return NULL; } @@ -126,11 +126,11 @@ s32 load_asset_section_from_rom_to_address(u32 assetIndex, s32 *address) { s32 load_asset_to_address(u32 assetIndex, s32 *address, s32 assetOffset, s32 size) { s32 *index; s32 start; - + if (size == 0 || gAssetsLookupTable[0] < assetIndex) { return 0; } - + assetIndex++; index = assetIndex + gAssetsLookupTable; start = *index + assetOffset; @@ -144,11 +144,11 @@ s32 load_asset_to_address(u32 assetIndex, s32 *address, s32 assetOffset, s32 siz u8 *get_rom_offset_of_asset(u32 assetIndex, s32 assetOffset) { s32 *index; s32 start; - + if (gAssetsLookupTable[0] < assetIndex) { return NULL; } - + assetIndex++; index = assetIndex + gAssetsLookupTable; start = *index + assetOffset; @@ -164,7 +164,7 @@ s32 get_size_of_asset_section(u32 assetIndex) { if (gAssetsLookupTable[0] < assetIndex) { return 0; } - + assetIndex++; index = assetIndex + gAssetsLookupTable; return *(index + 1) - *index; @@ -181,7 +181,7 @@ void dmacopy(u32 romOffset, u32 ramAddress, s32 numBytes) { osInvalDCache(ramAddress, numBytes); numBytesToDMA = MAX_TRANSFER_SIZE; - while(numBytes > 0) { + while (numBytes > 0) { if (numBytes < numBytesToDMA) { numBytesToDMA = numBytes; } diff --git a/src/audio.c b/src/audio.c index b59c2a67..cd909467 100644 --- a/src/audio.c +++ b/src/audio.c @@ -25,7 +25,7 @@ f32 D_800DC650 = 1.0; s32 musicVolumeSliderPercentage = 0x100; s32 D_800DC658 = 0; u8 D_800DC65C = 0; -u8 D_800DC660 = 0; +u8 D_800DC660 = 0; s32 D_800DC664 = 0; // Currently unknown, might be a different type. s32 D_800DC668 = 0; // Currently unknown, might be a different type. s32 D_800DC66C = 0x100; @@ -61,8 +61,8 @@ ALSeqFile *ALSeqFile_80115CF8; void *D_80115CFC; void *D_80115D00; -u8 D_80115D04; -u8 D_80115D05; +u8 D_80115D04; +u8 D_80115D05; s32 musicTempo; u32 *D_80115D0C; ALBankFile *ALBankFile_80115D10; @@ -79,13 +79,13 @@ s16 D_80115D30; f32 D_80115D34; s32 D_80115D38; s32 D_80115D3C; -u8 D_80115D40; -u8 D_80115D41; +u8 D_80115D40; +u8 D_80115D41; unk80115D48 D_80115D48[8]; ALCSeq D_80115D88; ALCSeq D_80115E80; -u8 D_80115F78; -u8 D_80115F79; +u8 D_80115F78; +u8 D_80115F79; s32 D_80115F7C; s32 D_80115F80; u32 D_80115F84; @@ -101,50 +101,48 @@ void audio_init(u32 arg0) { u32 seq_max_len; u32 tmp2; audioMgrConfig audConfig; - + seq_max_len = 0; alHeapInit(&gALHeap, gBssSectionStart, AUDIO_HEAP_SIZE); - + reg_s2 = load_asset_section_from_rom(ASSET_AUDIO_TABLE); - ALBankFile_80115D14 = (ALBankFile*) allocate_from_main_pool_safe(reg_s2[2] - reg_s2[1], COLOR_TAG_CYAN); + ALBankFile_80115D14 = (ALBankFile *)allocate_from_main_pool_safe(reg_s2[2] - reg_s2[1], COLOR_TAG_CYAN); load_asset_to_address(ASSET_AUDIO, ALBankFile_80115D14, reg_s2[1], reg_s2[2] - reg_s2[1]); alBnkfNew(ALBankFile_80115D14, get_rom_offset_of_asset(ASSET_AUDIO, reg_s2[2])); - + D_80115D28 = reg_s2[7] - reg_s2[6]; - D_80115D18 = (unk80115D18 *) allocate_from_main_pool_safe(D_80115D28, COLOR_TAG_CYAN); + D_80115D18 = (unk80115D18 *)allocate_from_main_pool_safe(D_80115D28, COLOR_TAG_CYAN); load_asset_to_address(ASSET_AUDIO, D_80115D18, reg_s2[6], D_80115D28); - D_80115D20 = D_80115D28/10; - - D_80115D2C = reg_s2[6]-reg_s2[5]; - D_80115D1C = (unk80115D1C *) allocate_from_main_pool_safe(D_80115D2C, COLOR_TAG_CYAN); + D_80115D20 = D_80115D28 / 10; + + D_80115D2C = reg_s2[6] - reg_s2[5]; + D_80115D1C = (unk80115D1C *)allocate_from_main_pool_safe(D_80115D2C, COLOR_TAG_CYAN); load_asset_to_address(ASSET_AUDIO, D_80115D1C, reg_s2[5], D_80115D2C); - D_80115D24 = D_80115D2C/3; + D_80115D24 = D_80115D2C / 3; ALBankFile_80115D10 = (ALBankFile *)allocate_from_main_pool_safe(reg_s2[0], COLOR_TAG_CYAN); load_asset_to_address(ASSET_AUDIO, ALBankFile_80115D10, 0, reg_s2[0]); alBnkfNew(ALBankFile_80115D10, get_rom_offset_of_asset(ASSET_AUDIO, reg_s2[0])); - ALSeqFile_80115CF8 = (ALSeqFile *) alHeapDBAlloc(0,0,&gALHeap,1,4); + ALSeqFile_80115CF8 = (ALSeqFile *)alHeapDBAlloc(0, 0, &gALHeap, 1, 4); load_asset_to_address(ASSET_AUDIO, ALSeqFile_80115CF8, reg_s2[4], 4); - seqfSize = (ALSeqFile_80115CF8->seqCount)*8 + 4; + seqfSize = (ALSeqFile_80115CF8->seqCount) * 8 + 4; ALSeqFile_80115CF8 = allocate_from_main_pool_safe(seqfSize, COLOR_TAG_CYAN); load_asset_to_address(ASSET_AUDIO, ALSeqFile_80115CF8, reg_s2[4], seqfSize); alSeqFileNew(ALSeqFile_80115CF8, get_rom_offset_of_asset(ASSET_AUDIO, reg_s2[4])); - D_80115D0C = (u32 *)allocate_from_main_pool_safe( (ALSeqFile_80115CF8->seqCount)*4, COLOR_TAG_CYAN); + D_80115D0C = (u32 *)allocate_from_main_pool_safe((ALSeqFile_80115CF8->seqCount) * 4, COLOR_TAG_CYAN); - - for(iCnt = 0; iCnt < ALSeqFile_80115CF8->seqCount; iCnt++){ - (u32*)((u32) ALSeqFile_80115CF8 + 8 + iCnt*8); + for (iCnt = 0; iCnt < ALSeqFile_80115CF8->seqCount; iCnt++) { + (u32 *)((u32)ALSeqFile_80115CF8 + 8 + iCnt * 8); D_80115D0C[iCnt] = ALSeqFile_80115CF8->seqArray[iCnt].len; - if(D_80115D0C[iCnt] & 1){ + if (D_80115D0C[iCnt] & 1) { D_80115D0C[iCnt]++; } - if(seq_max_len < D_80115D0C[iCnt]){ + if (seq_max_len < D_80115D0C[iCnt]) { seq_max_len = D_80115D0C[iCnt]; } } - synth_config.maxVVoices = 40; synth_config.maxPVoices = 40; synth_config.maxUpdates = 96; @@ -157,8 +155,8 @@ void audio_init(u32 arg0) { gMusicPlayer = func_80002224(24, 120); set_voice_limit(gMusicPlayer, 18); gSndFxPlayer = func_80002224(16, 50); - D_80115CFC = allocate_from_main_pool_safe( seq_max_len, COLOR_TAG_CYAN); - D_80115D00 = allocate_from_main_pool_safe( seq_max_len, COLOR_TAG_CYAN); + D_80115CFC = allocate_from_main_pool_safe(seq_max_len, COLOR_TAG_CYAN); + D_80115D00 = allocate_from_main_pool_safe(seq_max_len, COLOR_TAG_CYAN); audConfig.unk04 = 150; audConfig.unk00 = 32; audConfig.maxChannels = 16; @@ -179,27 +177,27 @@ void audio_init(u32 arg0) { } void func_80000890(u8 arg0) { - if(!D_80115F79){ + if (!D_80115F79) { D_80115F78 = arg0; - if(D_80115F78 == 0){ + if (D_80115F78 == 0) { D_800DC66C = 256; set_relative_volume_for_music(musicRelativeVolume); - func_80004A60(0,D_800DC66C*128-1); - func_80004A60(1,D_800DC66C*128-1); - func_80004A60(2,D_800DC66C*128-1); - func_80004A60(4,D_800DC66C*128-1); + func_80004A60(0, D_800DC66C * 128 - 1); + func_80004A60(1, D_800DC66C * 128 - 1); + func_80004A60(2, D_800DC66C * 128 - 1); + func_80004A60(4, D_800DC66C * 128 - 1); } } } void func_80000968(s32 arg0) { - switch(arg0) { + switch (arg0) { case 1: func_80004A60(0, 0); func_80004A60(1, 0x7FFF); func_80004A60(2, 0); func_80004A60(4, 0); - alCSPSetVol(gMusicPlayer, (s16) (musicRelativeVolume * musicVolumeSliderPercentage >> 2)); + alCSPSetVol(gMusicPlayer, (s16)(musicRelativeVolume * musicVolumeSliderPercentage >> 2)); alCSPSetVol(gSndFxPlayer, 0); break; case 2: @@ -219,8 +217,8 @@ void func_80000968(s32 arg0) { func_80004A60(1, 0x7FFF); func_80004A60(2, 0x7FFF); func_80004A60(4, 0x7FFF); - alCSPSetVol(gMusicPlayer, (s16) (musicRelativeVolume * musicVolumeSliderPercentage)); - alCSPSetVol(gSndFxPlayer, (s16) (sfxGetVolumeSlider() * sfxRelativeVolume)); + alCSPSetVol(gMusicPlayer, (s16)(musicRelativeVolume * musicVolumeSliderPercentage)); + alCSPSetVol(gSndFxPlayer, (s16)(sfxGetVolumeSlider() * sfxRelativeVolume)); break; } D_80115F79 = arg0; @@ -286,22 +284,22 @@ void func_80000CBC(void) { void func_80000D00(u8 arg0) { s32 reg_s2; s32 j; - if(D_80115D3C > 0){ - + if (D_80115D3C > 0) { + D_80115D38 += arg0; - D_800DC650 = ((f32)D_80115D38)/((f32)D_80115D3C); - - if((f64)D_800DC650 > 1.0f){ + D_800DC650 = ((f32)D_80115D38) / ((f32)D_80115D3C); + + if ((f64)D_800DC650 > 1.0f) { D_80115D38 = 0; D_80115D3C = 0; D_800DC650 = 1.0f; } set_relative_volume_for_music(musicRelativeVolume); - }else if(D_80115D3C < 0) { - + } else if (D_80115D3C < 0) { + D_80115D38 -= arg0; - D_800DC650 = 1.0f - ((f32)D_80115D38)/((f32)D_80115D3C); - if((f64)D_800DC650 < 0){ + D_800DC650 = 1.0f - ((f32)D_80115D38) / ((f32)D_80115D3C); + if ((f64)D_800DC650 < 0) { D_80115D38 = 0; D_80115D3C = 0; D_800DC650 = 0.0f; @@ -309,16 +307,16 @@ void func_80000D00(u8 arg0) { set_relative_volume_for_music(musicRelativeVolume); } - if(D_800DC658 > 0){ + if (D_800DC658 > 0) { //reg_arg0 = arg0; - for(reg_s2 = 0; reg_s2 < D_800DC658;){ + for (reg_s2 = 0; reg_s2 < D_800DC658;) { D_80115D48[reg_s2].unk2 -= arg0; - if(D_80115D48[reg_s2].unk2 <= 0){ + if (D_80115D48[reg_s2].unk2 <= 0) { j = reg_s2; func_80001D04(D_80115D48[reg_s2].unk0, D_80115D48[reg_s2].unk4); - + D_800DC658 -= 1; - while(j < D_800DC658){ + while (j < D_800DC658) { D_80115D48[reg_s2].unk0 = D_80115D48[reg_s2 + 1].unk0; D_80115D48[reg_s2].unk2 = D_80115D48[reg_s2 + 1].unk2; D_80115D48[reg_s2].unk4 = D_80115D48[reg_s2 + 1].unk4; @@ -326,8 +324,7 @@ void func_80000D00(u8 arg0) { //break; } j++; - } - else{ + } else { reg_s2++; } } @@ -335,8 +332,8 @@ void func_80000D00(u8 arg0) { func_8000232C(gMusicPlayer, D_80115CFC, &D_800DC65C, &D_80115D88); func_8000232C(gSndFxPlayer, D_80115D00, &D_800DC660, &D_80115E80); - if(D_80115D30 == -1 && gMusicPlayer->target){ - D_80115D30 = 0x03938700/alCSPGetTempo(gMusicPlayer); + if (D_80115D30 == -1 && gMusicPlayer->target) { + D_80115D30 = 0x03938700 / alCSPGetTempo(gMusicPlayer); } } @@ -359,21 +356,17 @@ u16 musicGetChanMask(void) { void func_80001074(u16 arg0) { u32 chan; - if(D_800DC65C){ + if (D_800DC65C) { D_80115F7C = arg0; - } - else{ + } else { gMusicPlayer->chanMask = arg0; - for(chan = 0; chan != 16; chan++){ - if(arg0 & (1 << chan)){ + for (chan = 0; chan != 16; chan++) { + if (arg0 & (1 << chan)) { func_80001170(chan); - } - else{ + } else { func_80001114(chan); } - } - } return; } @@ -430,11 +423,11 @@ u8 func_800012A8(u8 arg0) { void func_800012E8(void) { u32 chan; - if(!D_800DC648){ - for(chan = 0; chan<16; chan++){ - func_80001170( chan ); - func_80001268( chan, 127 ); - musicSetChlVol( chan, 127 ); + if (!D_800DC648) { + for (chan = 0; chan < 16; chan++) { + func_80001170(chan); + func_80001268(chan, 127); + musicSetChlVol(chan, 127); } } return; @@ -444,35 +437,34 @@ u8 func_80001358(u8 arg0, u8 arg1, s32 arg2) { u8 val_1f; u8 val_1e; s32 updatedVol; - + //u8 fadeIn_chan = arg0; - if(!(arg0 == 100)){ - val_1f = arg2 + alCSPGetChlVol(gMusicPlayer,arg0); - if(val_1f > 127){ + if (!(arg0 == 100)) { + val_1f = arg2 + alCSPGetChlVol(gMusicPlayer, arg0); + if (val_1f > 127) { val_1f = 127; } - alCSPSetChlVol(gMusicPlayer,arg0, val_1f); + alCSPSetChlVol(gMusicPlayer, arg0, val_1f); } - if(arg1 != 100){ - - updatedVol = alCSPGetChlVol(gMusicPlayer,arg1); + if (arg1 != 100) { + + updatedVol = alCSPGetChlVol(gMusicPlayer, arg1); val_1e = (updatedVol > arg2) ? updatedVol - arg2 : 0; - alCSPSetChlVol(gMusicPlayer,arg1, val_1e); + alCSPSetChlVol(gMusicPlayer, arg1, val_1e); return val_1e; - } - else{ - return 127-val_1f; + } else { + return 127 - val_1f; } } void func_80001440(u8 *arg0) { s32 s0 = 0; - if(gMusicPlayer->maxChannels > 0){ - do{ + if (gMusicPlayer->maxChannels > 0) { + do { arg0[s0] = alSeqpGetChlFXMix(gMusicPlayer, s0); s0++; - }while(s0 < gMusicPlayer->maxChannels); + } while (s0 < gMusicPlayer->maxChannels); } return; } @@ -482,9 +474,9 @@ void func_800014BC(f32 arg0) { } void musicSetTempo(s32 tempo) { - if(tempo != 0){ - f32 inv_tempo = (1.0f/tempo); - alCSPSetTempo(gMusicPlayer,(s32)(inv_tempo * 60000000.0f)); + if (tempo != 0) { + f32 inv_tempo = (1.0f / tempo); + alCSPSetTempo(gMusicPlayer, (s32)(inv_tempo * 60000000.0f)); D_80115D30 = tempo; } } @@ -500,38 +492,36 @@ u8 music_is_playing(void) { #if 1 GLOBAL_ASM("asm/non_matchings/audio/func_800015F8.s") #else -f32 func_800015F8(void){ +f32 func_800015F8(void) { u32 current_cnt = osGetCount(); u32 delta; f32 delta_f; f32 tmp; f32 *tmp2 = &D_80115D34; - - if(audioPrevCount < current_cnt){ + + if (audioPrevCount < current_cnt) { delta = current_cnt - audioPrevCount; delta_f = (delta < 0) - ? (f32) delta + 4294967296.000000f - : delta; - D_80115D34 = delta_f/D_800E49E0 + *tmp2; - } - else{ + ? (f32)delta + 4294967296.000000f + : delta; + D_80115D34 = delta_f / D_800E49E0 + *tmp2; + } else { delta = audioPrevCount - current_cnt; delta_f = (delta + -1); delta_f = (delta < 0) - ? delta_f + 4294967296.000000f - : delta_f; - *tmp2 = delta_f/D_800E49E0 + D_80115D34; + ? delta_f + 4294967296.000000f + : delta_f; + *tmp2 = delta_f / D_800E49E0 + D_80115D34; } - if(D_80115D40 == 0){ + if (D_80115D40 == 0) { D_80115D30 = 182; } - tmp = D_800E49E8/(f32) D_80115D30; - while(D_80115D34 > tmp){ + tmp = D_800E49E8 / (f32)D_80115D30; + while (D_80115D34 > tmp) { D_80115D34 -= tmp; } audioPrevCount = current_cnt; - return D_80115D34/tmp; - + return D_80115D34 / tmp; } #endif @@ -541,20 +531,20 @@ void func_80001728(u8 arg0, u8 *arg1, u8 *arg2, u8 *arg3) { *arg3 = D_80115D1C[arg0].unk2; } -void func_80001784(u8 a0){ - if(!func_80001C08()){ +void func_80001784(u8 a0) { + if (!func_80001C08()) { func_800022BC(D_80115D05 = a0, gSndFxPlayer); D_80115D41 = 1; } } void sfxSetTempo(s32 tempo) { - f32 inv_tempo = (1.0f/tempo); - alCSPSetTempo(gSndFxPlayer,(s32)(inv_tempo * 60000000.0f)); + f32 inv_tempo = (1.0f / tempo); + alCSPSetTempo(gSndFxPlayer, (s32)(inv_tempo * 60000000.0f)); } void func_80001844(void) { - if(!D_800DC648){ + if (!D_800DC648) { func_80002570(gMusicPlayer); } return; @@ -605,17 +595,17 @@ void set_relative_volume_for_music(u8 vol) { f32 normalized_vol; musicRelativeVolume = vol; - normalized_vol = musicVolumeSliderPercentage*musicRelativeVolume*D_800DC650; - alCSPSetVol(gMusicPlayer, (s16)((s32)(D_800DC66C*normalized_vol)>>8)); + normalized_vol = musicVolumeSliderPercentage * musicRelativeVolume * D_800DC650; + alCSPSetVol(gMusicPlayer, (s16)((s32)(D_800DC66C * normalized_vol) >> 8)); } void set_music_volume_slider(u32 slider_val) { f32 normalized_vol; - - slider_val = (slider_val < 0x101)?slider_val:256; + + slider_val = (slider_val < 0x101) ? slider_val : 256; musicVolumeSliderPercentage = slider_val; - normalized_vol = musicVolumeSliderPercentage*musicRelativeVolume*D_800DC650; - alCSPSetVol(gMusicPlayer, (s16)((s32)(D_800DC66C*normalized_vol)>>8)); + normalized_vol = musicVolumeSliderPercentage * musicRelativeVolume * D_800DC650; + alCSPSetVol(gMusicPlayer, (s16)((s32)(D_800DC66C * normalized_vol) >> 8)); } u8 musicGetRelativeVolume(void) { @@ -628,12 +618,12 @@ s32 musicGetVolSliderPercentage(void) { void sfxSetRelativeVolume(u8 arg0) { sfxRelativeVolume = arg0; - alCSPSetVol(gSndFxPlayer, (s16) (sfxGetVolumeSlider() * sfxRelativeVolume)); + alCSPSetVol(gSndFxPlayer, (s16)(sfxGetVolumeSlider() * sfxRelativeVolume)); } void sfxSetPan(ALPan pan) { u32 iChan; - for(iChan = 0; iChan < 16; iChan++){ + for (iChan = 0; iChan < 16; iChan++) { alCSPSetChlPan(gSndFxPlayer, iChan, pan); } return; @@ -641,11 +631,11 @@ void sfxSetPan(ALPan pan) { void play_sound(u8 arg0) { D_800DC644 = 1; - func_800022BC( D_80115D05 = arg0, gSndFxPlayer); + func_800022BC(D_80115D05 = arg0, gSndFxPlayer); } u32 func_80001C08(void) { - if(D_80115D05 && D_800DC644 && (gSndFxPlayer->state == AL_PLAYING) ){ + if (D_80115D05 && D_800DC644 && (gSndFxPlayer->state == AL_PLAYING)) { return D_80115D05; } D_800DC644 = 0; @@ -654,7 +644,7 @@ u32 func_80001C08(void) { void func_80001C5C(u16 arg0) { u32 s0; - for(s0 = 0; s0<64; s0++){ + for (s0 = 0; s0 < 64; s0++) { func_80004A60(s0, arg0 << 8); } } @@ -681,16 +671,15 @@ void func_80001EA8(u16 arg0, f32 x, f32 y, f32 z, s32 **arg4) { } void func_80001F14(u16 sndIndx, u32 *arg1) { - if(sndIndx <= 0 || ALBankFile_80115D14_GetSoundCount() < sndIndx){ - if(arg1){ + if (sndIndx <= 0 || ALBankFile_80115D14_GetSoundCount() < sndIndx) { + if (arg1) { *arg1 = 0; } - } - else{ - if(arg1){ - func_80004638(ALBankFile_80115D14->bankArray[0], (s16) sndIndx, arg1); - }else{ - func_80004638(ALBankFile_80115D14->bankArray[0], (s16) sndIndx, &D_80115F88); + } else { + if (arg1) { + func_80004638(ALBankFile_80115D14->bankArray[0], (s16)sndIndx, arg1); + } else { + func_80004638(ALBankFile_80115D14->bankArray[0], (s16)sndIndx, &D_80115F88); } } } @@ -699,7 +688,7 @@ void func_80001F14(u16 sndIndx, u32 *arg1) { GLOBAL_ASM("asm/non_matchings/audio/func_80001FB8.s") #else void func_80001FB8(u16 arg0) { - arg0*10 + D_80115D18[0].unk00; + arg0 * 10 + D_80115D18[0].unk00; } #endif @@ -737,26 +726,26 @@ void func_8000216C(unk80115D1C **arg0, s32 *arg1, s32 *arg2) { } u8 ALBankFile_80115D14_GetSoundDecayTime(u16 sndIndx) { - if(sndIndx <= 0 || ALBankFile_80115D14->bankArray[0]->instArray[0]->soundCount < sndIndx){ + if (sndIndx <= 0 || ALBankFile_80115D14->bankArray[0]->instArray[0]->soundCount < sndIndx) { return 0; } - return ((u32)(1+ ALBankFile_80115D14->bankArray[0]->instArray[0]->soundArray[sndIndx-1]->envelope->decayTime) == 0); + return ((u32)(1 + ALBankFile_80115D14->bankArray[0]->instArray[0]->soundArray[sndIndx - 1]->envelope->decayTime) == 0); } ALSeqPlayer *func_80002224(s32 _max_voices, s32 _max_events) { ALCSPlayer_Custom *cseqp; ALSeqpConfig config; - + config.maxVoices = _max_voices; config.maxEvents = _max_events; - config.unknown_0x10 = _max_voices; //this member doesn't exist in other versions of ALSeqpConfig + config.unknown_0x10 = _max_voices; //this member doesn't exist in other versions of ALSeqpConfig config.maxChannels = 16; config.heap = &gALHeap; config.initOsc = NULL; config.updateOsc = NULL; config.stopOsc = NULL; - cseqp = (ALCSPlayer_Custom *) alHeapDBAlloc(NULL, 0, &gALHeap, 1, sizeof(ALCSPlayer_Custom)); + cseqp = (ALCSPlayer_Custom *)alHeapDBAlloc(NULL, 0, &gALHeap, 1, sizeof(ALCSPlayer_Custom)); alCSPNew(cseqp, &config); alCSPSetBank(cseqp, ALBankFile_80115D10->bankArray[0]); cseqp->unk36 = 0x7F; @@ -778,31 +767,29 @@ void func_800022BC(u8 arg0, ALSeqPlayer *arg1) { #if 1 GLOBAL_ASM("asm/non_matchings/audio/func_8000232C.s") #else -void func_8000232C(ALSeqPlayer *seqp, void *ptr, u8 *arg2, ALCSeq *seq){ - if(alCSPGetState(seqp) == AL_STOPPED && *arg2){ +void func_8000232C(ALSeqPlayer *seqp, void *ptr, u8 *arg2, ALCSeq *seq) { + if (alCSPGetState(seqp) == AL_STOPPED && *arg2) { /*load_asset_to_address(ASSET_AUDIO, ptr, (u32)((ALSeqFile_80115CF8->seqArray)[*arg2]) - get_rom_offset_of_asset(ASSET_AUDIO,0), *((u32*)(((*arg2) << 3) + D_80115D0C)));*/ alCSeqNew(seq, ptr); alCSPSetSeq(seqp, seq); alCSPPlay(seqp); - if(seqp == gMusicPlayer){ - set_relative_volume_for_music(*((u8*)((*arg2)*3 + D_80115D1C->unk0))); - }else{ - + if (seqp == gMusicPlayer) { + set_relative_volume_for_music(*((u8 *)((*arg2) * 3 + D_80115D1C->unk0))); + } else { } } } #endif void func_80002570(ALSeqPlayer *seqp) { - if(gMusicPlayer == seqp && D_80115D40 != 0){ + if (gMusicPlayer == seqp && D_80115D40 != 0) { alCSPStop(seqp); D_80115D40 = 0; D_80115D04 = 0; D_800DC65C = 0; - } - else if(gSndFxPlayer == seqp && D_80115D41 != 0){ + } else if (gSndFxPlayer == seqp && D_80115D41 != 0) { alCSPStop(seqp); D_80115D41 = 0; D_800DC660 = 0; diff --git a/src/camera.c b/src/camera.c index 10e8d457..eecdaeca 100644 --- a/src/camera.c +++ b/src/camera.c @@ -45,7 +45,7 @@ ScreenViewport gScreenViewports[4] = { s32 D_800DD134 = 0; // Not sure about the typing here -s16 D_800DD138[8] = { +s16 D_800DD138[8] = { 0, 0, 0, -1, -1, 0, 0, 0 }; @@ -73,7 +73,6 @@ Vp D_800DD148[20] = { { 0, 0, 0x01FF, 0, 0, 0, 0x01FF, 0 }, }; - unk8011D510 D_800DD288 = { 0, 0, 0, 0, 1.0f, 0.0f, 0.0f, -281.0f, }; @@ -110,8 +109,8 @@ s32 D_80120CF0[6]; s32 D_80120D08; s32 D_80120D0C; f32 gCurCamFOV; -s8 D_80120D14; -u8 D_80120D15; +s8 D_80120D14; +u8 D_80120D15; s32 D_80120D18; s32 D_80120D1C; s32 D_80120D20[2]; @@ -132,7 +131,7 @@ Matrix D_801210A0; OSMesgQueue *D_801210E0[6]; OSMesg *D_801210F8; OSMesg D_801210FC; -OSContStatus status; +OSContStatus status; s32 D_80121108[2]; //Padding? unk80121110 D_80121110[8]; u16 D_80121140[4]; @@ -146,10 +145,10 @@ extern s32 D_B0000578; void func_80065EA0(void) { s32 i, j; - for(i = 0; i < 5; i++) { + for (i = 0; i < 5; i++) { D_80120D70[i] = &D_80120DA0[i]; }; - for(j = 0; j < 8; j++) { + for (j = 0; j < 8; j++) { D_80120CE4 = j; func_800663DC(200, 200, 200, 0, 0, 180); }; @@ -202,15 +201,13 @@ f32 get_current_camera_fov(void) { void update_camera_fov(f32 camFieldOfView) { if (CAMERA_MIN_FOV < camFieldOfView && camFieldOfView < CAMERA_MAX_FOV && camFieldOfView != gCurCamFOV) { gCurCamFOV = camFieldOfView; - guPerspectiveF(D_80120EE0, &perspNorm[5], camFieldOfView, - CAMERA_ASPECT, CAMERA_NEAR, CAMERA_FAR, CAMERA_SCALE); + guPerspectiveF(D_80120EE0, &perspNorm[5], camFieldOfView, CAMERA_ASPECT, CAMERA_NEAR, CAMERA_FAR, CAMERA_SCALE); func_8006F870(D_80120EE0, D_80120FE0); } } void func_80066194(void) { - guPerspectiveF(D_80120EE0, &perspNorm[5], CAMERA_DEFAULT_FOV, - CAMERA_ASPECT, CAMERA_NEAR, CAMERA_FAR, CAMERA_SCALE); + guPerspectiveF(D_80120EE0, &perspNorm[5], CAMERA_DEFAULT_FOV, CAMERA_ASPECT, CAMERA_NEAR, CAMERA_FAR, CAMERA_SCALE); func_8006F870(D_80120EE0, D_80120FE0); } @@ -270,11 +267,11 @@ f32 func_80066348(f32 arg0, f32 arg1, f32 arg2) { f32 temp_f2, temp_f0, temp_f14; phi_v1 = D_80120CE4; - + if (D_80120D14 != 0) { phi_v1 += 4; } - + temp_f0 = arg2 - D_80120AC0[phi_v1].z_position; temp_f2 = arg0 - D_80120AC0[phi_v1].x_position; temp_f14 = arg1 - D_80120AC0[phi_v1].y_position; @@ -282,18 +279,18 @@ f32 func_80066348(f32 arg0, f32 arg1, f32 arg2) { } void func_800663DC(s32 xPos, s32 yPos, s32 zPos, s32 arg3, s32 arg4, s32 arg5) { - D_80120AC0[D_80120CE4].unk4 = (s16) (arg3 * 0xB6); - D_80120AC0[D_80120CE4].x_position = (f32) xPos; - D_80120AC0[D_80120CE4].y_position = (f32) yPos; - D_80120AC0[D_80120CE4].z_position = (f32) zPos; - D_80120AC0[D_80120CE4].unk2 = (s16) (arg4 * 0xB6); + D_80120AC0[D_80120CE4].unk4 = (s16)(arg3 * 0xB6); + D_80120AC0[D_80120CE4].x_position = (f32)xPos; + D_80120AC0[D_80120CE4].y_position = (f32)yPos; + D_80120AC0[D_80120CE4].z_position = (f32)zPos; + D_80120AC0[D_80120CE4].unk2 = (s16)(arg4 * 0xB6); D_80120AC0[D_80120CE4].unk38 = (u16)0; D_80120AC0[D_80120CE4].unk24 = 0.0f; D_80120AC0[D_80120CE4].unk28 = 0.0f; D_80120AC0[D_80120CE4].unk2C = 0.0f; D_80120AC0[D_80120CE4].unk30 = 0.0f; D_80120AC0[D_80120CE4].unk1C = 160.0f; - D_80120AC0[D_80120CE4].unk0 = (s16) (arg5 * 0xB6); + D_80120AC0[D_80120CE4].unk0 = (s16)(arg5 * 0xB6); D_80120AC0[D_80120CE4].unk3B = D_800DD2F8[D_80120CE4]; } @@ -324,7 +321,7 @@ s32 func_8006652C(s32 arg0) { } else { gNumberOfViewports = 0; } - switch(gNumberOfViewports) { + switch (gNumberOfViewports) { case VIEWPORTS_COUNT_1_PLAYER: D_80120CE8 = 1; break; @@ -364,7 +361,7 @@ void func_80066610(void) { s32 i; D_800DD134 = 1 - D_800DD134; - for(i = 0; i < 4; i++) { + for (i = 0; i < 4; i++) { if (gScreenViewports[i].flags & 4) { gScreenViewports[i].flags &= ~1; } else if (gScreenViewports[i].flags & 2) { @@ -448,7 +445,7 @@ void func_80066940(s32 viewPortIndex, s32 arg1, s32 arg2, s32 arg3, s32 arg4) { s32 phi_a1; s32 phi_a2; s32 phi_a3; - + widthAndHeight = get_video_width_and_height_as_s32(); width = widthAndHeight & 0xFFFF; // Placement issues with the height variable. @@ -589,7 +586,7 @@ void func_80066CDC(Gfx **dlist, s32 arg1) { gScreenViewports[D_80120CE4].upperLeftY, gScreenViewports[D_80120CE4].lowerRightX, gScreenViewports[D_80120CE4].lowerRightY - ) + ); func_80068158(dlist, 0, 0, 0, 0); if (arg1 != 0) { func_80067D3C(dlist, arg1); @@ -606,14 +603,14 @@ void func_80066CDC(Gfx **dlist, s32 arg1) { if (osTvType == TV_TYPE_PAL) { sp58 = 0x91; } - - switch(gNumberOfViewports) { + + switch (gNumberOfViewports) { case VIEWPORTS_COUNT_1_PLAYER: phi_t3 = sp58; if (osTvType == TV_TYPE_PAL) { phi_t3 = sp58 - 0x12; } - gDPSetScissor((*dlist)++, SCISSOR_INTERLACE, 0, 0, temp_t1, temp_t0) + gDPSetScissor((*dlist)++, SCISSOR_INTERLACE, 0, 0, temp_t1, temp_t0); sp4C = temp_a2; break; case VIEWPORTS_COUNT_2_PLAYERS: @@ -623,19 +620,19 @@ void func_80066CDC(Gfx **dlist, s32 arg1) { if (osTvType == TV_TYPE_PAL) { phi_t3 = temp_v0_6 - 0xC; } - gDPSetScissor((*dlist)++, SCISSOR_INTERLACE, 0, 0, temp_t1, (temp_a3 - (temp_t0 >> 7))) + gDPSetScissor((*dlist)++, SCISSOR_INTERLACE, 0, 0, temp_t1, (temp_a3 - (temp_t0 >> 7))); } else { - gDPSetScissor((*dlist)++, SCISSOR_INTERLACE, 0, (temp_a3 + (temp_t0 >> 7)), temp_t1, (temp_t0 - (temp_t0 >> 7))) + gDPSetScissor((*dlist)++, SCISSOR_INTERLACE, 0, (temp_a3 + (temp_t0 >> 7)), temp_t1, (temp_t0 - (temp_t0 >> 7))); phi_t3 = temp_a3 + (temp_t0 >> 2); } sp4C = temp_a2; break; case VIEWPORTS_COUNT_3_PLAYERS: if (D_80120CE4 == 0) { - gDPSetScissor((*dlist)++, SCISSOR_INTERLACE, 0, 0, temp_a2 - (temp_t1 >> 8), temp_t0) + gDPSetScissor((*dlist)++, SCISSOR_INTERLACE, 0, 0, temp_a2 - (temp_t1 >> 8), temp_t0); phi_a1 = temp_t1 >> 2; } else { - gDPSetScissor((*dlist)++, SCISSOR_INTERLACE, temp_a2 + (temp_t1 >> 8), 0, temp_t1 - (temp_t1 >> 8), temp_t0) + gDPSetScissor((*dlist)++, SCISSOR_INTERLACE, temp_a2 + (temp_t1 >> 8), 0, temp_t1 - (temp_t1 >> 8), temp_t0); phi_a1 = temp_a2 + (temp_t1 >> 2); } sp4C = phi_a1; @@ -644,27 +641,23 @@ void func_80066CDC(Gfx **dlist, s32 arg1) { case VIEWPORTS_COUNT_4_PLAYERS: sp58 = sp58 >> 1; sp54 = temp_a2 >> 1; - switch(D_80120CE4) { + switch (D_80120CE4) { case 0: - gDPSetScissor((*dlist)++, SCISSOR_INTERLACE, 0.0f, 0.0f, - (temp_a2 - (temp_t1 >> 8)), (temp_a3 - (temp_t0 >> 7))) + gDPSetScissor((*dlist)++, SCISSOR_INTERLACE, 0.0f, 0.0f, (temp_a2 - (temp_t1 >> 8)), (temp_a3 - (temp_t0 >> 7))); phi_t5 = 0; phi_t4 = 0; case 1: - gDPSetScissor((*dlist)++, SCISSOR_INTERLACE, (temp_a2 + (temp_t1 >> 8)), 0, - ((temp_a2 * 2) - (temp_t1 >> 8)), (temp_a3 - (temp_t0 >> 7))) + gDPSetScissor((*dlist)++, SCISSOR_INTERLACE, (temp_a2 + (temp_t1 >> 8)), 0, ((temp_a2 * 2) - (temp_t1 >> 8)), (temp_a3 - (temp_t0 >> 7))); phi_t5 = 0; phi_t4 = temp_a2; break; case 2: - gDPSetScissor((*dlist)++, SCISSOR_INTERLACE, 0, temp_a3 + (temp_t0 >> 7), - temp_a2 - (temp_t1 >> 8), (temp_a3 * 2) - (temp_t0 >> 7)) + gDPSetScissor((*dlist)++, SCISSOR_INTERLACE, 0, temp_a3 + (temp_t0 >> 7), temp_a2 - (temp_t1 >> 8), (temp_a3 * 2) - (temp_t0 >> 7)); phi_t5 = temp_a3; phi_t4 = 0; break; case 3: - gDPSetScissor((*dlist)++, SCISSOR_INTERLACE, temp_a2 + (temp_t1 >> 8), temp_a3 + (temp_t0 >> 7), - (temp_a2 * 2) - (temp_t1 >> 8), (temp_a3 * 2) - (temp_t0 >> 7)) + gDPSetScissor((*dlist)++, SCISSOR_INTERLACE, temp_a2 + (temp_t1 >> 8), temp_a3 + (temp_t0 >> 7), (temp_a2 * 2) - (temp_t1 >> 8), (temp_a3 * 2) - (temp_t0 >> 7)); phi_t5 = temp_a3; phi_t4 = temp_a2; break; @@ -687,7 +680,7 @@ void func_80066CDC(Gfx **dlist, s32 arg1) { phi_t3 = sp54; break; } - + if (osTvType == TV_TYPE_PAL) { sp4C -= 4; } @@ -701,7 +694,6 @@ void func_80066CDC(Gfx **dlist, s32 arg1) { GLOBAL_ASM("asm/non_matchings/camera/func_80066CDC.s") #endif - GLOBAL_ASM("asm/non_matchings/camera/func_80067A3C.s") GLOBAL_ASM("asm/non_matchings/camera/func_80067D3C.s") @@ -713,7 +705,7 @@ void func_80067F2C(Gfx **dlist, s32 *arg1) { u32 widthAndHeight; s32 width, height; s32 i, j; - + widthAndHeight = get_video_width_and_height_as_s32(); height = widthAndHeight >> 0x10; width = widthAndHeight & 0xFFFF; @@ -723,16 +715,16 @@ void func_80067F2C(Gfx **dlist, s32 *arg1) { D_800DD148[D_80120CE4 + 5].vp.vscale[1] = width * 2; D_800DD148[D_80120CE4 + 5].vp.vtrans[0] = width * 2; D_800DD148[D_80120CE4 + 5].vp.vtrans[1] = height * 2; - gSPViewport((*dlist)++, (u8*)&D_800DD148[D_80120CE4 + 5] + 0x80000000) - fast3d_cmd((*dlist)++, 0x1000040, (u32)(*arg1 + 0x80000000)) + gSPViewport((*dlist)++, (u8 *)&D_800DD148[D_80120CE4 + 5] + 0x80000000); + fast3d_cmd((*dlist)++, 0x1000040, (u32)(*arg1 + 0x80000000)); *arg1 += 0x40; D_80120D1C = 0; D_80120D08 = 0; i = 0; - while(i < 4) { // for loop doesn't match here. + while (i < 4) { // for loop doesn't match here. j = 0; - while(j < 4) { + while (j < 4) { D_80120F20[i][j] = D_800DD2B8[i][j]; j++; } @@ -745,8 +737,8 @@ void func_8006807C(Gfx **dlist, s32 *arg1) { func_8006F768(&D_80121060, &D_80120EE0, &D_80120F20); func_8006FE74(D_80120D70[0], &D_800DD2A0); func_8006F768(D_80120D70[0], &D_80120F20, &D_80121060); - func_8006F870(D_80121060, (s32*)*arg1); // This doesn't look right. Need to check this! - fast3d_cmd((*dlist)++, 0x1000040, (u32)(*arg1 + 0x80000000)) + func_8006F870(D_80121060, (s32 *)*arg1); // This doesn't look right. Need to check this! + fast3d_cmd((*dlist)++, 0x1000040, (u32)(*arg1 + 0x80000000)); *arg1 += 0x40; D_80120D1C = 0; D_80120D08 = 0; @@ -763,9 +755,9 @@ void func_80068158(Gfx **dlist, s32 arg1, s32 arg2, s32 arg3, s32 arg4) { D_800DD148[D_80120CE4].vp.vtrans[1] = arg4 * 4; D_800DD148[D_80120CE4].vp.vscale[0] = tempArg1 * 4; D_800DD148[D_80120CE4].vp.vscale[1] = arg2 * 4; - gSPViewport((*dlist)++, (u8*)&D_800DD148[D_80120CE4] + 0x80000000) + gSPViewport((*dlist)++, (u8 *)&D_800DD148[D_80120CE4] + 0x80000000); } else { - gSPViewport((*dlist)++, (u8*)&D_800DD148[D_80120CE4 + 10 + (D_800DD134 * 5)] + 0x80000000) + gSPViewport((*dlist)++, (u8 *)&D_800DD148[D_80120CE4 + 10 + (D_800DD134 * 5)] + 0x80000000); } } @@ -776,7 +768,7 @@ void func_800682AC(Gfx **dlist) { height = widthAndHeight >> 0x10; width = widthAndHeight & 0xFFFF; if (!(gScreenViewports[D_80120CE4].flags & 1)) { - gDPSetScissor((*dlist)++, G_SC_NON_INTERLACE, 0, 0, width - 1, height - 1) + gDPSetScissor((*dlist)++, G_SC_NON_INTERLACE, 0, 0, width - 1, height - 1); func_80068158(dlist, width >> 1, height >> 1, width >> 1, height >> 1); } else { func_80067A3C(dlist); @@ -788,11 +780,11 @@ void func_800682AC(Gfx **dlist) { void func_80068408(Gfx **dlist, s32 *arg1) { func_800705F8(D_80120D70[D_80120D1C], 0.0f, 0.0f, 0.0f); func_8006F768(D_80120D70[D_80120D1C], &D_80120F20, &D_80121060); - func_8006F870(D_80121060, (s32*)*arg1); // This doesn't look right. Need to check this! + func_8006F870(D_80121060, (s32 *)*arg1); // This doesn't look right. Need to check this! D_80120D88[D_80120D1C] = *arg1; - - fast3d_cmd((*dlist)++, ((((D_80120D08 << 6) & 0xFF) << 0x10) | 0x1000000) | 0x40, (u32)(*arg1 + 0x80000000)) - + + fast3d_cmd((*dlist)++, ((((D_80120D08 << 6) & 0xFF) << 0x10) | 0x1000000) | 0x40, (u32)(*arg1 + 0x80000000)); + *arg1 += 0x40; } @@ -851,7 +843,7 @@ void func_80069E14(f32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4) { f32 temp_f14; f32 temp_f2; s32 i; - + for (i = 0; i <= gNumberOfViewports; i++) { temp_f0 = arg0 - D_80120AC0[i].x_position; temp_f2 = arg1 - D_80120AC0[i].y_position; @@ -865,7 +857,7 @@ void func_80069E14(f32 arg0, f32 arg1, f32 arg2, f32 arg3, f32 arg4) { void func_80069F28(f32 arg0) { s32 i; - for(i = 0; i <= gNumberOfViewports; i++) { + for (i = 0; i <= gNumberOfViewports; i++) { D_80120AC0[i].unk30 = arg0; } } @@ -875,8 +867,8 @@ void func_80069F28(f32 arg0) { void func_80069F64(s16 *mtx) { s32 i, j; s32 val; - for(i = 0; i < 4; i++) { - for(j = 0; j < 4; j++) { + for (i = 0; i < 4; i++) { + for (j = 0; j < 4; j++) { val = mtx[i * 4 + j]; rmonPrintf("%x.", val); val = mtx[((i + 4) * 4 + j)]; // Issue here. @@ -893,9 +885,9 @@ GLOBAL_ASM("asm/non_matchings/camera/func_80069F64.s") // Unused. Prints/Displays a 4x4 floating-point matrix. void func_8006A03C(f32 *mtx) { s32 i, j; - - for(i = 0; i < 4; i++) { - for(j = 0; j < 4; j++) { + + for (i = 0; i < 4; i++) { + for (j = 0; j < 4; j++) { rmonPrintf("%f ", mtx[i * 4 + j]); } rmonPrintf("\n"); @@ -924,7 +916,7 @@ s32 func_8006A10C(void) { return 0; } - if (!bitpattern) { } + if (!bitpattern) {} D_800DD300 = 1; @@ -935,7 +927,7 @@ GLOBAL_ASM("asm/non_matchings/camera/func_8006A1C4.s") void func_8006A434(void) { s32 i; - for(i = 0; i < 4; i++) { + for (i = 0; i < 4; i++) { D_80121150[i] = i; } } @@ -943,12 +935,12 @@ void func_8006A434(void) { void func_8006A458(s8 *activePlayers) { s32 i; s32 temp = 0; - for(i = 0; i < 4; i++) { + for (i = 0; i < 4; i++) { if (activePlayers[i]) { D_80121150[temp++] = i; } } - for(i = 0; i < 4; i++) { + for (i = 0; i < 4; i++) { if (!activePlayers[i]) { D_80121150[temp++] = i; } diff --git a/src/controller_pak.c b/src/controller_pak.c index c745c857..b74fb724 100644 --- a/src/controller_pak.c +++ b/src/controller_pak.c @@ -16,7 +16,7 @@ s32 *D_800DE440 = 0; u8 gN64FontCodes[68] = "\0 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ!\"#'*+,-./:=?@"; -s32 D_800DE488 = 0; // Currently unknown, might be a different type. +s32 D_800DE488 = 0; // Currently unknown, might be a different type. s32 D_800DE48C = 0; /*******************************/ @@ -54,7 +54,7 @@ const char D_800E7714[] = "WARNING : No Eprom\n"; const char D_800E7728[] = "WARNING : No Eprom\n"; const char D_800E773C[] = "DKRACING-GHOSTS"; // Used in func_80074B34 -const u8 D_800E774C[4] = { 0, 0, 0, 0 }; // Used in func_80074B34, but I'm confused to what this is for. +const u8 D_800E774C[4] = { 0, 0, 0, 0 }; // Used in func_80074B34, but I'm confused to what this is for. const char D_800E7750[] = "warning: corrupt ghost\n"; /*********************************/ @@ -144,7 +144,7 @@ s32 func_80073F5C(s32 arg0, s32 arg1) { size = get_s32_256(); // 256 bytes sp2C = allocate_from_main_pool_safe(size, COLOR_TAG_WHITE); - *((s32*)sp2C) = 0x47414D44; //'GAMD'; + *((s32 *)sp2C) = 0x47414D44; //'GAMD'; func_800732E8(arg1, sp2C + 4); phi_v1 = func_80073C5C(arg0, 3, &sp30); if (phi_v1 == 0) { @@ -168,7 +168,7 @@ s32 func_80074148(s32 arg0, Settings *arg1) { sp24 = get_s32_512(); // 512 bytes sp2C = allocate_from_main_pool_safe(sp24, COLOR_TAG_WHITE); - *((s32*)sp2C) = 0x54494D44; // TIMD + *((s32 *)sp2C) = 0x54494D44; // TIMD func_800738A4(arg1, sp2C + 4); phi_v1 = func_80073C5C(arg0, 4, &sp30); if (phi_v1 == 0) { @@ -202,7 +202,7 @@ s32 func_8007497C(u64 *arg0) { *arg0 >>= 8; *arg0 |= (s64)((s32)func_8007480C(*arg0)) << 56; if (func_8006EAC0() == 0) { - osEepromWrite(func_8006A100(), 0xF, (u8*)arg0); + osEepromWrite(func_8006A100(), 0xF, (u8 *)arg0); } return 1; } @@ -217,11 +217,11 @@ s16 func_80074A4C(GhostHeader *ghostHeader) { s16 len; s16 sum; s32 temp; - + sum = 0; len = (ghostHeader->nodeCount * sizeof(GhostDataFrame)) + sizeof(GhostHeader); - for(i = sizeof(GhostHeader); i < len; i++) { - sum += ((u8*)ghostHeader)[i]; + for (i = sizeof(GhostHeader); i < len; i++) { + sum += ((u8 *)ghostHeader)[i]; } return sum; } @@ -235,7 +235,7 @@ void func_80074AA8(GhostHeader *ghostHeader, s16 characterID, s16 time, s16 node ghostHeader->unk3 = 0; ghostHeader->time = time; ghostHeader->nodeCount = nodeCount; - bcopy(dest, (u8*)ghostHeader + 8, nodeCount * sizeof(GhostDataFrame)); + bcopy(dest, (u8 *)ghostHeader + 8, nodeCount * sizeof(GhostDataFrame)); ghostHeader->checksum = func_80074A4C(ghostHeader); } @@ -431,7 +431,7 @@ s32 func_80076AF4(s32 controllerIndex, s32 fileNum) { ret = 6; data = allocate_from_main_pool_safe(0x100, COLOR_TAG_BLACK); if (read_data_from_controller_pak(controllerIndex, fileNum, (u8 *)data, 0x100) == 0) { - switch(*data) { + switch (*data) { case 0x47414D44: //'GAMD': // Game Data? ret = 3; break; diff --git a/src/fade_transition.c b/src/fade_transition.c index 60070b29..3c37406f 100644 --- a/src/fade_transition.c +++ b/src/fade_transition.c @@ -27,15 +27,15 @@ s32 *D_800E31C8[2] = { NULL, NULL }; s32 D_800E31D0[2] = { 0, 0 }; Gfx D_800E31D8[] = { - gsDPPipeSync(), + gsDPPipeSync(), gsDPSetCycleType(G_CYC_1CYCLE), gsDPSetTextureLOD(G_TL_TILE), gsDPSetTextureLUT(G_TT_NONE), - gsDPSetTextureDetail(G_TD_CLAMP), + gsDPSetTextureDetail(G_TD_CLAMP), gsDPSetTexturePersp(G_TP_NONE), gsDPSetTextureFilter(G_TF_BILERP), - gsDPSetTextureConvert(G_TC_FILT), - gsDPSetAlphaCompare(G_AC_NONE), + gsDPSetTextureConvert(G_TC_FILT), + gsDPSetAlphaCompare(G_AC_NONE), gsDPSetRenderMode(G_RM_CLD_SURF, G_RM_CLD_SURF2), gsSPEndDisplayList(), }; @@ -295,7 +295,7 @@ s32 func_800C0494(s32 arg0) { } else if (arg0 >= 6) { arg0 = 5; } - + if (D_800E31AC != 0) { if (D_800E31B0 == 0) { D_800E31AC = -1; @@ -360,7 +360,7 @@ void render_fade_transition(s32 dlist, s32 arg1, s32 arg2) { render_fade_disabled(dlist, arg1, arg2); break; } - + func_80066CDC(dlist, arg1); } } @@ -380,10 +380,10 @@ void func_800C0724(void) { void func_800C0780(FadeTransition *transition) { if (transition->type & 0x80) { D_8012A750 = 255.0f; - D_8012A754 = -255.0f / (f32) D_800E31B0; + D_8012A754 = -255.0f / (f32)D_800E31B0; } else { D_8012A750 = 0.0f; - D_8012A754 = 255.0f / (f32) D_800E31B0; + D_8012A754 = 255.0f / (f32)D_800E31B0; } D_800E31AC = 1; } @@ -392,10 +392,10 @@ GLOBAL_ASM("asm/non_matchings/fade_transition/func_800C0834.s") void render_fade_fullscreen(Gfx **dlist, s32 arg1, s32 arg2) { s32 screenSize = get_video_width_and_height_as_s32(); - gSPDisplayList((*dlist)++, D_800E31D8) - gDPSetPrimColor((*dlist)++, 0, 0, gCurFadeRed, gCurFadeGreen, gCurFadeBlue, gCurFadeAlpha) - gDPSetCombineMode((*dlist)++, G_CC_PRIMITIVE, G_CC_PRIMITIVE) - gDPFillRectangle((*dlist)++, 0, 0, screenSize & 0x3FF, (screenSize >> 16) & 0x3FF) + gSPDisplayList((*dlist)++, D_800E31D8); + gDPSetPrimColor((*dlist)++, 0, 0, gCurFadeRed, gCurFadeGreen, gCurFadeBlue, gCurFadeAlpha); + gDPSetCombineMode((*dlist)++, G_CC_PRIMITIVE, G_CC_PRIMITIVE); + gDPFillRectangle((*dlist)++, 0, 0, screenSize & 0x3FF, (screenSize >> 16) & 0x3FF); func_8007B3D0(dlist); } @@ -404,20 +404,20 @@ GLOBAL_ASM("asm/non_matchings/fade_transition/func_800C1130.s") void render_fade_barndoor_horizontal(Gfx **dlist, s32 arg1, s32 arg2) { func_8007B3D0(dlist); - gSPDisplayList((*dlist)++, D_800E3648) + gSPDisplayList((*dlist)++, D_800E3648); // TODO: Need to clean this up. - gDkrVertices((*dlist)++, (s32)D_800E31C0[D_800E31D0[0]] + 0x80000000, (((s32)D_800E31C0[D_800E31D0[0]] + 0x80000000) & 6) | 0x58, 0x70) - gDkrTriangles((*dlist)++, (s32)D_800E31C8[D_800E31D0[0]] + 0x80000000, 8, TRIN_DISABLE_TEXTURE) + gDkrVertices((*dlist)++, (s32)D_800E31C0[D_800E31D0[0]] + 0x80000000, (((s32)D_800E31C0[D_800E31D0[0]] + 0x80000000) & 6) | 0x58, 0x70); + gDkrTriangles((*dlist)++, (s32)D_800E31C8[D_800E31D0[0]] + 0x80000000, 8, TRIN_DISABLE_TEXTURE); func_8007B3D0(dlist); } // This is exactly the same as render_fade_barndoor_horizontal; I wonder what gets changed then? void render_fade_barndoor_vertical(Gfx **dlist, s32 arg1, s32 arg2) { func_8007B3D0(dlist); - gSPDisplayList((*dlist)++, D_800E3648) + gSPDisplayList((*dlist)++, D_800E3648); // TODO: Need to clean this up. - gDkrVertices((*dlist)++, (s32)D_800E31C0[D_800E31D0[0]] + 0x80000000, (((s32)D_800E31C0[D_800E31D0[0]] + 0x80000000) & 6) | 0x58, 0x70) - gDkrTriangles((*dlist)++, (s32)D_800E31C8[D_800E31D0[0]] + 0x80000000, 8, TRIN_DISABLE_TEXTURE) + gDkrVertices((*dlist)++, (s32)D_800E31C0[D_800E31D0[0]] + 0x80000000, (((s32)D_800E31C0[D_800E31D0[0]] + 0x80000000) & 6) | 0x58, 0x70); + gDkrTriangles((*dlist)++, (s32)D_800E31C8[D_800E31D0[0]] + 0x80000000, 8, TRIN_DISABLE_TEXTURE); func_8007B3D0(dlist); } @@ -428,23 +428,23 @@ GLOBAL_ASM("asm/non_matchings/fade_transition/func_800C1EE8.s") void render_fade_circle(Gfx **dlist, s32 arg1, s32 arg2) { u8 *addr, *addr2; func_8007B3D0(dlist); - gSPDisplayList((*dlist)++, D_800E3648) - addr = (D_800E31C0[D_800E31D0[0]] + 0x80000000); + gSPDisplayList((*dlist)++, D_800E3648); + addr = (D_800E31C0[D_800E31D0[0]] + 0x80000000); addr2 = (D_800E31C8[D_800E31D0[0]] + 0x80000000); - gDkrVertices((*dlist)++, (s32)addr, ((s32)addr & 6) | 0x88, 0xA6) - gDkrTriangles((*dlist)++, (s32)addr2, 16, TRIN_DISABLE_TEXTURE) + gDkrVertices((*dlist)++, (s32)addr, ((s32)addr & 6) | 0x88, 0xA6); + gDkrTriangles((*dlist)++, (s32)addr2, 16, TRIN_DISABLE_TEXTURE); addr += 0xB4; addr2 += 0x100; - gDkrVertices((*dlist)++, (s32)addr, ((s32)addr & 6) | 0x88, 0xA6) - gDkrTriangles((*dlist)++, (s32)addr2, 16, TRIN_DISABLE_TEXTURE) + gDkrVertices((*dlist)++, (s32)addr, ((s32)addr & 6) | 0x88, 0xA6); + gDkrTriangles((*dlist)++, (s32)addr2, 16, TRIN_DISABLE_TEXTURE); addr += 0xB4; addr2 += 0x100; - gDkrVertices((*dlist)++, (s32)addr, ((s32)addr & 6) | 0x88, 0xA6) - gDkrTriangles((*dlist)++, (s32)addr2, 16, TRIN_DISABLE_TEXTURE) + gDkrVertices((*dlist)++, (s32)addr, ((s32)addr & 6) | 0x88, 0xA6); + gDkrTriangles((*dlist)++, (s32)addr2, 16, TRIN_DISABLE_TEXTURE); addr += 0xB4; addr2 += 0x100; - gDkrVertices((*dlist)++, (s32)addr, ((s32)addr & 6) | 0x88, 0xA6) - gDkrTriangles((*dlist)++, (s32)addr2, 16, TRIN_DISABLE_TEXTURE) + gDkrVertices((*dlist)++, (s32)addr, ((s32)addr & 6) | 0x88, 0xA6); + gDkrTriangles((*dlist)++, (s32)addr2, 16, TRIN_DISABLE_TEXTURE); func_8007B3D0(dlist); } #else @@ -455,15 +455,15 @@ GLOBAL_ASM("asm/non_matchings/fade_transition/render_fade_circle.s") void render_fade_waves(Gfx **dlist, s32 arg1, s32 arg2) { s32 i; func_8007B3D0(dlist); - gSPDisplayList((*dlist)++, D_800E3648) + gSPDisplayList((*dlist)++, D_800E3648); for(i = 0; i < 6; i++) { s32 index = D_800E31D0[0] + i; if(i != 1 && i != 4) { - gDkrVertices((*dlist)++, (s32)D_800E31C0[index] + 0x80000000, (((s32)D_800E31C0[index] + 0x80000000) & 6) | 0x78, 0x94) - gDkrTriangles((*dlist)++, (s32)D_800E31C8[index] + 0x80000000, 14, TRIN_DISABLE_TEXTURE) + gDkrVertices((*dlist)++, (s32)D_800E31C0[index] + 0x80000000, (((s32)D_800E31C0[index] + 0x80000000) & 6) | 0x78, 0x94); + gDkrTriangles((*dlist)++, (s32)D_800E31C8[index] + 0x80000000, 14, TRIN_DISABLE_TEXTURE); } else { - gDkrVertices((*dlist)++, (s32)D_800E31C0[index] + 0x80000000, (((s32)D_800E31C0[index] + 0x80000000) & 6) | 0x68, 0x82) - gDkrTriangles((*dlist)++, (s32)D_800E31C8[index] + 0x80000000, 12, TRIN_DISABLE_TEXTURE) + gDkrVertices((*dlist)++, (s32)D_800E31C0[index] + 0x80000000, (((s32)D_800E31C0[index] + 0x80000000) & 6) | 0x68, 0x82); + gDkrTriangles((*dlist)++, (s32)D_800E31C8[index] + 0x80000000, 12, TRIN_DISABLE_TEXTURE); } } func_8007B3D0(dlist); @@ -474,10 +474,10 @@ GLOBAL_ASM("asm/non_matchings/fade_transition/render_fade_waves.s") void render_fade_barndoor_diagonal(Gfx **dlist, s32 arg1, s32 arg2) { func_8007B3D0(dlist); - gSPDisplayList((*dlist)++, D_800E3648) + gSPDisplayList((*dlist)++, D_800E3648); // TODO: Need to clean this up. - gDkrVertices((*dlist)++, (s32)D_800E31C0[D_800E31D0[0]] + 0x80000000, (((s32)D_800E31C0[D_800E31D0[0]] + 0x80000000) & 6) | 0x48, 0x5E) - gDkrTriangles((*dlist)++, (s32)D_800E31C8[D_800E31D0[0]] + 0x80000000, 6, TRIN_DISABLE_TEXTURE) + gDkrVertices((*dlist)++, (s32)D_800E31C0[D_800E31D0[0]] + 0x80000000, (((s32)D_800E31C0[D_800E31D0[0]] + 0x80000000) & 6) | 0x48, 0x5E); + gDkrTriangles((*dlist)++, (s32)D_800E31C8[D_800E31D0[0]] + 0x80000000, 6, TRIN_DISABLE_TEXTURE); func_8007B3D0(dlist); } @@ -486,27 +486,27 @@ GLOBAL_ASM("asm/non_matchings/fade_transition/func_800C2640.s") #ifdef NON_MATCHING void func_800C27A0(s32 arg0) { //do { - if (D_800E31B0 > 0) { - gLastFadeRed += D_8012A744 * arg0; - gLastFadeGreen += D_8012A748 * arg0; - gLastFadeBlue += D_8012A74C * arg0; - if (arg0 >= D_800E31B0) { - gLastFadeRed = gCurFadeRed << 16; - gLastFadeGreen = gCurFadeGreen << 16; - gLastFadeBlue = gCurFadeBlue << 16; - D_800E31B0 = 0; - arg0 -= D_800E31B0; - } else { - D_800E31B0 -= arg0; - } + if (D_800E31B0 > 0) { + gLastFadeRed += D_8012A744 * arg0; + gLastFadeGreen += D_8012A748 * arg0; + gLastFadeBlue += D_8012A74C * arg0; + if (arg0 >= D_800E31B0) { + gLastFadeRed = gCurFadeRed << 16; + gLastFadeGreen = gCurFadeGreen << 16; + gLastFadeBlue = gCurFadeBlue << 16; + D_800E31B0 = 0; + arg0 -= D_800E31B0; } else { - D_800E31B4 -= arg0; - if (D_800E31B4 != 0xFFFF) { - if ((D_800E31B4 & 0xFFFF) <= 0) { - D_800E31B4 = 0; - } + D_800E31B0 -= arg0; + } + } else { + D_800E31B4 -= arg0; + if (D_800E31B4 != 0xFFFF) { + if ((D_800E31B4 & 0xFFFF) <= 0) { + D_800E31B4 = 0; } } + } //} while(1 == 0); } #else @@ -515,9 +515,9 @@ GLOBAL_ASM("asm/non_matchings/fade_transition/func_800C27A0.s") void render_fade_disabled(Gfx **dlist, s32 arg1, s32 arg2) { s32 screenSize = get_video_width_and_height_as_s32(); - gSPDisplayList((*dlist)++, D_800E31D8) - gDPSetPrimColor((*dlist)++, 0, 0, (gLastFadeRed >> 16), (gLastFadeGreen >> 16), (gLastFadeBlue >> 16), 255) - gDPSetCombineMode((*dlist)++, G_CC_PRIMITIVE, G_CC_PRIMITIVE) - gDPFillRectangle((*dlist)++, 0, 0, screenSize & 0x3FF, (screenSize >> 16) & 0x3FF) + gSPDisplayList((*dlist)++, D_800E31D8); + gDPSetPrimColor((*dlist)++, 0, 0, (gLastFadeRed >> 16), (gLastFadeGreen >> 16), (gLastFadeBlue >> 16), 255); + gDPSetCombineMode((*dlist)++, G_CC_PRIMITIVE, G_CC_PRIMITIVE); + gDPFillRectangle((*dlist)++, 0, 0, screenSize & 0x3FF, (screenSize >> 16) & 0x3FF); func_8007B3D0(dlist); } diff --git a/src/font.c b/src/font.c index 78a9070e..a947b3ba 100644 --- a/src/font.c +++ b/src/font.c @@ -8,17 +8,17 @@ /************ .data ************/ Gfx D_800E3690[] = { - gsDPPipeSync(), + gsDPPipeSync(), gsDPSetTextureLOD(G_TL_TILE), gsDPSetTextureLUT(G_TT_NONE), gsDPSetAlphaCompare(G_AC_NONE), - gsSPClearGeometryMode(G_ZBUFFER | G_FOG), - gsDPPipeSync(), + gsSPClearGeometryMode(G_ZBUFFER | G_FOG), + gsDPPipeSync(), gsSPEndDisplayList(), }; // Unused? -Gfx D_800E36C8[][2] = { +Gfx D_800E36C8[][2] = { { gsDPSetCombineMode(DKR_CC_UNK11, DKR_CC_UNK11), gsDPSetOtherMode(DKR_OMH_1CYC_POINT_NOPERSP, DKR_OML_COMMON | G_RM_XLU_SURF | G_RM_XLU_SURF2), @@ -33,8 +33,16 @@ s8 D_800E36E8 = 0; // Descending powers of 10 s32 gDescPowsOf10[9] = { - 1000000000, 100000000, 10000000, 1000000, 100000, 10000, 1000, 100, 10, -}; + 1000000000, + 100000000, + 10000000, + 1000000, + 100000, + 10000, + 1000, + 100, + 10, +}; s8 D_800E3710[48] = { 4, FALSE, 0, FALSE, 1, @@ -64,24 +72,24 @@ s32 D_8012A7F8; s32 D_8012A7FC; /******************************/ - + void load_fonts(void) { s32 *fontAssetData; s32 i; fontAssetData = load_asset_section_from_rom(ASSET_BINARY_44); - - gFonts = (FontData*)(fontAssetData); // ??? + + gFonts = (FontData *)(fontAssetData); // ??? gNumberOfFonts = *(fontAssetData); - gFonts = (FontData*)(fontAssetData + 1); - + gFonts = (FontData *)(fontAssetData + 1); + for (i = 0; i < gNumberOfFonts; i++) { gFonts[i].unk28[0] = 0; } - + D_8012A7E8 = allocate_from_main_pool_safe(unk8012A7E8_TOTAL_SIZE + unk8012A7EC_TOTAL_SIZE, COLOR_TAG_YELLOW); - D_8012A7EC = (unk8012A7EC*)((u8*)D_8012A7E8 + unk8012A7E8_TOTAL_SIZE); - + D_8012A7EC = (unk8012A7EC *)((u8 *)D_8012A7E8 + unk8012A7E8_TOTAL_SIZE); + for (i = 0; i < unk8012A7E8_COUNT; i++) { (*D_8012A7E8)[i].xpos = 0; (*D_8012A7E8)[i].ypos = 0; @@ -205,7 +213,7 @@ TextureHeader *func_800C4318(s32 font, u8 arg1) { return NULL; } } - // @bug: No return statement. The function will return whatever happens to be in v0 + // @bug: No return statement. The function will return whatever happens to be in v0 // before this function was called. } @@ -229,11 +237,11 @@ void set_text_background_color(s32 red, s32 green, s32 blue, s32 alpha) { } // Unused? -void func_800C4404(Gfx** displayList, char *text, s32 alignmentFlags) { +void func_800C4404(Gfx **displayList, char *text, s32 alignmentFlags) { func_800C45A4(displayList, &(*D_8012A7E8)[0], text, alignmentFlags, 1.0f); } -void draw_text(Gfx** displayList, s32 xpos, s32 ypos, char *text, s32 alignmentFlags) { +void draw_text(Gfx **displayList, s32 xpos, s32 ypos, char *text, s32 alignmentFlags) { unk8012A7E8 *temp = &(*D_8012A7E8)[0]; temp->xpos = (xpos == -0x8000) ? temp->unkC >> 1 : xpos; temp->ypos = (ypos == -0x8000) ? temp->unkE >> 1 : ypos; @@ -241,7 +249,7 @@ void draw_text(Gfx** displayList, s32 xpos, s32 ypos, char *text, s32 alignmentF } // Unused? -void func_800C44C0(Gfx** displayList, s32 arg1, char *text, s32 alignmentFlags) { +void func_800C44C0(Gfx **displayList, s32 arg1, char *text, s32 alignmentFlags) { if (arg1 >= 0 && arg1 < 8) { unk8012A7E8 *temp = &D_8012A7E8[arg1]; func_800C45A4(displayList, temp, text, alignmentFlags, 1.0f); @@ -249,7 +257,7 @@ void func_800C44C0(Gfx** displayList, s32 arg1, char *text, s32 alignmentFlags) } // Unused? -void func_800C4510(Gfx** displayList, s32 arg1, s32 xpos, s32 ypos, char *text, s32 alignmentFlags) { +void func_800C4510(Gfx **displayList, s32 arg1, s32 xpos, s32 ypos, char *text, s32 alignmentFlags) { if (arg1 >= 0 && arg1 < 8) { unk8012A7E8 *temp = &D_8012A7E8[arg1]; temp->xpos = (xpos == -0x8000) ? temp->unkC >> 1 : xpos; @@ -266,7 +274,7 @@ s32 func_800C4DA0(u8 *text, s32 x, s32 font) { s32 diffX, thisDiffX; FontData *fontData; FontCharData *fontCharData; - + if (text == NULL) { return 0; } @@ -275,7 +283,7 @@ s32 func_800C4DA0(u8 *text, s32 x, s32 font) { font = (*D_8012A7E8)[0].font; } fontData = &gFonts[font]; - while(*text != '\0') { + while (*text != '\0') { u8 ch = *text; thisDiffX = diffX; if ((ch < 0x21) || (ch >= 0x80)) { @@ -311,18 +319,18 @@ void func_800C4EDC(s32 arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4) { temp->xpos = 0; temp->ypos = 0; if (arg1 < arg3) { - temp->unk4 = (s16) arg1; - temp->unk8 = (s16) arg3; + temp->unk4 = (s16)arg1; + temp->unk8 = (s16)arg3; } else { - temp->unk8 = (s16) arg1; - temp->unk4 = (s16) arg3; + temp->unk8 = (s16)arg1; + temp->unk4 = (s16)arg3; } if (arg2 < arg4) { - temp->unk6 = (s16) arg2; - temp->unkA = (s16) arg4; + temp->unk6 = (s16)arg2; + temp->unkA = (s16)arg4; } else { - temp->unkA = (s16) arg2; - temp->unk6 = (s16) arg4; + temp->unkA = (s16)arg2; + temp->unk6 = (s16)arg4; } temp->unkC = (temp->unk8 - temp->unk4) + 1; temp->unkE = (temp->unkA - temp->unk6) + 1; @@ -338,7 +346,6 @@ void func_800C4F7C(s32 arg0, s32 font) { } } - void func_800C4FBC(s32 arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4) { if (arg0 > 0 && arg0 < 8) { unk8012A7E8 *temp = &D_8012A7E8[arg0]; @@ -408,7 +415,7 @@ void func_800C5428(s32 arg0, unk8012A7E8_24 *arg1) { unk8012A7E8 *temp; unk8012A7E8_24 *temp_24; unk8012A7E8_24 **temp_24_ptr; - + temp = &D_8012A7E8[arg0]; temp_24_ptr = &temp->unk24; temp_24 = temp->unk24; @@ -425,11 +432,11 @@ void func_800C5428(s32 arg0, unk8012A7E8_24 *arg1) { void func_800C5494(s32 arg0) { unk8012A7E8 *temp; unk8012A7E8_24 *temp_24, *temp_24_2; - + temp = &D_8012A7E8[arg0]; temp_24 = temp->unk24; if (temp_24 != NULL) { - temp_24_2 = temp_24; // This seems redundant. + temp_24_2 = temp_24; // This seems redundant. while (temp_24_2 != NULL) { temp_24_2->unk01 = 0xFF; temp_24_2 = temp_24_2->unk1C; @@ -442,14 +449,14 @@ void func_800C5494(s32 arg0) { void func_800C54E8(s32 arg0, unk800C54E8 *arg1, s32 arg2, s32 arg3, s32 arg4) { FontData *fontData; unk8012A7E8 *temp; - + temp = &D_8012A7E8[arg0]; - if(arg1 != NULL){ + if (arg1 != NULL) { if (arg1->unk19 != 0xFF) { fontData = &gFonts[arg1->unk19]; - if(arg4 != 4) { - switch(arg4) { + if (arg4 != 4) { + switch (arg4) { case 1: arg3 *= fontData->unk22; break; @@ -505,8 +512,8 @@ void func_800C56FC(s32 arg0, s32 arg1, s32 arg2) { D_800E36E8 = 0; } } - - for(i = 1; i < 8; i++) { + + for (i = 1; i < 8; i++) { if ((*D_8012A7E8)[i].unk1E & 0x8000) { if ((*D_8012A7E8)[i].unk1E & 0x4000) { func_800C5B58(arg0, arg1, arg2, i); @@ -518,21 +525,21 @@ void func_800C56FC(s32 arg0, s32 arg1, s32 arg2) { } #ifdef NON_MATCHING -void s32_to_string(char** outString, s32 number) { +void s32_to_string(char **outString, s32 number) { u8 digit; s32 i; s32 hasDigit; // boolean s32 div; - + // Check for a negative number - if (number < 0) { + if (number < 0) { **outString = '-'; number = -number; (*outString)++; } - + // Loop through digit places. - for(i = 0; i < 9; i++){ + for (i = 0; i < 9; i++) { hasDigit = FALSE; digit = '0'; if (number >= gDescPowsOf10[i]) { @@ -580,13 +587,13 @@ void func_800C5B58(Gfx **dlist, s32 *arg1, s32 *arg2, s32 arg3) { s32 x0, x1; char sp6C[256]; s32 y0, y1; - + temp = &D_8012A7E8[arg3]; - + if (temp->unk13 != 0) { - gSPDisplayList((*dlist)++, &D_800E3690) - gDkrDmaDisplayList((*dlist)++, ((u8*)&D_800E36C8[1]) + 0x80000000, 2) - gDPSetEnvColor((*dlist)++, 0, 0, 0, 0) + gSPDisplayList((*dlist)++, &D_800E3690); + gDkrDmaDisplayList((*dlist)++, ((u8 *)&D_800E36C8[1]) + 0x80000000, 2); + gDPSetEnvColor((*dlist)++, 0, 0, 0, 0); if ((temp->unk8 - temp->unk4) < 10 || (temp->unkA - temp->unk6) < 10) { render_fill_rectangle(dlist, temp->unk4 - 2, temp->unk6 - 2, temp->unk8 + 2, temp->unkA + 2); } else { @@ -595,8 +602,8 @@ void func_800C5B58(Gfx **dlist, s32 *arg1, s32 *arg2, s32 arg3) { render_fill_rectangle(dlist, temp->unk8 - 2, temp->unk6 + 2, temp->unk8 + 2, temp->unkA - 2); render_fill_rectangle(dlist, temp->unk4 - 2, temp->unkA - 2, temp->unk8 + 2, temp->unkA + 2); } - gDPPipeSync((*dlist)++) - gDPSetEnvColor((*dlist)++, temp->unk10, temp->unk11, temp->unk12, temp->unk13) + gDPPipeSync((*dlist)++); + gDPSetEnvColor((*dlist)++, temp->unk10, temp->unk11, temp->unk12, temp->unk13); for (i = 0; D_800E3710[i] >= 0; i += 5) { x0 = D_800E3710[i] + temp->unk4; y0 = (D_800E3710[i + 1]) ? D_800E3710[i + 2] + temp->unkA : D_800E3710[i + 2] + temp->unk6; @@ -604,7 +611,7 @@ void func_800C5B58(Gfx **dlist, s32 *arg1, s32 *arg2, s32 arg3) { y1 = (D_800E3710[i + 3]) ? D_800E3710[i + 4] + temp->unkA : D_800E3710[i + 4] + temp->unk6; render_fill_rectangle(dlist, x0, y0, x1, y1); } - gDPPipeSync((*dlist)++) + gDPPipeSync((*dlist)++); } if (arg1 != NULL && arg2 != NULL) { if (!D_800E36E8) { diff --git a/src/game_text.c b/src/game_text.c index 01c742cc..4a7e3476 100644 --- a/src/game_text.c +++ b/src/game_text.c @@ -81,7 +81,6 @@ void func_800C2AB4(void) { func_800C5494(6); } - void func_800C2AF4(s32 arg0) { D_800E3680 = arg0; } @@ -96,7 +95,7 @@ void func_800C2F1C(s32 arg0) { if (D_8012A7B6 != 0) { if (D_8012A7AC <= 0) { D_8012A7A8 -= arg0 * D_8012A7AA; - if ((s32) D_8012A7A8 < 0) { + if ((s32)D_8012A7A8 < 0) { D_8012A7A8 = 0; D_8012A7B6 = 0; func_800C5620(6); @@ -120,7 +119,7 @@ void func_800C2F1C(s32 arg0) { void func_800C3048(void) { D_8012A78C = -1; - D_8012A780 = (u8*)allocate_from_main_pool_safe(0x800, COLOR_TAG_GREEN); + D_8012A780 = (u8 *)allocate_from_main_pool_safe(0x800, COLOR_TAG_GREEN); D_8012A798.unk0 = D_8012A780 + 0x80; D_8012A798.unk4 = D_8012A798.unk0 + 0x3C0; D_8012A7A4 = 0; @@ -135,7 +134,7 @@ void func_800C30CC(void) { free_from_memory_pool(D_8012A780); D_800E3670 = 0; D_8012A789 = 0; - for(i = 0; i < 10; i++) { + for (i = 0; i < 10; i++) { func_8009CFB0(); }; func_800C2AB4(); diff --git a/src/gzip.c b/src/gzip.c index 710c2307..414956f6 100644 --- a/src/gzip.c +++ b/src/gzip.c @@ -22,8 +22,8 @@ s32 D_8012AAD8; /******************************/ void func_800C6170(void) { - D_800E3760 = (huft*)allocate_from_main_pool_safe(0x2800, COLOR_TAG_BLACK); - gAssetAddress = (s32*)allocate_from_main_pool_safe(0x10, COLOR_TAG_BLACK); + D_800E3760 = (huft *)allocate_from_main_pool_safe(0x2800, COLOR_TAG_BLACK); + gAssetAddress = (s32 *)allocate_from_main_pool_safe(0x10, COLOR_TAG_BLACK); } /** @@ -51,11 +51,11 @@ s32 get_asset_uncompressed_size(s32 assetIndex, s32 assetOffset) { * Returns the pointer to the decompressed data. */ u8 *gzip_inflate(u8 *compressedInput, u8 *decompressedOutput) { - gzip_inflate_input = compressedInput + 5; // The compression header is 5 bytes. + gzip_inflate_input = compressedInput + 5; // The compression header is 5 bytes. gzip_inflate_output = decompressedOutput; gzip_num_bits = 0; gzip_bit_buffer = 0; - while(gzip_inflate_block() != 0) {} // Keep calling gzip_inflate_block() until it returns 0. + while (gzip_inflate_block() != 0) {} // Keep calling gzip_inflate_block() until it returns 0. return decompressedOutput; } diff --git a/src/main.c b/src/main.c index 20e4669b..fe16ab81 100644 --- a/src/main.c +++ b/src/main.c @@ -33,21 +33,21 @@ s32 D_8011F918[1130]; void main(void) { osInitialize(); - osCreateThread(&gThread1, 1, (OSId) &func_80065D98, 0, &gThread1StackPointer, (OSPri) 0); + osCreateThread(&gThread1, 1, (OSId)&func_80065D98, 0, &gThread1StackPointer, (OSPri)0); osStartThread(&gThread1); } #ifdef NON_MATCHING void func_80065D98(s32 arg0) { func_800B6F50(); - osCreateThread(&D_8011F910, 3, (OSId) &thread3_main, 0, &D_8011F758, (OSPri) 10); + osCreateThread(&D_8011F910, 3, (OSId)&thread3_main, 0, &D_8011F758, (OSPri)10); D_8011D758[2049] = 0; D_8011D758[2048] = 0; D_8011D758[1] = 0; D_8011D758[0] = 0; osStartThread(&D_8011F910); osSetThreadPri(NULL, 0); - while(1){} + while (1) {} } #else GLOBAL_ASM("asm/non_matchings/main/func_80065D98.s") @@ -71,5 +71,3 @@ void func_80065E30(void) { #else GLOBAL_ASM("asm/non_matchings/main/func_80065E30.s") #endif - - diff --git a/src/memory.c b/src/memory.c index 2ad66e00..27a389df 100644 --- a/src/memory.c +++ b/src/memory.c @@ -30,7 +30,7 @@ const char D_800E7488[] = "Unable to record %d slots, colours overflowed table.\ MemoryPool gMemoryPools[4]; #ifndef _ALIGN16 - #define _ALIGN16(val) ((val) & 0xFFFFFFF0) + 0x10 +#define _ALIGN16(val) ((val)&0xFFFFFFF0) + 0x10 #endif s32 gNumberOfMemoryPools; @@ -53,7 +53,7 @@ extern MemoryPoolSlot gMainMemoryPool; */ void init_main_memory_pool(void) { gNumberOfMemoryPools = -1; - if(1) { + if (1) { // Create the main memory pool. new_memory_pool(&gMainMemoryPool, RAM_END - (s32)(&gMainMemoryPool), MAIN_POOL_SLOT_COUNT); } @@ -84,20 +84,20 @@ MemoryPoolSlot *new_memory_pool(MemoryPoolSlot *slots, s32 poolSize, s32 numSlot MemoryPool *pool; MemoryPoolSlot *firstSlot; unk80070BE4_8_0 *temp3; - + pool = &gMemoryPools[++gNumberOfMemoryPools]; pool->maxNumSlots = numSlots; pool->curNumSlots = 0; pool->slots = slots; pool->size = poolSize; - - for(i = 0; i < pool->maxNumSlots; i++) { + + for (i = 0; i < pool->maxNumSlots; i++) { slots[i].index = i; } - + firstSlot = pool->slots; temp3 = (unk80070BE4_8_0 *)&slots[numSlots]; - if((s32)temp3 & 0xF) { + if ((s32)temp3 & 0xF) { firstSlot->unk0 = (unk80070BE4_8_0 *)_ALIGN16((s32)temp3); } else { firstSlot->unk0 = temp3; @@ -106,9 +106,9 @@ MemoryPoolSlot *new_memory_pool(MemoryPoolSlot *slots, s32 poolSize, s32 numSlot firstSlot->flags = 0; firstSlot->prevIndex = -1; firstSlot->nextIndex = -1; - + pool->curNumSlots++; - + return pool->slots; } #else @@ -147,7 +147,7 @@ MemoryPoolSlot *allocate_from_memory_pool(s32 memoryPoolIndex, s32 size, u32 col s32 phi_a2; s32 phi_s0; s32 *sp28; - + sp28 = func_8006F510(); pool = &gMemoryPools[memoryPoolIndex]; if (pool->curNumSlots + 1 == pool->maxNumSlots) { @@ -159,7 +159,7 @@ MemoryPoolSlot *allocate_from_memory_pool(s32 memoryPoolIndex, s32 size, u32 col phi_a0 = 0; phi_a2 = 0x7FFFFFFF; // INT_MAX phi_s0 = -1; - while(phi_a0 != -1) { + while (phi_a0 != -1) { curSlot = &pool->slots[phi_a0]; if (!curSlot->flags && curSlot->size >= size && curSlot->size < phi_a2) { phi_s0 = phi_a0; @@ -182,7 +182,7 @@ GLOBAL_ASM("asm/non_matchings/memory/allocate_from_memory_pool.s") void *allocate_from_pool_containing_slots(MemoryPoolSlot *slots, s32 size) { s32 i; - for(i = gNumberOfMemoryPools; i != 0; i--) { + for (i = gNumberOfMemoryPools; i != 0; i--) { if (slots == gMemoryPools[i].slots) { return allocate_from_memory_pool(i, size, 0); } @@ -206,16 +206,16 @@ void *allocate_at_address_in_main_pool(s32 size, u8 *address, u32 colorTag) { size = _ALIGN16(size); // The size of the pool should be 16-byte aligned } slots = gMemoryPools[0].slots; - while(s0 != -1) { + while (s0 != -1) { curSlot = &slots[s0]; if (curSlot->flags == 0) { - if ((address >= (u8*)curSlot->unk0) && (((u8*)curSlot->unk0 + curSlot->size) >= (address + size))) { - if (address == (u8*)curSlot->unk0) { + if ((address >= (u8 *)curSlot->unk0) && (((u8 *)curSlot->unk0 + curSlot->size) >= (address + size))) { + if (address == (u8 *)curSlot->unk0) { allocate_memory_pool_slot(0, s0, size, 1, 0, colorTag); func_8006F53C(sp38); return curSlot->unk0; } else { - s0 = allocate_memory_pool_slot(0, s0, address - (u8*)curSlot->unk0, 0, 1, colorTag); + s0 = allocate_memory_pool_slot(0, s0, address - (u8 *)curSlot->unk0, 0, 1, colorTag); allocate_memory_pool_slot(0, s0, size, 1, 0, colorTag); func_8006F53C(sp38); return slots[s0].unk0; @@ -267,10 +267,10 @@ void free_from_memory_pool(void *data) { void clear_free_queue(void) { s32 i; s32 *sp28; - + sp28 = func_8006F510(); - - for(i = 0; i < gFreeQueueCount;) { + + for (i = 0; i < gFreeQueueCount;) { gFreeQueue[i].unk4--; if (gFreeQueue[i].unk4 == 0) { free_slot_containing_address(gFreeQueue[i].dataAddress); @@ -281,7 +281,7 @@ void clear_free_queue(void) { i++; } } - + func_8006F53C(sp28); } @@ -294,9 +294,9 @@ void free_slot_containing_address(u8 *address) { poolIndex = get_memory_pool_index_containing_address(address); slots = gMemoryPools[poolIndex].slots; - for(slotIndex = 0; slotIndex != -1; slotIndex = slot->nextIndex) { + for (slotIndex = 0; slotIndex != -1; slotIndex = slot->nextIndex) { slot = &slots[slotIndex]; - if (address == (u8*)slot->unk0) { + if (address == (u8 *)slot->unk0) { if (slot->flags == 1 || slot->flags == 4) { free_memory_pool_slot(poolIndex, slotIndex); } @@ -314,10 +314,10 @@ void func_80071314(void) { s32 slotIndex; sp40 = func_8006F510(); - + for (poolIndex = gNumberOfMemoryPools; poolIndex != -1; poolIndex--) { pool = &gMemoryPools[poolIndex]; - for(slotIndex = 0; slotIndex != -1; slotIndex = slot->nextIndex) { + for (slotIndex = 0; slotIndex != -1; slotIndex = slot->nextIndex) { slot = &pool->slots[slotIndex]; if (slot->flags == 1) { free_memory_pool_slot(poolIndex, slotIndex); @@ -352,9 +352,9 @@ s32 func_80071478(u8 *address) { sp18 = func_8006F510(); pool = &gMemoryPools[get_memory_pool_index_containing_address(address)]; slotIndex = 0; - while(slotIndex != -1) { + while (slotIndex != -1) { slot = slotIndex + pool->slots; // `slot = &pool->slots[slotIndex];` does not match. - if (address == (u8*)slot->unk0) { + if (address == (u8 *)slot->unk0) { if (slot->flags == 1 || slot->flags == 4) { slot->flags |= 2; func_8006F53C(sp18); @@ -376,9 +376,9 @@ s32 func_80071538(u8 *address) { sp18 = func_8006F510(); pool = &gMemoryPools[get_memory_pool_index_containing_address(address)]; slotIndex = 0; - while(slotIndex != -1) { + while (slotIndex != -1) { slot = slotIndex + pool->slots; // `slot = &pool->slots[slotIndex];` does not match. - if (address == (u8*)slot->unk0) { + if (address == (u8 *)slot->unk0) { if (slot->flags & 2) { slot->flags ^= 2; func_8006F53C(sp18); @@ -398,12 +398,12 @@ s32 get_memory_pool_index_containing_address(u8 *address) { s32 i; MemoryPool *pool; - for(i = gNumberOfMemoryPools; i > 0; i--) { + for (i = gNumberOfMemoryPools; i > 0; i--) { pool = &gMemoryPools[i]; - if ((u8*)pool->slots >= address) { + if ((u8 *)pool->slots >= address) { continue; } - if(address < pool->size + (u8*)pool->slots) { + if (address < pool->size + (u8 *)pool->slots) { break; } } @@ -428,9 +428,9 @@ void free_memory_pool_slot(s32 poolIndex, s32 slotIndex) { nextSlot = &slots[nextIndex]; prevSlot = &slots[prevIndex]; slot->flags = 0; - + if (nextIndex != -1) { - if(nextSlot->flags == 0) { + if (nextSlot->flags == 0) { slot->size += nextSlot->size; tempNextIndex = nextSlot->nextIndex; slot->nextIndex = tempNextIndex; @@ -442,7 +442,7 @@ void free_memory_pool_slot(s32 poolIndex, s32 slotIndex) { } } if (prevIndex != -1) { - if(prevSlot->flags == 0) { + if (prevSlot->flags == 0) { prevSlot->size += slot->size; tempNextIndex = slot->nextIndex; prevSlot->nextIndex = tempNextIndex; @@ -482,7 +482,7 @@ s32 allocate_memory_pool_slot(s32 memoryPoolIndex, s32 slotIndex, s32 size, s32 newIndex = pool->slots[pool->curNumSlots].index; pool->curNumSlots++; newSlot = &pool->slots[newIndex]; - newSlot->unk0 = ((u8*)slot->unk0) + size; + newSlot->unk0 = ((u8 *)slot->unk0) + size; newSlot->size = slotSize - size; newSlot->flags = newSlotIsTaken; futureIndex = slot->nextIndex; @@ -500,14 +500,13 @@ s32 allocate_memory_pool_slot(s32 memoryPoolIndex, s32 slotIndex, s32 size, s32 GLOBAL_ASM("asm/non_matchings/memory/allocate_memory_pool_slot.s") #endif - /** * Returns the passed in address aligned to the next 16-byte boundary. */ u8 *align16(u8 *address) { s32 remainder = (s32)address & 0xF; if (remainder > 0) { - address = (u8*)(((s32)address - remainder) + 16); + address = (u8 *)(((s32)address - remainder) + 16); } return address; } @@ -519,7 +518,7 @@ u8 *align16(u8 *address) { u8 *align8(u8 *address) { s32 remainder = (s32)address & 0x7; if (remainder > 0) { - address = (u8*)(((s32)address - remainder) + 8); + address = (u8 *)(((s32)address - remainder) + 8); } return address; } @@ -531,7 +530,7 @@ u8 *align8(u8 *address) { u8 *align4(u8 *address) { s32 remainder = (s32)address & 0x3; if (remainder > 0) { - address = (u8*)(((s32)address - remainder) + 4); + address = (u8 *)(((s32)address - remainder) + 4); } return address; } @@ -542,7 +541,7 @@ GLOBAL_ASM("asm/non_matchings/memory/func_800718A4.s") s32 get_memory_color_tag_count(s32 arg0) { s32 i, count; count = 0; - for(i = 0; i < 80; i++) { // Issue with this loop + for (i = 0; i < 80; i++) { // Issue with this loop if ((gMemoryPools[0].slots[i].flags) && (arg0 == gMemoryPools[0].slots[i].colorTag)) { count++; } @@ -588,18 +587,17 @@ void render_memory_color_tags(void) { } #ifdef NON_MATCHING -// Unused. Does nothing? +// Unused. Does nothing? void func_80071C74(void) { s32 i, flags; MemoryPool *pool; MemoryPoolSlot *slot; - - for(i = 0; i <= gNumberOfMemoryPools; i++) { + + for (i = 0; i <= gNumberOfMemoryPools; i++) { pool = &gMemoryPools[i]; slot = &pool->slots[0]; - while(slot->nextIndex != -1) { - if(slot->flags) { // I don't know how to get this to appear. - + while (slot->nextIndex != -1) { + if (slot->flags) { // I don't know how to get this to appear. } slot = &pool->slots[slot->nextIndex]; } @@ -609,10 +607,10 @@ void func_80071C74(void) { GLOBAL_ASM("asm/non_matchings/memory/func_80071C74.s") #endif -// Unused. Does nothing? +// Unused. Does nothing? void func_80071CE8(void) { s32 i; - for(i = gNumberOfMemoryPools; i != -1; i--) { + for (i = gNumberOfMemoryPools; i != -1; i--) { // Nothing here. There might've been a printf or something similar. } } diff --git a/src/menu.c b/src/menu.c index f4f5b9b1..66c16a29 100644 --- a/src/menu.c +++ b/src/menu.c @@ -30,7 +30,7 @@ /************ .bss ************/ -// The bss section needs to stay above the data section! +// The bss section needs to stay above the data section! // Otherwise the bss variables will get reordered, which is bad. unk800DFC10 *D_80126390; @@ -52,7 +52,7 @@ s32 D_801263C8; unk801263CC (*D_801263CC)[8]; s32 D_801263D0; -s8 gActivePlayersArray[4]; +s8 gActivePlayersArray[4]; s32 D_801263D8; s8 D_801263DC[4]; s32 D_801263E0; @@ -125,7 +125,7 @@ s8 D_80126540; s8 D_80126541; s32 D_80126544; s32 gMultiplayerSelectedNumberOfRacersCopy; // Saved version gMultiplayerSelectedNumberOfRacers? -u32 *D_80126550[67]; // lookup table? +u32 *D_80126550[67]; // lookup table? s32 D_8012665C; s32 D_80126660; s32 D_80126664; @@ -144,7 +144,7 @@ s32 D_80126818; s32 D_8012681C; s32 D_80126820; s32 D_80126824; -s8 D_80126828; +s8 D_80126828; s32 D_8012682C; s16 D_80126830; s32 D_80126834; @@ -177,7 +177,7 @@ s32 D_80126928; s32 D_8012692C; s32 D_80126930[36]; s8 gPlayerSelectVehicle[4]; // Unknown number of entries. -u8 D_801269C4[4]; +u8 D_801269C4[4]; s32 D_801269C8; s32 D_801269CC; s32 gAudioOutputStrings[3]; @@ -204,7 +204,7 @@ s32 D_80126A34; s32 D_80126A38; s32 D_80126A3C; s32 D_80126A40[8]; -s8 D_80126A60[2]; +s8 D_80126A60[2]; s32 D_80126A64; s32 D_80126A68; s32 D_80126A6C; @@ -239,7 +239,7 @@ s32 D_80126BE4; s32 D_80126BE8; f32 D_80126BEC; s32 D_80126BF0[8]; -s32 D_80126C10; +s32 D_80126C10; s32 D_80126C14; s32 D_80126C18; char **D_80126C1C; @@ -262,7 +262,7 @@ s8 D_80126C54; s8 D_80126C55; s8 D_80126C56; s8 D_80126C57; -u8 D_80126C58[20]; +u8 D_80126C58[20]; s32 *D_80126C6C; s32 D_80126C70; s32 D_80126C74; @@ -275,7 +275,7 @@ s32 D_80126CC0; /************ .data ************/ -s8 D_800DF450 = 0; +s8 D_800DF450 = 0; f32 D_800DF454 = 1.0f; s32 D_800DF458 = 1; s32 gTitleScreenCurrentOption = 0; // 0 = "Start", 1 = "Options" @@ -284,8 +284,8 @@ s32 D_800DF464 = 4; // Currently unknown, might be a different type. s32 D_800DF468 = 0; s32 D_800DF46C = 0; s32 gCurrentMenuId = 0; // Currently unknown, might be a different type. -s32 D_800DF474 = 0; // Currently unknown, might be a different type. -s32 D_800DF478 = 0; // Currently unknown, might be a different type. +s32 D_800DF474 = 0; // Currently unknown, might be a different type. +s32 D_800DF478 = 0; // Currently unknown, might be a different type. s32 gMenuDelay = 0; s32 gNumberOfReadyPlayers = 0; s32 D_800DF484 = 0; // Currently unknown, might be a different type. @@ -325,8 +325,7 @@ s8 D_800DF4EC = 0; // Unused? s32 D_800DF4F0[] = { - 0x4000, 0x8000, 0x1000, 0x2000, - 0x8000, 0x10, 0x400, 0x00 + 0x4000, 0x8000, 0x1000, 0x2000, 0x8000, 0x10, 0x400, 0x00 }; unk800DF510 D_800DF510[18] = { @@ -372,16 +371,14 @@ s32 D_800DF798 = 0; s32 D_800DF79C = 0; s32 D_800DF7A0 = 0; -char *gTitleMenuStrings[3] = {0, 0, 0}; +char *gTitleMenuStrings[3] = { 0, 0, 0 }; // Version text shown on the title screen? See 1:15 in https://www.youtube.com/watch?v=OHSCLcA74ao. char gVersionDisplayText[20] = "VERSION XXXXXXXX"; // "Diddy Kong Racing" logo texture indices? s16 D_800DF7C4[12] = { - 0x50, 0x51, 0x52, 0x53, - 0x54, 0x55, 0x56, 0x57, - 0x58, 0x59, 0x5A, -1 + 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, -1 }; DrawTexture D_800DF7DC[12] = { @@ -416,9 +413,7 @@ unk800DF83C D_800DF83C[10] = { s32 D_800DF9F4 = 0; u16 D_800DF9F8[12] = { - 0xFFFF, 0x00FF, 0xCC00, 0xFF00, - 0xFF99, 0x00FF, 0xFFFF, 0x6600, - 0x00FF, 0xFF33, 0x0000, 0x0F78 + 0xFFFF, 0x00FF, 0xCC00, 0xFF00, 0xFF99, 0x00FF, 0xFFFF, 0x6600, 0x00FF, 0xFF33, 0x0000, 0x0F78 }; char *gOptionMenuStrings[7] = { @@ -437,26 +432,24 @@ unk800DFA3C gAudioMenuStrings[8] = { { 161, 35, 0, 0, 0, 0xFF, 0x80, 2, 0, 12, NULL }, { 160, 32, 0xFF, 0x80, 0xFF, 0, 0xFF, 2, 0, 12, NULL }, { 160, 188, 0xFF, 0xFF, 0xFF, 0, 0xFF, 0, 0, 12, NULL }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL } + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL }, }; s32 D_800DFABC = 0; // Currently unknown, might be a different type. -s32 gSfxVolumeSliderValue = 256; // Value from 0 to 256 +s32 gSfxVolumeSliderValue = 256; // Value from 0 to 256 s32 gMusicVolumeSliderValue = 256; // Value from 0 to 256 s32 D_800DFAC8 = 0; // Unsure about typing here. u16 D_800DFACC[8] = { - 0x4040, 0xFFFF, 0xFF40, 0x40FF, - 0xFFD0, 0x40FF, 0x40FF, 0x40FF + 0x4040, 0xFFFF, 0xFF40, 0x40FF, 0xFFD0, 0x40FF, 0x40FF, 0x40FF }; s32 D_800DFADC = 0; // Currently unknown, might be a different type. s32 D_800DFAE0 = 0; // Currently unknown, might be a different type. - // Unsure about typing with these arrays. s32 D_800DFAE4[6] = { 0, 0, 0, 0, 0, 0 }; s32 D_800DFAFC[6] = { 0, 0, 0, 0, 0, 0 }; @@ -472,12 +465,10 @@ s32 D_800DFBDC = 0; // Unused? s32 *D_800DFBE0[10] = { - D_800DFAE4, D_800DFAFC, D_800DFB14, D_800DFB2C, - D_800DFB40, D_800DFB5C, D_800DFB8C, D_800DFBA4, - D_800DFB74, D_800DFBBC + D_800DFAE4, D_800DFAFC, D_800DFB14, D_800DFB2C, D_800DFB40, D_800DFB5C, D_800DFB8C, D_800DFBA4, D_800DFB74, D_800DFBBC }; -s32 D_800DFC08 = 0; // Currently unknown, might be a different type. +s32 D_800DFC08 = 0; // Currently unknown, might be a different type. s32 D_800DFC0C = 0xFFFF; // Currently unknown, might be a different type. unk800DFC10 D_800DFC10 = { NULL, 0, 0, NULL, 0 }; @@ -560,50 +551,50 @@ s16 D_800DFDCC[2] = { -1, 0 }; // Not sure what this is s32 D_800DFDD0[28] = { - 0xFFFF04FF, 0xFFFFFFFF, 0x010203FF, 0x0000FFFF, - 0x05FF00FF, 0xFFFF0203, 0xFFFF0009, 0xFFFF06FF, - 0x0100FFFF, 0x03FFFFFF, 0x0001FFFF, 0x07FF0201, - 0x00FFFFFF, 0xFFFF0005, 0x00FFFFFF, 0xFFFFFFFF, - 0x050607FF, 0x000301FF, 0xFFFF04FF, 0xFFFF0607, - 0xFFFF0002, 0x02FFFFFF, 0x0504FFFF, 0x07FFFFFF, - 0x000703FF, 0xFFFF0605, 0x04FFFFFF, 0xFFFF0004 + 0xFFFF04FF, 0xFFFFFFFF, 0x010203FF, 0x0000FFFF, + 0x05FF00FF, 0xFFFF0203, 0xFFFF0009, 0xFFFF06FF, + 0x0100FFFF, 0x03FFFFFF, 0x0001FFFF, 0x07FF0201, + 0x00FFFFFF, 0xFFFF0005, 0x00FFFFFF, 0xFFFFFFFF, + 0x050607FF, 0x000301FF, 0xFFFF04FF, 0xFFFF0607, + 0xFFFF0002, 0x02FFFFFF, 0x0504FFFF, 0x07FFFFFF, + 0x000703FF, 0xFFFF0605, 0x04FFFFFF, 0xFFFF0004, }; // Not sure what this is s32 D_800DFE40[32] = { - 0xFFFF04FF, 0xFFFFFFFF, 0x01080203, 0x0000FFFF, - 0x040500FF, 0xFFFF0802, 0x03FF0009, 0xFFFF0607, - 0x080100FF, 0x03FFFFFF, 0x0001FFFF, 0x07FF0208, - 0x0100FFFF, 0xFFFF0005, 0x0001FFFF, 0xFFFFFFFF, - 0x050607FF, 0x00030108, 0xFFFF04FF, 0xFFFF0607, - 0xFFFF0002, 0x0802FFFF, 0x0504FFFF, 0x07FFFFFF, - 0x00070203, 0xFFFF0605, 0x04FFFFFF, 0xFFFF0004, - 0xFFFF0506, 0x0100FFFF, 0x0203FFFF, 0x00060000 + 0xFFFF04FF, 0xFFFFFFFF, 0x01080203, 0x0000FFFF, + 0x040500FF, 0xFFFF0802, 0x03FF0009, 0xFFFF0607, + 0x080100FF, 0x03FFFFFF, 0x0001FFFF, 0x07FF0208, + 0x0100FFFF, 0xFFFF0005, 0x0001FFFF, 0xFFFFFFFF, + 0x050607FF, 0x00030108, 0xFFFF04FF, 0xFFFF0607, + 0xFFFF0002, 0x0802FFFF, 0x0504FFFF, 0x07FFFFFF, + 0x00070203, 0xFFFF0605, 0x04FFFFFF, 0xFFFF0004, + 0xFFFF0506, 0x0100FFFF, 0x0203FFFF, 0x00060000, }; // Not sure what this is s32 D_800DFEC0[32] = { - 0xFFFF04FF, 0xFFFFFFFF, 0x010203FF, 0x0000FFFF, - 0x050800FF, 0xFFFF0203, 0xFFFF0009, 0xFFFF0806, - 0x0100FFFF, 0x03FFFFFF, 0x0001FFFF, 0x06070201, - 0x00FFFFFF, 0xFFFF0005, 0x00FFFFFF, 0xFFFFFFFF, - 0x05080607, 0x00030001, 0xFFFF04FF, 0xFFFF0806, - 0x07FF0002, 0x0203FFFF, 0x080504FF, 0x07FFFFFF, - 0x000703FF, 0xFFFF0608, 0x0504FFFF, 0xFFFF0004, - 0x0102FFFF, 0x0504FFFF, 0x0607FFFF, 0x00080000 + 0xFFFF04FF, 0xFFFFFFFF, 0x010203FF, 0x0000FFFF, + 0x050800FF, 0xFFFF0203, 0xFFFF0009, 0xFFFF0806, + 0x0100FFFF, 0x03FFFFFF, 0x0001FFFF, 0x06070201, + 0x00FFFFFF, 0xFFFF0005, 0x00FFFFFF, 0xFFFFFFFF, + 0x05080607, 0x00030001, 0xFFFF04FF, 0xFFFF0806, + 0x07FF0002, 0x0203FFFF, 0x080504FF, 0x07FFFFFF, + 0x000703FF, 0xFFFF0608, 0x0504FFFF, 0xFFFF0004, + 0x0102FFFF, 0x0504FFFF, 0x0607FFFF, 0x00080000, }; // Not sure what this is s32 D_800DFF40[36] = { - 0xFFFF04FF, 0xFFFFFFFF, 0x01080203, 0x0000FFFF, - 0x05FF00FF, 0xFFFF0802, 0x03FF0009, 0xFFFF06FF, - 0x080100FF, 0x03FFFFFF, 0x0001FFFF, 0x07FF0208, - 0x0100FFFF, 0xFFFF0005, 0x00FFFFFF, 0xFFFFFFFF, - 0x05090607, 0x000301FF, 0xFFFF04FF, 0xFFFF0906, + 0xFFFF04FF, 0xFFFFFFFF, 0x01080203, 0x0000FFFF, + 0x05FF00FF, 0xFFFF0802, 0x03FF0009, 0xFFFF06FF, + 0x080100FF, 0x03FFFFFF, 0x0001FFFF, 0x07FF0208, + 0x0100FFFF, 0xFFFF0005, 0x00FFFFFF, 0xFFFFFFFF, + 0x05090607, 0x000301FF, 0xFFFF04FF, 0xFFFF0906, 0x07FF0002, 0x02FFFFFF, 0x090504FF, 0x07FFFFFF, - 0x000703FF, 0xFFFF0609, 0x0504FFFF, 0xFFFF0004, - 0xFFFF09FF, 0x0100FFFF, 0x0203FFFF, 0x000608FF, - 0x05FF0504, 0xFFFF0607, 0xFFFF0008, 0x00000000 + 0x000703FF, 0xFFFF0609, 0x0504FFFF, 0xFFFF0004, + 0xFFFF09FF, 0x0100FFFF, 0x0203FFFF, 0x000608FF, + 0x05FF0504, 0xFFFF0607, 0xFFFF0008, 0x00000000, }; s32 D_800DFFD0 = 0; @@ -623,7 +614,7 @@ MenuElement gCautionMenuTextElements[14] = { { 160, 186, 160, 180, 160, 186, 255, 255, 255, 0, 255, 0, 12, 0, NULL, 0, 0, 0, 0 }, { 160, 200, 160, 194, 160, 200, 255, 255, 255, 0, 255, 0, 12, 0, NULL, 0, 0, 0, 0 }, { 160, 200, 160, 208, 160, 200, 255, 255, 255, 0, 255, 0, 12, 0, NULL, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, 0, 0, 0, 0 } + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, 0, 0, 0, 0 }, }; MenuElement gGameSelectTextElemsNoAdv2[7] = { @@ -633,7 +624,7 @@ MenuElement gGameSelectTextElemsNoAdv2[7] = { { 160, 104, 160, 104, 160, 104, 255, 255, 255, 0, 255, 2, 12, 0, NULL, 0, 0, 0, 0 }, { -96, -9, -96, -9, -96, -9, 176, 224, 192, 255, 255, 0, 0, 7, NULL, 192, 44, 4, 4 }, { 160, 152, 160, 152, 160, 152, 255, 255, 255, 0, 255, 2, 12, 0, NULL, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, 0, 0, 0, 0 } + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, 0, 0, 0, 0 }, }; MenuElement gGameSelectTextElemsWithAdv2[9] = { @@ -645,7 +636,7 @@ MenuElement gGameSelectTextElemsWithAdv2[9] = { { 160, 136, 160, 136, 160, 136, 255, 255, 255, 0, 255, 2, 12, 0, NULL, 0, 0, 0, 0 }, { -112, -41, -112, -41, -112, -41, 176, 224, 192, 255, 255, 0, 0, 7, NULL, 224, 44, 4, 4 }, { 160, 184, 160, 184, 160, 184, 255, 255, 255, 0, 255, 2, 12, 0, NULL, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, 0, 0, 0, 0 } + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, 0, 0, 0, 0 }, }; s16 D_800E0398[6] = { @@ -656,28 +647,30 @@ s16 D_800E03A4[6] = { 0x00, 0x0B, 0x0C, 0x0A, -1, 0 }; -char *gFilenames[3] = { +char *gFilenames[3] = { NULL, NULL, NULL }; // Unused? u16 D_800E03BC[8] = { - 0x004C, 0x0070, 0x00F4, 0x0070, - 0x004C, 0x00D0, 0x00F4, 0x00D0, + 0x004C, + 0x0070, + 0x00F4, + 0x0070, + 0x004C, + 0x00D0, + 0x00F4, + 0x00D0, }; unk800E03CC D_800E03CC[3] = { - { 0x0018, 0x0051, 0x0058, 0x0040, 0x0004, 0x0004, 0x4080, 0xFFC0 }, - { 0x0074, 0x0051, 0x0058, 0x0040, 0x0004, 0x0004, 0x4080, 0xFFC0 }, + { 0x0018, 0x0051, 0x0058, 0x0040, 0x0004, 0x0004, 0x4080, 0xFFC0 }, + { 0x0074, 0x0051, 0x0058, 0x0040, 0x0004, 0x0004, 0x4080, 0xFFC0 }, { 0x00D0, 0x0051, 0x0058, 0x0040, 0x0004, 0x0004, 0x4080, 0xFFC0 }, }; s16 D_800E03FC[10] = { - 0x002C, 0x0036, - 0x0015, 0x0019, - 0x002C, 0x001B, - 0x003F, 0x0019, - 0x002D, 0x0019 + 0x002C, 0x0036, 0x0015, 0x0019, 0x002C, 0x001B, 0x003F, 0x0019, 0x002D, 0x0019 }; // Either 0 (2 racers), 1 (4 racers), or 2 (6 racers) @@ -686,21 +679,21 @@ s32 gMultiplayerSelectedNumberOfRacers = 0; s32 D_800E0414 = 0; s32 D_800E0418 = 0; -unk800DFC10 D_800E041C = { NULL, -12, -8, 0, 0 }; -unk800DFC10 D_800E042C = { NULL, -8, -12, 0, 0 }; -unk800DFC10 D_800E043C = { NULL, -12, -8, 0, 0 }; -unk800DFC10 D_800E044C = { NULL, -8, -12, 0, 0 }; +unk800DFC10 D_800E041C = { NULL, -12, -8, 0, 0 }; +unk800DFC10 D_800E042C = { NULL, -8, -12, 0, 0 }; +unk800DFC10 D_800E043C = { NULL, -12, -8, 0, 0 }; +unk800DFC10 D_800E044C = { NULL, -8, -12, 0, 0 }; unk800DFC10 D_800E045C = { NULL, 0, 0, NULL, 0x20 }; -s32 D_800E046C[2] = {0, 0}; // Not sure what these are. +s32 D_800E046C[2] = { 0, 0 }; // Not sure what these are. unk800DFC10 D_800E0474 = { NULL, 0, 0, NULL, 0x20 }; -s32 D_800E0484[2] = {0, 0}; // Not sure what these are. +s32 D_800E0484[2] = { 0, 0 }; // Not sure what these are. unk800DFC10 D_800E048C = { NULL, 0, 0, NULL, 0x20 }; -s32 D_800E049C[2] = {0, 0}; // Not sure what these are. +s32 D_800E049C[2] = { 0, 0 }; // Not sure what these are. unk800DFC10 D_800E04A4 = { NULL, 0, 0, NULL, 0x20 }; -s32 D_800E04B4[2] = {0, 0}; // Not sure what these are. +s32 D_800E04B4[2] = { 0, 0 }; // Not sure what these are. unk800DFC10 D_800E04BC = { NULL, 0, 0, NULL, 0x20 }; -s32 D_800E04CC[2] = {0, 0}; // Not sure what these are. +s32 D_800E04CC[2] = { 0, 0 }; // Not sure what these are. unk800DFC10 D_800E04D4 = { NULL, 0, 0, NULL, 0 }; unk800DFC10 D_800E04E4 = { NULL, 0, 0, NULL, 0 }; unk800DFC10 D_800E04F4 = { NULL, 0, 0, NULL, 0 }; @@ -725,59 +718,49 @@ s32 D_800E05F4[8] = { 0, 0xFFD0, 0, 0xFFF0, 0, 0x10, 0, 0 }; unk800DFC10 D_800E0614 = { NULL, -16, -16, 0, 0 }; unk800DFC10 *D_800E0624[9] = { - &D_800E045C, &D_800E04D4, &D_800E04E4, - &D_800E0474, &D_800E04F4, &D_800E0504, - &D_800E048C, &D_800E0514, &D_800E0524 + &D_800E045C, &D_800E04D4, &D_800E04E4, &D_800E0474, &D_800E04F4, &D_800E0504, &D_800E048C, &D_800E0514, &D_800E0524 }; unk800DFC10 *D_800E0648[6] = { - &D_800E04BC, &D_800E0544, &D_800E0564, - &D_800E04A4, &D_800E0534, &D_800E0554 + &D_800E04BC, &D_800E0544, &D_800E0564, &D_800E04A4, &D_800E0534, &D_800E0554 }; unk800DFC10 *D_800E0660[6] = { - &D_800E0574, &D_800E0584, &D_800E0594, - &D_800E05A4, &D_800E05B4, &D_800E05C4 + &D_800E0574, &D_800E0584, &D_800E0594, &D_800E05A4, &D_800E05B4, &D_800E05C4 }; unk800DFC10 *D_800E0678[4] = { &D_800E041C, &D_800E042C, &D_800E043C, &D_800E044C }; -u16 D_800E0688[20] = { +u16 D_800E0688[20] = { 0x44, 0x72, 0x44, 0x72, 0xCC, 0x72, 0x21, 0x72, 0x88, 0x72, 0xEF, 0x72, 0x21, 0x72, 0x66, 0x72, - 0xAA, 0x72, 0xEF, 0x72 + 0xAA, 0x72, 0xEF, 0x72, }; u16 D_800E06B0[10] = { - 0x68, 0x21, 0xFB, 0x27, - 0x8E, 0xF5, 0x27, 0x6C, - 0xB0, 0xF5 + 0x68, 0x21, 0xFB, 0x27, 0x8E, 0xF5, 0x27, 0x6C, 0xB0, 0xF5 }; s16 D_800E06C4[8] = { 0x0000, 0xFFC2, 0x0055, 0x0000, - 0x0000, 0x003E, 0xFFAB, 0x0000 + 0x0000, 0x003E, 0xFFAB, 0x0000, }; s16 D_800E06D4[8] = { 0x0000, 0xFFB6, 0x0055, 0x0000, - 0x0000, 0x004A, 0xFFAB, 0x0000 + 0x0000, 0x004A, 0xFFAB, 0x0000, }; s16 D_800E06E4[14] = { - 0x50, 0x8C, 0xA0, 0x40, - 0x04, 0x04, 0x50, 0x14, - 0x3A, 0x28, 0x50, 0x28, - 0x66, 0x28 + 0x50, 0x8C, 0xA0, 0x40, 0x04, 0x04, 0x50, 0x14, 0x3A, 0x28, 0x50, 0x28, 0x66, 0x28 }; s16 D_800E0700[8] = { - 0x50, 0x98, 0xA0, 0x28, - 0x04, 0x04, 0x50, 0x0E + 0x50, 0x98, 0xA0, 0x28, 0x04, 0x04, 0x50, 0x0E }; s16 D_800E0710[16] = { @@ -885,7 +868,7 @@ s32 D_800E096C = 0; s32 D_800E0970 = 0; s32 D_800E0974 = 0; const f32 D_800E7D04[1] = { 0.5f }; // .rodata -f32 *D_800E0978 = D_800E7D04; // .data +f32 *D_800E0978 = D_800E7D04; // .data s32 D_800E097C = 0; s32 D_800E0980 = 0; s32 D_800E0984 = 0; @@ -893,13 +876,11 @@ s32 D_800E0988 = 0; s32 D_800E098C = 0; s16 D_800E0990[8] = { - 0x4040, 0xFFA0, 0xFF40, 0x40A0, - 0xD0C0, 0x20B0, 0x20C0, 0x40B0 + 0x4040, 0xFFA0, 0xFF40, 0x40A0, 0xD0C0, 0x20B0, 0x20C0, 0x40B0 }; s16 D_800E09A0[8] = { - 0x00FF, 0x0080, 0x00FF, 0x0060, - 0x0000, 0xFF60, 0x0000, 0xFF80 + 0x00FF, 0x0080, 0x00FF, 0x0060, 0x0000, 0xFF60, 0x0000, 0xFF80 }; char *D_800E09B0[5] = { 0, 0, 0, 0, 0 }; @@ -912,15 +893,11 @@ s16 D_800E0A10 = 0; char *D_800E0A14[4] = { 0, 0, 0, 0 }; s16 D_800E0A24[14] = { - 0x0005, 0x003B, 0x0032, 0x0033, - 0x0034, 0x0035, 0x0036, 0x0039, - 0x0037, 0x0038, 0x003A, 0x0000, - 0x0001, 0xFFFF + 0x0005, 0x003B, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0039, 0x0037, 0x0038, 0x003A, 0x0000, 0x0001, 0xFFFF }; s16 D_800E0A40[8] = { - 0x0004, 0x0000, 0x0001, 0xFFFF, - 0x0300, 0x0000, 0x0012, 0xFFFF + 0x0004, 0x0000, 0x0001, 0xFFFF, 0x0300, 0x0000, 0x0012, 0xFFFF }; unk800DFC10 D_800E0A50 = { NULL, 0, 0, NULL, 0 }; @@ -935,8 +912,8 @@ unk800DFC10 D_800E0AD0 = { NULL, 0, 0, NULL, 0 }; unk800DFC10 D_800E0AE0 = { NULL, 0, 0, NULL, 0 }; unk800DFC10 *D_800E0AF0[10] = { - &D_800E0A50, &D_800E0A60, &D_800E0A70, &D_800E0A80, - &D_800E0A90, &D_800E0AA0, &D_800E0AB0, &D_800E0AC0, + &D_800E0A50, &D_800E0A60, &D_800E0A70, &D_800E0A80, + &D_800E0A90, &D_800E0AA0, &D_800E0AB0, &D_800E0AC0, &D_800E0AD0, &D_800E0AE0 }; @@ -1032,10 +1009,10 @@ s32 D_800E0FAC = 0; s32 D_800E0FB0 = 0; s16 D_800E0FB4[18] = { - 0x0004, 0x0000, 0x0001, 0x0018, - 0x0019, 0x001A, 0x001B, 0x001C, - 0x001D, 0x001E, 0x001F, 0x0020, - 0x0021, 0x0022, 0x0023, 0x0030, + 0x0004, 0x0000, 0x0001, 0x0018, + 0x0019, 0x001A, 0x001B, 0x001C, + 0x001D, 0x001E, 0x001F, 0x0020, + 0x0021, 0x0022, 0x0023, 0x0030, 0x005E, -1 }; @@ -1059,8 +1036,7 @@ s32 gTrophyRacePointsArray[8] = { }; s16 D_800E1024[14] = { - 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, - 0x39, 0x3A, 0x3B, 0x00, 0x01, -1, 0x00 + 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 0x00, 0x01, -1, 0x00 }; s32 D_800E1040 = 1; @@ -1147,74 +1123,73 @@ s16 *D_800E14BC[32] = { }; unk800E153C D_800E153C[] = { - { NULL, 0x00000000 }, + { NULL, 0x00000000 }, { NULL, 0x00400000 }, - { NULL, 0x00800000 }, + { NULL, 0x00800000 }, { NULL, 0x00C00000 }, { NULL, 0x01000000 }, - { NULL, 0x00000020 }, - { NULL, 0x00400020 }, - { NULL, 0x00800020 }, - { NULL, 0x00C00020 }, - { NULL, 0x01000020 }, + { NULL, 0x00000020 }, + { NULL, 0x00400020 }, + { NULL, 0x00800020 }, + { NULL, 0x00C00020 }, + { NULL, 0x01000020 }, { NULL, 0x00000000 }, }; unk800E153C D_800E1594[] = { - { NULL, 0x00000000 }, + { NULL, 0x00000000 }, { NULL, 0x00400000 }, - { NULL, 0x00800000 }, + { NULL, 0x00800000 }, { NULL, 0x00C00000 }, { NULL, 0x01000000 }, - { NULL, 0x00000020 }, - { NULL, 0x00400020 }, - { NULL, 0x00800020 }, - { NULL, 0x00C00020 }, - { NULL, 0x01000020 }, + { NULL, 0x00000020 }, + { NULL, 0x00400020 }, + { NULL, 0x00800020 }, + { NULL, 0x00C00020 }, + { NULL, 0x01000020 }, { NULL, 0x00000000 }, }; unk800E153C D_800E15EC[] = { - { NULL, 0x00000000 }, + { NULL, 0x00000000 }, { NULL, 0x00400000 }, - { NULL, 0x00800000 }, + { NULL, 0x00800000 }, { NULL, 0x00C00000 }, { NULL, 0x01000000 }, - { NULL, 0x00000020 }, - { NULL, 0x00400020 }, - { NULL, 0x00800020 }, - { NULL, 0x00C00020 }, - { NULL, 0x01000020 }, + { NULL, 0x00000020 }, + { NULL, 0x00400020 }, + { NULL, 0x00800020 }, + { NULL, 0x00C00020 }, + { NULL, 0x01000020 }, { NULL, 0x00000000 }, }; unk800E153C D_800E1644[] = { - { NULL, 0x00000000 }, + { NULL, 0x00000000 }, { NULL, 0x00400000 }, - { NULL, 0x00800000 }, + { NULL, 0x00800000 }, { NULL, 0x00C00000 }, { NULL, 0x01000000 }, - { NULL, 0x00000020 }, - { NULL, 0x00400020 }, - { NULL, 0x00800020 }, - { NULL, 0x00C00020 }, - { NULL, 0x01000020 }, + { NULL, 0x00000020 }, + { NULL, 0x00400020 }, + { NULL, 0x00800020 }, + { NULL, 0x00C00020 }, + { NULL, 0x01000020 }, { NULL, 0x00000000 }, }; unk800E153C D_800E169C[] = { - { NULL, 0x00000000 }, + { NULL, 0x00000000 }, { NULL, 0x00400000 }, - { NULL, 0x00800000 }, + { NULL, 0x00800000 }, { NULL, 0x00C00000 }, { NULL, 0x01000000 }, - { NULL, 0x00000020 }, - { NULL, 0x00400020 }, - { NULL, 0x00800020 }, - { NULL, 0x00C00020 }, - { NULL, 0x01000020 }, + { NULL, 0x00000020 }, + { NULL, 0x00400020 }, + { NULL, 0x00800020 }, + { NULL, 0x00C00020 }, + { NULL, 0x01000020 }, { NULL, 0x00000000 }, }; unk800E153C *D_800E16F4[5] = { - D_800E153C, D_800E1594, D_800E15EC, D_800E1644, - D_800E169C + D_800E153C, D_800E1594, D_800E15EC, D_800E1644, D_800E169C }; s16 D_800E1708[34] = { @@ -1230,13 +1205,11 @@ s16 D_800E174C[4] = { }; s16 D_800E1754[10] = { - 0x78, 0x12, 0x08, 0x06, 0xC0, 0x06, 0xD4, 0x1A, - 0x78, 0x22 + 0x78, 0x12, 0x08, 0x06, 0xC0, 0x06, 0xD4, 0x1A, 0x78, 0x22 }; s16 D_800E1768[12] = { - 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, - 0x3A, 0x3B, -1, 0 + 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, -1, 0 }; Gfx D_800E1780[11] = { @@ -1248,18 +1221,16 @@ Gfx D_800E1780[11] = { gsDPSetTexturePersp(G_TP_NONE), gsDPSetTextureFilter(G_TF_BILERP), gsDPSetTextureConvert(G_TC_FILT), - gsDPSetAlphaCompare(G_AC_NONE), + gsDPSetAlphaCompare(G_AC_NONE), gsDPSetRenderMode(G_RM_CLD_SURF, G_RM_CLD_SURF2), gsSPEndDisplayList(), }; s16 D_800E17D8[12] = { - 0x0032, 0x0033, 0x0034, 0x0035, - 0x0036, 0x0037, 0x0038, 0x0039, - 0x003A, 0x003B, -1, 0 + 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, 0x0038, 0x0039, 0x003A, 0x003B, -1, 0 }; -s16 D_800E17F0[2] = { +s16 D_800E17F0[2] = { -1, 0 }; @@ -1342,33 +1313,33 @@ char *gCreditsLastMessageArray[5] = { // Cheats that are shown in the credits. s32 gCheatsInCreditsArray[21] = { - CHEAT_BIG_CHARACTERS, - CHEAT_SMALL_CHARACTERS, - CHEAT_MUSIC_MENU, - CHEAT_START_WITH_10_BANANAS, - CHEAT_HORN_CHEAT, - CHEAT_DISPLAY_CREDITS, - CHEAT_DISABLE_WEAPONS, - CHEAT_DISABLE_BANANAS, - CHEAT_BANANAS_REDUCE_SPEED, - CHEAT_NO_LIMIT_TO_BANANAS, - CHEAT_ALL_BALLOONS_ARE_RED, - CHEAT_ALL_BALLOONS_ARE_GREEN, - CHEAT_ALL_BALLOONS_ARE_BLUE, - CHEAT_ALL_BALLOONS_ARE_YELLOW, - CHEAT_ALL_BALLOONS_ARE_RAINBOW, - CHEAT_MAXIMUM_POWER_UP, - CHEAT_TURN_OFF_ZIPPERS, - CHEAT_SELECT_SAME_PLAYER, - CHEAT_FOUR_WHEEL_DRIVER, - CHEAT_TWO_PLAYER_ADVENTURE, + CHEAT_BIG_CHARACTERS, + CHEAT_SMALL_CHARACTERS, + CHEAT_MUSIC_MENU, + CHEAT_START_WITH_10_BANANAS, + CHEAT_HORN_CHEAT, + CHEAT_DISPLAY_CREDITS, + CHEAT_DISABLE_WEAPONS, + CHEAT_DISABLE_BANANAS, + CHEAT_BANANAS_REDUCE_SPEED, + CHEAT_NO_LIMIT_TO_BANANAS, + CHEAT_ALL_BALLOONS_ARE_RED, + CHEAT_ALL_BALLOONS_ARE_GREEN, + CHEAT_ALL_BALLOONS_ARE_BLUE, + CHEAT_ALL_BALLOONS_ARE_YELLOW, + CHEAT_ALL_BALLOONS_ARE_RAINBOW, + CHEAT_MAXIMUM_POWER_UP, + CHEAT_TURN_OFF_ZIPPERS, + CHEAT_SELECT_SAME_PLAYER, + CHEAT_FOUR_WHEEL_DRIVER, + CHEAT_TWO_PLAYER_ADVENTURE, CHEAT_ULTIMATE_AI }; #define NUMBER_CHEATS_IN_CREDITS sizeof(gCheatsInCreditsArray) / sizeof(s32) s32 gViewingCreditsFromCheat = 0; // Set to 1 if viewing credits from "WHODIDTHIS" cheat -MenuElement D_800E1B50[9] = { +MenuElement D_800E1B50[9] = { { 480, 104, 160, 104, -160, 104, 255, 0, 255, 48, 255, 0, 4, 0, NULL, 0, 0, 0, 0 }, { 480, 132, 160, 132, -160, 132, 255, 255, 255, 0, 255, 2, 4, 0, NULL, 0, 0, 0, 0 }, { 480, 104, 160, 104, -160, 104, 255, 255, 255, 0, 255, 2, 4, 0, NULL, 0, 0, 0, 0 }, @@ -1377,7 +1348,7 @@ MenuElement D_800E1B50[9] = { { 480, 132, 160, 132, -160, 132, 255, 255, 255, 0, 255, 2, 4, 0, NULL, 0, 0, 0, 0 }, { 480, 104, 160, 104, -160, 104, 255, 255, 255, 0, 255, 2, 4, 0, NULL, 0, 0, 0, 0 }, { 480, 132, 160, 132, -160, 132, 255, 255, 255, 0, 255, 2, 4, 0, NULL, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, 0, 0, 0, 0 } + { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, 0, 0, 0, 0 }, }; Gfx D_800E1C70[] = { @@ -1393,15 +1364,15 @@ Gfx D_800E1C70[] = { Gfx D_800E1CA0[][2] = { { gsDPSetCombineMode(G_CC_SHADE, G_CC_SHADE), - gsDPSetOtherMode(DKR_OMH_1CYC_POINT_NOPERSP, DKR_OML_COMMON | G_RM_XLU_SURF | G_RM_XLU_SURF2), + gsDPSetOtherMode(DKR_OMH_1CYC_POINT_NOPERSP, DKR_OML_COMMON | G_RM_XLU_SURF | G_RM_XLU_SURF2), }, { gsDPSetCombineMode(G_CC_MODULATEIA, G_CC_MODULATEIA), - gsDPSetOtherMode(DKR_OMH_1CYC_BILERP, DKR_OML_COMMON | G_RM_XLU_SURF | G_RM_XLU_SURF2), + gsDPSetOtherMode(DKR_OMH_1CYC_BILERP, DKR_OML_COMMON | G_RM_XLU_SURF | G_RM_XLU_SURF2), }, { gsDPSetCombineMode(G_CC_PRIMITIVE, G_CC_PRIMITIVE), - gsDPSetOtherMode(DKR_OMH_1CYC_POINT_NOPERSP, DKR_OML_COMMON | G_RM_XLU_SURF | G_RM_XLU_SURF2), + gsDPSetOtherMode(DKR_OMH_1CYC_POINT_NOPERSP, DKR_OML_COMMON | G_RM_XLU_SURF | G_RM_XLU_SURF2), } }; @@ -1455,8 +1426,7 @@ s32 D_800E1DC0 = 32; s32 D_800E1DC4 = 32; s16 D_800E1DC8[16] = { - 1, 1, -1, 1, -1, 1, -1, -1, - 1, -1, -1, -1, 1, 1, 1, -1 + 1, 1, -1, 1, -1, 1, -1, -1, 1, -1, -1, -1, 1, 1, 1, -1 }; FadeTransition D_800E1DE8 = FADE_TRANSITION(0, FADE_COLOR_BLACK, 120, -1); @@ -1465,8 +1435,8 @@ char gRareCopyrightString[24] = "(C) COPYRIGHT RARE 1997"; //Probably a FadeTransition, but that won't be certain //FadeTransition D_800E1E08 = FADE_TRANSITION(0, FADE_COLOR_BLACK, 52, -1); -s16 D_800E1E08[4] = { - 0, 0, 0x34, -1 +s16 D_800E1E08[4] = { + 0, 0, 0x34, -1 }; s32 *D_800E1E10 = " (ADV."; @@ -1475,20 +1445,18 @@ s32 D_800E1E14 = 0; s32 D_800E1E18 = 0; s32 D_800E1E1C = 0; -s8 D_800E1E20[8] = { - 0, -1, 1, 0, 0, 1, -1, 0 +s8 D_800E1E20[8] = { + 0, -1, 1, 0, 0, 1, -1, 0 }; s8 D_800E1E28 = 0; s16 D_800E1E2C[10] = { - 0x4C, 0x4D, 0x4E, 0x4F, 0x5B, 0x5C, 0x00, 0x42, - -1, 0 + 0x4C, 0x4D, 0x4E, 0x4F, 0x5B, 0x5C, 0x00, 0x42, -1, 0 }; s16 D_800E1E40[10] = { - 0x0D, 0x0E, 0x0F, 0x10, 0x08, 0x09, 0x00, 0x0A, - -1, 0 + 0x0D, 0x0E, 0x0F, 0x10, 0x08, 0x09, 0x00, 0x0A, -1, 0 }; /*******************************/ @@ -1517,16 +1485,16 @@ const char D_800E8250[] = "loadFrontEndItem() - Item no %d out of range 0-%d\n"; // Should be functionally equivalent void load_menu_text(s32 language) { s32 start, langIndex, i, j; - + if (gMenuTextLangTable == NULL) { gMenuTextLangTable = load_asset_section_from_rom(ASSET_MENU_TEXT_TABLE); } - - switch(language) { + + switch (language) { case JAPANESE: langIndex = 4; break; - case GERMAN: + case GERMAN: langIndex = 3; break; case FRENCH: @@ -1536,7 +1504,7 @@ void load_menu_text(s32 language) { langIndex = 1; break; } - + start = gMenuTextLangTable[langIndex]; if (gMenuText != NULL) { load_asset_to_address(ASSET_MENU_TEXT, gMenuText, start, gMenuTextLangTable[langIndex + 1] - start); @@ -1545,22 +1513,22 @@ void load_menu_text(s32 language) { if ((s32)gMenuText[i] == -1) { gMenuText[i] = NULL; } else { - gMenuText[i] = &((u8*)gMenuText)[(s32)gMenuText[i]]; + gMenuText[i] = &((u8 *)gMenuText)[(s32)gMenuText[i]]; } } - gAudioOutputStrings[0] = gMenuText[0]; // STEREO - gAudioOutputStrings[1] = gMenuText[1]; // MONO - gAudioOutputStrings[2] = gMenuText[2]; // HEADPHONES - gAudioMenuStrings[1].unkC = gMenuText[3]; // SFX VOLUME - gAudioMenuStrings[2].unkC = gMenuText[4]; // MUSIC VOLUME - gAudioMenuStrings[3].unkC = gMenuText[5]; // RETURN - gAudioMenuStrings[4].unkC = gMenuText[6]; // AUDIO OPTIONS - gAudioMenuStrings[5].unkC = gMenuText[6]; // AUDIO OPTIONS - gMusicTestString = gMenuText[7]; // MUSIC TEST 00 - gMagicCodeMenuStrings[0] = gMenuText[14]; // ENTER CODE - gMagicCodeMenuStrings[1] = gMenuText[15]; // CLEAR ALL CODES - gMagicCodeMenuStrings[2] = gMenuText[16]; // CODE LIST - gMagicCodeMenuStrings[3] = gMenuText[5]; // RETURN + gAudioOutputStrings[0] = gMenuText[0]; // STEREO + gAudioOutputStrings[1] = gMenuText[1]; // MONO + gAudioOutputStrings[2] = gMenuText[2]; // HEADPHONES + gAudioMenuStrings[1].unkC = gMenuText[3]; // SFX VOLUME + gAudioMenuStrings[2].unkC = gMenuText[4]; // MUSIC VOLUME + gAudioMenuStrings[3].unkC = gMenuText[5]; // RETURN + gAudioMenuStrings[4].unkC = gMenuText[6]; // AUDIO OPTIONS + gAudioMenuStrings[5].unkC = gMenuText[6]; // AUDIO OPTIONS + gMusicTestString = gMenuText[7]; // MUSIC TEST 00 + gMagicCodeMenuStrings[0] = gMenuText[14]; // ENTER CODE + gMagicCodeMenuStrings[1] = gMenuText[15]; // CLEAR ALL CODES + gMagicCodeMenuStrings[2] = gMenuText[16]; // CODE LIST + gMagicCodeMenuStrings[3] = gMenuText[5]; // RETURN D_800E0BEC[1].unk14_a.asciiText = gMenuText[29]; // LAP TIMES D_800E0BEC[2].unk14_a.asciiText = gMenuText[30]; // OVERALL TIME D_800E0CEC[8].unk14_a.asciiText = gMenuText[31]; // RACE ORDER @@ -1569,74 +1537,74 @@ void load_menu_text(s32 language) { D_800E0E4C[1].unk14_a.asciiText = gMenuText[32]; // RECORD TIMES D_800E0E4C[2].unk14_a.asciiText = gMenuText[9]; // BEST TIME D_800E0E4C[5].unk14_a.asciiText = gMenuText[10]; // BEST LAP - gOptionMenuStrings[0] = gMenuText[34]; // ENGLISH + gOptionMenuStrings[0] = gMenuText[34]; // ENGLISH if (D_80126448 & 0x2000000) { gOptionMenuStrings[1] = gMenuText[182]; // SUBTITLES ON } else { gOptionMenuStrings[1] = gMenuText[183]; // SUBTITLES OFF } - gOptionMenuStrings[2] = gMenuText[6]; // AUDIO OPTIONS - gOptionMenuStrings[3] = gMenuText[165]; // SAVE OPTIONS - gOptionMenuStrings[4] = gMenuText[17]; // MAGIC CODES - gOptionMenuStrings[5] = gMenuText[5]; // RETURN - gFilenames[0] = gMenuText[72]; // GAME A - gFilenames[1] = gMenuText[73]; // GAME B - gFilenames[2] = gMenuText[74]; // GAME C - D_800DFAE4[0] = gMenuText[90]; // CONTROLLER PAK ~ - D_800DFAE4[1] = gMenuText[91]; // IS NOT PRESENT. - D_800DFAE4[3] = gMenuText[85]; // CANCEL - D_800DFAFC[0] = gMenuText[90]; // CONTROLLER PAK ~ - D_800DFAFC[1] = gMenuText[93]; // CONTAINS CORRUPT DATA. - D_800DFAFC[3] = gMenuText[94]; // ATTEMPT TO REPAIR - D_800DFAFC[4] = gMenuText[85]; // CANCEL - D_800DFB14[0] = gMenuText[90]; // CONTROLLER PAK ~ - D_800DFB14[1] = gMenuText[95]; // IRREPARABLY DAMAGED. - D_800DFB14[3] = gMenuText[96]; // REFORMAT PAK - D_800DFB14[4] = gMenuText[85]; // CANCEL - D_800DFB2C[0] = gMenuText[90]; // CONTROLLER PAK ~ - D_800DFB2C[1] = gMenuText[97]; // FULL. - D_800DFB2C[3] = gMenuText[98]; // CONTINUE - D_800DFB40[0] = gMenuText[90]; // CONTROLLER PAK ~ - D_800DFB40[1] = gMenuText[99]; // DIFFERENT CONTROLLER - D_800DFB40[2] = gMenuText[100]; // PAK IS INSERTED. - D_800DFB40[4] = gMenuText[85]; // CANCEL - D_800DFB5C[0] = gMenuText[90]; // CONTROLLER PAK ~ - D_800DFB5C[1] = gMenuText[102]; // CANNOT STORE ANY - D_800DFB5C[2] = gMenuText[103]; // MORE GHOSTS. - D_800DFB5C[4] = gMenuText[98]; // CONTINUE - D_800DFB74[0] = gMenuText[90]; // CONTROLLER PAK ~ - D_800DFB74[1] = gMenuText[184]; // CORRUPT DATA. - D_800DFB74[3] = gMenuText[23]; // TRY AGAIN - D_800DFB74[4] = gMenuText[85]; // CANCEL - D_800DFB8C[0] = gMenuText[153]; // Rumble Pak Detected - D_800DFB8C[1] = gMenuText[154]; // Insert any Controller Paks - D_800DFB8C[2] = gMenuText[155]; // you wish to use now! - D_800DFB8C[4] = gMenuText[98]; // CONTINUE - D_800DFBA4[0] = gMenuText[156]; // If you wish to use any - D_800DFBA4[1] = gMenuText[157]; // Rumble Paks then please - D_800DFBA4[2] = gMenuText[158]; // insert them now. - D_800DFBA4[4] = gMenuText[98]; // CONTINUE - D_800DFBBC[0] = gMenuText[104]; // SORRY, BUT YOU - D_800DFBBC[1] = gMenuText[105]; // CAN'T LOAD GAMES - D_800DFBBC[2] = gMenuText[106]; // FOR THE SECOND - D_800DFBBC[3] = gMenuText[107]; // ADVENTURE UNTIL - D_800DFBBC[4] = gMenuText[108]; // YOU HAVE COMPLETED - D_800DFBBC[5] = gMenuText[109]; // THE FIRST. - D_800DFBBC[7] = gMenuText[98]; // CONTINUE - gTitleMenuStrings[0] = gMenuText[137]; // START - gTitleMenuStrings[1] = gMenuText[36]; // OPTIONS - gGameSelectTextElemsNoAdv2[0].unk14_a.asciiText = gMenuText[76]; // GAME SELECT - gGameSelectTextElemsNoAdv2[1].unk14_a.asciiText = gMenuText[76]; // GAME SELECT - gGameSelectTextElemsNoAdv2[3].unk14_a.asciiText = gMenuText[142]; // ADVENTURE - gGameSelectTextElemsNoAdv2[5].unk14_a.asciiText = gMenuText[144]; // TRACKS + gOptionMenuStrings[2] = gMenuText[6]; // AUDIO OPTIONS + gOptionMenuStrings[3] = gMenuText[165]; // SAVE OPTIONS + gOptionMenuStrings[4] = gMenuText[17]; // MAGIC CODES + gOptionMenuStrings[5] = gMenuText[5]; // RETURN + gFilenames[0] = gMenuText[72]; // GAME A + gFilenames[1] = gMenuText[73]; // GAME B + gFilenames[2] = gMenuText[74]; // GAME C + D_800DFAE4[0] = gMenuText[90]; // CONTROLLER PAK ~ + D_800DFAE4[1] = gMenuText[91]; // IS NOT PRESENT. + D_800DFAE4[3] = gMenuText[85]; // CANCEL + D_800DFAFC[0] = gMenuText[90]; // CONTROLLER PAK ~ + D_800DFAFC[1] = gMenuText[93]; // CONTAINS CORRUPT DATA. + D_800DFAFC[3] = gMenuText[94]; // ATTEMPT TO REPAIR + D_800DFAFC[4] = gMenuText[85]; // CANCEL + D_800DFB14[0] = gMenuText[90]; // CONTROLLER PAK ~ + D_800DFB14[1] = gMenuText[95]; // IRREPARABLY DAMAGED. + D_800DFB14[3] = gMenuText[96]; // REFORMAT PAK + D_800DFB14[4] = gMenuText[85]; // CANCEL + D_800DFB2C[0] = gMenuText[90]; // CONTROLLER PAK ~ + D_800DFB2C[1] = gMenuText[97]; // FULL. + D_800DFB2C[3] = gMenuText[98]; // CONTINUE + D_800DFB40[0] = gMenuText[90]; // CONTROLLER PAK ~ + D_800DFB40[1] = gMenuText[99]; // DIFFERENT CONTROLLER + D_800DFB40[2] = gMenuText[100]; // PAK IS INSERTED. + D_800DFB40[4] = gMenuText[85]; // CANCEL + D_800DFB5C[0] = gMenuText[90]; // CONTROLLER PAK ~ + D_800DFB5C[1] = gMenuText[102]; // CANNOT STORE ANY + D_800DFB5C[2] = gMenuText[103]; // MORE GHOSTS. + D_800DFB5C[4] = gMenuText[98]; // CONTINUE + D_800DFB74[0] = gMenuText[90]; // CONTROLLER PAK ~ + D_800DFB74[1] = gMenuText[184]; // CORRUPT DATA. + D_800DFB74[3] = gMenuText[23]; // TRY AGAIN + D_800DFB74[4] = gMenuText[85]; // CANCEL + D_800DFB8C[0] = gMenuText[153]; // Rumble Pak Detected + D_800DFB8C[1] = gMenuText[154]; // Insert any Controller Paks + D_800DFB8C[2] = gMenuText[155]; // you wish to use now! + D_800DFB8C[4] = gMenuText[98]; // CONTINUE + D_800DFBA4[0] = gMenuText[156]; // If you wish to use any + D_800DFBA4[1] = gMenuText[157]; // Rumble Paks then please + D_800DFBA4[2] = gMenuText[158]; // insert them now. + D_800DFBA4[4] = gMenuText[98]; // CONTINUE + D_800DFBBC[0] = gMenuText[104]; // SORRY, BUT YOU + D_800DFBBC[1] = gMenuText[105]; // CAN'T LOAD GAMES + D_800DFBBC[2] = gMenuText[106]; // FOR THE SECOND + D_800DFBBC[3] = gMenuText[107]; // ADVENTURE UNTIL + D_800DFBBC[4] = gMenuText[108]; // YOU HAVE COMPLETED + D_800DFBBC[5] = gMenuText[109]; // THE FIRST. + D_800DFBBC[7] = gMenuText[98]; // CONTINUE + gTitleMenuStrings[0] = gMenuText[137]; // START + gTitleMenuStrings[1] = gMenuText[36]; // OPTIONS + gGameSelectTextElemsNoAdv2[0].unk14_a.asciiText = gMenuText[76]; // GAME SELECT + gGameSelectTextElemsNoAdv2[1].unk14_a.asciiText = gMenuText[76]; // GAME SELECT + gGameSelectTextElemsNoAdv2[3].unk14_a.asciiText = gMenuText[142]; // ADVENTURE + gGameSelectTextElemsNoAdv2[5].unk14_a.asciiText = gMenuText[144]; // TRACKS gGameSelectTextElemsWithAdv2[0].unk14_a.asciiText = gMenuText[76]; // GAME SELECT gGameSelectTextElemsWithAdv2[1].unk14_a.asciiText = gMenuText[76]; // GAME SELECT gGameSelectTextElemsWithAdv2[3].unk14_a.asciiText = gMenuText[142]; // ADVENTURE gGameSelectTextElemsWithAdv2[5].unk14_a.asciiText = gMenuText[143]; // ADVENTURE TWO gGameSelectTextElemsWithAdv2[7].unk14_a.asciiText = gMenuText[144]; // TRACKS - D_800E09B0[0] = gMenuText[69]; // BAD CONTROLLER PAK - D_800E09C4[0] = gMenuText[68]; // CONTROLLER PAK FULL - D_800E09D8[0] = gMenuText[67]; // NO CONTROLLER PAK + D_800E09B0[0] = gMenuText[69]; // BAD CONTROLLER PAK + D_800E09C4[0] = gMenuText[68]; // CONTROLLER PAK FULL + D_800E09D8[0] = gMenuText[67]; // NO CONTROLLER PAK D_800E09EC[4] = 0; D_800E09EC[5] = 0; D_800E09EC[0] = gMenuText[184]; // CORRUPT DATA. @@ -1650,18 +1618,18 @@ void load_menu_text(s32 language) { while (D_800E09EC[j] != 0) { j++; } - D_800E09EC[j] = gMenuText[185]; // TRY AGAIN! - D_800E0A04[0] = gMenuText[159]; // If you wish to use - D_800E0A04[1] = gMenuText[160]; // the Controller Pak - D_800E0A04[2] = gMenuText[162]; // insert it now! - D_800E0A14[0] = gMenuText[159]; // If you wish to use - D_800E0A14[1] = gMenuText[161]; // the Rumble Pak - D_800E0A14[2] = gMenuText[162]; // insert it now! + D_800E09EC[j] = gMenuText[185]; // TRY AGAIN! + D_800E0A04[0] = gMenuText[159]; // If you wish to use + D_800E0A04[1] = gMenuText[160]; // the Controller Pak + D_800E0A04[2] = gMenuText[162]; // insert it now! + D_800E0A14[0] = gMenuText[159]; // If you wish to use + D_800E0A14[1] = gMenuText[161]; // the Rumble Pak + D_800E0A14[2] = gMenuText[162]; // insert it now! gCautionMenuTextElements[0].unk14_a.asciiText = gMenuText[152]; // CAUTION gCautionMenuTextElements[1].unk14_a.asciiText = gMenuText[152]; // CAUTION - for(i = 2; i < 13; i++) { + for (i = 2; i < 13; i++) { // Caution message lines starting from gMenuText[166] - gCautionMenuTextElements[i].unk14_a.asciiText = gMenuText[166 + (i - 2)]; + gCautionMenuTextElements[i].unk14_a.asciiText = gMenuText[166 + (i - 2)]; } } } @@ -1688,7 +1656,7 @@ GLOBAL_ASM("asm/non_matchings/menu/func_80080BC8.s") void func_80080E6C(void) { D_800E1DB8 = 0; - D_800E1DB4 = (s32) (1 - D_800E1DB4); + D_800E1DB4 = (s32)(1 - D_800E1DB4); } GLOBAL_ASM("asm/non_matchings/menu/func_80080E90.s") @@ -1701,28 +1669,28 @@ void func_80081218(void) { s32 i; s32 sp28; s32 sp20; - + get_number_of_levels_and_worlds(&numLevels, &numWorlds); sp20 = ((numLevels * 4) + (numWorlds * 2) + 0x11B) & ~3; sp28 = numLevels * 4; D_80126530[0] = allocate_from_main_pool_safe(sp20 * 4, COLOR_TAG_WHITE); D_80126530[0] = D_80126530[0]; - D_80126530[0]->courseFlagsPtr = (u8*)D_80126530[0] + sizeof(Settings); - D_80126530[0]->balloonsPtr = (u8*)D_80126530[0]->courseFlagsPtr + sp28; - D_80126530[1] = (u8*)D_80126530[0] + sp20; - D_80126530[1]->courseFlagsPtr = (u8*)D_80126530[1] + sizeof(Settings); - D_80126530[1]->balloonsPtr = (u8*)D_80126530[1]->courseFlagsPtr + sp28; - D_80126530[2] = (u8*)D_80126530[1] + sp20; - D_80126530[2]->courseFlagsPtr = (u8*)D_80126530[2] + sizeof(Settings); - D_80126530[2]->balloonsPtr = (u8*)D_80126530[2]->courseFlagsPtr + sp28; - D_80126530[3] = (u8*)D_80126530[2] + sp20; - D_80126530[3]->courseFlagsPtr = (u8*)D_80126530[3] + sizeof(Settings); - D_80126530[3]->balloonsPtr = (u8*)D_80126530[3]->courseFlagsPtr + sp28; + D_80126530[0]->courseFlagsPtr = (u8 *)D_80126530[0] + sizeof(Settings); + D_80126530[0]->balloonsPtr = (u8 *)D_80126530[0]->courseFlagsPtr + sp28; + D_80126530[1] = (u8 *)D_80126530[0] + sp20; + D_80126530[1]->courseFlagsPtr = (u8 *)D_80126530[1] + sizeof(Settings); + D_80126530[1]->balloonsPtr = (u8 *)D_80126530[1]->courseFlagsPtr + sp28; + D_80126530[2] = (u8 *)D_80126530[1] + sp20; + D_80126530[2]->courseFlagsPtr = (u8 *)D_80126530[2] + sizeof(Settings); + D_80126530[2]->balloonsPtr = (u8 *)D_80126530[2]->courseFlagsPtr + sp28; + D_80126530[3] = (u8 *)D_80126530[2] + sp20; + D_80126530[3]->courseFlagsPtr = (u8 *)D_80126530[3] + sizeof(Settings); + D_80126530[3]->balloonsPtr = (u8 *)D_80126530[3]->courseFlagsPtr + sp28; gCheatsAssetData = get_misc_asset(0x41); gNumberOfCheats = (s32)(*gCheatsAssetData); - gMenuText = allocate_from_main_pool_safe(1024 * sizeof(char*), COLOR_TAG_WHITE); + gMenuText = allocate_from_main_pool_safe(1024 * sizeof(char *), COLOR_TAG_WHITE); load_menu_text(ENGLISH); - for(i = 0; i < 128; i++) { + for (i = 0; i < 128; i++) { D_80126550[i] = NULL; } } @@ -1736,22 +1704,22 @@ void func_800813C0(void) { void menu_init(u32 menuId) { s32 i; - + gCurrentMenuId = menuId; reset_controller_sticks(); gIgnorePlayerInput = 1; D_801263BC = 0; D_801263C8 = 0; D_80126828 = 0; - + // Does not match with a for loop - i = 0; - while(i < 4) { + i = 0; + while (i < 4) { D_80126808[i++] = 0; } - + func_80001844(); - switch(gCurrentMenuId) { + switch (gCurrentMenuId) { case MENU_LOGOS: menu_logos_screen_init(); break; @@ -1983,7 +1951,6 @@ 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 @@ -1992,11 +1959,11 @@ void draw_menu_elements(s32 arg0, MenuElement *elem, f32 arg2) { s32 s5; s32 tempX, tempY; s32 xPos, yPos; - + s5 = FALSE; if (arg0 != 4) { func_80067F2C(&D_801263A0, &D_801263A8); - while(elem->unk14_a.element != NULL) { + while (elem->unk14_a.element != NULL) { if (&D_80126850 != elem->unk14_a.element) { if (arg0 == 0) { tempX = elem->center - elem->left; @@ -2030,14 +1997,13 @@ void draw_menu_elements(s32 arg0, MenuElement *elem, f32 arg2) { } D_800DF764 = elem->opacity; func_80081800( - *elem->unk14_a.numberU16, - xPos - 0xA0, - (-yPos - D_800DF7A0) + 0x78, - elem->filterRed, - elem->filterGreen, - elem->filterBlue, - elem->textFont - ); + *elem->unk14_a.numberU16, + xPos - 0xA0, + (-yPos - D_800DF7A0) + 0x78, + elem->filterRed, + elem->filterGreen, + elem->filterBlue, + elem->textFont); break; case 2: if (s5) { @@ -2045,42 +2011,39 @@ void draw_menu_elements(s32 arg0, MenuElement *elem, f32 arg2) { func_8007B3D0(&D_801263A0); } func_80081C04( - *elem->unk14_a.number, - xPos - 0xA0, - (-yPos - D_800DF7A0) + 0x78, - elem->filterRed, - elem->filterGreen, - elem->filterBlue, - elem->opacity, - elem->textFont, - elem->textAlignFlags - ); + *elem->unk14_a.number, + xPos - 0xA0, + (-yPos - D_800DF7A0) + 0x78, + elem->filterRed, + elem->filterGreen, + elem->filterBlue, + elem->opacity, + elem->textFont, + elem->textAlignFlags); break; case 3: s5 = TRUE; render_textured_rectangle( - &D_801263A0, - elem->unk14_a.texture, - xPos, - yPos + D_800DF79C, - elem->filterRed, - elem->filterGreen, - elem->filterBlue, - elem->opacity - ); + &D_801263A0, + elem->unk14_a.texture, + xPos, + yPos + D_800DF79C, + elem->filterRed, + elem->filterGreen, + elem->filterBlue, + elem->opacity); break; case 4: s5 = TRUE; func_80078D00( - &D_801263A0, - elem->unk14_a.element, - xPos, - yPos + D_800DF79C, - elem->backgroundRed / 256.0f, + &D_801263A0, + elem->unk14_a.element, + xPos, + yPos + D_800DF79C, + elem->backgroundRed / 256.0f, elem->backgroundGreen / 256.0f, - (elem->filterRed << 0x18) | (elem->filterGreen << 0x10) | (elem->filterBlue << 8) | elem->opacity, - elem->textAlignFlags - ); + (elem->filterRed << 0x18) | (elem->filterGreen << 0x10) | (elem->filterBlue << 8) | elem->opacity, + elem->textAlignFlags); break; case 5: if (s5) { @@ -2107,31 +2070,29 @@ void draw_menu_elements(s32 arg0, MenuElement *elem, f32 arg2) { break; case 6: func_80080E90( - &D_801263A0, - xPos, - yPos + D_800DF7A0, - elem->backgroundRed, - elem->backgroundGreen, - elem->backgroundBlue, - elem->backgroundAlpha, - elem->filterRed, - elem->filterGreen, - elem->filterBlue, - elem->opacity - ); + &D_801263A0, + xPos, + yPos + D_800DF7A0, + elem->backgroundRed, + elem->backgroundGreen, + elem->backgroundBlue, + elem->backgroundAlpha, + elem->filterRed, + elem->filterGreen, + elem->filterBlue, + elem->opacity); break; case 7: func_80080580( - &D_801263A0, - xPos, - yPos + D_800DF7A0, - elem->backgroundRed, - elem->backgroundGreen, - elem->backgroundBlue, - elem->backgroundAlpha, - (elem->filterRed << 0x18) | (elem->filterGreen << 0x10) | (elem->filterBlue << 8) | elem->opacity, - elem->unk14_a.element - ); + &D_801263A0, + xPos, + yPos + D_800DF7A0, + elem->backgroundRed, + elem->backgroundGreen, + elem->backgroundBlue, + elem->backgroundAlpha, + (elem->filterRed << 0x18) | (elem->filterGreen << 0x10) | (elem->filterBlue << 8) | elem->opacity, + elem->unk14_a.element); break; } } @@ -2159,19 +2120,19 @@ void func_800828B8(void) { settings = get_settings(); get_number_of_levels_and_worlds(&numLevels, &numWorlds); - - for(i = 0; i < numLevels; i++) { + + for (i = 0; i < numLevels; i++) { settings->courseFlagsPtr[i] = 0; - for(numWorlds = 0; numWorlds < 3; numWorlds++) { + for (numWorlds = 0; numWorlds < 3; numWorlds++) { settings->courseFlagsPtr[i] |= D_80126530[numWorlds]->courseFlagsPtr[i]; } } - + settings->trophies = 0; settings->keys = 0; settings->bosses = 0; settings->cutsceneFlags = 0; - for(i = 0; i < 3; i++) { + for (i = 0; i < 3; i++) { settings->trophies |= D_80126530[i]->trophies; settings->keys |= D_80126530[i]->keys; settings->bosses |= D_80126530[i]->bosses; @@ -2183,7 +2144,7 @@ void func_800829F8(s32 arg0, s32 arg1) { s32 temp; D_800DF46C += arg1; - + if (D_800DF46C & 0x10) { load_menu_text(get_language()); set_text_font(0); @@ -2213,10 +2174,10 @@ void menu_logos_screen_init(void) { } s32 menu_logo_screen_loop(s32 arg0) { - s32 phi_v0; // sp24? + s32 phi_v0; // sp24? s32 yOffset; // sp28 s32 sp20; - + if (osTvType == TV_TYPE_PAL) { yOffset = 0x1A; if (D_80126450 < 2.6f && gMenuDelay == 0) { @@ -2238,7 +2199,7 @@ s32 menu_logo_screen_loop(s32 arg0) { func_80082FAC(); menu_init(MENU_TITLE); } - if (8.5 > D_80126450) { // This is a little weird, but it matches. + if (8.5 > D_80126450) { // This is a little weird, but it matches. set_text_font(1); set_text_background_color(0, 0, 0, 0); if ((D_80126450 < 8.0) && (D_80126450 >= 7.5)) { @@ -2293,7 +2254,7 @@ void menu_title_screen_init(void) { s32 i; s32 temp; s8 *tempArr; - + D_800DF488 = 1; D_801263BC = 0; gMenuDelay = 0; @@ -2313,7 +2274,7 @@ void menu_title_screen_init(void) { D_80126870 = 0; D_801263E0 = 0; func_8009C674(D_800DF7C4); - for(i = 0; i < 11; i++) { + for (i = 0; i < 11; i++) { D_800DF7DC[i].texture = D_80126550[D_800DF7C4[i]]; } set_music_player_voice_limit(0x1B); @@ -2372,13 +2333,13 @@ void func_800841B8(s32 arg0) { draw_text(&D_801263A0, 0xA1, 0x23, gMenuText[36], 0xC); set_text_color(255, 255, 255, 0, 0xFF); draw_text(&D_801263A0, 0xA0, 0x20, gMenuText[36], 0xC); - + phi_s1 = 0; phi_s2 = 0x4C; - + set_text_font(0); - - while(gOptionMenuStrings[phi_s1] != NULL) { + + while (gOptionMenuStrings[phi_s1] != NULL) { if (phi_s1 == D_800DF460) { phi_a3 = D_801263BC * 8; if (D_801263BC >= 0x20) { @@ -2389,7 +2350,7 @@ void func_800841B8(s32 arg0) { } set_text_color(255, 255, 255, phi_a3, 0xFF); draw_text(&D_801263A0, -0x8000, phi_s2, gOptionMenuStrings[phi_s1], 0xC); - + phi_s1++; phi_s2 += 0x1C; } @@ -2401,21 +2362,21 @@ s32 menu_options_loop(s32 arg0) { s32 buttonsPressed; s32 analogX; s32 analogY; - + D_801263BC = (D_801263BC + arg0) & 0x3F; - + if (gMenuDelay != 0) { if (gMenuDelay > 0) { - gMenuDelay += arg0; + gMenuDelay += arg0; } else { gMenuDelay -= arg0; } } - + if (gMenuDelay >= -0x13 && gMenuDelay < 0x23) { func_800841B8(arg0); } - + buttonsPressed = 0; analogX = 0; analogY = 0; @@ -2423,12 +2384,12 @@ s32 menu_options_loop(s32 arg0) { // Get input from all 4 controllers. s32 i; for (i = 0; i < 4; i++) { - analogY += gControllersYAxisDirection[i]; // Y axis (-1 = down, 1 = up) for controller - analogX += gControllersXAxisDirection[i]; // X axis (-1 = left, 1 = right) for controller + analogY += gControllersYAxisDirection[i]; // Y axis (-1 = down, 1 = up) for controller + analogX += gControllersXAxisDirection[i]; // X axis (-1 = left, 1 = right) for controller buttonsPressed |= get_buttons_pressed_from_player(i); // Button presses for controller } } - + if ((buttonsPressed & B_BUTTON) || ((buttonsPressed & (A_BUTTON | START_BUTTON)) && D_800DF460 == 5)) { // Leave the option menu func_80000C98(-0x80); @@ -2480,10 +2441,10 @@ s32 menu_options_loop(s32 arg0) { func_80001D04(0xEB, 0); } } - + if (gMenuDelay >= 0x1F) { // Change screen to a sub-menu - switch(D_800DF460) { + switch (D_800DF460) { case 2: func_80084734(); menu_init(MENU_AUDIO_OPTIONS); @@ -2512,7 +2473,6 @@ s32 menu_options_loop(s32 arg0) { GLOBAL_ASM("asm/non_matchings/menu/menu_options_loop.s") #endif - void func_80084734(void) { func_800C422C(2); } @@ -2557,7 +2517,7 @@ s32 menu_audio_options_loop(s32 arg0) { s32 i; sp30 = 0; - D_801263BC = (s32) ((D_801263BC + arg0) & 0x3F); + D_801263BC = (s32)((D_801263BC + arg0) & 0x3F); if (gMenuDelay != 0) { if (gMenuDelay > 0) { gMenuDelay += arg0; @@ -2573,15 +2533,15 @@ s32 menu_audio_options_loop(s32 arg0) { contX = 0; contY = 0; phi_a2 = 0; - + // Check all 4 controllers for inputs - for(i = 0; i < 4; i++) { + for (i = 0; i < 4; i++) { buttonInputs |= get_buttons_pressed_from_player(i); phi_a2 += func_8006A59C(i); contY += gControllersYAxisDirection[i]; contX += gControllersXAxisDirection[i]; } - + if (phi_a2 < 0) { phi_a2 += 0x18; if (phi_a2 > 0) { @@ -2593,7 +2553,7 @@ s32 menu_audio_options_loop(s32 arg0) { phi_a2 = 0; } } - + if (((buttonInputs & (A_BUTTON | START_BUTTON)) && (D_801263E0 == gOptionsMenuItemIndex + 1)) || (buttonInputs & B_BUTTON)) { gMenuDelay = -1; func_800C01D8(&D_800DF774); @@ -2622,7 +2582,7 @@ s32 menu_audio_options_loop(s32 arg0) { set_stereo_pan_mode(D_800DFAC8); sp30 = 1; } else if (((phi_a2 >> 2) != 0) && ((gOptionsMenuItemIndex == 1) || (gOptionsMenuItemIndex == 2))) { - if(gOptionsMenuItemIndex == 1) { + if (gOptionsMenuItemIndex == 1) { gSfxVolumeSliderValue += (phi_a2 >> 2); if (gSfxVolumeSliderValue < 0) { gSfxVolumeSliderValue = 0; @@ -2630,7 +2590,7 @@ s32 menu_audio_options_loop(s32 arg0) { gSfxVolumeSliderValue = 0x100; } set_sfx_volume_slider(gSfxVolumeSliderValue); - } else if(gOptionsMenuItemIndex == 2) { + } else if (gOptionsMenuItemIndex == 2) { gMusicVolumeSliderValue += (phi_a2 >> 2); if (gMusicVolumeSliderValue < 0) { gMusicVolumeSliderValue = 0; @@ -2667,13 +2627,13 @@ s32 menu_audio_options_loop(s32 arg0) { D_801263D8 = D_800DFABC; } } - + if (gOptionsMenuItemIndex == 1 && D_801269FC == NULL) { func_80001D04(0x19B, &D_801269FC); } else if (D_801269FC != NULL) { func_8000488C(&D_801269FC); } - + if (sp30 == 3) { func_80001D04(0x241, NULL); } else if (sp30 == 2) { @@ -2759,7 +2719,7 @@ s32 func_800860A8(s32 arg0, s32 *arg1, unk800860A8 *arg2, s32 *arg3, s32 arg4) { (*arg3)++; } } else { - if((*arg1 < 0) && ((phi_t0 & 0xFF) == 7)) { + if ((*arg1 < 0) && ((phi_t0 & 0xFF) == 7)) { *arg1 = 0; phi_t0 = 0; } else { @@ -2770,13 +2730,13 @@ s32 func_800860A8(s32 arg0, s32 *arg1, unk800860A8 *arg2, s32 *arg3, s32 arg4) { } } } - + return phi_t0; } void func_800861C8(unk800861C8 *arg0, s32 *arg1) { s32 i; - for(i = 0; i < 3; i++) { + for (i = 0; i < 3; i++) { if (D_80126530[i]->newGame != 0) { arg0[*arg1].unk0 = 1; arg0[*arg1].unk1 = 0; @@ -2813,7 +2773,6 @@ GLOBAL_ASM("asm/non_matchings/menu/func_80086A48.s") GLOBAL_ASM("asm/non_matchings/menu/func_80086AFC.s") GLOBAL_ASM("asm/non_matchings/menu/func_800871D8.s") - s32 func_800874D0(s32 arg0, s32 arg1) { s32 sp1C; @@ -2831,10 +2790,10 @@ s32 func_800874D0(s32 arg0, s32 arg1) { D_801263E0 = 4; } else if ((arg1 < 0) && (D_80126BD4 > 0)) { func_80001D04(0xEB, NULL); - D_80126BD4 = (s32) (D_80126BD4 - 1); + D_80126BD4 = (s32)(D_80126BD4 - 1); } else if ((arg1 > 0) && (D_80126BD4 < (D_80126A08 - 1))) { func_80001D04(0xEB, NULL); - D_80126BD4 = (s32) (D_80126BD4 + 1); + D_80126BD4 = (s32)(D_80126BD4 + 1); } return sp1C; } @@ -2848,16 +2807,15 @@ s32 func_800875E4(s32 arg0, s32 arg1) { D_801263E0 = 6; } else if ((arg1 < 0) && (D_80126BE4 > 0)) { func_80001D04(0xEB, NULL); - D_80126BE4 = (s32) (D_80126BE4 - 1); + D_80126BE4 = (s32)(D_80126BE4 - 1); } else if ((arg1 > 0) && (D_80126BE4 < D_80126A00 - 1)) { func_80001D04(0xEB, NULL); - D_80126BE4 = (s32) (D_80126BE4 + 1); + D_80126BE4 = (s32)(D_80126BE4 + 1); } - + return 0; } - s32 func_800876CC(s32 arg0, s32 arg1) { if (arg0 & 0x4000) { func_80001D04(0x241, NULL); @@ -2867,11 +2825,10 @@ s32 func_800876CC(s32 arg0, s32 arg1) { D_801263E0 = 7; D_801263D8 = 0; } - + return 0; } - GLOBAL_ASM("asm/non_matchings/menu/func_80087734.s") GLOBAL_ASM("asm/non_matchings/menu/menu_save_options_loop.s") @@ -2893,12 +2850,12 @@ void menu_boot_init(void) { func_800C01D8(&D_800DF77C); func_80077B34(0, 0, 0); func_8009C674(&D_800DF7C4); - + // Sets up the 11 texture pointers for the "Diddy Kong Racing" logo. - for(i = 0; i < 11; i++) { + for (i = 0; i < 11; i++) { D_800DF7DC[i].texture = D_80126550[D_800DF7C4[i]]; } - + // Reset variables for menu_boot_loop() D_80126C20 = 0; // D_80126C20 is the current state of the boot screen. Either 0, 1, or 2. D_80126C18 = 0; // D_80126C18 is a timer for the boot screen, counts up to 0x8C frames. @@ -2908,24 +2865,24 @@ void menu_boot_init(void) { s32 menu_boot_loop(s32 arg0) { // arg0 = sp30 s32 out; // sp2C - s32 y; // sp28 + s32 y; // sp28 // ra = sp24 out = 0; - + // Regalloc issue. // How do you make this not use a3 without introducing another local variable? y = 120; if (osTvType == TV_TYPE_PAL) { y = 132; } - + // You can make it use the correct register if you add in a temp variable like: // temp = y; // Then replace all the `y` instances below with `temp`. // However, this makes the stack too big. There is no room for another local variable. :\ - switch(D_80126C20) { + switch (D_80126C20) { case 0: if (D_80126C18 < 32) { D_80126C18 += arg0; @@ -2959,12 +2916,12 @@ s32 menu_boot_loop(s32 arg0) { out = func_800890AC(arg0); break; } - + if (y < 300) { render_textured_rectangle(&D_801263A0, &D_800DF7DC, 160, y, 255, 255, 255, 255); func_8007B3D0(&D_801263A0); } - + return out; } #else @@ -2972,7 +2929,7 @@ GLOBAL_ASM("asm/non_matchings/menu/MenuBootLoop.s") #endif void func_800887C4(void) { - func_8009C4A8((s16*)D_800DF7C4); + func_8009C4A8((s16 *)D_800DF7C4); } void func_800887E8(void) { @@ -2980,16 +2937,16 @@ void func_800887E8(void) { // Starting point D_80126AA0[0] = allocate_from_main_pool_safe(0x200, COLOR_TAG_WHITE); - + // Fills in the table. - for(i = 1; i < 16; i++) { - D_80126AA0[i] = (s32*)(((u32)D_80126AA0[0]) + (i * 0x20)); + for (i = 1; i < 16; i++) { + D_80126AA0[i] = (s32 *)(((u32)D_80126AA0[0]) + (i * 0x20)); } - - for(i = 0; i < 1; i++) { + + for (i = 0; i < 1; i++) { D_80126A60[i] = 0; } - + D_80126C10 = 0; D_801263E0 = 0; D_801263BC = 0; @@ -3052,7 +3009,7 @@ void render_magic_codes_ui(s32 arg0) { s32 i, j; s32 temp, alpha, green; char c; - + set_text_background_color(0, 0, 0, 0); func_800C5B58(&D_801263A0, 0, 0, 7); set_text_font(2); @@ -3062,12 +3019,12 @@ void render_magic_codes_ui(s32 arg0) { draw_text(&D_801263A0, 0xA0, 0x20, gMenuText[17], 0xC); // gMenuText[17] = "MAGIC CODES" set_text_font(0); set_text_color(0xFF, 0xFF, 0xFF, 0, 0xFF); - + c = 'A'; yPos = 60; // Draw the input table - for(i = 0; i < 4; i++) { - for(j = 0; j < 7; j++) { + for (i = 0; i < 4; i++) { + for (j = 0; j < 7; j++) { xPos = 64 + (j * 32); if (gOptionsMenuItemIndex == 5 && j == gCheatInputCurrentColumn && i == gCheatInputCurrentRow) { temp = D_801263BC * 8; @@ -3091,20 +3048,20 @@ void render_magic_codes_ui(s32 arg0) { } yPos += 0x16; } - + temp = D_801263BC * 8; if (temp >= 0x100) { temp = 0x1FF - temp; } - + set_text_font(0); yPos = 0xA4; yIncr = 16; if (osTvType == TV_TYPE_PAL) { yIncr = 24; } - - for(i = 0; gMagicCodeMenuStrings[i] != NULL; i++) { + + for (i = 0; gMagicCodeMenuStrings[i] != NULL; i++) { alpha = 0; if (i == gOptionsMenuItemIndex && D_801263E0 == 0) { alpha = temp; @@ -3112,7 +3069,7 @@ void render_magic_codes_ui(s32 arg0) { set_text_color(0xFF, 0xFF, 0xFF, alpha, 0xFF); draw_text(&D_801263A0, -0x8000, yPos, gMagicCodeMenuStrings[i], 0xC); yPos += yIncr; - } + } set_text_font(0); set_text_color(0xFF, 0xFF, 0x80, 0x80, 0xFF); set_text_background_color(0, 0, 0x80, 0x80); @@ -3121,7 +3078,7 @@ void render_magic_codes_ui(s32 arg0) { draw_text(&D_801263A0, -0x8000, 0x90, gMenuText[18], 0xC); // gMenuText[18] = "Sorry, the code was incorrect" } else { // Draw cheat code name. - draw_text(&D_801263A0, -0x8000, 0x90, (char*)(*gCheatsAssetData) + (*gCheatsAssetData + 1)[D_80126C4C + 1], 0xC); + draw_text(&D_801263A0, -0x8000, 0x90, (char *)(*gCheatsAssetData) + (*gCheatsAssetData + 1)[D_80126C4C + 1], 0xC); } } else if (5 == gOptionsMenuItemIndex) { draw_text(&D_801263A0, -0x8000, 0x90, D_80126C58, 0xC); @@ -3138,7 +3095,7 @@ void render_magic_codes_ui(s32 arg0) { func_800C4EDC(6, 0x4C, yPos - 0x1C, 0xF4, yPos + 0x1C); func_800C4FBC(6, 0, 0, 0, 0xA0); yPos = 4; - for(i = 0; i < 3; i++) { + for (i = 0; i < 3; i++) { alpha = 0; green = 0xFF; if (i == 0) { @@ -3148,10 +3105,10 @@ void render_magic_codes_ui(s32 arg0) { alpha = temp; } func_800C5000(6, 0xFF, green, 0xFF, alpha, 0xFF); - + // gMenuText[148] = "CLEAR ALL CODES?", [149] = "OK", [150] = "CANCEL" func_800C5168(6, -0x8000, yPos, gMenuText[148 + i], 1, 4); - + if (i != 0) { yPos += 0x10; } else { @@ -3190,7 +3147,6 @@ void menu_magic_codes_list_init(void) { } } - #ifdef NON_MATCHING // Should be functionally equivalent @@ -3200,7 +3156,7 @@ void render_magic_codes_list_menu_text(s32 arg0) { s32 phi_v0; s32 s2; s32 i; - + set_text_background_color(0, 0, 0, 0); set_text_font(2); set_text_color(0, 0, 0, 0xFF, 0x80); @@ -3209,7 +3165,7 @@ void render_magic_codes_list_menu_text(s32 arg0) { draw_text(&D_801263A0, 0xA0, 0x20, gMenuText[20], 0xC); // MAGIC CODES LIST numOfUnlockedCheats = 0; phi_v0 = 1; - for(i = 0; i < 32; i++) { + for (i = 0; i < 32; i++) { if (phi_v0 & gUnlockedMagicCodes) { D_80126C80[numOfUnlockedCheats] = i; numOfUnlockedCheats += 1; @@ -3224,11 +3180,11 @@ void render_magic_codes_list_menu_text(s32 arg0) { } set_text_font(0); set_text_color(0xFF, 0xFF, 0xFF, 0, 0xFF); - for(i = D_801263E0; (i < D_801263E0 + D_80126C70) && (i < numOfUnlockedCheats); i++) { + for (i = D_801263E0; (i < D_801263E0 + D_80126C70) && (i < numOfUnlockedCheats); i++) { if (i == gOptionsMenuItemIndex) { set_text_color(0xFF, 0xFF, 0xFF, fp, 0xFF); } - draw_text(&D_801263A0, 0x30, s2, (char*)(*gCheatsAssetData) + ((*gCheatsAssetData + 1)[D_80126C80[i]*2+1]), 0); + draw_text(&D_801263A0, 0x30, s2, (char *)(*gCheatsAssetData) + ((*gCheatsAssetData + 1)[D_80126C80[i] * 2 + 1]), 0); if ((1 << D_80126C80[i]) & gActiveMagicCodes) { draw_text(&D_801263A0, 0x100, s2, gMenuText[21], 0); // ON } else { @@ -3271,7 +3227,7 @@ s32 menu_magic_codes_list_loop(s32 arg0) { s32 phi_s1; s32 numUnlockedCodes; s32 code; - + sp48 = 0; if (gMenuDelay != 0) { if (gMenuDelay > 0) { @@ -3284,33 +3240,33 @@ s32 menu_magic_codes_list_loop(s32 arg0) { if (gMenuDelay >= -0x13 && gMenuDelay < 0x14) { render_magic_codes_list_menu_text(arg0); } - + buttonsPressed = 0; xAxis = 0; yAxis = 0; if (!gIgnorePlayerInput && gMenuDelay == 0) { - for(i = 0; i < 4; i++){ + for (i = 0; i < 4; i++) { buttonsPressed |= get_buttons_pressed_from_player(i); xAxis += gControllersXAxisDirection[i]; yAxis += gControllersYAxisDirection[i]; } } - + code = 1; numUnlockedCodes = 0; - for(i = 0; i < 32; i++) { // 32 is the max number of cheats. + for (i = 0; i < 32; i++) { // 32 is the max number of cheats. if (code & gUnlockedMagicCodes) { D_80126C80[numUnlockedCodes] = i; numUnlockedCodes++; } code <<= 1; } - + if (((xAxis < 0) || (xAxis > 0)) && (numUnlockedCodes != gOptionsMenuItemIndex)) { func_80001D04(0xEF, NULL); phi_s1 = 1 << D_80126C80[gOptionsMenuItemIndex]; - gActiveMagicCodes ^= phi_s1; // Toggle active cheats? - func_8008A8F8(phi_s1, 0x10, 0x20); // func_8008A8F8() = Clear flags? + gActiveMagicCodes ^= phi_s1; // Toggle active cheats? + func_8008A8F8(phi_s1, 0x10, 0x20); // func_8008A8F8() = Clear flags? func_8008A8F8(phi_s1, 0x20, 0x10); func_8008A8F8(phi_s1, 0x1000, 0x6080); func_8008A8F8(phi_s1, 0x6080, 0x1000); @@ -3322,9 +3278,9 @@ s32 menu_magic_codes_list_loop(s32 arg0) { func_8008A8F8(phi_s1, 0x40000, 0xB8000); func_8008A8F8(phi_s1, 0x80000, 0x78000); } - + phi_a2 = gOptionsMenuItemIndex; - + if (yAxis < 0) { gOptionsMenuItemIndex++; if (numUnlockedCodes < gOptionsMenuItemIndex) { @@ -3333,21 +3289,21 @@ s32 menu_magic_codes_list_loop(s32 arg0) { } if (yAxis > 0) { gOptionsMenuItemIndex--; - if ((s32) gOptionsMenuItemIndex < 0) { + if ((s32)gOptionsMenuItemIndex < 0) { gOptionsMenuItemIndex = 0; } } - + if (gOptionsMenuItemIndex < D_801263E0) { D_801263E0 = gOptionsMenuItemIndex; } else if (gOptionsMenuItemIndex >= (D_801263E0 + D_80126C70)) { D_801263E0 = (gOptionsMenuItemIndex - D_80126C70) + 1; } - + if (gOptionsMenuItemIndex != phi_a2) { func_80001D04(0xEB, NULL); } - + if ((buttonsPressed & 0x9000) && (numUnlockedCodes == gOptionsMenuItemIndex)) { sp48 = -1; } @@ -3389,7 +3345,7 @@ void calculate_and_display_rom_checksum(void) { numBytesLeft -= 0x1000; romOffset = 0x1000; tempBuffer = allocate_from_main_pool_safe(0x5000, COLOR_TAG_BLACK); - + while (numBytesLeft > 0) { numBytes = numBytesLeft; if (numBytesLeft >= 0x5001) { @@ -3397,29 +3353,28 @@ void calculate_and_display_rom_checksum(void) { } dmacopy(romOffset, tempBuffer, numBytes); numBytesLeft -= numBytes; - - for(i = 0; i < numBytes; i++) { + + for (i = 0; i < numBytes; i++) { D_800E1E14 += tempBuffer[i]; } - + romOffset += numBytes; } - + free_from_memory_pool(tempBuffer); D_800E1E18 = TRUE; } - + set_render_printf_background_color(0, 0, 0, 0x80); set_render_printf_position(0x20, 0x88); render_printf(D_800E8218, D_800E1E14, &__ROM_END); // D_800E8218 = "ROM checksum %08X,%d\n" - } #else GLOBAL_ASM("asm/non_matchings/menu/calculate_and_display_rom_checksum.s") #endif void func_8008AEB4(s32 arg0, s32 *arg1) { - switch(arg0) { + switch (arg0) { default: D_800DFFD0 = 0; return; @@ -3440,14 +3395,14 @@ void func_8008AEB4(s32 arg0, s32 *arg1) { */ void set_active_player_index(s32 controllerIndex) { s32 i; - + gNumberOfActivePlayers = 1; - + for (i = 0; i < 8; i++) { gPlayersCharacterArray[i] = (i == controllerIndex) ? 1 : -1; } - - for(i = 0; i < 4; i++) { + + for (i = 0; i < 4; i++) { gActivePlayersArray[i] = (i == controllerIndex) ? 1 : 0; } } @@ -3456,7 +3411,7 @@ void menu_character_select_init(void) { s32 breakTheLoop; s32 i; u8 *temp; - + breakTheLoop = FALSE; func_8006A434(); if (is_drumstick_unlocked()) { @@ -3477,7 +3432,7 @@ void menu_character_select_init(void) { gMenuDelay = 0; D_801263BC = 0; D_800DF484 = 0; - for(i = 0; (i < 4) && (!breakTheLoop); i++) { + for (i = 0; (i < 4) && (!breakTheLoop); i++) { if (gActivePlayersArray[i] != 0) { breakTheLoop = TRUE; D_801263C0.unk0 = (*D_801263CC)[gPlayersCharacterArray[i]].unkC; @@ -3492,7 +3447,7 @@ void menu_character_select_init(void) { D_801263B8.unk2 = 0; D_801263B8.unk1 = 0; play_music(0x1A); - for(i = 0; i < 10; i++) { + for (i = 0; i < 10; i++) { temp = D_800DFDB4[i]; if (i != D_801263C0.unk0) { func_80001114(temp[0]); @@ -3517,10 +3472,10 @@ void draw_character_select_text(s32 arg0) { set_text_background_color(0, 0, 0, 0); set_text_color(0, 0, 0, 0xFF, 0x80); // Draw "Player Select" text drop shadow - draw_text(&D_801263A0, 0xA1, 0x23, gMenuText[135], 0xC); + draw_text(&D_801263A0, 0xA1, 0x23, gMenuText[135], 0xC); set_text_color(255, 255, 255, 0, 0xFF); // Draw "Player Select" text - draw_text(&D_801263A0, 0xA0, 0x20, gMenuText[135], 0xC); + draw_text(&D_801263A0, 0xA0, 0x20, gMenuText[135], 0xC); if (gNumberOfReadyPlayers == gNumberOfActivePlayers && gNumberOfActivePlayers > 0) { yPos = 0xD0; if (osTvType == TV_TYPE_PAL) { @@ -3544,7 +3499,7 @@ void randomize_ai_racer_slots(s32 arg0) { s32 i, j; s32 numCharacters; s32 s1; - + numCharacters = 7; if (is_drumstick_unlocked()) { numCharacters = 8; @@ -3552,11 +3507,11 @@ void randomize_ai_racer_slots(s32 arg0) { if (is_tt_unlocked()) { numCharacters++; } - - if(arg0 < 8) { + + if (arg0 < 8) { s1 = FALSE; - for(i = 0; (i < arg0) && (!s1); i++) { - if(gCharacterIdSlots[i] == 9) { + for (i = 0; (i < arg0) && (!s1); i++) { + if (gCharacterIdSlots[i] == 9) { s1 = TRUE; } } @@ -3566,15 +3521,15 @@ void randomize_ai_racer_slots(s32 arg0) { } } i = arg0; - while(i < 8) { + while (i < 8) { s1 = FALSE; // Check for duplicate racer id. gCharacterIdSlots[i] = (*D_801263CC)[get_random_number_from_range(0, numCharacters)].unkC; - for(j = 0; j < i; j++){ + for (j = 0; j < i; j++) { if (gCharacterIdSlots[i] == gCharacterIdSlots[j]) { s1 = TRUE; // Duplicate found! } } - if(s1) { + if (s1) { continue; // Redo if duplicate was found. } i++; @@ -3599,8 +3554,8 @@ s32 menu_character_select_loop(s32 arg0) { draw_character_select_text(arg0); func_8008C168(arg0); func_8008E4EC(); - - for(i = 0; i < 4; i++){ + + for (i = 0; i < 4; i++) { if (1 == D_801263DC[i]) { D_801263DC[i] = 2; } @@ -3629,10 +3584,10 @@ s32 menu_character_select_loop(s32 arg0) { } } func_8008C128(); - + // Regalloc issue: gActivePlayersArray and phi_a0 need to switch registers. phi_a0 = 0; - for(i = 0; i < 4; i++) { + for (i = 0; i < 4; i++) { if (gActivePlayersArray[i]) { gCharacterIdSlots[phi_a0] = (*D_801263CC)[gPlayersCharacterArray[i]].unkC; phi_a0++; @@ -3640,7 +3595,7 @@ s32 menu_character_select_loop(s32 arg0) { } randomize_ai_racer_slots(phi_a0); func_8006A458(gActivePlayersArray); - + gIsInTracksMode = 1; if (phi_t3 >= gNumberOfActivePlayers) { func_80000B18(); @@ -3683,7 +3638,7 @@ void func_8008BFE8(s32 arg0, s8 *arg1, s32 arg2, u16 arg3, u16 arg4) { // Run this block if the DOUBLEVISION cheat isn't active. if (!(get_filtered_cheats() & CHEAT_SELECT_SAME_PLAYER)) { i = 0; - while(i < 4 && !someBool){ + while (i < 4 && !someBool) { if (i != arg0 && gPlayersCharacterArray[i] == arg1[j]) { someBool = 1; } @@ -3703,7 +3658,7 @@ void func_8008BFE8(s32 arg0, s8 *arg1, s32 arg2, u16 arg3, u16 arg4) { } void func_8008C128(void) { - func_8009C4A8((s16*)&D_800DFDC8); + func_8009C4A8((s16 *)&D_800DFDC8); set_free_queue_state(0); func_800C422C(2); set_free_queue_state(2); @@ -3762,14 +3717,14 @@ void menu_game_select_init(void) { func_8007FFEC(3); func_800C4170(2); play_music(0x1A); - - for(i = 0; i < 10; i++) { + + for (i = 0; i < 10; i++) { if (i != D_801263B4.unk0) { func_80001114(D_800DFDB4[i][0]); func_80001114(D_800DFDB4[i][1]); } } - + func_80001114(6); func_80000B18(); if (is_adventure_two_unlocked()) { @@ -3779,11 +3734,11 @@ void menu_game_select_init(void) { D_80126460 = gGameSelectTextElemsNoAdv2; D_801263E0 = 1; } - + // This loop doesn't match. - for(i = 0; i <= D_801263E0; i++) { + for (i = 0; i <= D_801263E0; i++) { u8 temp = i; // How do I make this a `mov`? - (&((unk80126460*)D_80126460)[temp] + 1)->elem[0].unk14_a.texture = D_80126550[67]; + (&((unk80126460 *)D_80126460)[temp] + 1)->elem[0].unk14_a.texture = D_80126550[67]; } } #else @@ -3804,17 +3759,17 @@ void func_8008C698(s32 arg0) { fade = 0x1FF - fade; } func_80067F2C(&D_801263A0, &D_801263A8); - - for(i = 0; i <= D_801263E0; i++) { + + for (i = 0; i <= D_801263E0; i++) { filterAlpha = 0; if (i == D_800DF460) { filterAlpha = fade; } // This doesn't match. temp = i; // How do I make this a `mov`? - (&((unk80126460*)D_80126460)[temp] + 1)->elem[1].filterAlpha = filterAlpha; + (&((unk80126460 *)D_80126460)[temp] + 1)->elem[1].filterAlpha = filterAlpha; } - + if (osTvType == TV_TYPE_PAL) { D_800DF79C = 0xC; D_800DF7A0 = 0; @@ -3822,8 +3777,8 @@ void func_8008C698(s32 arg0) { D_800DF79C = 0; D_800DF7A0 = 0; } - - draw_menu_elements(1, (MenuElement*)D_80126460, 1.0f); + + draw_menu_elements(1, (MenuElement *)D_80126460, 1.0f); func_80080BC8(&D_801263A0); } } @@ -3838,12 +3793,12 @@ s32 menu_game_select_loop(s32 arg0) { s32 playerYDir; s32 charSelectScene; s32 temp; - + func_8008C168(); - + // Regalloc issue: This needs to use v1, not a2! D_801263BC = (D_801263BC + arg0) & 0x3F; - + if (D_801263D8 != 0) { D_801263D8++; if (D_801263D8 >= 3) { @@ -3957,7 +3912,7 @@ void menu_file_select_init(void) { func_800C01D8(&D_800DF77C); func_800C4170(2); play_music(0x1A); - for(i = 0; i < 10; i++) { + for (i = 0; i < 10; i++) { if (i != D_801263B4.unk0) { func_80001114(D_800DFDB4[i][0]); func_80001114(D_800DFDB4[i][1]); @@ -3998,13 +3953,13 @@ void render_file_select_menu(s32 arg0) { u8 tempName[8]; u32 color; s32 i; - + if (osTvType == TV_TYPE_PAL) { y = 12; } else { y = 0; } - + func_8009BD5C(); func_80067F2C(&D_801263A0, &D_801263A8); for (i = 0; i < 3; i++) { // 3 files @@ -4059,8 +4014,7 @@ void render_file_select_menu(s32 arg0) { if (D_80126484 != 0) { if (D_80126494 == 0 && i == D_8012648C) { s2 = TRUE; - } - else if (D_80126494 > 0 && i == D_80126490) { + } else if (D_80126494 > 0 && i == D_80126490) { s2 = TRUE; } } else if (D_80126488 != 0 && i == D_8012648C) { @@ -4158,9 +4112,9 @@ void func_8008DC7C(s32 arg0) { temp_a1 = gControllersXAxisDirection; if (gNumberOfActivePlayers == 2) { phi_v1 = phi_v1 | get_buttons_pressed_from_player(1); - temp_a1 += gControllersXAxisDirection+1; + temp_a1 += gControllersXAxisDirection + 1; } - + if (D_80126494 == 0) { if (phi_v1 & 0x4000) { func_80001D04(0x241, NULL); @@ -4172,7 +4126,7 @@ void func_8008DC7C(s32 arg0) { func_80001D04(0xEF, NULL); D_80126494 = 1; } - + phi_v1_2 = D_8012648C; if (temp_a1 < 0) { phi_v1_2 = D_8012648C; @@ -4181,7 +4135,7 @@ void func_8008DC7C(s32 arg0) { phi_v1_2 = D_8012648C; } } - + if (temp_a1 > 0) { temp_t6 = phi_v1_2 + 1; if (phi_v1_2 < 2) { @@ -4189,9 +4143,9 @@ void func_8008DC7C(s32 arg0) { phi_v1_2 = temp_t6; } } - + //if (D_8012648C != phi_v1_2) { - func_80001D04(0xEB, NULL); + func_80001D04(0xEB, NULL); //} } else { if (phi_v1 & 0x9000) { @@ -4204,7 +4158,7 @@ void func_8008DC7C(s32 arg0) { D_801264A0[D_8012648C].name[1] = 'K'; D_801264A0[D_8012648C].name[2] = 'R'; D_801264A0[D_8012648C].name[3] = '\0'; - gSaveFileIndex = (s32) D_8012648C; + gSaveFileIndex = (s32)D_8012648C; D_801263E0 = 0; D_80126488 = 0; } else if (phi_v1 & 0x4000) { @@ -4261,10 +4215,10 @@ s32 menu_track_select_loop(s32 arg0) { } } func_8008E4EC(); - + gSPClearGeometryMode(D_801263A0++, G_CULL_FRONT) - - switch(D_801267D0) { + + switch (D_801267D0) { case 0: func_8008FF1C(arg0); func_800904E8(arg0); @@ -4276,7 +4230,7 @@ s32 menu_track_select_loop(s32 arg0) { func_80092188(arg0); break; } - + if (D_800DF760 < 0) { set_relative_volume_for_music(0); } else { @@ -4310,7 +4264,7 @@ s32 menu_track_select_loop(s32 arg0) { func_8008F534(); if (gMultiplayerSelectedNumberOfRacersCopy != gMultiplayerSelectedNumberOfRacers) { // regalloc issue with the for loop. - for(i = 0; i < 8; i++) { + for (i = 0; i < 8; i++) { settings->racers[i].starting_position = i; } } @@ -4339,7 +4293,7 @@ void func_8008F534(void) { set_free_queue_state(0); free_from_memory_pool(D_800E0970); set_free_queue_state(2); - for(i = 0; i < 15; i += 3){ + for (i = 0; i < 15; i += 3) { if (D_800E0710[i] != -1) { func_8009C508(D_800E0710[i]); } @@ -4382,7 +4336,7 @@ void render_track_select_setup_ui(s32 arg0) { s32 s3; s32 s4; s32 s7; - + sp80 = 0; sp78 = NULL; sp74 = FALSE; @@ -4448,8 +4402,8 @@ void render_track_select_setup_ui(s32 arg0) { set_text_font(0); s7 = D_800E0700[7] + D_800E0700[1] + sp80; s7++; - for(i = 0; i < 2; i++) { - for(j = 0; j < 4; j += 2) { + for (i = 0; i < 2; i++) { + for (j = 0; j < 4; j += 2) { if (j == 0) { set_text_color(0, 0, 0, 0xFF, D_800DF764 >> 1); } else { @@ -4468,7 +4422,7 @@ void render_track_select_setup_ui(s32 arg0) { if (D_801269C8 < 4) { set_text_font(0); set_text_color(0xFF, 0x40, 0x40, 0x60, D_800DF764); - draw_text(&D_801263A0, 0x38, 0x48 + sp80, gMenuText[9], 8); // gMenuText[9] = "BEST TIME" + draw_text(&D_801263A0, 0x38, 0x48 + sp80, gMenuText[9], 8); // gMenuText[9] = "BEST TIME" draw_text(&D_801263A0, 0x38, 0x5C + sp80, gMenuText[10], 8); // gMenuText[10] = "BEST LAP" set_text_color(0xFF, 0x80, 0xFF, 0x60, D_800DF764); decompress_filename_string(settings->courseInitialsPtr[gPlayerSelectVehicle[0]][gTrackIdForPreview], &sp78, 3); @@ -4486,7 +4440,7 @@ void render_track_select_setup_ui(s32 arg0) { render_textured_rectangle(&D_801263A0, &D_800E05B4, 0x88, sp80 + 0x72, 0xFF, 0xFF, 0xFF, D_800DF764); } else { render_textured_rectangle(&D_801263A0, &D_800E05C4, 0x88, sp80 + 0x72, 0xFF, 0xFF, 0xFF, D_800DF764); - for(i = 0; i < 2; i++) { + for (i = 0; i < 2; i++) { s32 yTemp = 0x97 + sp80 + (i * 0x18); if (i == D_800E0414) { render_textured_rectangle(&D_801263A0, D_800E0648[(i * 3) + 1], 0x68, yTemp, 0xFF, 0xFF, 0xFF, D_800DF764); @@ -4498,40 +4452,40 @@ void render_track_select_setup_ui(s32 arg0) { } else { if (!sp74) { s3 = (gNumberOfActivePlayers - 1) * gNumberOfActivePlayers; - for(i = 0; i < gNumberOfActivePlayers; i++) { - + for (i = 0; i < gNumberOfActivePlayers; i++) { + if (((gNumberOfActivePlayers == 1) && (i == D_801263E0)) || ((gNumberOfActivePlayers >= 2) && (D_801269C4[i] == 0))) { - s32 temp_v0_9 = D_800E0688[s3 + (i*2)]; - s32 temp_v1 = D_800E0688[s3 + (i*2) + 1] + sp80; + s32 temp_v0_9 = D_800E0688[s3 + (i * 2)]; + s32 temp_v1 = D_800E0688[s3 + (i * 2) + 1] + sp80; // Glow effect around Player image func_800C4EDC(7, temp_v0_9 - 2, temp_v1 - 2, temp_v0_9 + 0x32, temp_v1 + 0x17); func_800C5B58(&D_801263A0, 0, 0, 7); } - + // "Player" text image - render_textured_rectangle(&D_801263A0, D_800E0660[i], D_800E0688[s3 + (i*2)], D_800E0688[s3 + (i*2) + 1] + sp80, 0xFF, 0xFF, 0xFF, D_800DF764); + render_textured_rectangle(&D_801263A0, D_800E0660[i], D_800E0688[s3 + (i * 2)], D_800E0688[s3 + (i * 2) + 1] + sp80, 0xFF, 0xFF, 0xFF, D_800DF764); } } } - + if ((gNumberOfActivePlayers >= 2) || D_801263E0 == 0) { // Draws "Car", "Hover", "Plane" text choice images. if (sp74 == 0) { s32 yTemp = 0x8B + sp80; s3 = ((gNumberOfActivePlayers - 1) * gNumberOfActivePlayers) / 2; - for(i = 0; i < 3; i++) { + for (i = 0; i < 3; i++) { if ((1 << i) & sp7C) { if (gNumberOfActivePlayers > 0) { for (j = 0; j < gNumberOfActivePlayers; j++) { if (i == gPlayerSelectVehicle[j]) { // Highlighted - render_textured_rectangle(&D_801263A0, D_800E0624[(i*3) + 1], D_800E06B0[s3 + j], yTemp, 0xFF, 0xFF, 0xFF, D_800DF764); + render_textured_rectangle(&D_801263A0, D_800E0624[(i * 3) + 1], D_800E06B0[s3 + j], yTemp, 0xFF, 0xFF, 0xFF, D_800DF764); } else if (settings->courseFlagsPtr[gTrackIdForPreview] & 2) { // Not highlighted - render_textured_rectangle(&D_801263A0, D_800E0624[(i*3) + 2], D_800E06B0[s3 + j], yTemp, 0xFF, 0xFF, 0xFF, D_800DF764); + render_textured_rectangle(&D_801263A0, D_800E0624[(i * 3) + 2], D_800E06B0[s3 + j], yTemp, 0xFF, 0xFF, 0xFF, D_800DF764); } else { // Not available (Ghosted out) - render_textured_rectangle(&D_801263A0, D_800E0624[(i*3) + 2], D_800E06B0[s3 + j], yTemp, 0xFF, 0xFF, 0xFF, D_800DF764 / 2); + render_textured_rectangle(&D_801263A0, D_800E0624[(i * 3) + 2], D_800E06B0[s3 + j], yTemp, 0xFF, 0xFF, 0xFF, D_800DF764 / 2); } } } @@ -4564,9 +4518,9 @@ void render_track_select_setup_ui(s32 arg0) { // Draw vehicle image for second player render_textured_rectangle(&D_801263A0, D_800E0624[gPlayerSelectVehicle[1] * 3], 0xB0, s7, 0xFF, 0xFF, 0xFF, D_800DF764); } - + func_8007B3D0(&D_801263A0); - + if (gNumberOfActivePlayers < 3) { // Draw border around vehicle images if (!sp74) { @@ -4582,7 +4536,7 @@ void render_track_select_setup_ui(s32 arg0) { } } } - + if (sp74) { s32 temp_v0_12 = func_800C4DA0(gMenuText[136], 0, 0); // gMenuText[136] = "NUMBER OF RACERS" if ((D_800E06E4[2] - 0xC) < temp_v0_12) { @@ -4590,8 +4544,7 @@ void render_track_select_setup_ui(s32 arg0) { } else { s4 = D_800E06E4[2]; } - func_80080580(&D_801263A0, -(s4 >> 1), 0x78 - D_800E06E4[1], s4, D_800E06E4[3], - D_800E06E4[4], D_800E06E4[5], 0xB0E0C0FF, D_8012665C); + func_80080580(&D_801263A0, -(s4 >> 1), 0x78 - D_800E06E4[1], s4, D_800E06E4[3], D_800E06E4[4], D_800E06E4[5], 0xB0E0C0FF, D_8012665C); func_80080E6C(); set_text_font(0); set_text_color(0, 0, 0, 0xFF, 0x80); @@ -4601,7 +4554,7 @@ void render_track_select_setup_ui(s32 arg0) { // gMenuText[136] = "NUMBER OF RACERS" func_80068508(1); func_8007BF1C(0); - for(i = 0; i < 3; i++) { + for (i = 0; i < 3; i++) { s32 index = i * 2; if (i == gMultiplayerSelectedNumberOfRacers) { if (D_801263E0 < 3) { @@ -4615,7 +4568,7 @@ void render_track_select_setup_ui(s32 arg0) { // X position D_800DF75C[0].unkC = (D_800E06E4[index + 8] + D_800E06E4[0]) - 0xA0; // Y position - D_800DF75C[0].unk10 = (-D_800E06E4[index + 9] - D_800E06E4[1]) + 0x78; + D_800DF75C[0].unk10 = (-D_800E06E4[index + 9] - D_800E06E4[1]) + 0x78; // Number value to draw. D_800DF75C[0].unk18 = index + 2; func_8009CA60(0); @@ -4669,16 +4622,16 @@ GLOBAL_ASM("asm/non_matchings/menu/render_track_select_setup_ui.s") GLOBAL_ASM("asm/non_matchings/menu/func_80092188.s") s32 func_80092BE0(s32 arg0) { - s8 *trackIdArray; + s8 *trackIdArray; s32 index; s32 temp; - + trackIdArray = (s8 *)get_misc_asset(0x1C); - + index = 0; temp = -1; if (trackIdArray[0] != -1) { - while(temp < 0) { + while (temp < 0) { if (arg0 == trackIdArray[index]) { temp = index; } @@ -4688,14 +4641,14 @@ s32 func_80092BE0(s32 arg0) { } } } - + if (temp >= 0) { s64 temp2 = 0x10 << temp; if ((temp2 & D_80126448) == 0) { temp = -1; } } - + return temp; } @@ -4704,7 +4657,7 @@ void menu_5_init(void) { s32 result; s32 s0; s16 temp; - + settings = get_settings(); gTrackIdForPreview = 0; D_801263BC = 0; @@ -4753,7 +4706,6 @@ void menu_5_init(void) { GLOBAL_ASM("asm/non_matchings/menu/func_80092E94.s") - #ifdef NON_MATCHING // Regalloc issues s32 menu_5_loop(s32 arg0) { @@ -4766,12 +4718,12 @@ s32 menu_5_loop(s32 arg0) { s32 sp20; s32 sp1C; Settings *settings; - + if (D_801263E0 < 0) { return gTrackIdForPreview | 0x80; } settings = get_settings(); - sp24 = ((Settings4C*)((u8*)settings->unk4C + gTrackIdForPreview))->unk2; + sp24 = ((Settings4C *)((u8 *)settings->unk4C + gTrackIdForPreview))->unk2; sp28 = FALSE; temp0 = settings->courseFlagsPtr[sp24]; sp1C = 0; @@ -4834,12 +4786,12 @@ s32 menu_5_loop(s32 arg0) { if (D_80126830 > 0) { do { vehicle--; - } while(!((1 << vehicle) & sp30) && (vehicle >= 0)); + } while (!((1 << vehicle) & sp30) && (vehicle >= 0)); } if (D_80126830 < 0) { do { vehicle++; - } while(!((1 << vehicle) & sp30) && (vehicle < 3)); + } while (!((1 << vehicle) & sp30) && (vehicle < 3)); } if ((vehicle < 0) || (vehicle >= 3)) { vehicle = vehicle2; @@ -4872,7 +4824,7 @@ GLOBAL_ASM("asm/non_matchings/menu/menu_5_loop.s") #endif void func_80093A0C(void) { - func_8009C4A8((s16*)&D_800E0FB4); + func_8009C4A8((s16 *)&D_800E0FB4); func_800C422C(2); func_80000B28(); } @@ -4913,7 +4865,7 @@ void func_80094C14(s32 arg0) { D_80126A94 += arg0; if (D_801263D8 >= 0) { D_801263D8 += arg0; - switch(D_800DF460) { + switch (D_800DF460) { case 0: if (func_8000C8B4(0xF0) < D_801263D8) { func_80000C98(-0x100); @@ -4962,8 +4914,8 @@ void func_80095624(s32 arg0) { D_80126C1C = D_800E09B0; break; } - - for(D_80126C24 = 0; D_80126C1C[D_80126C24] != 0; D_80126C24++) { + + for (D_80126C24 = 0; D_80126C1C[D_80126C24] != 0; D_80126C24++) { } } #else @@ -4972,25 +4924,24 @@ GLOBAL_ASM("asm/non_matchings/menu/func_80095624.s") GLOBAL_ASM("asm/non_matchings/menu/func_80095728.s") - void func_80096790(void) { s32 temp; s8 *temp2; - - temp2 = (s8*)get_current_level_header(); + + temp2 = (s8 *)get_current_level_header(); func_8009C4A8(D_800E0A24); temp = *temp2 - 1; - + if (D_80126BB8) { func_8009C508(D_800E0710[temp * 3]); } D_80126BB8 = 0; - + if (D_80126BBC) { func_8009C508(D_800E0710[(temp * 3) + 1]); } D_80126BBC = 0; - + func_800981E8(); func_80000968(0); } @@ -5002,12 +4953,11 @@ void menu_11_init(void) { s8 temp_a2; settings = get_settings(); - D_80126BF0[0] = (s32) gMenuText[24]; - D_80126BF0[1] = (s32) gMenuText[23]; - D_80126BF0[2] = (s32) gMenuText[28]; + D_80126BF0[0] = (s32)gMenuText[24]; + D_80126BF0[1] = (s32)gMenuText[23]; + D_80126BF0[2] = (s32)gMenuText[28]; D_80126C14 = 3; - - + for (i = 0; i < gNumberOfActivePlayers; i++) { temp_a2 = settings->racers[i].starting_position; if (temp_a2 < 4) { @@ -5015,7 +4965,7 @@ void menu_11_init(void) { placements[temp_a2]++; } } - + D_801263E0 = -1; D_801263BC = 0; D_801263D8 = 0; @@ -5048,7 +4998,7 @@ void func_800976CC(void) { void decompress_filename_string(u32 compressedFilename, char *output, s32 length) { s32 index; output[length] = '\0'; // Set null terminator at the end - for(index = length - 1; index >= 0; ) { + for (index = length - 1; index >= 0;) { index--; output[index + 1] = gFileNameValidChars[compressedFilename & (sizeof(gFileNameValidChars) - 1)]; compressedFilename /= sizeof(gFileNameValidChars); // compressedFilename >>= 5; @@ -5068,12 +5018,12 @@ s32 compress_filename_string(unsigned char *filename, s32 length) { output = 0; processingChars = 1; - + for (i = 0; i < length; i++) { if (filename[i] == '\0') { processingChars = 0; } - + if (!processingChars) { currentChar = ' '; charIndex = 0; @@ -5081,18 +5031,18 @@ s32 compress_filename_string(unsigned char *filename, s32 length) { currentChar = filename[i]; charIndex = 0; } - + while (currentChar != gFileNameValidChars[charIndex]) { charIndex++; if (charIndex >= (s32)(sizeof(gFileNameValidChars) - 1)) { break; } } - + output *= sizeof(gFileNameValidChars); // output <<= 5; output |= charIndex & (sizeof(gFileNameValidChars) - 1); } - + return output; } @@ -5116,7 +5066,7 @@ s32 trim_filename_string(u8 *input, u8 *output) { if (*temp == '\0') { break; } - while(numSpacesProcessed < numSpaces){ + while (numSpacesProcessed < numSpaces) { *(output++) = *(input++); numSpacesProcessed++; } @@ -5128,7 +5078,7 @@ s32 trim_filename_string(u8 *input, u8 *output) { } #else GLOBAL_ASM("asm/non_matchings/menu/trim_filename_string.s") -#endif +#endif void func_80097874(s32 arg0, s32 arg1, s32 arg2, s32 arg3, s32 *arg4, s32 arg5, s32 arg6) { D_800E0F90 = arg0; @@ -5139,14 +5089,13 @@ void func_80097874(s32 arg0, s32 arg1, s32 arg2, s32 arg3, s32 *arg4, s32 arg5, D_80126C74 = arg5; D_80126C78 = arg6; D_800E0FA0 = 0; - D_80126C50 = (f32) *D_80126C6C; + D_80126C50 = (f32)*D_80126C6C; gCheatInputString = NULL; D_80126C3C = 0; D_80126C34 = 0; func_800C4170(2); } - GLOBAL_ASM("asm/non_matchings/menu/func_80097918.s") GLOBAL_ASM("asm/non_matchings/menu/func_80097D10.s") @@ -5177,25 +5126,25 @@ void menu_trophy_race_round_init(void) { settings = get_settings(); temp_t9 = get_misc_asset(0x1A); // Returns level ids array. - + if (D_800E0FEC == 0) { - for(i = 0; i < 8; i++) { + for (i = 0; i < 8; i++) { settings->racers[i].trophy_points = 0; } } - + temp = temp_t9[((gTrophyRaceWorldId - 1) * 6) + D_800E0FEC]; - while(temp == -1) { + while (temp == -1) { temp = (temp + 1) & 3; } - - for(i = 0; i < gNumberOfActivePlayers; i++){ + + for (i = 0; i < gNumberOfActivePlayers; i++) { gPlayerSelectVehicle[i] = func_8006B0AC(temp); } - + func_8006DB14(func_8006B0AC(temp)); load_level_for_menu(temp, -1, 1); - + gMenuDelay = 0; D_800E0980 = 10; func_800C4170(2); @@ -5217,7 +5166,7 @@ void func_800983C0(s32 arg0) { } else { sp2C = 0; } - + sp28 = func_8006BDDC(func_8006B1D4(gTrophyRaceWorldId)); sp24 = func_8006BDDC(sp20[((gTrophyRaceWorldId - 1) * 6) + D_800E0FEC]); set_text_background_color(0, 0, 0, 0); @@ -5248,25 +5197,25 @@ void func_80098EBC(s32 arg0) { s32 i; D_801263BC = (D_801263BC + arg0) & 0x3F; - + test = D_801263BC * 8; if (test >= 0x100) { test = 0x1FF - test; } - + // Has regalloc issues starting here. for (i = 0; i < D_800E0FE4; i++) { fade = 0xFF; - + if (gNumberOfActivePlayers < 3 && ((D_801263E0 == 0 && D_80126418[i]) || (D_801263E0 != 0 && D_80126420[i]))) { fade = (test >> 1) + 0x80; } - + D_800E1048[i][0].filterRed = fade; D_800E1048[i][0].filterGreen = fade; D_800E1048[i][0].filterBlue = fade; } - + if (D_801263E0 == 2 || D_801263E0 == 3) { draw_menu_elements(1, &D_800E1048, 1.0f); } @@ -5295,7 +5244,7 @@ GLOBAL_ASM("asm/non_matchings/menu/func_800998E0.s") void menu_ghost_data_init(void) { s32 i; s32 sp70; - + sp70 = func_800756D4(D_801264D0, &D_801264DC, &D_801264EC, &D_801264E4, &D_801264F8); if (sp70 == 0) { func_8009963C(); @@ -5313,10 +5262,10 @@ void menu_ghost_data_init(void) { D_800E1644[5].texture = D_80126550[21]; D_800E169C[0].texture = D_80126550[22]; D_800E169C[5].texture = D_80126550[23]; - for(i = 0; i < 4; i++) { + for (i = 0; i < 4; i++) { D_800E153C[i + 1].texture = D_800E153C[0].texture; D_800E153C[i + 6].texture = D_800E153C[5].texture; - if(i & 1 == 1) { + if (i & 1 == 1) { D_800E1594[i + 1].texture = D_800E1594[0].texture; D_800E1594[i + 6].texture = D_800E1594[5].texture; } else { @@ -5327,7 +5276,7 @@ void menu_ghost_data_init(void) { D_800E15EC[i + 6].texture = D_800E15EC[5].texture; D_800E1644[i + 1].texture = D_800E1644[0].texture; D_800E1644[i + 6].texture = D_800E1644[5].texture; - if(i & 1 == 1) { + if (i & 1 == 1) { D_800E169C[i + 1].texture = D_800E169C[0].texture; D_800E169C[i + 6].texture = D_800E169C[5].texture; } else { @@ -5362,13 +5311,13 @@ s32 menu_ghost_data_loop(s32 arg0) { s32 pressedButtons, xStick, yStick; s32 temp; s32 tempDelay; - + D_801263BC = (D_801263BC + arg0) & 0x3F; if ((gMenuDelay >= -0x13) && (gMenuDelay < 0x14)) { func_80099E8C(); } - + pressedButtons = 0; if (gMenuDelay != 0) { if (gMenuDelay < 0) { @@ -5377,18 +5326,18 @@ s32 menu_ghost_data_loop(s32 arg0) { gMenuDelay += arg0; } } - + xStick = 0; yStick = 0; if (!gIgnorePlayerInput && gMenuDelay == 0) { - for(i = 0; i < 4; i++) { + for (i = 0; i < 4; i++) { pressedButtons |= get_buttons_pressed_from_player(i); xStick += gControllersXAxisDirection[i]; yStick += gControllersYAxisDirection[i]; } } - - switch(D_801263E0) { + + switch (D_801263E0) { case 0: if ((pressedButtons & (START_BUTTON | A_BUTTON)) && (D_801264D4 > 0)) { D_801263E0 = 2; @@ -5455,7 +5404,7 @@ s32 menu_ghost_data_loop(s32 arg0) { } break; } - + gIgnorePlayerInput = FALSE; if (gMenuDelay >= 0x1F) { func_8009ABAC(); @@ -5474,22 +5423,22 @@ void func_8009ABAC(void) { void func_8009ABD8(s8 *arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4, s32 arg5) { s32 phi_v1; - + phi_v1 = 0; - while(phi_v1 < arg1) { + while (phi_v1 < arg1) { phi_v1++; while (-1 != *arg0) { arg0 += 3; } arg0++; } - + if ((phi_v1 == 0) && (get_misc_asset(0x19) == (s32 *)arg0)) { D_8012684C = 1; } else { D_8012684C = 0; } - + D_801267EC = arg0; D_80126824 = arg2; D_8012683C = arg3; @@ -5563,19 +5512,19 @@ void menu_credits_init(void) { play_music(8); gCreditsArray[84] = gCreditsLastMessageArray[0]; // "THE END?" } - + cheat = gCheatsInCreditsArray[get_random_number_from_range(0, NUMBER_CHEATS_IN_CREDITS - 1)]; cheatIndex = -1; - while(cheat != 0) { + while (cheat != 0) { cheat >>= 1; cheatIndex++; } - - // The first u16 of gCheatsAssetData is the total number of cheats. + + // The first u16 of gCheatsAssetData is the total number of cheats. // After that is the offsets to the cheat strings. - cheatOffsets = *gCheatsAssetData + 1; - gCreditsArray[85] = (char*)(*gCheatsAssetData) + (cheatOffsets)[(cheatIndex << 1) + 1]; // Cheat name - gCreditsArray[86] = (char*)(*gCheatsAssetData) + (cheatOffsets)[(cheatIndex << 1)]; // Cheat code + cheatOffsets = *gCheatsAssetData + 1; + gCreditsArray[85] = (char *)(*gCheatsAssetData) + (cheatOffsets)[(cheatIndex << 1) + 1]; // Cheat name + gCreditsArray[86] = (char *)(*gCheatsAssetData) + (cheatOffsets)[(cheatIndex << 1)]; // Cheat code } func_80000B18(); func_800C0170(); @@ -5589,14 +5538,14 @@ void func_8009B1E4(s32 arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4) { if (arg4 < 0) { arg4 = 0; } - - gSPDisplayList(D_801263A0++, D_800E1780) - gDPSetPrimColor(D_801263A0++, 0, 0, 0, 0, 0, arg4) - gDPSetCombineMode(D_801263A0++, G_CC_PRIMITIVE, G_CC_PRIMITIVE) - gDPFillRectangle(D_801263A0++, arg0, arg1, arg0 + arg2, arg1 + arg3) - gDPPipeSync(D_801263A0++) - gDPSetPrimColor(D_801263A0++, 0, 0, 255, 255, 255, 255) - + + gSPDisplayList(D_801263A0++, D_800E1780); + gDPSetPrimColor(D_801263A0++, 0, 0, 0, 0, 0, arg4); + gDPSetCombineMode(D_801263A0++, G_CC_PRIMITIVE, G_CC_PRIMITIVE); + gDPFillRectangle(D_801263A0++, arg0, arg1, arg0 + arg2, arg1 + arg3); + gDPPipeSync(D_801263A0++); + gDPSetPrimColor(D_801263A0++, 0, 0, 255, 255, 255, 255); + func_8007B3D0(&D_801263A0); } @@ -5623,9 +5572,9 @@ void func_8009BD5C(void) { func_8006652C(0); func_800665E8(0); - - temp_v0 = (unk80069D20*)func_80069D20(); - + + temp_v0 = (unk80069D20 *)func_80069D20(); + sp2A = temp_v0->unk0; sp28 = temp_v0->unk2; sp26 = temp_v0->unk4; @@ -5638,10 +5587,10 @@ void func_8009BD5C(void) { temp_v0->unkC = -32.0f; temp_v0->unk10 = -32.0f; temp_v0->unk14 = -32.0f; - + func_8001D5E0(0, 0, -1); func_80066CDC(&D_801263A0, &D_801263A8); - + temp_v0->unk0 = sp2A; temp_v0->unk2 = sp28; temp_v0->unk4 = sp26; @@ -5651,12 +5600,11 @@ void func_8009BD5C(void) { } void func_8009BE54() { - } void reset_controller_sticks(void) { s32 i; - for(i = 0; i < 4; i++) { + for (i = 0; i < 4; i++) { gControllersXAxisDirection[i] = 0; gControllersYAxisDirection[i] = 0; gControllersXAxisDelay[i] = 0; @@ -5675,7 +5623,7 @@ void reset_controller_sticks(void) { void update_controller_sticks(void) { s32 prevXAxis, prevYAxis; s32 i; - for(i = 0; i < 4; i++) { + for (i = 0; i < 4; i++) { prevXAxis = gControllersXAxis[i]; prevYAxis = gControllersYAxis[i]; gControllersXAxis[i] = func_8006A59C(i); @@ -5732,7 +5680,7 @@ GLOBAL_ASM("asm/non_matchings/menu/update_controller_sticks.s") void reset_character_id_slots(void) { s32 i; gTrackSelectRow = 1; // 1 = Dino Domain - for(i = 0; i < 8; i++) { + for (i = 0; i < 8; i++) { gCharacterIdSlots[i] = i; } } @@ -5835,8 +5783,8 @@ void set_magic_code_flags(s32 flags) { CHEAT_TWO_PLAYER_ADVENTURE | CHEAT_ULTIMATE_AI | CHEAT_EPC_LOCK_UP_DISPLAY | CHEAT_ROM_CHECKSUM) \ // Remember that ~ means NOT. So the challenge maps only allow cheats NOT included here. -#define CHEATS_ALLOWED_IN_CHALLENGES ~(CHEAT_START_WITH_10_BANANAS | CHEAT_DISABLE_BANANAS | \ - CHEAT_DISABLE_WEAPONS | CHEAT_ALL_BALLOONS_ARE_RED | CHEAT_ALL_BALLOONS_ARE_GREEN | \ +#define CHEATS_ALLOWED_IN_CHALLENGES ~(CHEAT_START_WITH_10_BANANAS | CHEAT_DISABLE_BANANAS | \ + CHEAT_DISABLE_WEAPONS | CHEAT_ALL_BALLOONS_ARE_RED | CHEAT_ALL_BALLOONS_ARE_GREEN | \ CHEAT_ALL_BALLOONS_ARE_BLUE | CHEAT_ALL_BALLOONS_ARE_YELLOW | CHEAT_ALL_BALLOONS_ARE_RAINBOW) /** @@ -5851,7 +5799,7 @@ s32 get_filtered_cheats(void) { cheats &= ~CHEAT_MIRRORED_TRACKS; // Disable mirroring } if (func_8006B14C(get_settings()->courseId) & 0x40) { - cheats &= CHEATS_ALLOWED_IN_CHALLENGES; + cheats &= CHEATS_ALLOWED_IN_CHALLENGES; } if (gIsInAdventureTwo && func_8006B240()) { cheats |= CHEAT_MIRRORED_TRACKS; // Enable mirroring @@ -5867,7 +5815,7 @@ s32 get_number_of_active_players(void) { } s32 func_8009C3D8(void) { - unk8006BDB0 *temp = (unk8006BDB0*)get_current_level_header(); + unk8006BDB0 *temp = (unk8006BDB0 *)get_current_level_header(); if (gIsInTwoPlayerAdventure && !gIsInTracksMode) { if (temp->unk4C == 0 || (temp->unk4C & 0x40) != 0) { return 2; @@ -5890,8 +5838,8 @@ s32 get_multiplayer_racer_count(void) { return (gMultiplayerSelectedNumberOfRacers + 1) << 1; // Doesn't match with multiply. } -Settings** func_8009C490(void) { - return (Settings**)D_80126530; +Settings **func_8009C490(void) { + return (Settings **)D_80126530; } void func_8009C49C(void) { @@ -5962,7 +5910,7 @@ void func_8009C904(s32 arg0) { if (D_800DF75C == NULL) { D_800DF75C = allocate_from_main_pool_safe(sizeof(unk800DF510) * 18, COLOR_TAG_RED); } - + D_800DF75C[arg0].unk0 = D_800DF510[arg0].unk0; D_800DF75C[arg0].unk2 = D_800DF510[arg0].unk2; D_800DF75C[arg0].unk4 = D_800DF510[arg0].unk4; @@ -6060,8 +6008,8 @@ void func_8009D1B8(s32 arg0, s32 arg1, s32 arg2) { D_80126516 = arg2; } func_800C5168(1, -0x8000, D_8012650E, arg0, 1, 4); - D_8012650E = (s8) (D_8012650E + arg1); - D_80126504 = (s8) (D_80126504 + 1); + D_8012650E = (s8)(D_8012650E + arg1); + D_80126504 = (s8)(D_80126504 + 1); } void func_8009D26C(void) { @@ -6072,11 +6020,11 @@ void func_8009D26C(void) { D_801264D8 = D_801264D8 - 1; func_80001D04(0xB2, NULL); } - + if (D_801264D8 < 0) { D_801264D8 = D_80126504 - 1; } - + if (D_801264D8 >= D_80126504) { D_801264D8 = 0; } @@ -6100,7 +6048,7 @@ s32 taj_menu_loop(void) { s32 sp2C; s32 buttonsPressed; // sp28 Settings *settings; // sp24 - + settings = get_settings(); if ((D_800DF4DC != 0) && (D_801264E2 == 0)) { D_801264E2 = -D_800DF4DC; @@ -6115,8 +6063,8 @@ s32 taj_menu_loop(void) { sp2C = 0; buttonsPressed = get_buttons_pressed_from_player(0); D_80126504 = 0; - - switch(D_801264E2) { + + switch (D_801264E2) { case 2: case 0x62: func_800C5168(1, -0x8000, 6, gMenuText[40], 1, 4); // VEHICLE SELECT @@ -6145,121 +6093,121 @@ s32 taj_menu_loop(void) { func_8009D1B8(gMenuText[44], 0x14, 3); // MAIN MENU break; } - + switch (D_801264E2) { - case 0: - func_800C31EC(7); - D_801264E2 = 1; - D_800DF4D8 = 1; - break; - case 1: - D_800DF4DC = 0; - func_800C5168(1, -0x8000, 6, gMenuText[36], 1, 4); // OPTIONS - D_8012650E = 0x1E; - func_8009D1B8(gMenuText[37], 0x14, 0); // CHANGE VEHICLE - if (settings->tajFlags & TAJ_FLAGS_UNLOCKED_A_CHALLENGE) { - func_8009D1B8(gMenuText[39], 0x14, 1); // CHALLENGES - } - func_8009D1B8(gMenuText[5], 0x14, 2); // RETURN - func_8009D26C(); - if (buttonsPressed & B_BUTTON) { - sp2C = 3; - func_80001D04(0x241, 0); - } else if (buttonsPressed & A_BUTTON) { - func_80001D04(0xEF, 0); - switch(D_80126516) { - case 1: - D_801264E2 = 3; - D_801264D8 = 0; - func_8003AC3C(0x239, 1); - break; - case 2: - sp2C = 3; - break; - case 0: - D_801264E2 = 2; - D_801264D8 = 0; - func_8003AC3C(0x234, 1); - break; - } - } - break; - case 2: - func_8009D26C(); - if (buttonsPressed & B_BUTTON) { - func_80001D04(0x241, 0); - func_8003AC3C(0x238, 1); + case 0: + func_800C31EC(7); D_801264E2 = 1; - D_801264D8 = 0; - } else if (buttonsPressed & A_BUTTON) { - if (D_80126516 != 3) { - sp2C = D_80126516 | 0x80; - D_801264E2 = 0x62; - } else { + D_800DF4D8 = 1; + break; + case 1: + D_800DF4DC = 0; + func_800C5168(1, -0x8000, 6, gMenuText[36], 1, 4); // OPTIONS + D_8012650E = 0x1E; + func_8009D1B8(gMenuText[37], 0x14, 0); // CHANGE VEHICLE + if (settings->tajFlags & TAJ_FLAGS_UNLOCKED_A_CHALLENGE) { + func_8009D1B8(gMenuText[39], 0x14, 1); // CHALLENGES + } + func_8009D1B8(gMenuText[5], 0x14, 2); // RETURN + func_8009D26C(); + if (buttonsPressed & B_BUTTON) { + sp2C = 3; + func_80001D04(0x241, 0); + } else if (buttonsPressed & A_BUTTON) { + func_80001D04(0xEF, 0); + switch (D_80126516) { + case 1: + D_801264E2 = 3; + D_801264D8 = 0; + func_8003AC3C(0x239, 1); + break; + case 2: + sp2C = 3; + break; + case 0: + D_801264E2 = 2; + D_801264D8 = 0; + func_8003AC3C(0x234, 1); + break; + } + } + break; + case 2: + func_8009D26C(); + if (buttonsPressed & B_BUTTON) { + func_80001D04(0x241, 0); + func_8003AC3C(0x238, 1); D_801264E2 = 1; D_801264D8 = 0; - func_8003AC3C(0x238, 1); + } else if (buttonsPressed & A_BUTTON) { + if (D_80126516 != 3) { + sp2C = D_80126516 | 0x80; + D_801264E2 = 0x62; + } else { + D_801264E2 = 1; + D_801264D8 = 0; + func_8003AC3C(0x238, 1); + } } - } - break; - case 3: - func_8009D26C(); - if ((buttonsPressed & B_BUTTON) || ((buttonsPressed & A_BUTTON) && (D_80126516 == 3))) { - func_80001D04(0x241, 0); - func_8003AC3C(0x23A, 1); + break; + case 3: + func_8009D26C(); + if ((buttonsPressed & B_BUTTON) || ((buttonsPressed & A_BUTTON) && (D_80126516 == 3))) { + func_80001D04(0x241, 0); + func_8003AC3C(0x23A, 1); + D_801264E2 = 1; + D_801264D8 = 3; + } else if (buttonsPressed & A_BUTTON) { + sp2C = D_80126516 | 0x40; + func_80001D04(0xEF, 0); + D_801264E2 = 0x63; + } + break; + case -3: + case -2: + case -1: + func_800C31EC(8 - D_801264E2); + D_801264E2 = 4; + break; + case -4: + func_800C31EC(0x11); + D_800DF4DC = 0; D_801264E2 = 1; D_801264D8 = 3; - } else if (buttonsPressed & A_BUTTON) { - sp2C = D_80126516 | 0x40; - func_80001D04(0xEF, 0); - D_801264E2 = 0x63; - } - break; - case -3: - case -2: - case -1: - func_800C31EC(8 - D_801264E2); - D_801264E2 = 4; - break; - case -4: - func_800C31EC(0x11); - D_800DF4DC = 0; - D_801264E2 = 1; - D_801264D8 = 3; - break; - case -5: - func_800C31EC(0x15); - D_800DF4DC = 0; - D_801264E2 = 7; - D_801264D8 = 0; - break; - case -8: - case -7: - case -6: - func_800C31EC(0xC - D_801264E2); - D_801264E2 = 6; - D_801264D8 = 0; - break; - case 4: - sp2C = (D_800DF4DC - 1) | 0x40; - D_801264E2 = 5; - func_800C5620(1); - break; - case 5: - D_800DF4DC = 0; - func_800C5620(1); - break; - case 6: - case 7: - sp2C = 4; - if (D_801264E2 == 7) { - sp2C = 3; - } - D_800DF4E0 = 0; - func_800C5620(1); - D_800DF4DC = 0; - D_801264E2 = 0; - break; + break; + case -5: + func_800C31EC(0x15); + D_800DF4DC = 0; + D_801264E2 = 7; + D_801264D8 = 0; + break; + case -8: + case -7: + case -6: + func_800C31EC(0xC - D_801264E2); + D_801264E2 = 6; + D_801264D8 = 0; + break; + case 4: + sp2C = (D_800DF4DC - 1) | 0x40; + D_801264E2 = 5; + func_800C5620(1); + break; + case 5: + D_800DF4DC = 0; + func_800C5620(1); + break; + case 6: + case 7: + sp2C = 4; + if (D_801264E2 == 7) { + sp2C = 3; + } + D_800DF4E0 = 0; + func_800C5620(1); + D_800DF4DC = 0; + D_801264E2 = 0; + break; } return sp2C; } @@ -6281,8 +6229,8 @@ s32 func_8009D9F4(void) { func_8009D1B8(gMenuText[51], 0x14, 1); // EXIT func_8009D26C(); if (playerInput & A_BUTTON) { - func_80001D04(0xEF, NULL); - switch(D_80126516) { + func_80001D04(0xEF, NULL); + switch (D_80126516) { case 0: state = 1; break; @@ -6306,9 +6254,9 @@ s32 tt_menu_loop(void) { s32 sp24; s32 sp20; s32 i; - + settings = get_settings(); - + if (is_in_two_player_adventure()) { settings->cutsceneFlags |= 2; } @@ -6331,9 +6279,9 @@ s32 tt_menu_loop(void) { D_8012650E = 0x20; switch (D_801264E2) { case TT_MENU_ROOT: - case TT_MENU_EXIT: + case TT_MENU_EXIT: func_800C5168(1, -0x8000, 6, gMenuText[36], 1, 4); // OPTIONS - func_8009D1B8(gMenuText[71], 0x14, 3); // STATUS + func_8009D1B8(gMenuText[71], 0x14, 3); // STATUS if (!is_in_two_player_adventure()) { if (is_time_trial_enabled()) { func_8009D1B8(gMenuText[65], 0x14, 0); // TIME TRIAL ON @@ -6360,7 +6308,7 @@ s32 tt_menu_loop(void) { } } if ((buttonsPressed & A_BUTTON) && (D_801264E2 != TT_MENU_EXIT)) { - switch(D_80126516) { + switch (D_80126516) { case 1: func_80001D04(0xEF, 0); D_80126398 = 0; @@ -6405,13 +6353,13 @@ s32 tt_menu_loop(void) { func_800C5168(1, -0x8000, sp38, D_801263A4[sp24], 1, 4); sp38 += 0x10; sp24++; - } + } } if (buttonsPressed & (A_BUTTON | B_BUTTON)) { D_801264E2 = TT_MENU_ROOT; } break; - case TT_MENU_GAME_STATUS: + case TT_MENU_GAME_STATUS: if (buttonsPressed & (A_BUTTON | B_BUTTON)) { D_801264E2 = TT_MENU_ROOT; D_800E1E28 = 0; @@ -6419,9 +6367,9 @@ s32 tt_menu_loop(void) { func_80036BCC(0x22F, 1); } break; - case TT_MENU_INTRODUCTION: + case TT_MENU_INTRODUCTION: sp20 = 6; - for(i = 52; gMenuText[i] != NULL; i++) { + for (i = 52; gMenuText[i] != NULL; i++) { func_800C5168(1, -0x8000, sp20, gMenuText[i], 1, 4); sp20 += 0x10; } @@ -6430,7 +6378,7 @@ s32 tt_menu_loop(void) { D_801264E2 = TT_MENU_ROOT; } break; - case TT_MENU_INSERT_CONT_PAK: + case TT_MENU_INSERT_CONT_PAK: func_800C5168(1, -0x8000, 0x22, gMenuText[159], 1, 4); // If you wish to use func_800C5168(1, -0x8000, 0x32, gMenuText[160], 1, 4); // the Controller Pak func_800C5168(1, -0x8000, 0x42, gMenuText[162], 1, 4); // insert it now! @@ -6444,7 +6392,7 @@ s32 tt_menu_loop(void) { D_801264E2 = TT_MENU_ROOT; } break; - case TT_MENU_INSERT_RUMBLE_PAK: + case TT_MENU_INSERT_RUMBLE_PAK: func_800C5168(1, -0x8000, 0x22, gMenuText[159], 1, 4); // If you wish to use func_800C5168(1, -0x8000, 0x32, gMenuText[161], 1, 4); // the Rumble Pak func_800C5168(1, -0x8000, 0x42, gMenuText[162], 1, 4); // insert it now! @@ -6452,12 +6400,12 @@ s32 tt_menu_loop(void) { D_801264E2 = TT_MENU_ROOT; } break; - case TT_MENU_SAVE_GHOST: + case TT_MENU_SAVE_GHOST: func_800C5168(1, -0x8000, 0x32, gMenuText[124], 1, 4); // PLEASE WAIT D_80126398++; if (D_80126398 >= 5) { s32 result = func_8001B738(0) & 0xFF; - if(result == 5) { + if (result == 5) { result = func_8001B738(0) & 0xFF; } switch (result) { @@ -6487,12 +6435,12 @@ s32 tt_menu_loop(void) { D_801263A4 = &D_800E09B0; D_801264E2 = TT_MENU_CONT_PAK_ERROR_1; break; - } + } } break; } - if ((D_801264E2 == TT_MENU_CONT_PAK_ERROR_1) || - (D_801264E2 == TT_MENU_CONT_PAK_ERROR_2) || + if ((D_801264E2 == TT_MENU_CONT_PAK_ERROR_1) || + (D_801264E2 == TT_MENU_CONT_PAK_ERROR_2) || (D_801264E2 == TT_MENU_CONT_PAK_ERROR_3)) { func_800C5168(1, -0x8000, 6, gMenuText[64], 1, 4); // PAK ERROR } @@ -6507,7 +6455,7 @@ GLOBAL_ASM("asm/non_matchings/menu/func_8009E3D0.s") s32 trophy_race_cabinet_menu_loop(void) { s32 sp24; s32 buttonsPressed; - + func_800C4EDC(1, 0x18, 0x10, 0xB8, 0x78); func_800C4F7C(1, 0); sp24 = 0; @@ -6538,11 +6486,9 @@ s32 trophy_race_cabinet_menu_loop(void) { } void func_8009E9A0(void) { - } void func_8009E9A8(void) { - } f32 func_8009E9B0(unk8012A7E8 *arg0, Gfx **arg1, s32 *arg2, s32 *arg3) { @@ -6585,7 +6531,7 @@ s64 func_8009EB08(void) { */ s32 get_language(void) { s32 language = ENGLISH; - switch(D_80126448 & 0xC) { + switch (D_80126448 & 0xC) { case 4: language = GERMAN; break; @@ -6606,8 +6552,8 @@ s32 get_language(void) { */ void set_language(s32 language) { s64 langFlag = 0; // English - - switch(language) { + + switch (language) { case GERMAN: langFlag = 4; break; @@ -6618,10 +6564,10 @@ void set_language(s32 language) { langFlag = 12; break; } - + D_80126448 &= ~0xC; D_80126448 |= langFlag; - + load_menu_text(language); func_8006ECE0(); } diff --git a/src/object_models.c b/src/object_models.c index 90a1220d..d83ab093 100644 --- a/src/object_models.c +++ b/src/object_models.c @@ -60,11 +60,11 @@ void func_8005F850(void) { D_8011D63C = load_asset_section_from_rom(ASSET_OBJECT_ANIMATIONS_TABLE); D_8011D644 = allocate_from_main_pool_safe(0xC00, COLOR_TAG_GREEN); D_8011D640 = 0; - + // Anti-tamper check. checksum = 0; for (i = 0; i < D_800DCEA4; i++) { - checksum += *(u8*)(((s32)&func_80024D54) + i); + checksum += *(u8 *)(((s32)&func_80024D54) + i); } if (checksum != D_800DCEA0) { func_8005C25C(); diff --git a/src/particles.c b/src/particles.c index b1a99e39..9b41a5ce 100644 --- a/src/particles.c +++ b/src/particles.c @@ -76,18 +76,18 @@ unk800E2D08 D_800E2D08[5] = { }; unk800E2D58 D_800E2D58[5] = { - { 0x0000, 0x01FF, 0x01FF }, - { 0x0000, 0x01FF, 0x01FF }, - { 0x0000, 0x0000, 0x01FF }, - { 0x0000, 0x0000, 0x01FF }, + { 0x0000, 0x01FF, 0x01FF }, + { 0x0000, 0x01FF, 0x01FF }, + { 0x0000, 0x0000, 0x01FF }, + { 0x0000, 0x0000, 0x01FF }, { 0x0000, 0x01FF, 0x01FF }, }; // Are these just Triangles? unk800E2D08 D_800E2D78[8] = { - { 0x0000, 0x0105, 0x0000, 0x0000, 0x0080, 0x0000, 0x0080, 0x01FF }, - { 0x0000, 0x0504, 0x0000, 0x0000, 0x0080, 0x01FF, 0x0000, 0x01FF }, - { 0x0001, 0x0206, 0x0080, 0x0000, 0x0100, 0x0000, 0x0100, 0x01FF }, + { 0x0000, 0x0105, 0x0000, 0x0000, 0x0080, 0x0000, 0x0080, 0x01FF }, + { 0x0000, 0x0504, 0x0000, 0x0000, 0x0080, 0x01FF, 0x0000, 0x01FF }, + { 0x0001, 0x0206, 0x0080, 0x0000, 0x0100, 0x0000, 0x0100, 0x01FF }, { 0x0001, 0x0605, 0x0080, 0x0000, 0x0100, 0x01FF, 0x0080, 0x01FF }, { 0x0002, 0x0307, 0x0100, 0x0000, 0x0180, 0x0000, 0x0180, 0x01FF }, { 0x0002, 0x0706, 0x0100, 0x0000, 0x0180, 0x01FF, 0x0100, 0x01FF }, @@ -118,7 +118,7 @@ s32 D_800E2E54 = 0; s32 D_800E2E58 = 0; s32 D_800E2E5C = 0; s32 *D_800E2E60 = NULL; -s32 D_800E2E64 = 0; +s32 D_800E2E64 = 0; s16 D_800E2E68[6] = { 0, 8, @@ -273,23 +273,23 @@ void func_800AE490(void) { #ifdef NON_MATCHING void init_particle_assets(void) { s32 i; - + func_800AE490(); gParticlesAssetTable = load_asset_section_from_rom(ASSET_PARTICLES_TABLE); - - for(gParticlesAssetTableCount = -1; (s32)gParticlesAssetTable[gParticlesAssetTableCount + 1] != -1; gParticlesAssetTableCount++){ + + for (gParticlesAssetTableCount = -1; (s32)gParticlesAssetTable[gParticlesAssetTableCount + 1] != -1; gParticlesAssetTableCount++) { } gParticlesAssets = load_asset_section_from_rom(ASSET_PARTICLES); - for(i = 0; i < gParticlesAssetTableCount; i++) { - gParticlesAssetTable[i] = (u8*)gParticlesAssets + (s32)gParticlesAssetTable[i]; + for (i = 0; i < gParticlesAssetTableCount; i++) { + gParticlesAssetTable[i] = (u8 *)gParticlesAssets + (s32)gParticlesAssetTable[i]; } gParticleBehaviorsAssetTable = load_asset_section_from_rom(ASSET_PARTICLE_BEHAVIORS_TABLE); - for(gParticleBehaviorsAssetTableCount = -1; (s32)gParticleBehaviorsAssetTable[gParticleBehaviorsAssetTableCount + 1] != -1; gParticleBehaviorsAssetTableCount++){ + for (gParticleBehaviorsAssetTableCount = -1; (s32)gParticleBehaviorsAssetTable[gParticleBehaviorsAssetTableCount + 1] != -1; gParticleBehaviorsAssetTableCount++) { } gParticleBehaviorsAssets = load_asset_section_from_rom(ASSET_PARTICLE_BEHAVIORS); - for(i = 0; i < gParticleBehaviorsAssetTableCount; i++) { - gParticleBehaviorsAssetTable[i] = (u8*)gParticleBehaviorsAssets + (s32)gParticleBehaviorsAssetTable[i]; - if((s32)gParticleBehaviorsAssetTable[i]->unk9C != -1) { + for (i = 0; i < gParticleBehaviorsAssetTableCount; i++) { + gParticleBehaviorsAssetTable[i] = (u8 *)gParticleBehaviorsAssets + (s32)gParticleBehaviorsAssetTable[i]; + if ((s32)gParticleBehaviorsAssetTable[i]->unk9C != -1) { gParticleBehaviorsAssetTable[i]->unk9C = get_misc_asset(gParticleBehaviorsAssetTable[i]->unk9C); } } @@ -306,12 +306,12 @@ void func_800AEE14(unk800AF024 *arg0, Vertex **arg1, Triangle **arg2) { Vertex *temp; Triangle *tri; s16 *temp2; - + arg0->unk4 = 3; arg0->unk8 = *arg1; temp = *arg1; temp2 = &D_800E2E68; - for(i = 0; i < 3; i++) { + for (i = 0; i < 3; i++) { temp->x = temp2[0]; temp->y = temp2[1]; temp2 += 2; @@ -339,12 +339,12 @@ void func_800AEEB8(unk800AF024 *arg0, Vertex **arg1, Triangle **arg2) { Vertex *temp; Triangle *tri; s16 *temp2; - + arg0->unk4 = 4; arg0->unk8 = *arg1; temp = *arg1; temp2 = &D_800E2E74; - for(i = 0; i < 4; i++) { + for (i = 0; i < 4; i++) { temp->x = temp2[0]; temp->y = temp2[1]; temp2 += 2; @@ -373,20 +373,20 @@ void func_800AEEB8(unk800AF024 *arg0, Vertex **arg1, Triangle **arg2) { tri[1].vi1 = 2; tri[1].vi2 = 1; tri[1].uv2.v = 0; - tri+=2; + tri += 2; *arg2 = tri; } void func_800AEF88(unk800AF024 *arg0, Vertex **arg1, Triangle **arg2) { s32 i; Vertex *temp; - + arg0->unk4 = 6; arg0->unk6 = 4; arg0->unk8 = *arg1; arg0->unkC = *arg2; temp = *arg1; - for(i = 0; i < 6; i++) { + for (i = 0; i < 6; i++) { temp->r = 255; temp->g = 255; temp->b = 255; @@ -399,13 +399,13 @@ void func_800AEF88(unk800AF024 *arg0, Vertex **arg1, Triangle **arg2) { void func_800AF024(unk800AF024 *arg0, Vertex **arg1, Triangle **arg2) { s32 i; Vertex *temp; - + arg0->unk4 = 8; arg0->unk6 = 8; arg0->unk8 = *arg1; arg0->unkC = *arg2; temp = *arg1; - for(i = 0; i < 16; i++) { + for (i = 0; i < 16; i++) { temp->r = 255; temp->g = 255; temp->b = 255; @@ -438,7 +438,7 @@ void func_800AF0F0(Object *obj) { Object_44 *temp_v0; Object_44_C *temp_v1; s16 temp_t8, temp_t1; - + temp_v0 = obj->unk44; temp_v1 = temp_v0->unkC; temp_t8 = (temp_v0->unk0->unk0 - 1) << 5; @@ -451,25 +451,20 @@ void func_800AF0F0(Object *obj) { temp_v1->unk1C = temp_t8; } -#ifdef NON_MATCHING void func_800AF134(unk800B2260 *arg0, s32 arg1, s32 arg2, s16 arg3, s16 arg4, s16 arg5) { + ParticleBehavior *temp; if (arg2 >= gParticlesAssetTableCount) { arg2 = 0; } if (arg1 >= gParticleBehaviorsAssetTableCount) { arg1 = 0; } - // Minor issue with these if statements. - if (arg0->unk8 == arg2) { - if(arg0->unk0 != gParticleBehaviorsAssetTable[arg1]) { - func_800B2260(arg0); - func_800AF29C(arg0, arg1, arg2, arg3, arg4, arg5); - } + temp = gParticleBehaviorsAssetTable[arg1]; + if ((arg0->unk8 != arg2) || (temp != arg0->unk0)) { + func_800B2260(arg0); + func_800AF29C(arg0, arg1, arg2, arg3, arg4, arg5); } } -#else -GLOBAL_ASM("asm/non_matchings/particles/func_800AF134.s") -#endif void func_800AF1E0(unk800AF29C *arg0, s32 arg1, s32 arg2) { ParticleBehavior *temp_v0; @@ -484,7 +479,7 @@ void func_800AF29C(unk800AF29C *arg0, s32 arg1, s32 arg2, s16 arg3, s16 arg4, s1 ParticleBehavior *temp_v1; s32 temp_v0_2; s32 flags; - + temp_v1 = gParticleBehaviorsAssetTable[arg1]; arg0->unk8 = arg2; arg0->unk18 = arg3; @@ -492,9 +487,9 @@ void func_800AF29C(unk800AF29C *arg0, s32 arg1, s32 arg2, s16 arg3, s16 arg4, s1 arg0->unk1A = arg4; arg0->unk1C = arg5; arg0->unk1E = 0; - + flags = temp_v1->flags; - + if (flags & 0x4000) { arg0->unk4 = 0x4000; arg0->unk6 = 0; @@ -510,7 +505,7 @@ void func_800AF29C(unk800AF29C *arg0, s32 arg1, s32 arg2, s16 arg3, s16 arg4, s1 } else { arg0->unk7 = 0xFF; } - arg0->unkB.unkC_400.unkC = (s32*)allocate_from_main_pool_safe(arg0->unk7 * 4, 0x80808080); + arg0->unkB.unkC_400.unkC = (s32 *)allocate_from_main_pool_safe(arg0->unk7 * 4, 0x80808080); arg0->unkB.unkC_400.unk10 = temp_v1->unk14; arg0->unkB.unkC_400.unk12 = temp_v1->unk16; arg0->unkB.unkC_400.unk14 = temp_v1->unk22; @@ -531,14 +526,14 @@ void func_800AF29C(unk800AF29C *arg0, s32 arg1, s32 arg2, s16 arg3, s16 arg4, s1 // Should be functionally equivalent. void func_800AF404(s32 arg0) { s32 i; - + D_800E2E28 = (D_800E2E28 + (arg0 * 64)) & 0x1FF; - for(i = 0; i < 5; i++) { + for (i = 0; i < 5; i++) { D_800E2D08[i].unk6 = D_800E2D58[i].unk0 + D_800E2E28; D_800E2D08[i].unkA = D_800E2D58[i].unk2 + D_800E2E28; D_800E2D08[i].unkE = D_800E2D58[i].unk4 + D_800E2E28; } - for(i = 0; i < 8; i++) { + for (i = 0; i < 8; i++) { D_800E2D78[i].unk6 = D_800E2DF8[i].unk0 + D_800E2E28; D_800E2D78[i].unkA = D_800E2DF8[i].unk2 + D_800E2E28; D_800E2D78[i].unkE = D_800E2DF8[i].unk4 + D_800E2E28; @@ -554,7 +549,7 @@ void func_800AF6E4(Object *obj, s32 arg1) { Object_6C *obj6C; obj6C = &obj->unk6C[arg1]; - + obj6C->unk4 &= 0x7FFF; obj->unk1A--; } @@ -573,7 +568,7 @@ GLOBAL_ASM("asm/non_matchings/particles/func_800B2040.s") void func_800B2260(unk800B2260 *arg0) { unk800B2260_C *temp_v0; s32 i; - + if (arg0->unk4 & 0x400) { if (arg0->unkC != NULL) { for (i = 0; i < arg0->unk6; i++) { @@ -595,13 +590,13 @@ GLOBAL_ASM("asm/non_matchings/particles/func_800B22FC.s") void func_800B263C(unk800B2260_C *arg0) { unk800B2260 *temp_v0; s32 i; - + temp_v0 = (unk800B2260 *)arg0->unk70; if (temp_v0 != NULL) { if (temp_v0->unk6 != 0) { if (arg0 == temp_v0->unkC[arg0->unk74]) { temp_v0->unk6--; - for(i = arg0->unk74; i < temp_v0->unk6; i++) { + for (i = arg0->unk74; i < temp_v0->unk6; i++) { temp_v0->unkC[i] = temp_v0->unkC[i + 1]; temp_v0->unkC[i]->unk74 = i; } diff --git a/src/printf.c b/src/printf.c index ca146036..035f83d1 100644 --- a/src/printf.c +++ b/src/printf.c @@ -31,15 +31,15 @@ u8 D_800E2EF4[196] = { }; Gfx D_800E2FB8[] = { - gsDPPipeSync(), + gsDPPipeSync(), gsDPSetCycleType(G_CYC_1CYCLE), gsDPSetTextureLOD(G_TL_TILE), gsDPSetTextureLUT(G_TT_NONE), - gsDPSetTextureDetail(G_TD_CLAMP), + gsDPSetTextureDetail(G_TD_CLAMP), gsDPSetTexturePersp(G_TP_NONE), gsDPSetTextureFilter(G_TF_BILERP), - gsDPSetTextureConvert(G_TC_FILT), - gsDPSetAlphaCompare(G_AC_NONE), + gsDPSetTextureConvert(G_TC_FILT), + gsDPSetAlphaCompare(G_AC_NONE), gsDPSetRenderMode(G_RM_XLU_SURF, G_RM_XLU_SURF2), gsDPSetEnvColor(255, 255, 255, 255), gsDPSetPrimColor(0, 0, 0, 0, 0, 0), diff --git a/src/screen_asset.c b/src/screen_asset.c index d96945c8..6d1b2e0a 100644 --- a/src/screen_asset.c +++ b/src/screen_asset.c @@ -19,17 +19,17 @@ u8 *load_screen(s32 screenIndex) { u8 *someAddr; s32 screenTableCount, start, size; s32 *screenTable; - + screenTable = (u8 *)load_asset_section_from_rom(ASSET_SCREENS_TABLE); screenTableCount = 0; - - while(screenTable[screenTableCount] != -1) { + + while (screenTable[screenTableCount] != -1) { screenTableCount++; } - + screenTableCount--; - - // screenTableCount will always be 0 in vanilla DKR, + + // screenTableCount will always be 0 in vanilla DKR, // since there are no screen assets in the ROM. if (screenTableCount == 0) { free_from_memory_pool(screenTable); @@ -39,14 +39,14 @@ u8 *load_screen(s32 screenIndex) { rmonPrintf("SCREEN: No out of range!!\n"); screenIndex = 0; } - + start = screenTable[screenIndex]; size = screenTable[screenIndex + 1] - start; someAddr = allocate_from_main_pool_safe(size, COLOR_TAG_BLUE); - + load_asset_to_address(ASSET_SCREENS, someAddr, start, size); free_from_memory_pool(screenTable); - + return someAddr; } } @@ -57,27 +57,25 @@ u8 *load_screen(s32 screenIndex) { */ void render_screen(Gfx **dlist, u8 *screenAddress) { s32 y_pos; - - gDkrDmaDisplayList((*dlist)++, (u32)&gRdpSetModeScreenAsset + 0x80000000, - numberOfGfxCommands(gRdpSetModeScreenAsset)) - + + gDkrDmaDisplayList((*dlist)++, (u32)&gRdpSetModeScreenAsset + 0x80000000, numberOfGfxCommands(gRdpSetModeScreenAsset)); + // Screen header is 16 bytes. screenAddress += 16; - + // Draw each 320x6 RGBA16 slice until the screen image is fully drawn. y_pos = 0; - while(y_pos != SCREEN_HEIGHT) { + while (y_pos != SCREEN_HEIGHT) { // Load the texture. - gDPLoadTextureBlockS((*dlist)++, screenAddress + 0x80000000, G_IM_FMT_RGBA, G_IM_SIZ_16b, - SCREEN_WIDTH, SCREEN_HEIGHT_PART, 0, G_TX_CLAMP, G_TX_CLAMP, 0, 0, 0, 0) - + gDPLoadTextureBlockS((*dlist)++, screenAddress + 0x80000000, G_IM_FMT_RGBA, G_IM_SIZ_16b, + SCREEN_WIDTH, SCREEN_HEIGHT_PART, 0, G_TX_CLAMP, G_TX_CLAMP, 0, 0, 0, 0); + // Draw the texture. - gSPTextureRectangle((*dlist)++, 0, ((y_pos) << 2), SCREEN_WIDTH << 2, - ((y_pos + SCREEN_HEIGHT_PART) << 2), 0, 0, 0, 1 << 12, 1 << 10) - + gSPTextureRectangle((*dlist)++, 0, ((y_pos) << 2), SCREEN_WIDTH << 2, + ((y_pos + SCREEN_HEIGHT_PART) << 2), 0, 0, 0, 1 << 12, 1 << 10); + // Advance to the next slice. screenAddress += SCREEN_WIDTH * SCREEN_HEIGHT_PART * 2; y_pos += SCREEN_HEIGHT_PART; } } - diff --git a/src/stacks.c b/src/stacks.c index 7dedc8a9..772ccba0 100644 --- a/src/stacks.c +++ b/src/stacks.c @@ -3,7 +3,7 @@ #include "stacks.h" -// This file only contains .bss variables and needs to be located just before +// This file only contains .bss variables and needs to be located just before // waves.c; that is why this is "located" at 0x800B7D1F. /************ .bss ************/ diff --git a/src/textures_sprites.c b/src/textures_sprites.c index 68abf7ef..91f32a8c 100644 --- a/src/textures_sprites.c +++ b/src/textures_sprites.c @@ -681,7 +681,7 @@ Gfx D_800DF1A8[][2] = { gsDPSetCombineMode(DKR_CC_UNK7, DKR_CC_UNK8), gsDPSetOtherMode(DKR_OMH_2CYC_BILERP, DKR_OML_COMMON | G_RM_NOOP | G_RM_OPA_SURF2), }, - { + { gsDPSetCombineMode(DKR_CC_UNK7, DKR_CC_UNK8), gsDPSetOtherMode(DKR_OMH_2CYC_BILERP, DKR_OML_COMMON | G_RM_NOOP | G_RM_AA_OPA_SURF2), }, @@ -793,7 +793,7 @@ Gfx D_800DF1A8[][2] = { gsDPSetCombineMode(DKR_CC_UNK7, DKR_CC_UNK8), gsDPSetOtherMode(DKR_OMH_2CYC_BILERP, DKR_OML_COMMON | G_RM_FOG_SHADE_A | G_RM_XLU_SURF2), }, - { + { gsDPSetCombineMode(DKR_CC_UNK7, DKR_CC_UNK8), gsDPSetOtherMode(DKR_OMH_2CYC_BILERP, DKR_OML_COMMON | G_RM_FOG_SHADE_A | G_RM_AA_XLU_SURF2), }, @@ -808,7 +808,7 @@ Gfx D_800DF1A8[][2] = { }; Gfx D_800DF3A8[] = { - gsDPPipeSync(), + gsDPPipeSync(), gsDPSetTextureLOD(G_TL_TILE), gsDPSetTextureLUT(G_TT_NONE), gsDPSetAlphaCompare(G_AC_NONE), @@ -817,7 +817,7 @@ Gfx D_800DF3A8[] = { }; Gfx D_800DF3D8[] = { - gsDPPipeSync(), + gsDPPipeSync(), gsDPSetTextureLOD(G_TL_TILE), gsDPSetTextureLUT(G_TT_NONE), gsDPSetAlphaCompare(G_AC_NONE), @@ -836,14 +836,13 @@ Gfx D_800DF410[][2] = { gsDPSetOtherMode(DKR_OMH_1CYC_BILERP, DKR_OML_COMMON | G_RM_ZB_CLD_SURF | G_RM_ZB_CLD_SURF2), }, { - gsDPSetCombineMode(DKR_CC_UNK9, G_CC_PASS2), + gsDPSetCombineMode(DKR_CC_UNK9, G_CC_PASS2), gsDPSetOtherMode(DKR_OMH_2CYC_BILERP, DKR_OML_COMMON | G_RM_ZB_CLD_SURF | G_RM_ZB_CLD_SURF2), }, }; /*******************************/ - /************ .rodata ************/ const char D_800E7B30[] = "Error: Texture no %x out of range on load. !!\n"; @@ -961,7 +960,7 @@ TextureHeader *load_texture(s32 arg0) { assetSize = D_80126320[assetTable][assetIndex + 1] - assetOffset; load_asset_to_address(assetSection, gTempTextureHeader, assetOffset, 0x28); numberOfTextures = (gTempTextureHeader->header.numOfTextures >> 8) & 0xFFFF; - + if (!gTempTextureHeader->header.isCompressed) { tex = allocate_from_main_pool((numberOfTextures * 0x60) + assetSize, gTexColorTag); if (tex == NULL) { @@ -1012,15 +1011,15 @@ TextureHeader *load_texture(s32 arg0) { } D_80126344 = 0; texTemp = tex; - alignedAddress = align16((u8*)((s32)texTemp + assetSize)); - for(i = 0; i < numberOfTextures; i++) { + alignedAddress = align16((u8 *)((s32)texTemp + assetSize)); + for (i = 0; i < numberOfTextures; i++) { build_tex_display_list(texTemp, alignedAddress); if (paletteOffset >= 0) { texTemp->ciPaletteOffset = paletteOffset; alignedAddress += 0x30; // I'm guessing it takes 6 f3d commands to load the palette } alignedAddress += 0x60; // I'm guessing it takes 12 f3d commands to load the texture - texTemp = (TextureHeader*)((s32)texTemp + texTemp->textureSize); + texTemp = (TextureHeader *)((s32)texTemp + texTemp->textureSize); } if (gCiPalettesSize >= 0x280) { return NULL; @@ -1040,7 +1039,7 @@ void free_texture(TextureHeader *tex) { if (tex != NULL) { tex->numberOfInstances--; if ((tex->numberOfInstances & 0xFF) <= 0) { - for(i = 0; i < gNumberOfLoadedTextures; i++) { + for (i = 0; i < gNumberOfLoadedTextures; i++) { if (tex == gTextureCache[i].texture) { free_from_memory_pool(tex); gTextureCache[i].id = -1; @@ -1065,7 +1064,7 @@ TextureHeader *func_8007B380(s32 arg0) { return 0; } // Regalloc issue here - if (gTextureCache[arg0].texture == (TextureHeader*)-1) { + if (gTextureCache[arg0].texture == (TextureHeader *)-1) { return 0; } return gTextureCache[arg0].texture; @@ -1081,8 +1080,8 @@ void func_8007B3D0(Gfx **dlist) { D_80126382 = 1; D_80126378 = 0; D_80126384 = 0; - gDPPipeSync((*dlist)++) - gSPSetGeometryMode((*dlist)++, G_SHADING_SMOOTH | G_SHADE | G_ZBUFFER) + gDPPipeSync((*dlist)++); + gSPSetGeometryMode((*dlist)++, G_SHADING_SMOOTH | G_SHADE | G_ZBUFFER); } void func_8007B43C(void) { @@ -1246,7 +1245,7 @@ void func_8007F1E8(unk8007F1E8 *arg0) { arg0->unk11 = arg0->unk15; arg0->unk12 = arg0->unk16; arg0->unk13 = arg0->unk17; - for(i = 0; i < arg0->unk0; i++) { + for (i = 0; i < arg0->unk0; i++) { arg0->unkC += arg0->unk18[i].unk0; } } @@ -1266,7 +1265,7 @@ void init_pulsating_light_data(PulsatingLightData *data) { void update_pulsating_light_data(PulsatingLightData *data, s32 timeDelta) { s32 thisFrameIndex, nextFrameIndex; - + if (data->numberFrames > 1) { data->time += timeDelta; while (data->time >= data->totalTime) { @@ -1284,9 +1283,9 @@ void update_pulsating_light_data(PulsatingLightData *data, s32 timeDelta) { if (nextFrameIndex >= data->numberFrames) { nextFrameIndex = 0; } - - data->outColorValue = data->frames[thisFrameIndex].value + - ((data->frames[nextFrameIndex].value * data->time) / data->frames[thisFrameIndex].time); + + data->outColorValue = data->frames[thisFrameIndex].value + + ((data->frames[nextFrameIndex].value * data->time) / data->frames[thisFrameIndex].time); } } @@ -1296,10 +1295,10 @@ void func_8007F594(Gfx **dlist, u32 index, u32 primitiveColor, u32 environmentCo index = 2; } // There are issues with the structure, but this should be equivalent functionality-wise. - gSPDisplayList((*dlist)++, D_800DF3A8) - gDkrDmaDisplayList((*dlist)++, &D_800DF410[index] + 0x80000000, numberOfGfxCommands(D_800DF410[0])) - gDPSetPrimColorRGBA((*dlist)++, primitiveColor) - gDPSetEnvColorRGBA((*dlist)++, environmentColor) + gSPDisplayList((*dlist)++, D_800DF3A8); + gDkrDmaDisplayList((*dlist)++, &D_800DF410[index] + 0x80000000, numberOfGfxCommands(D_800DF410[0])); + gDPSetPrimColorRGBA((*dlist)++, primitiveColor); + gDPSetEnvColorRGBA((*dlist)++, environmentColor); } #else GLOBAL_ASM("asm/non_matchings/textures_sprites/func_8007F594.s") diff --git a/src/thread0_epc.c b/src/thread0_epc.c index 5e04cf0c..c8b104b2 100644 --- a/src/thread0_epc.c +++ b/src/thread0_epc.c @@ -98,14 +98,14 @@ void func_800B6F40(s32 arg0, s32 arg1, s32 arg2) { #ifdef NON_MATCHING void func_800B6F50(void) { s32 i; - + // Almost matching, just have an issue with argument 4. // The -O2 compiler is too smart. :( osCreateThread(&D_801295E0, 0, thread0_Main, 0, &D_801295E0, 255); - + osStartThread(&D_801295E0); - - for(i = 0; i < 3; i++) { + + for (i = 0; i < 3; i++) { D_80129FB0[i] = -1; } } @@ -117,14 +117,14 @@ GLOBAL_ASM("asm/non_matchings/thread0_epc/func_800B6F50.s") void thread0_Main(s32 arg0) { // Has regalloc issues s32 sp34; s32 s0 = 0; - + osCreateMesgQueue(&D_80129790, &D_801297A8, 8); osSetEventMesg(12, &D_80129790, 8); osSetEventMesg(10, &D_80129790, 2); osCreatePiManager(150, &D_801297E8, &D_801297C8, 8); - - while(1) { - while(1) { + + while (1) { + while (1) { osRecvMesg(&D_80129790, &sp34, 1); if (!(get_filtered_cheats() & CHEAT_EPC_LOCK_UP_DISPLAY)) { continue; @@ -146,7 +146,7 @@ GLOBAL_ASM("asm/non_matchings/thread0_epc/thread0_Main.s") void func_800B70D0(void) { OSThread *node = __osGetActiveQueue(); - while(node->priority != -1) { + while (node->priority != -1) { if (node->priority == 0) { node->context.sr &= 0xFFFF00FE; node->context.sr |= 0x6C01; @@ -201,7 +201,7 @@ void func_800B7460(s32 *epc, s32 size, s32 mask) { } } func_800766D4(0, -1, &D_800E8EE8, &D_800E8EF0, &sp40, 0x800); - while(1); // Infinite loop; waiting for the player to reset the console? + while (1); // Infinite loop; waiting for the player to reset the console? } } #endif @@ -219,7 +219,7 @@ s32 func_800B76DC(void) { u8 *sp420[256]; u8 *sp220[128]; u8 *dataFromControllerPak[128]; - + if (D_800E3020 != -1) { return D_800E3020; } else { @@ -227,8 +227,7 @@ s32 func_800B76DC(void) { if ((func_800758DC(controllerIndex) == 0) && //Rumble pack check? (func_800764E8(controllerIndex, &D_800E8EF4, &D_800E8EFC, &fileNum) == 0) && (read_data_from_controller_pak(controllerIndex, fileNum, &dataFromControllerPak, - sizeof(dataFromControllerPak) * MAXCONTROLLERS) == 0)) - { + sizeof(dataFromControllerPak) * MAXCONTROLLERS) == 0)) { bcopy(&dataFromControllerPak, &gEpcInfo, sizeof(dataFromControllerPak) - 80); //Why less 80 (0x50)? bcopy(&sp220, &D_801299B0, sizeof(sp220)); bcopy(&sp420, &D_80129BB0, sizeof(sp420)); @@ -250,7 +249,6 @@ void func_800B77D4(s32 arg0) { } } - #if 1 GLOBAL_ASM("asm/non_matchings/thread0_epc/render_epc_lock_up_display.s") #else @@ -262,11 +260,11 @@ void render_epc_lock_up_display(void) { sp50[0] = D_800E302C[0]; // "setup" sp50[1] = D_800E302C[1]; // "control" sp50[2] = D_800E302C[2]; // "print" - + s3 = 0; - + set_render_printf_position(0x10, 0x20); - + switch (D_800E3024) { case 0: D_80129FB0[0] = gEpcInfo.unk130; @@ -278,7 +276,7 @@ void render_epc_lock_up_display(void) { render_printf(" cause\t\t0x%08x\n", gEpcInfo.cause); render_printf(" sr\t\t0x%08x\n", gEpcInfo.sr); render_printf(" badvaddr\t0x%08x\n", gEpcInfo.badvaddr); - for(i = 0; i < 3; i++) { + for (i = 0; i < 3; i++) { if (D_80129FB0[i] != -1) { if (s3 == 0) { s3 = 1; @@ -301,7 +299,7 @@ void render_epc_lock_up_display(void) { } else { // gEpcInfo.cause == -1 render_printf(" epc\t\t0x%08x\n", gEpcInfo.epc); render_printf(" cause\t\tmmAlloc(%d,0x%8x)\n", gEpcInfo.a0, gEpcInfo.a1); - for(i = 0; i < 3; i++) { + for (i = 0; i < 3; i++) { if (D_80129FB0[i] != -1) { if (s3 == 0) { s3 = 1; @@ -318,8 +316,10 @@ void render_epc_lock_up_display(void) { break; default: for (i = 0; i < 16; i++) { - render_printf(" %08x %08x %08x\n", - D_801299B0[i - 1], D_801299B0[i - 1 + 16], D_801299B0[i - 1 + 32]); + render_printf(" %08x %08x %08x\n", + D_801299B0[i - 1], + D_801299B0[i - 1 + 16], + D_801299B0[i - 1 + 32]); } break; case 4: diff --git a/src/thread30.c b/src/thread30.c index ce032d69..4478a4c4 100644 --- a/src/thread30.c +++ b/src/thread30.c @@ -29,7 +29,7 @@ s32 D_8012ACC0[1305]; // Unused? Might be another stack. // Currently defined in osViMgr.c // There are a few stacks defined next to each other. Maybe they are in their own separate file? -extern void *gThread30Stack; +extern void *gThread30Stack; /*****************************/ @@ -99,11 +99,11 @@ s32 set_level_to_load_in_background(s32 levelId, s32 cutsceneId) { */ void thread30(void *arg) { OSMesg mesg = 0; - while(TRUE){ + while (TRUE) { // Wait for a signal from the main thread do { osRecvMesg(&gThread30MesgQueue, &mesg, 1); - } while(mesg != (OSMesg)OS_MESG_TYPE_LOOPBACK); + } while (mesg != (OSMesg)OS_MESG_TYPE_LOOPBACK); // -1 means there won't be any racers loaded. load_level_for_menu(gThread30LevelIdToLoad, -1, gThread30CutsceneIdToLoad); gThread30NeedToLoadLevel = FALSE; diff --git a/src/unknown_003260.c b/src/unknown_003260.c index cbdb82ca..e9bb4893 100644 --- a/src/unknown_003260.c +++ b/src/unknown_003260.c @@ -38,18 +38,18 @@ extern f32 gVideoRefreshRate; /************ .data ************/ -s32 D_800DC680 = 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_800DC680 = 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 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. -s32 D_800DC6A4 = 0; // Currently unknown, might be a different type. -s32 D_800DC6A8 = 0; // Currently unknown, might be a different type. -s32 D_800DC6AC = 0; // Currently unknown, might be a different type. +s32 D_800DC694 = 0xFD0; // Size of func_80019808 (for checksum). +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. +s32 D_800DC6A4 = 0; // Currently unknown, might be a different type. +s32 D_800DC6A8 = 0; // Currently unknown, might be a different type. +s32 D_800DC6AC = 0; // Currently unknown, might be a different type. s32 D_800DC6B0 = 0; // Currently unknown, might be a different type. s32 D_800DC6B4 = 0; // Currently unknown, might be a different type. @@ -82,42 +82,40 @@ const char D_800E4B80[] = "WARNING: Attempt to stop NULL sound aborted\n"; GLOBAL_ASM("asm/non_matchings/unknown_003260/audioNewThread.s") #else void audioNewThread(ALSynConfig *c, OSPri p, s32 arg2) { - u32 *reg_v0; - void *reg_s0; - u32 tmp_size; - s32 tmp; + u32 *reg_v0; + void *reg_s0; + u32 tmp_size; + s32 tmp; s32 i; D_80115F90 = arg2; D_80115F94 = c->heap; c->dmaproc = &func_80003008; c->outputRate = osAiSetFrequency(22050); - D_8011962C = (((f32) c->outputRate)*2.0f)/gVideoRefreshRate; - if(D_8011962C < 0){ + D_8011962C = (((f32)c->outputRate) * 2.0f) / gVideoRefreshRate; + if (D_8011962C < 0) { } - if(c->fxType == AL_FX_CUSTOM){ + if (c->fxType == AL_FX_CUSTOM) { reg_v0 = load_asset_section_from_rom(ASSET_AUDIO_TABLE); - tmp_size = reg_v0[9]-reg_v0[8]; + tmp_size = reg_v0[9] - reg_v0[8]; reg_s0 = allocate_from_main_pool_safe(tmp_size, COLOR_TAG_CYAN); - load_asset_to_address(39,reg_s0, reg_v0[8],tmp_size); + load_asset_to_address(39, reg_s0, reg_v0[8], tmp_size); c->params = reg_s0; c[1].maxVVoices = 0; alInit(&ALGlobals_801161D0, c); free_from_memory_pool(reg_s0); - } - else{ + } else { alInit(&ALGlobals_801161D0, c); } D_80119240[0].node.next = NULL; D_80119240[0].node.prev = NULL; - for(i=0; i< 0x30; i++){ - alLink(&(D_80119240[i+1].node), &(D_80119240[i].node)); - D_80119240[i].unk10 = alHeapDBAlloc(0,0,c->heap, 1, 0x400); + for (i = 0; i < 0x30; i++) { + alLink(&(D_80119240[i + 1].node), &(D_80119240[i].node)); + D_80119240[i].unk10 = alHeapDBAlloc(0, 0, c->heap, 1, 0x400); } - D_80119240[i].unk10 = alHeapDBAlloc(0,0, c->heap, 1, 0x400); - alHeapDBAlloc(0,0, c->heap, 1, 120); - + D_80119240[i].unk10 = alHeapDBAlloc(0, 0, c->heap, 1, 0x400); + alHeapDBAlloc(0, 0, c->heap, 1, 120); osCreateMesgQueue(&D_80116198, &D_801161B0, 8); osCreateMesgQueue(&OSMesgQueue_80116160, &D_80116178, 8); @@ -146,7 +144,7 @@ void set_sfx_volume_slider(u32 arg0) { if (arg0 > 256) { arg0 = 256; } - + sfxVolumeSlider = arg0; } @@ -171,26 +169,25 @@ void alSndPNew(audioMgrConfig *c) { gAlSndPlayer->unk48 = c->maxChannels; gAlSndPlayer->unk3C = 0; gAlSndPlayer->frameTime = 33000; - gAlSndPlayer->unk40 = (unk800DC6BC_40 *) alHeapDBAlloc(0, 0, c->hp, 1, (c->unk00) << 6); - alEvtqNew(&(gAlSndPlayer->evtq), alHeapDBAlloc(0,0,c->hp,1, (c->unk04)*28), c->unk04); + gAlSndPlayer->unk40 = (unk800DC6BC_40 *)alHeapDBAlloc(0, 0, c->hp, 1, (c->unk00) << 6); + alEvtqNew(&(gAlSndPlayer->evtq), alHeapDBAlloc(0, 0, c->hp, 1, (c->unk04) * 28), c->unk04); D_800DC6B8 = gAlSndPlayer->unk40; - i=1; - for(i=1; i < c->unk00; i++){ + i = 1; + for (i = 1; i < c->unk00; i++) { tmp1 = gAlSndPlayer->unk40; - alLink( i + tmp1, i + tmp1 - 1); + alLink(i + tmp1, i + tmp1 - 1); } - D_80119C28 = alHeapDBAlloc(0,0,c->hp, 2, c->unk10); - for (i=0; i < c->unk10; i++){ + D_80119C28 = alHeapDBAlloc(0, 0, c->hp, 2, c->unk10); + for (i = 0; i < c->unk10; i++) { D_80119C28[i] = 32767; } - gAlSndPlayer->drvr = alGlobals; gAlSndPlayer->node.next = NULL; gAlSndPlayer->node.handler = &_sndpVoiceHandler; gAlSndPlayer->node.clientData = gAlSndPlayer; - + alSynAddPlayer(gAlSndPlayer->drvr, gAlSndPlayer); sp_38.type = 32; alEvtqPostEvent(&(gAlSndPlayer->evtq), &sp_38, gAlSndPlayer->frameTime); @@ -199,9 +196,9 @@ void alSndPNew(audioMgrConfig *c) { #if 1 GLOBAL_ASM("asm/non_matchings/unknown_003260/_sndpVoiceHandler.s") -#else -ALMicroTime _sndpVoiceHandler(void *node) { - unk800DC6BC *sndp = (unk800DC6BC *) node; +#else +ALMicroTime _sndpVoiceHandler(void *node) { + unk800DC6BC *sndp = (unk800DC6BC *)node; ALSndpEvent evt; do { @@ -211,13 +208,13 @@ ALMicroTime _sndpVoiceHandler(void *node) { evt.snd_event.type = AL_SNDP_API_EVT; alEvtqPostEvent(&sndp->evtq, (ALEvent *)&evt, sndp->frameTime); break; - + default: _handleEvent(sndp, (ALSndpEvent *)&sndp->nextEvent); break; } sndp->nextDelta = alEvtqNextEvent(&sndp->evtq, &sndp->nextEvent); - + } while (sndp->nextDelta == 0); sndp->curTime += sndp->nextDelta; return sndp->nextDelta; @@ -234,13 +231,13 @@ GLOBAL_ASM("asm/non_matchings/unknown_003260/func_80004520.s") void func_80004604(u8 *arg0, u8 arg1) { if (arg0) - arg0[0x36]=arg1; + arg0[0x36] = arg1; } u8 func_8000461C(u8 *arg0) { if (arg0) return arg0[0x3F]; - return 0; + return 0; } void func_80004638(ALBank *bnk, s16 sndIndx, s32 arg2) { @@ -258,9 +255,9 @@ void func_80004668(ALBank *bnk, s16 sndIndx, u8, s32) { void func_8000488C(u8 *arg0) { ALEvent sp_18; sp_18.type = 1024; - ((u32*)(&sp_18))[1] = (u32) arg0; - if(arg0){ - arg0[0x3e] &= ~(1<<4); + ((u32 *)(&sp_18))[1] = (u32)arg0; + if (arg0) { + arg0[0x3e] &= ~(1 << 4); alEvtqPostEvent(&(gAlSndPlayer->evtq), &sp_18, 0); } } @@ -270,15 +267,14 @@ void func_800049D8(void) { func_800048D8(3); } -void func_800049F8(void * sndState,s16 type, u32 arg2) { +void func_800049F8(void *sndState, s16 type, u32 arg2) { ALSndpEvent sndEvt; sndEvt.snd_event.type = type; sndEvt.snd_event.state = sndState; sndEvt.snd_event.unk04 = arg2; - if(sndState){ - alEvtqPostEvent(&(gAlSndPlayer->evtq), &sndEvt,0); + if (sndState) { + alEvtqPostEvent(&(gAlSndPlayer->evtq), &sndEvt, 0); } - } u16 func_80004A3C(u8 arg0) { diff --git a/src/unknown_005740.c b/src/unknown_005740.c index 58f754bf..cfd23262 100644 --- a/src/unknown_005740.c +++ b/src/unknown_005740.c @@ -8,7 +8,7 @@ /************ .data ************/ -s8 D_800DC6D0 = 1; // Currently unknown, might be a u8. +s8 D_800DC6D0 = 1; // Currently unknown, might be a u8. s32 D_800DC6D4 = 0; // Currently unknown, might be a different type. s32 D_800DC6D8 = 1; // Currently unknown, might be a different type. diff --git a/src/unknown_00BC20.c b/src/unknown_00BC20.c index de3618d5..1c70d66d 100644 --- a/src/unknown_00BC20.c +++ b/src/unknown_00BC20.c @@ -48,20 +48,20 @@ s32 D_800DC764 = 0; // Currently unknown, might be a different type. s32 D_800DC768 = 0; // Currently unknown, might be a different type. f32 D_800DC76C[15] = { - 1.0f, 0.70711f, 0.70711f, 1.0f, + 1.0f, 0.70711f, 0.70711f, 1.0f, 0.0f, 0.70711f, -0.70711f, 0.0f, -1.0f, -0.70711f, -0.70711f, -1.0f, - 0.0f, -0.70711f, 0.70711f + 0.0f, -0.70711f, 0.70711f, }; -u16 D_800DC7A8[8] = { - 0x0001, 0x0002, 0x0003, 0x0004, - 0x0051, 0x0054, 0x0055, 0x0056 +u16 D_800DC7A8[8] = { + 0x0001, 0x0002, 0x0003, 0x0004, + 0x0051, 0x0054, 0x0055, 0x0056, }; s16 D_800DC7B8[52] = { - 0x00ED, 0x00FF, 0x0037, 0x0038, - 0x0039, 0x003A, 0x0057, 0x0058, + 0x00ED, 0x00FF, 0x0037, 0x0038, + 0x0039, 0x003A, 0x0057, 0x0058, 0x0059, 0x005A, 0x00F3, 0x00FD, 0x0042, 0x0043, 0x0044, 0x0045, 0x005B, 0x005C, 0x005D, 0x005E, @@ -72,24 +72,25 @@ s16 D_800DC7B8[52] = { 0x0051, 0x0054, 0x0055, 0x0056, 0x00ED, 0x00FF, 0x00D9, 0x00DF, 0x00E0, 0x0105, 0x008A, 0x00DA, - 0x00E8, 0x0115, 0x0118, 0x0000 + 0x00E8, 0x0115, 0x0118, 0x0000, }; s16 D_800DC820[16] = { 0x0005, 0x0106, 0x0207, 0x0005, 0x0106, 0x010B, 0x010B, 0x0207, 0x000C, 0x020D, 0x0101, 0x0101, - 0x0101, 0x0101, 0x0101, 0x0000 + 0x0101, 0x0101, 0x0101, 0x0000, }; - s8 D_800DC840[8] = { 9, 1, 2, 3, 4, 5, 7, 0 }; s8 D_800DC848 = 0; -s32 D_800DC84C[3] = { // Currently unknown, might be a different type. - 0xFF401000, 0x1040FF00, 0x10FF4000 +s32 D_800DC84C[3] = { // Currently unknown, might be a different type. + 0xFF401000, + 0x1040FF00, + 0x10FF4000, }; -s32 D_800DC858 = 0; // Currently unknown, might be a different type. -s32 D_800DC85C = 0x0028FFFF; // Currently unknown, might be a different type. +s32 D_800DC858 = 0; // Currently unknown, might be a different type. +s32 D_800DC85C = 0x0028FFFF; // Currently unknown, might be a different type. u8 D_800DC860 = 0x80; u16 D_800DC864 = 0x0028; @@ -178,7 +179,7 @@ s8 D_8011AE02; s8 D_8011AE03; u32 *D_8011AE08[16]; s32 (*D_8011AE48)[8]; // Unknown number of entries. -u8 (*D_8011AE4C)[8]; // Unknown number of entries. +u8 (*D_8011AE4C)[8]; // Unknown number of entries. s32 D_8011AE50; s32 D_8011AE54; Object **gObjPtrList; // Not sure about the number of elements @@ -239,7 +240,7 @@ s32 D_8011AFE8; s16 D_8011AFEC; s16 D_8011AFEE; s32 D_8011AFF0; -unk800179D0 *D_8011AFF4; +unk800179D0 *D_8011AFF4; s32 D_8011AFF8; s32 D_8011AFFC; s32 D_8011B000; @@ -263,7 +264,7 @@ GLOBAL_ASM("asm/non_matchings/unknown_00BC20/func_8000B020.s") #if 1 GLOBAL_ASM("asm/non_matchings/unknown_00BC20/func_8000B290.s") -#else +#else extern s32 D_800DC754; extern Object *D_800DC75C; extern Object *D_800DC764; @@ -272,7 +273,7 @@ s32 *get_misc_asset(s32 arg0); void func_8000B290() { - if(D_800DC754){ + if (D_800DC754) { free_from_memory_pool(); } get_misc_asset(20); @@ -285,11 +286,11 @@ void func_8000B290() { free_texture(); D_800DC754->unk7C = 0; }*/ - if(D_800DC75C) + if (D_800DC75C) gParticlePtrList_addObject(D_800DC75C); D_800DC75C = NULL; - - if(D_800DC764) + + if (D_800DC764) gParticlePtrList_addObject(D_800DC764); D_800DC764 = NULL; @@ -341,18 +342,18 @@ void func_8000BF8C(void) { gAssetsObjectHeadersTableLength--; D_8011AE48 = (s32 *)allocate_from_main_pool_safe(gAssetsObjectHeadersTableLength * 4, COLOR_TAG_WHITE); D_8011AE4C = (u8 *)allocate_from_main_pool_safe(gAssetsObjectHeadersTableLength, COLOR_TAG_WHITE); - + for (i = 0; i < gAssetsObjectHeadersTableLength; i++) { (*D_8011AE4C)[i] = 0; } - + gAssetsMiscSection = load_asset_section_from_rom(ASSET_MISC); gAssetsMiscTable = load_asset_section_from_rom(ASSET_MISC_TABLE); gAssetsMiscTableLength = 0; while (-1 != gAssetsMiscTable[gAssetsMiscTableLength]) { gAssetsMiscTableLength++; } - + decrypt_magic_codes(&gAssetsMiscSection[gAssetsMiscTable[65]], (gAssetsMiscTable[66] - gAssetsMiscTable[65]) * 4); gObjPtrList = (Object **)allocate_from_main_pool_safe(0x800, COLOR_TAG_BLUE); D_8011ADC4 = 0; @@ -375,7 +376,7 @@ void decrypt_magic_codes(u8 *data, s32 length) { s32 i; //numWords = length / 4; - + for (i = 0; i < length; i++) { sp0 = ((data[i + 3] & 0xC0) >> 6) | (data[i + 0] & 0xC0) | ((data[i + 1] & 0xC0) >> 2) | ((data[i + 2] & 0xC0) >> 4); sp1 = ((data[i + 3] & 0x30) >> 4) | ((data[i + 0] & 0x30) << 2) | (data[i + 1] & 0x30) | ((data[i + 2] & 0x30) >> 2); @@ -391,7 +392,7 @@ void decrypt_magic_codes(u8 *data, s32 length) { void func_8000C460(void) { s32 i; - + D_8011AD26[0] = 1; D_8011AD5C = 0; D_8011AD60 = 0; @@ -404,7 +405,7 @@ void func_8000C460(void) { D_8011AD20[1] = 0; D_8011AD22[0] = 0; D_8011AD22[1] = 0; - + for (i = 0; i < 0x80; i++) { (*D_8011AF04)[i] = 0; } @@ -414,7 +415,7 @@ void func_8000C460(void) { for (i = 0; i < 0x10; i++) { D_8011AFF4[i].unk0 = 0; } - + D_8011AF08[0] = 0xFF; D_8011AF08[1] = 0xFF; objCount = 0; @@ -474,8 +475,7 @@ void func_8000C844(s32 arg0) { s32 func_8000C8B4(s32 arg0) { if (osTvType != 0 || arg0 < 0) { return arg0; - } - else { + } else { return (arg0 * 5) / 6; } } @@ -484,7 +484,7 @@ GLOBAL_ASM("asm/non_matchings/unknown_00BC20/func_8000C8F8.s") void func_8000CBC0(void) { s32 i = 0; - while(i < 16){ // For some odd reason, using a for loop here makes this not match. + while (i < 16) { // For some odd reason, using a for loop here makes this not match. D_8011AE08[i] = NULL; i++; } @@ -501,7 +501,7 @@ void func_8000CBF0(u32 *arg0, s32 arg1) { return; // I can't get this second return to appear. } D_8011AE08[arg1] = arg0; - return; + return; } #endif @@ -510,7 +510,7 @@ s32 func_8000CC20(u32 *arg0) { s32 phi_v1; phi_v1 = -1; - for(i = 0; i < 0x10; i++){ + for (i = 0; i < 0x10; i++) { if (D_8011AE08[i] == 0) { phi_v1 = i; i = 0x10; @@ -526,7 +526,7 @@ s32 func_8000CC20(u32 *arg0) { GLOBAL_ASM("asm/non_matchings/unknown_00BC20/func_8000CC7C.s") u32 func_8000E0B0(void) { - switch(D_8011AD38) { + switch (D_8011AD38) { case 1: return -1; case 7: @@ -561,8 +561,7 @@ s8 func_8000E148() { s8 func_8000E158(void) { if (D_800DC740 != 0) { return D_800DC73C; - } - else { + } else { return 0; } } @@ -627,7 +626,6 @@ GLOBAL_ASM("asm/non_matchings/unknown_00BC20/func_8000E5EC.s") GLOBAL_ASM("asm/non_matchings/unknown_00BC20/func_8000E79C.s") GLOBAL_ASM("asm/non_matchings/unknown_00BC20/func_8000E898.s") - Object *get_object(s32 index) { if (index < 0 || index >= objCount) { return 0; @@ -655,9 +653,9 @@ void func_8000E9D0(Object *arg0) { arg0->unk6 |= 0x8000; func_800245B4(arg0->unk2C | 0xC000); gObjPtrList[objCount++] = arg0; - if(1); + if (1); D_8011AE64++; -} +} GLOBAL_ASM("asm/non_matchings/unknown_00BC20/func_8000EA54.s") GLOBAL_ASM("asm/non_matchings/unknown_00BC20/func_8000F648.s") @@ -682,7 +680,6 @@ s32 func_8000FD34(unk8000FD34 *arg0, s32 arg1) { GLOBAL_ASM("asm/non_matchings/unknown_00BC20/func_8000FD54.s") - void gParticlePtrList_addObject(Object *object) { func_800245B4(object->unk4A | 0x8000); gParticlePtrList[gParticleCount] = object; @@ -703,37 +700,36 @@ GLOBAL_ASM("asm/non_matchings/unknown_00BC20/gParticlePtrList_flush.s") //bad regalloc; swap s2 = s3 /*removes objects in particleList from gObjPtrList and frees*/ void gParticlePtrList_flush(void) { - s32 j, i, search_indx, tmp; + s32 j, i, search_indx, tmp; Object *searchObj; - + D_8011AE88 = 0; - for (i = 0; i < gParticleCount; i++){ + for (i = 0; i < gParticleCount; i++) { search_indx = -1; searchObj = gParticlePtrList[i]; - - for(j = 0; j < objCount; j++){ - if(searchObj == gObjPtrList[j]) + + for (j = 0; j < objCount; j++) { + if (searchObj == gObjPtrList[j]) search_indx = j; } //if object found - if(search_indx != -1){ + if (search_indx != -1) { tmp = D_8011AE7C; - if(search_indx < D_8011AE7C) - D_8011AE7C = tmp-1; - + if (search_indx < D_8011AE7C) + D_8011AE7C = tmp - 1; + objCount--; - for(j = search_indx; j < objCount; j++){ - gObjPtrList[j] = gObjPtrList[j+1]; + for (j = search_indx; j < objCount; j++) { + gObjPtrList[j] = gObjPtrList[j + 1]; } } - func_800101AC(searchObj,0); + func_800101AC(searchObj, 0); } gParticleCount = 0; } #endif - GLOBAL_ASM("asm/non_matchings/unknown_00BC20/func_800101AC.s") GLOBAL_ASM("asm/non_matchings/unknown_00BC20/func_80010994.s") GLOBAL_ASM("asm/non_matchings/unknown_00BC20/func_80011134.s") @@ -766,11 +762,8 @@ GLOBAL_ASM("asm/non_matchings/unknown_00BC20/func_80011570.s") #if 1 GLOBAL_ASM("asm/non_matchings/unknown_00BC20/func_80011960.s") #else -void func_80011960(Object *arg0, s32 arg2, u32 arg3, Object_64 *arg4 - , u32 arg5 , u32 arg6 , u32 arg7, u32 arg8, f32 arg9) -{ - - +void func_80011960(Object *arg0, s32 arg2, u32 arg3, Object_64 *arg4, + u32 arg5, u32 arg6, u32 arg7, u32 arg8, f32 arg9) { } #endif @@ -781,46 +774,44 @@ extern f32 D_800E5550; void func_80011AD0(Object *this) { f32 tmp_f0; u32 offset; - switch(this->unk48){ + switch (this->unk48) { case 47: //L80011B10 - if(this->unk7C.word < 0) + if (this->unk7C.word < 0) break; - func_80011960( this, this->unk64->unk20, 4, this->unk64 - , 2, this->unk64->unk24, 11, 0, 1.0f); + func_80011960(this, this->unk64->unk20, 4, this->unk64, + 2, this->unk64->unk24, 11, 0, 1.0f); break; case 61: //L80011B58 - offset = (this->unk64->unkFC*6); + offset = (this->unk64->unkFC * 6); offset *= 5; - offset = offset*2 + 0x80; - func_80011960(this, offset, 6, this->unk64 - , 8, this->unk64->unkF8, 10, 0, 1.0f); + offset = offset * 2 + 0x80; + func_80011960(this, offset, 6, this->unk64, 8, this->unk64->unkF8, 10, 0, 1.0f); break; - case 3://L80011BB4 - tmp_f0 = (f32) this->unk3C->unkD; - if(this->unk3C->unkD < 0){ + case 3: //L80011BB4 + tmp_f0 = (f32)this->unk3C->unkD; + if (this->unk3C->unkD < 0) { tmp_f0 += 4294967296.0f; } - offset = (this->unk64->unkFC*6); + offset = (this->unk64->unkFC * 6); offset *= 5; - offset = offset*2 + 0x80; - func_80011960(this, offset, 6, this->unk64 - , 8, this->unk64->unkF8, 26, 0, tmp_f0 * D_800E5550); + offset = offset * 2 + 0x80; + func_80011960(this, offset, 6, this->unk64, 8, this->unk64->unkF8, 26, 0, tmp_f0 * D_800E5550); break; case 89: //L80011C38 - if(this->unk78 == 0) + if (this->unk78 == 0) break; - if(this->unk64->unk70 > 0 || 0.0f < this->unk64->unk74){ + if (this->unk64->unk70 > 0 || 0.0f < this->unk64->unk74) { func_800135B8(this); } break; default: break; - }//L80011C88 + } //L80011C88 } #endif @@ -831,25 +822,25 @@ void func_80012C30(void) { D_8011ADA4 = 0; } -void func_80012C3C(Gfx** dlist) { +void func_80012C3C(Gfx **dlist) { s32 i; Gfx *tmp; - for(i = 0; iunk6 & 0x5000) + if (object->unk6 & 0x5000) return; func_800B76B8(2, object->unk4A); D_8011AE8C = *arg0; @@ -877,30 +868,29 @@ void func_80012D5C(u32 *arg0, u32 *arg1, u32 *arg2, Object *object) { GLOBAL_ASM("asm/non_matchings/unknown_00BC20/func_80012E28.s") #else void func_80012E28(Object *this) { - s32 unused1; - Object_64 *sp_20; - f32 tmp_f2; - f32 sp_1c; - f32 tmp_f0; - + s32 unused1; + Object_64 *sp_20; + f32 tmp_f2; + f32 sp_1c; + f32 tmp_f0; + + if (this->unk48 == 1) { - if(this->unk48 == 1){ - sp_20 = this->unk64; this->y_rotation += sp_20->unk160; this->x_rotation += sp_20->unk162; this->z_rotation += sp_20->unk164; sp_1c = 0.0f; - if(sp_20->unk1D7 < 5) { - + if (sp_20->unk1D7 < 5) { + sp_1c = func_800707F8(sp_20->unk164); tmp_f2 = sp_1c; - tmp_f0 = func_800707F8(sp_20->unk162 - sp_20->unk166)*tmp_f2; - + tmp_f0 = func_800707F8(sp_20->unk162 - sp_20->unk166) * tmp_f2; + //bad regalloc of 0.0f - tmp_f0 = (tmp_f0 < 0.0f) ? 0.0f : tmp_f0*tmp_f0; - - sp_1c = (1.0f - tmp_f0)*24.0f + sp_20->unkD0; + tmp_f0 = (tmp_f0 < 0.0f) ? 0.0f : tmp_f0 * tmp_f0; + + sp_1c = (1.0f - tmp_f0) * 24.0f + sp_20->unkD0; } //L80012F0C this->y_position = this->y_position + sp_1c; @@ -924,15 +914,14 @@ GLOBAL_ASM("asm/non_matchings/unknown_00BC20/func_80012F94.s") void render_object(Object *this) { func_80012F94(this); - if(this->unk6 & 0x8000){ + if (this->unk6 & 0x8000) { func_800B3740(this, &D_8011AE8C, &D_8011AE90, &D_8011AE94, 32768); - } - else{ - if(this->descriptor_ptr->unk53 == 0) + } else { + if (this->descriptor_ptr->unk53 == 0) render_3d_model(this); - else if(this->descriptor_ptr->unk53 == 1) + else if (this->descriptor_ptr->unk53 == 1) render_3d_billboard(this); - else if(this->descriptor_ptr->unk53 == 4) + else if (this->descriptor_ptr->unk53 == 4) func_80011AD0(this); } func_80013548(this); @@ -953,23 +942,22 @@ GLOBAL_ASM("asm/non_matchings/unknown_00BC20/func_80013DCC.s") GLOBAL_ASM("asm/non_matchings/unknown_00BC20/func_80014090.s") void func_800142B8(void) { - s32 i = D_8011AE60; + s32 i = D_8011AE60; s32 j; Object *currObj; Object_68 *curr_68; - for(; i < objCount; i++){ + for (; i < objCount; i++) { currObj = gObjPtrList[i]; - if( (currObj->unk6 & 0x8000) == 0 && currObj->descriptor_ptr->unk53 == 0){ - for(j=0; jdescriptor_ptr->unk55; j++){ + if ((currObj->unk6 & 0x8000) == 0 && currObj->descriptor_ptr->unk53 == 0) { + for (j = 0; j < currObj->descriptor_ptr->unk55; j++) { curr_68 = currObj->unk68[j]; - if( curr_68 != NULL && curr_68->unk20 > 0){ + if (curr_68 != NULL && curr_68->unk20 > 0) { curr_68->unk20 = curr_68->unk20-- & 0x03; } } } } - } GLOBAL_ASM("asm/non_matchings/unknown_00BC20/func_800143A8.s") @@ -991,8 +979,8 @@ GLOBAL_ASM("asm/non_matchings/unknown_00BC20/func_80017978.s") u32 func_800179D0(void) { s16 i = 0; - while(i < 16) { - unk800179D0 *temp = &D_8011AFF4[i]; + while (i < 16) { + unk800179D0 *temp = &D_8011AFF4[i]; if (temp->unk0 != 0) { temp->unk0--; } @@ -1017,9 +1005,9 @@ GLOBAL_ASM("asm/non_matchings/unknown_00BC20/func_800185E4.s") Object *func_80018C6C(void) { s32 i; Object *current_obj; - for(i=D_8011AE60; i < objCount; i++){ + for (i = D_8011AE60; i < objCount; i++) { current_obj = gObjPtrList[i]; - if(!(current_obj->unk6 & 0x8000) && (current_obj->unk48 == 62)) + if (!(current_obj->unk6 & 0x8000) && (current_obj->unk48 == 62)) return current_obj; } return NULL; @@ -1108,7 +1096,7 @@ unknown8011AECC *func_8001BA00(s32 arg0) { unknown8011AECC *func_8001BA1C(s32 arg0, s32 arg1) { unknown8011AECC *val = &D_8011AECC[arg0]; if (arg1 != 0 && val->unk3A != -1) { - val = &D_8011AECC[val->unk3A]; + val = &D_8011AECC[val->unk3A]; } return val; } @@ -1136,7 +1124,7 @@ Object *get_object_struct(s32 indx) { if (gObjectCount == 0) { return NULL; } - if(indx < 0 || indx >= gObjectCount) { + if (indx < 0 || indx >= gObjectCount) { return NULL; } return (*gObjectStructArrayPtr)[indx]; @@ -1146,12 +1134,10 @@ GLOBAL_ASM("asm/non_matchings/unknown_00BC20/func_8001BB18.s") GLOBAL_ASM("asm/non_matchings/unknown_00BC20/func_8001BB68.s") void func_8001BC40(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { - } GLOBAL_ASM("asm/non_matchings/unknown_00BC20/func_8001BC54.s") - u32 func_8001BD94(s32 arg0) { if (arg0 < 0 || arg0 >= D_8011AEE0) { return 0; @@ -1192,7 +1178,6 @@ u32 func_8001D214(s32 arg0) { } void func_8001D23C(s32 arg0, s32 arg1, s32 arg2) { - } GLOBAL_ASM("asm/non_matchings/unknown_00BC20/func_8001D258.s") @@ -1204,10 +1189,10 @@ void calc_dyn_light_and_env_map_for_object(ObjectModel *model, Object *object, s s16 environmentMappingEnabled; s32 dynamicLightingEnabled; s16 i; - + dynamicLightingEnabled = 0; environmentMappingEnabled = 0; - + for (i = 0; i < model->numberOfBatches; i++) { if (model->batches[i].unk6 != 0xFF) { dynamicLightingEnabled = -1; // This is a bit weird, but I guess it works. @@ -1216,7 +1201,7 @@ void calc_dyn_light_and_env_map_for_object(ObjectModel *model, Object *object, s environmentMappingEnabled = -1; } } - + if (dynamicLightingEnabled) { // Calculates dynamic lighting for the object if (object->descriptor_ptr->unk71 != 0) { @@ -1227,7 +1212,7 @@ void calc_dyn_light_and_env_map_for_object(ObjectModel *model, Object *object, s calc_dynamic_lighting_for_object_2(object, model, arg2, arg3); } } - + if (environmentMappingEnabled) { // Calculates environment mapping for the object calc_env_mapping_for_object(model, object->z_rotation, object->x_rotation, object->y_rotation); @@ -1246,7 +1231,7 @@ s32 *get_misc_asset(s32 index) { if (index < 0 || index >= gAssetsMiscTableLength) { return gAssetsMiscSection; } - return (s32*)&gAssetsMiscSection[gAssetsMiscTable[index]]; + return (s32 *)&gAssetsMiscSection[gAssetsMiscTable[index]]; } s32 func_8001E2EC(s32 arg0) { @@ -1272,14 +1257,13 @@ void func_8001E36C(s32 arg0, f32 *arg1, f32 *arg2, f32 *arg3) { *arg1 = -32000.0f; *arg2 = -32000.0f; *arg3 = -32000.0f; - for(i=0; iunk6 & 0x8000) == 0 - && current_obj->unk48 == 39 - && current_obj->unk78 == arg0 - ){ + if (current_obj != NULL + && (current_obj->unk6 & 0x8000) == 0 + && current_obj->unk48 == 39 + && current_obj->unk78 == arg0) { *arg1 = current_obj->x_position; *arg2 = current_obj->y_position; *arg3 = current_obj->z_position; @@ -1381,7 +1365,6 @@ f32 func_800228B0(f32 *arg0, u32 arg1, f32 arg2, f32 *arg3) { // Unused? void func_800228DC(s32 arg0, s32 arg1, s32 arg2) { - } void func_800228EC(s32 arg0) { @@ -1405,7 +1388,7 @@ GLOBAL_ASM("asm/non_matchings/unknown_00BC20/func_800230D0.s") s8 func_8002341C(void) { return D_8011AEF6; } -#if 1 +#if 1 GLOBAL_ASM("asm/non_matchings/unknown_00BC20/func_8002342C.s") #else @@ -1413,7 +1396,7 @@ extern f32 sqrtf(f32); //bad regalloc //finds furthest object (with some additional conditions) -Object *func_8002342C(f32 x, f32 z){ +Object *func_8002342C(f32 x, f32 z) { Object *retval = NULL; s32 i; Object *currObj = NULL; @@ -1421,15 +1404,15 @@ Object *func_8002342C(f32 x, f32 z){ f32 z; f32 dist; f32 max = 0.0f; - - for(i=0; iunk6 & 0x8000) == 0 && currObj->unk48 == 87){ + if ((currObj->unk6 & 0x8000) == 0 && currObj->unk48 == 87) { x = currObj->x_position - x; z = currObj->z_position - z; - dist = sqrtf(x*x + z*z); + dist = sqrtf(x * x + z * z); - if(max < dist){ + if (max < dist) { max = dist; retval = currObj; } @@ -1725,251 +1708,250 @@ GLOBAL_ASM("asm/non_matchings/unknown_00BC20/func_80023E30.s") void run_object_loop_func(Object *obj, s32 arg1) { func_800B76B8(1, obj->unk4A); switch (obj->unk48) { - case 2: - func_80033DD0(obj, arg1); - break; - case 3: - func_800370D4(obj, arg1); - break; - case 4: - func_800377E4(obj, arg1); - break; - case 6: - func_800389B8(obj, arg1); - break; - case 25: - func_80038A78(obj, arg1); - break; - case 22: - func_80038BF4(obj, arg1); - break; - case 7: - func_80038F58(obj, arg1); - break; - case 10: - func_80039184(obj, arg1); - break; - case 11: - func_800391BC(obj, arg1); - break; - case 12: - func_800391FC(obj, arg1); - break; - case 13: - func_8003AD28(obj, arg1); - break; - case 30: - func_8003AE50(obj, arg1); - break; - case 41: - func_8003B174(obj, arg1); - break; - case 14: - func_8003B988(obj, arg1); - break; - case 15: - func_80030A74(obj); - break; - case 16: - func_8003D02C(obj, arg1); - break; - case 17: - func_8003E140(obj, arg1); - break; - case 23: - func_8003E5BC(obj, arg1); - break; - case 5: - case 18: - func_8003E630(obj, arg1); - break; - case 26: - func_8003CF98(obj, arg1); - break; - case 28: - func_80034B4C(obj, arg1); - break; - case 29: - func_80040148(obj, arg1); - break; - case 31: - func_800361E0(obj, arg1); - break; - case 32: - func_8003D5A0(obj, arg1); - break; - case 36: - func_80040448(obj, arg1); - break; - case 67: - func_80040570(obj, arg1); - break; - case 37: - func_80040820(obj, arg1); - break; - case 38: - func_8003CA68(obj, arg1); - break; - case 39: - func_8003CEA0(obj, arg1); - break; - case 40: - func_8003CF0C(obj, arg1); - break; - case 45: - func_80035260(obj, arg1); - break; - case 46: - func_8003564C(obj, arg1); - break; - case 47: - func_80035F6C(obj, arg1); - break; - case 50: - case 81: - case 85: - case 86: - func_80037CE8(obj, arg1); - break; - case 119: - func_80042CD0(obj, arg1); - break; - case 51: - func_80038710(obj, arg1); - break; - case 52: - func_800388D4(obj, arg1); - break; - case 53: - func_800387CC(obj, arg1); - break; - case 54: - func_8003833C(obj, arg1); - break; - case 55: - func_8003C7A4(obj, arg1); - break; - case 56: - func_800380F8(obj, arg1); - break; - case 57: - case 93: - func_8003596C(obj, arg1); - break; - case 58: - func_80035E34(obj, arg1); - break; - case 60: - func_800BFFDC(obj); - break; - case 61: - func_80040C54(obj, arg1); - break; - case 62: - func_80039330(obj, arg1); - break; - case 64: - obj_loop_world_key(obj, arg1); //arg1=speed - break; - case 65: - func_8003D3FC(obj, arg1); - break; - case 66: - func_8003D058(obj, arg1); - break; - case 68: - func_80037594(obj, arg1); - break; - case 69: - func_8003763C(obj, arg1); - break; - case 70: - case 72: - case 103: - case 104: - func_800381C0(obj, arg1); - break; - case 96: - case 97: - case 101: - case 102: - func_8003827C(obj, arg1); - break; - case 73: - func_80034B74(obj, arg1); - break; - case 74: - func_80034E9C(obj, arg1); - break; - case 75: - func_80042090(obj, arg1); - break; - case 76: - func_8003D2B8(obj, arg1); - break; - case 77: - func_8003B4BC(obj, arg1); - break; - case 78: - func_80034860(obj, arg1); - break; - case 79: - func_800345A0(obj, arg1); - break; - case 80: - func_8003ACA0(obj, arg1); - break; - case 82: - func_80035C50(obj, arg1); - break; - case 84: - func_80037D78(obj, arg1); - break; - case 88: - case 110: - func_8003DD14(obj, arg1); - break; - case 90: - func_80038AD4(obj, arg1); - break; - case 94: - func_80042160(obj, arg1); - break; - case 98: - func_80038DC4(obj, arg1); - break; - case 105: - func_80042178(obj, arg1); - break; - case 100: - func_800357D4(obj, arg1); - break; - case 108: - case 116: - func_80033F60(obj, arg1); - break; - case 109: - func_800422F0(obj, arg1); - break; - case 111: - func_8003C2E4(obj, arg1); - break; - case 113: - func_80037D08(obj, arg1); - break; - case 115: - func_80042998(obj, arg1); - break; - case 117: - func_80042A90(obj, arg1); - break; + case 2: + func_80033DD0(obj, arg1); + break; + case 3: + func_800370D4(obj, arg1); + break; + case 4: + func_800377E4(obj, arg1); + break; + case 6: + func_800389B8(obj, arg1); + break; + case 25: + func_80038A78(obj, arg1); + break; + case 22: + func_80038BF4(obj, arg1); + break; + case 7: + func_80038F58(obj, arg1); + break; + case 10: + func_80039184(obj, arg1); + break; + case 11: + func_800391BC(obj, arg1); + break; + case 12: + func_800391FC(obj, arg1); + break; + case 13: + func_8003AD28(obj, arg1); + break; + case 30: + func_8003AE50(obj, arg1); + break; + case 41: + func_8003B174(obj, arg1); + break; + case 14: + func_8003B988(obj, arg1); + break; + case 15: + func_80030A74(obj); + break; + case 16: + func_8003D02C(obj, arg1); + break; + case 17: + func_8003E140(obj, arg1); + break; + case 23: + func_8003E5BC(obj, arg1); + break; + case 5: + case 18: + func_8003E630(obj, arg1); + break; + case 26: + func_8003CF98(obj, arg1); + break; + case 28: + func_80034B4C(obj, arg1); + break; + case 29: + func_80040148(obj, arg1); + break; + case 31: + func_800361E0(obj, arg1); + break; + case 32: + func_8003D5A0(obj, arg1); + break; + case 36: + func_80040448(obj, arg1); + break; + case 67: + func_80040570(obj, arg1); + break; + case 37: + func_80040820(obj, arg1); + break; + case 38: + func_8003CA68(obj, arg1); + break; + case 39: + func_8003CEA0(obj, arg1); + break; + case 40: + func_8003CF0C(obj, arg1); + break; + case 45: + func_80035260(obj, arg1); + break; + case 46: + func_8003564C(obj, arg1); + break; + case 47: + func_80035F6C(obj, arg1); + break; + case 50: + case 81: + case 85: + case 86: + func_80037CE8(obj, arg1); + break; + case 119: + func_80042CD0(obj, arg1); + break; + case 51: + func_80038710(obj, arg1); + break; + case 52: + func_800388D4(obj, arg1); + break; + case 53: + func_800387CC(obj, arg1); + break; + case 54: + func_8003833C(obj, arg1); + break; + case 55: + func_8003C7A4(obj, arg1); + break; + case 56: + func_800380F8(obj, arg1); + break; + case 57: + case 93: + func_8003596C(obj, arg1); + break; + case 58: + func_80035E34(obj, arg1); + break; + case 60: + func_800BFFDC(obj); + break; + case 61: + func_80040C54(obj, arg1); + break; + case 62: + func_80039330(obj, arg1); + break; + case 64: + obj_loop_world_key(obj, arg1); //arg1=speed + break; + case 65: + func_8003D3FC(obj, arg1); + break; + case 66: + func_8003D058(obj, arg1); + break; + case 68: + func_80037594(obj, arg1); + break; + case 69: + func_8003763C(obj, arg1); + break; + case 70: + case 72: + case 103: + case 104: + func_800381C0(obj, arg1); + break; + case 96: + case 97: + case 101: + case 102: + func_8003827C(obj, arg1); + break; + case 73: + func_80034B74(obj, arg1); + break; + case 74: + func_80034E9C(obj, arg1); + break; + case 75: + func_80042090(obj, arg1); + break; + case 76: + func_8003D2B8(obj, arg1); + break; + case 77: + func_8003B4BC(obj, arg1); + break; + case 78: + func_80034860(obj, arg1); + break; + case 79: + func_800345A0(obj, arg1); + break; + case 80: + func_8003ACA0(obj, arg1); + break; + case 82: + func_80035C50(obj, arg1); + break; + case 84: + func_80037D78(obj, arg1); + break; + case 88: + case 110: + func_8003DD14(obj, arg1); + break; + case 90: + func_80038AD4(obj, arg1); + break; + case 94: + func_80042160(obj, arg1); + break; + case 98: + func_80038DC4(obj, arg1); + break; + case 105: + func_80042178(obj, arg1); + break; + case 100: + func_800357D4(obj, arg1); + break; + case 108: + case 116: + func_80033F60(obj, arg1); + break; + case 109: + func_800422F0(obj, arg1); + break; + case 111: + func_8003C2E4(obj, arg1); + break; + case 113: + func_80037D08(obj, arg1); + break; + case 115: + func_80042998(obj, arg1); + break; + case 117: + func_80042A90(obj, arg1); + break; } func_800B76B8(1, -1); } // Unused void func_8002458C(s32 arg0) { - } s16 *func_80024594(s32 *arg0, s32 *arg1) { @@ -1984,4 +1966,3 @@ void func_800245B4(s16 arg0) { D_800DC700 = 0; } } - diff --git a/src/unknown_0255E0.c b/src/unknown_0255E0.c index 359128a3..805c409d 100644 --- a/src/unknown_0255E0.c +++ b/src/unknown_0255E0.c @@ -22,19 +22,18 @@ s32 D_800DC870 = 0; // Currently unknown, might be a different type. unknown800DC874 D_800DC874 = { -128, 40, -1 }; unknown800DC874 D_800DC87C = { -125, 70, -1 }; -f32 D_800DC884[10] = { - 0.0f, 0.125f, 0.25f, 0.375f, - 0.5f, 0.625f, 0.75f, 0.875f +f32 D_800DC884[10] = { + 0.0f, 0.125f, 0.25f, 0.375f, 0.5f, 0.625f, 0.75f, 0.875f }; f32 D_800DC8AC[27] = { - 50.0f, 0.0f, 32.0f, -50.0f, - 0.0f, 32.0f, -50.0f, 100.0f, - 32.0f, 0.0f, 0.0f, 32.0f, - 130.0f, 60.0f, -68.0f, 130.0f, - -60.0f, -68.0f, 0.0f, 0.0f, - 32.0f, -130.0f, -60.0f, -68.0f, - -130.0f, 60.0f, -68.0f + 50.0f, 0.0f, 32.0f, -50.0f, + 0.0f, 32.0f, -50.0f, 100.0f, + 32.0f, 0.0f, 0.0f, 32.0f, + 130.0f, 60.0f, -68.0f, 130.0f, + -60.0f, -68.0f, 0.0f, 0.0f, + 32.0f, -130.0f, -60.0f, -68.0f, + -130.0f, 60.0f, -68.0f, }; LevelModel *gCurrentLevelModel = NULL; @@ -44,10 +43,8 @@ s32 D_800DC920 = -1; s32 D_800DC924 = 0; s32 D_800DC928 = 0; // Currently unknown, might be a different type. -s8 D_800DC92C[24] = { - 0, 1, 4, 1, 2, 4, 2, 3, - 4, 3, 0, 4, 5, 6, 1, 1, - 0, 5, 3, 2, 7, 7, 8, 3 +s8 D_800DC92C[24] = { + 0, 1, 4, 1, 2, 4, 2, 3, 4, 3, 0, 4, 5, 6, 1, 1, 0, 5, 3, 2, 7, 7, 8, 3 // There may or may not be extra zeroes here. }; @@ -174,7 +171,6 @@ s16 D_8011D4B8; s16 D_8011D4BA; s32 D_8011D4BC; - /******************************/ s32 func_800249E0(s32 arg0) { @@ -195,27 +191,27 @@ void func_800249F0(u32 arg0, u32 arg1, s32 arg2, u32 arg3, u32 arg4, u32 arg5, u D_8011B104 = 0; D_8011B108 = 0; D_8011B10C = 0; - if(gCurrentLevelHeader2->race_type == 6 || gCurrentLevelHeader2->race_type == 7){ + if (gCurrentLevelHeader2->race_type == 6 || gCurrentLevelHeader2->race_type == 7) { D_8011B0F8 = 1; } func_8002C0C4(arg0); - if(arg2 < 2){ + if (arg2 < 2) { D_8011D384 = 0; - for(i = 0; i < gCurrentLevelModel->numberOfSegments; i++){ - if(gCurrentLevelModel->segments[i].unk2B != 0){ + for (i = 0; i < gCurrentLevelModel->numberOfSegments; i++) { + if (gCurrentLevelModel->segments[i].unk2B != 0) { D_8011D384++; gCurrentLevelModel->segments[i].unk2B = 1; } } } - if(is_in_two_player_adventure() && (gCurrentLevelHeader2->race_type == 0 || gCurrentLevelHeader2->race_type & 0x40)){ + if (is_in_two_player_adventure() && (gCurrentLevelHeader2->race_type == 0 || gCurrentLevelHeader2->race_type & 0x40)) { tmp_a2 = 2; - }else{ + } else { tmp_a2 = arg2; tmp_a2++; } - if(D_8011D384){ + if (D_8011D384) { func_800B82B4(gCurrentLevelModel, gCurrentLevelHeader2, tmp_a2); } func_8006652C(arg2); @@ -223,34 +219,33 @@ void func_800249F0(u32 arg0, u32 arg1, s32 arg2, u32 arg3, u32 arg4, u32 arg5, u D_8011B110 = 0; D_8011B114 = 0x10000; func_80011390(); - func_8000C8F8(arg6,0); - func_8000C8F8(arg5,1); + func_8000C8F8(arg6, 0); + func_8000C8F8(arg5, 1); D_8011D37C = arg2; func_8000CC7C(arg3, arg4, arg2); func_8000B020(72, 64); - if(arg0 == 0 && arg4 == 0){ + if (arg0 == 0 && arg4 == 0) { func_800C01D8(&D_800DC87C); - } - else{ + } else { func_800C01D8(&D_800DC874); } func_8006652C(D_8011D37C); D_8011B0FC = 0; i = 0; - do{ + do { D_8011D350[i] = allocate_from_main_pool_safe(3200, COLOR_TAG_YELLOW); D_8011D320[i] = allocate_from_main_pool_safe(12800, COLOR_TAG_YELLOW); D_8011D338[i] = allocate_from_main_pool_safe(20000, COLOR_TAG_YELLOW); - }while(&D_8011D338[++i] != &D_8011D348); - + } while (&D_8011D338[++i] != &D_8011D348); + D_8011B0C8 = 0; - func_8002D8DC(1,1,0); - func_8002D8DC(2,2,0); + func_8002D8DC(1, 1, 0); + func_8002D8DC(2, 2, 0); D_8011B0C8 = 1; - func_8002D8DC(1,1,0); - func_8002D8DC(2,2,0); + func_8002D8DC(1, 1, 0); + func_8002D8DC(2, 2, 0); D_8011B0C8 = 0; - if(gCurrentLevelHeader2->unkB7){ + if (gCurrentLevelHeader2->unkB7) { D_8011B0E1 = gCurrentLevelHeader2->unkB4; D_8011B0E2 = gCurrentLevelHeader2->unkB5; D_8011B0E3 = gCurrentLevelHeader2->unkB6; @@ -259,7 +254,6 @@ void func_800249F0(u32 arg0, u32 arg1, s32 arg2, u32 arg3, u32 arg4, u32 arg5, u } #endif - GLOBAL_ASM("asm/non_matchings/unknown_0255E0/func_80024D54.s") GLOBAL_ASM("asm/non_matchings/unknown_0255E0/func_80025510.s") @@ -310,7 +304,7 @@ GLOBAL_ASM("asm/non_matchings/unknown_0255E0/func_80028050.s") #if 1 GLOBAL_ASM("asm/non_matchings/unknown_0255E0/func_800289B8.s") #else -void func_800289B8(void){ +void func_800289B8(void) { u8 sp_2f = gCurrentLevelHeader2->unkC1; u8 sp_2e = gCurrentLevelHeader2->unkC2; u8 sp_2d = gCurrentLevelHeader2->unkC3; @@ -325,19 +319,19 @@ void func_800289B8(void){ #endif void render_skydome(void) { - unk80120AC0 * v0_some_struct; - if(D_8011B0B8 == NULL) + unk80120AC0 *v0_some_struct; + if (D_8011B0B8 == NULL) return; v0_some_struct = func_80069D20(); - if(gCurrentLevelHeader2->unk49 == 0){ + if (gCurrentLevelHeader2->unk49 == 0) { D_8011B0B8->x_position = v0_some_struct->x_position; D_8011B0B8->y_position = v0_some_struct->y_position; D_8011B0B8->z_position = v0_some_struct->z_position; } func_80068408(&D_8011B0A0, &D_8011B0A4); - if(D_8011B0DC){ + if (D_8011B0DC) { func_80012D5C(&D_8011B0A0, &D_8011B0A4, &D_8011B0A8, D_8011B0B8); } } @@ -347,7 +341,6 @@ GLOBAL_ASM("asm/non_matchings/unknown_0255E0/func_80028CD0.s") #endif - void func_80028FA0(s32 arg0) { D_8011B0FC = arg0; } @@ -367,7 +360,7 @@ void render_level_geometry_and_objects(void) { s32 s0; Object *obj; s32 sp44; - + func_80012C30(); if (get_settings()->courseId == 0x24) { // 0x24 = Opening sequence area D_8011B0FC = 1; @@ -380,16 +373,16 @@ void render_level_geometry_and_objects(void) { sp168 = 1; spD8[0] = 0; } - + for (i = 1; i <= gCurrentLevelModel->numberOfSegments; i++) { sp58[i] = FALSE; } sp58[0] = TRUE; - + if (D_8011B0E0 != 0) { for (i = 0; i < sp168; i++) { - render_level_segment(spD8[i], 0); // Render opaque segments - sp58[spD8[i]+1] = TRUE; + render_level_segment(spD8[i], 0); // Render opaque segments + sp58[spD8[i] + 1] = TRUE; } } if (gCurrentLevelModel->numberOfSegments < 2) { @@ -397,7 +390,7 @@ void render_level_geometry_and_objects(void) { } func_8007B3D0(&D_8011B0A0); func_80015348(sp160, sp16C - 1); - + sp158 = 0x200 << (func_80066220() & 1); for (i = sp160; i < sp16C; i++) { obj = get_object(i); @@ -405,8 +398,7 @@ void render_level_geometry_and_objects(void) { objFlags = obj->unk6; if (objFlags & 0x80) { s0 = 0; - } - else if (!(objFlags & 0x8000)) { + } else if (!(objFlags & 0x8000)) { s0 = obj->unk39; } if (objFlags & sp158) { @@ -424,7 +416,7 @@ void render_level_geometry_and_objects(void) { } } } - + i = sp16C - 1; if (i >= sp160) { sp44 = sp160 - 1; @@ -448,7 +440,7 @@ void render_level_geometry_and_objects(void) { } } i--; - } while(i != sp44); + } while (i != sp44); } i = sp168 - 1; if (D_8011B0E0 != 0) { @@ -463,7 +455,7 @@ void render_level_geometry_and_objects(void) { func_8007B3D0(&D_8011B0A0); func_8007B4C8(&D_8011B0A0, 0, 0xA); func_80012C3C(&D_8011B0A0); - + i = sp16C - 1; if (i >= sp160) { sp44 = sp160 - 1; @@ -503,7 +495,7 @@ void render_level_geometry_and_objects(void) { } } i--; - } while(i != sp44); + } while (i != sp44); } if (D_800DC924 && func_80027568()) { func_8002581C(&spD8, sp168, func_80066220()); @@ -539,7 +531,7 @@ void render_level_segment(s32 segmentId, s32 nonOpaque) { s32 textureIndex; s32 textureFlags; s32 temp; - + if (nonOpaque && (D_8011D384 != 0)) { sp78 = func_800B9228(segment); } else { @@ -552,8 +544,8 @@ void render_level_segment(s32 segmentId, s32 nonOpaque) { sp70 = segment->unk40; i = 0; } - - for(; i < sp70; i++) { + + for (; i < sp70; i++) { batchInfo = &segment->batches[i]; flags = batchInfo->flags; textureFlags = 0; @@ -588,28 +580,27 @@ void render_level_segment(s32 segmentId, s32 nonOpaque) { vertices = &segment->vertices[temp_v0]; triangles = &segment->triangles[temp_v1]; levelHeaderIndex = (flags >> 28) & 7; - if (levelHeaderIndex != 0) { // This is unused, so this should always be false. - lvlHeader70 = gCurrentLevelHeader2->unk70;//gCurrentLevelHeader2[levelHeaderIndex].unk70; - gDPSetEnvColor(D_8011B0A0++, lvlHeader70->red, lvlHeader70->green, lvlHeader70->blue, lvlHeader70->alpha) + if (levelHeaderIndex != 0) { // This is unused, so this should always be false. + lvlHeader70 = gCurrentLevelHeader2->unk70; //gCurrentLevelHeader2[levelHeaderIndex].unk70; + gDPSetEnvColor(D_8011B0A0++, lvlHeader70->red, lvlHeader70->green, lvlHeader70->blue, lvlHeader70->alpha); } else { - gDPSetEnvColor(D_8011B0A0++, 255, 255, 255, 0) + gDPSetEnvColor(D_8011B0A0++, 255, 255, 255, 0); } temp = batchInfo->unk7 << 14; if (flags & 0x40000) { // Only gets used in Spaceport alpha for the pulsating lights in the outside section. color = gCurrentLevelHeader2->pulseLightData->outColorValue & 0xFF; - gDPSetPrimColor(D_8011B0A0++, 0, 0, color, color, color, color) + gDPSetPrimColor(D_8011B0A0++, 0, 0, color, color, color, color); func_8007BA5C(&D_8011B0A0, texture, flags, temp); vertices += 0x80000000; - gDkrVertices(D_8011B0A0++, vertices, (((numberVertices - 1) << 3) | (vertices & 6)), numberVertices) - gDkrTriangles(D_8011B0A0++, triangles + 0x80000000, numberTriangles, TRIN_ENABLE_TEXTURE) - gDPSetPrimColor(D_8011B0A0++, 0, 0, 255, 255, 255, 255) // Reset the primitive color + gDkrVertices(D_8011B0A0++, vertices, (((numberVertices - 1) << 3) | (vertices & 6)), numberVertices); + gDkrTriangles(D_8011B0A0++, triangles + 0x80000000, numberTriangles, TRIN_ENABLE_TEXTURE); + gDPSetPrimColor(D_8011B0A0++, 0, 0, 255, 255, 255, 255); // Reset the primitive color } else { func_8007B4E8(&D_8011B0A0, texture, flags, temp); hasTexture = (texture == NULL) ? TRIN_DISABLE_TEXTURE : TRIN_ENABLE_TEXTURE; vertices += 0x80000000; - gDkrVertices(D_8011B0A0++, vertices, (((numberVertices - 1) << 3) | (vertices & 6)), numberVertices) - gDkrTriangles(D_8011B0A0++, triangles + 0x80000000, numberTriangles, hasTexture) - + gDkrVertices(D_8011B0A0++, vertices, (((numberVertices - 1) << 3) | (vertices & 6)), numberVertices); + gDkrTriangles(D_8011B0A0++, triangles + 0x80000000, numberTriangles, hasTexture); } } } @@ -624,8 +615,8 @@ GLOBAL_ASM("asm/non_matchings/unknown_0255E0/render_level_segment.s") void traverse_segments_bsp_tree(s32 nodeIndex, s32 segmentIndex, s32 segmentIndex2, u8 *segmentsOrder, u32 *segmentsOrderIndex) { BspTreeNode *curNode; s32 camValue; - - while(TRUE) { + + while (TRUE) { curNode = &gCurrentLevelModel->segmentsBspTree[nodeIndex]; if (curNode->splitType == 0) { camValue = D_8011B0B0->x_position; // Camera X @@ -695,12 +686,12 @@ s32 func_80029DE0(Object *obj, s32 segmentIndex) { y = obj->y_position; z = obj->z_position; bb = &gCurrentLevelModel->segmentsBoundingBoxes[segmentIndex]; - if ((x < (bb->unk6 + 25)) && ((bb->unk0 - 25) < x) && - (z < (bb->unkA + 25)) && ((bb->unk4 - 25) < z) && + if ((x < (bb->unk6 + 25)) && ((bb->unk0 - 25) < x) && + (z < (bb->unkA + 25)) && ((bb->unk4 - 25) < z) && (y < (bb->unk8 + 25)) && ((bb->unk2 - 25) < y)) { return TRUE; } - + return FALSE; } #else @@ -719,11 +710,11 @@ s32 get_level_segment_index_from_position(f32 xPos, f32 yPos, f32 zPos) { if (gCurrentLevelModel == NULL) { return -1; } - + minVal = 1000000; result = -1; - - for(i = 0; i < gCurrentLevelModel->numberOfSegments; i++) { + + for (i = 0; i < gCurrentLevelModel->numberOfSegments; i++) { bb = &gCurrentLevelModel->segmentsBoundingBoxes[i]; if (((s32)xPos < bb->unk6) && (bb->unk0 < (s32)xPos) && ((s32)zPos < bb->unkA) && (bb->unk4 < (s32)zPos)) { heightDiff = (s32)yPos - ((bb->unk8 + bb->unk2) >> 1); @@ -736,23 +727,21 @@ s32 get_level_segment_index_from_position(f32 xPos, f32 yPos, f32 zPos) { } } } - + return result; } #else GLOBAL_ASM("asm/non_matchings/unknown_0255E0/get_level_segment_index_from_position.s") #endif - s32 func_8002A05C(s32 arg0, s32 arg1, s32 *arg2) { s32 i; s32 cnt = 0; - LevelModelSegmentBoundingBox * a0; - for(i = 0; i < gCurrentLevelModel->numberOfSegments; i++){ + LevelModelSegmentBoundingBox *a0; + for (i = 0; i < gCurrentLevelModel->numberOfSegments; i++) { a0 = gCurrentLevelModel->segmentsBoundingBoxes + i; - if(arg0 < a0->unk6 + 4 && a0->unk0 - 4 < arg0 - && arg1 < a0->unkA + 4 && a0->unk4 - 4 < arg1 - ){ + if (arg0 < a0->unk6 + 4 && a0->unk0 - 4 < arg0 + && arg1 < a0->unkA + 4 && a0->unk4 - 4 < arg1) { *arg2 = i; cnt++; arg2++; @@ -765,40 +754,40 @@ s32 func_8002A134(s32 *arg0, s16 arg1, s16 arg2, s16 arg3, s16 arg4, s16 arg5, s s32 phi_v1; s32 i; LevelModelSegmentBoundingBox *bb; - + arg1 -= 4; arg2 -= 4; arg3 -= 4; arg4 += 4; arg5 += 4; arg6 += 4; - + i = 0; phi_v1 = 0; - - while(i < gCurrentLevelModel->numberOfSegments) { + + while (i < gCurrentLevelModel->numberOfSegments) { bb = &gCurrentLevelModel->segmentsBoundingBoxes[i]; - if ((bb->unk6 >= arg1) && (arg4 >= bb->unk0) && - (bb->unkA >= arg3) && (arg6 >= bb->unk4) && + if ((bb->unk6 >= arg1) && (arg4 >= bb->unk0) && + (bb->unkA >= arg3) && (arg6 >= bb->unk4) && (bb->unk8 >= arg2) && (arg5 >= bb->unk2)) { phi_v1++; *arg0++ = i; } i++; } - + return phi_v1; } LevelModelSegment *func_8002A2C8(s32 arg0) { - if(arg0 < 0 || gCurrentLevelModel->numberOfSegments < arg0) + if (arg0 < 0 || gCurrentLevelModel->numberOfSegments < arg0) return NULL; - + return gCurrentLevelModel->segments + arg0; } LevelModelSegmentBoundingBox *func_8002A2DC(s32 arg0) { - if(arg0 < 0 || gCurrentLevelModel->numberOfSegments < arg0) + if (arg0 < 0 || gCurrentLevelModel->numberOfSegments < arg0) return NULL; return gCurrentLevelModel->segmentsBoundingBoxes + arg0; @@ -813,16 +802,16 @@ s32 func_8002A5F8(LevelModelSegmentBoundingBox *bb) { s32 i, j; s32 s2; f32 temp0, temp1, temp2, temp3; - + j = 0; - while(TRUE) { + while (TRUE) { temp0 = D_8011D0F8[j].unk0; temp1 = D_8011D0F8[j].unk4; temp2 = D_8011D0F8[j].unk8; temp3 = D_8011D0F8[j].unkC; i = 0; s2 = FALSE; - while(i < 8 && !s2) { + while (i < 8 && !s2) { if (i & 1) { sp48 = bb->unk0 * temp0; } else { @@ -881,7 +870,7 @@ GLOBAL_ASM("asm/non_matchings/unknown_0255E0/func_8002B0F4.s") s32 func_8002B9BC(Object *obj, f32 *arg1, f32 *arg2, s32 arg3) { LevelModelSegment *seg; - + if (arg2 != NULL) { arg2[0] = 0.0f; arg2[2] = 0.0f; @@ -907,10 +896,10 @@ void func_8002C71C(LevelModelSegment *segment) { s32 curVertY; s32 numVerts; s32 i; - + segment->unk38 = -10000; numVerts = 0; - for(i = 0; i < segment->numberOfBatches; i++) { + for (i = 0; i < segment->numberOfBatches; i++) { if (segment->batches[i].flags & 0x2000) { segment->unk34[numVerts++] = i; curVertY = segment->vertices[segment->batches[i].verticesOffset].y; @@ -932,21 +921,21 @@ GLOBAL_ASM("asm/non_matchings/unknown_0255E0/func_8002CC30.s") #ifdef NON_MATCHING -typedef struct unk8002D30C_a0{ +typedef struct unk8002D30C_a0 { u8 pad00[0x04]; struct unk8002D30C_a0 *unk04; struct unk8002D30C_a0 *unk08; -}unk8002D30C_a0; +} unk8002D30C_a0; void func_8002D30C(unk8002D30C_a0 *arg0, s32 arg1) { // Weird issue here with the ra register. - while(arg0 != NULL) { - if(arg0->unk04) { - arg0->unk04 = (unk8002D30C_a0*)((s32)arg0->unk04 + arg1); + while (arg0 != NULL) { + if (arg0->unk04) { + arg0->unk04 = (unk8002D30C_a0 *)((s32)arg0->unk04 + arg1); } - if(arg0->unk08){ - arg0->unk08 = (unk8002D30C_a0*)((s32)arg0->unk08 + arg1); + if (arg0->unk08) { + arg0->unk08 = (unk8002D30C_a0 *)((s32)arg0->unk08 + arg1); } func_8002D30C(arg0->unk04, arg1); @@ -1015,11 +1004,11 @@ GLOBAL_ASM("asm/non_matchings/unknown_0255E0/func_80030664.s") #endif void func_80030750(s32 arg0, s16 *arg1, s16 *arg2, s8 *arg3, s8 *arg4, s8 *arg5) { - *arg1 = D_8011D388[arg0].unkC >> 0x10; + *arg1 = D_8011D388[arg0].unkC >> 0x10; *arg2 = D_8011D388[arg0].unk10 >> 0x10; - *arg3 = D_8011D388[arg0].unk0 >> 0x10; - *arg4 = D_8011D388[arg0].unk4 >> 0x10; - *arg5 = D_8011D388[arg0].unk8 >> 0x10; + *arg3 = D_8011D388[arg0].unk0 >> 0x10; + *arg4 = D_8011D388[arg0].unk4 >> 0x10; + *arg5 = D_8011D388[arg0].unk8 >> 0x10; } void func_800307BC(s32 arg0) { @@ -1028,7 +1017,7 @@ void func_800307BC(s32 arg0) { D_8011D388[arg0].unk14 = 0; D_8011D388[arg0].unk18 = 0; D_8011D388[arg0].unk1C = 0; - D_8011D388[arg0].unkC = 0x03FA0000; + D_8011D388[arg0].unkC = 0x03FA0000; D_8011D388[arg0].unk10 = 0x03FF0000; D_8011D388[arg0].unk28 = D_8011D388[arg0].unk0 >> 0x10; D_8011D388[arg0].unk29 = D_8011D388[arg0].unk4 >> 0x10; @@ -1041,7 +1030,7 @@ void func_800307BC(s32 arg0) { void func_80030838(s32 arg0, s32 arg1) { s32 i; - for(i = 0; i < arg0; i++) { + for (i = 0; i < arg0; i++) { if (D_8011D388[i].unk30 > 0) { if (arg1 < D_8011D388[i].unk30) { D_8011D388[i].unk0 += D_8011D388[i].unk14 * arg1; @@ -1051,10 +1040,10 @@ void func_80030838(s32 arg0, s32 arg1) { D_8011D388[i].unk10 += D_8011D388[i].unk24 * arg1; D_8011D388[i].unk30 -= arg1; } else { - D_8011D388[i].unk0 = D_8011D388[i].unk28 << 0x10; - D_8011D388[i].unk4 = D_8011D388[i].unk29 << 0x10; - D_8011D388[i].unk8 = D_8011D388[i].unk2A << 0x10; - D_8011D388[i].unkC = D_8011D388[i].unk2C << 0x10; + D_8011D388[i].unk0 = D_8011D388[i].unk28 << 0x10; + D_8011D388[i].unk4 = D_8011D388[i].unk29 << 0x10; + D_8011D388[i].unk8 = D_8011D388[i].unk2A << 0x10; + D_8011D388[i].unkC = D_8011D388[i].unk2C << 0x10; D_8011D388[i].unk10 = D_8011D388[i].unk2E << 0x10; D_8011D388[i].unk30 = 0; } @@ -1069,7 +1058,6 @@ void func_8003093C(s32 arg0) { GLOBAL_ASM("asm/non_matchings/unknown_0255E0/func_80030A74.s") GLOBAL_ASM("asm/non_matchings/unknown_0255E0/func_80030DE0.s") - void func_80031018(void) { Matrix mf; @@ -1087,7 +1075,7 @@ void func_80031018(void) { f32 x = 0.0f; f32 y = 0.0f; f32 z = -65536.0f; - + sp_38.unk04 = D_8011B0B0->z_rotation; sp_38.unk02 = D_8011B0B0->x_rotation; sp_38.unk00 = D_8011B0B0->y_rotation; @@ -1095,12 +1083,12 @@ void func_80031018(void) { sp_38.unk10 = 0.0f; sp_38.unk14 = 0.0f; sp_38.unk08 = 1.0f; - + func_8006FC30(&mf, &sp_38); guMtxXFMF(&mf, x, y, z, &x, &y, &z); //Store x/y/z as integers - D_8011D468.x = (s32) x; - D_8011D468.y = (s32) y; - D_8011D468.z = (s32) z; + D_8011D468.x = (s32)x; + D_8011D468.y = (s32)y; + D_8011D468.z = (s32)z; } diff --git a/src/unknown_032760.c b/src/unknown_032760.c index 9254de99..24e2c1b6 100644 --- a/src/unknown_032760.c +++ b/src/unknown_032760.c @@ -28,7 +28,6 @@ f32 D_8011D4CC; /*******************************/ - void func_80031B60(void) { if (D_800DC950 != NULL) { free_from_memory_pool(D_800DC950); @@ -47,7 +46,7 @@ void func_80031BB8(s32 count) { s32 i; func_80031B60(); D_800DC958 = count; - D_800DC950 = allocate_from_main_pool_safe(D_800DC958 * (sizeof(s32*) + sizeof(unk800DC954) + sizeof(unk800DC960) + sizeof(unk800DC964)), COLOR_TAG_MAGENTA); + D_800DC950 = allocate_from_main_pool_safe(D_800DC958 * (sizeof(s32 *) + sizeof(unk800DC954) + sizeof(unk800DC960) + sizeof(unk800DC964)), COLOR_TAG_MAGENTA); D_800DC954 = &D_800DC950[D_800DC958]; D_800DC960 = &D_800DC954[D_800DC958]; D_800DC964 = &D_800DC960[D_800DC958]; @@ -118,7 +117,7 @@ GLOBAL_ASM("asm/non_matchings/unknown_032760/func_80032424.s") void func_80032BAC(unk800DC950 *arg0) { unk800DC950 *entry = NULL; s32 i; - for(i = 0; (i < D_800DC95C) && (entry == NULL); i++) { + for (i = 0; (i < D_800DC95C) && (entry == NULL); i++) { if (arg0 == D_800DC950[i]) { entry = D_800DC950[i]; } @@ -136,7 +135,6 @@ s32 func_80032C6C(void) { return D_800DC95C; } - #ifdef NON_MATCHING // Close to matching. Should be functionally equivalent. @@ -150,10 +148,10 @@ void func_80032C7C(Object *object) { f32 temp; s16 phi_a0, phi_a1; unk800DC950 *entry; - + if (object->descriptor_ptr->unk3D == 0) { - switch(object->descriptor_ptr->unk53) { // Model type - case 0: // 3D Model + switch (object->descriptor_ptr->unk53) { // Model type + case 0: // 3D Model sp64 = 2; break; case 1: // 2D Billboard @@ -165,15 +163,15 @@ void func_80032C7C(Object *object) { sp64 = 0; break; } - + sp82 = object->x_position; sp80 = object->y_position; sp7E = object->z_position; D_800DC968 = 0; for (i = 0; i < D_800DC95C; i++) { entry = D_800DC950[i]; - if ((entry->unk2 & sp64) && (entry->unk4 == 1) && (sp82 >= entry->unk50) && - (entry->unk56 >= sp82) && (sp80 >= entry->unk52) && (entry->unk58 >= sp80) && + if ((entry->unk2 & sp64) && (entry->unk4 == 1) && (sp82 >= entry->unk50) && + (entry->unk56 >= sp82) && (sp80 >= entry->unk52) && (entry->unk58 >= sp80) && (sp7E >= entry->unk54) && (entry->unk5A >= sp7E)) { if (entry->unk0 == 0) { if (entry->unk28 >= 0x10000) { @@ -228,7 +226,7 @@ void func_80032C7C(Object *object) { } } } - + if (object->descriptor_ptr->unk71 != 0) { if (D_800DC968 == 0) { object->unk54->unk7 = 0; @@ -250,7 +248,7 @@ void func_80032C7C(Object *object) { phi_a0 = 1; phi_a1 = 0; } - for(i = 2; i < D_800DC968; i++) { + for (i = 2; i < D_800DC968; i++) { if (D_800DC960[phi_a1].unk10 < D_800DC960[i + 2].unk10) { if (D_800DC960[phi_a0].unk10 < D_800DC960[i + 2].unk10) { phi_a1 = phi_a0; @@ -303,13 +301,13 @@ GLOBAL_ASM("asm/non_matchings/unknown_032760/func_80032C7C.s") void func_800337E4(void) { s32 i; s32 temp; - - for(i = 1; i < D_800DC968; i++) { + + for (i = 1; i < D_800DC968; i++) { if (D_800DC960[i].unk10 >= 2) { if (D_800DC960[0].unk10 >= D_800DC960[i].unk10) { temp = (D_800DC960[i].unk10 << 0x10); temp /= D_800DC960[0].unk10; - D_800DC960[0].unk4 = D_800DC960[0].unk4 + ((D_800DC960[i].unk4 * temp) >> 0x10);; + D_800DC960[0].unk4 = D_800DC960[0].unk4 + ((D_800DC960[i].unk4 * temp) >> 0x10); D_800DC960[0].unk8 = D_800DC960[0].unk8 + ((D_800DC960[i].unk8 * temp) >> 0x10); D_800DC960[0].unkC = D_800DC960[0].unkC + ((D_800DC960[i].unkC * temp) >> 0x10); } else { @@ -339,7 +337,7 @@ GLOBAL_ASM("asm/non_matchings/unknown_032760/func_800337E4.s") f32 func_80033A14(unk800DC950 *arg0) { f32 out; f32 temp; - + out = arg0->unk28 / 65536.0f; switch (arg0->unk3) { case 1: diff --git a/src/unknown_0348C0.c b/src/unknown_0348C0.c index be94816f..a906c5e0 100644 --- a/src/unknown_0348C0.c +++ b/src/unknown_0348C0.c @@ -27,25 +27,25 @@ /************ .data ************/ // Unsure about the signed/unsigned with these arrays. -u16 D_800DC970[4] = { - 0x40FF, 0xFFFF, 0x0007, 0x0003 -}; -u16 D_800DC978[4] = { - 0x0000, 0x0000, 0x001E, 0xFFFF +u16 D_800DC970[4] = { + 0x40FF, 0xFFFF, 0x0007, 0x0003 +}; +u16 D_800DC978[4] = { + 0x0000, 0x0000, 0x001E, 0xFFFF }; u16 D_800DC980[20] = { 0xFF00, 0x0100, 0x0000, 0xFFFF, 0xFFFF, 0x0100, 0x0100, 0x0000, 0xFFFF, 0xFFFF, 0x0100, 0xFF00, 0x0000, 0xFFFF, 0xFFFF, 0xFF00, - 0xFF00, 0x0000, 0xFFFF, 0xFFFF + 0xFF00, 0x0000, 0xFFFF, 0xFFFF, }; u16 D_800DC9A8[20] = { 0x0000, 0x0040, 0xFFC0, 0x0000, 0xFFC0, 0xFFC0, 0x0000, 0x0040, 0x0020, 0x0000, 0xFFC0, 0x0020, 0x0000, 0x0040, 0x0040, 0x0000, - 0xFFC0, 0x0040, 0x0000, 0x0000 + 0xFFC0, 0x0040, 0x0000, 0x0000, }; u16 D_800DC9D0[64] = { 0x0000, 0x0301, 0x0004, 0x0000, @@ -63,7 +63,7 @@ u16 D_800DC9D0[64] = { 0x0002, 0x0305, 0x0001, 0x0000, 0x0001, 0x0004, 0x0000, 0x0004, 0x0002, 0x0504, 0x0001, 0x0000, - 0x0000, 0x0004, 0x0000, 0x0000 + 0x0000, 0x0004, 0x0000, 0x0000, }; s8 D_800DCA50[8] = { 2, 5, 6, 3, 10, 8, 7, 9 @@ -89,10 +89,8 @@ s8 D_800DCA94[8] = { }; s8 D_800DCA9C[12] = { - 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00 + 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; - u16 D_800DCAA8[64] = { 0x0000, 0x0301, 0x0000, 0x0000, 0xFFFF, 0xFFFF, 0x0000, 0xFFFF, @@ -109,14 +107,14 @@ u16 D_800DCAA8[64] = { 0x0002, 0x0305, 0xFFFF, 0x0000, 0xFFFF, 0xFFFF, 0x0000, 0xFFFF, 0x0002, 0x0504, 0xFFFF, 0x0000, - 0x0000, 0xFFFF, 0x0000, 0x0000 + 0x0000, 0xFFFF, 0x0000, 0x0000, }; u16 D_800DCB28[20] = { 0xFFC0, 0x0000, 0x0020, 0xFFC0, 0x0000, 0xFFE0, 0x0000, 0x0000, 0x0020, 0x0000, 0x0000, 0xFFE0, 0x0040, 0x0000, 0x0020, 0x0040, - 0x0000, 0xFFE0, 0x0000, 0x0000 + 0x0000, 0xFFE0, 0x0000, 0x0000, }; /*******************************/ @@ -154,7 +152,7 @@ void func_80033CC0(Object *arg0, LevelObjectEntry80033CC0 *arg1) { } phi_f0 /= 64; arg0->scale = arg0->descriptor_ptr->unkC * phi_f0; - ((Object_50_80033CC0*)arg0->unk50)->unk0 = arg0->descriptor_ptr->unk4 * phi_f0; + ((Object_50_80033CC0 *)arg0->unk50)->unk0 = arg0->descriptor_ptr->unk4 * phi_f0; arg0->unk3A = arg1->unk8; arg0->y_rotation = arg1->unkA << 6 << 4; if (arg1->unkB) { @@ -224,7 +222,6 @@ void func_80034B4C(unk80034B4C *arg0, s32 arg1) { } void func_80034B68(s32 arg0, s32 arg1) { - } GLOBAL_ASM("asm/non_matchings/unknown_032760/func_80034B74.s") @@ -247,7 +244,6 @@ void func_8003522C(Object *arg0, s32 arg1) { GLOBAL_ASM("asm/non_matchings/unknown_032760/func_80035260.s") void func_80035640(s32 arg0, s32 arg1) { - } void func_8003564C(Object *arg0, s32 arg1) { @@ -357,7 +353,7 @@ void func_80035E34(Object *obj, s32 arg1) { if (obj60->unk0 == 1) { s8 temp = someOtherObj64->unk1D6; if ((temp == 1) || (temp == 2)) { - someObj = (Object*)obj60->unk4; + someObj = (Object *)obj60->unk4; someObj->y_rotation = 0x4000; someObj->unk3A++; someObj->unk3A &= 1; @@ -367,15 +363,15 @@ void func_80035E34(Object *obj, s32 arg1) { void func_80035EF8(Object *arg0, unk80035EF8 *arg1) { f32 phi_f0; - arg0->unk78 = (s32) arg1->unkE; + arg0->unk78 = (s32)arg1->unkE; arg0->unk7C.word = -1; arg0->y_rotation = arg1->unkC << 6 << 4; // Not sure about the values here. - phi_f0 = (f32) (arg1->unkA & 0xFF); + phi_f0 = (f32)(arg1->unkA & 0xFF); if (phi_f0 < 10.0f) { phi_f0 = 10.0f; } phi_f0 /= 64; - arg0->scale = (f32) (arg0->descriptor_ptr->unkC * phi_f0); + arg0->scale = (f32)(arg0->descriptor_ptr->unkC * phi_f0); } void func_80035F6C(Object *obj, s32 arg1) { @@ -404,7 +400,7 @@ void func_80035F6C(Object *obj, s32 arg1) { obj64->unkC = temp_t5; obj64->unk10 = 0x40010203; obj64->unk14 = temp_t4; - obj64->unk18 = (s32) (temp_t4 | temp_t5); + obj64->unk18 = (s32)(temp_t4 | temp_t5); obj64->unk1C = temp_t5; } } @@ -516,16 +512,13 @@ void func_80037D08(unk80037D08_arg0 *arg0, s32 arg1) { } void func_80037D54(s32 arg0, s32 arg1) { - } /* Unused? */ void func_80037D60(s32 arg0, s32 arg1) { - } void func_80037D6C(s32 arg0, s32 arg1) { - } GLOBAL_ASM("asm/non_matchings/unknown_032760/func_80037D78.s") @@ -598,7 +591,7 @@ void func_8003827C(Object *obj, s32 arg1) { Object_64_8003827C *obj64 = obj->unk64; if (obj64->unk24 == 0) { if (obj64->unk38 != 0) { - obj64->unk24 = (s16) (obj64->unk38 & 0xFF); + obj64->unk24 = (s16)(obj64->unk38 & 0xFF); } } if (obj64->unk24 != 0) { @@ -685,7 +678,7 @@ void func_800388D4(Object *arg0, s32 arg1) { } else { arg0->unk6 &= ~0x4000; } - + obj4C = arg0->unk4C; if (obj4C->unk13 < ((arg0->unk78 >> 16) & 0xFF)) { playerObj = obj4C->unk0; @@ -700,7 +693,6 @@ void func_800388D4(Object *arg0, s32 arg1) { } void func_800389AC(s32 arg0, s32 arg1) { - } void func_800389B8(Object *obj, s32 arg1) { @@ -719,7 +711,6 @@ void func_800389B8(Object *obj, s32 arg1) { } void func_80038A6C(s32 arg0, s32 arg1) { - } void func_80038A78(Object *arg0, s32 arg1) { @@ -731,13 +722,12 @@ void func_80038A78(Object *arg0, s32 arg1) { } void func_80038AC8(s32 arg0, s32 arg1) { - } void func_80038AD4(Object *arg0, s32 arg1) { f32 temp_f2; - temp_f2 = (f32) arg1; + temp_f2 = (f32)arg1; if (osTvType == TV_TYPE_PAL) { temp_f2 *= 1.2; } @@ -784,7 +774,7 @@ void func_80038D58(Object *arg0, s32 arg1) { void func_80038DC4(Object *arg0, s32 arg1) { if (arg0->unk78 != 0) { Object_3C_80038DC4 *temp = arg0->unk3C_a.unk3C; - if(arg0->unk4C->unk13 < 0x78) { + if (arg0->unk4C->unk13 < 0x78) { func_8006F338(temp->unk8); arg0->unk78 = 0; func_80001D04(0x30, 0); @@ -826,7 +816,6 @@ void func_80039160(unk80039160 *arg0, s8 *arg1) { } void func_80039184(s32 arg0, s32 arg1) { - } void func_80039190(unk80039190 *arg0, u8 *arg1) { @@ -837,7 +826,6 @@ void func_80039190(unk80039190 *arg0, u8 *arg1) { } void func_800391BC(s32 arg0, s32 arg1) { - } void func_800391C8(Object *arg0, s32 arg1) { @@ -849,7 +837,7 @@ void func_800391C8(Object *arg0, s32 arg1) { void func_800391FC(Object *obj, s32 arg1) { s32 sp2C; - + if (obj->unk78 > 0) { obj->unk78 -= arg1; arg1 *= 2; @@ -901,7 +889,6 @@ void func_8003AC3C(u16 arg0, s32 arg1) { } void func_8003ACA0(s32 arg0, s32 arg1) { - } f32 func_8003ACAC(void) { @@ -920,7 +907,6 @@ void func_8003ACBC(Object *arg0, u8 *arg1, s32 arg2) { } void func_8003AD28(s32 arg0, s32 arg1) { - } void func_8003AD34(Object *obj, LevelObjectEntry8003AD34 *arg1) { @@ -1045,11 +1031,9 @@ void func_8003CEA0(Object *arg0, s32 arg1) { } void func_8003CF00(s32 arg0, s32 arg1) { - } void func_8003CF0C(s32 arg0, s32 arg1) { - } void func_8003CF18(unk8003CF18 *arg0, u8 *arg1) { @@ -1082,7 +1066,6 @@ void func_8003CFE0(s32 arg0, u8 *arg1) { } void func_8003D02C(s32 arg0, s32 arg1) { - } void func_8003D038(unk8003D038 *arg0, s8 *arg1) { @@ -1093,7 +1076,6 @@ void func_8003D038(unk8003D038 *arg0, s8 *arg1) { GLOBAL_ASM("asm/non_matchings/unknown_032760/func_8003D058.s") void func_8003D2AC(s32 arg0, s32 arg1) { - } GLOBAL_ASM("asm/non_matchings/unknown_032760/func_8003D2B8.s") @@ -1123,7 +1105,7 @@ void func_8003DBA0(Object *obj, s32 arg1) { obj->unk4C->unk10 = 0x1E; obj->unk78 = 3; obj->unk7C.word = 16; - if(!is_in_tracks_mode()) { + if (!is_in_tracks_mode()) { if (func_8000E1DC() && is_in_adventure_two()) { obj->unk78 = 0; } else { @@ -1142,7 +1124,7 @@ void func_8003DC5C(Object *obj, s32 arg1) { obj->unk4C->unk10 = 0x1E; obj->unk78 = 3; obj->unk7C.word = 0; - if(!is_in_tracks_mode()) { + if (!is_in_tracks_mode()) { if (func_8000E1DC() && !is_in_adventure_two()) { obj->unk78 = 0; } else { @@ -1177,11 +1159,11 @@ void func_8003DE74(Object *obj, unk8003DE74 *arg1) { void obj_loop_world_key(Object *worldKeyObj, s32 speed) { Settings *settings; Object *playerObj; - + // Check if the player is near the key // "worldKeyObj->unk4C->unk13" is the player's distance from the key (Up to 255). if (worldKeyObj->unk4C->unk13 < WORLD_KEY_GRAB_CHECK_RADIUS) { - // "worldKeyObj->unk4C->unk0" is only set when the player is within 255 units of + // "worldKeyObj->unk4C->unk0" is only set when the player is within 255 units of // the key object, otherwise it is NULL. playerObj = worldKeyObj->unk4C->unk0; if (playerObj != NULL) { @@ -1192,13 +1174,13 @@ void obj_loop_world_key(Object *worldKeyObj, s32 speed) { play_sound(SOUND_WORLD_KEY_GRAB); settings = get_settings(); settings->keys |= 1 << worldKeyObj->unk78; // Set key flag - gParticlePtrList_addObject(worldKeyObj); // Makes the key unload. + gParticlePtrList_addObject(worldKeyObj); // Makes the key unload. } } } } - - // Rotate world key + + // Rotate world key worldKeyObj->y_rotation += speed * 256; } @@ -1206,11 +1188,9 @@ GLOBAL_ASM("asm/non_matchings/unknown_032760/func_8003DFCC.s") GLOBAL_ASM("asm/non_matchings/unknown_032760/func_8003E140.s") void func_8003E5B0(s32 arg0, s32 arg1) { - } void func_8003E5BC(s32 arg0, s32 arg1) { - } void func_8003E5C8(Object *arg0, s32 arg1) { @@ -1307,7 +1287,7 @@ void func_8003FEF4(Object *arg0, LevelObjectEntry8003FEF4 *arg1) { void func_8004001C(Object *arg0, LevelObjectEntry8004001C *entry) { s32 temp; - Object_64_8004001C *obj64 = (Object_64_8004001C*)arg0->unk64; + Object_64_8004001C *obj64 = (Object_64_8004001C *)arg0->unk64; obj64->unk2 = entry->unk8; temp = entry->unk9; obj64->unk4 = temp & 0xFF; @@ -1331,8 +1311,8 @@ void func_800400A4(Object *obj, LevelObjectEntry800400A4 *arg1, s32 arg2) { if (obj64->unk0 >= numberOfTexturesInLevel) { obj64->unk0 = numberOfTexturesInLevel - 1; } - obj64->unk4 = (s16) arg1->unkA; - obj64->unk6 = (s16) arg1->unkB; + obj64->unk4 = (s16)arg1->unkA; + obj64->unk6 = (s16)arg1->unkB; if (arg2 == 0) { obj64->unk8 = 0; obj64->unkA = 0; @@ -1434,15 +1414,12 @@ void func_8004210C(unk8004210C *arg0, s8 *arg1) { } void func_80042150(s32 arg0, s32 arg1, s32 arg2) { - } void func_80042160(s32 arg0, s32 arg1) { - } void func_8004216C(s32 arg0, s32 arg1) { - } void func_80042178(Object *obj, s32 arg1) { @@ -1451,7 +1428,7 @@ void func_80042178(Object *obj, s32 arg1) { unk80042178 sp20; obj3C = obj->unk3C_a.unk3C; - if (func_80016DE8(obj->x_position, 0, obj->z_position, (f32) obj3C->unk8, 1, &sp20) > 0) { + if (func_80016DE8(obj->x_position, 0, obj->z_position, (f32)obj3C->unk8, 1, &sp20) > 0) { obj->unk74 = obj3C->unkA; } else { obj->unk74 = 0; @@ -1461,8 +1438,8 @@ void func_80042178(Object *obj, s32 arg1) { void func_80042210(Object *obj, LevelObjectEntry80042210 *arg1) { Object_64_80042210 *obj64; - - obj64 = (Object_64_80042210*)obj->unk64; + + obj64 = (Object_64_80042210 *)obj->unk64; obj64->unk15 = arg1->unkA; obj64->unk0 = obj->x_position; obj64->unk4 = obj->y_position; @@ -1474,7 +1451,7 @@ void func_80042210(Object *obj, LevelObjectEntry80042210 *arg1) { obj64->unk24 = obj->z_position; obj64->unk19 = 0; obj64->unk30 = 1.0f; - + if (obj64->unk15) { obj->unk3A = 1; if (is_drumstick_unlocked() || (get_settings()->trophies & 0xFF) != 0xFF) { @@ -1493,7 +1470,7 @@ void func_80042998(s32 arg0, s32 arg1) { func_8001F460(arg0, arg1, arg0); obj = func_8000BF44(-1); - + if (obj != NULL) { obj64 = obj->unk64; obj->unk78 = 0; diff --git a/src/unknown_043920.c b/src/unknown_043920.c index f16378d2..792e6c5a 100644 --- a/src/unknown_043920.c +++ b/src/unknown_043920.c @@ -29,16 +29,16 @@ s32 D_800DCB5C = 0; // Currently unknown, might be a different type. f32 D_800DCB60[14] = { -10.0f, 5.0f, 0.0f, 0.0f, 10.0f, 5.0f, 0.0f, 0.0f, - -10.0f, 10.0f, 0.0f, 0.0f, + -10.0f, 10.0f, 0.0f, 0.0f, 10.0f, 10.0f, }; s32 D_800DCB98 = 0; // Currently unknown, might be a different type. f32 D_800DCB9C[19] = { - 0.004f, 0.007f, 0.0099999999f, 0.004f, - 0.0099999999f, 0.0099999999f, 0.0099999999f, 0.0099999999f, - 0.0099999999f, 0.0099999999f, 0.004f, 0.004f, - 0.004f, 0.004f, 0.004f, 0.004f, + 0.004f, 0.007f, 0.0099999999f, 0.004f, + 0.0099999999f, 0.0099999999f, 0.0099999999f, 0.0099999999f, + 0.0099999999f, 0.0099999999f, 0.004f, 0.004f, + 0.004f, 0.004f, 0.004f, 0.004f, 0.004f, 0.004f, 0.004f, }; @@ -52,8 +52,8 @@ f32 D_800DCBE8[19] = { // Unused? Not sure if this is actually an array or just some random data. s32 D_800DCC34[19] = { - 0, 1, 1, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1, 1, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, }; @@ -70,15 +70,15 @@ s16 D_800DCCB4[12] = { u16 D_800DCCCC[20] = { 0x010C, 0x010B, 0x0009, 0x010C, - 0x010C, 0x010C, 0x010C, 0x010C, - 0x010C, 0x010C, 0x010C, 0x0005, - 0x010C, 0x010C, 0x010C, 0x010C, + 0x010C, 0x010C, 0x010C, 0x010C, + 0x010C, 0x010C, 0x010C, 0x0005, + 0x010C, 0x010C, 0x010C, 0x010C, 0x010C, 0x010C, 0x010C, 0x0000, }; s32 D_800DCCF4[19] = { 1, 4, 16, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 0x100, 1, 1, 1, 1, 1, + 1, 1, 1, 0x100, 1, 1, 1, 1, 1, }; s32 D_800DCD40[20] = { @@ -98,7 +98,7 @@ s8 D_800DCDA0[8] = { }; s8 D_800DCDA8[8] = { - 1, 1, 1, 2, 3, 2, 3, 2 , + 1, 1, 1, 2, 3, 2, 3, 2, }; // Unused? @@ -215,7 +215,7 @@ GLOBAL_ASM("asm/non_matchings/unknown_043920/func_80049794.s") void func_8004C0A0(s32 arg0, Object *planeObj, Object_64_8004C0A0 *planeObj64) { s32 temp_v1; s32 phi_v0; - + if (planeObj64->unk1D7 != 10) { //!@bug Typo. Should've been `== 0`, not `= 0`. if (planeObj64->unk1F2 = 0) { @@ -269,7 +269,7 @@ void func_8004C140(Object *obj, Object_64_8004C140 *obj64) { } if (obj64->unk1D6 < 5) { func_800570B8(obj, 0x1C2, 8, 0x81); - switch(obj64->unk187) { + switch (obj64->unk187) { case 1: case 2: if (phi_v1 != 0) { @@ -301,7 +301,7 @@ GLOBAL_ASM("asm/non_matchings/unknown_043920/func_8004D590.s") void func_8004D95C(s32 arg0, s32 arg1, Object *obj, Object_64_8004D95C *obj64) { s16 sp26; - + if (obj64->unk118 != 0) { func_80006AC8(obj); } @@ -378,7 +378,7 @@ typedef struct Object_64_80050754 { void func_80050754(Object *obj, Object_64_80050754 *obj64, f32 arg2) { f32 xDiff, yDiff, zDiff; Object *someObj; - + obj->unk3B = 0; obj->unk18 = 0x28; someObj = obj64->someObj; @@ -495,7 +495,7 @@ GLOBAL_ASM("asm/non_matchings/unknown_043920/func_80052D7C.s") void func_80053478(Object_64_80053478 *obj) { s32 phi_v0; f32 phi_f0 = obj->unk2C; - + if (phi_f0 < 0.0) { phi_f0 = -phi_f0; } @@ -637,7 +637,7 @@ GLOBAL_ASM("asm/non_matchings/unknown_043920/func_80057220.s") void func_800575EC(Object *obj, Object_64_800575EC *obj64) { Matrix mf; - + D_8011D510.unk0 = obj->y_rotation; D_8011D510.unk2 = obj->x_rotation; D_8011D510.unk4 = 0; @@ -721,14 +721,14 @@ void func_80059790(s32 arg0, s32 *arg1, s32 *arg2, s32 *arg3) { } temp_lo = arg0 / 3600; *arg1 = temp_lo; - temp_lo_2 = (s32) (arg0 - (temp_lo * 3600)) / 60; + temp_lo_2 = (s32)(arg0 - (temp_lo * 3600)) / 60; *arg2 = temp_lo_2; - *arg3 = (s32) ((s32) (((arg0 - (*arg1 * 3600)) - (temp_lo_2 * 60)) * 100) / 60); + *arg3 = (s32)((s32)(((arg0 - (*arg1 * 3600)) - (temp_lo_2 * 60)) * 100) / 60); } void func_800598D0(void) { gGhostData[0] = allocate_from_main_pool_safe(0x21C0, COLOR_TAG_RED); - gGhostData[1] = (GhostNode*)gGhostData[0] + MAX_NUMBER_OF_GHOST_NODES; + gGhostData[1] = (GhostNode *)gGhostData[0] + MAX_NUMBER_OF_GHOST_NODES; gGhostData[2] = NULL; // T.T. Ghost D_8011D5A0[0] = 0; D_8011D5A0[1] = 0; @@ -747,7 +747,7 @@ void func_80059944(void) { } void func_80059984(s32 arg0) { - D_8011D59D = (s8) ((D_8011D59C + 1) & 1); + D_8011D59D = (s8)((D_8011D59C + 1) & 1); D_8011D5AC = arg0; } @@ -789,7 +789,7 @@ s32 load_tt_ghost(s32 ghostOffset, s32 size, s16 *outTime) { if (gGhostData[2] != NULL) { *outTime = ghost->time; gTTGhostNodeCount = ghost->nodeCount; - bcopy((u8*)ghost + 8, gGhostData[2], size - sizeof(GhostHeader)); + bcopy((u8 *)ghost + 8, gGhostData[2], size - sizeof(GhostHeader)); free_from_memory_pool(ghost); return 0; } @@ -828,9 +828,9 @@ void func_8005A3C0(void) { void func_8005A3D0(void) { s32 i; s32 count = 0; - u8 *temp = (u8*)&func_8003B4BC; + u8 *temp = (u8 *)&func_8003B4BC; - for(i = 0; i < D_800DCB50; i++) { + for (i = 0; i < D_800DCB50; i++) { count += temp[i]; } @@ -854,7 +854,7 @@ void func_8005C270(unk8005C270 *arg0) { arg0->unk192--; if (arg0->unk192 < 0) { arg0->unk192 += temp; - if(arg0->unk193 > 0){ + if (arg0->unk193 > 0) { arg0->unk193--; } } diff --git a/src/unknown_05CEF0.c b/src/unknown_05CEF0.c index 0c424f8c..60821ec1 100644 --- a/src/unknown_05CEF0.c +++ b/src/unknown_05CEF0.c @@ -15,8 +15,8 @@ s16 D_800DCDE0[16] = { 0x022B, 0x00A3, 0x00A4, 0x00B3, - 0x00B4, 0x00F0, 0x00F1, 0x00F6, - 0x00F7, 0x0225, 0x0226, 0x002E, + 0x00B4, 0x00F0, 0x00F1, 0x00F6, + 0x00F7, 0x0225, 0x0226, 0x002E, 0x002F, 0x0030, 0x0000, 0x0000, }; diff --git a/src/unknown_05DCD0.c b/src/unknown_05DCD0.c index 7ce872d5..c9b641a8 100644 --- a/src/unknown_05DCD0.c +++ b/src/unknown_05DCD0.c @@ -9,17 +9,11 @@ /************ .data ************/ s16 D_800DCE00[16] = { - 0x022D, 0x00A7, 0x00A8, 0x00B7, - 0x00B8, 0x00F4, 0x00F5, 0x00FA, - 0x00FB, 0x0229, 0x022A, 0x002E, - 0x002F, 0x0030, 0x0000, 0x0000 + 0x022D, 0x00A7, 0x00A8, 0x00B7, 0x00B8, 0x00F4, 0x00F5, 0x00FA, 0x00FB, 0x0229, 0x022A, 0x002E, 0x002F, 0x0030, 0x0000, 0x0000 }; s16 D_800DCE20[16] = { - 0x022C, 0x00A5, 0x00A6, 0x00B5, - 0x00B6, 0x00F2, 0x00F3, 0x00F8, - 0x00F9, 0x0227, 0x0228, 0x002E, - 0x002F, 0x0030, 0x0000, 0x0000 + 0x022C, 0x00A5, 0x00A6, 0x00B5, 0x00B6, 0x00F2, 0x00F3, 0x00F8, 0x00F9, 0x0227, 0x0228, 0x002E, 0x002F, 0x0030, 0x0000, 0x0000 }; /*******************************/ @@ -31,8 +25,8 @@ s8 D_8011D5D1; // These 3 might be a file boundary. s32 D_8011D5D4; -s32 D_8011D5D8; -s32 D_8011D5DC; +s32 D_8011D5D8; +s32 D_8011D5DC; s8 D_8011D5E0; s8 D_8011D5E1; diff --git a/src/unknown_05F0C0.c b/src/unknown_05F0C0.c index b6e5cb84..062d198b 100644 --- a/src/unknown_05F0C0.c +++ b/src/unknown_05F0C0.c @@ -12,7 +12,7 @@ s16 D_800DCE40[16] = { 0x0244, 0x0242, 0x0243, 0x0245, 0x0246, 0x0247, 0x0248, 0x00F6, 0x00F7, 0x0225, 0x0226, 0x002E, - 0x002F, 0x0030, 0x0000, 0x0000 + 0x002F, 0x0030, 0x0000, 0x0000, }; /*******************************/ diff --git a/src/unknown_05F690.c b/src/unknown_05F690.c index 015eb0fc..e3370a80 100644 --- a/src/unknown_05F690.c +++ b/src/unknown_05F690.c @@ -9,10 +9,7 @@ /************ .data ************/ s16 D_800DCE60[14] = { - 0x022C, 0x00A5, 0x00A6, 0x0057, - 0x0051, 0x006D, 0x0052, 0x00F8, - 0x00F9, 0x0227, 0x0228, 0x002E, - 0x002F, 0x0030 + 0x022C, 0x00A5, 0x00A6, 0x0057, 0x0051, 0x006D, 0x0052, 0x00F8, 0x00F9, 0x0227, 0x0228, 0x002E, 0x002F, 0x0030 }; /*******************************/ diff --git a/src/unknown_05FF10.c b/src/unknown_05FF10.c index efce3d07..04a63c38 100644 --- a/src/unknown_05FF10.c +++ b/src/unknown_05FF10.c @@ -12,7 +12,7 @@ s16 D_800DCE80[14] = { 0x022C, 0x00A5, 0x00A6, 0x0057, 0x0051, 0x006D, 0x0052, 0x00F8, 0x00F9, 0x0227, 0x0228, 0x002E, - 0x002F, 0x0030 + 0x002F, 0x0030, }; /*******************************/ diff --git a/src/unknown_06B2B0.c b/src/unknown_06B2B0.c index 16539808..95595428 100644 --- a/src/unknown_06B2B0.c +++ b/src/unknown_06B2B0.c @@ -53,9 +53,9 @@ const char D_800E7148[] = "Swapping\n"; /************ .data ************/ -s8 *D_800DD310 = NULL; // Currently unknown, might be a different type. -s8 D_800DD314 = -1; -u8 D_800DD318 = 0; +s8 *D_800DD310 = NULL; // Currently unknown, might be a different type. +s8 D_800DD314 = -1; +u8 D_800DD318 = 0; s32 D_800DD31C = 0; // Updated automatically from calc_func_checksums.py @@ -70,32 +70,34 @@ s8 D_800DD330 = 0; // Unused char *D_800DD334[6] = { NULL, NULL, NULL, // These could be a file boundary. - D_800E7110, D_800E7118, D_800E7128 + D_800E7110, + D_800E7118, + D_800E7128 }; // Unused char gBuildString[40] = "Version 7.7 29/09/97 15.00 L.Schuneman"; -s8 D_800DD374 = 0; +s8 D_800DD374 = 0; s32 D_800DD378 = 1; s32 D_800DD37C = 0; s32 D_800DD380 = 0; // Currently unknown, might be a different type. s32 D_800DD384 = 0; s32 D_800DD388 = 0; // Currently unknown, might be a different type. -s8 D_800DD38C = 0; -s8 D_800DD390 = 0; +s8 D_800DD38C = 0; +s8 D_800DD390 = 0; s16 D_800DD394 = 0; -s8 D_800DD398 = 0; -s8 D_800DD39C = 0; -s8 D_800DD3A0 = 0; +s8 D_800DD398 = 0; +s8 D_800DD39C = 0; +s8 D_800DD3A0 = 0; s32 D_800DD3A4 = 0; // Currently unknown, might be a different type. s32 D_800DD3A8 = 0; // Currently unknown, might be a different type. s32 D_800DD3AC = 0; // Currently unknown, might be a different type. -s32 gNumF3dCmdsPerPlayer[4] = { 4500, 7000, 11000, 11000 }; +s32 gNumF3dCmdsPerPlayer[4] = { 4500, 7000, 11000, 11000 }; s32 gNumHudVertsPerPlayer[4] = { 300, 600, 850, 900 }; -s32 gNumHudMatPerPlayer[4] = { 300, 400, 550, 600 }; -s32 gNumHudTrisPerPlayer[4] = { 20, 30, 40, 50 }; -s8 D_800DD3F0 = 0; +s32 gNumHudMatPerPlayer[4] = { 300, 400, 550, 600 }; +s32 gNumHudTrisPerPlayer[4] = { 20, 30, 40, 50 }; +s8 D_800DD3F0 = 0; FadeTransition D_800DD3F4 = FADE_TRANSITION(128, FADE_COLOR_BLACK, 20, 0); // Unused? FadeTransition D_800DD3FC = FADE_TRANSITION(0, FADE_COLOR_WHITE, 20, -1); @@ -137,7 +139,7 @@ s32 gCurrHudVerts; s32 *gHudTriangles[2]; s32 gCurrHudTris; s32 D_80121230[8]; -s8 D_80121250[16]; +s8 D_80121250[16]; OSSched *D_80121260; s32 D_80121268[2208]; //Padding s32 D_801234E8; @@ -151,15 +153,15 @@ s32 D_80123504; s32 D_80123508; s32 D_8012350C; Settings *gSettingsPtr; -s8 D_80123514; -s8 gIsPaused; -s8 D_80123516; +s8 D_80123514; +s8 gIsPaused; +s8 D_80123516; s32 D_80123518; s32 D_8012351C; s32 D_80123520; -s8 D_80123524; -s8 D_80123525; -s8 D_80123526; +s8 D_80123524; +s8 D_80123525; +s8 D_80123526; s32 gCurrNumF3dCmdsPerPlayer; s32 gCurrNumHudMatPerPlayer; s32 gCurrNumHudTrisPerPlayer; @@ -180,7 +182,7 @@ void func_8006A6B0(void) { u8 *sp44; sp44 = allocate_from_main_pool_safe(sizeof(LevelHeader), COLOR_TAG_YELLOW); gTempAssetTable = load_asset_section_from_rom(ASSET_LEVEL_HEADERS_TABLE); - for(i = 0; i < 16; i++) { + for (i = 0; i < 16; i++) { D_80121180[i] = 0; } gNumberOfLevelHeaders = 0; @@ -218,7 +220,7 @@ void func_8006A6B0(void) { } free_from_memory_pool(gTempAssetTable); free_from_memory_pool(sp44); - + gTempAssetTable = load_asset_section_from_rom(ASSET_LEVEL_NAMES_TABLE); count = 0; while (gTempAssetTable[count] != -1) { @@ -230,15 +232,15 @@ void func_8006A6B0(void) { D_8012116C = allocate_from_main_pool_safe(count * sizeof(s32), COLOR_TAG_YELLOW); D_800DD310 = allocate_from_main_pool_safe(temp, COLOR_TAG_YELLOW); load_asset_to_address(ASSET_LEVEL_NAMES, D_800DD310, 0, temp); - for(i = 0; i < count; i++) { + for (i = 0; i < count; i++) { D_8012116C[i] = &D_800DD310[gTempAssetTable[i]]; } free_from_memory_pool(gTempAssetTable); - + // Anti-piracy/Anti-tamper check. checksumCount = 0; - for(i = 0; i < gFunc80068158Length; i++) { - checksumCount += ((u8*)&func_80068158)[i]; + for (i = 0; i < gFunc80068158Length; i++) { + checksumCount += ((u8 *)&func_80068158)[i]; } if (checksumCount != gFunc80068158Checksum) { // Disables button inputs in some parts of the game if the checksum doesn't match. @@ -278,7 +280,7 @@ s32 func_8006B018(s8 arg0) { s32 func_8006B054(s8 arg0) { s32 out, i; out = 0; - for(i = 0; i < gNumberOfLevelHeaders; i++) { + for (i = 0; i < gNumberOfLevelHeaders; i++) { if (arg0 == D_8012117C[i].unk0) { out++; } @@ -296,7 +298,7 @@ s32 func_8006B0AC(s32 arg0) { s32 func_8006B0F8(s32 arg0) { if (arg0 > 0 && arg0 < gNumberOfLevelHeaders) { s32 temp = D_8012117C[arg0].unk2; - if(temp != 0) { + if (temp != 0) { return (temp >> 4) & 0xF; } } @@ -319,12 +321,12 @@ s8 func_8006B190(s32 arg0) { s32 func_8006B1D4(s32 arg0) { s8 *temp; - + if (arg0 < 0 || arg0 >= gNumberOfWorlds) { arg0 = 0; } temp = get_misc_asset(0x1B); - + return temp[arg0]; } @@ -354,7 +356,7 @@ void load_level(s32 levelId, s32 numberOfPlayers, s32 entranceId, s32 vehicleId, s32 phi_v0_2; s8 *someAsset; Settings *settings; - + func_80072708(); if (cutsceneId == -1) { cutsceneId = 0; @@ -372,7 +374,7 @@ void load_level(s32 levelId, s32 numberOfPlayers, s32 entranceId, s32 vehicleId, } else { func_8000318C(16); } - + settings = get_settings(); gTempAssetTable = load_asset_section_from_rom(ASSET_LEVEL_HEADERS_TABLE); maxLevelCount = 0; @@ -385,7 +387,7 @@ void load_level(s32 levelId, s32 numberOfPlayers, s32 entranceId, s32 vehicleId, } offset = gTempAssetTable[levelId]; size = gTempAssetTable[levelId + 1] - offset; - gCurrentLevelHeader = (LevelHeader*)allocate_from_main_pool_safe(size, COLOR_TAG_YELLOW); + gCurrentLevelHeader = (LevelHeader *)allocate_from_main_pool_safe(size, COLOR_TAG_YELLOW); load_asset_to_address(ASSET_LEVEL_HEADERS, gCurrentLevelHeader, offset, size); D_800DD330 = 0; sp44 = levelId; @@ -415,13 +417,12 @@ void load_level(s32 levelId, s32 numberOfPlayers, s32 entranceId, s32 vehicleId, } someAsset = get_misc_asset(0x43); phi_s0 = 0; - while(levelId != someAsset[phi_s0 + 1]) { + while (levelId != someAsset[phi_s0 + 1]) { phi_s0++; } levelId = someAsset[phi_s0 + 1]; entranceId = cutsceneId; } - } if (gCurrentLevelHeader->race_type == RACE_TYPE_HUB_AREA) { s32 curWorld = gCurrentLevelHeader->world; @@ -432,7 +433,7 @@ void load_level(s32 levelId, s32 numberOfPlayers, s32 entranceId, s32 vehicleId, // Trigger World Key unlocking Challenge Door cutscene. func_8006C1AC(levelId, entranceId, vehicleId, cutsceneId); settings->cutsceneFlags |= temp_v0_5; - levelId = get_misc_asset(0x44)[curWorld-1]; + levelId = get_misc_asset(0x44)[curWorld - 1]; entranceId = 0; cutsceneId = 5; } @@ -470,9 +471,9 @@ void load_level(s32 levelId, s32 numberOfPlayers, s32 entranceId, s32 vehicleId, } } if (cutsceneId == 0x64) { - if(get_trophy_race_world_id() != 0 && gCurrentLevelHeader->race_type == RACE_TYPE_DEFAULT) { + if (get_trophy_race_world_id() != 0 && gCurrentLevelHeader->race_type == RACE_TYPE_DEFAULT) { cutsceneId = 0; - } else if(is_in_tracks_mode() == 1 && gCurrentLevelHeader->race_type == RACE_TYPE_DEFAULT) { + } else if (is_in_tracks_mode() == 1 && gCurrentLevelHeader->race_type == RACE_TYPE_DEFAULT) { cutsceneId = 0; } } @@ -548,11 +549,11 @@ void load_level(s32 levelId, s32 numberOfPlayers, s32 entranceId, s32 vehicleId, func_8001E450(cutsceneId); func_800249F0(gCurrentLevelHeader->geometry, gCurrentLevelHeader->skybox, numberOfPlayers, vehicleId, entranceId, gCurrentLevelHeader->collectables, gCurrentLevelHeader->unkBA); if (gCurrentLevelHeader->unk3A == 0 && gCurrentLevelHeader->unk3C == 0 && gCurrentLevelHeader->fogR == 0 && gCurrentLevelHeader->fogG == 0 && gCurrentLevelHeader->fogB == 0) { - for(i = 0; i < 4; i++) { + for (i = 0; i < 4; i++) { func_800307BC(i); } } else { - for(i = 0; i < 4; i++) { + for (i = 0; i < 4; i++) { func_80030664(i, gCurrentLevelHeader->unk3A, gCurrentLevelHeader->unk3C, (u8)gCurrentLevelHeader->fogR, gCurrentLevelHeader->fogG, gCurrentLevelHeader->fogB); } } @@ -563,14 +564,13 @@ void load_level(s32 levelId, s32 numberOfPlayers, s32 entranceId, s32 vehicleId, settings->courseId = levelId; if (gCurrentLevelHeader->weather_enable > 0) { func_800AB4A8( - gCurrentLevelHeader->unk92, - gCurrentLevelHeader->weather_enable, - gCurrentLevelHeader->unk96 << 8, - gCurrentLevelHeader->unk98 << 8, - gCurrentLevelHeader->unk9A << 8, - gCurrentLevelHeader->unk94 * 0x101, - gCurrentLevelHeader->unk95 * 0x101 - ); + gCurrentLevelHeader->unk92, + gCurrentLevelHeader->weather_enable, + gCurrentLevelHeader->unk96 << 8, + gCurrentLevelHeader->unk98 << 8, + gCurrentLevelHeader->unk9A << 8, + gCurrentLevelHeader->unk94 * 0x101, + gCurrentLevelHeader->unk95 * 0x101); func_800AB308(-1, -0x200); } if (gCurrentLevelHeader->unk49 == -1) { @@ -578,7 +578,7 @@ void load_level(s32 levelId, s32 numberOfPlayers, s32 entranceId, s32 vehicleId, gCurrentLevelHeader->unkA8 = (u16)0; gCurrentLevelHeader->unkAA = (u16)0; } - if ((s32)gCurrentLevelHeader->pulseLightData != -1) { + if ((s32)gCurrentLevelHeader->pulseLightData != -1) { // Only used in spaceport alpha for some pulsating lights. gCurrentLevelHeader->pulseLightData = get_misc_asset((s32)gCurrentLevelHeader->pulseLightData); init_pulsating_light_data(gCurrentLevelHeader->pulseLightData); @@ -621,30 +621,30 @@ u8 func_8006BDC0(void) { u8 *func_8006BDDC(s32 arg0) { u8 *text; u8 numberOfNullPointers = 0; - - if(arg0 < 0 || arg0 >= gNumberOfLevelHeaders) { + + if (arg0 < 0 || arg0 >= gNumberOfLevelHeaders) { return NULL; } - + text = D_8012116C[arg0]; - switch(get_language()) { + switch (get_language()) { case GERMAN: - while(numberOfNullPointers < 1) { - if(*(text++) == 0) { + while (numberOfNullPointers < 1) { + if (*(text++) == 0) { numberOfNullPointers++; } } break; case FRENCH: - while(numberOfNullPointers < 2) { - if(*(text++) == 0) { + while (numberOfNullPointers < 2) { + if (*(text++) == 0) { numberOfNullPointers++; } } break; case JAPANESE: - while(numberOfNullPointers < 3) { - if(*(text++) == 0) { + while (numberOfNullPointers < 3) { + if (*(text++) == 0) { numberOfNullPointers++; } } @@ -669,7 +669,7 @@ void func_8006BEFC(void) { func_800AB35C(); } if (gCurrentLevelHeader->unk49 == 0xFF) { - free_texture(gCurrentLevelHeader->unkA4); + free_texture(gCurrentLevelHeader->unkA4); } } @@ -678,7 +678,7 @@ void func_8006BFC8(s8 *arg0) { s16 phi_v1; s8 phi_s0; Settings *settings; - + phi_s0 = 0; if (!is_in_tracks_mode()) { settings = get_settings(); @@ -692,17 +692,17 @@ void func_8006BFC8(s8 *arg0) { } else { phi_s0 = 3; } - + if (get_trophy_race_world_id() != 0) { phi_s0 = 4; } - - if(is_in_adventure_two()){ + + if (is_in_adventure_two()) { phi_s0 += 5; } - + phi_s0 = arg0[phi_s0]; - + if ((get_filtered_cheats() << 6) < 0) { phi_s0 = 9; } @@ -746,7 +746,7 @@ void func_8006C1AC(s32 arg0, s32 arg1, s32 arg2, s32 arg3) { void func_8006C22C(s32 *arg0, s32 *arg1, s32 *arg2, s32 *arg3) { s16 temp_v1; - + D_800DD328--; *arg3 = D_801211C8[D_800DD328]; D_800DD328--; @@ -755,15 +755,14 @@ void func_8006C22C(s32 *arg0, s32 *arg1, s32 *arg2, s32 *arg3) { *arg1 = D_801211C8[D_800DD328]; D_800DD328--; *arg0 = D_801211C8[D_800DD328]; - + if (temp_v1 != -1) { *arg2 = temp_v1; } - + D_800DD32C = 1; } - void func_8006C2E4(void) { D_800DD328 = 0; } @@ -786,14 +785,16 @@ void thread3_main(s32 arg0) { D_800DD37C = func_8006A1C4(D_800DD37C, 0); D_80123520 = 0; D_801234EC = -1; - while(1) { + while (1) { if (func_8006EAC0() != 0) { func_80072708(); audioStopThread(); stop_thread30(); - __osSpSetStatus(0xAAAA82); - osDpSetStatus(0x1D6); - while(1); // Infinite loop + __osSpSetStatus(SP_SET_HALT | SP_CLR_INTR_BREAK | SP_CLR_YIELD | SP_CLR_YIELDED | SP_CLR_TASKDONE | SP_CLR_RSPSIGNAL + | SP_CLR_CPUSIGNAL | SP_CLR_SIG5 | SP_CLR_SIG6 | SP_CLR_SIG7); + osDpSetStatus(DPC_SET_XBUS_DMEM_DMA | DPC_CLR_FREEZE | DPC_CLR_FLUSH | DPC_CLR_TMEM_CTR | DPC_CLR_PIPE_CTR + | DPC_CLR_CMD_CTR | DPC_CLR_CMD_CTR); + while (1); // Infinite loop } render(); func_80065E30(); @@ -811,7 +812,7 @@ void func_8006C3E0(void) { } D_80123514 = FALSE; D_80123518 = 0; - + if (osTvType == TV_TYPE_PAL) { mode = 14; } else if (osTvType == TV_TYPE_NTSC) { @@ -819,8 +820,8 @@ void func_8006C3E0(void) { } else if (osTvType == TV_TYPE_MPAL) { mode = 28; } - - osCreateScheduler(&D_80121260, &D_801234E8, /*priority*/ 13, (u8) mode, 1); + + osCreateScheduler(&D_80121260, &D_801234E8, /*priority*/ 13, (u8)mode, 1); D_800DD3A0 = 0; if (func_8006EFB8() == 0) { D_800DD3A0 = 1; @@ -850,11 +851,11 @@ void func_8006C3E0(void) { D_80123504 = 0; D_80123508 = 0; D_801234E8 = 0; - + gCurrDisplayList = gDisplayLists[D_801234E8]; - gDPFullSync(gCurrDisplayList++) - gSPEndDisplayList(gCurrDisplayList++) - + gDPFullSync(gCurrDisplayList++); + gSPEndDisplayList(gCurrDisplayList++); + osSetTime(0); } @@ -862,9 +863,9 @@ void render(void) { s32 phi_v0; s32 phi_v0_2; s32 temp, temp2; - + osSetTime(0); - + if (D_800DD380 == 8) { gCurrDisplayList = gDisplayLists[D_801234E8]; set_rsp_segment(&gCurrDisplayList, 0, 0); @@ -880,12 +881,12 @@ void render(void) { if (D_800DD3F0 != 0) { D_800DD3F0 -= 1; } - + gCurrDisplayList = gDisplayLists[D_801234E8]; gCurrHudMat = gHudMatrices[D_801234E8]; gCurrHudVerts = gHudVertices[D_801234E8]; gCurrHudTris = gHudTriangles[D_801234E8]; - + set_rsp_segment(&gCurrDisplayList, 0, 0); set_rsp_segment(&gCurrDisplayList, 1, gVideoLastFramebuffer); set_rsp_segment(&gCurrDisplayList, 2, gVideoLastDepthBuffer); @@ -900,15 +901,15 @@ void render(void) { } if (D_800DD3A0 != 0) { phi_v0 = 0; - while(phi_v0 != 10000000) { + while (phi_v0 != 10000000) { phi_v0 += 1; } if (phi_v0 >= 20000001) { // This shouldn't ever be true? render_printf(D_800E7134 /* "BBB\n" */); } } - - switch(D_801234EC) { + + switch (D_801234EC) { case -1: // Pre-boot screen func_8006F43C(); break; @@ -922,10 +923,10 @@ void render(void) { func_800B77D4(D_800DD404); break; } - - // This is a good spot to place custom text if you want it to overlay it over ALL the + + // This is a good spot to place custom text if you want it to overlay it over ALL the // menus & gameplay. - + func_80000D00((u8)D_800DD404); func_800B5F78(&gCurrDisplayList); func_800C56FC(&gCurrDisplayList, &gCurrHudMat, &gCurrHudVerts); @@ -937,10 +938,10 @@ void render(void) { if ((D_80123520 >= 8) && (func_8006F4C8() != 0)) { func_800829F8(&gCurrDisplayList, D_800DD404); } - - gDPFullSync(gCurrDisplayList++) - gSPEndDisplayList(gCurrDisplayList++) - + + gDPFullSync(gCurrDisplayList++); + gSPEndDisplayList(gCurrDisplayList++); + func_80066610(); if (D_800DD3F0 != 1) { if (D_800DD38C == 0) { @@ -961,7 +962,7 @@ void render(void) { } func_80070B04(gVideoLastFramebuffer, gVideoCurrFramebuffer, gVideoCurrFramebuffer + phi_v0_2); } - + temp = func_8007A98C(D_800DD380); D_800DD404 = temp; temp2 = 6; @@ -1013,8 +1014,8 @@ void func_8006CC14(void) { func_800A003C(); func_800C30CC(); gCurrDisplayList = gDisplayLists[D_801234E8]; - gDPFullSync(gCurrDisplayList++) - gSPEndDisplayList(gCurrDisplayList++) + gDPFullSync(gCurrDisplayList++); + gSPEndDisplayList(gCurrDisplayList++); set_free_queue_state(2); } @@ -1022,11 +1023,11 @@ void func_8006CC14(void) { // Almost matching except for a couple minor issues. void func_8006CCF0(s32 arg0) { s32 i, buttonHeldInputs, sp40, sp3C, buttonPressedInputs, phi_v1_2; - + sp40 = 0; buttonHeldInputs = 0; buttonPressedInputs = 0; - + for (i = 0; i < func_8009C3D8(); i++) { buttonHeldInputs |= get_buttons_held_from_player(i); buttonPressedInputs |= get_buttons_pressed_from_player(i); @@ -1037,7 +1038,7 @@ void func_8006CCF0(s32 arg0) { if (!gIsPaused) { func_80010994(arg0); if (func_80066510() == 0 || func_8001139C()) { - if ((buttonPressedInputs & START_BUTTON) && (func_8006C2F0() == 0) && (D_800DD390 == 0) + if ((buttonPressedInputs & START_BUTTON) && (func_8006C2F0() == 0) && (D_800DD390 == 0) && (D_801234EC == 0) && (D_80123516 == 0) && (D_800DD394 == 0) && (D_800DD398 == 0)) { buttonPressedInputs = 0; gIsPaused = TRUE; @@ -1121,49 +1122,49 @@ void func_8006CCF0(s32 arg0) { if (gIsPaused) { i = func_80094170(&gCurrDisplayList, arg0); switch (i - 1) { - case 0: - gIsPaused = FALSE; - break; - case 1: - func_80001050(); - func_800C314C(); - if (func_80023568() != 0 && is_in_two_player_adventure()) { - func_8006F398(); - } - buttonHeldInputs |= (L_TRIG | R_TRIG); - break; - case 2: - func_80001050(); - func_800C314C(); - if (func_80023568() != 0 && is_in_two_player_adventure()) { - func_8006F398(); - } - buttonHeldInputs |= L_TRIG; - break; - case 4: - sp40 = 1; - func_800C314C(); - buttonHeldInputs |= L_TRIG; - break; - case 11: - sp40 = 6; - func_800C314C(); - buttonHeldInputs |= L_TRIG; - break; - case 5: - gIsPaused = FALSE; - break; - case 6: - func_80022E18(1); - gIsPaused = FALSE; - break; - case 3: - D_800DD390 = 0; - func_80001050(); - func_800C314C(); - func_8006C2E4(); - buttonHeldInputs |= (L_TRIG | R_TRIG); - break; + case 0: + gIsPaused = FALSE; + break; + case 1: + func_80001050(); + func_800C314C(); + if (func_80023568() != 0 && is_in_two_player_adventure()) { + func_8006F398(); + } + buttonHeldInputs |= (L_TRIG | R_TRIG); + break; + case 2: + func_80001050(); + func_800C314C(); + if (func_80023568() != 0 && is_in_two_player_adventure()) { + func_8006F398(); + } + buttonHeldInputs |= L_TRIG; + break; + case 4: + sp40 = 1; + func_800C314C(); + buttonHeldInputs |= L_TRIG; + break; + case 11: + sp40 = 6; + func_800C314C(); + buttonHeldInputs |= L_TRIG; + break; + case 5: + gIsPaused = FALSE; + break; + case 6: + func_80022E18(1); + gIsPaused = FALSE; + break; + case 3: + D_800DD390 = 0; + func_80001050(); + func_800C314C(); + func_8006C2E4(); + buttonHeldInputs |= (L_TRIG | R_TRIG); + break; } } func_80078054(&gCurrDisplayList); @@ -1192,7 +1193,7 @@ void func_8006CCF0(s32 arg0) { D_800DD394 -= arg0; if (D_800DD394 <= 0) { buttonHeldInputs = L_TRIG; - switch(D_80123524) { + switch (D_80123524) { case 1: buttonHeldInputs = (L_TRIG | Z_TRIG); break; @@ -1295,7 +1296,7 @@ void func_8006CCF0(s32 arg0) { // Trophy race related? load_menu_with_level_background(MENU_UNUSED_22, 0x22, 0); break; - case 6: + case 6: // Go to character select menu from "Select Character" option in tracks menu. i = 0; if (is_drumstick_unlocked() != 0) { @@ -1384,7 +1385,7 @@ void func_8006D968(s8 *arg0) { s32 i; if (D_801234EC != 4) { D_80121250[0] = D_801234F4; - for(i = 0; i < 2; i++) { + for (i = 0; i < 2; i++) { D_80121250[i + 2] = arg0[i + 8]; D_80121250[i + 4] = arg0[i + 10]; D_80121250[i + 6] = arg0[i + 12]; @@ -1415,7 +1416,7 @@ void load_menu_with_level_background(s32 menuId, s32 levelId, s32 cutsceneId) { func_80004A60(1, 0x7FFF); func_80004A60(2, 0x7FFF); func_80065EA0(); - + if (!D_80123514) { D_80123514 = FALSE; if (levelId < 0) { @@ -1490,7 +1491,7 @@ void func_8006DC58(s32 arg0) { // Minor & regalloc issues. void func_8006DCF8(s32 arg0) { s32 menuLoopResult, temp, temp2, tempResult; - + gIsPaused = FALSE; D_80123516 = 0; if (!D_80123514 && D_801234F0) { @@ -1505,8 +1506,8 @@ void func_8006DCF8(s32 arg0) { if ((menuLoopResult != -1) && (menuLoopResult & 0x200)) { func_8006DBE4(); gCurrDisplayList = gDisplayLists[D_801234E8]; - gDPFullSync(gCurrDisplayList++) - gSPEndDisplayList(gCurrDisplayList++) + gDPFullSync(gCurrDisplayList++); + gSPEndDisplayList(gCurrDisplayList++); D_801234F4 = menuLoopResult & 0x7F; D_80123518 = func_8006B0AC(D_801234F4); D_80123504 = 0; @@ -1573,8 +1574,8 @@ void func_8006DCF8(s32 arg0) { func_8006DBE4(); // Minor issue here. gCurrDisplayList = gDisplayLists[D_801234E8]; - gDPFullSync(gCurrDisplayList++) - gSPEndDisplayList(gCurrDisplayList++) + gDPFullSync(gCurrDisplayList++); + gSPEndDisplayList(gCurrDisplayList++); temp = menuLoopResult & 0x7F; D_80121250[1] = temp; D_80121250[0] = D_801234F4; @@ -1592,8 +1593,8 @@ void func_8006DCF8(s32 arg0) { if (menuLoopResult > 0) { func_8006DBE4(); gCurrDisplayList = gDisplayLists[D_801234E8]; - gDPFullSync(gCurrDisplayList++) - gSPEndDisplayList(gCurrDisplayList++) + gDPFullSync(gCurrDisplayList++); + gSPEndDisplayList(gCurrDisplayList++); D_801234EC = 0; func_8006CAE4(menuLoopResult, -1, D_80123518); if (gSettingsPtr->newGame && !is_in_tracks_mode()) { @@ -1612,8 +1613,8 @@ void load_level_for_menu(s32 levelId, s32 numberOfPlayers, s32 cutsceneId) { func_8006DBE4(); if (get_thread30_level_id_to_load() == 0) { gCurrDisplayList = gDisplayLists[D_801234E8]; - gDPFullSync(gCurrDisplayList++) - gSPEndDisplayList(gCurrDisplayList++) + gDPFullSync(gCurrDisplayList++); + gSPEndDisplayList(gCurrDisplayList++); } } if (levelId != -1) { @@ -1628,7 +1629,7 @@ void calc_and_alloc_heap_for_settings(void) { s32 dataSize; u32 sizes[15]; s32 numWorlds, numLevels; - + func_8006A6B0(); reset_character_id_slots(); get_number_of_levels_and_worlds(&numLevels, &numWorlds); @@ -1636,35 +1637,35 @@ void calc_and_alloc_heap_for_settings(void) { sizes[1] = sizes[0] + (numLevels * 4); // balloonsPtr sizes[2] = sizes[1] + (numWorlds * 2); // flapInitialsPtr[0] dataSize = (numLevels * 2); - sizes[3] = sizes[2] + dataSize; // flapInitialsPtr[1] - sizes[4] = sizes[3] + dataSize; // flapInitialsPtr[2] - sizes[5] = sizes[4] + dataSize; // flapTimesPtr[0] - sizes[6] = sizes[5] + dataSize; // flapTimesPtr[1] - sizes[7] = sizes[6] + dataSize; // flapTimesPtr[2] - sizes[8] = sizes[7] + dataSize; // courseInitialsPtr[0] - sizes[9] = sizes[8] + dataSize; // courseInitialsPtr[1] - sizes[10] = sizes[9] + dataSize; // courseInitialsPtr[2] + sizes[3] = sizes[2] + dataSize; // flapInitialsPtr[1] + sizes[4] = sizes[3] + dataSize; // flapInitialsPtr[2] + sizes[5] = sizes[4] + dataSize; // flapTimesPtr[0] + sizes[6] = sizes[5] + dataSize; // flapTimesPtr[1] + sizes[7] = sizes[6] + dataSize; // flapTimesPtr[2] + sizes[8] = sizes[7] + dataSize; // courseInitialsPtr[0] + sizes[9] = sizes[8] + dataSize; // courseInitialsPtr[1] + sizes[10] = sizes[9] + dataSize; // courseInitialsPtr[2] sizes[11] = sizes[10] + dataSize; // courseTimesPtr[0] sizes[12] = sizes[11] + dataSize; // courseTimesPtr[1] sizes[13] = sizes[12] + dataSize; // courseTimesPtr[2] sizes[14] = sizes[13] + dataSize; // total size - + gSettingsPtr = allocate_from_main_pool_safe(sizes[14], COLOR_TAG_WHITE); - gSettingsPtr->courseFlagsPtr = (u8*)gSettingsPtr + sizes[0]; - gSettingsPtr->balloonsPtr = (u8*)gSettingsPtr + sizes[1]; + gSettingsPtr->courseFlagsPtr = (u8 *)gSettingsPtr + sizes[0]; + gSettingsPtr->balloonsPtr = (u8 *)gSettingsPtr + sizes[1]; gSettingsPtr->tajFlags = 0; - gSettingsPtr->flapInitialsPtr[0] = (u8*)gSettingsPtr + sizes[2]; - gSettingsPtr->flapInitialsPtr[1] = (u8*)gSettingsPtr + sizes[3]; - gSettingsPtr->flapInitialsPtr[2] = (u8*)gSettingsPtr + sizes[4]; - gSettingsPtr->flapTimesPtr[0] = (u8*)gSettingsPtr + sizes[5]; - gSettingsPtr->flapTimesPtr[1] = (u8*)gSettingsPtr + sizes[6]; - gSettingsPtr->flapTimesPtr[2] = (u8*)gSettingsPtr + sizes[7]; - gSettingsPtr->courseInitialsPtr[0] = (u8*)gSettingsPtr + sizes[8]; - gSettingsPtr->courseInitialsPtr[1] = (u8*)gSettingsPtr + sizes[9]; - gSettingsPtr->courseInitialsPtr[2] = (u8*)gSettingsPtr + sizes[10]; - gSettingsPtr->courseTimesPtr[0] = (u8*)gSettingsPtr + sizes[11]; - gSettingsPtr->courseTimesPtr[1] = (u8*)gSettingsPtr + sizes[12]; - gSettingsPtr->courseTimesPtr[2] = (u8*)gSettingsPtr + sizes[13]; + gSettingsPtr->flapInitialsPtr[0] = (u8 *)gSettingsPtr + sizes[2]; + gSettingsPtr->flapInitialsPtr[1] = (u8 *)gSettingsPtr + sizes[3]; + gSettingsPtr->flapInitialsPtr[2] = (u8 *)gSettingsPtr + sizes[4]; + gSettingsPtr->flapTimesPtr[0] = (u8 *)gSettingsPtr + sizes[5]; + gSettingsPtr->flapTimesPtr[1] = (u8 *)gSettingsPtr + sizes[6]; + gSettingsPtr->flapTimesPtr[2] = (u8 *)gSettingsPtr + sizes[7]; + gSettingsPtr->courseInitialsPtr[0] = (u8 *)gSettingsPtr + sizes[8]; + gSettingsPtr->courseInitialsPtr[1] = (u8 *)gSettingsPtr + sizes[9]; + gSettingsPtr->courseInitialsPtr[2] = (u8 *)gSettingsPtr + sizes[10]; + gSettingsPtr->courseTimesPtr[0] = (u8 *)gSettingsPtr + sizes[11]; + gSettingsPtr->courseTimesPtr[1] = (u8 *)gSettingsPtr + sizes[12]; + gSettingsPtr->courseTimesPtr[2] = (u8 *)gSettingsPtr + sizes[13]; gSettingsPtr->unk4C = &D_80121250; D_800DD37C = 263; } @@ -1683,11 +1684,11 @@ void func_8006E5BC(void) { gSettingsPtr->racers[i].starting_position = 7 - i; } gSettingsPtr->racers[i].unk7 = 0; - for(j = 0; j < 4; j++) { + for (j = 0; j < 4; j++) { gSettingsPtr->racers[i].placements[j] = 0; } gSettingsPtr->racers[i].course_time = 0; - for(j = 0; j < 3; j++) { + for (j = 0; j < 3; j++) { gSettingsPtr->racers[i].lap_times[j] = 0; } } @@ -1704,11 +1705,11 @@ void func_8006E770(Settings *settings, s32 arg1) { s32 numWorlds, numLevels; s32 index; u16 *temp_v0; - + get_number_of_levels_and_worlds(&numLevels, &numWorlds); - temp_v0 = (u16*)get_misc_asset(0x17); + temp_v0 = (u16 *)get_misc_asset(0x17); for (i = 0; i < 3; i++) { // 3 = number of save files? - for(j = 0; j < numLevels; j++) { + for (j = 0; j < numLevels; j++) { index = (j * 12) + (i * 4); if (arg1 & 1) { settings->flapInitialsPtr[i][j] = temp_v0[index + 3]; @@ -1729,14 +1730,14 @@ void func_8006E994(Settings *settings) { get_number_of_levels_and_worlds(&sp1C, &sp20); settings->newGame = 1; - + for (i = 0; i < sp20; i++) { settings->balloonsPtr[i] = 0; } - for(i = 0; i < sp1C; i++) { + for (i = 0; i < sp1C; i++) { settings->courseFlagsPtr[i] = 0; } - + settings->keys = 0; settings->unkA = 0; settings->bosses = 0; @@ -1770,7 +1771,7 @@ s8 func_8006EAB0(void) { s32 func_8006EAC0(void) { if (D_80123560[0] == 0) { - D_80123560[0] = (s32) ((osRecvMesg(&D_80123548, NULL, 0) + 1) != 0); + D_80123560[0] = (s32)((osRecvMesg(&D_80123548, NULL, 0) + 1) != 0); } return D_80123560[0]; } @@ -1842,8 +1843,8 @@ void func_8006ECE0(void) { GLOBAL_ASM("asm/non_matchings/unknown_06B2B0/func_8006ECFC.s") s32 func_8006EFB8(void) { - // Have to use literal here for this function to match. - if (*((s32*)0xA4000000) != -1) { + //Could be SP_DMEM_START / CACHERR_EE / SR_FR / M_K0 / LEO_STATUS_BUFFER_MANAGER_INTERRUPT + if (IO_READ(SP_DMEM_START) != -1) { return 0; } return 1; @@ -1856,23 +1857,23 @@ void func_8006EFDC(void) { s32 size1, size2, size3, size4, totalSize; D_8012350C = 3; - + size1 = (gNumF3dCmdsPerPlayer[3] * sizeof(Gwords)); size2 = (gNumHudMatPerPlayer[3] * sizeof(Mtx)); size3 = (gNumHudVertsPerPlayer[3] * sizeof(Vertex)); size4 = (gNumHudTrisPerPlayer[3] * sizeof(Triangle)); totalSize = size1 + size2 + size3 + size4; - - gDisplayLists[0] = (u8*)allocate_from_main_pool_safe(totalSize, COLOR_TAG_RED); - gHudMatrices[0] = (u8*)gDisplayLists[0] + size1; - gHudVertices[0] = (u8*)gHudMatrices[0] + size2; - gHudTriangles[0] = (u8*)gHudVertices[0] + size3; - - gDisplayLists[1] = (u8*)allocate_from_main_pool_safe(totalSize, COLOR_TAG_YELLOW); - gHudMatrices[1] = (u8*)gDisplayLists[1] + size1; - gHudVertices[1] = (u8*)gHudMatrices[1] + size2; - gHudTriangles[1] = (u8*)gHudVertices[1] + size3; - + + gDisplayLists[0] = (u8 *)allocate_from_main_pool_safe(totalSize, COLOR_TAG_RED); + gHudMatrices[0] = (u8 *)gDisplayLists[0] + size1; + gHudVertices[0] = (u8 *)gHudMatrices[0] + size2; + gHudTriangles[0] = (u8 *)gHudVertices[0] + size3; + + gDisplayLists[1] = (u8 *)allocate_from_main_pool_safe(totalSize, COLOR_TAG_YELLOW); + gHudMatrices[1] = (u8 *)gDisplayLists[1] + size1; + gHudVertices[1] = (u8 *)gHudMatrices[1] + size2; + gHudTriangles[1] = (u8 *)gHudVertices[1] + size3; + gCurrNumF3dCmdsPerPlayer = gNumF3dCmdsPerPlayer[3]; gCurrNumHudMatPerPlayer = gNumHudMatPerPlayer[3]; gCurrNumHudTrisPerPlayer = gNumHudTrisPerPlayer[3]; @@ -1954,11 +1955,11 @@ void func_8006F398(void) { func_8006A50C(); func_8000E194(); - - first_racer_data = (u8*)(gSettingsPtr->racers); - second_racer_data = (u8*)(gSettingsPtr->racers + 1); - - for(i = 0; i < sizeof(Racer); i++) { + + first_racer_data = (u8 *)(gSettingsPtr->racers); + second_racer_data = (u8 *)(gSettingsPtr->racers + 1); + + for (i = 0; i < sizeof(Racer); i++) { temp = first_racer_data[i]; first_racer_data[i] = second_racer_data[i]; second_racer_data[i] = temp; @@ -1972,8 +1973,8 @@ void func_8006F42C(void) { void func_8006F43C(void) { s32 i; s32 buttonInputs = 0; - - for(i = 0; i < MAXCONTROLLERS; i++) { + + for (i = 0; i < MAXCONTROLLERS; i++) { buttonInputs |= get_buttons_held_from_player(i); } if (buttonInputs & START_BUTTON) { @@ -1994,8 +1995,9 @@ s32 func_8006F4C8(void) { } s32 func_8006F4EC(void) { - // Have to use a literal here for the function to match. - if (*((s32*)0xA4001000) != 0x17D7) { + if (IO_READ(SP_IMEM_START) != + (SP_STATUS_HALT | SP_STATUS_BROKE | SP_STATUS_DMA_BUSY | SP_STATUS_IO_FULL | SP_STATUS_INTR_BREAK | SP_STATUS_YIELD | + SP_STATUS_YIELDED | SP_STATUS_TASKDONE | SP_STATUS_TASKDONE | SP_STATUS_RSPSIGNAL | SP_STATUS_SIG5)) { return 0; } return 1; diff --git a/src/unknown_077C50.c b/src/unknown_077C50.c index d5b196b2..f52c4328 100644 --- a/src/unknown_077C50.c +++ b/src/unknown_077C50.c @@ -21,25 +21,25 @@ void render_borders_for_multiplayer(Gfx **dlist) { temp0 = width >> 8; height = widthAndHeight >> 16; temp1 = height >> 7; - gDPSetCycleType((*dlist)++, G_CYC_FILL) - gDPSetFillColor((*dlist)++, 0x00010001) // Black fill color - switch(get_viewport_count()){ + gDPSetCycleType((*dlist)++, G_CYC_FILL); + gDPSetFillColor((*dlist)++, 0x00010001); // Black fill color + switch (get_viewport_count()) { case VIEWPORTS_COUNT_2_PLAYERS: // Draws a solid horizontal black line in the middle of the screen. - gDPFillRectangle((*dlist)++, 0, (height >> 1) - temp1, width, ((height >> 1) - temp1) + temp1) + gDPFillRectangle((*dlist)++, 0, (height >> 1) - temp1, width, ((height >> 1) - temp1) + temp1); break; case VIEWPORTS_COUNT_3_PLAYERS: levelHeader = get_current_level_header(); // Draw black square in the bottom-right corner. if (func_800A8458() || (levelHeader->race_type & 0x40)) { - gDPFillRectangle((*dlist)++, width >> 1, height >> 1, width, height) + gDPFillRectangle((*dlist)++, width >> 1, height >> 1, width, height); } // There is no break statement here. This is intentional. case VIEWPORTS_COUNT_4_PLAYERS: temp2 = (width >> 1) - temp0; // Draws 2 black lines in the middle of the screen. One vertical, another horizontal. - gDPFillRectangle((*dlist)++, 0, (height >> 1) - temp1, width, ((height >> 1) - temp1) + temp1) - gDPFillRectangle((*dlist)++, temp2, 0, temp2 + temp0, height) + gDPFillRectangle((*dlist)++, 0, (height >> 1) - temp1, width, ((height >> 1) - temp1) + temp1); + gDPFillRectangle((*dlist)++, temp2, 0, temp2 + temp0, height); break; } return; @@ -62,22 +62,22 @@ void func_80077268(Gfx **dlist) { widthAndHeight = get_video_width_and_height_as_s32(); height = widthAndHeight >> 16; width = widthAndHeight & 0xFFFF; - gDPSetCycleType((*dlist)++, G_CYC_1CYCLE) - gDPSetCombineMode((*dlist)++, G_CC_PRIMITIVE, G_CC_PRIMITIVE) - gDPSetRenderMode((*dlist)++, G_RM_XLU_SURF, G_RM_XLU_SURF2) - gDPSetPrimColor((*dlist)++, 0, 0, 0, 0, 0, 0) + gDPSetCycleType((*dlist)++, G_CYC_1CYCLE); + gDPSetCombineMode((*dlist)++, G_CC_PRIMITIVE, G_CC_PRIMITIVE); + gDPSetRenderMode((*dlist)++, G_RM_XLU_SURF, G_RM_XLU_SURF2); + gDPSetPrimColor((*dlist)++, 0, 0, 0, 0, 0, 0); // Issues with this block. switch(get_viewport_count()){ case VIEWPORTS_COUNT_2_PLAYERS: temp_v0_4 = (height >> 1) - (temp_t2 >> 1); - gDPFillRectangle((*dlist)++, 0, temp_v0_4, width, temp_v0_4 + temp_t2) + gDPFillRectangle((*dlist)++, 0, temp_v0_4, width, temp_v0_4 + temp_t2); break; case VIEWPORTS_COUNT_3_PLAYERS: case VIEWPORTS_COUNT_4_PLAYERS: temp_v0_3 = (height >> 1) - (temp_t2 >> 1); temp_a2_2 = (width >> 1) - (ra >> 1); - gDPFillRectangle((*dlist)++, 0, temp_v0_3, width, temp_v0_3 + temp_t2) - gDPFillRectangle((*dlist)++, temp_a2_2, 0, temp_a2_2 + ra, height) + gDPFillRectangle((*dlist)++, 0, temp_v0_3, width, temp_v0_3 + temp_t2); + gDPFillRectangle((*dlist)++, temp_a2_2, 0, temp_a2_2 + ra, height); break; } } diff --git a/src/unknown_078050.c b/src/unknown_078050.c index 8e8e8d88..107d0bf1 100644 --- a/src/unknown_078050.c +++ b/src/unknown_078050.c @@ -52,53 +52,53 @@ Gfx D_800DE520[] = { gsDPSetAlphaCompare(G_AC_NONE), gsDPSetRenderMode(G_RM_OPA_SURF, G_RM_OPA_SURF2), gsDPSetColorDither(G_CD_MAGICSQ), - gsDPPipeSync(), + gsDPPipeSync(), gsSPEndDisplayList(), }; Gfx D_800DE598[] = { - gsDPPipeSync(), + gsDPPipeSync(), gsDPSetTextureLOD(G_TL_TILE), gsDPSetTextureLUT(G_TT_NONE), gsDPSetAlphaCompare(G_AC_NONE), gsSPClearGeometryMode(G_ZBUFFER | G_FOG), - gsDPPipeSync(), + gsDPPipeSync(), gsDPSetCombineMode(G_CC_DECALRGBA, G_CC_DECALRGBA), gsDPSetOtherMode(DKR_OMH_1CYC_POINT_NOPERSP, DKR_OML_COMMON | G_RM_OPA_SURF | G_RM_OPA_SURF2), gsSPEndDisplayList(), }; Gfx D_800DE5E0[] = { - gsDPPipeSync(), + gsDPPipeSync(), gsDPSetTextureLOD(G_TL_TILE), gsDPSetTextureLUT(G_TT_NONE), gsDPSetAlphaCompare(G_AC_NONE), gsSPClearGeometryMode(G_ZBUFFER | G_FOG), - gsDPPipeSync(), + gsDPPipeSync(), gsDPSetCombineMode(G_CC_PRIMITIVE, G_CC_PRIMITIVE), gsDPSetOtherMode(DKR_OMH_1CYC_POINT_NOPERSP, DKR_OML_COMMON | G_RM_OPA_SURF | G_RM_OPA_SURF2), gsSPEndDisplayList(), }; Gfx D_800DE628[] = { - gsDPPipeSync(), + gsDPPipeSync(), gsDPSetTextureLOD(G_TL_TILE), gsDPSetTextureLUT(G_TT_NONE), gsDPSetAlphaCompare(G_AC_NONE), gsSPClearGeometryMode(G_ZBUFFER | G_FOG), - gsDPPipeSync(), + gsDPPipeSync(), gsDPSetCombineMode(G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM), gsDPSetOtherMode(DKR_OMH_1CYC_POINT_NOPERSP, DKR_OML_COMMON | G_RM_XLU_SURF | G_RM_XLU_SURF2), gsSPEndDisplayList(), }; Gfx D_800DE670[] = { - gsDPPipeSync(), + gsDPPipeSync(), gsDPSetTextureLOD(G_TL_TILE), gsDPSetTextureLUT(G_TT_NONE), gsDPSetAlphaCompare(G_AC_NONE), gsSPClearGeometryMode(G_ZBUFFER | G_FOG), - gsDPPipeSync(), + gsDPPipeSync(), gsSPEndDisplayList(), }; @@ -146,14 +146,14 @@ Gfx D_800DE6E8[][2] = { s32 D_801242A0[256]; s32 D_801246A0[1536]; -OSMesgQueue D_80125EA0; -OSMesg D_80125EB8; -OSMesgQueue D_80125EC0; -OSMesgQueue D_80125ED8; -OSMesg D_80125EF0; -s32 D_80125EF8[6]; -OSMesg D_80125F10; -s32 D_80125F18[6]; +OSMesgQueue D_80125EA0; +OSMesg D_80125EB8; +OSMesgQueue D_80125EC0; +OSMesgQueue D_80125ED8; +OSMesg D_80125EF0; +s32 D_80125EF8[6]; +OSMesg D_80125F10; +s32 D_80125F18[6]; u8 D_80125F30; u8 D_80125F31; u8 D_80125F32; @@ -215,15 +215,15 @@ void render_background(Gfx **dlist, s32 *arg1, s32 arg2) { widthAndHeight = get_video_width_and_height_as_s32(); w = widthAndHeight & 0xFFFF; h = widthAndHeight >> 0x10; - - gDPPipeSync((*dlist)++) - gDPSetScissor((*dlist)++, 0, 0, 0, w - 1, h - 1) - gDPSetCycleType((*dlist)++, G_CYC_FILL) - gDPSetColorImage((*dlist)++, G_IM_FMT_RGBA, G_IM_SIZ_16b, w, 0x02000000) - gDPSetFillColor((*dlist)++, 0xFFFCFFFC) - gDPFillRectangle((*dlist)++, 0, 0, w - 1, h - 1) - gDPPipeSync((*dlist)++) - gDPSetColorImage((*dlist)++, G_IM_FMT_RGBA, G_IM_SIZ_16b, w, 0x01000000) + + gDPPipeSync((*dlist)++); + gDPSetScissor((*dlist)++, 0, 0, 0, w - 1, h - 1); + gDPSetCycleType((*dlist)++, G_CYC_FILL); + gDPSetColorImage((*dlist)++, G_IM_FMT_RGBA, G_IM_SIZ_16b, w, 0x02000000); + gDPSetFillColor((*dlist)++, 0xFFFCFFFC); + gDPFillRectangle((*dlist)++, 0, 0, w - 1, h - 1); + gDPPipeSync((*dlist)++); + gDPSetColorImage((*dlist)++, G_IM_FMT_RGBA, G_IM_SIZ_16b, w, 0x01000000); if (arg2) { if (func_80066910(0)) { if (D_800DE4CC) { @@ -233,17 +233,17 @@ void render_background(Gfx **dlist, s32 *arg1, s32 arg2) { } else if (D_800DE4D0.ptr != NULL) { D_800DE4D0.function(dlist, arg1); } else { - gDPSetFillColor((*dlist)++, D_800DE4BC) - gDPFillRectangle((*dlist)++, 0, 0, w - 1, h - 1) + gDPSetFillColor((*dlist)++, D_800DE4BC); + gDPFillRectangle((*dlist)++, 0, 0, w - 1, h - 1); } if (func_80066BA8(0, &sp90, &sp8C, &sp88, &sp84)) { - gDPSetCycleType((*dlist)++, G_CYC_1CYCLE) - gDPSetPrimColor((*dlist)++, 0, 0, D_800DE4B0, D_800DE4B4, D_800DE4B8, 0xFF) - gDPSetCombineMode((*dlist)++, G_CC_PRIMITIVE, G_CC_PRIMITIVE) - gDPSetRenderMode((*dlist)++, G_RM_OPA_SURF, G_RM_OPA_SURF2) - gDPFillRectangle((*dlist)++, sp90, sp8C, sp88, sp84) + gDPSetCycleType((*dlist)++, G_CYC_1CYCLE); + gDPSetPrimColor((*dlist)++, 0, 0, D_800DE4B0, D_800DE4B4, D_800DE4B8, 0xFF); + gDPSetCombineMode((*dlist)++, G_CC_PRIMITIVE, G_CC_PRIMITIVE); + gDPSetRenderMode((*dlist)++, G_RM_OPA_SURF, G_RM_OPA_SURF2); + gDPFillRectangle((*dlist)++, sp90, sp8C, sp88, sp84); } - } else { + } else { if (D_800DE4CC) { func_800787FC(dlist); } else if (D_800DE4C4 != 0) { @@ -254,12 +254,12 @@ void render_background(Gfx **dlist, s32 *arg1, s32 arg2) { //Also has an issue here. rgba16Color = ((D_800DE4B0 << 8) & 0xF800) | ((D_800DE4B4 * 8) & 0x7C0) | ((D_800DE4B8 >> 2) & 0x3E) | 1; rgba16Color |= rgba16Color << 0x10; - gDPSetFillColor((*dlist)++, rgba16Color) - gDPFillRectangle((*dlist)++, 0, 0, w - 1, h - 1) + gDPSetFillColor((*dlist)++, rgba16Color); + gDPFillRectangle((*dlist)++, 0, 0, w - 1, h - 1); } } } - gDPPipeSync((*dlist)++) + gDPPipeSync((*dlist)++); func_80067A3C(dlist); } #else @@ -268,20 +268,20 @@ GLOBAL_ASM("asm/non_matchings/unknown_078050/render_background.s") void func_80078054(Gfx **dlist) { s32 width = get_video_width_and_height_as_s32() & 0xFFF; - gDPSetColorImage((*dlist)++, G_IM_FMT_RGBA, G_IM_SIZ_16b, width, 0x01000000) - gDPSetDepthImage((*dlist)++, 0x2000000) - gSPDisplayList((*dlist)++, D_800DE520) + gDPSetColorImage((*dlist)++, G_IM_FMT_RGBA, G_IM_SIZ_16b, width, 0x01000000); + gDPSetDepthImage((*dlist)++, 0x2000000); + gSPDisplayList((*dlist)++, D_800DE520); } void func_800780DC(Gfx **dlist) { - gSPDisplayList((*dlist)++, D_800DE4E0) + gSPDisplayList((*dlist)++, D_800DE4E0); } void func_80078100(OSSched *sc) { osScInterruptQ = osScGetInterruptQ(sc); - osCreateMesgQueue(&D_80125EA0, &D_80125EB8,1); - osCreateMesgQueue(&D_80125EC0, &D_80125EF0,8); - osCreateMesgQueue(&D_80125ED8, &D_80125F10,8); + osCreateMesgQueue(&D_80125EA0, &D_80125EB8, 1); + osCreateMesgQueue(&D_80125EC0, &D_80125EF0, 8); + osCreateMesgQueue(&D_80125ED8, &D_80125F10, 8); } void func_80078170(u32 arg0, u32 arg1, u32 arg2) { @@ -314,7 +314,7 @@ void func_800787F0(void) { GLOBAL_ASM("asm/non_matchings/unknown_078050/func_800787FC.s") -void func_80078AAC(u32 arg0){ +void func_80078AAC(u32 arg0) { D_800DE4D0.ptr = arg0; } @@ -326,10 +326,10 @@ void render_textured_rectangle(Gfx **dlist, DrawTexture *arg1, s32 arg2, s32 arg DrawTexture *phi_t2; s32 x0, y0; s32 x1, y1; - s32 u, v; + s32 u, v; - gSPDisplayList((*dlist)++, D_800DE628) - gDPSetPrimColor((*dlist)++, 0, 0, red, green, blue, alpha) + gSPDisplayList((*dlist)++, D_800DE628); + gDPSetPrimColor((*dlist)++, 0, 0, red, green, blue, alpha); tex = arg1->texture; while (tex != NULL) { x0 = (arg1->xOffset * 4) + (arg2 * 4); @@ -348,15 +348,15 @@ void render_textured_rectangle(Gfx **dlist, DrawTexture *arg1, s32 arg2, s32 arg v = -(y0 * 8); y0 = 0; } - gDkrDmaDisplayList((*dlist)++, tex->cmd + 0x80000000, tex->numberOfCommands) - gSPTextureRectangle((*dlist)++, x0, y0, x1, y1, 0, u, v, 1024, 1024) + gDkrDmaDisplayList((*dlist)++, tex->cmd + 0x80000000, tex->numberOfCommands); + gSPTextureRectangle((*dlist)++, x0, y0, x1, y1, 0, u, v, 1024, 1024); } } arg1++; tex = arg1->texture; } - gDPPipeSync((*dlist)++) - gDPSetPrimColor((*dlist)++, 0, 0, 255, 255, 255, 255) + gDPPipeSync((*dlist)++); + gDPSetPrimColor((*dlist)++, 0, 0, 255, 255, 255, 255); } #else GLOBAL_ASM("asm/non_matchings/unknown_078050/render_textured_rectangle.s") diff --git a/src/unknown_078050.h b/src/unknown_078050.h index c1a0fd1c..b10a75ea 100644 --- a/src/unknown_078050.h +++ b/src/unknown_078050.h @@ -4,7 +4,7 @@ #include "types.h" #include "structs.h" #include "f3ddkr.h" -#include "lib/src/mips1/sc/sched.h" +#include "sched.h" #include "libultra_internal.h" typedef union { diff --git a/src/unknown_09F8F0.c b/src/unknown_09F8F0.c index 3f3dc492..1f834b47 100644 --- a/src/unknown_09F8F0.c +++ b/src/unknown_09F8F0.c @@ -79,38 +79,37 @@ unk800E1E64 D_800E1E64[59] = { }; u16 D_800E25C4[96] = { - 0x0000, 0x0035, 0x0010, 0x0001, 0x0036, 0x0012, 0x0004, 0x00CB, - 0x0013, 0x0005, 0x00D3, 0x0013, 0x0006, 0x00DC, 0x0013, 0x0002, - 0xFF88, 0xFFE1, 0x001B, 0x0021, 0x0016, 0x0008, 0x00D3, 0x0013, - 0x0009, 0x00DC, 0x0013, 0x000B, 0x00A7, 0x0013, 0x000E, 0x0000, - 0x000A, 0x0010, 0x003B, 0x0023, 0x0011, 0x003B, 0x0023, 0x0007, - 0x0021, 0x0016, 0x001C, 0x001E, 0x002A, 0x0012, 0x00CA, 0x0013, + 0x0000, 0x0035, 0x0010, 0x0001, 0x0036, 0x0012, 0x0004, 0x00CB, + 0x0013, 0x0005, 0x00D3, 0x0013, 0x0006, 0x00DC, 0x0013, 0x0002, + 0xFF88, 0xFFE1, 0x001B, 0x0021, 0x0016, 0x0008, 0x00D3, 0x0013, + 0x0009, 0x00DC, 0x0013, 0x000B, 0x00A7, 0x0013, 0x000E, 0x0000, + 0x000A, 0x0010, 0x003B, 0x0023, 0x0011, 0x003B, 0x0023, 0x0007, + 0x0021, 0x0016, 0x001C, 0x001E, 0x002A, 0x0012, 0x00CA, 0x0013, 0x000D, 0x0000, 0x000A, 0x000C, 0x0000, 0x000A, 0x0023, 0x0000, - 0x000A, 0x0024, 0x0000, 0x000A, 0x001E, 0x0000, 0x000A, 0x001F, - 0x0000, 0x000A, 0x001D, 0x0000, 0x000A, 0x002F, 0xFF38, 0x0023, - 0x0030, 0xFF51, 0x0025, 0x0031, 0xFF96, 0xFFD3, 0x0003, 0x00B4, - 0x0013, 0x0032, 0x0107, 0x0011, 0x0020, 0x00F7, 0x002D, 0x0033, - 0x0103, 0x0031, 0x002E, 0x0022, 0x0047, 0xFFFF, 0xFFFF, 0xFFFF + 0x000A, 0x0024, 0x0000, 0x000A, 0x001E, 0x0000, 0x000A, 0x001F, + 0x0000, 0x000A, 0x001D, 0x0000, 0x000A, 0x002F, 0xFF38, 0x0023, + 0x0030, 0xFF51, 0x0025, 0x0031, 0xFF96, 0xFFD3, 0x0003, 0x00B4, + 0x0013, 0x0032, 0x0107, 0x0011, 0x0020, 0x00F7, 0x002D, 0x0033, + 0x0103, 0x0031, 0x002E, 0x0022, 0x0047, 0xFFFF, 0xFFFF, 0xFFFF, }; u16 D_800E2684[118] = { - 0x0000, 0x002D, 0x0010, 0x0087, 0x0004, 0x005E, 0x0013, 0x004E, - 0x0005, 0x0066, 0x0013, 0x0056, 0x0006, 0x006F, 0x0013, 0x005F, - 0x0002, 0xFFD1, 0xFFDC, 0x0024, 0x001B, 0x0000, 0x0016, 0xFFE3, - 0x0007, 0x0000, 0x0016, 0xFFE3, 0x0008, 0x0061, 0x0013, 0x0044, - 0x0009, 0x006A, 0x0013, 0x004D, 0x000B, 0x0037, 0x0013, 0x001A, - 0x000C, 0x0000, 0x000A, 0x0000, 0x000D, 0x0000, 0x000A, 0x0000, - 0x000E, 0xFF60, 0x000A, 0xFF60, 0x0010, 0x0066, 0x0013, 0x0056, - 0x0011, 0x0066, 0x0013, 0x0056, 0x0012, 0x0058, 0x0013, 0x003B, - 0x001C, 0xFFFD, 0x002A, 0xFFE0, 0x0020, 0x0012, 0x002D, 0x0078, - 0x001E, 0xFFEA, 0x000A, 0xFFEA, 0x001F, 0x000C, 0x000A, 0x0010, - 0x001D, 0x0000, 0x000A, 0xFFD9, 0x0023, 0x0000, 0x000A, 0x0000, - 0x0024, 0x0000, 0x000A, 0x0000, 0x002F, 0xFF38, 0x0019, 0xFFD8, - 0x0030, 0xFF51, 0x001B, 0xFFF1, 0x0031, 0xFFDF, 0xFFCE, 0x0032, - 0x0003, 0x0047, 0x0013, 0x0037, 0x0033, 0x003C, 0x0014, 0x003C, - 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x0000, 0x0000 + 0x0000, 0x002D, 0x0010, 0x0087, 0x0004, 0x005E, 0x0013, 0x004E, + 0x0005, 0x0066, 0x0013, 0x0056, 0x0006, 0x006F, 0x0013, 0x005F, + 0x0002, 0xFFD1, 0xFFDC, 0x0024, 0x001B, 0x0000, 0x0016, 0xFFE3, + 0x0007, 0x0000, 0x0016, 0xFFE3, 0x0008, 0x0061, 0x0013, 0x0044, + 0x0009, 0x006A, 0x0013, 0x004D, 0x000B, 0x0037, 0x0013, 0x001A, + 0x000C, 0x0000, 0x000A, 0x0000, 0x000D, 0x0000, 0x000A, 0x0000, + 0x000E, 0xFF60, 0x000A, 0xFF60, 0x0010, 0x0066, 0x0013, 0x0056, + 0x0011, 0x0066, 0x0013, 0x0056, 0x0012, 0x0058, 0x0013, 0x003B, + 0x001C, 0xFFFD, 0x002A, 0xFFE0, 0x0020, 0x0012, 0x002D, 0x0078, + 0x001E, 0xFFEA, 0x000A, 0xFFEA, 0x001F, 0x000C, 0x000A, 0x0010, + 0x001D, 0x0000, 0x000A, 0xFFD9, 0x0023, 0x0000, 0x000A, 0x0000, + 0x0024, 0x0000, 0x000A, 0x0000, 0x002F, 0xFF38, 0x0019, 0xFFD8, + 0x0030, 0xFF51, 0x001B, 0xFFF1, 0x0031, 0xFFDF, 0xFFCE, 0x0032, + 0x0003, 0x0047, 0x0013, 0x0037, 0x0033, 0x003C, 0x0014, 0x003C, + 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0x0000, 0x0000, }; - unk800E2770 D_800E2770[2] = { { 0, 0xFD, 0, 0, 0, 0, 0 }, { 0, 0xFF, 0, 0, 0, 0, 0 }, @@ -119,8 +118,7 @@ unk800E2770 D_800E2770[2] = { s8 D_800E2790 = 1; s8 D_800E2794[16] = { - 1, 1, 1, 1, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2 + 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 }; s8 D_800E27A4[4] = { @@ -130,29 +128,29 @@ s8 D_800E27A4[4] = { s8 D_800E27A8 = 1; s8 D_800E27AC[12] = { - -1, 40, 40, -2, + -1, 40, 40, -2, 40, -1, 40, -2, - 40, 40, -1, -2 + 40, 40, -1, -2, }; s32 D_800E27B8 = 0; u8 D_800E27BC[120] = { - 0xFF, 0xA0, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x80, - 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xAF, 0x00, 0x00, - 0xFF, 0x80, 0xFF, 0x00, 0x00, 0xFF, 0x80, 0xBE, - 0x80, 0x80, 0x80, 0x00, 0x00, 0xFF, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x40, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x40, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x40, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x40, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 + 0xFF, 0xA0, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x80, + 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xAF, 0x00, 0x00, + 0xFF, 0x80, 0xFF, 0x00, 0x00, 0xFF, 0x80, 0xBE, + 0x80, 0x80, 0x80, 0x00, 0x00, 0xFF, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x40, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x40, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x40, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x40, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, }; s32 D_800E2834 = -2; @@ -161,8 +159,7 @@ f32 D_800E2838 = 0.0f; // Unused? s32 D_800E283C[5] = { - 0x06FFFFFF, 0x000FFFFF, 0x06000000, 0x0014FFFF, - 0x00000000 + 0x06FFFFFF, 0x000FFFFF, 0x06000000, 0x0014FFFF, 0x00000000 }; /*******************************/ @@ -258,7 +255,7 @@ GLOBAL_ASM("asm/non_matchings/unknown_09F8F0/func_800A01A0.s") void func_800A0B74(void) { s32 i; - for(i = 0; i < 2; i++) { + for (i = 0; i < 2; i++) { if (D_800E2770[i].unk4 != 0) { func_8000488C(D_800E2770[i].unk4); D_800E2770[i].unk4 = 0; diff --git a/src/unknown_0ABDF0.c b/src/unknown_0ABDF0.c index 9aaf92bb..75b71fae 100644 --- a/src/unknown_0ABDF0.c +++ b/src/unknown_0ABDF0.c @@ -33,15 +33,15 @@ s32 D_800E291C = 0; s32 D_800E2920[2] = { 0, 0 }; Gfx D_800E2928[] = { - gsDPPipeSync(), + gsDPPipeSync(), gsDPSetCycleType(G_CYC_1CYCLE), gsDPSetTextureLOD(G_TL_TILE), gsDPSetTextureLUT(G_TT_NONE), - gsDPSetTextureDetail(G_TD_CLAMP), + gsDPSetTextureDetail(G_TD_CLAMP), gsDPSetTexturePersp(G_TP_NONE), gsDPSetTextureFilter(G_TF_BILERP), - gsDPSetTextureConvert(G_TC_FILT), - gsDPSetAlphaCompare(G_AC_NONE), + gsDPSetTextureConvert(G_TC_FILT), + gsDPSetAlphaCompare(G_AC_NONE), gsDPSetRenderMode(G_RM_CLD_SURF, G_RM_CLD_SURF2), gsSPEndDisplayList(), }; diff --git a/src/video.c b/src/video.c index 3d45f57b..3515ad7b 100644 --- a/src/video.c +++ b/src/video.c @@ -8,7 +8,7 @@ u16 *gVideoDepthBuffer = NULL; s32 D_800DE774 = 0; // Currently unknown, might be a different type. -s8 D_800DE778 = 2; +s8 D_800DE778 = 2; VideoModeResolution gVideoModeResolutions[] = { { SCREEN_WIDTH, SCREEN_HEIGHT }, // 320x240 @@ -46,8 +46,8 @@ u16 *gVideoCurrDepthBuffer; u16 *gVideoLastDepthBuffer; u8 D_801262E4; s32 D_801262E8[8]; -u8 D_80126308; -u8 D_80126309; +u8 D_80126308; +u8 D_80126309; s32 D_8012630C; OSScClient D_80126310; @@ -66,14 +66,14 @@ void init_video(s32 videoModeIndex, OSSched *sc) { gVideoAspectRatio = ASPECT_RATIO_NTSC; gVideoHeightRatio = HEIGHT_RATIO_NTSC; } - + if (osTvType == TV_TYPE_PAL) { s32 i; - for(i = 0; i < 8; i++) { + for (i = 0; i < 8; i++) { gVideoModeResolutions[i].height += PAL_HEIGHT_DIFFERENCE; } } - + func_8007A974(); set_video_mode_index(videoModeIndex); gVideoFramebuffers[0] = 0; @@ -113,15 +113,15 @@ s32 get_video_width_and_height_as_s32(void) { void init_vi_settings(void) { s32 viModeTableIndex; OSViMode *tvViMode; - + viModeTableIndex = OS_VI_NTSC_LPN1; if (osTvType == TV_TYPE_PAL) { viModeTableIndex = OS_VI_PAL_LPN1; } else if (osTvType == TV_TYPE_MPAL) { viModeTableIndex = OS_VI_MPAL_LPN1; } - - switch(gVideoModeIndex & 7) { + + switch (gVideoModeIndex & 7) { case 0: stubbed_printf("320 by 240 Point sampled, Non interlaced.\n"); osViSetMode(&osViModeTable[viModeTableIndex]); @@ -156,7 +156,7 @@ void init_vi_settings(void) { } else if (osTvType == TV_TYPE_MPAL) { tvViMode = &osViModeMpalLpn1; } - + memory_copy((u8 *)tvViMode, (u8 *)&gTvViMode, sizeof(OSViMode)); gTvViMode.comRegs.width = WIDTH(640); gTvViMode.comRegs.xScale = SCALE(1, 0); @@ -223,7 +223,6 @@ void init_framebuffer(s32 index) { gVideoDepthBuffer = ((s32)gVideoDepthBuffer + 0x3F) & ~0x3F; } } - } void func_8007A974(void) { @@ -250,7 +249,7 @@ s32 func_8007A98C(s32 arg0) { s0 += 1; s0 &= 0xFF; } - + if (s0 < D_80126309) { if (D_80126308 < 0x14) { D_80126308++; @@ -298,7 +297,7 @@ void swap_framebuffers(void) { void memory_copy(u8 *src, u8 *dest, s32 len) { s32 i; - for(i = 0; i < len; i++) { - *dest++ = *src++; + for (i = 0; i < len; i++) { + *dest++ = *src++; } } diff --git a/src/video.h b/src/video.h index bf9a448a..6c810e53 100644 --- a/src/video.h +++ b/src/video.h @@ -7,7 +7,7 @@ #include "PR/libultra.h" #include "PR/os_message.h" #include "PR/os_vi.h" -#include "lib/src/mips1/sc/sched.h" +#include "sched.h" #define REFRESH_50HZ 50 #define REFRESH_60HZ 60 diff --git a/src/waves.c b/src/waves.c index af348422..3a7be0b6 100644 --- a/src/waves.c +++ b/src/waves.c @@ -54,15 +54,11 @@ s16 D_800E30FC[10] = { }; s16 D_800E3110[26] = { - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, - 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, - 21, 22, 23, 24, 25, 0 + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 0 }; s16 D_800E3144[26] = { - 0, 1, 1, 1, 2, 3, 4, 4, 4, 5, - 3, 4, 4, 4, 5, 3, 4, 4, 4, 5, - 6, 7, 7, 7, 8, 0 + 0, 1, 1, 1, 2, 3, 4, 4, 4, 5, 3, 4, 4, 4, 5, 3, 4, 4, 4, 5, 6, 7, 7, 7, 8, 0 }; s32 *D_800E3178 = NULL; @@ -201,11 +197,11 @@ void func_800B8B8C(void) { s32 temp_v0; s32 phi_v0; s32 i; - + D_800E30DC = 0; phi_v0 = 0; - - for(i = 0; i < D_8012A0D8 * D_8012A0DC; i++) { + + for (i = 0; i < D_8012A0D8 * D_8012A0DC; i++) { temp_v0 = phi_v0 + 1; D_800E30D4[i] = 0; phi_v0 = temp_v0; @@ -217,10 +213,10 @@ GLOBAL_ASM("asm/non_matchings/waves/func_800B8C04.s") s32 func_800B9228(LevelModelSegment *arg0) { s32 v0 = 0; s32 result = 0; - while(v0 < D_8012A0E0 && arg0 != D_800E30D8[v0].unk00){ + while (v0 < D_8012A0E0 && arg0 != D_800E30D8[v0].unk00) { v0++; }; - if(D_800E30D4[D_800E30D8[v0].unk0C]){ + if (D_800E30D4[D_800E30D8[v0].unk0C]) { result = 1; D_8012A1E8[D_800E30DC++] = v0; }