Animation system updated, some more boot files decompiled (+6%), z_fcurve_data_skelanime decompiled (1 non-matching), some asm files split, etc (#89)

* Progress on various files

* gfxprint stuff

* split some rodata, add iconv for rodata string parsing

* z_std_dma rodata

* 2 nonmatchings in gfxprint

* mtxuty-cvt ok

* more

* match a function in idle.c

* progress

* Cleanup

* Rename BgPolygon to CollisionPoly

* progress

* some effect stuff

* more effect progress

* updates

* made suggested changes

* z_effect_soft_sprite_old_init mostly ok

* remove old effects enum

* gamealloc.c OK

* added more files

* motor.c almost done

* motor.c OK

* updates

* migration of two files

* listalloc.c oK

* z_fcurve_data_skelanime split

* z_fcurve_data_skelanime.c decompiled

* more files split

* z_malloc.c OK

* contpfs.c OK

* fault.c rodata migrated

* migrated fault_drawer rodata

* update

* update preprocess.py

* renamed functions in z_skelanime

* started z_skelanime cleanup

* like halfway through fixing z_skelanime

* animation system updated to meet oot standards

* remove unused animation structs

* rename matrix structs to fit oot

* Add -woff 712

* fix diff_settings.py because i accidentally broke it before

* fixed merge conflict, doesn't match though

* It matches now

* Updates

* Fixed warnings...added gcc code syntax checking

* Remove gcc check, added in Tharo's PR

* warnings fixed (i think)

* fixed all warnings i think

* ok

* not sure what to do

* Fix all warnings i think (z_en_a_keep needs some file cleanup thouguh)

* it matches if i do this

* remove comment

* accidentally put osPfsFreeBlocks in epilinkhandle.c

* memcmp -> bcmp

* change u32 size to size_t size, delete string.h because it caused unnecessary confusion with defining size_t twice

* format.sh

* MTXMODE_NEW and MTXMODE_APPLY to matrix functions

* Made suggested changes

* pragma sFaultDrawerFont instead of including in repo

* add some functions to functions.h

* Bss reordering fixed in z_collision_check...added hack to disasm.py

* Updated z_en_a_keep.c

* Missed suggestion in EnAObj_Destroy

* .

* update z_fcurve_Data_skelanime and z_skelanime with suggestions

* devmgr.c ok

* minor changes

* Addressed comments

* remove redundant file

* gfxp -> dlist in game.c

* updated actorfixer.py

* fixed warnings in z_malloc

* Change void* back to Actor*

* format

* Add the soft_sprit comments back

* Rename SV->Flex

* remove .common

* run format

* Update src/code/z_skelanime.c

* u32 channel

Co-authored-by: Lucas Shaw <lucas.shaw1123@gmail.com>
Co-authored-by: angie <angheloalf95@gmail.com>
Co-authored-by: Kenix3 <kenixwhisperwind@gmail.com>
This commit is contained in:
Lucas Shaw
2021-10-24 10:59:14 -04:00
committed by GitHub
parent 961913f18f
commit dcf44596d2
181 changed files with 4953 additions and 3658 deletions
+2 -2
View File
@@ -17,7 +17,7 @@ void PreRender_SetValuesSave(PreRender* this, u32 width, u32 height, void* fbuf,
void PreRender_Init(PreRender* this) {
bzero(this, sizeof(PreRender));
func_80174AA0(&this->alloc);
ListAlloc_Init(&this->alloc);
}
/**
@@ -35,7 +35,7 @@ void PreRender_SetValues(PreRender* this, u32 width, u32 height, void* fbuf, voi
}
void PreRender_Destroy(PreRender* this) {
func_80174BA0(&this->alloc);
ListAlloc_FreeAll(&this->alloc);
}
void func_8016FDB8(PreRender* this, Gfx** gfxp, void* buf, void* bufSave, u32 arg4) {
+5 -5
View File
@@ -12,7 +12,7 @@ void* THA_GetTail(TwoHeadArena* tha) {
return tha->tail;
}
void* THA_AllocStart(TwoHeadArena* tha, u32 size) {
void* THA_AllocStart(TwoHeadArena* tha, size_t size) {
void* start = tha->head;
tha->head = (u32)tha->head + size;
@@ -23,7 +23,7 @@ void* THA_AllocStart1(TwoHeadArena* tha) {
return THA_AllocStart(tha, 1);
}
void* THA_AllocEnd(TwoHeadArena* tha, u32 size) {
void* THA_AllocEnd(TwoHeadArena* tha, size_t size) {
u32 mask;
if (size >= 0x10) {
@@ -42,14 +42,14 @@ void* THA_AllocEnd(TwoHeadArena* tha, u32 size) {
return tha->tail;
}
void* THA_AllocEndAlign16(TwoHeadArena* tha, u32 size) {
void* THA_AllocEndAlign16(TwoHeadArena* tha, size_t size) {
u32 mask = ~0xF;
tha->tail = (((u32)tha->tail & mask) - size) & mask;
return tha->tail;
}
void* THA_AllocEndAlign(TwoHeadArena* tha, u32 size, u32 mask) {
void* THA_AllocEndAlign(TwoHeadArena* tha, size_t size, u32 mask) {
tha->tail = (((u32)tha->tail & mask) - size) & mask;
return tha->tail;
}
@@ -67,7 +67,7 @@ void THA_Init(TwoHeadArena* tha) {
tha->tail = (u32)tha->bufp + tha->size;
}
void THA_Ct(TwoHeadArena* tha, void* ptr, u32 size) {
void THA_Ct(TwoHeadArena* tha, void* ptr, size_t size) {
bzero(tha, sizeof(TwoHeadArena));
tha->bufp = ptr;
tha->size = size;
+2 -2
View File
@@ -1,6 +1,6 @@
#include "global.h"
void THGA_Ct(TwoHeadGfxArena* thga, Gfx* start, u32 size) {
void THGA_Ct(TwoHeadGfxArena* thga, Gfx* start, size_t size) {
THA_Ct((TwoHeadArena*)thga, start, size);
}
@@ -44,7 +44,7 @@ Gfx* THGA_AllocStart8Wrapper(TwoHeadGfxArena* thga) {
return THGA_AllocStart8(thga);
}
Gfx* THGA_AllocEnd(TwoHeadGfxArena* thga, u32 size) {
Gfx* THGA_AllocEnd(TwoHeadGfxArena* thga, size_t size) {
return THA_AllocEnd((TwoHeadArena*)thga, size);
}
-5
View File
@@ -1,5 +0,0 @@
#include "global.h"
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800F23E0/func_800F23E0.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800F23E0/func_800F2478.s")
-5
View File
@@ -1,5 +0,0 @@
#include "global.h"
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80122660/func_80122660.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80122660/func_80122670.s")
+91 -90
View File
@@ -22,7 +22,7 @@ void Game_SetFramerateDivisor(GameState* gameState, s32 divisor) {
}
void GameState_SetFBFilter(Gfx** gfx, u32 arg1) {
Gfx* _gfx = *gfx;
Gfx* dlist = *gfx;
if ((R_FB_FILTER_TYPE > 0) && (R_FB_FILTER_TYPE < 5)) {
D_801F8010.type = R_FB_FILTER_TYPE;
@@ -30,7 +30,7 @@ void GameState_SetFBFilter(Gfx** gfx, u32 arg1) {
D_801F8010.color.g = R_FB_FILTER_PRIM_COLOR(1);
D_801F8010.color.b = R_FB_FILTER_PRIM_COLOR(2);
D_801F8010.color.a = R_FB_FILTER_A;
func_80140D10(&D_801F8010, &_gfx, arg1);
func_80140D10(&D_801F8010, &dlist, arg1);
} else {
if ((R_FB_FILTER_TYPE == 5) || (R_FB_FILTER_TYPE == 6)) {
D_801F8020.useRgba = (R_FB_FILTER_TYPE == 6);
@@ -42,7 +42,7 @@ void GameState_SetFBFilter(Gfx** gfx, u32 arg1) {
D_801F8020.envColor.g = R_FB_FILTER_ENV_COLOR(1);
D_801F8020.envColor.b = R_FB_FILTER_ENV_COLOR(2);
D_801F8020.envColor.a = R_FB_FILTER_A;
func_80142100(&D_801F8020, &_gfx, arg1);
func_80142100(&D_801F8020, &dlist, arg1);
} else {
if (R_FB_FILTER_TYPE == 7) {
sMonoColors.unk_00 = 0;
@@ -54,27 +54,24 @@ void GameState_SetFBFilter(Gfx** gfx, u32 arg1) {
sMonoColors.envColor.g = R_FB_FILTER_ENV_COLOR(1);
sMonoColors.envColor.b = R_FB_FILTER_ENV_COLOR(2);
sMonoColors.envColor.a = R_FB_FILTER_A;
VisMono_Draw(&sMonoColors, &_gfx, arg1);
VisMono_Draw(&sMonoColors, &dlist, arg1);
}
}
}
*gfx = _gfx;
*gfx = dlist;
}
void Game_Nop80173534(GameState* gamestate) {
;
void Game_Nop80173534(GameState* gameState) {
}
void GameState_Draw(GameState* gamestate, GraphicsContext* gfxCtx) {
void GameState_Draw(GameState* gameState, GraphicsContext* gfxCtx) {
Gfx* nextDisplayList;
Gfx* polyOpa;
OPEN_DISPS(gfxCtx);
polyOpa = POLY_OPA_DISP;
nextDisplayList = Graph_GfxPlusOne(POLY_OPA_DISP);
nextDisplayList = Graph_GfxPlusOne(polyOpa = POLY_OPA_DISP);
gSPDisplayList(OVERLAY_DISP++, nextDisplayList);
if (R_FB_FILTER_TYPE && R_FB_FILTER_ENV_COLOR(3) == 0) {
@@ -98,119 +95,123 @@ void GameState_Draw(GameState* gamestate, GraphicsContext* gfxCtx) {
if (R_ENABLE_ARENA_DBG != 0) {
SpeedMeter_DrawTimeEntries(&D_801F7FF0, gfxCtx);
SpeedMeter_DrawAllocEntries(&D_801F7FF0, gfxCtx, gamestate);
SpeedMeter_DrawAllocEntries(&D_801F7FF0, gfxCtx, gameState);
}
CLOSE_DISPS(gfxCtx);
}
void Game_ResetSegments(GraphicsContext* gfxCtx) {
gSPSegment(gfxCtx->polyOpa.p++, 0, 0);
gSPSegment(gfxCtx->polyOpa.p++, 0xF, gfxCtx->framebuffer);
gSPSegment(gfxCtx->polyXlu.p++, 0, 0);
gSPSegment(gfxCtx->polyXlu.p++, 0xF, gfxCtx->framebuffer);
gSPSegment(gfxCtx->overlay.p++, 0, 0);
gSPSegment(gfxCtx->overlay.p++, 0xF, gfxCtx->framebuffer);
void GameState_SetFrameBuffer(GraphicsContext* gfxCtx) {
OPEN_DISPS(gfxCtx);
gSPSegment(POLY_OPA_DISP++, 0, NULL);
gSPSegment(POLY_OPA_DISP++, 0xF, gfxCtx->framebuffer);
gSPSegment(POLY_XLU_DISP++, 0, NULL);
gSPSegment(POLY_XLU_DISP++, 0xF, gfxCtx->framebuffer);
gSPSegment(OVERLAY_DISP++, 0, NULL);
gSPSegment(OVERLAY_DISP++, 0xF, gfxCtx->framebuffer);
CLOSE_DISPS(gfxCtx);
}
void func_801736DC(GraphicsContext* gfxCtx) {
Gfx* nextDisplayList;
Gfx* _polyOpa;
Gfx* polyOpa;
nextDisplayList = Graph_GfxPlusOne(_polyOpa = gfxCtx->polyOpa.p);
gSPDisplayList(gfxCtx->overlay.p++, nextDisplayList);
OPEN_DISPS(gfxCtx);
nextDisplayList = Graph_GfxPlusOne(polyOpa = gfxCtx->polyOpa.p);
gSPDisplayList(OVERLAY_DISP++, nextDisplayList);
gSPEndDisplayList(nextDisplayList++);
Graph_BranchDlist(_polyOpa, nextDisplayList);
Graph_BranchDlist(polyOpa, nextDisplayList);
gfxCtx->polyOpa.p = nextDisplayList;
POLY_OPA_DISP = nextDisplayList;
CLOSE_DISPS(gfxCtx);
}
void Game_UpdateInput(GameState* gamestate) {
Padmgr_GetInput(gamestate->input, 1);
void Game_UpdateInput(GameState* gameState) {
Padmgr_GetInput(gameState->input, 1);
}
void Game_Update(GameState* gamestate) {
GraphicsContext* _gCtx;
_gCtx = gamestate->gfxCtx;
void Game_Update(GameState* gameState) {
GraphicsContext* gfxCtx = gameState->gfxCtx;
Game_ResetSegments(gamestate->gfxCtx);
GameState_SetFrameBuffer(gameState->gfxCtx);
gamestate->main(gamestate);
gameState->main(gameState);
if (R_PAUSE_MENU_MODE != 2) {
GameState_Draw(gamestate, _gCtx);
func_801736DC(_gCtx);
GameState_Draw(gameState, gfxCtx);
func_801736DC(gfxCtx);
}
}
void Game_IncrementFrameCount(GameState* gamestate) {
Game_Nop80173534(gamestate);
gamestate->frames++;
void Game_IncrementFrameCount(GameState* gameState) {
Game_Nop80173534(gameState);
gameState->frames++;
}
void Game_InitHeap(GameState* gamestate, u32 size) {
GameState* _ctx;
void* buf;
_ctx = gamestate;
buf = Gamealloc_Alloc(&_ctx->alloc, size);
void GameState_InitArena(GameState* gameState, size_t size) {
GameAlloc* alloc = &gameState->alloc;
void* buf = GameAlloc_Malloc(alloc, size);
if (buf) {
THA_Ct(&gamestate->heap, buf, size);
THA_Ct(&gameState->heap, buf, size);
return;
}
THA_Ct(&gamestate->heap, NULL, 0);
__assert("../game.c", 0x40B);
THA_Ct(&gameState->heap, NULL, 0);
__assert("../game.c", 1035);
}
void Game_ResizeHeap(GameState* gamestate, u32 size) {
void GameState_Realloc(GameState* gameState, size_t size) {
GameAlloc* alloc;
void* buf;
u32 systemMaxFree;
u32 bytesFree;
u32 bytesAllocated;
void* gameArena;
size_t systemMaxFree;
size_t bytesFree;
size_t bytesAllocated;
void* heapStart;
heapStart = gamestate->heap.bufp;
alloc = &gamestate->alloc;
THA_Dt(&gamestate->heap);
Gamealloc_Free(alloc, heapStart);
heapStart = gameState->heap.bufp;
alloc = &gameState->alloc;
THA_Dt(&gameState->heap);
GameAlloc_Free(alloc, heapStart);
SystemArena_AnalyzeArena(&systemMaxFree, &bytesFree, &bytesAllocated);
size = ((systemMaxFree - (sizeof(ArenaNode))) < size) ? (0) : (size);
if (!size) {
if (size == 0) {
size = systemMaxFree - (sizeof(ArenaNode));
}
if ((buf = Gamealloc_Alloc(alloc, size)) != NULL) {
THA_Ct(&gamestate->heap, buf, size);
if ((gameArena = GameAlloc_Malloc(alloc, size)) != NULL) {
THA_Ct(&gameState->heap, gameArena, size);
} else {
THA_Ct(&gamestate->heap, 0, 0);
__assert("../game.c", 0x432);
THA_Ct(&gameState->heap, 0, 0);
__assert("../game.c", 1074);
}
}
void Game_StateInit(GameState* gamestate, GameStateFunc gameStateInit, GraphicsContext* gfxCtx) {
gamestate->gfxCtx = gfxCtx;
gamestate->frames = 0U;
gamestate->main = NULL;
gamestate->destroy = NULL;
gamestate->running = 1;
gfxCtx->unk274 = D_801FBB88;
void GameState_Init(GameState* gameState, GameStateFunc init, GraphicsContext* gfxCtx) {
gameState->gfxCtx = gfxCtx;
gameState->frames = 0U;
gameState->main = NULL;
gameState->destroy = NULL;
gameState->running = 1;
gfxCtx->viMode = D_801FBB88;
gfxCtx->viConfigFeatures = gViConfigFeatures;
gfxCtx->viConfigXScale = gViConfigXScale;
gfxCtx->viConfigYScale = gViConfigYScale;
gamestate->nextGameStateInit = NULL;
gamestate->nextGameStateSize = 0U;
gameState->nextGameStateInit = NULL;
gameState->nextGameStateSize = 0U;
{
s32 requiredScopeTemp;
Gamealloc_Init(&gamestate->alloc);
Game_InitHeap(gamestate, 0x100000);
Game_SetFramerateDivisor(gamestate, 3);
GameAlloc_Init(&gameState->alloc);
GameState_InitArena(gameState, 0x100000);
Game_SetFramerateDivisor(gameState, 3);
gameStateInit(gamestate);
init(gameState);
func_80140CE0(&D_801F8010);
func_801420C0(&D_801F8020);
@@ -219,17 +220,17 @@ void Game_StateInit(GameState* gamestate, GameStateFunc gameStateInit, GraphicsC
func_801773A0(&D_801F7FF0);
func_8013ED9C();
osSendMesg(&gamestate->gfxCtx->unk5C, NULL, 1);
osSendMesg(&gameState->gfxCtx->unk5C, NULL, 1);
}
}
void Game_StateFini(GameState* gamestate) {
void GameState_Destroy(GameState* gameState) {
func_80172BC0();
func_8019E014();
osRecvMesg(&gamestate->gfxCtx->unk5C, 0, 1);
osRecvMesg(&gameState->gfxCtx->unk5C, NULL, OS_MESG_BLOCK);
if (gamestate->destroy != 0) {
gamestate->destroy(gamestate);
if (gameState->destroy != NULL) {
gameState->destroy(gameState);
}
func_8013EDD0();
@@ -238,28 +239,28 @@ void Game_StateFini(GameState* gamestate) {
func_801420F4(&D_801F8020);
func_80141900(&sMonoColors);
func_80140900(&D_801F8048);
THA_Dt(&gamestate->heap);
Gamealloc_FreeAll(&gamestate->alloc);
THA_Dt(&gameState->heap);
GameAlloc_Cleanup(&gameState->alloc);
}
GameStateFunc Game_GetNextStateInit(GameState* gamestate) {
return gamestate->nextGameStateInit;
GameStateFunc GameState_GetNextStateInit(GameState* gameState) {
return gameState->nextGameStateInit;
}
u32 Game_GetNextStateSize(GameState* gamestate) {
return gamestate->nextGameStateSize;
size_t Game_GetNextStateSize(GameState* gameState) {
return gameState->nextGameStateSize;
}
u32 Game_GetShouldContinue(GameState* gamestate) {
return gamestate->running;
u32 GameState_IsRunning(GameState* gameState) {
return gameState->running;
}
s32 Game_GetHeapFreeSize(GameState* gamestate) {
return THA_GetSize(&gamestate->heap);
s32 GameState_GetArenaSize(GameState* gameState) {
return THA_GetSize(&gameState->heap);
}
s32 func_80173B48(GameState* gamestate) {
s32 result;
result = OS_CYCLES_TO_NSEC(gamestate->framerateDivisor * sIrqMgrRetraceTime) - OS_CYCLES_TO_NSEC(D_801FBAF0);
s32 func_80173B48(GameState* gameState) {
s32 result = OS_CYCLES_TO_NSEC(gameState->framerateDivisor * sIrqMgrRetraceTime) - OS_CYCLES_TO_NSEC(D_801FBAF0);
return result;
}
+53 -5
View File
@@ -1,11 +1,59 @@
#include "global.h"
#pragma GLOBAL_ASM("asm/non_matchings/code/gamealloc/func_80173BF0.s")
void GameAlloc_Log(GameAlloc* this) {
GameAllocEntry* iter;
#pragma GLOBAL_ASM("asm/non_matchings/code/gamealloc/Gamealloc_Alloc.s")
iter = this->base.next;
while (iter != &this->base) {
iter = iter->next;
}
}
#pragma GLOBAL_ASM("asm/non_matchings/code/gamealloc/Gamealloc_Free.s")
void* GameAlloc_Malloc(GameAlloc* this, size_t size) {
GameAllocEntry* ptr = SystemArena_Malloc(size + sizeof(GameAllocEntry));
#pragma GLOBAL_ASM("asm/non_matchings/code/gamealloc/Gamealloc_FreeAll.s")
if (ptr != NULL) {
ptr->size = size;
ptr->prev = this->head;
this->head->next = ptr;
this->head = ptr;
ptr->next = &this->base;
this->base.prev = this->head;
return ptr + 1;
} else {
return NULL;
}
}
#pragma GLOBAL_ASM("asm/non_matchings/code/gamealloc/Gamealloc_Init.s")
void GameAlloc_Free(GameAlloc* this, void* data) {
GameAllocEntry* ptr;
if (data != NULL) {
ptr = &((GameAllocEntry*)data)[-1];
ptr->prev->next = ptr->next;
ptr->next->prev = ptr->prev;
this->head = this->base.prev;
SystemArena_Free(ptr);
}
}
void GameAlloc_Cleanup(GameAlloc* this) {
GameAllocEntry* next = this->base.next;
GameAllocEntry* cur;
while (&this->base != next) {
cur = next;
next = next->next;
SystemArena_Free(cur);
}
this->head = &this->base;
this->base.next = &this->base;
this->base.prev = &this->base;
}
void GameAlloc_Init(GameAlloc* this) {
this->head = &this->base;
this->base.next = &this->base;
this->base.prev = &this->base;
}
+57 -4
View File
@@ -1,9 +1,62 @@
#include "global.h"
#pragma GLOBAL_ASM("asm/non_matchings/code/listalloc/func_80174AA0.s")
ListAlloc* ListAlloc_Init(ListAlloc* this) {
this->prev = NULL;
this->next = NULL;
return this;
}
#pragma GLOBAL_ASM("asm/non_matchings/code/listalloc/func_80174AB4.s")
void* ListAlloc_Alloc(ListAlloc* this, size_t size) {
ListAlloc* ptr = SystemArena_Malloc(size + sizeof(ListAlloc));
ListAlloc* next;
#pragma GLOBAL_ASM("asm/non_matchings/code/listalloc/func_80174B20.s")
if (ptr == NULL) {
return NULL;
}
#pragma GLOBAL_ASM("asm/non_matchings/code/listalloc/func_80174BA0.s")
next = this->next;
if (next != NULL) {
next->next = ptr;
}
ptr->prev = next;
ptr->next = NULL;
this->next = ptr;
if (this->prev == NULL) {
this->prev = ptr;
}
return (u8*)ptr + sizeof(ListAlloc);
}
void ListAlloc_Free(ListAlloc* this, void* data) {
ListAlloc* ptr = &((ListAlloc*)data)[-1];
if (ptr->prev != NULL) {
ptr->prev->next = ptr->next;
}
if (ptr->next != NULL) {
ptr->next->prev = ptr->prev;
}
if (this->prev == ptr) {
this->prev = ptr->next;
}
if (this->next == ptr) {
this->next = ptr->prev;
}
SystemArena_Free(ptr);
}
void ListAlloc_FreeAll(ListAlloc* this) {
ListAlloc* iter = this->prev;
while (iter != NULL) {
ListAlloc_Free(this, (u8*)iter + sizeof(ListAlloc));
iter = this->prev;
}
}
+11 -11
View File
@@ -28,36 +28,36 @@ void Main(void* arg) {
R_ENABLE_ARENA_DBG = 0;
osCreateMesgQueue(&siEventCallbackQueue, siEventCallbackBuffer, ARRAY_COUNT(siEventCallbackBuffer));
osSetEventMesg(OS_EVENT_SI, &siEventCallbackQueue, NULL);
osCreateMesgQueue(&sSiIntMsgQ, sSiIntMsgBuf, ARRAY_COUNT(sSiIntMsgBuf));
osSetEventMesg(OS_EVENT_SI, &sSiIntMsgQ, NULL);
osCreateMesgQueue(&mainIrqmgrCallbackQueue, mainIrqCallbackBuffer, ARRAY_COUNT(mainIrqCallbackBuffer));
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);
CIC6105_AddRomInfoFaultPage();
IrqMgr_AddClient(&gIrqMgr, &mainIrqmgrCallbackNode, &mainIrqmgrCallbackQueue);
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(&padmgrStackEntry, padmgrStack, padmgrStack + sizeof(padmgrStack), 0, 0x100, "padmgr");
Padmgr_Start(&siEventCallbackQueue, &gIrqMgr, 7, Z_PRIORITY_PADMGR, padmgrStack + sizeof(padmgrStack));
PadMgr_Init(&sSiIntMsgQ, &gIrqMgr, 7, Z_PRIORITY_PADMGR, padmgrStack + sizeof(padmgrStack));
AudioMgr_Unlock(&audioContext);
StackCheck_Init(&graphStackEntry, graphStack, graphStack + sizeof(graphStack), 0, 0x100, "graph");
osCreateThread(&graphOSThread, Z_THREAD_ID_GRAPH, Graph_ThreadEntry, arg, graphStack + sizeof(graphStack),
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(&graphOSThread);
osStartThread(&sGraphThread);
exit = false;
while (!exit) {
msg = NULL;
osRecvMesg(&mainIrqmgrCallbackQueue, (OSMesg)&msg, OS_MESG_BLOCK);
osRecvMesg(&irqMgrMsgQ, (OSMesg)&msg, OS_MESG_BLOCK);
if (msg == NULL) {
break;
}
@@ -72,6 +72,6 @@ void Main(void* arg) {
}
}
IrqMgr_RemoveClient(&gIrqMgr, &mainIrqmgrCallbackNode);
osDestroyThread(&graphOSThread);
IrqMgr_RemoveClient(&gIrqMgr, &irqClient);
osDestroyThread(&sGraphThread);
}
+1 -1
View File
@@ -54,4 +54,4 @@
#pragma GLOBAL_ASM("asm/non_matchings/code/padmgr/Padmgr_ThreadEntry.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/padmgr/Padmgr_Start.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/padmgr/PadMgr_Init.s")
+34 -34
View File
@@ -1,92 +1,92 @@
#include "global.h"
void SysMatrix_StateAlloc(GameState* gamestate) {
sMatrixStack = (MtxF*)THA_AllocEndAlign16(&gamestate->heap, 0x500);
void Matrix_StateAlloc(GameState* gameState) {
sMatrixStack = (MtxF*)THA_AllocEndAlign16(&gameState->heap, 0x500);
sCurrentMatrix = sMatrixStack;
}
void SysMatrix_StatePush(void) {
void Matrix_StatePush(void) {
MtxF* prev = sCurrentMatrix;
sCurrentMatrix++;
Matrix_MtxFCopy(sCurrentMatrix, prev);
}
void SysMatrix_StatePop(void) {
void Matrix_StatePop(void) {
sCurrentMatrix--;
}
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/SysMatrix_CopyCurrentState.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_CopyCurrentState.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/SysMatrix_SetCurrentState.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_SetCurrentState.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/SysMatrix_GetCurrentState.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_GetCurrentState.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/SysMatrix_InsertMatrix.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_InsertMatrix.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/SysMatrix_InsertTranslation.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_InsertTranslation.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_Scale.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/SysMatrix_InsertXRotation_s.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_InsertXRotation_s.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/SysMatrix_InsertXRotation_f.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_InsertXRotation_f.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/SysMatrix_RotateStateAroundXAxis.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_RotateStateAroundXAxis.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/SysMatrix_SetStateXRotation.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_SetStateXRotation.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_RotateY.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/SysMatrix_InsertYRotation_f.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_InsertYRotation_f.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/SysMatrix_InsertZRotation_s.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_InsertZRotation_s.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/SysMatrix_InsertZRotation_f.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_InsertZRotation_f.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/SysMatrix_InsertRotation.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_InsertRotation.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/SysMatrix_RotateAndTranslateState.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_JointPosition.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/SysMatrix_SetStateRotationAndTranslation.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_SetStateRotationAndTranslation.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/SysMatrix_ToRSPMatrix.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_ToRSPMatrix.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/SysMatrix_GetStateAsRSPMatrix.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_ToMtx.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_NewMtx.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/SysMatrix_AppendToPolyOpaDisp.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_AppendToPolyOpaDisp.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/SysMatrix_MultiplyVector3fByState.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_MultiplyVector3fByState.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/SysMatrix_GetStateTranslation.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_GetStateTranslation.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/SysMatrix_GetStateTranslationAndScaledX.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_GetStateTranslationAndScaledX.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/SysMatrix_GetStateTranslationAndScaledY.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_GetStateTranslationAndScaledY.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/SysMatrix_GetStateTranslationAndScaledZ.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_GetStateTranslationAndScaledZ.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/SysMatrix_MultiplyVector3fXZByCurrentState.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_MultiplyVector3fXZByCurrentState.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_MtxFCopy.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/SysMatrix_FromRSPMatrix.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_FromRSPMatrix.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/SysMatrix_MultiplyVector3fByMatrix.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_MultiplyVector3fByMatrix.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/SysMatrix_TransposeXYZ.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_TransposeXYZ.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/SysMatrix_NormalizeXYZ.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_NormalizeXYZ.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/func_8018219C.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/func_801822C4.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/SysMatrix_InsertRotationAroundUnitVector_f.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_InsertRotationAroundUnitVector_f.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/SysMatrix_InsertRotationAroundUnitVector_s.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/Matrix_InsertRotationAroundUnitVector_s.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/sys_matrix/func_80182C90.s")
+2 -2
View File
@@ -1,5 +1,5 @@
#include "global.h"
#pragma GLOBAL_ASM("asm/non_matchings/code/z_DLF/DLF_LoadGameState.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/z_DLF/Overlay_LoadGameState.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/z_DLF/DLF_FreeGameState.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/z_DLF/Overlay_FreeGameState.s")
+3 -3
View File
@@ -53,7 +53,7 @@ void ActorShadow_Draw(Actor* actor, Lights* lights, GlobalContext* globalCtx, Gf
}
func_800C0094(actor->floorPoly, actor->world.pos.x, actor->floorHeight, actor->world.pos.z, &mtx);
SysMatrix_SetCurrentState(&mtx);
Matrix_SetCurrentState(&mtx);
if (dlist != D_04076BC0) {
Matrix_RotateY((f32)actor->shape.rot.y * (M_PI / 32768), MTXMODE_APPLY);
@@ -117,7 +117,7 @@ void func_800B40E0(GlobalContext* globalCtx, Light* light, MtxF* arg2, s32 arg3,
sp58 = Math_FAtan2F(light->l.dir[0], light->l.dir[2]);
arg6 *= (4.5f - (light->l.dir[1] * 0.035f));
arg6 = (arg6 < 1.0f) ? 1.0f : arg6;
SysMatrix_SetCurrentState(arg2);
Matrix_SetCurrentState(arg2);
Matrix_RotateY(sp58, MTXMODE_APPLY);
Matrix_Scale(arg5, 1.0f, arg5 * arg6, MTXMODE_APPLY);
@@ -744,7 +744,7 @@ void Actor_FreeOverlay(ActorOverlay* entry) {
if ((entry->allocType & 1) != 0) {
entry->loadedRamAddr = NULL;
} else {
zelda_free(ramAddr);
ZeldaArena_Free(ramAddr);
entry->loadedRamAddr = NULL;
}
}
+1 -1
View File
@@ -736,7 +736,7 @@ void* ActorOverlayTable_FaultAddrConv(void* arg0, void* arg1) {
s32 i;
u8* ramStart;
u8* ramEnd;
u32 size;
size_t size;
u32 offset;
for (i = 0; i < gMaxActorId; i++, overlayEntry++) {
+7 -7
View File
@@ -327,7 +327,7 @@ s32 Collider_FreeJntSph(GlobalContext* globalCtx, ColliderJntSph* collider) {
collider->count = 0;
if (collider->elements != NULL) {
zelda_free(collider->elements);
ZeldaArena_Free(collider->elements);
}
collider->elements = NULL;
return 1;
@@ -359,7 +359,7 @@ s32 Collider_SetJntSphToActor(GlobalContext* globalCtx, ColliderJntSph* collider
Collider_SetBaseToActor(globalCtx, &collider->base, &src->base);
collider->count = src->count;
collider->elements = zelda_malloc(src->count * sizeof(ColliderJntSphElement));
collider->elements = ZeldaArena_Malloc(src->count * sizeof(ColliderJntSphElement));
if (collider->elements == NULL) {
collider->count = 0;
@@ -385,7 +385,7 @@ s32 Collider_SetJntSphAllocType1(GlobalContext* globalCtx, ColliderJntSph* spher
Collider_SetBaseType1(globalCtx, &sphereGroup->base, actor, &src->base);
sphereGroup->count = src->count;
sphereGroup->elements = zelda_malloc(src->count * sizeof(ColliderJntSphElement));
sphereGroup->elements = ZeldaArena_Malloc(src->count * sizeof(ColliderJntSphElement));
if (sphereGroup->elements == NULL) {
sphereGroup->count = 0;
@@ -681,7 +681,7 @@ s32 Collider_FreeTris(GlobalContext* globalCtx, ColliderTris* tris) {
tris->count = 0;
if (tris->elements != NULL) {
zelda_free(tris->elements);
ZeldaArena_Free(tris->elements);
}
tris->elements = NULL;
@@ -714,7 +714,7 @@ s32 Collider_SetTrisAllocType1(GlobalContext* globalCtx, ColliderTris* tris, Act
Collider_SetBaseType1(globalCtx, &tris->base, actor, &src->base);
tris->count = src->count;
tris->elements = zelda_malloc(tris->count * sizeof(ColliderTrisElement));
tris->elements = ZeldaArena_Malloc(tris->count * sizeof(ColliderTrisElement));
if (tris->elements == NULL) {
tris->count = 0;
@@ -3691,7 +3691,7 @@ void Collider_UpdateSpheres(s32 limb, ColliderJntSph* collider) {
D_801EE1C0.x = collider->elements[i].dim.modelSphere.center.x;
D_801EE1C0.y = collider->elements[i].dim.modelSphere.center.y;
D_801EE1C0.z = collider->elements[i].dim.modelSphere.center.z;
SysMatrix_MultiplyVector3fByState(&D_801EE1C0, &D_801EE1D0);
Matrix_MultiplyVector3fByState(&D_801EE1C0, &D_801EE1D0);
collider->elements[i].dim.worldSphere.center.x = D_801EE1D0.x;
collider->elements[i].dim.worldSphere.center.y = D_801EE1D0.y;
collider->elements[i].dim.worldSphere.center.z = D_801EE1D0.z;
@@ -3733,7 +3733,7 @@ void Collider_UpdateSphere(s32 limb, ColliderSphere* collider) {
D_801EE1E0.x = collider->dim.modelSphere.center.x;
D_801EE1E0.y = collider->dim.modelSphere.center.y;
D_801EE1E0.z = collider->dim.modelSphere.center.z;
SysMatrix_MultiplyVector3fByState(&D_801EE1E0, &D_801EE1F0);
Matrix_MultiplyVector3fByState(&D_801EE1E0, &D_801EE1F0);
collider->dim.worldSphere.center.x = D_801EE1F0.x;
collider->dim.worldSphere.center.y = D_801EE1F0.y;
collider->dim.worldSphere.center.z = D_801EE1F0.z;
+2 -2
View File
@@ -106,8 +106,8 @@ void EffFootmark_Draw(GlobalContext* globalCtx) {
for (footmark = globalCtx->footprintInfo, i = 0; i < 100; i++, footmark++) {
if (footmark->actor != NULL) {
SysMatrix_SetCurrentState(&footmark->displayMatrix);
Matrix_Scale(footmark->size * 0.00390625f * 0.7f, 1, footmark->size * 0.00390625f, 1);
Matrix_SetCurrentState(&footmark->displayMatrix);
Matrix_Scale(footmark->size * (1.0f / 0x100) * 0.7f, 1, footmark->size * (1.0f / 0x100), MTXMODE_APPLY);
gSPMatrix(gfxCtx->polyXlu.p++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_NOPUSH | G_MTX_LOAD);
+2 -2
View File
@@ -41,7 +41,7 @@ void EffectSS_Clear(GlobalContext* globalCtx) {
for (i = 0; i < EFFECT_SS_MAX; i++) {
addr = overlay->loadedRamAddr;
if (addr != NULL) {
zelda_free(addr);
ZeldaArena_Free(addr);
}
overlay->loadedRamAddr = 0;
@@ -175,7 +175,7 @@ void EffectSs_Spawn(GlobalContext* globalCtx, s32 type, s32 priority, void* init
initInfo = entry->initInfo;
} else {
if (entry->loadedRamAddr == NULL) {
entry->loadedRamAddr = zelda_mallocR(overlaySize);
entry->loadedRamAddr = ZeldaArena_MallocR(overlaySize);
if (entry->loadedRamAddr == NULL) {
return;
+5 -4
View File
@@ -403,7 +403,7 @@ void EffectSsGSpk_SpawnSmall(GlobalContext* globalCtx, Actor* actor, Vec3f* pos,
// EffectSsDFire Spawn Functions
void EffectSsDFire_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, s16 scale, s16 scaleStep,
s16 alpha, s16 fadeDelay, s16 life, s32 arg9) {
s16 alpha, s16 fadeDelay, s16 arg8, s32 life) {
EffectSsDFireInitParams initParams;
Math_Vec3f_Copy(&initParams.pos, pos);
@@ -413,8 +413,8 @@ void EffectSsDFire_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity,
initParams.scaleStep = scaleStep;
initParams.alpha = alpha;
initParams.fadeDelay = fadeDelay;
initParams.unk_2C = arg8;
initParams.life = life;
initParams.unk_30 = arg9;
EffectSs_Spawn(globalCtx, EFFECT_SS_D_FIRE, 128, &initParams);
}
@@ -535,8 +535,8 @@ void EffectSsDtBubble_SpawnCustomColor(GlobalContext* globalCtx, Vec3f* pos, Vec
/**
* Spawn a single fragment
*
* Notes:
* - if a display list is not provided, D_0400C0D0 (wilted deku fragment) will be used as default
* * Notes:
* - if a display list is not provided, an unknown default will be used as default
* - the unused arg does not do anything, any value can be passed here
* - due to how life is implemented it is capped at 200. Any value over 200 is accepted, but the fragment will
* only live for 200 frames
@@ -960,6 +960,7 @@ void EffectSsExtra_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity,
}
// EffectSsDeadDb Spawn Functions
void EffectSsDeadDb_Spawn(GlobalContext* globalCtx, Vec3f* pos, Vec3f* velocity, Vec3f* accel, Color_RGBA8* prim,
Color_RGBA8* env, s16 scale, s16 scaleStep, s32 unk) {
EffectSsDeadDbInitParams initParams;
+40 -31
View File
@@ -1,48 +1,57 @@
#include "global.h"
void EnAObj_Init(ActorEnAObj* this, GlobalContext* globalCtx) {
ActorEnAObj* s0 = (ActorEnAObj*)this;
s0->base.textId = ((s0->base.params >> 8) & 0xFF) | 0x300;
s0->base.params = (s0->base.params & 0xFF) - 9;
Actor_ProcessInitChain((Actor*)s0, &enAObjInitVar);
ActorShape_Init(&s0->base.shape, 0, (ActorShadowFunc)func_800B3FC0, 12);
Collider_InitAndSetCylinder(globalCtx, &s0->collision, (Actor*)s0, &enAObjCylinderInit);
Collider_UpdateCylinder((Actor*)s0, &s0->collision);
s0->base.colChkInfo.mass = 255;
s0->update = (ActorFunc)EnAObj_Update1;
#define THIS ((EnAObj*)thisx)
void EnAObj_Update1(EnAObj* this, GlobalContext* globalCtx);
void EnAObj_Update2(EnAObj* this, GlobalContext* globalCtx);
void EnAObj_Init(Actor* thisx, GlobalContext* globalCtx) {
EnAObj* this = THIS;
this->actor.textId = ((this->actor.params >> 8) & 0xFF) | 0x300;
this->actor.params = (this->actor.params & 0xFF) - 9;
Actor_ProcessInitChain(&this->actor, &enAObjInitVar);
ActorShape_Init(&this->actor.shape, 0, func_800B3FC0, 12);
Collider_InitAndSetCylinder(globalCtx, &this->collision, &this->actor, &enAObjCylinderInit);
Collider_UpdateCylinder(&this->actor, &this->collision);
this->actor.colChkInfo.mass = 255;
this->actionFunc = EnAObj_Update1;
}
void EnAObj_Destroy(ActorEnAObj* this, GlobalContext* globalCtx) {
ColliderCylinder* a2 = &this->collision;
Collider_DestroyCylinder(globalCtx, a2);
void EnAObj_Destroy(Actor* thisx, GlobalContext* globalCtx) {
EnAObj* this = THIS;
Collider_DestroyCylinder(globalCtx, &this->collision);
}
void EnAObj_Update1(ActorEnAObj* this, GlobalContext* globalCtx) {
s16 v0;
s32 v1;
if (func_800B84D0((Actor*)this, globalCtx) != 0) {
this->update = (ActorFunc)EnAObj_Update2;
void EnAObj_Update1(EnAObj* this, GlobalContext* globalCtx) {
s32 yawDiff;
if (func_800B84D0(&this->actor, globalCtx)) {
this->actionFunc = EnAObj_Update2;
} else {
v0 = this->base.yawTowardsPlayer - this->base.shape.rot.y;
v1 = (v0 < 0) ? -v0 : v0;
if ((v1 < 10240) || ((this->base.params == 1) && (v1 > 22528))) {
func_800B863C((Actor*)this, globalCtx);
yawDiff = ABS_ALT((s16)(this->actor.yawTowardsPlayer - this->actor.shape.rot.y));
if ((yawDiff < 0x2800) || ((this->actor.params == 1) && (yawDiff > 0x5800))) {
func_800B863C(&this->actor, globalCtx);
}
}
}
void EnAObj_Update2(ActorEnAObj* this, GlobalContext* globalCtx) {
if (func_800B867C((Actor*)this, globalCtx) != 0) {
this->update = (ActorFunc)EnAObj_Update1;
void EnAObj_Update2(EnAObj* this, GlobalContext* globalCtx) {
if (func_800B867C(&this->actor, globalCtx)) {
this->actionFunc = EnAObj_Update1;
}
}
void EnAObj_Update(ActorEnAObj* this, GlobalContext* globalCtx) {
(this->update)((Actor*)this, (GlobalContext*)globalCtx);
Actor_SetHeight((Actor*)this, 45.0f);
CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, (Collider*)&this->collision);
void EnAObj_Update(Actor* thisx, GlobalContext* globalCtx) {
EnAObj* this = THIS;
this->actionFunc(this, globalCtx);
Actor_SetHeight(&this->actor, 45.0f);
CollisionCheck_SetOC(globalCtx, &globalCtx->colChkCtx, &this->collision.base);
}
void EnAObj_Draw(ActorEnAObj* this, GlobalContext* globalCtx) {
func_800BDFC0(globalCtx, enAObjDisplayLists[this->base.params]);
void EnAObj_Draw(Actor* thisx, GlobalContext* globalCtx) {
func_800BDFC0(globalCtx, enAObjDisplayLists[thisx->params]);
}
+2 -2
View File
@@ -660,7 +660,7 @@ void EnItem00_Draw(Actor* thisx, GlobalContext* globalCtx) {
this->unk152 = -2;
}
} else {
Matrix_Scale(16.0f, 16.0f, 16.0f, 1);
Matrix_Scale(16.0f, 16.0f, 16.0f, MTXMODE_APPLY);
GetItem_Draw(globalCtx, 8);
}
break;
@@ -785,7 +785,7 @@ void EnItem00_DrawHeartContainer(EnItem00* actor, GlobalContext* globalCtx) {
OPEN_DISPS(globalCtx->state.gfxCtx);
func_8012C2DC(globalCtx->state.gfxCtx);
Matrix_Scale(20.0f, 20.0f, 20.0f, 1);
Matrix_Scale(20.0f, 20.0f, 20.0f, MTXMODE_APPLY);
gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx), G_MTX_MODELVIEW | G_MTX_LOAD);
+5
View File
@@ -0,0 +1,5 @@
#include "global.h"
#pragma GLOBAL_ASM("asm/non_matchings/code/z_fcurve_data/func_800F23E0.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/z_fcurve_data/func_800F2478.s")
+173 -7
View File
@@ -1,15 +1,181 @@
#include "global.h"
#pragma GLOBAL_ASM("asm/non_matchings/code/z_fcurve_data_skelanime/func_800F2620.s")
void SkelCurve_Clear(SkelAnimeCurve* skelCurve) {
skelCurve->limbCount = 0;
skelCurve->limbList = NULL;
skelCurve->transUpdIdx = NULL;
skelCurve->animCurFrame = 0.0f;
skelCurve->animSpeed = 0.0f;
skelCurve->animFinalFrame = 0.0f;
skelCurve->unk0C = 0.0f;
skelCurve->transforms = NULL;
}
#pragma GLOBAL_ASM("asm/non_matchings/code/z_fcurve_data_skelanime/func_800F2650.s")
s32 SkelCurve_Init(GlobalContext* globalCtx, SkelAnimeCurve* skelCurve, SkelCurveLimbList* limbListSeg,
TransformUpdateIndex* transUpdIdx) {
SkelCurveLimb** limbs;
SkelCurveLimbList* limbList = (SkelCurveLimbList*)Lib_SegmentedToVirtual(limbListSeg);
#pragma GLOBAL_ASM("asm/non_matchings/code/z_fcurve_data_skelanime/func_800F26C0.s")
skelCurve->limbCount = limbList->limbCount;
skelCurve->limbList = (SkelCurveLimb**)Lib_SegmentedToVirtual(limbList->limbs);
#pragma GLOBAL_ASM("asm/non_matchings/code/z_fcurve_data_skelanime/func_800F26F0.s")
skelCurve->transforms = ZeldaArena_Malloc(sizeof(*skelCurve->transforms) * skelCurve->limbCount);
#pragma GLOBAL_ASM("asm/non_matchings/code/z_fcurve_data_skelanime/func_800F2728.s")
do {
skelCurve->animCurFrame = 0.0f;
} while (0);
return 1;
}
#pragma GLOBAL_ASM("asm/non_matchings/code/z_fcurve_data_skelanime/func_800F29A0.s")
void SkelCurve_Destroy(GlobalContext* globalCtx, SkelAnimeCurve* skelCurve) {
if (skelCurve->transforms != NULL) {
ZeldaArena_Free(skelCurve->transforms);
}
}
#pragma GLOBAL_ASM("asm/non_matchings/code/z_fcurve_data_skelanime/func_800F2CD8.s")
void SkelCurve_SetAnim(SkelAnimeCurve* skelCurve, TransformUpdateIndex* transUpdIdx, f32 arg2, f32 animFinalFrame,
f32 animCurFrame, f32 animSpeed) {
skelCurve->unk0C = arg2 - skelCurve->animSpeed;
skelCurve->animFinalFrame = animFinalFrame;
skelCurve->animCurFrame = animCurFrame;
skelCurve->animSpeed = animSpeed;
skelCurve->transUpdIdx = transUpdIdx;
}
#ifdef NON_MATCHING
/* Should be functionally equivalent, also migrating rodata makes it a lot cleaner */
s32 SkelCurve_Update(GlobalContext* globalCtx, SkelAnimeCurve* skelCurve) {
s16* transforms;
u8* transformRefIdx;
TransformUpdateIndex* transformIndex;
u16* transformCopyValues;
s32 i;
s32 ret = 0;
s32 k;
TransformData* transData;
f32 transformValue;
s32 j;
transformIndex = Lib_SegmentedToVirtual(skelCurve->transUpdIdx);
transformRefIdx = Lib_SegmentedToVirtual(transformIndex->refIndex);
transData = Lib_SegmentedToVirtual(transformIndex->transformData);
transformCopyValues = Lib_SegmentedToVirtual(transformIndex->copyValues);
transforms = (s16*)skelCurve->transforms;
skelCurve->animCurFrame += skelCurve->animSpeed * (globalCtx->state.framerateDivisor * 0.5f);
if ((skelCurve->animSpeed >= 0.0f && skelCurve->animCurFrame > skelCurve->animFinalFrame) ||
(skelCurve->animSpeed < 0.0f && skelCurve->animCurFrame < skelCurve->animFinalFrame)) {
skelCurve->animCurFrame = skelCurve->animFinalFrame;
ret = 1;
}
for (i = 0; i < skelCurve->limbCount; i++) {
for (j = 0; j < 3; j++) {
for (k = 0; k < 3; k++, transformRefIdx++, transforms++) {
if (*transformRefIdx == 0) {
transformValue = *transformCopyValues;
*transforms = transformValue;
transformCopyValues++;
} else {
transformValue = func_800F2478(skelCurve->animCurFrame, transData, *transformRefIdx);
transData += *transformRefIdx;
if (j == 0) {
*transforms = transformValue * 1024.0f;
} else if (j == 1) {
*transforms = transformValue * (32768.0f / 180.0f);
} else {
*transforms = transformValue * 100.0f;
}
}
}
}
}
return ret;
}
#else
#pragma GLOBAL_ASM("asm/non_matchings/code/z_fcurve_data_skelanime/SkelCurve_Update.s")
#endif
void SkelCurve_DrawLimb(GlobalContext* globalCtx, s32 limbIndex, SkelAnimeCurve* skelCurve,
OverrideCurveLimbDraw overrideLimbDraw, PostCurveLimbDraw postLimbDraw, s32 lod, Actor* thisx) {
SkelCurveLimb* limb = (SkelCurveLimb*)Lib_SegmentedToVirtual(skelCurve->limbList[limbIndex]);
OPEN_DISPS(globalCtx->state.gfxCtx);
Matrix_StatePush();
if (overrideLimbDraw == NULL ||
(overrideLimbDraw != NULL && overrideLimbDraw(globalCtx, skelCurve, limbIndex, thisx))) {
Vec3f scale;
Vec3s rot;
Vec3f pos;
Gfx* dList;
Vec3s* transform = (Vec3s*)&skelCurve->transforms[limbIndex];
scale.x = transform->x / 1024.0f;
scale.y = transform->y / 1024.0f;
scale.z = transform->z / 1024.0f;
transform++;
rot.x = transform->x;
rot.y = transform->y;
rot.z = transform->z;
transform++;
pos.x = transform->x;
pos.y = transform->y;
pos.z = transform->z;
Matrix_JointPosition(&pos, &rot);
Matrix_Scale(scale.x, scale.y, scale.z, MTXMODE_APPLY);
if (lod == 0) {
s32 pad1;
dList = limb->dList[0];
if (dList != NULL) {
gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx),
G_MTX_LOAD | G_MTX_NOPUSH | G_MTX_MODELVIEW);
gSPDisplayList(POLY_OPA_DISP++, dList);
}
} else if (lod == 1) {
s32 pad2;
dList = limb->dList[0];
if (dList != NULL) {
gSPMatrix(POLY_OPA_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx),
G_MTX_LOAD | G_MTX_NOPUSH | G_MTX_MODELVIEW);
gSPDisplayList(POLY_OPA_DISP++, dList);
}
dList = limb->dList[1];
if (dList != NULL) {
gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(globalCtx->state.gfxCtx),
G_MTX_LOAD | G_MTX_NOPUSH | G_MTX_MODELVIEW);
gSPDisplayList(POLY_XLU_DISP++, dList);
}
}
}
if (postLimbDraw != NULL) {
postLimbDraw(globalCtx, skelCurve, limbIndex, thisx);
}
if (limb->firstChildIdx != LIMB_DONE) {
SkelCurve_DrawLimb(globalCtx, limb->firstChildIdx, skelCurve, overrideLimbDraw, postLimbDraw, lod, thisx);
}
Matrix_StatePop();
if (limb->nextLimbIdx != LIMB_DONE) {
SkelCurve_DrawLimb(globalCtx, limb->nextLimbIdx, skelCurve, overrideLimbDraw, postLimbDraw, lod, thisx);
}
CLOSE_DISPS(globalCtx->state.gfxCtx);
}
void SkelCurve_Draw(Actor* actor, GlobalContext* globalCtx, SkelAnimeCurve* skelCurve,
OverrideCurveLimbDraw overrideLimbDraw, PostCurveLimbDraw postLimbDraw, s32 lod, Actor* thisx) {
if (skelCurve->transforms != NULL) {
SkelCurve_DrawLimb(globalCtx, 0, skelCurve, overrideLimbDraw, postLimbDraw, lod, thisx);
}
}
+1 -1
View File
@@ -432,7 +432,7 @@ void Lights_DrawGlow(GlobalContext* globalCtx) {
gDPSetPrimColor(dl++, 0, 0, params->color[0], params->color[1], params->color[2], 50);
SysMatrix_InsertTranslation(params->x, params->y, params->z, 0);
Matrix_InsertTranslation(params->x, params->y, params->z, MTXMODE_NEW);
Matrix_Scale(scale, scale, scale, MTXMODE_APPLY);
gSPMatrix(dl++, Matrix_NewMtx(globalCtx->state.gfxCtx),
+43 -10
View File
@@ -1,21 +1,54 @@
#include "global.h"
#pragma GLOBAL_ASM("asm/non_matchings/code/z_malloc/zelda_malloc.s")
void* ZeldaArena_Malloc(size_t size) {
void* ptr = __osMalloc(&sZeldaArena, size);
#pragma GLOBAL_ASM("asm/non_matchings/code/z_malloc/zelda_mallocR.s")
return ptr;
}
#pragma GLOBAL_ASM("asm/non_matchings/code/z_malloc/zelda_realloc.s")
void* ZeldaArena_MallocR(size_t size) {
void* ptr = __osMallocR(&sZeldaArena, size);
#pragma GLOBAL_ASM("asm/non_matchings/code/z_malloc/zelda_free.s")
return ptr;
}
#pragma GLOBAL_ASM("asm/non_matchings/code/z_malloc/zelda_calloc.s")
void* ZeldaArena_Realloc(void* ptr, size_t newSize) {
ptr = __osRealloc(&sZeldaArena, ptr, newSize);
return ptr;
}
#pragma GLOBAL_ASM("asm/non_matchings/code/z_malloc/MainHeap_AnalyzeArena.s")
void ZeldaArena_Free(void* ptr) {
__osFree(&sZeldaArena, ptr);
}
#pragma GLOBAL_ASM("asm/non_matchings/code/z_malloc/MainHeap_Check.s")
void* ZeldaArena_Calloc(u32 num, size_t size) {
void* ret;
u32 n = num * size;
#pragma GLOBAL_ASM("asm/non_matchings/code/z_malloc/MainHeap_Init.s")
ret = __osMalloc(&sZeldaArena, n);
if (ret != NULL) {
bzero(ret, n);
}
#pragma GLOBAL_ASM("asm/non_matchings/code/z_malloc/MainHeap_Cleanup.s")
return ret;
}
#pragma GLOBAL_ASM("asm/non_matchings/code/z_malloc/MainHeap_IsInitialized.s")
void ZeldaArena_GetSizes(size_t* outMaxFree, size_t* outFree, size_t* outAlloc) {
__osAnalyzeArena(&sZeldaArena, outMaxFree, outFree, outAlloc);
}
void ZeldaArena_Check() {
__osCheckArena(&sZeldaArena);
}
void ZeldaArena_Init(void* start, size_t size) {
__osMallocInit(&sZeldaArena, start, size);
}
void ZeldaArena_Cleanup() {
__osMallocCleanup(&sZeldaArena);
}
u8 ZeldaArena_IsInitialized() {
return __osMallocIsInitalized(&sZeldaArena);
}
+5
View File
@@ -0,0 +1,5 @@
#include "global.h"
#pragma GLOBAL_ASM("asm/non_matchings/code/z_pause/func_80122660.s")
#pragma GLOBAL_ASM("asm/non_matchings/code/z_pause/func_80122670.s")
+1 -1
View File
@@ -77,7 +77,7 @@ void Room_Init(GlobalContext* globalCtx, RoomContext* roomCtx) {
#ifdef NON_MATCHING
s32 Room_StartRoomTransition(GlobalContext* globalCtx, RoomContext* roomCtx, s32 index) {
u32 size;
size_t size;
// XXX: this should use a branch-likely
if (roomCtx->unk31 == 0) {
+6 -6
View File
@@ -1,7 +1,7 @@
#include "global.h"
s32 Object_Spawn(ObjectContext* objectCtx, s16 id) {
u32 size;
size_t size;
objectCtx->status[objectCtx->num].id = id;
size = objectFileTable[id].vromEnd - objectFileTable[id].vromStart;
@@ -23,8 +23,8 @@ s32 Object_Spawn(ObjectContext* objectCtx, s16 id) {
return objectCtx->num - 1;
}
void Object_InitBank(GameState* gamestate, ObjectContext* objectCtx) {
GlobalContext* globalCtx = (GlobalContext*)gamestate;
void Object_InitBank(GameState* gameState, ObjectContext* objectCtx) {
GlobalContext* globalCtx = (GlobalContext*)gameState;
s32 pad;
u32 spaceSize;
s32 i;
@@ -49,7 +49,7 @@ void Object_InitBank(GameState* gamestate, ObjectContext* objectCtx) {
for (i = 0; i < OBJECT_EXCHANGE_BANK_MAX; i++) { objectCtx->status[i].id = 0; }
// clang-format on
objectCtx->spaceStart = objectCtx->status[0].segment = THA_AllocEndAlign16(&gamestate->heap, spaceSize);
objectCtx->spaceStart = objectCtx->status[0].segment = THA_AllocEndAlign16(&gameState->heap, spaceSize);
objectCtx->spaceEnd = (void*)((u32)objectCtx->spaceStart + spaceSize);
objectCtx->mainKeepIndex = Object_Spawn(objectCtx, GAMEPLAY_KEEP);
@@ -60,7 +60,7 @@ void Object_UpdateBank(ObjectContext* objectCtx) {
s32 i;
ObjectStatus* status = &objectCtx->status[0];
RomFile* objectFile;
u32 size;
size_t size;
for (i = 0; i < objectCtx->num; i++) {
if (status->id < 0) {
@@ -354,7 +354,7 @@ s32 Scene_LoadAreaTextures(GlobalContext* globalCtx, s32 fileIndex) {
{ SEGMENT_ROM_START(scene_texture_08), SEGMENT_ROM_END(scene_texture_08) },
};
u32 vromStart = sceneTextureFiles[fileIndex].vromStart;
u32 size = sceneTextureFiles[fileIndex].vromEnd - vromStart;
size_t size = sceneTextureFiles[fileIndex].vromEnd - vromStart;
if (size != 0) {
globalCtx->roomCtx.unk74 = THA_AllocEndAlign16(&globalCtx->state.heap, size);
+1276 -996
View File
File diff suppressed because it is too large Load Diff
+12 -12
View File
@@ -237,7 +237,7 @@ s32 View_SetQuake(View* view, Vec3f rot, Vec3f scale, f32 speed) {
return 1;
}
s32 View_StepQuake(View* view, RSPMatrix* matrix) {
s32 View_StepQuake(View* view, Mtx* matrix) {
MtxF mf;
if (view->quakeSpeed == 0.0f) {
@@ -256,16 +256,16 @@ s32 View_StepQuake(View* view, RSPMatrix* matrix) {
view->currQuakeScale.z += ((view->quakeScale.z - view->currQuakeScale.z) * view->quakeSpeed);
}
SysMatrix_FromRSPMatrix(matrix, &mf);
SysMatrix_SetCurrentState(&mf);
SysMatrix_RotateStateAroundXAxis(view->currQuakeRot.x);
SysMatrix_InsertYRotation_f(view->currQuakeRot.y, 1);
SysMatrix_InsertZRotation_f(view->currQuakeRot.z, 1);
Matrix_Scale(view->currQuakeScale.x, view->currQuakeScale.y, view->currQuakeScale.z, 1);
SysMatrix_InsertZRotation_f(-view->currQuakeRot.z, 1);
SysMatrix_InsertYRotation_f(-view->currQuakeRot.y, 1);
SysMatrix_RotateStateAroundXAxis(-view->currQuakeRot.x);
SysMatrix_GetStateAsRSPMatrix(matrix);
Matrix_FromRSPMatrix(matrix, &mf);
Matrix_SetCurrentState(&mf);
Matrix_RotateStateAroundXAxis(view->currQuakeRot.x);
Matrix_InsertYRotation_f(view->currQuakeRot.y, 1);
Matrix_InsertZRotation_f(view->currQuakeRot.z, 1);
Matrix_Scale(view->currQuakeScale.x, view->currQuakeScale.y, view->currQuakeScale.z, MTXMODE_APPLY);
Matrix_InsertZRotation_f(-view->currQuakeRot.z, 1);
Matrix_InsertYRotation_f(-view->currQuakeRot.y, 1);
Matrix_RotateStateAroundXAxis(-view->currQuakeRot.x);
Matrix_ToMtx(matrix);
return 1;
}
@@ -310,7 +310,7 @@ s32 View_RenderToPerspectiveMatrix(View* view) {
guPerspective(projection, &view->normal, view->fovy, aspect, view->zNear, view->zFar, view->scale);
view->projection = *projection;
//! @bug: This cast of `projection` is invalid
View_StepQuake(view, (RSPMatrix*)projection);
View_StepQuake(view, (Mtx*)projection);
gSPPerspNormalize(POLY_OPA_DISP++, view->normal);
gSPMatrix(POLY_OPA_DISP++, projection, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION);
+9 -9
View File
@@ -35,9 +35,9 @@ void func_80143148(SkyboxContext* skyboxCtx, s32 arg1) {
}
}
void func_801431E8(GameState* gamestate, SkyboxContext* skyboxCtx, s16 skyType) {
GlobalContext* globalCtx = (GlobalContext*)gamestate;
u32 size;
void func_801431E8(GameState* gameState, SkyboxContext* skyboxCtx, s16 skyType) {
GlobalContext* globalCtx = (GlobalContext*)gameState;
size_t size;
void* offset;
s32 pad;
@@ -82,7 +82,7 @@ void func_801431E8(GameState* gamestate, SkyboxContext* skyboxCtx, s16 skyType)
}
void func_80143324(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skyType) {
u32 size;
size_t size;
if (1) {}
@@ -133,22 +133,22 @@ void func_80143324(GlobalContext* globalCtx, SkyboxContext* skyboxCtx, s16 skyTy
}
}
void func_801434E4(GameState* gamestate, SkyboxContext* skyboxCtx, s16 skyType) {
void func_801434E4(GameState* gameState, SkyboxContext* skyboxCtx, s16 skyType) {
skyboxCtx->skyboxShouldDraw = 0;
skyboxCtx->rotX = skyboxCtx->rotY = skyboxCtx->rotZ = 0.0f;
func_801431E8(gamestate, skyboxCtx, skyType);
func_801431E8(gameState, skyboxCtx, skyType);
if (skyType != 0) {
skyboxCtx->unk17C = THA_AllocEndAlign16(&gamestate->heap, 0x3840);
skyboxCtx->unk17C = THA_AllocEndAlign16(&gameState->heap, 0x3840);
if (skyType == 5) {
// Allocate enough space for the vertices for a 6 sided skybox (cube)
skyboxCtx->roomVtx = THA_AllocEndAlign16(&gamestate->heap, sizeof(Vtx) * 32 * 6);
skyboxCtx->roomVtx = THA_AllocEndAlign16(&gameState->heap, sizeof(Vtx) * 32 * 6);
func_80143148(skyboxCtx, 6);
} else {
// Allocate enough space for the vertices for a 5 sided skybox (bottom is missing)
skyboxCtx->roomVtx = THA_AllocEndAlign16(&gamestate->heap, sizeof(Vtx) * 32 * 5);
skyboxCtx->roomVtx = THA_AllocEndAlign16(&gameState->heap, sizeof(Vtx) * 32 * 5);
func_80143148(skyboxCtx, 5);
}
}