1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-07-14 03:44:34 +00:00

merge and change scene thing

This commit is contained in:
fig02 2020-03-20 08:17:48 -04:00
commit aa603ca229
113 changed files with 1722 additions and 5879 deletions

View file

@ -228,8 +228,6 @@ void __osMalloc_FreeBlockTest(Arena *arena, ArenaNode *node)
}
}
//single instruction not matching, stack problem
#ifdef NON_MATCHING
void* __osMalloc_NoLockDebug(Arena *arena, u32 size, const char *file, s32 line)
{
ArenaNode *iter;
@ -237,19 +235,19 @@ void* __osMalloc_NoLockDebug(Arena *arena, u32 size, const char *file, s32 line)
ArenaNode *newNode;
void *ret;
ArenaNode *next;
u32 pad;
ret = NULL;
iter = arena->head;
size = ALIGN16(size);
blockSize = ALIGN16(size) + sizeof(ArenaNode);
while (iter)
{
if (iter->isFree && iter->size >= size)
{
if ((arena->flag & CHECK_FREE_BLOCK) != 0)
if (arena->flag & CHECK_FREE_BLOCK)
__osMalloc_FreeBlockTest(arena, iter);
blockSize = ALIGN16(size) + sizeof(ArenaNode);
if (blockSize < iter->size)
{
newNode = (ArenaNode *)((u32)iter + blockSize);
@ -269,7 +267,7 @@ void* __osMalloc_NoLockDebug(Arena *arena, u32 size, const char *file, s32 line)
iter->isFree = false;
ArenaImpl_SetDebugInfo(iter, file, line, arena);
ret = (void *)((u32)iter + sizeof(ArenaNode));
if ((arena->flag & FILL_ALLOCBLOCK) != 0)
if (arena->flag & FILL_ALLOCBLOCK)
func_80106860(ret, BLOCK_ALLOC_MAGIC, size);
break;
@ -280,9 +278,6 @@ void* __osMalloc_NoLockDebug(Arena *arena, u32 size, const char *file, s32 line)
return ret;
}
#else
#pragma GLOBAL_ASM("asm/non_matchings/code/__osMalloc/__osMalloc_NoLockDebug.s")
#endif
void* __osMallocDebug(Arena* arena, u32 size, const char* file, s32 line)
{
@ -293,13 +288,11 @@ void* __osMallocDebug(Arena* arena, u32 size, const char* file, s32 line)
return ret;
}
//stack + missing a move
#ifdef NON_MATCHING
void* __osMallocRDebug(Arena *arena, u32 size, const char *file, s32 line)
{
ArenaNode *iter;
u32 blockSize;
ArenaNode *newNode;
u32 blockSize;
ArenaNode *next;
void *ret;
@ -311,7 +304,7 @@ void* __osMallocRDebug(Arena *arena, u32 size, const char *file, s32 line)
{
if (iter->isFree && iter->size >= size)
{
if ((arena->flag & CHECK_FREE_BLOCK) != 0)
if (arena->flag & CHECK_FREE_BLOCK)
__osMalloc_FreeBlockTest(arena, iter);
blockSize = ALIGN16(size) + sizeof(ArenaNode);
@ -328,12 +321,14 @@ void* __osMallocRDebug(Arena *arena, u32 size, const char *file, s32 line)
next = ArenaImpl_GetNextBlock(newNode);
if (next)
next->prev = newNode;
iter = newNode;
}
iter->isFree = false;
ArenaImpl_SetDebugInfo(iter, file, line, arena);
ret = (void *)((u32)iter + sizeof(ArenaNode));
if ((arena->flag & FILL_ALLOCBLOCK) != 0)
if (arena->flag & FILL_ALLOCBLOCK)
func_80106860(ret, BLOCK_ALLOC_MAGIC, size);
break;
@ -345,13 +340,7 @@ void* __osMallocRDebug(Arena *arena, u32 size, const char *file, s32 line)
ArenaImpl_Unlock(arena);
return ret;
}
#else
#pragma GLOBAL_ASM("asm/non_matchings/code/__osMalloc/__osMallocRDebug.s")
#endif
//same diff as __osMalloc_NoLockDebug
#ifdef NON_MATCHING
void* __osMalloc_NoLock(Arena *arena, u32 size)
{
ArenaNode *iter;
@ -359,19 +348,20 @@ void* __osMalloc_NoLock(Arena *arena, u32 size)
ArenaNode *newNode;
void *ret;
ArenaNode *next;
u32 pad;
ret = NULL;
iter = arena->head;
size = ALIGN16(size);
blockSize = ALIGN16(size) + sizeof(ArenaNode);
while (iter)
{
if (iter->isFree && iter->size >= size)
{
if ((arena->flag & CHECK_FREE_BLOCK) != 0)
if (arena->flag & CHECK_FREE_BLOCK)
__osMalloc_FreeBlockTest(arena, iter);
blockSize = ALIGN16(size) + sizeof(ArenaNode);
if (blockSize < iter->size)
{
newNode = (ArenaNode *)((u32)iter + blockSize);
@ -391,7 +381,7 @@ void* __osMalloc_NoLock(Arena *arena, u32 size)
iter->isFree = false;
ArenaImpl_SetDebugInfo(iter, NULL, 0, arena);
ret = (void *)((u32)iter + sizeof(ArenaNode));
if ((arena->flag & FILL_ALLOCBLOCK) != 0)
if (arena->flag & FILL_ALLOCBLOCK)
func_80106860(ret, BLOCK_ALLOC_MAGIC, size);
break;
@ -402,9 +392,6 @@ void* __osMalloc_NoLock(Arena *arena, u32 size)
return ret;
}
#else
#pragma GLOBAL_ASM("asm/non_matchings/code/__osMalloc/__osMalloc_NoLock.s")
#endif
void* __osMalloc(Arena* arena, u32 size)
{
@ -415,13 +402,11 @@ void* __osMalloc(Arena* arena, u32 size)
return ret;
}
//same diff as __osMallocRDebug
#ifdef NON_MATCHING
void* __osMallocR(Arena *arena, u32 size)
{
ArenaNode *iter;
u32 blockSize;
ArenaNode *newNode;
u32 blockSize;
ArenaNode *next;
void *ret;
@ -433,7 +418,7 @@ void* __osMallocR(Arena *arena, u32 size)
{
if (iter->isFree && iter->size >= size)
{
if ((arena->flag & CHECK_FREE_BLOCK) != 0)
if (arena->flag & CHECK_FREE_BLOCK)
__osMalloc_FreeBlockTest(arena, iter);
blockSize = ALIGN16(size) + sizeof(ArenaNode);
@ -450,12 +435,14 @@ void* __osMallocR(Arena *arena, u32 size)
next = ArenaImpl_GetNextBlock(newNode);
if (next)
next->prev = newNode;
iter = newNode;
}
iter->isFree = false;
ArenaImpl_SetDebugInfo(iter, NULL, 0, arena);
ret = (void *)((u32)iter + sizeof(ArenaNode));
if ((arena->flag & FILL_ALLOCBLOCK) != 0)
if (arena->flag & FILL_ALLOCBLOCK)
func_80106860(ret, BLOCK_ALLOC_MAGIC, size);
break;
@ -467,13 +454,7 @@ void* __osMallocR(Arena *arena, u32 size)
ArenaImpl_Unlock(arena);
return ret;
}
#else
#pragma GLOBAL_ASM("asm/non_matchings/code/__osMalloc/__osMallocR.s")
#endif
//small reordering
#ifdef NON_MATCHING
void __osFree_NoLock(Arena* arena, void* ptr)
{
ArenaNode* node;
@ -486,12 +467,12 @@ void __osFree_NoLock(Arena* arena, void* ptr)
node = (ArenaNode*)((u32)ptr - sizeof(ArenaNode));
if (node == NULL || node->magic != NODE_MAGIC)
{
osSyncPrintf(VT_COL(RED, WHITE) "__osFree:不正解放(%08x)\n" VT_RST, arena); //__osFree: Unauthorized release (%08x)
osSyncPrintf(VT_COL(RED, WHITE) "__osFree:不正解放(%08x)\n" VT_RST, ptr); //__osFree: Unauthorized release (%08x)
return;
}
if (node->isFree)
{
osSyncPrintf(VT_COL(RED, WHITE) "__osFree:二重解放(%08x)\n" VT_RST, arena); //__osFree: Double release (%08x)
osSyncPrintf(VT_COL(RED, WHITE) "__osFree:二重解放(%08x)\n" VT_RST, ptr); //__osFree: Double release (%08x)
return;
}
if (arena != node->arena && arena != NULL)
@ -505,12 +486,12 @@ void __osFree_NoLock(Arena* arena, void* ptr)
prev = ArenaImpl_GetPrevBlock(node);
node->isFree = true;
ArenaImpl_SetDebugInfo(node, NULL, 0, arena);
if ((arena->flag & FILL_FREEBLOCK) != 0)
if (arena->flag & FILL_FREEBLOCK)
{
func_80106860((u32)node + sizeof(ArenaNode), BLOCK_FREE_MAGIC, node->size);
}
newNext = node->next;
newNext = next;
if ((u32)next == (u32)node + sizeof(ArenaNode) + node->size && next->isFree)
{
newNext = ArenaImpl_GetNextBlock(next);
@ -518,26 +499,23 @@ void __osFree_NoLock(Arena* arena, void* ptr)
newNext->prev = node;
node->size += next->size + sizeof(ArenaNode);
if ((arena->flag & FILL_FREEBLOCK) != 0)
if (arena->flag & FILL_FREEBLOCK)
func_80106860(next, BLOCK_FREE_MAGIC, sizeof(ArenaNode));
node->next = newNext;
next = newNext;
}
if (prev && prev->isFree && (u32)node == (u32)prev + sizeof(ArenaNode) + prev->size)
{
if (newNext)
newNext->prev = prev;
prev->next = newNext;
if (next)
next->prev = prev;
prev->next = next;
prev->size += node->size + sizeof(ArenaNode);
if ((arena->flag & FILL_FREEBLOCK) != 0)
if (arena->flag & FILL_FREEBLOCK)
func_80106860(node, BLOCK_FREE_MAGIC, sizeof(ArenaNode));
}
}
}
#else
#pragma GLOBAL_ASM("asm/non_matchings/code/__osMalloc/__osFree_NoLock.s")
#endif
void __osFree(Arena* arena, void* ptr)
{
@ -546,8 +524,6 @@ void __osFree(Arena* arena, void* ptr)
ArenaImpl_Unlock(arena);
}
//small reordering
#ifdef NON_MATCHING
void __osFree_NoLockDebug(Arena* arena, void* ptr, const char* file, s32 line)
{
ArenaNode* node;
@ -560,12 +536,12 @@ void __osFree_NoLockDebug(Arena* arena, void* ptr, const char* file, s32 line)
node = (ArenaNode*)((u32)ptr - sizeof(ArenaNode));
if (node == NULL || node->magic != NODE_MAGIC)
{
osSyncPrintf(VT_COL(RED, WHITE) "__osFree:不正解放(%08x) [%s:%d ]\n" VT_RST, arena, file, line); //__osFree: Unauthorized release (%08x)
osSyncPrintf(VT_COL(RED, WHITE) "__osFree:不正解放(%08x) [%s:%d ]\n" VT_RST, ptr, file, line); //__osFree: Unauthorized release (%08x)
return;
}
if (node->isFree)
{
osSyncPrintf(VT_COL(RED, WHITE) "__osFree:二重解放(%08x)\n" VT_RST, arena); //__osFree: Double release (%08x)
osSyncPrintf(VT_COL(RED, WHITE) "__osFree:二重解放(%08x) [%s:%d ]\n" VT_RST, ptr, file, line); //__osFree: Double release (%08x)
return;
}
if (arena != node->arena && arena != NULL)
@ -579,7 +555,7 @@ void __osFree_NoLockDebug(Arena* arena, void* ptr, const char* file, s32 line)
prev = ArenaImpl_GetPrevBlock(node);
node->isFree = true;
ArenaImpl_SetDebugInfo(node, file, line, arena);
if ((arena->flag & FILL_FREEBLOCK) != 0)
if (arena->flag & FILL_FREEBLOCK)
{
func_80106860((u32)node + sizeof(ArenaNode), BLOCK_FREE_MAGIC, node->size);
}
@ -592,26 +568,23 @@ void __osFree_NoLockDebug(Arena* arena, void* ptr, const char* file, s32 line)
newNext->prev = node;
node->size += next->size + sizeof(ArenaNode);
if ((arena->flag & FILL_FREEBLOCK) != 0)
if (arena->flag & FILL_FREEBLOCK)
func_80106860(next, BLOCK_FREE_MAGIC, sizeof(ArenaNode));
node->next = newNext;
next = newNext;
}
if (prev && prev->isFree && (u32)node == (u32)prev + sizeof(ArenaNode) + prev->size)
{
if (newNext)
newNext->prev = prev;
prev->next = newNext;
if (next)
next->prev = prev;
prev->next = next;
prev->size += node->size + sizeof(ArenaNode);
if ((arena->flag & FILL_FREEBLOCK) != 0)
if (arena->flag & FILL_FREEBLOCK)
func_80106860(node, BLOCK_FREE_MAGIC, sizeof(ArenaNode));
}
}
}
#else
#pragma GLOBAL_ASM("asm/non_matchings/code/__osMalloc/__osFree_NoLockDebug.s")
#endif
void __osFreeDebug(Arena* arena, void* ptr, const char* file, s32 line)
{
@ -620,33 +593,27 @@ void __osFreeDebug(Arena* arena, void* ptr, const char* file, s32 line)
ArenaImpl_Unlock(arena);
}
//small reordering, stack usage
#ifdef NON_MATCHING
void* __osRealloc(Arena* arena, void* ptr, u32 newSize)
{
void* newAlloc;
ArenaNode* node;
ArenaNode* next;
u32 sizeDiff;
ArenaNode* overNext;
ArenaNode* newNext;
void* newAlloc;
//-----------
ArenaNode* next2;
ArenaNode unk;
ArenaNode* overNext;
ArenaNode* newNext2;
ArenaNode* next2;
u32 sizeDiff;
ArenaNode* overNext2;
//----------
u32 newSize2;
ArenaNode* newNext3;
ArenaNode* overNext3;
ArenaNode localCopy;
u32 blockSize;
s32 pad;
newSize = ALIGN16(newSize);
osSyncPrintf("__osRealloc(%08x, %d)\n", ptr, newSize);
ArenaImpl_Lock(arena);
if (!ptr)
{
ptr = __osMalloc(arena, newSize);
ptr = __osMalloc_NoLock(arena, newSize);
}
else if (!newSize)
{
@ -694,13 +661,14 @@ void* __osRealloc(Arena* arena, void* ptr, u32 newSize)
else if (newSize < node->size)
{
next2 = ArenaImpl_GetNextBlock(node);
if (next && next->isFree)
if (next2 && next2->isFree)
{
blockSize = ALIGN16(newSize) + sizeof(ArenaNode);
//Increased free block behind current memory block
osSyncPrintf("現メモリブロックの後ろのフリーブロックを大きくしました\n");
unk = *next2;
newNext2 = (u32)node + ALIGN16(newSize) + sizeof(ArenaNode);
*newNext2 = unk;
newNext2 = (ArenaNode*)((u32)node + blockSize);
localCopy = *next2;
*newNext2 = localCopy;
newNext2->size += node->size - newSize;
node->next = newNext2;
node->size = newSize;
@ -710,20 +678,20 @@ void* __osRealloc(Arena* arena, void* ptr, u32 newSize)
}
else if (newSize + sizeof(ArenaNode) < node->size)
{
blockSize = ALIGN16(newSize) + sizeof(ArenaNode);
//Generated because there is no free block after the current memory block
osSyncPrintf("現メモリブロックの後ろにフリーブロックがないので生成します\n");
newSize2 = ALIGN16(newSize) + sizeof(ArenaNode);
newNext3 = (ArenaNode*)((u32)node + newSize2);
newNext3->next = ArenaImpl_GetNextBlock(node);
newNext3->prev = node;
newNext3->size = node->size - newSize2;
newNext3->isFree = true;
newNext3->magic = NODE_MAGIC;
node->next = newNext3;
newNext2 = (ArenaNode*)((u32)node + blockSize);
newNext2->next = ArenaImpl_GetNextBlock(node);
newNext2->prev = node;
newNext2->size = node->size - blockSize;
newNext2->isFree = true;
newNext2->magic = NODE_MAGIC;
node->next = newNext2;
node->size = newSize;
overNext3 = ArenaImpl_GetNextBlock(newNext3);
if (overNext3)
overNext3->prev = newNext3;
overNext2 = ArenaImpl_GetNextBlock(newNext2);
if (overNext2)
overNext2->prev = newNext2;
}
else
{
@ -732,14 +700,11 @@ void* __osRealloc(Arena* arena, void* ptr, u32 newSize)
ptr = NULL;
}
}
}
ArenaImpl_Unlock(arena);
return ptr;
}
#else
#pragma GLOBAL_ASM("asm/non_matchings/code/__osMalloc/__osRealloc.s")
#endif
void* __osReallocDebug(Arena* arena, void* ptr, u32 newSize, const char* file, s32 line)
{
@ -757,7 +722,7 @@ void ArenaImpl_GetSizes(Arena* arena, u32* outMaxFree, u32* outFree, u32* outAll
*outAlloc = 0;
iter = arena->head;
while(iter)
while (iter)
{
if (iter->isFree)
{
@ -774,8 +739,6 @@ void ArenaImpl_GetSizes(Arena* arena, u32* outMaxFree, u32* outFree, u32* outAll
ArenaImpl_Unlock(arena);
}
//small reordering at the end
#ifdef NON_MATCHING
void __osDisplayArena(Arena* arena)
{
u32 freeSize;
@ -803,7 +766,7 @@ void __osDisplayArena(Arena* arena)
osSyncPrintf("メモリブロック範囲 status サイズ [時刻 s ms us ns: TID:src:行]\n");
iter = arena->head;
while(iter)
while (iter)
{
if (iter && iter->magic == NODE_MAGIC)
{
@ -828,14 +791,14 @@ void __osDisplayArena(Arena* arena)
{
allocatedSize += iter->size;
}
iter = next;
}
else
{
osSyncPrintf("%08x Block Invalid\n", iter);
iter = NULL;
next = NULL;
}
iter = next;
}
osSyncPrintf("確保ブロックサイズの合計 0x%08x バイト\n", allocatedSize); //Total reserved node size 0x%08x bytes
@ -844,12 +807,7 @@ void __osDisplayArena(Arena* arena)
ArenaImpl_Unlock(arena);
}
#else
#pragma GLOBAL_ASM("asm/non_matchings/code/__osMalloc/__osDisplayArena.s")
#endif
//small reordering
#ifdef NON_MATCHING
void ArenaImpl_FaultClient(Arena* arena)
{
u32 freeSize;
@ -872,7 +830,7 @@ void ArenaImpl_FaultClient(Arena* arena)
FaultDrawer_Printf("Memory Block Region status size\n");
iter = arena->head;
while(iter)
while (iter)
{
if (iter && iter->magic == NODE_MAGIC)
{
@ -894,15 +852,15 @@ void ArenaImpl_FaultClient(Arena* arena)
{
allocatedSize += iter->size;
}
iter = next;
}
else
{
FaultDrawer_SetFontColor(0xF801);
FaultDrawer_Printf("%08x Block Invalid\n", iter);
iter = NULL;
next = NULL;
}
iter = next;
}
FaultDrawer_SetFontColor(0x7F1);
@ -910,9 +868,6 @@ void ArenaImpl_FaultClient(Arena* arena)
FaultDrawer_Printf("Total Free Block Size %08x\n", freeSize);
FaultDrawer_Printf("Largest Free Block Size %08x\n", maxFree);
}
#else
#pragma GLOBAL_ASM("asm/non_matchings/code/__osMalloc/ArenaImpl_FaultClient.s")
#endif
u32 __osCheckArena(Arena* arena)
{
@ -924,7 +879,7 @@ u32 __osCheckArena(Arena* arena)
//Checking the contents of the arena. . (%08x)
osSyncPrintf("アリーナの内容をチェックしています... (%08x)\n", arena);
iter = arena->head;
while(iter)
while (iter)
{
if (iter && iter->magic == NODE_MAGIC)
{

View file

@ -1,7 +1,7 @@
#include <ultra64.h>
#include <global.h>
void func_8007C1AC(Vec3f* dest, struct_80045714* arg1);
Vec3f* func_8007C1AC(Vec3f* dest, struct_80045714* arg1);
f32 func_8007BF90(Vec3f* a, Vec3f* b)
{
@ -33,49 +33,48 @@ f32 func_8007C058(f32 arg0, f32 arg1)
#pragma GLOBAL_ASM("asm/non_matchings/code/code_8007BF90/func_8007C0A8.s")
#ifdef NON_MATCHING
void func_8007C0F8(Vec3f* dest, Vec3f* a, Vec3f* b)
Vec3f* func_8007C0F8(Vec3f* dest, Vec3f* a, Vec3f* b)
{
Vec3f v1;
Vec3f v2;
f32 temp;
v1.x = b->x - a->x;
v1.y = b->y - a->y;
v1.z = b->z - a->z;
temp = func_8007C058(sqrtf(SQ(v1.x) + SQ(v1.y) + SQ(v1.z)), 0.01f);
v2.x = v1.x / temp;
v2.y = v1.y / temp;
v2.z = v1.z / temp;
*dest = v2;
return dest;
}
Vec3f* func_8007C1AC(Vec3f* dest, struct_80045714* arg1)
{
f32 fVar1;
Vec3f v;
f32 sin4;
f32 cos4;
f32 sin6;
f32 cos6;
v.x = b->x - a->x;
v.y = b->y - a->y;
v.z = b->z - a->z;
cos4 = Math_Coss(arg1->unk_04);
cos6 = Math_Coss(arg1->unk_06);
sin4 = Math_Sins(arg1->unk_04);
sin6 = Math_Sins(arg1->unk_06);
fVar1 = func_8007C058(sqrtf(v.x * v.x + v.y * v.y + v.z * v.z), D_8013CB80);
v.x = arg1->unk_00 * sin4 * sin6;
v.y = arg1->unk_00 * cos4;
v.z = arg1->unk_00 * sin4 * cos6;
dest->x = v.x / fVar1;
dest->y = v.y / fVar1;
dest->z = v.z / fVar1;
*dest = v;
return dest;
}
#else
#pragma GLOBAL_ASM("asm/non_matchings/code/code_8007BF90/func_8007C0F8.s")
#endif
#ifdef NON_MATCHING
void func_8007C1AC(Vec3f* dest, struct_80045714* arg1)
{
f32 fVar1;
f32 fVar2;
f32 fVar3;
f32 fVar4;
f32 fVar5;
f32 fVar6;
fVar1 = Math_Coss(arg1->unk_04);
fVar2 = Math_Coss(arg1->unk_06);
fVar3 = Math_Coss(arg1->unk_04);
fVar4 = Math_Coss(arg1->unk_06);
fVar6 = arg1->unk_00;
fVar5 = arg1->unk_00;
dest->x = arg1->unk_00 * fVar3 * fVar4;
dest->y = fVar6 * fVar1;
dest->z = fVar5 * fVar3 * fVar2;
}
#else
#pragma GLOBAL_ASM("asm/non_matchings/code/code_8007BF90/func_8007C1AC.s")
#endif
void func_8007C3F4(struct_80045714* arg0, Vec3f* arg1);

View file

@ -45,22 +45,18 @@ void func_800AA0B4(void)
if (0) ; // Necessary to match
}
#ifdef NON_MATCHING
void func_800AA0F0(void)
{
if ((gPadMgr.unk_460 == func_800A9F30) && (gPadMgr.unk_464 == 0))
PadMgr* padmgr = &gPadMgr;
if ((padmgr->unk_460 == func_800A9F30) && (padmgr->unk_464 == 0))
{
// asm loads/writes directly to 0x80166D20 and 0x80166D24
// but the compiler wants to reuse offsets from 0x801668C0
gPadMgr.unk_460 = NULL;
gPadMgr.unk_464 = 0;
padmgr->unk_460 = NULL;
padmgr->unk_464 = 0;
}
func_800D3178(&D_80160FD0);
}
#else
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800A9F30/func_800AA0F0.s")
#endif
u32 func_800AA148(void)
{

View file

@ -1,5 +1,6 @@
#include <ultra64.h>
#include <global.h>
#include <alloca.h>
#include <vt.h>
//data
@ -55,40 +56,42 @@ void Fault_ClientProcessThread(FaultClientContext* ctx)
osSendMesg(ctx->queue, ctx->msg, 1);
}
#ifdef NON_MATCHING
void Fault_ProcessClientContext(FaultClientContext* ctx)
{
OSMesgQueue queue;
OSMesg msg;
OSThread* t;
OSTimer timer;
OSMesg recMsg;
OSThread* thread;
OSTimer timer;
u32 timerMsgVal;
timerMsgVal = 666;
thread = NULL;
osCreateMesgQueue(&queue, &msg, 1);
ctx->queue = &queue;
ctx->msg = NULL;
if (sFaultStructPtr->currClientThreadSp)
if (sFaultStructPtr->currClientThreadSp != 0)
{
Fault_ClientProcessThread(ctx);
t = NULL;
thread = alloca(sizeof(OSThread));
osCreateThread(thread, 2, Fault_ClientProcessThread, ctx, sFaultStructPtr->currClientThreadSp, 0x7E);
osStartThread(thread);
}
else
{
OSThread thread;
osCreateThread(&thread, 2, &Fault_ClientProcessThread, ctx, sFaultStructPtr->currClientThreadSp, 0x7E);
osStartThread(&thread);
t = &thread;
Fault_ClientProcessThread(ctx);
}
while(true)
while (true)
{
osSetTimer(&timer, OS_USEC_TO_CYCLES(1000000), 0, &queue, (OSMesg)0x29A);
osSetTimer(&timer, OS_USEC_TO_CYCLES(1000000), 0, &queue, (OSMesg)timerMsgVal);
osRecvMesg(&queue, &recMsg, 1);
if (recMsg == (OSMesg)0x29A)
if (recMsg != (OSMesg)666)
break;
if (sFaultIsWaitingForInput)
if (!sFaultIsWaitingForInput)
{
ctx->ret = -1;
break;
@ -96,17 +99,13 @@ void Fault_ProcessClientContext(FaultClientContext* ctx)
}
osStopTimer(&timer);
if (t)
if (thread != NULL)
{
osStopThread(t);
//osDestroyThread(t);
osDestroyThread(t);
osStopThread(thread);
osDestroyThread(thread);
}
}
#else
#pragma GLOBAL_ASM("asm/non_matchings/code/fault/Fault_ProcessClientContext.s")
#endif
u32 Fault_ProcessClient(u32 callback, u32 param0, u32 param1)
{
@ -120,16 +119,22 @@ u32 Fault_ProcessClient(u32 callback, u32 param0, u32 param1)
}
#ifdef NON_MATCHING
void Fault_AddClient(FaultClient *client, void* callback, void* param0, void* param1)
// minor ordering differences
void Fault_AddClient(FaultClient* client, void* callback, void* param0, void* param1)
{
bool alreadyExist = false;
OSIntMask mask = osSetIntMask(1);
FaultClient* iter = sFaultStructPtr->clients;
OSIntMask mask;
u32 alreadyExists;
FaultClient* iter;
alreadyExists = false;
mask = osSetIntMask(1);
iter = sFaultStructPtr->clients;
while (iter)
{
if (iter == client)
{
alreadyExist = true;
alreadyExists = true;
goto end;
}
iter = iter->next;
@ -143,7 +148,7 @@ void Fault_AddClient(FaultClient *client, void* callback, void* param0, void* pa
end:
osSetIntMask(mask);
if (alreadyExist)
if (alreadyExists)
osSyncPrintf(VT_COL(RED, WHITE) "fault_AddClient: %08x は既にリスト中にある\n" VT_RST, client);
}
#else
@ -187,7 +192,6 @@ void Fault_RemoveClient(FaultClient* client) {
osSyncPrintf(VT_COL(RED, WHITE) "fault_RemoveClient: %08x リスト不整合です\n" VT_RST, client);
}
#pragma GLOBAL_ASM("asm/non_matchings/code/fault/Fault_AddAddrConvClient.s")
void Fault_RemoveAddrConvClient(FaultAddrConvClient* client) {
@ -266,20 +270,23 @@ void Fault_UpdatePadImpl()
}
#ifdef NON_MATCHING
bool Fault_WaitForInputImpl()
// ordering differences and possibly regalloc
u32 Fault_WaitForInputImpl()
{
u16 kDown;
bool exitDebugger;
u32 exitDebugger;
s32 count = 600;
Input* curInput = &sFaultStructPtr->padInput;
while (true)
{
while (true)
{
Fault_Sleep(0x10);
Fault_UpdatePadImpl();
kDown = curInput->padPressed;
if (kDown == 0x20)
sFaultStructPtr->faultActive = !sFaultStructPtr->faultActive;
@ -291,14 +298,18 @@ bool Fault_WaitForInputImpl()
}
if (kDown == 0x8000 || kDown == 0x100)
break;
return false;
if (kDown == 0x200)
return true;
if (kDown == 0x800)
FaultDrawer_SetOsSyncPrintfEnabled(true);
if (kDown == 0x400)
FaultDrawer_SetOsSyncPrintfEnabled(false);
}
return false;
}
#else
@ -338,10 +349,10 @@ void Fault_DrawCornerRec(u16 color)
Fault_DrawRec(0x16, 0x10, 8, 1, color);
}
void Fault_PrintFReg(s32 idx, f32 *value)
void Fault_PrintFReg(s32 idx, f32* value)
{
u32 raw = *(u32*)value;
int v0 = ((raw & 0x7f800000) >> 0x17) - 0x7f;
s32 v0 = ((raw & 0x7f800000) >> 0x17) - 0x7f;
if ((v0 >= -0x7e && v0 < 0x80) || raw == 0)
FaultDrawer_Printf("F%02d:%14.7e ", idx, *value);
@ -349,8 +360,7 @@ void Fault_PrintFReg(s32 idx, f32 *value)
FaultDrawer_Printf("F%02d: %08x(16) ", idx, raw);
}
#ifdef NON_MATCHING
void Fault_LogFReg(s32 idx, f32 *value)
void Fault_LogFReg(s32 idx, f32* value)
{
u32 raw = *(u32*)value;
s32 v0 = ((raw & 0x7f800000) >> 0x17) - 0x7f;
@ -358,11 +368,8 @@ void Fault_LogFReg(s32 idx, f32 *value)
if ((v0 >= -0x7e && v0 < 0x80) || raw == 0)
osSyncPrintf("F%02d:%14.7e ", idx, *value);
else
osSyncPrintf("F%02d: %08x(16) ", idx, raw);
osSyncPrintf("F%02d: %08x(16) ", idx, *(u32*)value);
}
#else
#pragma GLOBAL_ASM("asm/non_matchings/code/fault/Fault_LogFReg.s")
#endif
void Fault_PrintFPCR(u32 value)
{
@ -567,14 +574,16 @@ void Fault_DrawMemDumpPage(const char* title, u32* addr, u32 param_3) {
FaultDrawer_SetCharPad(0, 0);
}
#ifdef NON_MATCHING
// saved register and stack usage differences
// possibly some minor ordering and regalloc differences
void Fault_DrawMemDump(u32 pc, u32 sp, u32 unk0, u32 unk1)
{
s32 count;
u16 held;
s32 off;
Input* curInput = &sFaultStructPtr->padInput;
u32 addr = pc;
s32 count;
s32 off;
while (true)
{
if (addr < 0x80000000)
@ -583,49 +592,54 @@ void Fault_DrawMemDump(u32 pc, u32 sp, u32 unk0, u32 unk1)
addr = 0x807fff00;
addr &= ~0xF;
Fault_DrawMemDumpPage("Dump", (u32*)addr);
Fault_DrawMemDumpPage("Dump", (u32*)addr, 0);
count = 600;
while (sFaultStructPtr->faultActive)
{
if (count-- == 0)
if (count == 0)
return;
count--;
Fault_Sleep(0x10);
Fault_UpdatePadImpl();
if ((sFaultStructPtr->padInput.padPressed | ~0x20) == ~0x20)
if (!~(curInput->padPressed | ~0x20))
sFaultStructPtr->faultActive = false;
}
do
{
Fault_Sleep(0x10);
Fault_UpdatePadImpl();
} while (sFaultStructPtr->padInput.padPressed == 0);
} while (curInput->padPressed == 0);
if ((sFaultStructPtr->padInput.padPressed | ~0x1000) == ~0)
if (!~(curInput->padPressed | ~0x1000))
return;
held = sFaultStructPtr->padInput.status;
if ((held | ~0x8000) == ~0)
if (!~(curInput->raw.pad | ~0x8000))
return;
off = 0x10;
if ((held | ~0x2000) == ~0)
if (!~(curInput->raw.pad | ~0x2000))
off = 0x100;
if ((held | ~0x4000) == ~0)
if (!~(curInput->raw.pad | ~0x4000))
off <<= 8;
if ((held | ~0x800) == ~0)
if (!~(curInput->raw.pad | ~0x800))
addr -= off;
if ((held | ~0x400) == ~0)
addr -= off;
if ((held | ~0x8) == ~0)
if (!~(curInput->raw.pad | ~0x400))
addr += off;
if (!~(curInput->raw.pad | ~0x8))
addr = pc;
if ((held | ~0x4) == ~0)
if (!~(curInput->raw.pad | ~0x4))
addr = sp;
if ((held | ~0x2) == ~0)
if (!~(curInput->raw.pad | ~0x2))
addr = unk0;
if ((held | ~0x1) == ~0)
if (!~(curInput->raw.pad | ~0x1))
addr = unk1;
if ((held | ~0x20) == ~0)
if (!~(curInput->raw.pad | ~0x20))
break;
}
sFaultStructPtr->faultActive = true;
}
#else
@ -674,6 +688,7 @@ void Fault_ProcessClients(void)
{
FaultClient* iter = sFaultStructPtr->clients;
s32 idx = 0;
while(iter)
{
if (iter->callback)
@ -696,58 +711,59 @@ void Fault_UpdatePad()
}
#ifdef NON_MATCHING
void Fault_ThreadEntry(u32 unused)
// saved register and stack usage differences
void Fault_ThreadEntry(void* arg)
{
OSThread *faultedThread;
OSThread* faultedThread;
OSMesg msg;
//osSetEventMesg
osSetEventMesg(OS_EVENT_CPU_BREAK, &sFaultStructPtr->queue, 1);
osSetEventMesg(OS_EVENT_FAULT, &sFaultStructPtr->queue, 2);
while (true)
{
osRecvMesg(&sFaultStructPtr->queue, &msg, 1);
do
{
osRecvMesg(&sFaultStructPtr->queue, &msg, 1);
if (msg == (OSMesg)1)
{
sFaultStructPtr->msgId = 1;
osSyncPrintf("フォルトマネージャ:OS_EVENT_CPU_BREAKを受信しました\n");
}
else if (msg == (OSMesg)2)
{
sFaultStructPtr->msgId = 2;
osSyncPrintf("フォルトマネージャ:OS_EVENT_FAULTを受信しました\n");
}
else if (msg != (OSMesg)3)
{
sFaultStructPtr->msgId = (u8)3;
osSyncPrintf("フォルトマネージャ:不明なメッセージを受信しました\n");
}
if (msg == (OSMesg)1)
{
sFaultStructPtr->msgId = 1;
osSyncPrintf("フォルトマネージャ:OS_EVENT_CPU_BREAKを受信しました\n");
}
else if (1 && msg == (OSMesg)2)
{
sFaultStructPtr->msgId = 2;
osSyncPrintf("フォルトマネージャ:OS_EVENT_FAULTを受信しました\n");
}
else if (msg == (OSMesg)3)
{
Fault_UpdatePad();
faultedThread = NULL;
continue;
}
else
{
sFaultStructPtr->msgId = 3;
osSyncPrintf("フォルトマネージャ:不明なメッセージを受信しました\n");
}
if (msg == (OSMesg)3)
{
Fault_UpdatePad();
faultedThread = NULL;
}
else
{
faultedThread = __osGetCurrFaultedThread();
osSyncPrintf("__osGetCurrFaultedThread()=%08x\n", faultedThread);
if (!faultedThread)
if (faultedThread == NULL)
{
faultedThread = Fault_FindFaultedThread();
osSyncPrintf("FindFaultedThread()=%08x\n", faultedThread);
}
}
if (!faultedThread)
continue;
} while (faultedThread == NULL);
__osSetFpcCsr(__osGetFpcCsr() & -0xf81);
sFaultStructPtr->faultedThread = faultedThread;
while (!sFaultStructPtr->faultHandlerEnabled)
Fault_Sleep(1000);
Fault_Sleep(500);
Fault_CommitFB();
@ -781,10 +797,12 @@ void Fault_ThreadEntry(u32 unused)
FaultDrawer_DrawText(0x40, 0x64, " THANK YOU! ");
FaultDrawer_DrawText(0x40, 0x6E, " You are great debugger!");
Fault_WaitForInput();
} while (!sFaultStructPtr->exitDebugger);
while(!sFaultStructPtr->exitDebugger){}
while (!sFaultStructPtr->exitDebugger)
{
}
Fault_ResumeThread(faultedThread);
}

View file

@ -47,7 +47,7 @@ FaultDrawer sFaultDrawerDefault =
22, 297,//xStart, xEnd
0xFFFF, 0x0000, //foreColor, backColor
22, 16, //cursorX, cursorY
&sFaultDrawerFont, //font
sFaultDrawerFont, //font
8, 8, 0, 0,
{ //printColors
0x0001, 0xF801, 0x07C1, 0xFFC1,
@ -63,7 +63,6 @@ FaultDrawer sFaultDrawerDefault =
FaultDrawer sFaultDrawerStruct;
char D_8016B6C0[0x20]; //? unused
void FaultDrawer_SetOsSyncPrintfEnabled(u32 enabled)
{
sFaultDrawerStruct.osSyncPrintfEnabled = enabled;
@ -75,9 +74,10 @@ void FaultDrawer_DrawRecImpl(s32 xstart, s32 ystart, s32 xend, s32 yend, u16 col
if (sFaultDrawerStruct.w - xstart > 0 && sFaultDrawerStruct.h - ystart > 0)
{
s32 x, y;
for (y = 0; y < yend-ystart+1; y++)
for (x = 0; x < xend-xstart+1; x++)
sFaultDrawerStruct.fb[sFaultDrawerStruct.w*y+x] = color;
for (y = 0; y <= yend - ystart; y++)
for (x = 0; x <= xend - xstart; x++)
sFaultDrawerStruct.fb[sFaultDrawerStruct.w * y + x] = color;
osWritebackDCacheAll();
}
@ -86,35 +86,38 @@ void FaultDrawer_DrawRecImpl(s32 xstart, s32 ystart, s32 xend, s32 yend, u16 col
#pragma GLOBAL_ASM("asm/non_matchings/code/fault_drawer/FaultDrawer_DrawRecImpl.s")
#endif
#ifdef NON_MATCHING
// regalloc and minor ordering differences
void FaultDrawer_DrawChar(char c)
{
s32 x, y;
u32* dataStart = &sFaultDrawerStruct.fontData[(c >> 3) * 0x10 + (c & 4) >> 2];
u16* fb = &sFaultDrawerStruct.fb[sFaultDrawerStruct.w * sFaultDrawerStruct.cursorY + sFaultDrawerStruct.cursorX];
u32* dataPtr;
u16* fb;
if (sFaultDrawerStruct.xStart <= sFaultDrawerStruct.cursorX &&
sFaultDrawerStruct.charW + sFaultDrawerStruct.cursorX -1 <= sFaultDrawerStruct.xEnd &&
sFaultDrawerStruct.yStart <= sFaultDrawerStruct.cursorY &&
sFaultDrawerStruct.charH + sFaultDrawerStruct.cursorY -1 <= sFaultDrawerStruct.yEnd &&
sFaultDrawerStruct.charH != 0
)
dataPtr = &sFaultDrawerStruct.fontData[((c & 4) >> 2) + ((c / 8) * 16)];
fb = &sFaultDrawerStruct.fb[sFaultDrawerStruct.cursorY * sFaultDrawerStruct.w];
fb = &fb[sFaultDrawerStruct.cursorX];
if ((sFaultDrawerStruct.xStart <= sFaultDrawerStruct.cursorX) &&
((sFaultDrawerStruct.charW + sFaultDrawerStruct.cursorX - 1) <= sFaultDrawerStruct.xEnd) &&
(sFaultDrawerStruct.yStart <= sFaultDrawerStruct.cursorY) &&
((sFaultDrawerStruct.charH + sFaultDrawerStruct.cursorY - 1) <= sFaultDrawerStruct.yEnd))
{
for (y = 0; y < sFaultDrawerStruct.charH; y++)
{
u32 mask = 0x10000000 << (c & 3);
u32 mask = 0x10000000 << (c % 4);
u32 data = *dataPtr;
for (x = 0; x < sFaultDrawerStruct.charW; x++)
{
if ((mask & *dataStart))
if (mask & data)
fb[x] = sFaultDrawerStruct.foreColor;
else
if (sFaultDrawerStruct.backColor & 1)
fb[x] = sFaultDrawerStruct.backColor;
else if (sFaultDrawerStruct.backColor & 1)
fb[x] = sFaultDrawerStruct.backColor;
mask >>= 4;
}
fb += sFaultDrawerStruct.w;
dataStart += 2;
dataPtr += 2;
}
}
}
@ -186,58 +189,56 @@ void FaultDrawer_FillScreen()
FaultDrawer_SetCursor(sFaultDrawerStruct.xStart, sFaultDrawerStruct.yStart);
}
#ifdef NON_MATCHING
u32 FaultDrawer_FormatStringFunc(u32 arg0, const char* str, s32 count)
{
while (count)
for (count; count != 0; count--, str++)
{
s32 curXStart; //s32?
s32 curXStart;
s32 curXEnd;
if (sFaultDrawerStruct.escCode)
{
sFaultDrawerStruct.escCode = false;
if (*str > 0x30 && *str < 0x3A)
FaultDrawer_SetForeColor(gFaultStruct.colors[*str + 12]);
FaultDrawer_SetForeColor(sFaultDrawerStruct.printColors[*str - 0x30]);
curXStart = sFaultDrawerStruct.cursorX;
curXEnd = sFaultDrawerStruct.xEnd - sFaultDrawerStruct.charW;
}
else
{
if (*str == '\n')
switch (*str)
{
if (sFaultDrawerStruct.osSyncPrintfEnabled)
osSyncPrintf("\n");
case '\n':
if (sFaultDrawerStruct.osSyncPrintfEnabled)
osSyncPrintf("\n");
sFaultDrawerStruct.cursorX = sFaultDrawerStruct.w;
curXStart = sFaultDrawerStruct.w;
curXEnd = sFaultDrawerStruct.xEnd - sFaultDrawerStruct.charW;
}
else if (*str == '\x1a')
{
sFaultDrawerStruct.escCode = true;
curXStart = sFaultDrawerStruct.cursorX;
curXEnd = sFaultDrawerStruct.xEnd - sFaultDrawerStruct.charW;
}
else
{
if (sFaultDrawerStruct.osSyncPrintfEnabled)
osSyncPrintf("%c", *str);
sFaultDrawerStruct.cursorX = sFaultDrawerStruct.w;
curXStart = sFaultDrawerStruct.cursorX;
curXEnd = sFaultDrawerStruct.xEnd - sFaultDrawerStruct.charW;
break;
case '\x1A':
sFaultDrawerStruct.escCode = true;
curXStart = sFaultDrawerStruct.cursorX;
curXEnd = sFaultDrawerStruct.xEnd - sFaultDrawerStruct.charW;
break;
default:
if (sFaultDrawerStruct.osSyncPrintfEnabled)
osSyncPrintf("%c", *str);
FaultDrawer_DrawChar(*str);
sFaultDrawerStruct.cursorX += sFaultDrawerStruct.charW + sFaultDrawerStruct.charWPad;
FaultDrawer_DrawChar(*str);
sFaultDrawerStruct.cursorX += sFaultDrawerStruct.charW + sFaultDrawerStruct.charWPad;
curXStart = sFaultDrawerStruct.cursorX;
curXEnd = sFaultDrawerStruct.xEnd - sFaultDrawerStruct.charW;
curXStart = sFaultDrawerStruct.cursorX;
curXEnd = sFaultDrawerStruct.xEnd - sFaultDrawerStruct.charW;
}
}
if (curXEnd <= curXStart)
{
sFaultDrawerStruct.cursorY += sFaultDrawerStruct.charH + sFaultDrawerStruct.charHPad;
sFaultDrawerStruct.cursorX = sFaultDrawerStruct.xStart;
if (sFaultDrawerStruct.yEnd - sFaultDrawerStruct.charH <= (u16)sFaultDrawerStruct.cursorY) //cast?
sFaultDrawerStruct.cursorY += sFaultDrawerStruct.charH + sFaultDrawerStruct.charHPad;
if (sFaultDrawerStruct.yEnd - sFaultDrawerStruct.charH <= sFaultDrawerStruct.cursorY)
{
if (sFaultDrawerStruct.inputCallback)
{
@ -247,16 +248,12 @@ u32 FaultDrawer_FormatStringFunc(u32 arg0, const char* str, s32 count)
sFaultDrawerStruct.cursorY = sFaultDrawerStruct.yStart;
}
}
count--;
str++;
}
osWritebackDCacheAll();
return arg0;
}
#else
#pragma GLOBAL_ASM("asm/non_matchings/code/fault_drawer/FaultDrawer_FormatStringFunc.s")
#endif
void FaultDrawer_VPrintf(const char* str, char* args) //va_list
{

View file

@ -104,54 +104,92 @@ u8 sGfxPrintFontData[(16*256)/2] =
};
#define gDPSetPrimColorMod(pkt, m, l, rgba) \
_DW({ \
Gfx *_g = (Gfx *)(pkt); \
\
_g->words.w0 = (_SHIFTL(G_SETPRIMCOLOR, 24, 8) | \
_SHIFTL(m, 8, 8) | _SHIFTL(l, 0, 8)); \
_g->words.w1 = (rgba); \
#define gDPSetPrimColorMod(pkt, m, l, rgba) \
_DW({ \
Gfx *_g = (Gfx *)(pkt); \
\
_g->words.w0 = (_SHIFTL(G_SETPRIMCOLOR, 24, 8) | \
_SHIFTL(m, 8, 8) | _SHIFTL(l, 0, 8)); \
_g->words.w1 = (rgba); \
})
#ifdef NON_MATCHING
// regalloc and minor ordering differences
void GfxPrint_InitDlist(GfxPrint* this)
{
u32 palette;
u32 tile;
s32 width = 16;
s32 height = 256;
s32 i;
gDPPipeSync(this->dlist++);
gDPSetOtherMode(this->dlist++, 0xECF0, 0x504244);
gDPSetCombineLERP(this->dlist++, K5, K5, 0, TEXEL0, 0, 0, 0, TEXEL0, K5, K5, 0, TEXEL0, 0, 0, 0, TEXEL0);
gDPLoadTextureBlock(this->dlist++, sGfxPrintFontData, G_IM_FMT_CI, G_IM_SIZ_4b, 16, 256, 0, 0, 0, 0, 0, 0, 0); //? missmatch here
gDPLoadTLUT(this->dlist++, 64, 0x100, sGfxPrintFontTLUT);
gDPSetOtherMode(this->dlist++,
G_AD_DISABLE | G_CD_DISABLE | G_CK_NONE | G_TC_FILT | G_TF_BILERP |
G_TT_IA16 | G_TL_TILE | G_TD_CLAMP | G_TP_NONE | G_CYC_1CYCLE | G_PM_NPRIMITIVE,
G_AC_NONE | G_ZS_PRIM | G_RM_XLU_SURF | G_RM_XLU_SURF2);
gDPSetCombineLERP(this->dlist++,
0, 0, 0, TEXEL0, 0, 0, 0, TEXEL0,
0, 0, 0, TEXEL0, 0, 0, 0, TEXEL0);
tile = 2;
palette = 1;
do
gDPSetTextureImage(this->dlist++, G_IM_FMT_CI, G_IM_SIZ_4b_LOAD_BLOCK, 1, sGfxPrintFontData);
gDPSetTile(this->dlist++, G_IM_FMT_CI, G_IM_SIZ_4b_LOAD_BLOCK,
0, 0, G_TX_LOADTILE, 0,
G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD,
G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD);
gDPLoadSync(this->dlist++);
gDPLoadBlock(this->dlist++, G_TX_LOADTILE, 0, 0,
(((width)*(height) + G_IM_SIZ_4b_INCR) >> G_IM_SIZ_4b_SHIFT) - 1,
CALC_DXT(width, G_IM_SIZ_4b_BYTES));
gDPPipeSync(this->dlist++);
gDPSetTile(this->dlist++, G_IM_FMT_CI, G_IM_SIZ_4b,
1, 0, G_TX_RENDERTILE, 0,
G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD,
G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD);
gDPSetTileSize(this->dlist++, G_TX_RENDERTILE, 0, 0,
((width)-1) << G_TEXTURE_IMAGE_FRAC,
((height)-1) << G_TEXTURE_IMAGE_FRAC);
gDPLoadTLUT(this->dlist++, 64, 256, sGfxPrintFontTLUT);
for (i = 1; i < 4; i++)
{
gDPSetTile(this->dlist++, G_IM_FMT_CI, G_IM_SIZ_4b, 1, 0x0, tile, palette++, G_TX_NOMIRROR | G_TX_CLAMP, 0, 0, G_TX_NOMIRROR | G_TX_CLAMP, 0, 0);
gDPSetTileSize(this->dlist++, tile, 0, 0, 15, 255);
tile+=2;
} while (palette < 4);
gDPSetTile(this->dlist++, G_IM_FMT_CI, G_IM_SIZ_4b,
1, 0, i * 2, i,
G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD,
G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD);
gDPSetTileSize(this->dlist++, i * 2, 0, 0, 60, 1020);
}
gDPSetPrimColorMod(this->dlist++, 0, 0, *(u32*)&this->color);
gDPLoadTextureTile(this->dlist++, sGfxPrintUnkData, G_IM_FMT_CI, G_IM_SIZ_8b, 1, 0, 0, 0, 0, 7, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP, 1, 3, 0, 0);
gDPLoadTLUT(this->dlist++, 16, 0x140, sGfxPrintUnkTLUT);
tile = 3;
do
gDPSetTextureImage(this->dlist++, G_IM_FMT_CI, G_IM_SIZ_8b, 1, sGfxPrintUnkData);
gDPSetTile(this->dlist++, G_IM_FMT_CI, G_IM_SIZ_8b,
1, 0, G_TX_LOADTILE, 0 ,
G_TX_NOMIRROR | G_TX_WRAP, 3, G_TX_NOLOD,
G_TX_NOMIRROR | G_TX_WRAP, 1, G_TX_NOLOD);
gDPLoadSync(this->dlist++);
gDPLoadTile(this->dlist++, G_TX_LOADTILE, 0, 0, 2, 28);
gDPPipeSync(this->dlist++);
gDPSetTile(this->dlist++, G_IM_FMT_CI, G_IM_SIZ_8b,
1, 0, 1, 4,
G_TX_NOMIRROR | G_TX_WRAP, 3, G_TX_NOLOD,
G_TX_NOMIRROR | G_TX_WRAP, 1, G_TX_NOLOD);
gDPSetTileSize(this->dlist++, 1, 0, 0, 4, 28);
gDPLoadTLUT(this->dlist++, 16, 320, sGfxPrintUnkTLUT);
for (i = 1; i < 4; i++)
{
gDPSetTile(this->dlist++, G_IM_FMT_CI, G_IM_SIZ_4b, tile, 0x0, G_TX_RENDERTILE, 4, G_TX_NOMIRROR | G_TX_WRAP, 3, 0, G_TX_NOMIRROR | G_TX_WRAP, 1, 0);
gDPSetTileSize(this->dlist++, tile, 0, 0, 1, 7);
tile += 2;
} while (tile != 9);
gDPSetTile(this->dlist++, G_IM_FMT_CI, G_IM_SIZ_4b,
1, 0, i * 2 + 1, 4,
G_TX_NOMIRROR | G_TX_WRAP, 3, G_TX_NOLOD,
G_TX_NOMIRROR | G_TX_WRAP, 1, G_TX_NOLOD);
gDPSetTileSize(this->dlist++, i * 2 + 1, 0, 0, 4, 28);
}
}
#else
#pragma GLOBAL_ASM("asm/non_matchings/code/gfxprint/GfxPrint_InitDlist.s")
#endif
void GfxPrint_SetColor(GfxPrint* this, u32 r, u32 g, u32 b, u32 a)
{
this->color.r = r;
@ -180,71 +218,95 @@ void GfxPrint_SetBasePosPx(GfxPrint* this, s32 x, s32 y)
this->baseY = y << 2;
}
//close from matching
#ifdef NON_MATCHING
void GfxPrint_PrintCharImpl(GfxPrint* this, u8 c)
// regalloc and ordering differences
void GfxPrint_PrintCharImpl(GfxPrint* this, char c)
{
u32 test;
u32 test2;
if (this->flag & GFXPRINT_UPDATE_MODE)
{
this->flag &= ~GFXPRINT_UPDATE_MODE;
gDPPipeSync(this->dlist++);
if (this->flag & GFXPRINT_USE_RGBA16)
{
gDPSetTextureLUT(this->dlist++, G_TT_RGBA16);
gDPSetCycleType(this->dlist++, G_CYC_2CYCLE);
gDPSetRenderMode(this->dlist++, G_RM_OPA_CI, G_RM_XLU_SURF2);
gDPSetCombineLERP(this->dlist++, TEXEL0, K5, TEXEL1, COMBINED_ALPHA, TEXEL0, 0, TEXEL1, 0, K5, K5, 0, COMBINED, 0, 0, 0, COMBINED);
gDPSetCombineLERP(this->dlist++,
TEXEL0, 0, TEXEL1, 0, TEXEL0, 0, TEXEL1, 0,
0, 0, 0, COMBINED, 0, 0, 0, COMBINED);
}
else
{
gDPSetTextureLUT(this->dlist++, G_TT_IA16);
gDPSetCycleType(this->dlist++, G_CYC_1CYCLE);
gDPSetRenderMode(this->dlist++, G_RM_XLU_SURF, G_RM_XLU_SURF2);
gDPSetCombineLERP(this->dlist++, TEXEL0, K5, PRIMITIVE, COMBINED_ALPHA, 0, 0, 0, TEXEL0, TEXEL0, K5, PRIMITIVE, COMBINED_ALPHA, 0, 0, 0, TEXEL0);
gDPSetCombineLERP(this->dlist++,
TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, TEXEL0,
TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, TEXEL0);
}
}
test = (c & 4) << 6;
test2 = (c >> 3) << 8;
if (this->flag & GFXPRINT_FLAG4)
{
gDPSetPrimColorMod(this->dlist++, 0, 0, 0);
if (this->flag & GFXPRINT_FLAG64)
gSPTextureRectangle(this->dlist++, (this->posX+4)<<1, (this->posY+4)<<1, (this->posX+0x24)<<1, (this->posY+0x24)<<1, c<<1, test, test2, 512, 512); //c*2 ?
gSPTextureRectangle(this->dlist++,
(this->posX + 4) << 1, (this->posY + 4) << 1,
(this->posX + 4 + 32) << 1, (this->posY + 4 + 32) << 1,
c * 2,
(u16)(c & 4) * 64, (u16)(c >> 3) * 256,
512, 512);
else
gSPTextureRectangle(this->dlist++, this->posX+4, this->posY+4, this->posX+0x24, this->posY+0x24, c<<1, test, test2, 1024, 1024);
gSPTextureRectangle(this->dlist++,
this->posX + 4, this->posY + 4,
this->posX + 4 + 32, this->posY + 4 + 32,
c * 2,
(u16)(c & 4) * 64, (u16)(c >> 3) * 256,
1024, 1024);
gDPSetPrimColorMod(this->dlist++, 0, 0, *(u32*)&this->color);
}
if (this->flag & GFXPRINT_FLAG64)
gSPTextureRectangle(this->dlist++, (this->posX)<<1, (this->posY)<<1, (this->posX + 0x20)<<1, (this->posY + 0x20)<<1, c << 1, test, test2, 512, 512);
else
gSPTextureRectangle(this->dlist++, this->posX, this->posY, this->posX + 0x20, this->posY + 0x20, c << 1, test, test2, 1024, 1024);
this->posX += 0x20;
if (this->flag & GFXPRINT_FLAG64)
gSPTextureRectangle(this->dlist++,
(this->posX) << 1, (this->posY) << 1,
(this->posX + 32) << 1, (this->posY + 32) << 1,
c * 2,
(u16)(c & 4) * 64, (u16)(c >> 3) * 256,
512, 512);
else
gSPTextureRectangle(this->dlist++,
this->posX, this->posY,
this->posX + 32, this->posY + 32,
c * 2,
(u16)(c & 4) * 64, (u16)(c >> 3) * 256,
1024, 1024);
this->posX += 32;
}
#else
#pragma GLOBAL_ASM("asm/non_matchings/code/gfxprint/GfxPrint_PrintCharImpl.s")
#endif
#ifdef NON_MATCHING
void GfxPrint_PrintChar(GfxPrint *this, char c)
void GfxPrint_PrintChar(GfxPrint* this, u8 c)
{
u8 charParam = c;
if (c == ' ')
this->posX += 0x20;
else if (c > 0x20 && c < 0x7f)
GfxPrint_PrintCharImpl(this, c);
else if (c >= 0xa0 && c < 0xe0)
{
u8 charParam = c;
if ((this->flag & GFXPRINT_FLAG1) != 0)
this->posX += 0x20;
}
else if (c > 0x20 && c < 0x7F)
{
GfxPrint_PrintCharImpl(this, charParam);
}
else if (c >= 0xA0 && c < 0xE0)
{
if (this->flag & GFXPRINT_FLAG1)
{
if (c < 0xc0)
if (c < 0xC0)
charParam = c - 0x20;
else
charParam = c + 0x20;
@ -253,75 +315,41 @@ void GfxPrint_PrintChar(GfxPrint *this, char c)
}
else
{
switch(c)
switch (c)
{
case 0:
return;
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
return;
//tab
case 9:
{
u32 uVar1;
do {
GfxPrint_PrintCharImpl(this, 0x20);
uVar1 = this->posX - this->baseX;
if (uVar1 < 0 && uVar1 != 0)
uVar1 -= 0x100;
} while (uVar1 != 0);
return;
}
//line feed
case 0xa:
{
break;
case '\n':
this->posY += 0x20;
case '\r':
this->posX = this->baseX;
return;
}
/*
case 0xb:
case 0xc:
return;
*/
//carriage return
case 0xd:
{
this->posX = this->baseX;
return;
}
case 0x8a:
this->flag &= ~GFXPRINT_USE_RGBA16;
this->flag |= GFXPRINT_UPDATE_MODE;
return;
case 0x8b:
break;
case '\t':
do
{
GfxPrint_PrintCharImpl(this, 0x20);
} while ((this->posX - this->baseX) % 256);
break;
case 0x8D:
this->flag |= GFXPRINT_FLAG1;
break;
case 0x8C:
this->flag &= ~GFXPRINT_FLAG1;
break;
case 0x8B:
this->flag |= GFXPRINT_USE_RGBA16;
this->flag |= GFXPRINT_UPDATE_MODE;
return;
case 0x8c:
this->flag &= ~GFXPRINT_FLAG1;
return;
case 0x8d:
this->flag |= GFXPRINT_FLAG1;
return;
case 0x8e:
break;
case 0x8A:
this->flag &= ~GFXPRINT_USE_RGBA16;
this->flag |= GFXPRINT_UPDATE_MODE;
break;
case 0x8E:
default:
return;
break;
}
}
}
#else
#pragma GLOBAL_ASM("asm/non_matchings/code/gfxprint/GfxPrint_PrintChar.s")
#endif
void GfxPrint_PrintStringWithSize(GfxPrint* this, const void* buffer, size_t charSize, size_t charCount)
{
@ -409,4 +437,4 @@ void GfxPrint_Printf(GfxPrint* this, const char* fmt, ...)
va_start(args, fmt);
GfxPrint_VPrintf(this, fmt, args);
}
}

View file

@ -1,10 +1,13 @@
#include <ultra64.h>
#include <global.h>
#include <vt.h>
#include <PR/os_cont.h>
#include <ultra64/controller.h>
#include <padmgr.h>
s32 D_8012D280 = 1;
OSMesgQueue* PadMgr_LockGetControllerQueue(PadMgr* padmgr)
{
OSMesgQueue* ctrlrqueue = NULL;
@ -37,23 +40,28 @@ void PadMgr_UnlockReleaseControllerQueue(PadMgr* padmgr, OSMesgQueue* ctrlrqueue
void PadMgr_Lock2(PadMgr* padmgr)
{
osRecvMesg(&padmgr->queue2, 0, OS_MESG_BLOCK);
osRecvMesg(&padmgr->queue2, NULL, OS_MESG_BLOCK);
}
void PadMgr_Unlock2(PadMgr* padmgr)
{
osSendMesg(&padmgr->queue2, 0, OS_MESG_BLOCK);
osSendMesg(&padmgr->queue2, NULL, OS_MESG_BLOCK);
}
#ifdef NON_MATCHING
// regalloc and minor ordering differences
void func_800C740C(PadMgr* padmgr)
{
static u32 D_8012D284 = 0;
static u32 D_8016A4F0;
s32 temp;
s32 var1;
OSMesgQueue* ctrlrqueue;
s32 var3;
s32 var4;
s32 i;
temp = 1;
ctrlrqueue = PadMgr_LockGetControllerQueue(padmgr);
var1 = 0;
@ -63,26 +71,28 @@ void func_800C740C(PadMgr* padmgr)
{
if (padmgr->pad_status[i].status & 1)
{
if (padmgr->unk_2AE[i] == 1)
if (padmgr->unk_2AE[i] == temp)
{
if (padmgr->unk_2B2[i] != 0)
{
if (padmgr->unk_2B6[i] < 3)
{
osSyncPrintf(D_80145894); //"\x1b[33m" (probably formatting/debugger interface)
osSyncPrintf(D_8014589C, i + 1, D_801458B0); //"padmgr: %d[JPN]Con: ", "[JPN]Vibration pack jumble jumble"
osSyncPrintf(D_801458CC); //"\x1b[m" (probably formatting/debugger interface)
if (osSetVibration(&padmgr->unk_controller[i], 1) != 0)
osSyncPrintf(VT_FGCOL(YELLOW));
osSyncPrintf("padmgr: %dコン: %s\n", i + 1, "振動パック ぶるぶるぶるぶる");
osSyncPrintf(VT_RST);
if (osSetVibration(&padmgr->unk_controller[i], temp) != 0)
{
padmgr->unk_2AE[i] = 0;
osSyncPrintf(D_801458D0);
osSyncPrintf(D_801458D8, i + 1, D_801458EC); //"A communication error has occurred with the vibraton pack"
osSyncPrintf(D_80145914);
osSyncPrintf(VT_FGCOL(YELLOW));
osSyncPrintf("padmgr: %dコン: %s\n", i + 1, "振動パックで通信エラーが発生しました");
osSyncPrintf(VT_RST);
}
else
{
padmgr->unk_2B6[i] = 3;
}
var1 = 1;
}
}
@ -90,20 +100,22 @@ void func_800C740C(PadMgr* padmgr)
{
if (padmgr->unk_2B6[i] != 0)
{
osSyncPrintf(D_80145918);
osSyncPrintf(D_80145920, i + 1, D_80145934); //"Stop vibration pack"
osSyncPrintf(D_80145944);
osSyncPrintf(VT_FGCOL(YELLOW));
osSyncPrintf("padmgr: %dコン: %s\n", i + 1, "振動パック 停止");
osSyncPrintf(VT_RST);
if (osSetVibration(&padmgr->unk_controller[i], 0) != 0)
{
padmgr->unk_2AE[i] = 0;
osSyncPrintf(D_80145948);
osSyncPrintf(D_80145950, i + 1, D_80145964); //"A communication error has occurred with the vibration pack"
osSyncPrintf(D_8014598C);
osSyncPrintf(VT_FGCOL(YELLOW));
osSyncPrintf("padmgr: %dコン: %s\n", i + 1, "振動パックで通信エラーが発生しました");
osSyncPrintf(VT_RST);
}
else
{
padmgr->unk_2B6[i]--;
}
var1 = 1;
}
}
@ -115,16 +127,16 @@ void func_800C740C(PadMgr* padmgr)
{
if (padmgr->unk_2AE[i] == 1)
{
osSyncPrintf(D_80145990);
osSyncPrintf(D_80145998, i + 1, D_801459AC); //"Vibration pack seems to be pulled out"
osSyncPrintf(D_801459CC);
osSyncPrintf(VT_FGCOL(YELLOW));
osSyncPrintf("padmgr: %dコン: %s\n", i + 1, "振動パックが抜かれたようです");
osSyncPrintf(VT_RST);
padmgr->unk_2AE[i] = 0;
}
else
{
osSyncPrintf(D_801459D0);
osSyncPrintf(D_80145A24);
osSyncPrintf(D_801459D8, i + 1, D_801459EC); //"It seems that a controller pack that is not a vibration pack was pulled out"
osSyncPrintf(VT_FGCOL(YELLOW));
osSyncPrintf("padmgr: %dコン: %s\n", i + 1, "振動パックではないコントローラパックが抜かれたようです");
osSyncPrintf(VT_RST);
padmgr->unk_2AE[i] = 0;
}
}
@ -145,9 +157,9 @@ void func_800C740C(PadMgr* padmgr)
padmgr->unk_2AE[var3] = 1;
osSetVibration(&padmgr->unk_controller[var3], 1);
osSetVibration(&padmgr->unk_controller[var3], 0);
osSyncPrintf(D_80145A28);
osSyncPrintf(D_80145A30, var3 + 1, D_80145A44); //"Recognized vibration pack"
osSyncPrintf(D_80145A60);
osSyncPrintf(VT_FGCOL(YELLOW));
osSyncPrintf("padmgr: %dコン: %s\n", var3 + 1, "振動パックを認識しました");
osSyncPrintf(VT_RST);
}
else if (var4 == 11)
{
@ -155,12 +167,11 @@ void func_800C740C(PadMgr* padmgr)
}
else if (var4 == 4)
{
LogUtils_LogThreadId(D_80145A64, 282);
++D_8012D284;
osSyncPrintf(D_80145A70, D_8012D284); //"++errcnt = %d"
osSyncPrintf(D_80145A80);
osSyncPrintf(D_80145A88, var3 + 1, D_80145A9C); //"Controller pack communication error"
osSyncPrintf(D_80145ABC);
LogUtils_LogThreadId("../padmgr.c", 282);
osSyncPrintf("++errcnt = %d\n", ++D_8012D284);
osSyncPrintf(VT_FGCOL(YELLOW));
osSyncPrintf("padmgr: %dコン: %s\n", var3 + 1, "コントローラパックの通信エラー");
osSyncPrintf(VT_RST);
}
}
}
@ -169,6 +180,8 @@ void func_800C740C(PadMgr* padmgr)
PadMgr_UnlockReleaseControllerQueue(padmgr, ctrlrqueue);
}
#else
u32 D_8012D284 = 0;
u32 D_8016A4F0;
#pragma GLOBAL_ASM("asm/non_matchings/code/padmgr/func_800C740C.s")
#endif
@ -186,10 +199,10 @@ void func_800C7818(PadMgr* padmgr)
{
if ((gFaultStruct.msgId == 0) && (padmgr->unk_45D != 0))
{
osSyncPrintf("\x1b[33m");
osSyncPrintf(VT_FGCOL(YELLOW));
//EUC-JP: コン | 'Con'? , EUC-JP: 振動パック 停止 | Stop vibration pack
osSyncPrintf("padmgr: %dコン: %s\n", i + 1, "振動パック 停止");
osSyncPrintf("\x1b[m");
osSyncPrintf(VT_RST);
}
osSetVibration(&padmgr->unk_controller[i], 0);
@ -211,7 +224,8 @@ void func_800C7934(PadMgr* padmgr, u32 a1, u32 a2)
}
#ifdef NON_MATCHING
//func_800A23CC in 1.0
// minor ordering difference
// 800A23CC in 1.0
void func_800C7948(PadMgr* padmgr, u8* a1)
{
padmgr->unk_2B2[0] = a1[0];

View file

@ -6,7 +6,7 @@ void TitleSetup_InitImpl(GameState* gameState)
osSyncPrintf("ゼルダ共通データ初期化\n");
SaveContext_Init();
gameState->running = false;
gameState->init = func_80800878; gameState->size = sizeof(TitleContext);
gameState->init = Title_Init; gameState->size = sizeof(TitleContext);
}
void TitleSetup_Destroy(GameState* gameState)

View file

@ -3763,7 +3763,7 @@ void Actor_SetTextWithPrefix(GlobalContext* globalCtx, Actor* actor, s16 baseTex
case SCENE_HAKADAN_BS:
case SCENE_KAKARIKO:
case SCENE_KAKARIKO3:
case SCENE_BACK_ALLEY:
case SCENE_IMPA:
case SCENE_HUT:
case SCENE_HAKAANA:
case SCENE_HAKASITARELAY:
@ -4332,7 +4332,7 @@ s16 func_80034DD4(Actor* actor, GlobalContext* globalCtx, s16 arg2, f32 arg3)
if (arg3 < var)
{
actor->flags &= ~0x1;
actor->flags &= ~1;
Math_SmoothScaleMaxMinS(&arg2, 0, 6, 0x14, 1);
}
else
@ -4415,35 +4415,7 @@ s32 func_80035124(Actor* actor, GlobalContext* globalCtx)
return ret;
}
/* z_cheap_proc.c */
void Draw_DListOpa(GlobalContext* globalCtx, u32 dlist)
{
GraphicsContext* gfxCtx = globalCtx->state.gfxCtx;
Gfx* gfxArr[4];
func_800C6AC4(gfxArr, globalCtx->state.gfxCtx, "../z_cheap_proc.c", 214);
func_80093D18(globalCtx->state.gfxCtx);
gSPMatrix(gfxCtx->polyOpa.p++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_cheap_proc.c", 216), G_MTX_MODELVIEW | G_MTX_LOAD);
gSPDisplayList(gfxCtx->polyOpa.p++, dlist);
func_800C6B54(gfxArr, globalCtx->state.gfxCtx, "../z_cheap_proc.c", 219);
}
void Draw_DListXlu(GlobalContext* globalCtx, u32 dlist)
{
GraphicsContext* gfxCtx = globalCtx->state.gfxCtx;
Gfx* gfxArr[4];
func_800C6AC4(gfxArr, globalCtx->state.gfxCtx, "../z_cheap_proc.c", 228);
func_80093D84(globalCtx->state.gfxCtx);
gSPMatrix(gfxCtx->polyXlu.p++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_cheap_proc.c", 230), G_MTX_MODELVIEW | G_MTX_LOAD);
gSPDisplayList(gfxCtx->polyXlu.p++, dlist);
func_800C6B54(gfxArr, globalCtx->state.gfxCtx, "../z_cheap_proc.c", 233);
}
#include "z_cheap_proc.c"
u8 func_800353E8(GlobalContext* globalCtx)
{

View file

@ -232,8 +232,9 @@ void func_80044340(Camera *camera, Vec3f *b, Vec3f *c)
*c = sp20.unk_00;
}
#ifdef NON_MATCHING
f32 func_80038B7C();
#ifdef NON_MATCHING
// ordering
s32 func_800443A0(Camera *camera, Vec3f *b, Vec3f *c)
{
@ -449,17 +450,16 @@ f32 func_80045714(Vec3f *a, s16 b, s16 c, f32 arg3);
#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_80045714.s")
#endif
#ifdef NON_MATCHING
f32 func_8007C0A8(f32, f32);
// CLOSE: stack is slightly off, probably a temp var
s32 func_800457A8(Camera *camera, struct_80045714 *b, f32 c, s16 d)
{
f32 unused;
Vec3f sp50;
Vec3f sp44;
s32 unused2;
f32 temp_ret;
PosRot *sp2C;
f32 temp_ret;
temp_ret = func_8002DC84(camera->player);
@ -481,13 +481,11 @@ s32 func_800457A8(Camera *camera, struct_80045714 *b, f32 c, s16 d)
return 1;
}
#else
#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_800457A8.s")
#endif
f32 func_8007C028(Vec3f *, Vec3f *);
#ifdef NON_MATCHING
f32 func_8007C028(Vec3f *, Vec3f *);
// CLOSE: regalloc, plus stack is slightly off, probably a temp var
// CLOSE: regalloc
s32 func_800458D4(Camera *camera, struct_80045714 *b, f32 c, f32 *d, s16 e)
{
f32 phi_f2;
@ -496,7 +494,7 @@ s32 func_800458D4(Camera *camera, struct_80045714 *b, f32 c, f32 *d, s16 e)
f32 temp_ret;
PosRot *temp_s1;
f32 sp48;
Vec3f sp3C; // unused
s32 pad[2];
sp60.y = func_8002DC84(camera->player) + c;
sp60.x = 0.0f;
@ -631,7 +629,6 @@ s32 func_80045C74(Camera *camera, struct_80045714 *b, f32 c, f32 *d, s16 arg4)
phi_f16 = 1.0f - sinf(OREG(33) * (M_PI / 180) - temp_ret_3);
else
phi_f16 = 1.0f;
}
sp70.y -= temp * phi_f16;
}
@ -881,51 +878,43 @@ void Camera_Vec3fCopy(Vec3f *src, Vec3f *dst)
// 225 lines
#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_80057C6C.s")
#ifdef NON_MATCHING
// still needs a bit of work, but should be functionally equivalent
s32 func_8005AD40(Camera *camera, s32 a, s16 b, f32 c, s16 d, s16 e, s16 f);
void func_80057FC4(Camera *camera)
{
if (camera != &camera->globalCtx->cameraCtx.activeCameras[0])
{
camera->unk_142 = 33;
camera->unk_154 = camera->unk_142 = 33;
camera->unk_14C &= ~0x4;
camera->unk_154 = camera->unk_142; // compiler uses the same temp reg, but it should load from 142 right after being saved to
// maybe try camera->unk_154 = camera->unk_142 = 33 and make them have differing signs?
return;
}
// try putting these in a bunch of if else statements
if (*camera->globalCtx->roomCtx.curRoom.unk_08 != 1)
else if (camera->globalCtx->roomCtx.curRoom.mesh->polygon.type != 1)
{
if (camera->globalCtx->roomCtx.curRoom.unk_03 != 0)
switch (camera->globalCtx->roomCtx.curRoom.unk_03)
{
if (camera->globalCtx->roomCtx.curRoom.unk_03 == 1)
{
case 1:
func_8005AD40(camera, 0, -99, 0, 0, 18, 10);
camera->unk_142 = 3;
camera->unk_154 = camera->unk_142;
return;
}
osSyncPrintf("camera: room type: default set etc (%d)\n", camera->globalCtx->roomCtx.curRoom.unk_03);
func_8005AD40(camera, 0, -99, 0, 0, 18, 10);
camera->unk_142 = 1;
camera->unk_154 = camera->unk_142;
return;
camera->unk_154 = camera->unk_142 = 3;
break;
case 0:
osSyncPrintf("camera: room type: default set field\n");
func_8005AD40(camera, 0, -99, 0, 0, 18, 10);
camera->unk_154 = camera->unk_142 = 1;
break;
default:
osSyncPrintf("camera: room type: default set etc (%d)\n", camera->globalCtx->roomCtx.curRoom.unk_03);
func_8005AD40(camera, 0, -99, 0, 0, 18, 10);
camera->unk_154 = camera->unk_142 = 1;
camera->unk_14C |= 4;
break;
}
osSyncPrintf("camera: room type: default set field\n");
func_8005AD40(camera, 0, -99, 0, 0, 18, 10);
camera->unk_142 = 1;
camera->unk_14C |= 4;
camera->unk_154 = camera->unk_142;
return;
}
osSyncPrintf("camera: room type: prerender\n");
camera->unk_142 = 0x21;
camera->unk_14C &= 0xfffb;
camera->unk_154 = camera->unk_142;
else
{
osSyncPrintf("camera: room type: prerender\n");
camera->unk_154 = camera->unk_142 = 33;
camera->unk_14C &= ~0x4;
}
}
#else
#pragma GLOBAL_ASM("asm/non_matchings/code/z_camera/func_80057FC4.s")
#endif
void Camera_Stub80058140(Camera *camera)
{
@ -1093,7 +1082,7 @@ s16 func_8005AD1C(Camera *camera, s16 b)
return camera->unk_14C;
}
s32 func_8005AD40(Camera *camera, s32 a, s16 b, s16 c, s16 d, s16 e, s16 f)
s32 func_8005AD40(Camera *camera, s32 a, s16 b, f32 c, s16 d, s16 e, s16 f)
{
if ((camera->unk_142 == 43) || (camera->unk_142 == 29))
return 0;

30
src/code/z_cheap_proc.c Normal file
View file

@ -0,0 +1,30 @@
#include <ultra64.h>
#include <global.h>
void Draw_DListOpa(GlobalContext* globalCtx, u32 dlist)
{
GraphicsContext* gfxCtx = globalCtx->state.gfxCtx;
Gfx* gfxArr[4];
func_800C6AC4(gfxArr, globalCtx->state.gfxCtx, "../z_cheap_proc.c", 214);
func_80093D18(globalCtx->state.gfxCtx);
gSPMatrix(gfxCtx->polyOpa.p++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_cheap_proc.c", 216), G_MTX_MODELVIEW | G_MTX_LOAD);
gSPDisplayList(gfxCtx->polyOpa.p++, dlist);
func_800C6B54(gfxArr, globalCtx->state.gfxCtx, "../z_cheap_proc.c", 219);
}
void Draw_DListXlu(GlobalContext* globalCtx, u32 dlist)
{
GraphicsContext* gfxCtx = globalCtx->state.gfxCtx;
Gfx* gfxArr[4];
func_800C6AC4(gfxArr, globalCtx->state.gfxCtx, "../z_cheap_proc.c", 228);
func_80093D84(globalCtx->state.gfxCtx);
gSPMatrix(gfxCtx->polyXlu.p++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_cheap_proc.c", 230), G_MTX_MODELVIEW | G_MTX_LOAD);
gSPDisplayList(gfxCtx->polyXlu.p++, dlist);
func_800C6B54(gfxArr, globalCtx->state.gfxCtx, "../z_cheap_proc.c", 233);
}

View file

@ -1,20 +1,309 @@
#include <ultra64.h>
#include <global.h>
#include <z64.h>
#include <color.h>
#include <regs.h>
#include <PR/os_cont.h>
#pragma GLOBAL_ASM("asm/non_matchings/code/z_debug/func_800636C0.s")
typedef struct
{
u8 x;
u8 y;
u8 colorId;
char text[0x15];
} PrintTextBuffer;
void func_8006375C(UNK_TYPE arg0, UNK_TYPE arg1, UNK_TYPE arg2)
typedef struct
{
u16 push;
u16 held;
} InputCombo;
GameInfo* gGameInfo;
int D_8015FA94; //no known symbols
PrintTextBuffer D_8015FA98[0x16];
s16 D_8011E0B0 = 0; //PrintTextBuffer index
Color_RGBA8 printTextColors[] = {
{ 0xFF, 0xFF, 0x20, 0xC0 },
{ 0xFF, 0x96, 0x80, 0xC0 },
{ 0x80, 0x60, 0x00, 0x40 },
{ 0xC0, 0x80, 0x10, 0x80 },
{ 0xFF, 0xC0, 0x20, 0x80 },
{ 0xE6, 0xE6, 0xDC, 0x40 },
{ 0x80, 0x96, 0xFF, 0x80 },
{ 0x80, 0xFF, 0x20, 0x80 },
};
InputCombo inputCombos[REG_GROUPS] = {
{ L_TRIG, U_CBUTTONS },
{ L_TRIG, L_CBUTTONS },
{ L_TRIG, D_CBUTTONS },
{ L_TRIG, A_BUTTON },
{ R_TRIG, D_CBUTTONS },
{ L_TRIG, R_CBUTTONS },
{ L_TRIG, R_TRIG },
{ L_TRIG, L_JPAD },
{ L_TRIG, R_JPAD },
{ L_TRIG, U_JPAD },
{ L_TRIG, B_BUTTON },
{ L_TRIG, Z_TRIG },
{ L_TRIG, D_JPAD },
{ R_TRIG, A_BUTTON },
{ R_TRIG, B_BUTTON },
{ R_TRIG, Z_TRIG },
{ R_TRIG, L_TRIG },
{ R_TRIG, U_CBUTTONS },
{ R_TRIG, R_CBUTTONS },
{ R_TRIG, L_JPAD },
{ R_TRIG, L_CBUTTONS },
{ R_TRIG, START_BUTTON },
{ L_TRIG, START_BUTTON },
{ R_TRIG, R_JPAD },
{ R_TRIG, U_JPAD },
{ START_BUTTON, R_TRIG },
{ START_BUTTON, A_BUTTON },
{ START_BUTTON, B_BUTTON },
{ START_BUTTON, R_CBUTTONS },
};
char regChar[] = " SOPQMYDUIZCNKXcsiWAVHGmnBdkb";
//initialize GameInfo
void func_800636C0()
{
s32 i;
gGameInfo = (GameInfo*)SystemArena_MallocDebug(sizeof(GameInfo), "../z_debug.c", 260);
gGameInfo->regPage = 0;
gGameInfo->regGroup = 0;
gGameInfo->regCur = 0;
gGameInfo->dpadLast = 0;
gGameInfo->repeat = 0;
for (i = 0; i < ARRAY_COUNT(gGameInfo->data); i++)
{
gGameInfo->data[i] = 0;
}
}
//Called when free movement is active.
//8011D394 to enable camera debugger
void func_8006375C(s32 arg0, s32 arg1, float* d_80855320)
{
}
#ifdef NON_MATCHING //regalloc
//Copy Camera Debugger Text
void func_8006376C(u8 x, u8 y, u8 colorId, const char* text)
{
PrintTextBuffer* buf;
char* bufText;
s16 i; //v1
buf = &D_8015FA98[D_8011E0B0];
if (D_8011E0B0 < 0x16) {
buf->x = x;
buf->y = y;
buf->colorId = colorId;
i = 0;
bufText = buf->text + 1;
if (*buf->text = *text++) {
do if (i++ > 0x14) {
break;
} while (*bufText++ = *text++);
}
*bufText = '\0';
D_8011E0B0++;
}
}
#else
#pragma GLOBAL_ASM("asm/non_matchings/code/z_debug/func_8006376C.s")
#endif
#pragma GLOBAL_ASM("asm/non_matchings/code/z_debug/func_80063828.s")
//Draw Text
void func_80063828(GfxPrint* gfxPrint)
{
s32 i;
Color_RGBA8* color;
PrintTextBuffer* buffer;
char* text;
#pragma GLOBAL_ASM("asm/non_matchings/code/z_debug/func_8006390C.s")
i = 0;
if (D_8011E0B0 > 0)
{
do
{
buffer = &D_8015FA98[i];
text = buffer->text;
#pragma GLOBAL_ASM("asm/non_matchings/code/z_debug/func_80063C04.s")
color = &printTextColors[buffer->colorId];
GfxPrint_SetColor(gfxPrint, color->r, color->g, color->b, color->a);
GfxPrint_SetPos(gfxPrint, buffer->x, buffer->y);
GfxPrint_Printf(gfxPrint, "%s", text);
i += 1;
} while (i < D_8011E0B0);
}
}
#pragma GLOBAL_ASM("asm/non_matchings/code/z_debug/func_80063D7C.s")
//Edit REG
void func_8006390C(Input* input) {
s32 dpad;
s32 regGroup;
s32 increment;
InputCombo* input_combo;
s32 i;
regGroup = (gGameInfo->regGroup * REG_PAGES + gGameInfo->regPage) * REG_PER_PAGE - REG_PER_PAGE;
dpad = input->raw.pad & 0xF00;
if (!~(input->raw.pad | ~L_TRIG) ||
!~(input->raw.pad | ~R_TRIG) ||
!~(input->raw.pad | ~START_BUTTON)) {
input_combo = inputCombos;
for (i = 0; i < REG_GROUPS; i++)
{
if (~(~input_combo->push | input->raw.pad) ||
~(~input_combo->held | input->padPressed)) {
input_combo++;
}
else
break;
}
if (i < REG_GROUPS) {
if (i == gGameInfo->regGroup) {
gGameInfo->regPage = (gGameInfo->regPage + 1) % (REG_PAGES + 1);
return;
}
gGameInfo->regGroup = i;
gGameInfo->regPage = 0;
}
}
else {
switch (gGameInfo->regPage - 1)
{
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
if (dpad == gGameInfo->dpadLast) {
gGameInfo->repeat--;
if (gGameInfo->repeat < 0) {
gGameInfo->repeat = 1;
}
else {
dpad ^= gGameInfo->dpadLast;
}
}
else {
gGameInfo->repeat = 0x10;
gGameInfo->dpadLast = dpad;
}
increment =
(dpad & R_JPAD) ? (
!~(input->raw.pad | ~(A_BUTTON | B_BUTTON)) ? 1000 :
!~(input->raw.pad | ~A_BUTTON) ? 100 :
!~(input->raw.pad | ~B_BUTTON) ? 10 : 1) :
(dpad & L_JPAD) ? (
!~(input->raw.pad | ~(A_BUTTON | B_BUTTON)) ? -1000 :
!~(input->raw.pad | ~A_BUTTON) ? -100 :
!~(input->raw.pad | ~B_BUTTON) ? -10 : -1) :
0;
gGameInfo->data[gGameInfo->regCur + regGroup] += increment;
if (dpad & U_JPAD) {
gGameInfo->regCur--;
if (gGameInfo->regCur < 0) {
gGameInfo->regCur = REG_PER_PAGE - 1;
}
}
else if (dpad & D_JPAD) {
gGameInfo->regCur++;
if (gGameInfo->regCur >= REG_PER_PAGE) {
gGameInfo->regCur = 0;
}
}
if (iREG(0)) {
iREG(0) = 0;
func_800AA000(0, iREG(1), iREG(2), iREG(3));
}
}
}
}
//Draw Memory Viewer
void func_80063C04(GfxPrint* gfxPrint)
{
s32 i;
s32 page;
s32 regGroup;
s32 test; //removing affects stack
char name[3];
page = (gGameInfo->regPage * REG_PER_PAGE) - REG_PER_PAGE;
regGroup = (gGameInfo->regGroup * REG_PAGES + gGameInfo->regPage) * REG_PER_PAGE - REG_PER_PAGE;
//set up register name string
name[0] = 'R';
name[1] = regChar[gGameInfo->regGroup]; //r_group type char
name[2] = '\0';
GfxPrint_SetColor(gfxPrint, 0, 0x80, 0x80, 0x80);
for (i = 0; i != REG_PER_PAGE; i++)
{
if (i == gGameInfo->regCur)
{
GfxPrint_SetColor(gfxPrint, 0, 0xff, 0xff, 0xff);
}
GfxPrint_SetPos(gfxPrint, 3, i + 5);
GfxPrint_Printf(gfxPrint, "%s%02d%6d", &name, page + i, gGameInfo->data[i + regGroup]);
if (i == gGameInfo->regCur)
{
GfxPrint_SetColor(gfxPrint, 0, 0x80, 0x80, 0x80);
}
}
}
void func_80063D7C(GraphicsContext* gfxCtx) {
Gfx* sp7C;
Gfx* sp78;
Gfx* tempRet;
void* unk2[6];
GfxPrint gfxPrint;
void* unk[2];
Gfx* dlFrame[4]; //stores state of GfxCtx next ptrs
func_800C6AC4(&dlFrame, gfxCtx, "../z_debug.c", 628);
GfxPrint_Ctor(&gfxPrint);
sp78 = gfxCtx->polyOpa.p;
tempRet = func_800C6C20(gfxCtx->polyOpa.p);
gSPDisplayList(gfxCtx->overlay.p++, tempRet);
GfxPrint_Open(&gfxPrint, tempRet);
if ((OREG(0) == 1) || (OREG(0) == 8)) {
func_80063828(&gfxPrint);
}
if (gGameInfo->regPage != 0) {
func_80063C04(&gfxPrint);
}
D_8011E0B0 = 0;
sp7C = GfxPrint_Close(&gfxPrint);
gSPEndDisplayList(sp7C++);
func_800C6C28(sp78, sp7C);
gfxCtx->polyOpa.p = sp7C;
if (0);
func_800C6B54(&dlFrame, gfxCtx, "../z_debug.c", 664);
GfxPrint_Dtor(&gfxPrint);
}

View file

@ -1,20 +1,17 @@
#include <ultra64.h>
#include <global.h>
#ifdef NON_MATCHING
void Lib_MemSet(void* dest, size_t size, u8 val)
void Lib_MemSet(u8* dest, size_t size, u8 val)
{
u8* destu = dest;
u32 i;
u32 i = 0;
for (i = 0; i < size; i++)
{
*destu++ = val;
}
// TODO: Convert this to while/for if possible
if (i == size) return;
do {
*dest++ = val;
i++;
} while (i != size);
}
#else
#pragma GLOBAL_ASM("asm/non_matchings/code/z_lib/Lib_MemSet.s")
#endif
f32 Math_Coss(s16 angle)
{
@ -559,15 +556,12 @@ f32 func_800784D8(f32* pValue, f32 target, f32 scale, f32 maxStep, f32 minStep)
return step;
}
#ifdef NON_MATCHING
// regalloc differences
s16 Math_SmoothScaleMaxMinS(s16* pValue, s16 target, s16 invScale, s16 maxStep, s16 minStep)
{
s16 step = 0;
s16 diff = (target - *pValue);
s32 baseStep;
s16 step;
baseStep = diff / invScale;
s32 baseStep = diff / invScale;
if (*pValue != target)
{
@ -604,9 +598,6 @@ s16 Math_SmoothScaleMaxMinS(s16* pValue, s16 target, s16 invScale, s16 maxStep,
return diff;
}
#else
#pragma GLOBAL_ASM("asm/non_matchings/code/z_lib/Math_SmoothScaleMaxMinS.s")
#endif
void Math_SmoothScaleMaxS(s16* pValue, s16 target, s16 invScale, s16 maxStep)
{

View file

@ -72,7 +72,7 @@ RestrictionFlags sRestrictionFlags[] =
{ SCENE_KOKIRI_HOME5, 0x10, 0x10, 0x15 },
{ SCENE_MALON_STABLE, 0x10, 0x10, 0x15 },
{ SCENE_HUT, 0x10, 0x10, 0x15 },
{ SCENE_BACK_ALLEY, 0x10, 0x10, 0x15 },
{ SCENE_IMPA, 0x10, 0x10, 0x15 },
{ SCENE_LABO, 0x10, 0x10, 0x15 },
{ SCENE_HYLIA_LABO, 0x00, 0x10, 0x15 },
{ SCENE_TENT, 0x10, 0x10, 0x15 },

View file

@ -6,6 +6,8 @@
#include "z_demo_go.h"
#include <vt.h>
#define ROOM 0x00
#define FLAGS 0x00000010
@ -25,7 +27,7 @@ void func_8097D130(DemoGo* this, GlobalContext* globalCtx);
void func_8097D290(DemoGo* this, GlobalContext* globalCtx);
void func_8097D29C(DemoGo* this, GlobalContext* globalCtx);
u32 D_8097D440[] = {0x0600CE80, 0x0600D280, 0x0600D680};
UNK_PTR D_8097D440[] = {0x0600CE80, 0x0600D280, 0x0600D680};
ActorFunc D_8097D44C[] =
{
@ -58,9 +60,10 @@ const ActorInit Demo_Go_InitVars =
(ActorFunc)DemoGo_Draw,
};
extern u32 D_060029A8;
extern u32 D_0600FEF0;
extern u32 D_06004930;
extern UNK_TYPE D_060029A8;
extern UNK_TYPE D_06004930;
extern UNK_TYPE D_0600E680;
extern UNK_TYPE D_0600FEF0;
UNK_TYPE func_8097C870(DemoGo *this)
{
@ -149,33 +152,36 @@ void func_8097CA78(DemoGo* this, GlobalContext* globalCtx)
func_8097C9B8(this);
}
// Not equivalent, I believe in part due to actorAction->endPos being the wrong type, holding floats instead of ints
#ifdef NON_MATCHING
void func_8097CB0C(DemoGo* this, GlobalContext* globalCtx) {
void func_8097CB0C(DemoGo* this, GlobalContext* globalCtx)
{
Actor* thisx = &this->actor;
PosRot* posRot = &thisx->posRot;
CutsceneContext* csCtx = &globalCtx->csCtx;
Vec3f startPos;
f32 temp_ret;
CsCmdActorAction* actorAction;
f32 temp_ret;
s32 pad;
Vec3f startPos;
Vec3f endPos;
if (globalCtx->csCtx.state != 0)
{
actorAction = csCtx->actorActions[func_8097C870(this)];
if (actorAction != 0)
if (actorAction != NULL)
{
temp_ret = func_8006F93C(actorAction->endFrame, actorAction->startFrame, csCtx->frames);
startPos = actorAction->startPos;
thisx->posRot.pos.x = (((actorAction->endPos.x - startPos.x) * temp_ret) + startPos.x);
thisx->posRot.pos.y = (((actorAction->endPos.y - startPos.y) * temp_ret) + startPos.y);
thisx->posRot.pos.z = (((actorAction->endPos.z - startPos.z) * temp_ret) + startPos.z);
thisx->shape.rot.y = actorAction->rot.y;
thisx->posRot.rot.y = actorAction->rot.y;
startPos.x = actorAction->startPos.x;
startPos.y = actorAction->startPos.y;
startPos.z = actorAction->startPos.z;
endPos.x = actorAction->endPos.x;
endPos.y = actorAction->endPos.y;
endPos.z = actorAction->endPos.z;
posRot->pos.x = (((endPos.x - startPos.x) * temp_ret) + startPos.x);
posRot->pos.y = (((endPos.y - startPos.y) * temp_ret) + startPos.y);
posRot->pos.z = (((endPos.z - startPos.z) * temp_ret) + startPos.z);
posRot->rot.y = thisx->shape.rot.y = actorAction->rot.y;
}
}
}
#else
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Demo_Go/func_8097CB0C.s")
#endif
void func_8097CC08(DemoGo* this)
{
@ -207,7 +213,7 @@ void func_8097CCE0(DemoGo* this, GlobalContext* globalCtx)
if (globalCtx->csCtx.state != 0)
{
actorAction = globalCtx->csCtx.actorActions[func_8097C870(this)];
if (actorAction != 0)
if (actorAction != NULL)
{
thisRotY = thisx->posRot.rot.y;
rotYDelta = actorAction->rot.y - thisRotY;
@ -234,15 +240,15 @@ UNK_TYPE DemoGo_FrameUpdateMatrix(DemoGo* this)
return SkelAnime_FrameUpdateMatrix(&this->skelAnime);
}
// This is probably at least close to equivalent but not necessarily so
#ifdef NON_MATCHING
UNK_TYPE func_8097CDB0(DemoGo* this, GlobalContext* globalCtx, u16 csCmdActorAction)
// return value isn't produced in the same way
s32 func_8097CDB0(DemoGo* this, GlobalContext* globalCtx, u16 csCmdActorAction)
{
CutsceneContext* csCtx = &globalCtx->csCtx;
CsCmdActorAction* actorAction = csCtx->actorActions[func_8097C870(this)];
if (csCtx->state != 0)
{
if (actorAction != 0 && actorAction->action == csCmdActorAction)
if (actorAction != NULL && actorAction->action == csCmdActorAction)
{
return 1;
}
@ -277,7 +283,7 @@ void func_8097CE78(DemoGo* this, GlobalContext* globalCtx)
if (globalCtx->csCtx.state != 0)
{
actorAction = csCtx->actorActions[func_8097C870(this)];
if (actorAction != 0 && csCtx->frames >= actorAction->endFrame)
if (actorAction != NULL && csCtx->frames >= actorAction->endFrame)
{
func_8097CA78(this, globalCtx);
this->action = 3;
@ -369,7 +375,7 @@ void DemoGo_Update(DemoGo* this, GlobalContext* globalCtx)
{
if (this->action < 0 || this->action >= 7 || D_8097D44C[this->action] == 0)
{
osSyncPrintf("メインモードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n");
osSyncPrintf(VT_FGCOL(RED) "メインモードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST);
return;
}
D_8097D44C[this->action](this, globalCtx);
@ -391,32 +397,31 @@ void func_8097D290(DemoGo* this, GlobalContext* globalCtx)
}
// Not equivalent yet - the gSPSegment calls are probably the main issue
#ifdef NON_MATCHING
extern u32 D_0600E680;
void func_8097D29C(DemoGo* this, GlobalContext* globalCtx)
{
u32 addr = D_8097D440[this->unk_190];
GraphicsContext* gfxCtx = &globalCtx->state.gfxCtx;
s32 pad;
s16 temp = this->unk_190;
SkelAnime* skelAnime = &this->skelAnime;
void* srcSegment8 = D_8097D440[temp];
void* srcSegment9 = &D_0600E680;
GraphicsContext* gfxCtx = globalCtx->state.gfxCtx;
Gfx* gfxArr[4];
func_800C6AC4(gfxArr, globalCtx->state.gfxCtx, "../z_demo_go.c", 732);
func_80093D18(globalCtx->state.gfxCtx);
gSPSegment(gfxCtx->polyOpa.p++, 0x08, SEGMENTED_TO_VIRTUAL(srcSegment8));
gSPSegment(gfxCtx->polyOpa.p++, 0x09, SEGMENTED_TO_VIRTUAL(srcSegment9));
gSPSegment(gfxCtx->polyOpa.p++, 0x08, SEGMENTED_TO_VIRTUAL(addr));
gSPSegment(gfxCtx->polyOpa.p++, 0x09, SEGMENTED_TO_VIRTUAL(D_0600E680));
func_800A1AC8(globalCtx, skelAnime->limbIndex, skelAnime->actorDrawTbl, skelAnime->dListCount, NULL, NULL, &this->actor);
func_800A1AC8(globalCtx, this->skelAnime.limbIndex, this->skelAnime.actorDrawTbl, this->skelAnime.dListCount, 0, 0, &this->actor);
func_800C6B54(gfxArr, globalCtx->state.gfxCtx, "../z_demo_go.c", 746);
}
#else
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Demo_Go/func_8097D29C.s")
#endif
void DemoGo_Draw(DemoGo* this, GlobalContext* globalCtx) {
if (this->drawConfig < 0 || this->drawConfig >= 2 || D_8097D468[this->drawConfig] == 0)
{
osSyncPrintf("描画モードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n");
osSyncPrintf(VT_FGCOL(RED) "描画モードがおかしい!!!!!!!!!!!!!!!!!!!!!!!!!\n" VT_RST);
return;
}
D_8097D468[this->drawConfig](this, globalCtx);

View file

@ -8,7 +8,6 @@ typedef struct
{
/* 0x0000 */ Actor actor;
/* 0x014C */ SkelAnime skelAnime;
/* 0x018C */ char unk_18C[0x4];
/* 0x0190 */ s16 unk_190;
/* 0x0192 */ s16 unk_192;
/* 0x0194 */ s32 action;

View file

@ -1,14 +1,25 @@
/*
* File: z_door_ana.c
* Overlay: ovl_Door_Ana
* Description: Grottos Entrances/Exits
*/
#include "z_door_ana.h"
#define ROOM 0x00
#define FLAGS 0x02000000
void DoorAna_Init(DoorAna* this, GlobalContext* globalCtx);
void DoorAna_Destroy(DoorAna* this, GlobalContext* globalCtx);
void DoorAna_Update(DoorAna* this, GlobalContext* globalCtx);
void DoorAna_Draw(DoorAna* this, GlobalContext* globalCtx);
static void DoorAna_Init(DoorAna* this, GlobalContext* globalCtx);
static void DoorAna_Destroy(DoorAna* this, GlobalContext* globalCtx);
static void DoorAna_Update(DoorAna* this, GlobalContext* globalCtx);
static void DoorAna_Draw(DoorAna* this, GlobalContext* globalCtx);
static void DoorAna_SetupAction(DoorAna* this, ActorFunc func);
static void DoorAna_Update_Hidden(DoorAna* this, GlobalContext* globalCtx);
static void DoorAna_Update_Open(DoorAna* this, GlobalContext* globalCtx);
static void DoorAna_Update_Entering(DoorAna* this, GlobalContext* globalCtx);
/*
const ActorInit Door_Ana_InitVars =
{
ACTOR_DOOR_ANA,
@ -22,19 +33,186 @@ const ActorInit Door_Ana_InitVars =
(ActorFunc)DoorAna_Update,
(ActorFunc)DoorAna_Draw,
};
*/
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Door_Ana/func_80993EF0.s")
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Door_Ana/DoorAna_Init.s")
// initial collision data
static ColliderCylinderInit colliderInit =
{
0x0A, 0x00, 0x09, 0x00,
0x00, 0x01, 0x00, 0x00,
0x02, 0x00, 0x00, 0x00,
0x00000000, 0x00, 0x00,
0x00, 0x00, 0x00000048,
0x00, 0x00, 0x00, 0x00,
0x00, 0x01, 0x00, 0x00,
0x0032, 0x000A, 0x0000,
0x0000, 0x0000, 0x0000
};
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Door_Ana/DoorAna_Destroy.s")
// array of entrance table entries to grotto destinations
static s16 entrances[] = {
0x036D, 0x003F, 0x0598, 0x059C,
0x05A0, 0x05A4, 0x05A8, 0x05AC,
0x05B0, 0x05B4, 0x05B8, 0x05BC,
0x05C0, 0x05C4, 0x05FC
};
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Door_Ana/func_80993FEC.s")
// display list
extern Gfx* D_05001390;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Door_Ana/func_80994124.s")
// sets current actionFunc to be ran on next update call
static void DoorAna_SetupAction(DoorAna* this, ActorFunc func)
{
this->actionFunc = func;
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Door_Ana/func_809942D8.s")
static void DoorAna_Init(DoorAna* this, GlobalContext* globalCtx)
{
ColliderCylinderMain* collider;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Door_Ana/DoorAna_Update.s")
this->actor.shape.rot.z = 0;
this->actor.shape.rot.y = this->actor.shape.rot.z;
// init block for grottos that are initially "hidden" (require explosives/hammer/song of storms to open)
if ((this->actor.params & 0x300) != 0)
{
// only allocate collider for grottos that need bombing/hammering open
if ((this->actor.params & 0x200) != 0)
{
collider = &this->collider;
ActorCollider_AllocCylinder(globalCtx, collider);
ActorCollider_InitCylinder(globalCtx, collider, &this->actor, &colliderInit);
}
else
{
this->actor.flags |= 0x10;
}
Actor_SetScale(&this->actor, 0);
DoorAna_SetupAction(this, (ActorFunc)&DoorAna_Update_Hidden);
}
else
{
DoorAna_SetupAction(this, (ActorFunc)&DoorAna_Update_Open);
}
this->actor.unk_1F = 0;
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_Door_Ana/DoorAna_Draw.s")
static void DoorAna_Destroy(DoorAna* this, GlobalContext* globalCtx)
{
// free collider if it has one
if ((this->actor.params & 0x200) != 0)
{
ActorCollider_FreeCylinder(globalCtx, &this->collider);
}
}
// update routine for grottos that are currently "hidden"/unopened
static void DoorAna_Update_Hidden(DoorAna* this, GlobalContext* globalCtx)
{
bool openGrotto = false;
if ((this->actor.params & 0x200) == 0)
{
// opening with song of storms
if (this->actor.waterSurfaceDist < 40000.0f && func_8006C4A4(globalCtx, 5) != 0)
{
openGrotto = true;
this->actor.flags &= ~0x10;
}
}
else
{
// bombing/hammering open a grotto
if ((this->collider.base.collideFlags & 2) != 0)
{
openGrotto = true;
ActorCollider_FreeCylinder(globalCtx, &this->collider);
}
else
{
ActorCollider_Cylinder_Update(&this->actor, &this->collider);
Actor_CollisionCheck_SetAC(globalCtx, &globalCtx->sub_11E60, &this->collider);
}
}
// open the grotto
if (openGrotto)
{
this->actor.params &= ~0x0300;
DoorAna_SetupAction(this, (ActorFunc)&DoorAna_Update_Open);
Audio_PlaySoundGeneral(NA_SE_SY_CORRECT_CHIME, &D_801333D4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
}
func_8002F5F0(&this->actor, globalCtx);
}
// update routine for grottos that are open
static void DoorAna_Update_Open(DoorAna* this, GlobalContext* globalCtx)
{
Player* player;
s32 destinationIdx;
player = PLAYER;
if (Math_ApproxF(&this->actor.scale.x, 0.01f, 0.001f) != 0)
{
if ((this->actor.unk_1F != 0) && (globalCtx->sceneLoadFlag == 0) &&
(player->stateFlags1 & 0x80000000) && (player->unk_84F == 0))
{
destinationIdx = ((this->actor.params >> 0xC) & 7) - 1;
func_800C0AF4(globalCtx, 1, 0x4FF);
gSaveContext.respawn[RESPAWN_MODE_RETURN].pos.y = this->actor.posRot.pos.y;
gSaveContext.respawn[RESPAWN_MODE_RETURN].yaw = this->actor.initPosRot.rot.y;
gSaveContext.respawn[RESPAWN_MODE_RETURN].data = this->actor.params & 0xFFFF;
if (destinationIdx < 0)
{
destinationIdx = this->actor.initPosRot.rot.z + 1;
}
globalCtx->nextEntranceIndex = entrances[destinationIdx];
DoorAna_SetupAction(this, (ActorFunc)&DoorAna_Update_Entering);
}
else
{
if (func_8008E988(globalCtx) == 0 && !(player->stateFlags1 & 0x8800000) &&
this->actor.xzDistanceFromLink <= 15.0f && -50.0f <= this->actor.yDistanceFromLink &&
this->actor.yDistanceFromLink <= 15.0f)
{
player->stateFlags1 |= 0x80000000;
this->actor.unk_1F = 1;
}
else
{
this->actor.unk_1F = 0;
}
}
}
Actor_SetScale(&this->actor, this->actor.scale.x);
}
// update function for after the player has triggered the grotto
static void DoorAna_Update_Entering(DoorAna* this, GlobalContext* globalCtx)
{
Player* player;
if (this->actor.yDistanceFromLink <= 0.0f && 15.0f < this->actor.xzDistanceFromLink)
{
player = PLAYER;
player->actor.posRot.pos.x = Math_Sins(this->actor.rotTowardsLinkY) * 15.0f + this->actor.posRot.pos.x;
player->actor.posRot.pos.z = Math_Coss(this->actor.rotTowardsLinkY) * 15.0f + this->actor.posRot.pos.z;
}
}
static void DoorAna_Update(DoorAna* this, GlobalContext* globalCtx)
{
this->actionFunc(this, globalCtx);
// changes the grottos facing angle based on camera angle
this->actor.shape.rot.y = func_8005A9F4(globalCtx->cameraCtx.activeCameraPtrs[globalCtx->cameraCtx.unk_5C0]) + 0x8000;
}
static void DoorAna_Draw(DoorAna* this, GlobalContext* globalCtx)
{
GraphicsContext* gfxCtx = globalCtx->state.gfxCtx;
Gfx** dList = &D_05001390; // required for stack placement?
Gfx* gfxArr[3];
func_800C6AC4(gfxArr, globalCtx->state.gfxCtx, "../z_door_ana.c", 440);
func_80093D84(globalCtx->state.gfxCtx);
gSPMatrix(gfxCtx->polyXlu.p++, Matrix_NewMtx(globalCtx->state.gfxCtx, "../z_door_ana.c", 446), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPDisplayList(gfxCtx->polyXlu.p++, dList);
func_800C6B54(gfxArr, globalCtx->state.gfxCtx, "../z_door_ana.c", 449);
}

View file

@ -7,7 +7,8 @@
typedef struct
{
/* 0x0000 */ Actor actor;
/* 0x014C */ char unk_14C[0x50];
/* 0x014C */ ColliderCylinderMain collider;
/* 0x0198 */ ActorFunc actionFunc;
} DoorAna; // size = 0x019C
extern const ActorInit Door_Ana_InitVars;

View file

@ -7,6 +7,8 @@
#include <ultra64.h>
#include <global.h>
#include <vt.h>
//temp struct until we can reference other actors outside of their file
typedef struct
{
@ -56,7 +58,7 @@ static void EnAnubiceTag_Init(EnAnubiceTag* this, GlobalContext* globalCtx)
{
osSyncPrintf("\n\n");
//"Anubis control tag generated"
osSyncPrintf("☆☆☆☆☆ アヌビス制御タグ発生 ☆☆☆☆☆ %d\n", this->actor.params);
osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ アヌビス制御タグ発生 ☆☆☆☆☆ %d\n" VT_RST, this->actor.params);
if (this->actor.params < (s16)0xFFFF)
{

View file

@ -11,7 +11,6 @@ typedef struct
{
/* 0x0000 */ Actor actor;
/* 0x014C */ SkelAnime skelAnime;
/* 0x018C */ char unk_18C[0x4];
/* 0x0190 */ ActorFunc updateFunc;
/* 0x0194 */ u32 unk_194;
/* 0x0198 */ s32 unk_198;

View file

@ -231,7 +231,7 @@ static s8 EnDog_CanFollow(EnDog* this, GlobalContext* globalCtx)
gSaveContext.dogParams = (this->actor.params & 0x7FFF);
return 1;
}
return 0;
}
@ -331,8 +331,8 @@ static void EnDog_Init(EnDog* this, GlobalContext* globalCtx)
Actor_Kill(&this->actor);
}
break;
case SCENE_BACK_ALLEY:
// Richard's Home
case SCENE_IMPA:
if ((u32)(this->actor.params & 0x8000) == 0)
{
if (gSaveContext.richardIsLost == 0)

View file

@ -8,7 +8,6 @@ typedef struct
{
/* 0x0000 */ Actor actor;
/* 0x014C */ SkelAnime skelAnime;
/* 0x018C */ char unk_18C[0x4];
/* 0x0190 */ ActorFunc actionFunc;
/* 0x0194 */ ColliderCylinderMain collider;
/* 0x01E0 */ Path* path;

View file

@ -1,14 +1,19 @@
/*
* File: z_en_lightbox.c
* Overlay: ovl_En_Lightbox
* Description:
*/
#include "z_en_lightbox.h"
#define ROOM 0x00
#define FLAGS 0x00000010
void EnLightbox_Init(EnLightbox* this, GlobalContext* globalCtx);
void EnLightbox_Destroy(EnLightbox* this, GlobalContext* globalCtx);
void EnLightbox_Update(EnLightbox* this, GlobalContext* globalCtx);
void EnLightbox_Draw(EnLightbox* this, GlobalContext* globalCtx);
static void EnLightbox_Init(EnLightbox* this, GlobalContext* globalCtx);
static void EnLightbox_Destroy(EnLightbox* this, GlobalContext* globalCtx);
static void EnLightbox_Update(EnLightbox* this, GlobalContext* globalCtx);
static void EnLightbox_Draw(EnLightbox* this, GlobalContext* globalCtx);
/*
const ActorInit En_Lightbox_InitVars =
{
ACTOR_EN_LIGHTBOX,
@ -22,11 +27,105 @@ const ActorInit En_Lightbox_InitVars =
(ActorFunc)EnLightbox_Update,
(ActorFunc)EnLightbox_Draw,
};
*/
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Lightbox/EnLightbox_Init.s")
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Lightbox/EnLightbox_Destroy.s")
extern u32 D_06000B70;
extern u32 D_06001F10;
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Lightbox/EnLightbox_Update.s")
static void EnLightbox_Init(EnLightbox* this, GlobalContext* globalCtx)
{
u32 local_c = 0;
Actor* thisx = &this->dyna.actor;
s32 pad[4];
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Lightbox/EnLightbox_Draw.s")
switch(thisx->params){
case 0:
Actor_SetScale(thisx, 0.025f);
break;
case 1:
Actor_SetScale(thisx, 0.05f);
break;
case 2:
Actor_SetScale(thisx, 0.075f);
break;
case 3:
Actor_SetScale(thisx, 0.1f);
default:
break;
}
thisx->posRot2.pos = thisx->posRot.pos;
thisx->sub_98.unk_10 = 0x1E;
thisx->sub_98.unk_12 = 0x32;
ActorShape_Init(&thisx->shape, 0.0f, ActorShadow_DrawFunc_Circle, 6.0f);
this->dyna.unk_160 = 0;
this->dyna.unk_15C = 0;
thisx->unk_1F = 0;
thisx->gravity = -2.0f;
DynaPolyInfo_Alloc(&D_06001F10, &local_c);
this->dyna.dynaPolyId = DynaPolyInfo_RegisterActor(globalCtx, &globalCtx->colCtx.dyna, thisx, local_c);
}
static void EnLightbox_Destroy(EnLightbox* this, GlobalContext* globalCtx)
{
DynaPolyInfo_Free(globalCtx, &globalCtx->colCtx.dyna, this->dyna.dynaPolyId);
}
static void EnLightbox_Update(EnLightbox* this, GlobalContext* globalCtx)
{
Actor* thisx = &this->dyna.actor;
if (this->dyna.unk_162 != 0)
{
if (func_8002F5A0(thisx, globalCtx))
{
this->dyna.unk_162 = 0;
}
}
else
{
if (func_8002F410(thisx, globalCtx))
{
this->dyna.unk_162++;
}
else
{
if (thisx->speedXZ)
{
if (thisx->bgCheckFlags & 8)
{
thisx->posRot.rot.y = (thisx->posRot.rot.y + thisx->unk_7E) - thisx->posRot.rot.y;
Audio_PlaySoundGeneral(NA_SE_EV_BOMB_BOUND, &thisx->unk_E4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
thisx->speedXZ *= 0.7f;
thisx->bgCheckFlags &= ~0x8;
}
}
if ((thisx->bgCheckFlags & 1) == 0)
{
Math_ApproxF(&thisx->speedXZ, 0, IREG(57) / 100.0f);
}
else
{
Math_ApproxF(&thisx->speedXZ, 0, IREG(58) / 100.0f);
if ((thisx->bgCheckFlags & 2) && (thisx->velocity.y < IREG(59) / 100.0f))
{
Audio_PlaySoundGeneral(NA_SE_EV_BOMB_BOUND, &thisx->unk_E4, 4, &D_801333E0, &D_801333E0, &D_801333E8);
thisx->velocity.y *= IREG(60) / 100.0f;
thisx->bgCheckFlags &= ~0x1;
}
else
{
func_8002F580(thisx, globalCtx);
}
}
}
}
Actor_MoveForward(thisx);
func_8002E4B4(globalCtx, thisx, thisx->sub_98.unk_12, thisx->sub_98.unk_10, thisx->sub_98.unk_10, 0x1D);
thisx->posRot2.pos = thisx->posRot.pos;
}
static void EnLightbox_Draw(EnLightbox* this, GlobalContext* globalCtx)
{
Draw_DListOpa(globalCtx, &D_06000B70);
}

View file

@ -6,8 +6,7 @@
typedef struct
{
/* 0x0000 */ Actor actor;
/* 0x014C */ char unk_14C[0x18];
/* 0x0000 */ DynaPolyActor dyna;
} EnLightbox; // size = 0x0164
extern const ActorInit En_Lightbox_InitVars;

View file

@ -11,7 +11,6 @@ typedef struct
{
/* 0x0000 */ Actor actor;
/* 0x014C */ SkelAnime skelAnime;
/* 0x018C */ char unk_18C[0x4];
/* 0x0190 */ UNK_PTR unkSkelAnimeStruct;
/* 0x0194 */ char unk_194[0x32];
/* 0x01C6 */ s16 unk_1C6;

View file

@ -7,6 +7,8 @@
#include <ultra64.h>
#include <global.h>
#include <vt.h>
typedef struct
{
/* 0x0000 */ Actor actor;
@ -58,7 +60,7 @@ static void EnOkarinaEffect_Init(EnOkarinaEffect* this, GlobalContext* globalCtx
{
osSyncPrintf("\n\n");
//"Ocarina Storm Effect"
osSyncPrintf("☆☆☆☆☆ オカリナあらし効果ビカビカビカ〜 ☆☆☆☆☆ \n");
osSyncPrintf(VT_FGCOL(YELLOW) "☆☆☆☆☆ オカリナあらし効果ビカビカビカ〜 ☆☆☆☆☆ \n" VT_RST);
osSyncPrintf("\n\n");
if (globalCtx->unk_10B12[1] != 0)
{

View file

@ -4,24 +4,16 @@
* Description: Flying pot enemy
*/
#include <ultra64.h>
#include <global.h>
#include "z_en_tubo_trap.h"
typedef struct
{
/* 0x0000 */ Actor actor;
/* 0x014C */ ActorFunc playfunc;
/* 0x0150 */ f32 pos_y_seek;
/* 0x0154 */ Vec3f pos_init;
/* 0x0160 */ ColliderCylinderMain capsule;
} EnTuboTrap; // size = 0x01AC
#include <vt.h>
void EnTuboTrap_Init(EnTuboTrap* this, GlobalContext* globalCtx);
void EnTuboTrap_Destroy(EnTuboTrap* this, GlobalContext* globalCtx);
void EnTuboTrap_Update(EnTuboTrap* this, GlobalContext* globalCtx);
void EnTuboTrap_Draw(EnTuboTrap* this, GlobalContext* globalCtx);
void EnTuboTrap_TestLevitate(EnTuboTrap* this, GlobalContext* globalCtx);
void EnTuboTrap_InitializeAttack(EnTuboTrap* this, GlobalContext* globalCtx);
void EnTuboTrap_WaitForProximity(EnTuboTrap* this, GlobalContext* globalCtx);
void EnTuboTrap_Levitate(EnTuboTrap* this, GlobalContext* globalCtx);
void EnTuboTrap_Fly(EnTuboTrap* this, GlobalContext* globalCtx);
#define ROOM 0x00
@ -44,7 +36,7 @@ static ColliderCylinderInit cylinderInitData =
0x0000, 0x0000, 0x0000
};
ActorInit En_Tubo_Trap_InitVars =
const ActorInit En_Tubo_Trap_InitVars =
{
ACTOR_EN_TUBO_TRAP,
ACTORTYPE_PROP,
@ -58,321 +50,277 @@ ActorInit En_Tubo_Trap_InitVars =
(ActorFunc)EnTuboTrap_Draw,
};
extern u32 DL_SHARD;
extern u32 DL_TUBO;
extern UNK_TYPE D_05017A60;
extern Gfx D_05017870[];
void EnTuboTrap_Init(EnTuboTrap* this, GlobalContext* globalCtx)
{
s32 pad;
ActorShape_Init(&this->actor.shape, 0.0f, ActorShadow_DrawFunc_Circle, 2.0f);
osSyncPrintf("\n\n");
osSyncPrintf("\x1b[32m☆☆☆☆☆ 壷トラップ ☆☆☆☆☆ %x\n\x1b[m", this->actor.params);
ActorCollider_AllocCylinder(globalCtx, &this->capsule);
ActorCollider_InitCylinder(globalCtx, &this->capsule, &this->actor, &cylinderInitData);
osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ 壷トラップ ☆☆☆☆☆ %x\n" VT_RST, this->actor.params); // "Urn Trap"
ActorCollider_AllocCylinder(globalCtx, &this->collider);
ActorCollider_InitCylinder(globalCtx, &this->collider, &this->actor, &cylinderInitData);
Actor_SetScale(&this->actor, 0.1f);
this->playfunc = (ActorFunc*)EnTuboTrap_TestLevitate;
this->actionFunc = (ActorFunc)EnTuboTrap_WaitForProximity;
}
void EnTuboTrap_Destroy(EnTuboTrap* this, GlobalContext* globalCtx)
{
ColliderCylinderMain* capsule = &this->capsule;
ActorCollider_FreeCylinder(globalCtx, capsule);
ColliderCylinderMain* collider = &this->collider;
ActorCollider_FreeCylinder(globalCtx, collider);
}
void EnTuboTrap_DropCollectible(EnTuboTrap* this, GlobalContext* globalCtx)
{
s16 params = this->actor.params;
s16 param1 = (params >> 6) & 0x03FF;
if (param1 >= 0 && param1 < 0x1A)
s16 param3FF = (params >> 6) & 0x3FF;
if (param3FF >= 0 && param3FF < 0x1A)
{
Item_DropCollectible(globalCtx, &this->actor.posRot, param1 | ((params & 0x03F) << 8));
Item_DropCollectible(globalCtx, &this->actor.posRot, param3FF | ((params & 0x3F) << 8));
}
}
#ifdef NON_MATCHING
void EnTuboTrap_Fragments(EnTuboTrap* this, GlobalContext* globalCtx)
// regalloc and stack usage differences, most likely the same differences as EnTuboTrap_SpawnWaterFragments
void EnTuboTrap_SpawnFragments(EnTuboTrap* this, GlobalContext* globalCtx)
{
u32 uVar1;
s32 rando_seed = 0;
s32 shard_count = 0;
Vec3f* actorPos;
f32 rand;
f32 cos;
f32 sin;
u32 addr;
Vec3f spC8;
Vec3f spBC;
s16 var;
s32 temp;
s32 i;
/* spawn fragments */
do
addr = &D_05017A60;
actorPos = &this->actor.posRot.pos;
for (i = 0, var = 0; i < 15; i++, var += 20000)
{
Vec3f burst_depth[2];
f32 rng;
sin = Math_Sins(var);
cos = Math_Coss(var);
spC8.x = sin * 8.0f;
spC8.y = (Math_Rand_ZeroOne() * 5.0f) + 2.0f;
spC8.z = cos * 8.0f;
/* burst_depth_x */
burst_depth[0].x = Math_Sins(rando_seed) * 8.0f;
burst_depth[0].y = (Math_Rand_ZeroOne() * 5.0f) + 2.0f;
burst_depth[0].z = Math_Coss(rando_seed) * 8.0f;
spBC.x = spC8.x * 0.23f;
spBC.y = (Math_Rand_ZeroOne() * 5.0f) + 2.0f;
spBC.z = spC8.z * 0.23f;
/* burst_depth_y */
burst_depth[1].x = (f32)(burst_depth[0].x * 0.23f);
burst_depth[1].y = (f32)(Math_Rand_ZeroOne() * 5.0f) + 2.0f;
burst_depth[1].z = (f32)(burst_depth[0].z * 0.23f);
spC8.x += actorPos->x;
spC8.y += actorPos->y;
spC8.z += actorPos->z;
VEC3_ADD(burst_depth[0], this->actor.posRot.pos)
rng = Math_Rand_ZeroOne();
if (rng < 0.2f)
{
uVar1 = 0x60;
}
rand = Math_Rand_ZeroOne();
if (rand < 0.2f)
temp = 96;
else if (rand < 0.6f)
temp = 64;
else
{
uVar1 = 0x20;
temp = 32;
if (rng < 0.6f)
{
uVar1 = 0x40;
}
}
/* The Heavy Lifting */
Effect_SpawnFragment(globalCtx, &burst_depth[0], &burst_depth[1], &this->actor.posRot.pos, -239, uVar1, 10, 10, 0,
(Math_Rand_ZeroOne() * 65.0f) + 15.0f, 0, 0x20, 0x3C, -1, 3, DL_SHARD);
shard_count++;
rando_seed = (s32)((rando_seed + 0x4E20) * 0x10000) >> 0x10;
Effect_SpawnFragment(globalCtx, &spC8, &spBC, actorPos, -240, temp, 10, 10, 0,
(Math_Rand_ZeroOne() * 65.0f) + 15.0f, 0, 32, 60, -1, 3, addr);
}
while(shard_count != 15);
func_80033480(globalCtx, &this->actor.posRot.pos, 30.0f, 4, 20, 50, 0);
func_80033480(globalCtx, actorPos, 30.0f, 4, 20, 50, 0);
}
#else
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_Fragments.s")
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_SpawnFragments.s")
#endif
#ifdef NON_MATCHING
void EnTuboTrap_FragmentsWater(EnTuboTrap* this, GlobalContext* globalCtx)
// regalloc and stack usage differences, most likely the same differences as EnTuboTrap_SpawnFragments
void EnTuboTrap_SpawnWaterFragments(EnTuboTrap* this, GlobalContext* globalCtx)
{
u32 uVar1;
s32 rando_seed = 0;
s32 shard_count = 0;
Vec3f burst_depth[2];
f32 rng;
Vec3f* actorPos;
f32 rand;
f32 cos;
f32 sin;
u32 addr;
Vec3f spC8;
Vec3f spBC;
s16 var;
s32 temp;
s32 i;
Math_Vec3f_Copy(&burst_depth[0], &this->actor.posRot.pos);
burst_depth[0].y += this->actor.waterSurfaceDist;
addr = &D_05017A60;
actorPos = &this->actor.posRot.pos;
/* spawn a small splash */
func_8002949C(globalCtx, &burst_depth[0], 0, 0, 0, 0x190);
spC8 = *actorPos;
spC8.y += this->actor.unk_84;
/* spawn fragments */
do
func_8002949C(globalCtx, &spC8, 0, 0, 0, 400);
for (i = 0, var = 0; i < 15; i++, var += 20000)
{
/* burst_depth_x */
burst_depth[0].x = Math_Sins(rando_seed) * 8.0f;
burst_depth[0].y = (Math_Rand_ZeroOne() * 5.0f) + 2.0f;
burst_depth[0].z = Math_Coss(rando_seed) * 8.0f;
sin = Math_Sins(var);
cos = Math_Coss(var);
spC8.x = sin * 8.0f;
spC8.y = (Math_Rand_ZeroOne() * 5.0f) + 2.0f;
spC8.z = cos * 8.0f;
/* burst_depth_y */
burst_depth[1].x = (f32)(burst_depth[0].x * 0.23f);
burst_depth[1].y = (f32)(Math_Rand_ZeroOne() * 5.0f) + 2.0f;
burst_depth[1].z = (f32)(burst_depth[0].z * 0.23f);
spBC.x = spC8.x * 0.23f;
spBC.y = (Math_Rand_ZeroOne() * 4.0f) + 2.0f;
spBC.z = spC8.z * 0.23f;
VEC3_ADD(burst_depth[0], this->actor.posRot.pos)
spC8.x += actorPos->x;
spC8.y += actorPos->y;
spC8.z += actorPos->z;
rng = Math_Rand_ZeroOne();
if (rng < 0.2f)
{
uVar1 = 0x60;
}
rand = Math_Rand_ZeroOne();
if (rand < 0.2f)
temp = 64;
else
{
uVar1 = 0x20;
temp = 32;
if (rng < 0.6f)
{
uVar1 = 0x40;
}
}
/* The Heavy Lifting */
Effect_SpawnFragment(globalCtx, &burst_depth[0], &burst_depth[1], &this->actor.posRot.pos, -239, uVar1,
10, 10, 0, (Math_Rand_ZeroOne() * 65.0f) + 15.0f, 0, 0x20, 0x3C, -1, 3, DL_SHARD);
shard_count++;
rando_seed = (s32)((rando_seed + 0x4E20) * 0x10000) >> 0x10;
Effect_SpawnFragment(globalCtx, &spC8, &spBC, actorPos, -180, temp, 30, 30, 0,
(Math_Rand_ZeroOne() * 65.0f) + 15.0f, 0, 32, 70, -1, 3, addr);
}
while(shard_count != 15);
func_80033480(globalCtx, &this->actor.posRot.pos, 30.0f, 4, 20, 50, 0);
}
#else
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_FragmentsWater.s")
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_SpawnWaterFragments.s")
#endif
#ifdef NON_MATCHING
void EnTuboTrap_TestCollider(EnTuboTrap* this, GlobalContext* globalCtx)
void EnTuboTrap_HandleImpact(EnTuboTrap* this, GlobalContext* globalCtx)
{
u8 bVar1, bVar2;
u16 uVar3;
Actor* collided_this;
s32 pad;
Player* player = PLAYER;
if (!(this->actor.bgCheckFlags & 20))
if ((this->actor.bgCheckFlags & 0x20) && (this->actor.unk_84 > 15.0f))
{
bVar1 = this->capsule.base.colliderFlags;
EnTuboTrap_SpawnWaterFragments(this, globalCtx);
Audio_PlaySoundAtPosition(globalCtx, &this->actor.posRot.pos, 40, NA_SE_EV_BOMB_DROP_WATER);
EnTuboTrap_DropCollectible(this, globalCtx);
Actor_Kill(&this->actor);
return;
}
else
if (this->collider.base.colliderFlags & 4)
{
if (this->actor.waterSurfaceDist > 15.0f)
this->collider.base.colliderFlags &= ~4;
EnTuboTrap_SpawnFragments(this, globalCtx);
Audio_PlaySoundAtPosition(globalCtx, &this->actor.posRot.pos, 40, NA_SE_IT_SHIELD_REFLECT_SW);
Audio_PlaySoundAtPosition(globalCtx, &this->actor.posRot.pos, 40, NA_SE_EV_POT_BROKEN);
EnTuboTrap_DropCollectible(this, globalCtx);
Actor_Kill(&this->actor);
return;
}
if (this->collider.base.collideFlags & 2)
{
this->collider.base.collideFlags &= ~2;
EnTuboTrap_SpawnFragments(this, globalCtx);
Audio_PlaySoundAtPosition(globalCtx, &this->actor.posRot.pos, 40, NA_SE_EV_EXPLOSION);
Audio_PlaySoundAtPosition(globalCtx, &this->actor.posRot.pos, 40, NA_SE_EV_POT_BROKEN);
EnTuboTrap_DropCollectible(this, globalCtx);
Actor_Kill(&this->actor);
return;
}
if (this->collider.base.colliderFlags & 2)
{
this->collider.base.colliderFlags &= ~2;
if (this->collider.base.at == &player->actor)
{
EnTuboTrap_FragmentsWater(this, globalCtx);
Audio_PlaySoundAtPosition(globalCtx, &this->actor.posRot.pos, 40, NA_SE_EV_BOMB_DROP_WATER);
EnTuboTrap_SpawnFragments(this, globalCtx);
Audio_PlaySoundAtPosition(globalCtx, &this->actor.posRot.pos, 40, NA_SE_EV_POT_BROKEN);
Audio_PlaySoundAtPosition(globalCtx, &player->actor.posRot.pos, 40, 0x83E);
EnTuboTrap_DropCollectible(this, globalCtx);
Actor_Kill(&this->actor);
return;
}
bVar1 = this->capsule.base.collideFlags;
}
if (!(bVar1 & 4))
if ((this->actor.bgCheckFlags & 8) || (this->actor.bgCheckFlags & 1))
{
bVar2 = this->capsule.base.collideFlags;
if (!(bVar2 & 2))
{
if (!(bVar1 & 2))
{
uVar3 = this->actor.bgCheckFlags;
}
else
{
collided_this = this->capsule.base.actor;
this->capsule.base.colliderFlags = bVar1 & 0xFD;
if (collided_this == &player->actor)
{
EnTuboTrap_Fragments(this, globalCtx);
Audio_PlaySoundAtPosition(globalCtx, &this->actor.posRot.pos, 0x28, NA_SE_EV_POT_BROKEN);
Audio_PlaySoundAtPosition(globalCtx, &player->actor.posRot.pos, 0x28, NA_SE_PL_BODY_HIT);
EnTuboTrap_DropCollectible(this, globalCtx);
Actor_Kill(&this->actor);
return;
}
uVar3 = this->actor.bgCheckFlags;
}
if ((uVar3 & 8) || (uVar3 & 1))
{
EnTuboTrap_Fragments(this, globalCtx);
Audio_PlaySoundAtPosition(globalCtx, &this->actor.posRot.pos, 0x28, NA_SE_EV_POT_BROKEN);
EnTuboTrap_DropCollectible(this, globalCtx);
Actor_Kill(&this->actor);
}
}
else
{
this->capsule.base.collideFlags = bVar2 & 0xFD;
EnTuboTrap_Fragments(this, globalCtx);
Audio_PlaySoundAtPosition(globalCtx, &this->actor.posRot.pos, 0x28, NA_SE_EV_EXPLOSION);
Audio_PlaySoundAtPosition(globalCtx, &this->actor.posRot.pos, 0x28, NA_SE_EV_POT_BROKEN);
EnTuboTrap_DropCollectible(this, globalCtx);
Actor_Kill(&this->actor);
}
}
else
{
this->capsule.base.colliderFlags = bVar1 & 0xFB;
EnTuboTrap_Fragments(this, globalCtx);
Audio_PlaySoundAtPosition(globalCtx, &this->actor.posRot.pos, 0x28, NA_SE_IT_SHIELD_REFLECT_SW);
Audio_PlaySoundAtPosition(globalCtx, &this->actor.posRot.pos, 0x28, NA_SE_EV_POT_BROKEN);
EnTuboTrap_SpawnFragments(this, globalCtx);
Audio_PlaySoundAtPosition(globalCtx, &this->actor.posRot.pos, 40, NA_SE_EV_POT_BROKEN);
EnTuboTrap_DropCollectible(this, globalCtx);
Actor_Kill(&this->actor);
return;
}
}
#else
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_TestCollider.s")
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_HandleImpact.s")
#endif
#ifdef NON_MATCHING
void EnTuboTrap_TestLevitate(EnTuboTrap* this, GlobalContext* globalCtx)
void EnTuboTrap_WaitForProximity(EnTuboTrap* this, GlobalContext* globalCtx)
{
Player* player = PLAYER;
f32 seekY;
f32 targetHeight;
if (BREG(2) != 0)
{
osSyncPrintf("[32m☆☆☆☆☆ わて ☆☆☆☆☆ %f\n", globalCtx, this->actor.posRot.pos.y);
osSyncPrintf("[32m☆☆☆☆☆ おいどん ☆☆☆☆☆ %f\n");
osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ わて ☆☆☆☆☆ %f\n" VT_RST, this->actor.posRot.pos.y); // "You"
osSyncPrintf(VT_FGCOL(GREEN) "☆☆☆☆☆ おいどん ☆☆☆☆☆ %f\n" VT_RST, player->actor.posRot.pos.y); // "Me"
osSyncPrintf("\n\n");
}
if (this->actor.xzDistanceFromLink < 200.00000000 && this->actor.posRot.pos.y <= player->actor.posRot.pos.y)
if (this->actor.xzDistanceFromLink < 200.0f && this->actor.posRot.pos.y <= player->actor.posRot.pos.y)
{
Actor_ChangeType(globalCtx, &globalCtx->actorCtx, this, ACTORTYPE_ENEMY);
this->actor.flags |= 1;
seekY = (f32)gSaveContext.link_age * -10.00000000 + 40.00000000;
this->pos_y_seek = player->actor.posRot.pos.y;
targetHeight = 40.0f + -10.0f * gSaveContext.link_age;
if (this->pos_y_seek < this->actor.posRot.pos.y)
this->pos_y_seek = this->actor.posRot.pos.y + seekY;
this->actor.initPosRot.pos = this->actor.posRot.pos;
this->targetY = player->actor.posRot.pos.y + targetHeight;
if (this->targetY < this->actor.posRot.pos.y)
this->targetY = this->actor.posRot.pos.y + targetHeight;
this->originPos = this->actor.posRot.pos;
Audio_PlayActorSound2(this, NA_SE_EV_POT_MOVE_START);
this->playfunc = (ActorFunc)EnTuboTrap_InitializeAttack;
this->actionFunc = (ActorFunc)EnTuboTrap_Levitate;
}
}
#else
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_TestLevitate.s")
#endif
#ifdef NON_MATCHING
void EnTuboTrap_InitializeAttack(EnTuboTrap* this, GlobalContext* globalCtx)
void EnTuboTrap_Levitate(EnTuboTrap* this, GlobalContext* globalCtx)
{
this->actor.posRot.rot.y += 5000;
Math_SmoothScaleMaxF(&this->actor.posRot.pos.y, this->pos_y_seek, 0.8f, 3.0f); /* Tween levitation */
this->actor.shape.rot.y += 5000;
Math_SmoothScaleMaxF(&this->actor.posRot.pos.y, this->targetY, 0.8f, 3.0f);
if (ABS(this->actor.posRot.pos.y - this->pos_y_seek) < 10.0f)
if (fabsf(this->actor.posRot.pos.y - this->targetY) < 10.0f)
{
this->actor.speedXZ = 10.0f;
this->actor.posRot.rot.y = this->actor.rotTowardsLinkY;
this->playfunc = (ActorFunc)EnTuboTrap_Fly;
this->actionFunc = (ActorFunc)EnTuboTrap_Fly;
}
}
#else
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_InitializeAttack.s")
#endif
#ifdef NON_MATCHING
void EnTuboTrap_Fly(EnTuboTrap* this, GlobalContext* globalCtx)
{
Vec3f pos_delta;
f32 dx = this->originPos.x - this->actor.posRot.pos.x;
f32 dy = this->originPos.y - this->actor.posRot.pos.y;
f32 dz = this->originPos.z - this->actor.posRot.pos.z;
VEC3_SUB(pos_delta, this->pos_init, this->actor.posRot.pos);
Audio_PlayActorSound2(&this->actor, NA_SE_EN_TUBOOCK_FLY);
Audio_PlayActorSound2(&this->actor, 0x3037);
if (240.0f < sqrtf(SQ(pos_delta.x) + SQ(pos_delta.y) + SQ(pos_delta.z)))
Math_SmoothScaleMaxF(&this->actor.gravity, -3.0f, 0.2f, 0.5f); /* Tween to ground */
if (240.0f < sqrtf(SQ(dx) + SQ(dy) + SQ(dz)))
Math_SmoothScaleMaxF(&this->actor.gravity, -3.0f, 0.2f, 0.5f);
this->actor.posRot.rot.y += 5000;
EnTuboTrap_TestCollider(this, globalCtx);
this->actor.shape.rot.y += 5000;
EnTuboTrap_HandleImpact(this, globalCtx);
}
#else
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_Fly.s")
#endif
#ifdef NON_MATCHING
void EnTuboTrap_Update(EnTuboTrap* this, GlobalContext* globalCtx)
{
this->playfunc(this, globalCtx);
Actor_MoveForward(&this->actor); /* Probably to haul ass towards Link */
func_8002E4B4(globalCtx, &this->actor, 10.0f, 10.0f, 20.0f, 0x1D); /* Necessary for drawing a shadow */
Actor_SetHeight(&this->actor, 0.0f);
ActorCollider_Cylinder_Update(&this->actor, &this->capsule);
Actor_CollisionCheck_SetAC(globalCtx, &globalCtx->sub_11E60, &this->capsule);
Actor_CollisionCheck_SetAT(globalCtx, &globalCtx->sub_11E60, &this->capsule);
EnTuboTrap* tuboTrap = this;
SubGlobalContext11E60* sub_11E60 = &globalCtx->sub_11E60;
tuboTrap->actionFunc(tuboTrap, globalCtx);
Actor_MoveForward(&tuboTrap->actor);
func_8002E4B4(globalCtx, &tuboTrap->actor, 10.0f, 10.0f, 20.0f, 0x1D);
Actor_SetHeight(&tuboTrap->actor, 0.0f);
ActorCollider_Cylinder_Update(&tuboTrap->actor, &tuboTrap->collider);
Actor_CollisionCheck_SetAC(globalCtx, sub_11E60, &tuboTrap->collider);
Actor_CollisionCheck_SetAT(globalCtx, sub_11E60, &tuboTrap->collider);
}
#else
#pragma GLOBAL_ASM("asm/non_matchings/overlays/actors/ovl_En_Tubo_Trap/EnTuboTrap_Update.s")
#endif
void EnTuboTrap_Draw(EnTuboTrap* this, GlobalContext* globalCtx)
{
Draw_DListOpa(globalCtx, &DL_TUBO);
Draw_DListOpa(globalCtx, D_05017870);
}

View file

@ -0,0 +1,18 @@
#ifndef _Z_EN_TUBO_TRAP_H_
#define _Z_EN_TUBO_TRAP_H_
#include <ultra64.h>
#include <global.h>
typedef struct
{
/* 0x0000 */ Actor actor;
/* 0x014C */ ActorFunc actionFunc;
/* 0x0150 */ f32 targetY;
/* 0x0154 */ Vec3f originPos;
/* 0x0160 */ ColliderCylinderMain collider;
} EnTuboTrap; // size = 0x01AC
extern const ActorInit En_Tubo_Trap_InitVars;
#endif

View file

@ -14,7 +14,6 @@ typedef struct
{
/* 0x0000 */ Actor actor;
/* 0x014C */ SkelAnime skelAnime;
/* 0x018C */ char unk_18C[0x4];
/* 0x0190 */ ActorFunc actionFunc;
/* 0x0194 */ s16 timer;
/* 0x0196 */ s16 switchFlag;

View file

@ -6,23 +6,209 @@
#include <ultra64.h>
#include <global.h>
#include <alloca.h>
#pragma GLOBAL_ASM("asm/non_matchings/overlays/gamestates/ovl_title/func_80800000.s")
extern Gfx D_01002720[];
extern u8 D_01001800[];
extern u8 D_01000000[];
void func_80800128(TitleContext* this)
void Title_PrintBuildInfo(Gfx** gfxp)
{
this->unk_1E1 = 1;
Gfx* g;
GfxPrint* printer;
g = *gfxp;
g = func_8009411C(g);
printer = alloca(0x30);
GfxPrint_Ctor(printer);
GfxPrint_Open(printer, g);
GfxPrint_SetColor(printer, 0xFF, 0x9B, 0xFF, 0xFF);
GfxPrint_SetPos(printer, 9, 21);
GfxPrint_Printf(printer, "NOT MARIO CLUB VERSION");
GfxPrint_SetColor(printer, 0xFF, 0xFF, 0xFF, 0xFF);
GfxPrint_SetPos(printer, 7, 23);
GfxPrint_Printf(printer, "[Creator:%s]", gBuildTeam);
GfxPrint_SetPos(printer, 7, 24);
GfxPrint_Printf(printer, "[Date:%s]", gBuildDate);
g = GfxPrint_Close(printer);
GfxPrint_Dtor(printer);
*gfxp = g;
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/gamestates/ovl_title/func_80800134.s")
#pragma GLOBAL_ASM("asm/non_matchings/overlays/gamestates/ovl_title/func_808001C8.s")
#pragma GLOBAL_ASM("asm/non_matchings/overlays/gamestates/ovl_title/func_8080073C.s")
void func_80800858(TitleContext* this)
// Note: In other rom versions this function also updates unk_1D4, coverAlpha, addAlpha, visibleDuration to calculate the fade-in/fade-out + the duration of the n64 logo animation
void Title_Calc(TitleContext* this)
{
func_800A9AD0(this, &this->unk_1D0);
this->exit = 1;
}
#pragma GLOBAL_ASM("asm/non_matchings/overlays/gamestates/ovl_title/func_80800878.s")
void Title_InitView(TitleContext* this, f32 x, f32 y, f32 z)
{
View* view;
Vec3f v1;
Vec3f v2;
Vec3f v3;
view = &this->view;
v3.z = 0;
v3.x = 0;
v2.z = 0;
v2.y = 0;
v2.x = 0;
v1.x = x;
v1.y = y;
v1.z = z;
v3.y = 1.0;
func_800AA460(view, 30.0f, 10.0f, 12800.0f);
func_800AA358(view, &v1, &v2, &v3);
func_800AAA50(view, 0xF);
}
void Title_Draw(TitleContext* this)
{
static s16 sTitleRotY = 0;
static u32 D_808009A4 = 0;
static Lights1 sTitleLights = gdSPDefLights1(0x64, 0x64, 0x64, 0xFF, 0xFF, 0xFF, 0x45, 0x45, 0x45);
u16 y;
u16 idx;
char pad1[0x4];
Vec3f v3;
Vec3f v1;
Vec3f v2;
char pad2[0x8];
GraphicsContext* gfxCtx = this->state.gfxCtx;
Gfx* gfxArr[4];
func_800C6AC4(&gfxArr, this->state.gfxCtx, "../z_title.c", 395);
v3.x = 69;
v3.y = 69;
v3.z = 69;
v2.x = -4949.148;
v2.y = 4002.5417;
v1.x = 0;
v1.y = 0;
v1.z = 0;
v2.z = 1119.0837;
func_8002EABC(&v1, &v2, &v3, this->state.gfxCtx);
gSPSetLights1(gfxCtx->polyOpa.p++, sTitleLights);
Title_InitView(this, 0, 150.0, 300.0);
func_80093D18(this->state.gfxCtx);
Matrix_Translate(-53.0, -5.0, 0, MTXMODE_NEW);
Matrix_Scale(1.0, 1.0, 1.0, MTXMODE_APPLY);
Matrix_RotateXYZ(0, sTitleRotY, 0, MTXMODE_APPLY);
gSPMatrix(gfxCtx->polyOpa.p++, Matrix_NewMtx(this->state.gfxCtx, "../z_title.c", 424), G_MTX_LOAD);
gSPDisplayList(gfxCtx->polyOpa.p++, &D_01002720);
func_800944C4(this->state.gfxCtx);
gDPPipeSync(gfxCtx->polyOpa.p++);
gDPSetCycleType(gfxCtx->polyOpa.p++, G_CYC_2CYCLE);
gDPSetRenderMode(gfxCtx->polyOpa.p++, G_RM_XLU_SURF2, G_RM_OPA_CI | CVG_DST_WRAP);
gDPSetCombineLERP(gfxCtx->polyOpa.p++, TEXEL1, PRIMITIVE, ENV_ALPHA, TEXEL0, 0, 0, 0, TEXEL0, PRIMITIVE, ENVIRONMENT, COMBINED, ENVIRONMENT, COMBINED, 0, PRIMITIVE, 0);
gDPSetPrimColor(gfxCtx->polyOpa.p++, 0, 0, 170, 255, 255, 255);
gDPSetEnvColor(gfxCtx->polyOpa.p++, 0, 0, 255, 128);
gDPLoadMultiBlock(gfxCtx->polyOpa.p++,
&D_01001800,
0x100,
1,
G_IM_FMT_I,
G_IM_SIZ_8b,
32, 32,
0,
G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP,
5, 5,
2, 11);
for (idx = 0, y = 94; idx < 16; idx++, y += 2)
{
gDPLoadTextureBlock(gfxCtx->polyOpa.p++,
&D_01000000[0x180 * idx],
G_IM_FMT_I,
G_IM_SIZ_8b,
192, 2,
0,
G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMIRROR | G_TX_WRAP,
G_TX_NOMASK, G_TX_NOMASK,
G_TX_NOLOD, G_TX_NOLOD);
gDPSetTileSize(gfxCtx->polyOpa.p++, 1, this->uls, (this->ult & 0x7F) - idx*4, 0, 0);
gSPTextureRectangle(gfxCtx->polyOpa.p++, 388, y << 2, 1156, (y+2)<<2, G_TX_RENDERTILE, 0, 0, 1024, 1024);
}
func_8007672C(this->state.gfxCtx, 0, 0, 0, (s16)this->coverAlpha, 2);
sTitleRotY += 300;
func_800C6B54(&gfxArr, this->state.gfxCtx, "../z_title.c", 483);
}
void Title_Update(TitleContext* this)
{
GraphicsContext* gfxCtx = this->state.gfxCtx;
u32 pad;
Gfx* gfxArr[4];
u32 pad2;
Gfx* gfx[2];
func_800C6AC4(&gfxArr, this->state.gfxCtx, "../z_title.c", 494);
gSPSegment(gfxCtx->polyOpa.p++, 0, NULL);
gSPSegment(gfxCtx->polyOpa.p++, 1, this->staticSegment);
func_80095248(this->state.gfxCtx, 0, 0, 0);
Title_Calc(this);
Title_Draw(this);
if (D_8012DBC0)
{
gfx[0] = gfxCtx->polyOpa.p;
Title_PrintBuildInfo(&gfx);
gfxCtx->polyOpa.p = gfx[0];
}
if (this->exit)
{
gSaveContext.seq_index = -1;
gSaveContext.night_sfx = -1;
gSaveContext.game_mode = 1;
this->state.running = false;
this->state.init = Opening_Init; this->state.size = sizeof(OpeningContext);
}
func_800C6B54(&gfxArr, this->state.gfxCtx, "../z_title.c", 541);
}
void Title_Destroy(TitleContext* this)
{
func_800A9AD0(this, &this->sram);
}
void Title_Init(TitleContext* this)
{
u32 size = (u32)_nintendo_rogo_staticSegmentRomEnd - (u32)_nintendo_rogo_staticSegmentRomStart;
u32 pad;
this->staticSegment = Game_Alloc(&this->state, size, "../z_title.c", 611);
osSyncPrintf("z_title.c\n");
if (this->staticSegment == NULL)
{
__assert("this->staticSegment != NULL", "../z_title.c", 614);
}
DmaMgr_SendRequest1(this->staticSegment, (u32)_nintendo_rogo_staticSegmentRomStart, size, "../z_title.c", 615);
R_UPDATE_RATE = 1;
Matrix_Init(&this->state);
func_800AA278(&this->view, this->state.gfxCtx);
this->state.main = Title_Update;
this->state.destroy = Title_Destroy;
this->exit = false;
gSaveContext.file_num = 0xFF;
func_800A9CD4(&this->state, &this->sram);
this->ult = 0;
this->unk_1D4 = 0x14;
this->coverAlpha = 0xFF;
this->addAlpha = -3;
this->visibleDuration = 0x3C;
}