Stack cleanups (#1193)

* Use STACK and STACK_TOP everywhere

* format

* remove fake variable

* bss

* review

Co-authored-by: Derek Hensley <hensley.derek58@gmail.com>

* Update src/boot_O2_g3/boot_main.c

Co-authored-by: Derek Hensley <hensley.derek58@gmail.com>

* review

* renames

* more renames

* and more

* whoopsie, forgot those too

* hopefully the last cleanup

* forgot some stuff

* a

* bss

---------

Co-authored-by: Derek Hensley <hensley.derek58@gmail.com>
This commit is contained in:
Anghelo Carvajal 2023-03-08 15:25:51 -03:00 committed by GitHub
parent 9f529aaf2a
commit 2f1e7b3de8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
25 changed files with 192 additions and 169 deletions

20
include/buffers.h Normal file
View File

@ -0,0 +1,20 @@
#ifndef BUFFERS_H
#define BUFFERS_H
#include "z64.h"
#include "macros.h"
#include "stack.h"
extern u8 gGfxSPTaskYieldBuffer[OS_YIELD_DATA_SIZE];
extern STACK(gGfxSPTaskStack, 0x400);
extern GfxPool gGfxPools[2];
extern u8 gAudioHeap[0x138000];
extern u8 gSystemHeap[];
extern u8 gPictoPhotoI8[PICTO_PHOTO_SIZE];
extern u8 D_80784600[0x56200];
extern u16 gFramebuffer0[SCREEN_HEIGHT][SCREEN_WIDTH];
#endif

12
include/stack.h Normal file
View File

@ -0,0 +1,12 @@
#ifndef STACK_H
#define STACK_H
#include "alignment.h"
#define STACK(stack, size) \
u64 stack[ALIGN8(size) / sizeof(u64)]
#define STACK_TOP(stack) \
((u8*)(stack) + sizeof(stack))
#endif

View File

@ -282,27 +282,12 @@ extern f64 D_800994C8;
extern char gBuildTeam[];
extern char gBuildDate[];
extern char gBuildMakeOption[];
// extern StackEntry sBootThreadInfo;
// extern OSThread sIdleThread;
// extern u8 sIdleThreadStack[0x400];
// extern StackEntry sIdleThreadInfo;
// extern u8 sBootThreadStack[0x400];
extern IrqMgr gIrqMgr;
// extern u8 sIrqMgrStack[0x500];
// extern StackEntry sIrqMgrStackInfo;
// extern OSThread gMainThread;
// extern u8 sMainStack[0x900];
// extern StackEntry sMainStackInfo;
// extern OSMesg sPiMgrCmdBuff[50];
// extern OSMesgQueue gPiMgrCmdQ;
extern OSViMode gViConfigMode;
extern u8 D_8009B290;
extern StackEntry sDmaMgrStackInfo;
extern u16 numDmaEntries;
extern OSMesgQueue sDmaMgrMsgQueue;
extern OSMesg sDmaMgrMsgs[32];
extern OSThread sDmaMgrThread;
extern u8 sDmaMgrStack[0x500];
extern u8 sYaz0DataBuffer[0x400];
extern u8* sYaz0CurDataEnd;
extern u32 sYaz0CurRomStart;
@ -312,13 +297,9 @@ extern void* gYaz0DecompressDstEnd;
// extern UNK_TYPE4 D_8009BE30;
// extern UNK_TYPE4 D_8009BE34;
// extern FaultClient romInfoFaultClient;
extern FaultThreadStruct* sFaultContext;
extern f32 D_8009BE54;
extern u32 faultCustomOptions;
extern u32 faultCopyToLog;
extern u8 sFaultStack[0x600];
extern StackEntry sFaultThreadInfo;
extern FaultThreadStruct gFaultStruct;
extern FaultDrawer sFaultDrawerStruct;
// extern UNK_TYPE4 D_8009CD10;
extern u32 sRandFloat;
@ -333,10 +314,7 @@ extern UNK_TYPE1 D_8009CF60;
extern OSThread __osThreadSave;
extern OSPiHandle D_8009D130;
extern OSPiHandle D_8009D1A8;
// extern OSThread D_8009D220;
// extern u8 piManagerStack[0x1000];
// extern OSMesgQueue D_8009E3D0;
// extern OSMesg D_8009E3E8[1];
extern OSMesg D_8009E3F0[1];
extern OSMesgQueue __osPiAccessQueue;
extern __OSInode __osPfsInodeCache;
@ -348,13 +326,7 @@ extern u32 __osViIntrCount;
extern u32 __osTimerCounter;
extern OSPifRam __osPfsPifRam;
extern OSPiHandle CartRomHandle;
extern OSThread viThread;
extern u8 viThreadStack[0x1000];
extern OSMesgQueue viEventQueue;
// extern OSMesg viEventBuf[5];
// extern OSIoMesg viRetraceMsg;
// extern OSIoMesg viCounterMsg;
extern u16 viRetrace;
extern DmaEntry dmadata[1568];
// extern UNK_TYPE1 D_80186028;
extern u64 aspMainTextStart[];
@ -2488,11 +2460,7 @@ extern Struct_80140E80* D_801F6D4C;
extern BombersNotebook sBombersNotebook;
extern u8 sBombersNotebookOpen;
extern u8 sMotionBlurStatus;
extern SlowlyTask D_801F6E00;
extern s32 D_801F6FC0;
extern StackEntry slowlyStackEntry;
extern u8 slowlyStack[0x1000];
extern UNK_TYPE1 D_801F7FE8;
extern UNK_TYPE1 D_801F7FF0;
extern struct_801F8010 D_801F8010;
extern struct_801F8020 D_801F8020;
@ -2503,24 +2471,12 @@ extern FaultClient sGraphFaultClient;
extern GfxMasterList* gGfxMasterDL;
extern CfbInfo sGraphCfbInfos[3];
extern OSTime sGraphTaskStartTime;
extern OSMesgQueue sSiIntMsgQ;
extern OSMesg sSiIntMsgBuf[1];
extern u32 gSegments[NUM_SEGMENTS];
extern SchedContext gSchedContext;
extern IrqMgrClient irqClient;
extern OSMesgQueue irqMgrMsgQ;
extern OSMesg irqMgrMsgBuf[60];
extern OSThread sGraphThread;
extern u8 sGraphStack[6144];
extern u8 schedStack[1536];
extern u8 audioStack[2048];
extern u8 padmgrStack[1280];
extern StackEntry sGraphStackInfo;
extern StackEntry schedStackEntry;
extern StackEntry audioStackEntry;
extern StackEntry padmgrStackEntry;
extern AudioMgr audioContext;
extern PadMgr D_801FB620;
extern OSThread gGraphThread;
extern PadMgr gPadMgr;
extern FaultClient sSchedFaultClient;
extern OSTime sRSPGFXStartTime;
extern OSTime sRSPAudioStartTime;
@ -2636,15 +2592,7 @@ extern Vec3f D_801FBDA4;
extern Vec3f D_801FBDE8;
extern MtxF* sMatrixStack;
extern MtxF* sCurrentMatrix;
// extern UNK_TYPE1 D_801FBE10;
// extern UNK_TYPE1 D_801FBE28;
// extern UNK_TYPE1 D_801FBE2C;
// extern UNK_TYPE4 D_801FBE30;
extern u8 sys_flashromStack[0x1000];
extern StackEntry sys_flashromStackEntry;
extern OSThread sys_flashromOSThread;
extern s80185D40 D_801FD008;
extern OSMesg D_801FD034;
extern s32 D_801FD120;
// extern UNK_TYPE1 D_801FD140;
// extern UNK_TYPE1 D_801FD158;
@ -2777,17 +2725,6 @@ extern AudioCustomSeqFunction gAudioCustomSeqFunction;
extern AudioCustomReverbFunction gAudioCustomReverbFunction;
extern AudioCustomSynthFunction gAudioCustomSynthFunction;
// post-code buffers
extern u8 gGfxSPTaskYieldBuffer[OS_YIELD_DATA_SIZE];
extern u8 gGfxSPTaskStack[0x400];
extern GfxPool gGfxPools[2];
extern u8 gAudioHeap[0x138000];
extern u8 gSystemHeap[UNK_SIZE];
extern u8 gPictoPhotoI8[PICTO_PHOTO_SIZE];
extern u8 D_80784600[0x56200];
extern u16 gFramebuffer0[SCREEN_HEIGHT][SCREEN_WIDTH];
// other segments
extern GfxMasterList D_0E000000;
extern Mtx D_01000000;

View File

@ -11,6 +11,7 @@
*/
#include "global.h"
#include "buffers.h"
/**
* SoundFont Notes:

View File

@ -1,4 +1,5 @@
#include "global.h"
#include "buffers.h"
const s16 gAudioTatumInit[] = {
0x1C00, // unused

View File

@ -1,21 +1,22 @@
#include "prevent_bss_reordering.h"
#include "global.h"
#include "stack.h"
StackEntry sBootThreadInfo;
StackEntry sBootStackInfo;
OSThread sIdleThread;
u8 sIdleThreadStack[0x400];
StackEntry sIdleThreadInfo;
u8 sBootThreadStack[0x400];
STACK(sIdleThreadStack, 0x400);
StackEntry sIdleStackInfo;
STACK(sBootThreadStack, 0x400);
void bootproc(void) {
StackCheck_Init(&sBootThreadInfo, sBootThreadStack, sBootThreadStack + sizeof(sBootThreadStack), 0, -1, "boot");
StackCheck_Init(&sBootStackInfo, sBootThreadStack, STACK_TOP(sBootThreadStack), 0, -1, "boot");
osMemSize = osGetMemSize();
func_800818F4();
osInitialize();
osUnmapTLBAll();
gCartHandle = osCartRomInit();
StackCheck_Init(&sIdleThreadInfo, sIdleThreadStack, sIdleThreadStack + sizeof(sIdleThreadStack), 0, 256, "idle");
osCreateThread(&sIdleThread, Z_THREAD_ID_IDLE, Idle_ThreadEntry, NULL, sIdleThreadStack + sizeof(sIdleThreadStack),
StackCheck_Init(&sIdleStackInfo, sIdleThreadStack, STACK_TOP(sIdleThreadStack), 0, 0x100, "idle");
osCreateThread(&sIdleThread, Z_THREAD_ID_IDLE, Idle_ThreadEntry, NULL, STACK_TOP(sIdleThreadStack),
Z_PRIORITY_IDLE);
osStartThread(&sIdleThread);
}

View File

@ -1,7 +1,15 @@
#include "ultra64.h"
#include "global.h"
#include "stack.h"
#include "vt.h"
extern FaultThreadStruct* sFaultContext;
extern f32 D_8009BE54;
extern u32 faultCustomOptions;
extern u32 faultCopyToLog;
extern STACK(sFaultStack, 0x600);
extern StackEntry sFaultStackInfo;
// data
const char* sCpuExceptions[] = {
"Interrupt",
@ -759,9 +767,9 @@ void Fault_SetOptionsFromController3(void) {
}
if (faultCustomOptions) {
graphPC = sGraphThread.context.pc;
graphRA = sGraphThread.context.ra;
graphSP = sGraphThread.context.sp;
graphPC = gGraphThread.context.pc;
graphRA = gGraphThread.context.ra;
graphSP = gGraphThread.context.sp;
if (CHECK_BTN_ALL(input3->cur.button, BTN_R)) {
static u32 faultCopyToLog;
@ -889,8 +897,8 @@ void Fault_Start(void) {
sFaultContext->faultActive = 0;
gFaultStruct.faultHandlerEnabled = 1;
osCreateMesgQueue(&sFaultContext->queue, sFaultContext->msg, ARRAY_COUNT(sFaultContext->msg));
StackCheck_Init(&sFaultThreadInfo, sFaultStack, sFaultStack + sizeof(sFaultStack), 0, 0x100, "fault");
osCreateThread(&sFaultContext->thread, 2, Fault_ThreadEntry, NULL, sFaultStack + sizeof(sFaultStack), 0x7F);
StackCheck_Init(&sFaultStackInfo, sFaultStack, STACK_TOP(sFaultStack), 0, 0x100, "fault");
osCreateThread(&sFaultContext->thread, 2, Fault_ThreadEntry, NULL, STACK_TOP(sFaultStack), 0x7F);
osStartThread(&sFaultContext->thread);
}

View File

@ -1,5 +1,7 @@
#include "prevent_bss_reordering.h"
#include "global.h"
#include "stack.h"
#include "buffers.h"
u8 D_80096B20 = 1;
vu8 gViConfigUseDefault = 1;
@ -9,10 +11,10 @@ f32 gViConfigXScale = 1.0f;
f32 gViConfigYScale = 1.0f;
IrqMgr gIrqMgr;
u8 sIrqMgrStack[0x500];
STACK(sIrqMgrStack, 0x500);
StackEntry sIrqMgrStackInfo;
OSThread gMainThread;
u8 sMainStack[0x900];
OSThread sMainThread;
STACK(sMainStack, 0x900);
StackEntry sMainStackInfo;
OSMesg sPiMgrCmdBuff[50];
OSMesgQueue gPiMgrCmdQ;
@ -71,8 +73,8 @@ void Idle_InitCodeAndMemory(void) {
}
void Main_ThreadEntry(void* arg) {
StackCheck_Init(&sIrqMgrStackInfo, sIrqMgrStack, sIrqMgrStack + sizeof(sIrqMgrStack), 0, 0x100, "irqmgr");
IrqMgr_Init(&gIrqMgr, &sIrqMgrStackInfo, Z_PRIORITY_IRQMGR, 1);
StackCheck_Init(&sIrqMgrStackInfo, sIrqMgrStack, STACK_TOP(sIrqMgrStack), 0, 0x100, "irqmgr");
IrqMgr_Init(&gIrqMgr, STACK_TOP(sIrqMgrStack), Z_PRIORITY_IRQMGR, 1);
DmaMgr_Start();
Idle_InitCodeAndMemory();
Main(arg);
@ -108,10 +110,9 @@ void Idle_InitVideo(void) {
void Idle_ThreadEntry(void* arg) {
Idle_InitVideo();
osCreatePiManager(150, &gPiMgrCmdQ, sPiMgrCmdBuff, ARRAY_COUNT(sPiMgrCmdBuff));
StackCheck_Init(&sMainStackInfo, sMainStack, sMainStack + sizeof(sMainStack), 0, 0x400, "main");
osCreateThread(&gMainThread, Z_THREAD_ID_MAIN, Main_ThreadEntry, arg, sMainStack + sizeof(sMainStack),
Z_PRIORITY_MAIN);
osStartThread(&gMainThread);
StackCheck_Init(&sMainStackInfo, sMainStack, STACK_TOP(sMainStack), 0, 0x400, "main");
osCreateThread(&sMainThread, Z_THREAD_ID_MAIN, Main_ThreadEntry, arg, STACK_TOP(sMainStack), Z_PRIORITY_MAIN);
osStartThread(&sMainThread);
osSetThreadPri(NULL, 0);
do { } while (true); }

View File

@ -1,5 +1,6 @@
#include "prevent_bss_reordering.h"
#include "global.h"
#include "stack.h"
u32 sDmaMgrDmaBuffSize = 0x2000;
@ -8,7 +9,7 @@ u16 numDmaEntries;
OSMesgQueue sDmaMgrMsgQueue;
OSMesg sDmaMgrMsgs[32];
OSThread sDmaMgrThread;
u8 sDmaMgrStack[0x500];
STACK(sDmaMgrStack, 0x500);
s32 DmaMgr_DmaRomToRam(uintptr_t rom, void* ram, size_t size) {
OSIoMesg ioMsg;
@ -226,8 +227,8 @@ void DmaMgr_Start(void) {
}
osCreateMesgQueue(&sDmaMgrMsgQueue, sDmaMgrMsgs, ARRAY_COUNT(sDmaMgrMsgs));
StackCheck_Init(&sDmaMgrStackInfo, sDmaMgrStack, sDmaMgrStack + sizeof(sDmaMgrStack), 0, 0x100, "dmamgr");
osCreateThread(&sDmaMgrThread, Z_THREAD_ID_DMAMGR, DmaMgr_ThreadEntry, NULL, sDmaMgrStack + sizeof(sDmaMgrStack),
StackCheck_Init(&sDmaMgrStackInfo, sDmaMgrStack, STACK_TOP(sDmaMgrStack), 0, 0x100, "dmamgr");
osCreateThread(&sDmaMgrThread, Z_THREAD_ID_DMAMGR, DmaMgr_ThreadEntry, NULL, STACK_TOP(sDmaMgrStack),
Z_PRIORITY_DMAMGR);
osStartThread(&sDmaMgrThread);

View File

@ -1,3 +1,3 @@
#include "global.h"
#include "buffers.h"
GfxPool gGfxPools[2];

View File

@ -1,3 +1,3 @@
#include "global.h"
#include "buffers.h"
u8 gGfxSPTaskStack[0x400];
STACK(gGfxSPTaskStack, 0x400);

View File

@ -1,4 +1,3 @@
#include "prevent_bss_reordering.h"
#include "global.h"
#include "buffers.h"
u8 gGfxSPTaskYieldBuffer[OS_YIELD_DATA_SIZE];

View File

@ -1,4 +1,4 @@
#include "global.h"
#include "buffers.h"
u8 gAudioHeap[0x138000];

View File

@ -1,4 +1,5 @@
#include "global.h"
#include "stack.h"
/**
* Assigns the "save" values in PreRender
@ -410,19 +411,24 @@ void PreRender_ApplyFilters(PreRender* this) {
}
}
extern SlowlyTask D_801F6E00;
extern s32 D_801F6FC0;
extern StackEntry sSlowlyStackInfo;
extern STACK(sSlowlyStack, 0x1000);
/**
* Initializes `PreRender_ApplyFilters` onto a new "slowly" thread
*/
void PreRender_ApplyFiltersSlowlyInit(PreRender* this) {
if ((this->cvgSave != NULL) && (this->fbufSave != NULL)) {
if (D_801F6FC0) {
StackCheck_Cleanup(&slowlyStackEntry);
StackCheck_Cleanup(&sSlowlyStackInfo);
Slowly_Stop(&D_801F6E00);
}
this->unk_4D = 1;
StackCheck_Init(&slowlyStackEntry, slowlyStack, &slowlyStack[4096], 0, 0x100, "slowly");
Slowly_Start(&D_801F6E00, &D_801F7FE8, PreRender_ApplyFilters, this, NULL);
StackCheck_Init(&sSlowlyStackInfo, sSlowlyStack, STACK_TOP(sSlowlyStack), 0, 0x100, "slowly");
Slowly_Start(&D_801F6E00, STACK_TOP(sSlowlyStack), PreRender_ApplyFilters, this, NULL);
D_801F6FC0 = true;
}
}
@ -432,7 +438,7 @@ void PreRender_ApplyFiltersSlowlyInit(PreRender* this) {
*/
void PreRender_ApplyFiltersSlowlyDestroy(PreRender* this) {
if (D_801F6FC0) {
StackCheck_Cleanup(&slowlyStackEntry);
StackCheck_Cleanup(&sSlowlyStackInfo);
Slowly_Stop(&D_801F6E00);
D_801F6FC0 = false;
}

View File

@ -1,4 +1,5 @@
#include "global.h"
#include "buffers.h"
#include "system_malloc.h"
#include "overlays/gamestates/ovl_daytelop/z_daytelop.h"
#include "overlays/gamestates/ovl_file_choose/z_file_choose.h"

View File

@ -3,7 +3,29 @@
* reordering than just prevent_bss_reordering.h: there is too much of it to control, and it cannot be split into
* separate files since most of it is at addresses ending in 8.
*/
#include "global.h"
#include "buffers.h"
#include "stack.h"
extern OSMesgQueue sSiIntMsgQ;
extern OSMesg sSiIntMsgBuf[1];
extern u32 gSegments[NUM_SEGMENTS];
extern SchedContext gSchedContext;
extern IrqMgrClient irqClient;
extern OSMesgQueue irqMgrMsgQ;
extern OSMesg irqMgrMsgBuf[60];
extern OSThread gGraphThread;
extern STACK(sGraphStack, 0x1800);
extern STACK(sSchedStack, 0x600);
extern STACK(sAudioStack, 0x800);
extern STACK(sPadMgrStack, 0x500);
extern StackEntry sGraphStackInfo;
extern StackEntry sSchedStackInfo;
extern StackEntry sAudioStackInfo;
extern StackEntry sPadMgrStackInfo;
extern AudioMgr sAudioMgr;
extern PadMgr gPadMgr;
void Main(void* arg) {
intptr_t fb;
@ -33,25 +55,24 @@ void Main(void* arg) {
osCreateMesgQueue(&irqMgrMsgQ, irqMgrMsgBuf, ARRAY_COUNT(irqMgrMsgBuf));
StackCheck_Init(&schedStackEntry, schedStack, schedStack + sizeof(schedStack), 0, 0x100, "sched");
Sched_Init(&gSchedContext, schedStack + sizeof(schedStack), Z_PRIORITY_SCHED, D_8009B290, 1, &gIrqMgr);
StackCheck_Init(&sSchedStackInfo, sSchedStack, STACK_TOP(sSchedStack), 0, 0x100, "sched");
Sched_Init(&gSchedContext, STACK_TOP(sSchedStack), Z_PRIORITY_SCHED, D_8009B290, 1, &gIrqMgr);
CIC6105_AddRomInfoFaultPage();
IrqMgr_AddClient(&gIrqMgr, &irqClient, &irqMgrMsgQ);
StackCheck_Init(&audioStackEntry, audioStack, audioStack + sizeof(audioStack), 0, 0x100, "audio");
AudioMgr_Init(&audioContext, audioStack + sizeof(audioStack), Z_PRIORITY_AUDIOMGR, 0xA, &gSchedContext, &gIrqMgr);
StackCheck_Init(&sAudioStackInfo, sAudioStack, STACK_TOP(sAudioStack), 0, 0x100, "audio");
AudioMgr_Init(&sAudioMgr, STACK_TOP(sAudioStack), Z_PRIORITY_AUDIOMGR, 0xA, &gSchedContext, &gIrqMgr);
StackCheck_Init(&padmgrStackEntry, padmgrStack, padmgrStack + sizeof(padmgrStack), 0, 0x100, "padmgr");
PadMgr_Init(&sSiIntMsgQ, &gIrqMgr, 7, Z_PRIORITY_PADMGR, padmgrStack + sizeof(padmgrStack));
StackCheck_Init(&sPadMgrStackInfo, sPadMgrStack, STACK_TOP(sPadMgrStack), 0, 0x100, "padmgr");
PadMgr_Init(&sSiIntMsgQ, &gIrqMgr, 7, Z_PRIORITY_PADMGR, STACK_TOP(sPadMgrStack));
AudioMgr_Unlock(&audioContext);
AudioMgr_Unlock(&sAudioMgr);
StackCheck_Init(&sGraphStackInfo, sGraphStack, sGraphStack + sizeof(sGraphStack), 0, 0x100, "graph");
osCreateThread(&sGraphThread, Z_THREAD_ID_GRAPH, Graph_ThreadEntry, arg, sGraphStack + sizeof(sGraphStack),
Z_PRIORITY_GRAPH);
osStartThread(&sGraphThread);
StackCheck_Init(&sGraphStackInfo, sGraphStack, STACK_TOP(sGraphStack), 0, 0x100, "graph");
osCreateThread(&gGraphThread, Z_THREAD_ID_GRAPH, Graph_ThreadEntry, arg, STACK_TOP(sGraphStack), Z_PRIORITY_GRAPH);
osStartThread(&gGraphThread);
exit = false;
@ -73,5 +94,5 @@ void Main(void* arg) {
}
IrqMgr_RemoveClient(&gIrqMgr, &irqClient);
osDestroyThread(&sGraphThread);
osDestroyThread(&gGraphThread);
}

View File

@ -1,4 +1,5 @@
#include "global.h"
#include "buffers.h"
#include "system_malloc.h"
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_cfb/func_80178750.s")

View File

@ -1,6 +1,17 @@
#include "global.h"
#include "stack.h"
#include "system_malloc.h"
// extern UNK_TYPE1 D_801FBE10;
// extern UNK_TYPE1 D_801FBE28;
// extern UNK_TYPE1 D_801FBE2C;
// extern UNK_TYPE4 D_801FBE30;
extern STACK(sSysFlashromStack, 0x1000);
extern StackEntry sys_flashromStackEntry;
extern OSThread sys_flashromOSThread;
extern s80185D40 D_801FD008;
extern OSMesg D_801FD034;
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_flashrom/func_801857C0.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_flashrom/func_801857D0.s")

View File

@ -1,4 +1,5 @@
#include "global.h"
#include "buffers.h"
#include "z64debug_display.h"
#include "z64quake.h"
#include "z64rumble.h"

View File

@ -1,3 +1,4 @@
#include "prevent_bss_reordering.h"
#include "global.h"
#include "overlays/gamestates/ovl_file_choose/z_file_choose.h"

View File

@ -1,9 +1,10 @@
#include "global.h"
#include "stack.h"
OSPiHandle D_8009D130;
OSPiHandle D_8009D1A8;
OSThread D_8009D220;
u8 piManagerStack[0x1000];
OSThread sPiMgrThread;
STACK(sPiMgrStack, 0x1000);
OSMesgQueue D_8009E3D0;
OSMesg D_8009E3E8[1];
@ -27,14 +28,14 @@ void osCreatePiManager(OSPri pri, OSMesgQueue* cmdQ, OSMesg* cmdBuf, s32 cmdMsgC
}
savedMask = __osDisableInt();
__osPiDevMgr.active = 1;
__osPiDevMgr.thread = &D_8009D220;
__osPiDevMgr.thread = &sPiMgrThread;
__osPiDevMgr.cmdQueue = cmdQ;
__osPiDevMgr.evtQueue = &D_8009E3D0;
__osPiDevMgr.acsQueue = &__osPiAccessQueue;
__osPiDevMgr.piDmaCallback = __osPiRawStartDma;
__osPiDevMgr.epiDmaCallback = __osEPiRawStartDma;
osCreateThread(&D_8009D220, 0, __osDevMgrMain, (void*)&__osPiDevMgr, &piManagerStack[4096], pri);
osStartThread(&D_8009D220);
osCreateThread(&sPiMgrThread, 0, __osDevMgrMain, &__osPiDevMgr, STACK_TOP(sPiMgrStack), pri);
osStartThread(&sPiMgrThread);
__osRestoreInt(savedMask);
if (oldPri != -1) {
osSetThreadPri(NULL, oldPri);

View File

@ -1,8 +1,9 @@
#include "global.h"
#include "stack.h"
#include "osint.h"
OSThread viThread;
u8 viThreadStack[0x1000];
STACK(sViStack, 0x1000);
OSMesgQueue viEventQueue;
OSMesg viEventBuf[6];
OSIoMesg viRetraceMsg;
@ -45,7 +46,7 @@ void osCreateViManager(OSPri pri) {
__osViDevMgr.piDmaCallback = NULL;
__osViDevMgr.epiDmaCallback = NULL;
osCreateThread(&viThread, 0, &viMgrMain, &__osViDevMgr, viThreadStack + sizeof(viThreadStack), pri);
osCreateThread(&viThread, 0, &viMgrMain, &__osViDevMgr, STACK_TOP(sViStack), pri);
__osViInit();
osStartThread(&viThread);
__osRestoreInt(prevInt);

View File

@ -4,6 +4,7 @@
* Description: Trees, shrubs
*/
#include "prevent_bss_reordering.h"
#include "z_en_wood02.h"
#include "objects/object_wood02/object_wood02.h"
@ -35,8 +36,8 @@ typedef enum {
/* 5 */ WOOD_DRAW_LEAF_YELLOW
} WoodDrawType;
static f32 sSpawnCos;
static f32 sSpawnSin;
f32 sWood02SpawnCos;
f32 sWood02SpawnSin;
ActorInit En_Wood02_InitVars = {
ACTOR_EN_WOOD02,
@ -70,9 +71,9 @@ static ColliderCylinderInit sCylinderInit = {
{ 18, 60, 0, { 0, 0, 0 } },
};
static f32 sSpawnDistance[] = { 707.0f, 525.0f, 510.0f, 500.0f, 566.0f, 141.0f };
f32 sWood02SpawnDistance[] = { 707.0f, 525.0f, 510.0f, 500.0f, 566.0f, 141.0f };
static s16 sSpawnAngle[] = { 0x1FFF, 0x4C9E, 0x77F5, 0xA5C9, -0x293D, 0xA000 };
s16 sWood02SpawnAngle[] = { 0x1FFF, 0x4C9E, 0x77F5, 0xA5C9, -0x293D, 0xA000 };
static InitChainEntry sInitChain[] = {
ICHAIN_F32(targetArrowOffset, 5600, ICHAIN_STOP),
@ -136,12 +137,12 @@ void EnWood02_SpawnOffspring(EnWood02* this, PlayState* play) {
extraRot = 0x4000;
}
sSpawnCos = Math_CosS(sSpawnAngle[i] + this->actor.world.rot.y + extraRot);
sSpawnSin = Math_SinS(sSpawnAngle[i] + this->actor.world.rot.y + extraRot);
sWood02SpawnCos = Math_CosS(sWood02SpawnAngle[i] + this->actor.world.rot.y + extraRot);
sWood02SpawnSin = Math_SinS(sWood02SpawnAngle[i] + this->actor.world.rot.y + extraRot);
childPos.x = (sSpawnDistance[i] * sSpawnSin) + this->actor.home.pos.x;
childPos.x = (sWood02SpawnDistance[i] * sWood02SpawnSin) + this->actor.home.pos.x;
childPos.y = this->actor.home.pos.y;
childPos.z = (sSpawnDistance[i] * sSpawnCos) + this->actor.home.pos.z;
childPos.z = (sWood02SpawnDistance[i] * sWood02SpawnCos) + this->actor.home.pos.z;
if (EnWood02_SpawnZoneCheck(this, play, &childPos)) {
if (this->unk_14A[i] & 0x80) {
@ -152,8 +153,8 @@ void EnWood02_SpawnOffspring(EnWood02* this, PlayState* play) {
childParams = ((this->unk_144 << 8) & 0xFF00) | (this->actor.params + 1);
child = (EnWood02*)Actor_SpawnAsChild(&play->actorCtx, &this->actor, play, ACTOR_EN_WOOD02, childPos.x,
childPos.y, childPos.z, this->actor.world.rot.x, sSpawnAngle[i],
unk, childParams);
childPos.y, childPos.z, this->actor.world.rot.x,
sWood02SpawnAngle[i], unk, childParams);
if (child != NULL) {
child->unk_14A[0] = i;
this->unk_14A[i] |= 1;
@ -296,10 +297,10 @@ void EnWood02_Init(Actor* thisx, PlayState* play) {
if (spawnType == WOOD_SPAWN_SPAWNER) {
EnWood02_SpawnOffspring(this, play);
sSpawnCos = Math_CosS(sSpawnAngle[5] + this->actor.world.rot.y + extraRot);
sSpawnSin = Math_SinS(sSpawnAngle[5] + this->actor.world.rot.y + extraRot);
this->actor.world.pos.x += sSpawnSin * sSpawnDistance[5];
this->actor.world.pos.z += sSpawnCos * sSpawnDistance[5];
sWood02SpawnCos = Math_CosS(sWood02SpawnAngle[5] + this->actor.world.rot.y + extraRot);
sWood02SpawnSin = Math_SinS(sWood02SpawnAngle[5] + this->actor.world.rot.y + extraRot);
this->actor.world.pos.x += sWood02SpawnSin * sWood02SpawnDistance[5];
this->actor.world.pos.z += sWood02SpawnCos * sWood02SpawnDistance[5];
} else {
this->actor.flags |= ACTOR_FLAG_10;
this->unk_151 = 2;

View File

@ -4,11 +4,9 @@
* Description: "Master" instance of grass for unit spawned by Obj_Grass_Unit
*/
#include "prevent_bss_reordering.h"
#include "z_obj_grass.h"
#include "overlays/actors/ovl_Obj_Grass_Carry/z_obj_grass_carry.h"
#include "objects/gameplay_keep/gameplay_keep.h"
#include "prevent_bss_reordering.h"
#define FLAGS (ACTOR_FLAG_10 | ACTOR_FLAG_20)

View File

@ -285,15 +285,15 @@
0x800994D0:("D_800994D0","char","[]",0xc),
0x800994DC:("D_800994DC","char","[]",0x12),
0x800994F0:("D_800994F0","char","[]",0x1),
0x80099500:("sBootThreadInfo","StackEntry","",0x1c),
0x80099500:("sBootStackInfo","StackEntry","",0x1c),
0x80099520:("sIdleThread","OSThread","",0x1b0),
0x800996D0:("sIdleThreadStack","u8","[1024]",0x400),
0x80099AD0:("sIdleThreadInfo","StackEntry","",0x1c),
0x80099AD0:("sIdleStackInfo","StackEntry","",0x1c),
0x80099AF0:("sBootThreadStack","u8","[1024]",0x400),
0x80099EF0:("gIrqMgr","IrqMgr","",0x280),
0x8009A170:("sIrqMgrStack","u8","[1280]",0x500),
0x8009A670:("sIrqMgrStackInfo","StackEntry","",0x1c),
0x8009A690:("gMainThread","OSThread","",0x1b0),
0x8009A690:("sMainThread","OSThread","",0x1b0),
0x8009A840:("sMainStack","u8","[2304]",0x900),
0x8009B140:("sMainStackInfo","StackEntry","",0x1c),
0x8009B160:("sPiMgrCmdBuff","OSMesg","[50]",0xc8),
@ -320,7 +320,7 @@
0x8009BE58:("faultCustomOptions","u32","",0x4),
0x8009BE5C:("faultCopyToLog","u32","",0x4),
0x8009BE60:("sFaultStack","u8","[1536]",0x600),
0x8009C460:("sFaultThreadInfo","StackEntry","",0x1c),
0x8009C460:("sFaultStackInfo","StackEntry","",0x1c),
0x8009C480:("gFaultStruct","FaultThreadStruct","",0x848),
0x8009CCD0:("sFaultDrawerStruct","FaultDrawer","",0x3c),
0x8009CD10:("D_8009CD10","UNK_TYPE4","",0x4),
@ -343,8 +343,8 @@
0x8009CF80:("__osThreadSave","OSThread","",0x1b0),
0x8009D130:("D_8009D130","OSPiHandle","",0x74),
0x8009D1A8:("D_8009D1A8","OSPiHandle","",0x74),
0x8009D220:("D_8009D220","OSThread","",0x1b0),
0x8009D3D0:("piManagerStack","u8","[4096]",0x1000),
0x8009D220:("sPiMgrThread","OSThread","",0x1b0),
0x8009D3D0:("sPiMgrStack","u8","[4096]",0x1000),
0x8009E3D0:("D_8009E3D0","OSMesgQueue","",0x18),
0x8009E3E8:("D_8009E3E8","OSMesg","[1]",0x4),
0x8009E3F0:("D_8009E3F0","OSMesg","[1]",0x4),
@ -359,7 +359,7 @@
0x8009E5D0:("__osPfsPifRam","OSPifRam","",0x40),
0x8009E610:("CartRomHandle","OSPiHandle","",0x74),
0x8009E690:("viThread","OSThread","",0x1b0),
0x8009E840:("viThreadStack","u8","[4096]",0x1000),
0x8009E840:("sViStack","u8","[4096]",0x1000),
0x8009F840:("viEventQueue","OSMesgQueue","",0x18),
0x8009F858:("viEventBuf","OSMesg","[5]",0x14),
0x8009F870:("viRetraceMsg","OSIoMesg","",0x18),
@ -4063,9 +4063,8 @@
0x801F6DFD:("sMotionBlurStatus","UNK_TYPE1","",0x1),
0x801F6E00:("D_801F6E00","SlowlyTask","",0x1c0),
0x801F6FC0:("D_801F6FC0","UNK_TYPE1","",0x1),
0x801F6FC8:("slowlyStackEntry","StackEntry","",0x1c),
0x801F6FE8:("slowlyStack","u8","[4096]",0x1000),
0x801F7FE8:("D_801F7FE8","UNK_TYPE1","",0x1),
0x801F6FC8:("sSlowlyStackInfo","StackEntry","",0x1c),
0x801F6FE8:("sSlowlyStack","u8","[4096]",0x1000),
0x801F7FF0:("D_801F7FF0","UNK_TYPE1","",0x1),
0x801F8010:("D_801F8010","struct_801F8010","",0x10),
0x801F8020:("D_801F8020","struct_801F8020","",0x10),
@ -4083,17 +4082,17 @@
0x801F84F8:("irqClient","IrqMgrClient","",0x8),
0x801F8500:("irqMgrMsgQ","OSMesgQueue","",0x18),
0x801F8518:("irqMgrMsgBuf","OSMesg","[60]",0xf0),
0x801F8608:("sGraphThread","OSThread","",0x1b0),
0x801F8608:("gGraphThread","OSThread","",0x1b0),
0x801F87B8:("sGraphStack","u8","[6144]",0x1800),
0x801F9FB8:("schedStack","u8","[1536]",0x600),
0x801FA5B8:("audioStack","u8","[2048]",0x800),
0x801FADB8:("padmgrStack","u8","[1280]",0x500),
0x801F9FB8:("sSchedStack","u8","[1536]",0x600),
0x801FA5B8:("sAudioStack","u8","[2048]",0x800),
0x801FADB8:("sPadMgrStack","u8","[1280]",0x500),
0x801FB2B8:("sGraphStackInfo","StackEntry","",0x1c),
0x801FB2D8:("schedStackEntry","StackEntry","",0x1c),
0x801FB2F8:("audioStackEntry","StackEntry","",0x1c),
0x801FB318:("padmgrStackEntry","StackEntry","",0x1c),
0x801FB338:("audioContext","AudioMgr","",0x2e0),
0x801FB620:("D_801FB620","PadMgr","",0x480),
0x801FB2D8:("sSchedStackInfo","StackEntry","",0x1c),
0x801FB2F8:("sAudioStackInfo","StackEntry","",0x1c),
0x801FB318:("sPadMgrStackInfo","StackEntry","",0x1c),
0x801FB338:("sAudioMgr","AudioMgr","",0x2e0),
0x801FB620:("gPadMgr","PadMgr","",0x480),
0x801FBAA0:("sSchedFaultClient","UNK_TYPE1","",0x1),
0x801FBAB0:("sRSPGFXStartTime","OSTime","",0x8),
0x801FBAB8:("sRSPAudioStartTime","OSTime","",0x8),
@ -4216,7 +4215,7 @@
0x801FBE28:("D_801FBE28","UNK_TYPE1","",0x1),
0x801FBE2C:("D_801FBE2C","UNK_TYPE1","",0x1),
0x801FBE30:("D_801FBE30","UNK_TYPE4","",0x4),
0x801FBE38:("sys_flashromStack","u8","[4096]",0x1000),
0x801FBE38:("sSysFlashromStack","u8","[4096]",0x1000),
0x801FCE38:("sys_flashromStackEntry","StackEntry","",0x1c),
0x801FCE58:("sys_flashromOSThread","OSThread","",0x1b0),
0x801FD008:("D_801FD008","s80185D40","",0x2c),
@ -6649,8 +6648,8 @@
0x808C3BC0:("D_808C3BC0","UNK_TYPE1","",0x1),
0x808C4CE0:("En_Wood02_InitVars","UNK_TYPE1","",0x1),
0x808C4D00:("D_808C4D00","UNK_TYPE1","",0x1),
0x808C4D2C:("D_808C4D2C","UNK_TYPE1","",0x1),
0x808C4D44:("D_808C4D44","UNK_TYPE1","",0x1),
0x808C4D2C:("sWood02SpawnDistance","f32","",0x1),
0x808C4D44:("sWood02SpawnAngle","UNK_TYPE1","",0x1),
0x808C4D4E:("D_808C4D4E","UNK_TYPE2","",0x2),
0x808C4D50:("D_808C4D50","UNK_TYPE1","",0x1),
0x808C4D54:("D_808C4D54","UNK_TYPE1","",0x1),
@ -6660,8 +6659,8 @@
0x808C4E10:("D_808C4E10","f32","",0x4),
0x808C4E14:("D_808C4E14","f32","",0x4),
0x808C4E18:("D_808C4E18","UNK_TYPE1","",0x1),
0x808C4F70:("D_808C4F70","f32","",0x4),
0x808C4F74:("D_808C4F74","UNK_TYPE1","",0x1),
0x808C4F70:("sWood02SpawnCos","f32","",0x4),
0x808C4F74:("sWood02SpawnSin","UNK_TYPE1","",0x4),
0x808C98C0:("En_Death_InitVars","UNK_TYPE1","",0x1),
0x808C98E0:("D_808C98E0","UNK_TYPE1","",0x1),
0x808C990C:("D_808C990C","UNK_TYPE1","",0x1),