summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMegaMech <MegaMech@users.noreply.github.com>2024-04-05 21:42:14 -0600
committerGitHub <noreply@github.com>2024-04-05 21:42:14 -0600
commitc4d596d297182d81488c7d09769666de450140bb (patch)
treeed8456aa14f96a1da3807693f621e8c4179756e3 /src
parent12f332614ed9ee8b684d4b0fdae91e5ef14568ff (diff)
trig tables shiftable (#596)
Diffstat (limited to 'src')
-rw-r--r--src/audio/load.c2
-rw-r--r--src/audio/synthesis.h4
-rw-r--r--src/buffers/buffers.c22
-rw-r--r--src/buffers/gfx_output_buffer.c7
-rw-r--r--src/buffers/gfx_output_buffer.h (renamed from src/data/gfx_output_buffer.h)1
-rw-r--r--src/buffers/memory_pool.c (renamed from src/data/memory_pool.c)4
-rw-r--r--src/buffers/random.c4
-rw-r--r--src/buffers/random.h4
-rw-r--r--src/buffers/trig_tables.c (renamed from src/data/trig_tables.c)0
-rw-r--r--src/buffers/trig_tables.h (renamed from src/data/trig_tables.h)0
-rw-r--r--src/buffers/trig_tables_bss.c13
-rw-r--r--src/data/buffers.c32
-rw-r--r--src/data/gfx_output_buffer.c6
-rw-r--r--src/debug/all_variables.h2
-rw-r--r--src/main.c14
-rw-r--r--src/main.h7
-rw-r--r--src/racing/math_util.c2
-rw-r--r--src/racing/math_util.h4
-rw-r--r--src/racing/skybox_and_splitscreen.c8
19 files changed, 67 insertions, 69 deletions
diff --git a/src/audio/load.c b/src/audio/load.c
index e390470ee..f43d3d4a8 100644
--- a/src/audio/load.c
+++ b/src/audio/load.c
@@ -9,7 +9,7 @@
#include "audio/synthesis.h"
#include "audio/seqplayer.h"
#include "audio/port_eu.h"
-#include "data/gfx_output_buffer.h"
+#include "buffers/gfx_output_buffer.h"
#define ALIGN16(val) (((val) + 0xF) & ~0xF)
diff --git a/src/audio/synthesis.h b/src/audio/synthesis.h
index 06e244f85..974fc9c32 100644
--- a/src/audio/synthesis.h
+++ b/src/audio/synthesis.h
@@ -109,10 +109,6 @@ Acmd *final_resample(Acmd *acmd, struct NoteSynthesisState *synthesisState, s32
Acmd *func_800B86A0(Acmd *cmd, struct NoteSubEu *note, struct NoteSynthesisState *synthesisState, s32 nSamples, u16 inBuf, s32 headsetPanSettings, u32 flags);
Acmd *note_apply_headset_pan_effects(Acmd *acmd, struct NoteSubEu *noteSubEu, struct NoteSynthesisState *note, s32 bufLen, s32 flags, s32 leftRight);
-// These 2 are almost certainly misnamed and misplaced
-extern u64 gGfxSPTaskOutputBuffer[];
-extern u32 gGfxSPTaskOutputBufferSize;
-
extern struct SynthesisReverb gSynthesisReverbs[4];
/*
diff --git a/src/buffers/buffers.c b/src/buffers/buffers.c
new file mode 100644
index 000000000..cbdaae317
--- /dev/null
+++ b/src/buffers/buffers.c
@@ -0,0 +1,22 @@
+#include <ultra64.h>
+#include <macros.h>
+#include "config.h"
+#include "buffers.h"
+
+ALIGNED8 union_D_802BFB80 D_802BFB80;
+ALIGNED8 struct_D_802DFB80 D_802DFB80[2][2][8];
+#ifdef AVOID_UB
+ALIGNED8 struct_D_802F1F80 D_802F1F80[2][4][8];
+#else
+ALIGNED8 u16 D_802F1F80[2][4][0x100 * 8];
+#endif
+
+ALIGNED8 u16 gZBuffer[SCREEN_WIDTH * SCREEN_HEIGHT];
+
+#ifdef AVOID_UB
+ALIGNED8 u16 gFramebuffers[3][SCREEN_WIDTH * SCREEN_HEIGHT];
+#else
+u16 gFramebuffer0[SCREEN_WIDTH * SCREEN_HEIGHT];
+u16 gFramebuffer1[SCREEN_WIDTH * SCREEN_HEIGHT];
+u16 gFramebuffer2[SCREEN_WIDTH * SCREEN_HEIGHT];
+#endif
diff --git a/src/buffers/gfx_output_buffer.c b/src/buffers/gfx_output_buffer.c
new file mode 100644
index 000000000..0a699180c
--- /dev/null
+++ b/src/buffers/gfx_output_buffer.c
@@ -0,0 +1,7 @@
+#include <ultra64.h>
+#include <macros.h>
+#include "gfx_output_buffer.h"
+
+ALIGNED8 u64 gGfxSPTaskOutputBuffer[GFX_OUTPUT_BUFFER_SIZE];
+
+u32 gGfxSPTaskOutputBufferSize;
diff --git a/src/data/gfx_output_buffer.h b/src/buffers/gfx_output_buffer.h
index 6c489c1ea..5336b65ad 100644
--- a/src/data/gfx_output_buffer.h
+++ b/src/buffers/gfx_output_buffer.h
@@ -9,6 +9,5 @@
// 0x3F00
extern u64 gGfxSPTaskOutputBuffer[GFX_OUTPUT_BUFFER_SIZE];
-extern u32 gGfxSPTaskOutputBufferSize;
#endif // GFX_OUTPUT_BUFFER_H
diff --git a/src/data/memory_pool.c b/src/buffers/memory_pool.c
index 0c6e13116..d7dee6cc9 100644
--- a/src/data/memory_pool.c
+++ b/src/buffers/memory_pool.c
@@ -5,7 +5,7 @@
#define MEMORY_POOL_SIZE 0xAB630
/**
- * Memory pool setup to prevent other code segments flowing into the memory pool
- * and for easier portability.
+ * Memory pool variable prevents code segments flowing into the memory pool
+ * for easier portability.
*/
u8 memoryPool[MEMORY_POOL_SIZE];
diff --git a/src/buffers/random.c b/src/buffers/random.c
new file mode 100644
index 000000000..f68724e1f
--- /dev/null
+++ b/src/buffers/random.c
@@ -0,0 +1,4 @@
+#include <segments.h>
+
+u16 gRandomSeed16;
+u8 randomSeedPadding[216];
diff --git a/src/buffers/random.h b/src/buffers/random.h
new file mode 100644
index 000000000..f144f7843
--- /dev/null
+++ b/src/buffers/random.h
@@ -0,0 +1,4 @@
+#include <ultra64.h>
+
+extern u16 gRandomSeed16;
+extern u8 randomSeedPadding[];
diff --git a/src/data/trig_tables.c b/src/buffers/trig_tables.c
index 22c61be30..22c61be30 100644
--- a/src/data/trig_tables.c
+++ b/src/buffers/trig_tables.c
diff --git a/src/data/trig_tables.h b/src/buffers/trig_tables.h
index 569ffefc1..569ffefc1 100644
--- a/src/data/trig_tables.h
+++ b/src/buffers/trig_tables.h
diff --git a/src/buffers/trig_tables_bss.c b/src/buffers/trig_tables_bss.c
new file mode 100644
index 000000000..aa2bc38d1
--- /dev/null
+++ b/src/buffers/trig_tables_bss.c
@@ -0,0 +1,13 @@
+#include <ultra64.h>
+#include <macros.h>
+
+/**
+ * Trig tables get loaded into memory at this location.
+ * See trig_tables.c for the real file.
+ */
+
+#ifdef VERSION_EU
+ALIGNED8 u8 trigTablesPadding[0x5750];
+#else
+ALIGNED8 u8 trigTablesPadding[0x5810];
+#endif
diff --git a/src/data/buffers.c b/src/data/buffers.c
deleted file mode 100644
index b755fad6c..000000000
--- a/src/data/buffers.c
+++ /dev/null
@@ -1,32 +0,0 @@
-#include <ultra64.h>
-
-#include "config.h"
-#include "buffers.h"
-
-u16 gRandomSeed16;
-
-u8 randomSeedPadding[216];
-
-#ifdef VERSION_EU
-u8 frameBufferPadding[0x5750];
-#else
-u8 frameBufferPadding[0x5810];
-#endif
-
-union_D_802BFB80 D_802BFB80;
-struct_D_802DFB80 D_802DFB80[2][2][8];
-#ifdef AVOID_UB
-struct_D_802F1F80 D_802F1F80[2][4][8];
-#else
-u16 D_802F1F80[2][4][0x100 * 8];
-#endif
-
-u16 gZBuffer[SCREEN_WIDTH * SCREEN_HEIGHT];
-
-#ifdef AVOID_UB
-u16 gFramebuffers[3][SCREEN_WIDTH * SCREEN_HEIGHT];
-#else
-u16 gFramebuffer0[SCREEN_WIDTH * SCREEN_HEIGHT];
-u16 gFramebuffer1[SCREEN_WIDTH * SCREEN_HEIGHT];
-u16 gFramebuffer2[SCREEN_WIDTH * SCREEN_HEIGHT];
-#endif
diff --git a/src/data/gfx_output_buffer.c b/src/data/gfx_output_buffer.c
deleted file mode 100644
index f1624c767..000000000
--- a/src/data/gfx_output_buffer.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include <ultra64.h>
-#include "gfx_output_buffer.h"
-
-u64 gGfxSPTaskOutputBuffer[GFX_OUTPUT_BUFFER_SIZE];
-
-u32 gGfxSPTaskOutputBufferSize; \ No newline at end of file
diff --git a/src/debug/all_variables.h b/src/debug/all_variables.h
index 5cbab34ac..408fffe88 100644
--- a/src/debug/all_variables.h
+++ b/src/debug/all_variables.h
@@ -63,7 +63,7 @@
#include <objects.h>
#include <segments.h>
#include <sounds.h>
-#include "data/trig_tables.h"
+#include "buffers/trig_tables.h"
#include <types.h>
#include <ultra64.h>
#include <vehicles.h>
diff --git a/src/main.c b/src/main.c
index 6b6296d30..78222bca6 100644
--- a/src/main.c
+++ b/src/main.c
@@ -35,7 +35,7 @@
#include "staff_ghosts.h"
#include <debug.h>
#include "crash_screen.h"
-#include "data/gfx_output_buffer.h"
+#include "buffers/gfx_output_buffer.h"
// Declarations (not in this file)
void func_80091B78(void);
@@ -53,9 +53,9 @@ struct VblankHandler *gVblankHandler2 = NULL;
struct SPTask *gActiveSPTask = NULL;
struct SPTask *sCurrentAudioSPTask = NULL;
-struct SPTask* sCurrentDisplaySPTask = NULL;
-struct SPTask* sNextAudioSPTask = NULL;
-struct SPTask* sNextDisplaySPTask = NULL;
+struct SPTask *sCurrentDisplaySPTask = NULL;
+struct SPTask *sNextAudioSPTask = NULL;
+struct SPTask *sNextDisplaySPTask = NULL;
struct Controller gControllers[NUM_PLAYERS];
@@ -137,7 +137,7 @@ struct SPTask *gGfxSPTask;
s32 D_801502A0;
s32 D_801502A4;
u16 *gPhysicalFramebuffers[3];
-u32 D_801502B4;
+uintptr_t gPhysicalZBuffer;
UNUSED u32 D_801502B8;
UNUSED u32 D_801502BC;
Mat4 D_801502C0;
@@ -368,7 +368,7 @@ void read_controllers(void) {
}
void func_80000BEC(void) {
- D_801502B4 = VIRTUAL_TO_PHYSICAL(&gZBuffer);
+ gPhysicalZBuffer = VIRTUAL_TO_PHYSICAL(&gZBuffer);
}
void dispatch_audio_sptask(struct SPTask *spTask) {
@@ -538,7 +538,7 @@ void setup_game_memory(void) {
textureSegStart = (ptrdiff_t) SEG_RACING - commonCourseDataSize;
#else
textureSegStart = SEG_RACING - commonCourseDataSize;
-#endif
+#endif
osPiStartDma(&gDmaIoMesg, 0, 0, COMMON_TEXTURES_ROM_START, (void *) textureSegStart, commonCourseDataSize, &gDmaMesgQueue);
osRecvMesg(&gDmaMesgQueue, &gMainReceivedMesg, OS_MESG_BLOCK);
diff --git a/src/main.h b/src/main.h
index dfca328e6..c1fa48de3 100644
--- a/src/main.h
+++ b/src/main.h
@@ -182,7 +182,7 @@ extern struct SPTask *gGfxSPTask;
extern s32 D_801502A0;
extern s32 D_801502A4;
extern u16 *gPhysicalFramebuffers[];
-extern u32 D_801502B4;
+extern uintptr_t gPhysicalZBuffer;
extern Mat4 D_801502C0;
extern s32 padding[];
@@ -231,9 +231,4 @@ extern f32 gCourseTimer;
// end of definition of main.c variables
-extern u64 gGfxSPTaskOutputBuffer[];
-extern u32 gGfxSPTaskOutputBufferSize;
-
-extern u32 *D_801978D0; // Segment? Keeps track of segmented addresses?
-
#endif
diff --git a/src/racing/math_util.c b/src/racing/math_util.c
index aef024671..c28210f63 100644
--- a/src/racing/math_util.c
+++ b/src/racing/math_util.c
@@ -5,7 +5,7 @@
#include <main.h>
#include "buffers.h"
#include <PR/rcp.h>
-#include "data/trig_tables.h"
+#include "buffers/trig_tables.h"
#include "math.h"
#pragma intrinsic (sqrtf,fabs)
diff --git a/src/racing/math_util.h b/src/racing/math_util.h
index 794028219..9bc5241bc 100644
--- a/src/racing/math_util.h
+++ b/src/racing/math_util.h
@@ -69,8 +69,4 @@ f32 is_within_render_distance(Vec3f, Vec3f, u16, f32, f32, f32);
extern s32 D_802B91C0[];
extern Vec3f D_802B91C8;
-// end of math_util.c variables
-
-extern u16 gRandomSeed16;
-
#endif // MATH_UTIL_H
diff --git a/src/racing/skybox_and_splitscreen.c b/src/racing/skybox_and_splitscreen.c
index ebdaf7b96..f059f5863 100644
--- a/src/racing/skybox_and_splitscreen.c
+++ b/src/racing/skybox_and_splitscreen.c
@@ -177,8 +177,8 @@ void func_802A39E0(struct UnkStruct_800DC5EC *arg0) {
gDPPipeSync(gDisplayListHead++);
gDPSetCycleType(gDisplayListHead++, G_CYC_FILL);
- gDPSetDepthImage(gDisplayListHead++, D_801502B4);
- gDPSetColorImage(gDisplayListHead++, G_IM_FMT_RGBA, G_IM_SIZ_16b, SCREEN_WIDTH, D_801502B4);
+ gDPSetDepthImage(gDisplayListHead++, gPhysicalZBuffer);
+ gDPSetColorImage(gDisplayListHead++, G_IM_FMT_RGBA, G_IM_SIZ_16b, SCREEN_WIDTH, gPhysicalZBuffer);
gDPSetFillColor(gDisplayListHead++, 0xFFFCFFFC);
gDPPipeSync(gDisplayListHead++);
gDPSetScissor(gDisplayListHead++, G_SC_NON_INTERLACE, ulx, uly, lrx, lry);
@@ -197,8 +197,8 @@ void func_802A39E0(struct UnkStruct_800DC5EC *arg0) {
void init_z_buffer(void) {
gDPPipeSync(gDisplayListHead++);
gDPSetCycleType(gDisplayListHead++, G_CYC_FILL);
- gDPSetDepthImage(gDisplayListHead++, D_801502B4);
- gDPSetColorImage(gDisplayListHead++, G_IM_FMT_RGBA, G_IM_SIZ_16b, SCREEN_WIDTH, D_801502B4);
+ gDPSetDepthImage(gDisplayListHead++, gPhysicalZBuffer);
+ gDPSetColorImage(gDisplayListHead++, G_IM_FMT_RGBA, G_IM_SIZ_16b, SCREEN_WIDTH, gPhysicalZBuffer);
gDPSetFillColor(gDisplayListHead++, 0xFFFCFFFC);
gDPPipeSync(gDisplayListHead++);
gDPSetScissor(gDisplayListHead++, G_SC_NON_INTERLACE, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);