Label a save info loop (#645)

* save info

* more gcc progress
This commit is contained in:
MegaMech 2024-08-22 23:59:04 -06:00 committed by GitHub
parent 40f677db52
commit 8ebae23080
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
18 changed files with 261 additions and 42 deletions

View File

@ -81,6 +81,7 @@ endif
ifeq ($(COMPILER),ido)
MIPSISET := -mips2
else ifeq ($(COMPILER),gcc)
DEFINES += AVOID_UB=1 NON_MATCHING=1
NON_MATCHING := 1
VERSION_ASFLAGS := --defsym AVOID_UB=1
MIPSISET := -mips3
@ -633,7 +634,7 @@ $(GLOBAL_ASM_RACING_O_FILES): CC := $(PYTHON) $(TOOLS_DIR)/asm_processor/build.p
$(BUILD_DIR)/src/os/%.o: OPT_FLAGS :=
$(BUILD_DIR)/src/os/math/%.o: OPT_FLAGS := -O2
$(BUILD_DIR)/src/os/math/ll%.o: OPT_FLAGS :=
$(BUILD_DIR)/src/os/math/ll%.o: MIPSISET := -mips3 -32
$(BUILD_DIR)/src/os/math/ll%.o: MIPSISET := -mips3
$(BUILD_DIR)/src/os/ldiv.o: OPT_FLAGS := -O2
$(BUILD_DIR)/src/os/string.o: OPT_FLAGS := -O2
$(BUILD_DIR)/src/os/gu%.o: OPT_FLAGS := -O3

View File

@ -18,7 +18,7 @@ glabel audio_init
/* BCD08 800BC108 3C04800F */ lui $a0, %hi(gAudioHeapSize)
/* BCD0C 800BC10C 8C84A710 */ lw $a0, %lo(gAudioHeapSize)($a0)
/* BCD10 800BC110 00001825 */ or $v1, $zero, $zero
/* BCD14 800BC114 3C0A803B */ lui $t2, %hi(D_803B71A0)
/* BCD14 800BC114 3C0A803B */ lui $t2, %hi(gAudioGlobalsEndMarker)
/* BCD18 800BC118 04810003 */ bgez $a0, .L800BC128
/* BCD1C 800BC11C 000478C3 */ sra $t7, $a0, 3
/* BCD20 800BC120 24810007 */ addiu $at, $a0, 0x7
@ -40,7 +40,7 @@ glabel audio_init
/* BCD58 800BC158 AC48FFF8 */ sw $t0, -0x8($v0)
.L800BC15C:
/* BCD5C 800BC15C 2482F780 */ addiu $v0, $a0, %lo(gGfxSPTaskOutputBufferSize)
/* BCD60 800BC160 254A71A0 */ addiu $t2, $t2, %lo(D_803B71A0)
/* BCD60 800BC160 254A71A0 */ addiu $t2, $t2, %lo(gAudioGlobalsEndMarker)
/* BCD64 800BC164 01421823 */ subu $v1, $t2, $v0
/* BCD68 800BC168 000380C2 */ srl $s0, $v1, 3
/* BCD6C 800BC16C 06000008 */ bltz $s0, .L800BC190

View File

@ -26,7 +26,7 @@ glabel audio_init
/* 0BCD08 800BC108 3C04800F */ lui $a0, %hi(gAudioHeapSize) # $a0, 0x800f
/* 0BCD0C 800BC10C 8C84A5D0 */ lw $a0, %lo(gAudioHeapSize)($a0)
/* 0BCD10 800BC110 00001825 */ move $v1, $zero
/* 0BCD14 800BC114 3C0A803B */ lui $t2, %hi(D_803B71A0) # $t2, 0x803b
/* 0BCD14 800BC114 3C0A803B */ lui $t2, %hi(gAudioGlobalsEndMarker) # $t2, 0x803b
/* 0BCD18 800BC118 04810003 */ bgez $a0, .L800BC128
/* 0BCD1C 800BC11C 000478C3 */ sra $t7, $a0, 3
/* 0BCD20 800BC120 24810007 */ addiu $at, $a0, 7
@ -48,7 +48,7 @@ glabel audio_init
/* 0BCD58 800BC158 AC48FFF8 */ sw $t0, -8($v0)
.L800BC15C:
/* 0BCD5C 800BC15C 2482F780 */ addiu $v0, $a0, %lo(gGfxSPTaskOutputBufferSize) # -0x880
/* 0BCD60 800BC160 254A71A0 */ addiu $t2, %lo(D_803B71A0) # addiu $t2, $t2, 0x71a0
/* 0BCD60 800BC160 254A71A0 */ addiu $t2, %lo(gAudioGlobalsEndMarker) # addiu $t2, $t2, 0x71a0
/* 0BCD64 800BC164 01421823 */ subu $v1, $t2, $v0
/* 0BCD68 800BC168 000380C2 */ srl $s0, $v1, 3
/* 0BCD6C 800BC16C 06000007 */ bltz $s0, .L800BC18C

View File

@ -10,6 +10,12 @@
Configuration
=======================*/
#define AUDIO_HEAP_SIZE 0x48C00
#define AUDIO_HEAP_INIT_SIZE 0x2600
#define DOUBLE_SIZE_ON_64_BIT(size) ((size) * (sizeof(void *) / 4))
#define SCREEN_WIDTH 320
#define SCREEN_HEIGHT 240

View File

@ -35,12 +35,17 @@ typedef struct {
u8 unknownBytes[8];
} OnlyBestTimeTrialRecords; // size = 0x38
typedef struct {
// GP Points scored for each CC mode
// 1st place is 3 points, 2nd is 2, etc.
// Lowest dibit is the Mushroom Cup, 2nd dibit is the Flower Cup, etc
u8 grandPrixPoints[4];
u8 soundMode;
} SaveInfo;
typedef struct {
SaveInfo saveInfo;
// It's unknown what the first byte is used for
u8 checksum[3];
} Stuff; // size = 0x8

View File

@ -316,8 +316,8 @@ SECTIONS
BUILD_DIR/src/os/_Printf.o(.rodata*);
BUILD_DIR/asm/os/osSetIntMask.o(.rodata);
BUILD_DIR/src/os/_Ldtob.o(.rodata*);
BUILD_DIR/data/rsp.o(.data);
BUILD_DIR/src/audio/data.o(.data);
BUILD_DIR/data/rsp.o(.data*);
BUILD_DIR/src/audio/data.o(.data*);
}
END_SEG(main)
@ -424,6 +424,7 @@ SECTIONS
BUILD_DIR/src/audio/heap.o(.bss*);
BUILD_DIR/src/audio/load.o(.bss*);
BUILD_DIR/src/audio/data.o(.bss*);
BUILD_DIR/src/buffers/audio_heap.o(.bss*);
. = ALIGN(0x8);
}
END_NOLOAD(buffers)
@ -579,7 +580,8 @@ SECTIONS
#define COURSE_OFFSETS_SEG(dir, name) \
BEGIN_SEG(name, 0x09000000) \
{ \
BUILD_DIR/courses/dir/course_offsets.o(.data); \
BUILD_DIR/courses/dir/course_offsets.o(.data*); \
BUILD_DIR/courses/dir/course_offsets.o(.rodata*); \
. = ALIGN(0x10); \
} \
END_SEG(name)

