summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/boot/idle.c15
-rw-r--r--src/buffers/audio_heap.c3
-rw-r--r--src/buffers/framebuffer_hi.c5
-rw-r--r--src/buffers/framebuffer_lo.c5
-rw-r--r--src/buffers/gfxpools.c2
-rw-r--r--src/buffers/gfxstack.c2
-rw-r--r--src/buffers/gfxyield.c2
-rw-r--r--src/buffers/heaps.c5
-rw-r--r--src/buffers/system_heap.c6
-rw-r--r--src/code/main.c4
-rw-r--r--src/code/sys_cfb.c9
-rw-r--r--src/code/z_play.c10
-rw-r--r--src/code/z_vr_box.c3
13 files changed, 44 insertions, 27 deletions
diff --git a/src/boot/idle.c b/src/boot/idle.c
index 08f6d6ec7..cb35fafe8 100644
--- a/src/boot/idle.c
+++ b/src/boot/idle.c
@@ -1,4 +1,5 @@
#include "prevent_bss_reordering.h"
+#include "buffers.h"
#include "irqmgr.h"
#include "main.h"
#include "stack.h"
@@ -41,10 +42,10 @@ void Main_InitFramebuffer(u32* framebuffer, size_t numBytes, u32 value) {
}
void Main_InitScreen(void) {
- Main_InitFramebuffer((u32*)gFramebuffer1, sizeof(gFramebuffer1),
+ Main_InitFramebuffer((u32*)gLoBuffer.framebuffer, sizeof(gLoBuffer.framebuffer),
(GPACK_RGBA5551(0, 0, 0, 1) << 16) | GPACK_RGBA5551(0, 0, 0, 1));
ViConfig_UpdateVi(false);
- osViSwapBuffer(gFramebuffer1);
+ osViSwapBuffer(gLoBuffer.framebuffer);
osViBlack(false);
}
@@ -52,9 +53,13 @@ void Main_InitMemory(void) {
void* memStart = (void*)0x80000400;
void* memEnd = OS_PHYSICAL_TO_K0(osMemSize);
- Main_ClearMemory(memStart, gFramebuffer1);
- Main_ClearMemory(D_80025D00, bootproc);
- Main_ClearMemory(gGfxSPTaskYieldBuffer, memEnd);
+ Main_ClearMemory(memStart, SEGMENT_START(framebuffer_lo));
+
+ // Clear the rest of the buffer that was not initialized by Main_InitScreen
+ Main_ClearMemory(&gLoBuffer.skyboxBuffer, SEGMENT_END(framebuffer_lo));
+
+ // Clear all the buffers after the `code` segment, up to the end of the available RAM space
+ Main_ClearMemory(SEGMENT_END(code), memEnd);
}
void Main_Init(void) {
diff --git a/src/buffers/audio_heap.c b/src/buffers/audio_heap.c
new file mode 100644
index 000000000..1fab091bc
--- /dev/null
+++ b/src/buffers/audio_heap.c
@@ -0,0 +1,3 @@
+#include "buffers.h"
+
+u8 gAudioHeap[0x138000] ALIGNED(16);
diff --git a/src/buffers/framebuffer_hi.c b/src/buffers/framebuffer_hi.c
new file mode 100644
index 000000000..2ae30d39c
--- /dev/null
+++ b/src/buffers/framebuffer_hi.c
@@ -0,0 +1,5 @@
+#include "buffers.h"
+
+// Don't add symbols here unless you know what you are doing.
+
+BufferHigh gHiBuffer ALIGNED(64);
diff --git a/src/buffers/framebuffer_lo.c b/src/buffers/framebuffer_lo.c
new file mode 100644
index 000000000..121372505
--- /dev/null
+++ b/src/buffers/framebuffer_lo.c
@@ -0,0 +1,5 @@
+#include "buffers.h"
+
+// Don't add symbols here unless you know what you are doing.
+
+BufferLow gLoBuffer ALIGNED(64);
diff --git a/src/buffers/gfxpools.c b/src/buffers/gfxpools.c
index ff4934f11..f7b4ab5b7 100644
--- a/src/buffers/gfxpools.c
+++ b/src/buffers/gfxpools.c
@@ -1,3 +1,3 @@
#include "buffers.h"
-GfxPool gGfxPools[2];
+GfxPool gGfxPools[2] ALIGNED(16);
diff --git a/src/buffers/gfxstack.c b/src/buffers/gfxstack.c
index 8864d58ef..b88e27eaa 100644
--- a/src/buffers/gfxstack.c
+++ b/src/buffers/gfxstack.c
@@ -1,3 +1,3 @@
#include "buffers.h"
-STACK(gGfxSPTaskStack, 0x400);
+STACK(gGfxSPTaskStack, 0x400) ALIGNED(16);
diff --git a/src/buffers/gfxyield.c b/src/buffers/gfxyield.c
index 576cfc0bb..866257eac 100644
--- a/src/buffers/gfxyield.c
+++ b/src/buffers/gfxyield.c
@@ -1,3 +1,3 @@
#include "buffers.h"
-u8 gGfxSPTaskYieldBuffer[OS_YIELD_DATA_SIZE];
+u8 gGfxSPTaskYieldBuffer[OS_YIELD_DATA_SIZE] ALIGNED(16);
diff --git a/src/buffers/heaps.c b/src/buffers/heaps.c
deleted file mode 100644
index 477eca03e..000000000
--- a/src/buffers/heaps.c
+++ /dev/null
@@ -1,5 +0,0 @@
-#include "buffers.h"
-
-u8 gAudioHeap[0x138000];
-
-u8 gSystemHeap[UNK_SIZE];
diff --git a/src/buffers/system_heap.c b/src/buffers/system_heap.c
new file mode 100644
index 000000000..df3d79003
--- /dev/null
+++ b/src/buffers/system_heap.c
@@ -0,0 +1,6 @@
+#include "buffers.h"
+
+// Don't add symbols here unless you know what you are doing.
+
+// Dummy, marks the start of system_heap space whose actual size depends on the spec
+u8 gSystemHeap[UNK_SIZE] ALIGNED(16);
diff --git a/src/code/main.c b/src/code/main.c
index 14ee841ce..83df66396 100644
--- a/src/code/main.c
+++ b/src/code/main.c
@@ -53,8 +53,8 @@ void Main(void* arg) {
Check_RegionIsSupported();
Check_ExpansionPak();
- sysHeap = (intptr_t)gSystemHeap;
- fb = 0x80780000;
+ sysHeap = (intptr_t)SEGMENT_START(system_heap);
+ fb = FRAMEBUFFERS_START_ADDR;
gSystemHeapSize = fb - sysHeap;
SystemHeap_Init((void*)sysHeap, gSystemHeapSize);
diff --git a/src/code/sys_cfb.c b/src/code/sys_cfb.c
index 32600643a..b559a44ee 100644
--- a/src/code/sys_cfb.c
+++ b/src/code/sys_cfb.c
@@ -1,5 +1,5 @@
-#include "prevent_bss_reordering.h"
#include "z64.h"
+#include "buffers.h"
#include "regs.h"
#include "functions.h"
#include "macros.h"
@@ -41,9 +41,6 @@ u8 gSysCfbHiResEnabled;
#include "system_malloc.h"
#include "z64vimode.h"
-extern u16 gFramebufferHiRes0[HIRES_BUFFER_WIDTH][HIRES_BUFFER_HEIGHT];
-extern u16 gFramebufferHiRes1[HIRES_BUFFER_WIDTH][HIRES_BUFFER_HEIGHT];
-
void SysCfb_SetLoResMode(void) {
gFramebuffers[1] = sCfbLoRes1;
gFramebuffers[0] = sCfbLoRes0;
@@ -93,8 +90,8 @@ void SysCfb_SetHiResMode(void) {
}
void SysCfb_Init(void) {
- sCfbLoRes1 = gFramebuffer1;
- sCfbLoRes0 = gFramebuffer0;
+ sCfbLoRes1 = gLoBuffer.framebuffer;
+ sCfbLoRes0 = gHiBuffer.framebuffer;
sCfbHiRes1 = gFramebufferHiRes1;
sCfbHiRes0 = gFramebufferHiRes0;
SysCfb_SetLoResMode();
diff --git a/src/code/z_play.c b/src/code/z_play.c
index 226980b4d..ca4fb500d 100644
--- a/src/code/z_play.c
+++ b/src/code/z_play.c
@@ -248,7 +248,7 @@ void Play_TriggerPictoPhoto(void) {
void Play_TakePictoPhoto(PreRender* prerender) {
PreRender_ApplyFilters(prerender);
- Play_ConvertRgba16ToIntensityImage(gPictoPhotoI8, prerender->fbufSave, SCREEN_WIDTH, PICTO_PHOTO_TOPLEFT_X,
+ Play_ConvertRgba16ToIntensityImage(gHiBuffer.pictoPhotoI8, prerender->fbufSave, SCREEN_WIDTH, PICTO_PHOTO_TOPLEFT_X,
PICTO_PHOTO_TOPLEFT_Y, (PICTO_PHOTO_TOPLEFT_X + PICTO_PHOTO_WIDTH) - 1,
(PICTO_PHOTO_TOPLEFT_Y + PICTO_PHOTO_HEIGHT) - 1, 8);
}
@@ -2262,10 +2262,10 @@ void Play_Init(GameState* thisx) {
PreRender_SetValues(&this->pauseBgPreRender, gCfbWidth, gCfbHeight, NULL, NULL);
this->unk_18E64 = gWorkBuffer;
- this->pictoPhotoI8 = gPictoPhotoI8;
- this->unk_18E68 = D_80784600;
- this->unk_18E58 = D_80784600;
- this->unk_18E60 = D_80784600;
+ this->pictoPhotoI8 = gHiBuffer.pictoPhotoI8;
+ this->unk_18E68 = gHiBuffer.D_80784600;
+ this->unk_18E58 = gHiBuffer.D_80784600;
+ this->unk_18E60 = gHiBuffer.D_80784600;
gTransitionTileState = TRANS_TILE_OFF;
this->transitionMode = TRANS_MODE_OFF;
D_801D0D54 = false;
diff --git a/src/code/z_vr_box.c b/src/code/z_vr_box.c
index 605dff84c..23f00d246 100644
--- a/src/code/z_vr_box.c
+++ b/src/code/z_vr_box.c
@@ -1,4 +1,5 @@
#include "global.h"
+#include "buffers.h"
u32 D_801C5E30[] = { 0, 0x2000, 0x4000, 0x6000, 0x8000, 0xC000 };
@@ -193,7 +194,7 @@ void Skybox_Setup(GameState* gameState, SkyboxContext* skyboxCtx, s16 skyboxId)
switch (skyboxId) {
case SKYBOX_NORMAL_SKY:
// Send a DMA request for the cloudy sky texture
- skyboxCtx->staticSegments[0] = &D_80025D00;
+ skyboxCtx->staticSegments[0] = gLoBuffer.skyboxBuffer;
size = SEGMENT_ROM_SIZE(d2_cloud_static);
segment = (void*)ALIGN8((uintptr_t)skyboxCtx->staticSegments[0] + size);
DmaMgr_SendRequest0(skyboxCtx->staticSegments[0], SEGMENT_ROM_START(d2_cloud_static), size);