Skip to content

Commit

Permalink
Label a save info loop (#645)
Browse files Browse the repository at this point in the history
* save info

* more gcc progress
  • Loading branch information
MegaMech authored Aug 23, 2024
1 parent 40f677d commit 8ebae23
Show file tree
Hide file tree
Showing 18 changed files with 261 additions and 42 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions asm/eu_nonmatchings/audio_init.s
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions asm/non_matchings/audio/load/audio_init.s
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 6 additions & 0 deletions include/mk64.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 5 additions & 0 deletions include/save_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 5 additions & 3 deletions mk64.ld
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
16 changes: 15 additions & 1 deletion safe_gcc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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 \
Expand All @@ -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 \
Expand Down Expand Up @@ -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 changes: 169 additions & 0 deletions safe_gcc_old.mk
Original file line number Diff line number Diff line change
@@ -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\
5 changes: 3 additions & 2 deletions src/audio/audio_session_presets.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include "internal.h"
#include "data.h"
#include "../buffers/audio_heap.h"

struct ReverbSettingsEU sReverbSettings[] = {
{0x01, 0x28, 0x4fff},
Expand Down Expand Up @@ -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;

Expand Down
6 changes: 3 additions & 3 deletions src/audio/data.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <PR/ultratypes.h>
#include <macros.h>
#include <mk64.h>

#include "data.h"
#include "effects.h"
Expand Down Expand Up @@ -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;
6 changes: 3 additions & 3 deletions src/audio/data.h
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
Expand Down
2 changes: 1 addition & 1 deletion src/audio/load.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit 8ebae23

Please sign in to comment.