View File

@ -7,9 +7,11 @@ SAFE_C_FILES := \
build/us/src/code_80091440.o \
build/us/src/effects.o \
build/us/src/code_80057C60_var.o \
build/us/src/code_80091750.o \
build/us/src/code_800029B0.o \
build/us/src/animation.o \
build/us/src/player_controller.o \
build/us/src/code_80005FD0.o \
build/us/src/profiler.o \
build/us/src/render_player.o \
build/us/src/code_80086E70.o \
@ -18,6 +20,7 @@ SAFE_C_FILES := \
build/us/src/kart_dma.o \
build/us/src/math_util_2.o \
build/us/src/main.o \
build/us/src/data/some_data.o \
build/us/src/data/kart_attributes.o \
build/us/src/data/path_spawn_metadata.o \
build/us/src/data/textures.o \
@ -27,6 +30,7 @@ SAFE_C_FILES := \
build/us/src/audio/heap.o \
build/us/src/audio/effects.o \
build/us/src/audio/playback.o \
build/us/src/audio/data.o \
build/us/src/audio/audio_session_presets.o \
build/us/src/audio/port_eu.o \
build/us/src/buffers/gfx_output_buffer.o \
@ -164,4 +168,14 @@ SAFE_C_FILES := \
build/us/src/os/math/llconv.o \
build/us/src/os/math/cosf.o \
build/us/src/os/math/llmuldiv.o \
build/us/src/os/math/sinf.o \
build/us/src/os/math/sinf.o \
# build/us/src/save.o
# build/us/src/crash_screen.o
# build/us/src/code_8006E9C0.o
# build/us/src/audio/synthesis.o
# build/us/src/code_80057C60.o
# build/us/src/menus.o
# build/us/src/render_objects.o
# build/us/src/code_800AF9B0.o
# build/us/src/update_objects.o

169
safe_gcc_old.mk Normal file
View File

@ -0,0 +1,169 @@
# This file is auto-generated. DO NOT MODIFY!
SAFE_C_FILES := \
build/us/src/camera.o \
build/us/src/spawn_players.o \
build/us/src/code_8003DC40.o \
build/us/src/code_80091440.o \
build/us/src/effects.o \
build/us/src/code_80057C60_var.o \
build/us/src/code_800029B0.o \
build/us/src/code_80004740.o \
build/us/src/player_controller.o \
build/us/src/profiler.o \
build/us/src/render_player.o \
build/us/src/code_80086E70.o \
build/us/src/staff_ghosts.o \
build/us/src/gbiMacro.o \
build/us/src/kart_dma.o \
build/us/src/math_util_2.o \
build/us/src/main.o \
build/us/src/data/kart_attributes.o \
build/us/src/data/path_spawn_metadata.o \
build/us/src/data/textures.o \
build/us/src/data/trig_tables_bss.o \
build/us/src/data/data_segment2.o \
build/us/src/audio/seqplayer.o \
build/us/src/audio/heap.o \
build/us/src/audio/effects.o \
build/us/src/audio/playback.o \
build/us/src/audio/audio_session_presets.o \
build/us/src/audio/port_eu.o \
build/us/src/buffers/gfx_output_buffer.o \
build/us/src/buffers/trig_tables.o \
build/us/src/buffers/buffers.o \
build/us/src/buffers/random.o \
build/us/src/buffers/trig_tables_bss.o \
build/us/src/buffers/memory_pool.o \
build/us/src/ending/credits.o \
build/us/src/ending/code_80280000.o \
build/us/src/ending/ceremony_and_credits.o \
build/us/src/ending/dl_unk_80284EE0.o \
build/us/src/ending/code_80281780.o \
build/us/src/ending/podium_ceremony_actors.o \
build/us/src/ending/code_80281C40.o \
build/us/src/ending/camera_junk.o \
build/us/src/debug/debug.o \
build/us/src/debug/crash_screen_enhancement.o \
build/us/src/racing/collision.o \
build/us/src/racing/skybox_and_splitscreen.o \
build/us/src/racing/memory.o \
build/us/src/racing/race_logic.o \
build/us/src/racing/actors_extended.o \
build/us/src/racing/render_courses.o \
build/us/src/racing/actors.o \
build/us/src/os/guOrthoF.o \
build/us/src/os/guLookAtF.o \
build/us/src/os/__osSiDeviceBusy.o \
build/us/src/os/_Litob.o \
build/us/src/os/osContInit.o \
build/us/src/os/osInitialize.o \
build/us/src/os/osAiSetNextBuffer.o \
build/us/src/os/guMtxCatL.o \
build/us/src/os/__osAiDeviceBusy.o \
build/us/src/os/contramread.o \
build/us/src/os/osSpTaskLoadGo.o \
build/us/src/os/crc.o \
build/us/src/os/osCreateMesgQueue.o \
build/us/src/os/guRotateF.o \
build/us/src/os/__osLeoInterrupt.o \
build/us/src/os/osContStartReadData.o \
build/us/src/os/osGetThreadPri.o \
build/us/src/os/osPfsNumFiles.o \
build/us/src/os/__osSiRawReadIo.o \
build/us/src/os/osSpTaskYield.o \
build/us/src/os/osStartThread.o \
build/us/src/os/osViData.o \
build/us/src/os/osPfsFileState.o \
build/us/src/os/contpfs.o \
build/us/src/os/leointerrupt.o \
build/us/src/os/osPfsAllocateFile.o \
build/us/src/os/ldiv.o \
build/us/src/os/osSpTaskYielded.o \
build/us/src/os/__osSpSetPc.o \
build/us/src/os/osSetTime.o \
build/us/src/os/osYieldThread.o \
build/us/src/os/osPiRawStartDma.o \
build/us/src/os/osSetTimer.o \
build/us/src/os/osPfsDeleteFile.o \
build/us/src/os/__osSpDeviceBusy.o \
build/us/src/os/osEepromRead.o \
build/us/src/os/osPiRawReadIo.o \
build/us/src/os/osSetEventMesg.o \
build/us/src/os/NaN.o \
build/us/src/os/osJamMesg.o \
build/us/src/os/osPfsChecker.o \
build/us/src/os/sprintf.o \
build/us/src/os/_Printf.o \
build/us/src/os/osViTable.o \
build/us/src/os/osEepromLongWrite.o \
build/us/src/os/__osEPiRawWriteIo.o \
build/us/src/os/osViSetEvent.o \
build/us/src/os/__osGetCurrFaultedThread.o \
build/us/src/os/osCreatePiManager.o \
build/us/src/os/epidma.o \
build/us/src/os/osCartRomInit.o \
build/us/src/os/osPfsFreeBlocks.o \
build/us/src/os/osPfsSearchFile.o \
build/us/src/os/__osAtomicDec.o \
build/us/src/os/osViBlack.o \
build/us/src/os/__osViInit.o \
build/us/src/os/osEepromWrite.o \
build/us/src/os/osAiSetFrequency.o \
build/us/src/os/__osEPiRawReadIo.o \
build/us/src/os/guLookAtRef.o \
build/us/src/os/guPerspectiveF.o \
build/us/src/os/contramwrite.o \
build/us/src/os/osGetTime.o \
build/us/src/os/__osViSwapContext.o \
build/us/src/os/alBnkfNew.o \
build/us/src/os/__osSpSetStatus.o \
build/us/src/os/osPfsReadWriteFile.o \
build/us/src/os/osPiStartDma.o \
build/us/src/os/osRecvMesg.o \
build/us/src/os/osDestroyThread.o \
build/us/src/os/string.o \
build/us/src/os/__osSiRawWriteIo.o \
build/us/src/os/osPfsInit.o \
build/us/src/os/guMtxCatF.o \
build/us/src/os/osPfsIsPlug.o \
build/us/src/os/__osDequeueThread.o \
build/us/src/os/__osSiCreateAccessQueue.o \
build/us/src/os/osViSwapBuffer.o \
build/us/src/os/is_debug.o \
build/us/src/os/__osViGetCurrentContext.o \
build/us/src/os/__osPiCreateAccessQueue.o \
build/us/src/os/__osSpRawStartDma.o \
build/us/src/os/__osSyncPutChars.o \
build/us/src/os/osSendMesg.o \
build/us/src/os/osSyncPrintf.o \
build/us/src/os/__osResetGlobalIntMask.o \
build/us/src/os/guScaleF.o \
build/us/src/os/osSetThreadPri.o \
build/us/src/os/__osDevMgrMain.o \
build/us/src/os/osVirtualToPhysical.o \
build/us/src/os/osViSetMode.o \
build/us/src/os/__osSetHWIntrRoutine.o \
build/us/src/os/osCreateViManager.o \
build/us/src/os/__osSiRawStartDma.o \
build/us/src/os/guNormalize.o \
build/us/src/os/osLeoDiskInit.o \
build/us/src/os/__osSpGetStatus.o \
build/us/src/os/osEepromLongRead.o \
build/us/src/os/_Ldtob.o \
build/us/src/os/guMtxF2L.o \
build/us/src/os/osEPiRawStartDma.o \
build/us/src/os/osPiGetCmdQueue.o \
build/us/src/os/osAiGetLength.o \
build/us/src/os/osViSetSpecialFeatures.o \
build/us/src/os/osCreateThread.o \
build/us/src/os/osTimer.o \
build/us/src/os/osEepromProbe.o \
build/us/src/os/__osSetGlobalIntMask.o \
build/us/src/os/guTranslateF.o \
build/us/src/os/math/llconv.o \
build/us/src/os/math/cosf.o \
build/us/src/os/math/llmuldiv.o \
build/us/src/os/math/sinf.o \
build/us/assets/code/common_data/common_data.o\
build/us/assets/code/common_data/common_data.mio0.o\

View File

@ -3,6 +3,7 @@
#include "internal.h"
#include "data.h"
#include "../buffers/audio_heap.h"
struct ReverbSettingsEU sReverbSettings[] = {
{0x01, 0x28, 0x4fff},
@ -33,8 +34,8 @@ struct AudioSessionSettingsEU gAudioSessionPresets[] = {
s8 gUnusedCount800EA5C8 = 0x1c;
s16 gTatumsPerBeat = TATUMS_PER_BEAT;
s32 gAudioHeapSize = 0x00048c00;
s32 gAudioInitPoolSize = 0x00002600;
s32 gAudioHeapSize = AUDIO_HEAP_SIZE;
s32 gAudioInitPoolSize = AUDIO_HEAP_INIT_SIZE;
s32 D_800EA5D8 = 0;
volatile s32 gAudioLoadLock = 0;

View File

@ -1,5 +1,6 @@
#include <PR/ultratypes.h>
#include <macros.h>
#include <mk64.h>
#include "data.h"
#include "effects.h"
@ -435,10 +436,9 @@ struct SPTask *gAudioTask; // gAudioTask?
struct SPTask gAudioTasks[2]; // gAudioTasks?
f32 D_803B7178;
s32 gRefreshRate;
s16 *gAiBuffers[3]; // unconfirmed, osAiSetNextBuffer vaddr
s16 *gAiBuffers[NUMAIBUFFERS]; // unconfirmed, osAiSetNextBuffer vaddr
s16 gAiBufferLengths[NUMAIBUFFERS]; // osAiSetNextBuffer nbytes
u16 D_803B7192; // unconfirmed
u32 gAudioRandom;
s32 gAudioErrorFlags;
u32 D_803B71A0[4]; // unconfirmed
ALIGNED8 u8 gAudioHeap[4]; // unconfirmed
u64 gAudioGlobalsEndMarker;

View File

@ -51,12 +51,12 @@ extern struct SPTask *gAudioTask; // D_803B70D4
extern struct SPTask gAudioTasks[2]; // D_803B70D8
extern f32 D_803B7178;
extern s32 gRefreshRate;
extern s16 *gAiBuffers[NUMAIBUFFERS]; // D_803B7180
extern s16 gAiBufferLengths[NUMAIBUFFERS]; // osAiSetNextBuffer nbytes
extern s16 *gAiBuffers[]; // D_803B7180
extern s16 gAiBufferLengths[]; // osAiSetNextBuffer nbytes
extern u16 D_803B7192; // unconfirmed
extern u32 gAudioRandom;
extern s32 gAudioErrorFlags;
extern u32 D_803B71A0[]; // unconfirmed
extern u64 gAudioGlobalsEndMarker; // unconfirmed
extern u8 gAudioHeap[]; // unconfirmed
extern struct ReverbSettingsEU sReverbSettings[];

View File

@ -791,7 +791,7 @@ void audio_init(void) {
#ifdef TARGET_N64
// It seems boot.s doesn't clear the .bss area for audio, so do it here.
ptr64 = (u64 *)((u8 *) gGfxSPTaskOutputBuffer + sizeof(gGfxSPTaskOutputBuffer));
for (i = ((uintptr_t) &D_803B71A0 - (uintptr_t) ((u64 *)((u8 *) gGfxSPTaskOutputBuffer + sizeof(gGfxSPTaskOutputBuffer))) ) / 8; i >= 0; i--) {
for (i = ((uintptr_t) &gAudioGlobalsEndMarker - (uintptr_t) ((u64 *)((u8 *) gGfxSPTaskOutputBuffer + sizeof(gGfxSPTaskOutputBuffer))) ) / 8; i >= 0; i--) {
*ptr64++ = 0;
}
#endif

View File

@ -109,11 +109,12 @@ struct SPTask *create_next_audio_frame_task(void) {
gAudioCmd = gAudioCmdBuffers[gAudioTaskIndex];
index = gCurrAiBufferIndex;
currAiBuffer = gAiBuffers[index];
gAiBufferLengths[index] = ((gAudioBufferParameters.samplesPerFrameTarget - samplesRemainingInAI + EXTRA_BUFFERED_AI_SAMPLES_TARGET) & ~0xF) + SAMPLES_TO_OVERPRODUCE;
gAiBufferLengths[index] = ((gAudioBufferParameters.samplesPerFrameTarget - samplesRemainingInAI +
EXTRA_BUFFERED_AI_SAMPLES_TARGET) & ~0xF) + SAMPLES_TO_OVERPRODUCE;
if (gAiBufferLengths[index] < gAudioBufferParameters.minAiBufferLength) {
gAiBufferLengths[index] = gAudioBufferParameters.minAiBufferLength;
}
if (gAudioBufferParameters.maxAiBufferLength < gAiBufferLengths[index]) {
if (gAiBufferLengths[index] > gAudioBufferParameters.maxAiBufferLength) {
gAiBufferLengths[index] = gAudioBufferParameters.maxAiBufferLength;
}
if (osRecvMesg(D_800EA3AC, &sp54, 0) != -1) {
@ -136,7 +137,7 @@ struct SPTask *create_next_audio_frame_task(void) {
task->ucode_boot_size = (u8*) rspF3DBootEnd - (u8*) rspF3DBootStart;
task->ucode = rspAspMainStart;
task->ucode_data = rspAspMainDataStart;
task->ucode_size = 0x00001000;
task->ucode_size = 0x1000; // (This size is ignored (according to sm64))
task->ucode_data_size = (rspAspMainDataEnd - rspAspMainDataStart) * sizeof(u64);
task->dram_stack = NULL;
task->dram_stack_size = 0;

9
src/buffers/audio_heap.c Normal file
View File

@ -0,0 +1,9 @@
#include <PR/ultratypes.h>
#include <macros.h>
#include <mk64.h>
#include "audio_heap.h"
#include "audio/data.h"
ALIGNED8 u8 gAudioHeap[DOUBLE_SIZE_ON_64_BIT(AUDIO_HEAP_SIZE)];

10
src/buffers/audio_heap.h Normal file
View File

@ -0,0 +1,10 @@
#ifndef AUDIO_HEAP_H
#define AUDIO_HEAP_H
#include <PR/ultratypes.h>
#include <mk64.h>
#define AUDIO_HEAP_SIZE 0x48C00
#define AUDIO_HEAP_INIT_SIZE 0x2600
#endif // AUDIO_HEAP_H

View File

@ -260,7 +260,7 @@ void options_menu_act(struct Controller *controller, u16 arg1) {
sp38->unk8 = -1;
}
if (sp2C && gSoundMode != sp38->cursor) {
gSaveData.main.soundMode = gSoundMode;
gSaveData.main.saveInfo.soundMode = gSoundMode;
write_save_data_grand_prix_points_and_sound_mode();
update_save_data_backup();
sp38->cursor = gSoundMode;
@ -269,7 +269,7 @@ void options_menu_act(struct Controller *controller, u16 arg1) {
func_8009E280();
play_sound2(SOUND_MENU_GO_BACK);
if (gSoundMode != sp38->cursor) {
gSaveData.main.soundMode = gSoundMode;
gSaveData.main.saveInfo.soundMode = gSoundMode;
write_save_data_grand_prix_points_and_sound_mode();
update_save_data_backup();
sp38->cursor = gSoundMode;
@ -1123,7 +1123,7 @@ void splash_menu_act(struct Controller *controller, u16 arg1) {
}
play_sound2(SOUND_MENU_CURSOR_MOVE);
func_800B44BC();
gSaveData.main.soundMode = gSoundMode;
gSaveData.main.saveInfo.soundMode = gSoundMode;
write_save_data_grand_prix_points_and_sound_mode();
update_save_data_backup();
}
@ -1134,7 +1134,7 @@ void splash_menu_act(struct Controller *controller, u16 arg1) {
}
play_sound2(SOUND_MENU_CURSOR_MOVE);
func_800B44BC();
gSaveData.main.soundMode = gSoundMode;
gSaveData.main.saveInfo.soundMode = gSoundMode;
write_save_data_grand_prix_points_and_sound_mode();
}
if (btnAndStick & U_JPAD) {

View File

@ -939,6 +939,7 @@ f32 atan2f(f32 arg0, f32 arg1) {
return atan2s(arg0, arg1);
}
#ifndef NON_MATCHING // The decomp does not support fabs
UNUSED f32 func_802B79F0(f32 arg0, f32 arg1) {
f64 halfpi;
f32 temp_f0;
@ -973,6 +974,7 @@ UNUSED f32 func_802B79F0(f32 arg0, f32 arg1) {
}
return var_f2;
}
#endif
UNUSED u16 func_802B7B50(f32 arg0, f32 arg1) {
return ((atan2f(arg0, arg1) * 32768.0f) / M_PI);

View File

@ -90,9 +90,9 @@ void reset_save_data_grand_prix_points_and_sound_mode(void) {
s32 cup_index;
Stuff *main = &gSaveData.main;
for (cup_index = 0; cup_index < 4; cup_index++) {
main->grandPrixPoints[cup_index] = 0;
main->saveInfo.grandPrixPoints[cup_index] = 0;
}
main->soundMode = SOUND_STEREO;
main->saveInfo.soundMode = SOUND_STEREO;
gSoundMode = SOUND_STEREO;
func_800B44BC();
write_save_data_grand_prix_points_and_sound_mode();
@ -120,11 +120,11 @@ u8 checksum_time_trial_records(s32 courseIdx) {
u8 compute_save_data_checksum_1(void) {
u8 *grandPrixPoints = (u8 *) &gSaveData.main.grandPrixPoints;
u8 *grandPrixPoints = (u8 *) &gSaveData.main.saveInfo.grandPrixPoints;
s32 i;
s32 crc = 0;
for (i = 0; i < 5; i++) {
for (i = 0; i < sizeof(SaveInfo); i++) {
crc += ((grandPrixPoints[i] + 1) * (i + 1)) + i;
}
@ -147,7 +147,7 @@ void load_save_data(void) {
validate_save_data();
gSoundMode = gSaveData.main.soundMode;
gSoundMode = gSaveData.main.saveInfo.soundMode;
if (gSoundMode >= NUM_SOUND_MODES) {
gSoundMode = SOUND_MONO;
}
@ -212,10 +212,10 @@ void validate_save_data(void) {
if (validate_save_data_checksum_backup() == 0) {
for (cup_index = 0; cup_index < 4; cup_index++) {
main->grandPrixPoints[cup_index] = backup->grandPrixPoints[cup_index];
main->saveInfo.grandPrixPoints[cup_index] = backup->saveInfo.grandPrixPoints[cup_index];
}
main->soundMode = backup->soundMode;
main->saveInfo.soundMode = backup->saveInfo.soundMode;
main->checksum[1] = compute_save_data_checksum_backup_1();
main->checksum[2] = compute_save_data_checksum_backup_2();
osEepromLongWrite(&gSIEventMesgQueue, EEPROM_ADDR(main), (u8 *) main, sizeof(Stuff));
@ -384,8 +384,7 @@ void func_800B536C(s32 arg0) {
s32 tmp2;
if (arg0 >= 0) {
points = &gSaveData.main.grandPrixPoints[gCCSelection];
points = &gSaveData.main.saveInfo.grandPrixPoints[gCCSelection];
tmp = func_800B54EC(gCupSelection, *points);
tmp2 = 3 - arg0;
if ((arg0 < 3) && (tmp < (3-arg0))) {
@ -406,7 +405,7 @@ void func_800B5404(s32 arg0, s32 arg1)
if (arg0 >= 0) {
temp2 = arg1 / 4;
points = &gSaveData.main.grandPrixPoints[arg1 % 4];
points = &gSaveData.main.saveInfo.grandPrixPoints[arg1 % 4];
temp = func_800B54EC(temp2, *points);
if ((arg0 < 3) && (temp < (temp_a0 = 3 - arg0))) {
@ -420,7 +419,7 @@ void func_800B5404(s32 arg0, s32 arg1)
// Get Grand Prix points for a given cup and CC mode
u8 func_800B54C0(s32 cup, s32 cc_mode) {
return func_800B54EC(cup, gSaveData.main.grandPrixPoints[cc_mode]);
return func_800B54EC(cup, gSaveData.main.saveInfo.grandPrixPoints[cc_mode]);
}
// Get Grand Prix points scored for a given cup
@ -449,7 +448,7 @@ u8 func_800B5508(s32 cup, s32 ccGrandPrixPoints, s32 points_scored) {
// Check if all 4 cups have gold cups scored
// for a given CC mode
s32 func_800B5530(s32 cc_mode) {
if (gSaveData.main.grandPrixPoints[cc_mode] == 0xFF) {
if (gSaveData.main.saveInfo.grandPrixPoints[cc_mode] == 0xFF) {
return 1;
}
return 0;
@ -548,21 +547,21 @@ void update_save_data_backup(void) {
s32 cup_index;
Stuff *main = &gSaveData.main;
Stuff *backup = &gSaveData.backup;
for (cup_index = 0; cup_index < 4; cup_index++) {
backup->grandPrixPoints[cup_index] = main->grandPrixPoints[cup_index];
for (cup_index = 0; cup_index < NUM_CUPS - 1; cup_index++) {
backup->saveInfo.grandPrixPoints[cup_index] = main->saveInfo.grandPrixPoints[cup_index];
}
backup->soundMode = main->soundMode;
backup->saveInfo.soundMode = main->saveInfo.soundMode;
backup->checksum[1] = compute_save_data_checksum_backup_1();
backup->checksum[2] = compute_save_data_checksum_backup_2();
osEepromLongWrite(&gSIEventMesgQueue, EEPROM_ADDR(backup), (u8 *) backup, sizeof(Stuff));
}
u8 compute_save_data_checksum_backup_1(void) {
u8 *backupGrandPrixPoints = gSaveData.backup.grandPrixPoints;
u8 *backupGrandPrixPoints = gSaveData.backup.saveInfo.grandPrixPoints;
s32 i;
s32 crc = 0;
for (i = 0; i < 5; i++) {
for (i = 0; i < sizeof(SaveInfo); i++) {
crc += ((backupGrandPrixPoints[i] + 1) * (i + 1)) + i;
}