mirror of
https://github.com/zeldaret/oot.git
synced 2025-07-13 11:24:40 +00:00
Merge branch 'master' into doc_pause_menu
This commit is contained in:
commit
929724c37c
357 changed files with 2965 additions and 1900 deletions
|
@ -1,140 +1,135 @@
|
|||
/**
|
||||
* @file TwoHeadArena.c
|
||||
*
|
||||
* This file implements a simple general purpose double-ended stack allocator.
|
||||
*
|
||||
* A double-ended stack allocator accepts allocations at either the "head" or "tail" of its allotted memory region.
|
||||
* While in general this type of allocator could accept deallocations on the most recently allocated block at either
|
||||
* end, this implementation does not support any individual deallocations; the only provided way to deallocate anything
|
||||
* is to reset the entire arena, deallocating everything. This scheme is most applicable to allocating similar data
|
||||
* with identical lifetime.
|
||||
*/
|
||||
#include "global.h"
|
||||
|
||||
void THGA_Ct(TwoHeadGfxArena* thga, Gfx* start, u32 size) {
|
||||
THA_Ct((TwoHeadArena*)thga, start, size);
|
||||
}
|
||||
|
||||
void THGA_Dt(TwoHeadGfxArena* thga) {
|
||||
THA_Dt((TwoHeadArena*)thga);
|
||||
}
|
||||
|
||||
u32 THGA_IsCrash(TwoHeadGfxArena* thga) {
|
||||
return THA_IsCrash((TwoHeadArena*)thga);
|
||||
}
|
||||
|
||||
void THGA_Init(TwoHeadGfxArena* thga) {
|
||||
THA_Init((TwoHeadArena*)thga);
|
||||
}
|
||||
|
||||
s32 THGA_GetSize(TwoHeadGfxArena* thga) {
|
||||
return THA_GetSize((TwoHeadArena*)thga);
|
||||
}
|
||||
|
||||
Gfx* THGA_GetHead(TwoHeadGfxArena* thga) {
|
||||
return THA_GetHead((TwoHeadArena*)thga);
|
||||
}
|
||||
|
||||
void THGA_SetHead(TwoHeadGfxArena* thga, Gfx* start) {
|
||||
THA_SetHead((TwoHeadArena*)thga, start);
|
||||
}
|
||||
|
||||
Gfx* THGA_GetTail(TwoHeadGfxArena* thga) {
|
||||
return THA_GetTail((TwoHeadArena*)thga);
|
||||
}
|
||||
|
||||
Gfx* THGA_AllocStartArray8(TwoHeadGfxArena* thga, u32 count) {
|
||||
return THA_AllocStart((TwoHeadArena*)thga, count * 8);
|
||||
}
|
||||
|
||||
Gfx* THGA_AllocStart8(TwoHeadGfxArena* thga) {
|
||||
return THGA_AllocStartArray8(thga, 1);
|
||||
}
|
||||
|
||||
Gfx* THGA_AllocStart8Wrapper(TwoHeadGfxArena* thga) {
|
||||
return THGA_AllocStart8(thga);
|
||||
}
|
||||
|
||||
Gfx* THGA_AllocEnd(TwoHeadGfxArena* thga, u32 size) {
|
||||
return THA_AllocEnd((TwoHeadArena*)thga, size);
|
||||
}
|
||||
|
||||
Gfx* THGA_AllocEndArray64(TwoHeadGfxArena* thga, u32 count) {
|
||||
return THGA_AllocEnd(thga, count * 0x40);
|
||||
}
|
||||
|
||||
Gfx* THGA_AllocEnd64(TwoHeadGfxArena* thga) {
|
||||
return THGA_AllocEnd(thga, 0x40);
|
||||
}
|
||||
|
||||
Gfx* THGA_AllocEndArray16(TwoHeadGfxArena* thga, u32 count) {
|
||||
return THGA_AllocEnd(thga, count * 0x10);
|
||||
}
|
||||
|
||||
Gfx* THGA_AllocEnd16(TwoHeadGfxArena* thga) {
|
||||
return THGA_AllocEnd(thga, 0x10);
|
||||
}
|
||||
|
||||
void* THA_GetHead(TwoHeadArena* tha) {
|
||||
return tha->head;
|
||||
}
|
||||
|
||||
void THA_SetHead(TwoHeadArena* tha, void* start) {
|
||||
tha->head = start;
|
||||
void THA_SetHead(TwoHeadArena* tha, void* newHead) {
|
||||
tha->head = newHead;
|
||||
}
|
||||
|
||||
void* THA_GetTail(TwoHeadArena* tha) {
|
||||
return tha->tail;
|
||||
}
|
||||
|
||||
void* THA_AllocStart(TwoHeadArena* tha, u32 size) {
|
||||
/**
|
||||
* Allocates to the head of the Two Head Arena. The allocation will not have any alignment guarantees.
|
||||
*/
|
||||
void* THA_AllocHead(TwoHeadArena* tha, size_t size) {
|
||||
void* start = tha->head;
|
||||
|
||||
tha->head = (void*)((u32)tha->head + size);
|
||||
tha->head = (u8*)tha->head + size;
|
||||
return start;
|
||||
}
|
||||
|
||||
void* THA_AllocStart1(TwoHeadArena* tha) {
|
||||
return THA_AllocStart(tha, 1);
|
||||
void* THA_AllocHeadByte(TwoHeadArena* tha) {
|
||||
return THA_AllocHead(tha, 1);
|
||||
}
|
||||
|
||||
void* THA_AllocEnd(TwoHeadArena* tha, u32 size) {
|
||||
u32 mask;
|
||||
/**
|
||||
* Allocates to the tail end of the Two Head Arena. The allocation will be aligned based on the size of the allocation.
|
||||
* All allocations of 16 bytes or more will be aligned to 16-bytes. Otherwise, the alignment will be the largest power
|
||||
* of 2 for which the size is a multiple, in order to accommodate the alignment requirements of any data types that can
|
||||
* fit within the allocation.
|
||||
*/
|
||||
void* THA_AllocTail(TwoHeadArena* tha, size_t size) {
|
||||
uintptr_t mask;
|
||||
|
||||
if (size == 8) {
|
||||
mask = ~7;
|
||||
// Align 8 for multiples of 8
|
||||
mask = ALIGN_MASK(8);
|
||||
} else if (size == 4 || size == 12) {
|
||||
mask = ~3;
|
||||
// Align 4 for multiples of 4
|
||||
mask = ALIGN_MASK(4);
|
||||
} else if (size == 2 || size == 6 || size == 10 || size == 12 || size == 14) {
|
||||
mask = ~1;
|
||||
// Align 2 for multiples of 2
|
||||
mask = ALIGN_MASK(2);
|
||||
} else if (size >= 0x10) {
|
||||
// Align 0x10 for allocations greater than 0x10
|
||||
mask = ALIGN_MASK(0x10);
|
||||
} else {
|
||||
mask = (size >= 0x10) ? ~0xF : 0;
|
||||
//! @bug if size is less than 16 and odd the computation below will give NULL. The mask for this case would be
|
||||
//! more sensible as ~0, for no extra alignment
|
||||
mask = 0;
|
||||
}
|
||||
|
||||
tha->tail = (void*)((((u32)tha->tail & mask) - size) & mask);
|
||||
tha->tail = (void*)((((uintptr_t)tha->tail & mask) - size) & mask);
|
||||
return tha->tail;
|
||||
}
|
||||
|
||||
void* THA_AllocEndAlign16(TwoHeadArena* tha, u32 size) {
|
||||
u32 mask = ~0xF;
|
||||
/**
|
||||
* Allocates to the tail end of the Two Head Arena with guaranteed 16-byte alignment.
|
||||
*/
|
||||
void* THA_AllocTailAlign16(TwoHeadArena* tha, size_t size) {
|
||||
uintptr_t mask = ALIGN_MASK(0x10);
|
||||
|
||||
tha->tail = (void*)((((u32)tha->tail & mask) - size) & (u32)(u64)mask);
|
||||
tha->tail = (void*)((((uintptr_t)tha->tail & mask) - size) & (uintptr_t)(u64)mask);
|
||||
return tha->tail;
|
||||
}
|
||||
|
||||
void* THA_AllocEndAlign(TwoHeadArena* tha, u32 size, u32 mask) {
|
||||
tha->tail = (void*)((((u32)tha->tail & mask) - size) & mask);
|
||||
/**
|
||||
* Allocates to the tail end of the Two Head Arena using the provided mask to align the allocated region.
|
||||
*
|
||||
* @param tha Arena to allocate to
|
||||
* @param size Size of the allocation
|
||||
* @param mask Mask to use to align the allocated region. To align to n-bytes where n is a power of 2, use the
|
||||
* ALIGN_MASK(n) macro
|
||||
*
|
||||
* @return Pointer to the start of the allocated block
|
||||
*/
|
||||
void* THA_AllocTailAlign(TwoHeadArena* tha, size_t size, uintptr_t mask) {
|
||||
tha->tail = (void*)((((uintptr_t)tha->tail & mask) - size) & mask);
|
||||
return tha->tail;
|
||||
}
|
||||
|
||||
s32 THA_GetSize(TwoHeadArena* tha) {
|
||||
return (u32)tha->tail - (u32)tha->head;
|
||||
/**
|
||||
* Gets the remaining size of the Two Head Arena
|
||||
*
|
||||
* @return Remaining size. A negative number indicates an overflow.
|
||||
*/
|
||||
s32 THA_GetRemaining(TwoHeadArena* tha) {
|
||||
return (s32)((u8*)tha->tail - (u8*)tha->head);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if the Two Head Arena has overflowed, false otherwise
|
||||
*/
|
||||
u32 THA_IsCrash(TwoHeadArena* tha) {
|
||||
return THA_GetSize(tha) < 0;
|
||||
return THA_GetRemaining(tha) < 0;
|
||||
}
|
||||
|
||||
void THA_Init(TwoHeadArena* tha) {
|
||||
tha->head = tha->bufp;
|
||||
tha->tail = (void*)((u32)tha->bufp + tha->size);
|
||||
/**
|
||||
* Resets the head and tail positions of the Two Head Arena, all prior allocations are effectively considered free
|
||||
* as any new allocations will begin to overwrite them.
|
||||
*/
|
||||
void THA_Reset(TwoHeadArena* tha) {
|
||||
tha->head = tha->start;
|
||||
tha->tail = (u8*)tha->start + tha->size;
|
||||
}
|
||||
|
||||
void THA_Ct(TwoHeadArena* tha, void* ptr, u32 size) {
|
||||
tha->bufp = ptr;
|
||||
/**
|
||||
* Creates a new Two Head Arena at `start` with available size `size`
|
||||
*/
|
||||
void THA_Init(TwoHeadArena* tha, void* start, size_t size) {
|
||||
tha->start = start;
|
||||
tha->size = size;
|
||||
THA_Init(tha);
|
||||
THA_Reset(tha);
|
||||
}
|
||||
|
||||
void THA_Dt(TwoHeadArena* tha) {
|
||||
/**
|
||||
* Destroys the Two Head Arena, no further allocations are possible
|
||||
*/
|
||||
void THA_Destroy(TwoHeadArena* tha) {
|
||||
bzero(tha, sizeof(TwoHeadArena));
|
||||
}
|
||||
|
|
102
src/code/TwoHeadGfxArena.c
Normal file
102
src/code/TwoHeadGfxArena.c
Normal file
|
@ -0,0 +1,102 @@
|
|||
/**
|
||||
* @file TwoHeadGfxArena.c
|
||||
*
|
||||
* This file implements a particular use of the double-ended stack allocator from TwoHeadArena.c for graphics data.
|
||||
*
|
||||
* Display list commands are allocated from the head while other graphics data such as matrices and vertices are
|
||||
* allocated from the tail end.
|
||||
*
|
||||
* @see TwoHeadArena.c
|
||||
*/
|
||||
#include "global.h"
|
||||
|
||||
void THGA_Init(TwoHeadGfxArena* thga, void* start, size_t size) {
|
||||
THA_Init(&thga->tha, start, size);
|
||||
}
|
||||
|
||||
void THGA_Destroy(TwoHeadGfxArena* thga) {
|
||||
THA_Destroy(&thga->tha);
|
||||
}
|
||||
|
||||
u32 THGA_IsCrash(TwoHeadGfxArena* thga) {
|
||||
return THA_IsCrash(&thga->tha);
|
||||
}
|
||||
|
||||
void THGA_Reset(TwoHeadGfxArena* thga) {
|
||||
THA_Reset(&thga->tha);
|
||||
}
|
||||
|
||||
s32 THGA_GetRemaining(TwoHeadGfxArena* thga) {
|
||||
return THA_GetRemaining(&thga->tha);
|
||||
}
|
||||
|
||||
Gfx* THGA_GetHead(TwoHeadGfxArena* thga) {
|
||||
return THA_GetHead(&thga->tha);
|
||||
}
|
||||
|
||||
void THGA_SetHead(TwoHeadGfxArena* thga, Gfx* newHead) {
|
||||
THA_SetHead(&thga->tha, newHead);
|
||||
}
|
||||
|
||||
void* THGA_GetTail(TwoHeadGfxArena* thga) {
|
||||
return THA_GetTail(&thga->tha);
|
||||
}
|
||||
|
||||
/**
|
||||
* Allocates a display list of `num` Gfx commands to the head of the Two Head Gfx Arena.
|
||||
*/
|
||||
Gfx* THGA_AllocDisplayList(TwoHeadGfxArena* thga, size_t num) {
|
||||
return THA_AllocHead(&thga->tha, num * sizeof(Gfx));
|
||||
}
|
||||
|
||||
/**
|
||||
* Allocates a single Gfx command to the head of the Two Head Gfx Arena.
|
||||
*/
|
||||
Gfx* THGA_AllocGfx(TwoHeadGfxArena* thga) {
|
||||
return THGA_AllocDisplayList(thga, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Identical to `THGA_AllocGfx`
|
||||
*
|
||||
* @see THGA_AllocGfx
|
||||
*/
|
||||
Gfx* THGA_AllocGfx2(TwoHeadGfxArena* thga) {
|
||||
return THGA_AllocGfx(thga);
|
||||
}
|
||||
|
||||
/**
|
||||
* Allocates to the end of the Two Head Gfx Arena. Intended for data complementary to the display lists such as
|
||||
* matrices and vertices that are only needed for a single graphics task.
|
||||
*/
|
||||
void* THGA_AllocTail(TwoHeadGfxArena* thga, size_t size) {
|
||||
return THA_AllocTail(&thga->tha, size);
|
||||
}
|
||||
|
||||
/**
|
||||
* Allocates `num` matrices to the tail end of the Two Head Gfx Arena.
|
||||
*/
|
||||
Mtx* THGA_AllocMtxArray(TwoHeadGfxArena* thga, size_t num) {
|
||||
return THGA_AllocTail(thga, num * sizeof(Mtx));
|
||||
}
|
||||
|
||||
/**
|
||||
* Allocates a matrix to the tail end of the Two Head Gfx Arena.
|
||||
*/
|
||||
Mtx* THGA_AllocMtx(TwoHeadGfxArena* thga) {
|
||||
return THGA_AllocTail(thga, sizeof(Mtx));
|
||||
}
|
||||
|
||||
/**
|
||||
* Allocates `num` vertices to the tail end of the Two Head Gfx Arena.
|
||||
*/
|
||||
Vtx* THGA_AllocVtxArray(TwoHeadGfxArena* thga, size_t num) {
|
||||
return THGA_AllocTail(thga, num * sizeof(Vtx));
|
||||
}
|
||||
|
||||
/**
|
||||
* Allocates a vertex to the tail end of the Two Head Gfx Arena.
|
||||
*/
|
||||
Vtx* THGA_AllocVtx(TwoHeadGfxArena* thga) {
|
||||
return THGA_AllocTail(thga, sizeof(Vtx));
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
#include "global.h"
|
||||
#include "vt.h"
|
||||
#include "terminal.h"
|
||||
|
||||
#define FILL_ALLOCBLOCK (1 << 0)
|
||||
#define FILL_FREEBLOCK (1 << 1)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "global.h"
|
||||
#include "vt.h"
|
||||
#include "terminal.h"
|
||||
|
||||
/**
|
||||
* Update the `carriedActor`'s position based on the dynapoly actor identified by `bgId`.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "global.h"
|
||||
#include "vt.h"
|
||||
#include "terminal.h"
|
||||
|
||||
u32 gIsCtrlr2Valid = false;
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "ultra64.h"
|
||||
#include "global.h"
|
||||
#include "vt.h"
|
||||
#include "terminal.h"
|
||||
|
||||
typedef struct {
|
||||
/* 0x00 */ u16 sfxId;
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
* DPad-Down disables sending fault pages over osSyncPrintf.
|
||||
*/
|
||||
#include "global.h"
|
||||
#include "vt.h"
|
||||
#include "terminal.h"
|
||||
#include "alloca.h"
|
||||
|
||||
void FaultDrawer_Init(void);
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* the crash screen implemented by fault.c
|
||||
*/
|
||||
#include "global.h"
|
||||
#include "vt.h"
|
||||
#include "terminal.h"
|
||||
|
||||
typedef struct {
|
||||
/* 0x00 */ u16* fb;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "global.h"
|
||||
#include "vt.h"
|
||||
#include "terminal.h"
|
||||
|
||||
SpeedMeter D_801664D0;
|
||||
struct_801664F0 D_801664F0;
|
||||
|
@ -173,7 +173,7 @@ void GameState_Draw(GameState* gameState, GraphicsContext* gfxCtx) {
|
|||
DebugArena_Display();
|
||||
SystemArena_Display();
|
||||
// "%08x bytes left until the death of Hyrule (game_alloc)"
|
||||
osSyncPrintf("ハイラル滅亡まであと %08x バイト(game_alloc)\n", THA_GetSize(&gameState->tha));
|
||||
osSyncPrintf("ハイラル滅亡まであと %08x バイト(game_alloc)\n", THA_GetRemaining(&gameState->tha));
|
||||
R_ENABLE_ARENA_DBG = 0;
|
||||
}
|
||||
|
||||
|
@ -243,14 +243,14 @@ void GameState_Update(GameState* gameState) {
|
|||
func_800C4344(gameState);
|
||||
|
||||
if (SREG(63) == 1u) {
|
||||
if (SREG(48) < 0) {
|
||||
SREG(48) = 0;
|
||||
if (R_VI_MODE_EDIT_STATE < VI_MODE_EDIT_STATE_INACTIVE) {
|
||||
R_VI_MODE_EDIT_STATE = VI_MODE_EDIT_STATE_INACTIVE;
|
||||
gfxCtx->viMode = &gViConfigMode;
|
||||
gfxCtx->viFeatures = gViConfigFeatures;
|
||||
gfxCtx->xScale = gViConfigXScale;
|
||||
gfxCtx->yScale = gViConfigYScale;
|
||||
} else if (SREG(48) > 0) {
|
||||
ViMode_Update(&sViMode, gameState->input);
|
||||
} else if (R_VI_MODE_EDIT_STATE > VI_MODE_EDIT_STATE_INACTIVE) {
|
||||
ViMode_Update(&sViMode, &gameState->input[0]);
|
||||
gfxCtx->viMode = &sViMode.customViMode;
|
||||
gfxCtx->viFeatures = sViMode.viFeatures;
|
||||
gfxCtx->xScale = 1.0f;
|
||||
|
@ -261,6 +261,7 @@ void GameState_Update(GameState* gameState) {
|
|||
gfxCtx->viFeatures = gViConfigFeatures;
|
||||
gfxCtx->xScale = gViConfigXScale;
|
||||
gfxCtx->yScale = gViConfigYScale;
|
||||
|
||||
if (SREG(63) == 6 || (SREG(63) == 2u && osTvType == OS_TV_NTSC)) {
|
||||
gfxCtx->viMode = &osViModeNtscLan1;
|
||||
gfxCtx->yScale = 1.0f;
|
||||
|
@ -304,7 +305,8 @@ void GameState_Update(GameState* gameState) {
|
|||
HREG(83) = HREG(82);
|
||||
HREG(84) = HREG(81);
|
||||
gViConfigAdditionalScanLines = HREG(82);
|
||||
gViConfigYScale = HREG(81) == 0 ? 240.0f / (gViConfigAdditionalScanLines + 240.0f) : 1.0f;
|
||||
gViConfigYScale =
|
||||
HREG(81) == 0 ? ((f32)SCREEN_HEIGHT) / (gViConfigAdditionalScanLines + (f32)SCREEN_HEIGHT) : 1.0f;
|
||||
D_80009430 = 1;
|
||||
}
|
||||
}
|
||||
|
@ -323,10 +325,10 @@ void GameState_InitArena(GameState* gameState, size_t size) {
|
|||
osSyncPrintf("ハイラル確保 サイズ=%u バイト\n"); // "Hyrule reserved size = %u bytes"
|
||||
arena = GameAlloc_MallocDebug(&gameState->alloc, size, "../game.c", 992);
|
||||
if (arena != NULL) {
|
||||
THA_Ct(&gameState->tha, arena, size);
|
||||
THA_Init(&gameState->tha, arena, size);
|
||||
osSyncPrintf("ハイラル確保成功\n"); // "Successful Hyral"
|
||||
} else {
|
||||
THA_Ct(&gameState->tha, NULL, 0);
|
||||
THA_Init(&gameState->tha, NULL, 0);
|
||||
osSyncPrintf("ハイラル確保失敗\n"); // "Failure to secure Hyrule"
|
||||
Fault_AddHungupAndCrash("../game.c", 999);
|
||||
}
|
||||
|
@ -338,10 +340,10 @@ void GameState_Realloc(GameState* gameState, size_t size) {
|
|||
u32 systemMaxFree;
|
||||
u32 systemFree;
|
||||
u32 systemAlloc;
|
||||
void* thaBufp = gameState->tha.bufp;
|
||||
void* thaStart = gameState->tha.start;
|
||||
|
||||
THA_Dt(&gameState->tha);
|
||||
GameAlloc_Free(alloc, thaBufp);
|
||||
THA_Destroy(&gameState->tha);
|
||||
GameAlloc_Free(alloc, thaStart);
|
||||
osSyncPrintf("ハイラル一時解放!!\n"); // "Hyrule temporarily released!!"
|
||||
SystemArena_GetSizes(&systemMaxFree, &systemFree, &systemAlloc);
|
||||
if ((systemMaxFree - 0x10) < size) {
|
||||
|
@ -358,10 +360,10 @@ void GameState_Realloc(GameState* gameState, size_t size) {
|
|||
osSyncPrintf("ハイラル再確保 サイズ=%u バイト\n", size); // "Hyral reallocate size = %u bytes"
|
||||
gameArena = GameAlloc_MallocDebug(alloc, size, "../game.c", 1033);
|
||||
if (gameArena != NULL) {
|
||||
THA_Ct(&gameState->tha, gameArena, size);
|
||||
THA_Init(&gameState->tha, gameArena, size);
|
||||
osSyncPrintf("ハイラル再確保成功\n"); // "Successful reacquisition of Hyrule"
|
||||
} else {
|
||||
THA_Ct(&gameState->tha, NULL, 0);
|
||||
THA_Init(&gameState->tha, NULL, 0);
|
||||
osSyncPrintf("ハイラル再確保失敗\n"); // "Failure to secure Hyral"
|
||||
SystemArena_Display();
|
||||
Fault_AddHungupAndCrash("../game.c", 1044);
|
||||
|
@ -406,7 +408,7 @@ void GameState_Init(GameState* gameState, GameStateFunc init, GraphicsContext* g
|
|||
func_800ACE70(&D_801664F0);
|
||||
func_800AD920(&D_80166500);
|
||||
VisMono_Init(&sMonoColors);
|
||||
if (SREG(48) == 0) {
|
||||
if (R_VI_MODE_EDIT_STATE == VI_MODE_EDIT_STATE_INACTIVE) {
|
||||
ViMode_Init(&sViMode);
|
||||
}
|
||||
SpeedMeter_Init(&D_801664D0);
|
||||
|
@ -436,10 +438,10 @@ void GameState_Destroy(GameState* gameState) {
|
|||
func_800ACE90(&D_801664F0);
|
||||
func_800AD950(&D_80166500);
|
||||
VisMono_Destroy(&sMonoColors);
|
||||
if (SREG(48) == 0) {
|
||||
if (R_VI_MODE_EDIT_STATE == VI_MODE_EDIT_STATE_INACTIVE) {
|
||||
ViMode_Destroy(&sViMode);
|
||||
}
|
||||
THA_Dt(&gameState->tha);
|
||||
THA_Destroy(&gameState->tha);
|
||||
GameAlloc_Cleanup(&gameState->alloc);
|
||||
SystemArena_Display();
|
||||
Fault_RemoveClient(&sGameFaultClient);
|
||||
|
@ -465,13 +467,13 @@ void* GameState_Alloc(GameState* gameState, size_t size, char* file, s32 line) {
|
|||
if (THA_IsCrash(&gameState->tha)) {
|
||||
osSyncPrintf("ハイラルは滅亡している\n");
|
||||
ret = NULL;
|
||||
} else if ((u32)THA_GetSize(&gameState->tha) < size) {
|
||||
} else if ((u32)THA_GetRemaining(&gameState->tha) < size) {
|
||||
// "Hyral on the verge of extinction does not have %d bytes left (%d bytes until extinction)"
|
||||
osSyncPrintf("滅亡寸前のハイラルには %d バイトの余力もない(滅亡まであと %d バイト)\n", size,
|
||||
THA_GetSize(&gameState->tha));
|
||||
THA_GetRemaining(&gameState->tha));
|
||||
ret = NULL;
|
||||
} else {
|
||||
ret = THA_AllocEndAlign16(&gameState->tha, size);
|
||||
ret = THA_AllocTailAlign16(&gameState->tha, size);
|
||||
if (THA_IsCrash(&gameState->tha)) {
|
||||
osSyncPrintf("ハイラルは滅亡してしまった\n"); // "Hyrule has been destroyed"
|
||||
ret = NULL;
|
||||
|
@ -486,9 +488,9 @@ void* GameState_Alloc(GameState* gameState, size_t size, char* file, s32 line) {
|
|||
}
|
||||
|
||||
void* GameState_AllocEndAlign16(GameState* gameState, size_t size) {
|
||||
return THA_AllocEndAlign16(&gameState->tha, size);
|
||||
return THA_AllocTailAlign16(&gameState->tha, size);
|
||||
}
|
||||
|
||||
s32 GameState_GetArenaSize(GameState* gameState) {
|
||||
return THA_GetSize(&gameState->tha);
|
||||
return THA_GetRemaining(&gameState->tha);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "global.h"
|
||||
#include "vt.h"
|
||||
#include "terminal.h"
|
||||
|
||||
#define GFXPOOL_HEAD_MAGIC 0x1234
|
||||
#define GFXPOOL_TAIL_MAGIC 0x5678
|
||||
|
@ -93,10 +93,10 @@ void Graph_InitTHGA(GraphicsContext* gfxCtx) {
|
|||
|
||||
pool->headMagic = GFXPOOL_HEAD_MAGIC;
|
||||
pool->tailMagic = GFXPOOL_TAIL_MAGIC;
|
||||
THGA_Ct(&gfxCtx->polyOpa, pool->polyOpaBuffer, sizeof(pool->polyOpaBuffer));
|
||||
THGA_Ct(&gfxCtx->polyXlu, pool->polyXluBuffer, sizeof(pool->polyXluBuffer));
|
||||
THGA_Ct(&gfxCtx->overlay, pool->overlayBuffer, sizeof(pool->overlayBuffer));
|
||||
THGA_Ct(&gfxCtx->work, pool->workBuffer, sizeof(pool->workBuffer));
|
||||
THGA_Init(&gfxCtx->polyOpa, pool->polyOpaBuffer, sizeof(pool->polyOpaBuffer));
|
||||
THGA_Init(&gfxCtx->polyXlu, pool->polyXluBuffer, sizeof(pool->polyXluBuffer));
|
||||
THGA_Init(&gfxCtx->overlay, pool->overlayBuffer, sizeof(pool->overlayBuffer));
|
||||
THGA_Init(&gfxCtx->work, pool->workBuffer, sizeof(pool->workBuffer));
|
||||
|
||||
gfxCtx->polyOpaBuffer = pool->polyOpaBuffer;
|
||||
gfxCtx->polyXluBuffer = pool->polyXluBuffer;
|
||||
|
@ -175,8 +175,8 @@ void Graph_TaskSet00(GraphicsContext* gfxCtx) {
|
|||
osSyncPrintf("RCPが帰ってきませんでした。"); // "RCP did not return."
|
||||
osSyncPrintf(VT_RST);
|
||||
|
||||
LogUtils_LogHexDump((void*)&HW_REG(SP_MEM_ADDR_REG, u32), 0x20);
|
||||
LogUtils_LogHexDump((void*)&DPC_START_REG, 0x20);
|
||||
LogUtils_LogHexDump((void*)PHYS_TO_K1(SP_BASE_REG), 0x20);
|
||||
LogUtils_LogHexDump((void*)PHYS_TO_K1(DPC_BASE_REG), 0x20);
|
||||
LogUtils_LogHexDump(gGfxSPTaskYieldBuffer, sizeof(gGfxSPTaskYieldBuffer));
|
||||
|
||||
SREG(6) = -1;
|
||||
|
@ -321,8 +321,8 @@ void Graph_Update(GraphicsContext* gfxCtx, GameState* gameState) {
|
|||
}
|
||||
|
||||
if (HREG(81) < 0) {
|
||||
LogUtils_LogHexDump((void*)&HW_REG(SP_MEM_ADDR_REG, u32), 0x20);
|
||||
LogUtils_LogHexDump((void*)&DPC_START_REG, 0x20);
|
||||
LogUtils_LogHexDump((void*)PHYS_TO_K1(SP_BASE_REG), 0x20);
|
||||
LogUtils_LogHexDump((void*)PHYS_TO_K1(DPC_BASE_REG), 0x20);
|
||||
}
|
||||
|
||||
if (HREG(81) < 0) {
|
||||
|
@ -458,20 +458,20 @@ void* Graph_Alloc(GraphicsContext* gfxCtx, size_t size) {
|
|||
TwoHeadGfxArena* thga = &gfxCtx->polyOpa;
|
||||
|
||||
if (HREG(59) == 1) {
|
||||
osSyncPrintf("graph_alloc siz=%d thga size=%08x bufp=%08x head=%08x tail=%08x\n", size, thga->size, thga->bufp,
|
||||
osSyncPrintf("graph_alloc siz=%d thga size=%08x bufp=%08x head=%08x tail=%08x\n", size, thga->size, thga->start,
|
||||
thga->p, thga->d);
|
||||
}
|
||||
return THGA_AllocEnd(&gfxCtx->polyOpa, ALIGN16(size));
|
||||
return THGA_AllocTail(&gfxCtx->polyOpa, ALIGN16(size));
|
||||
}
|
||||
|
||||
void* Graph_Alloc2(GraphicsContext* gfxCtx, size_t size) {
|
||||
TwoHeadGfxArena* thga = &gfxCtx->polyOpa;
|
||||
|
||||
if (HREG(59) == 1) {
|
||||
osSyncPrintf("graph_alloc siz=%d thga size=%08x bufp=%08x head=%08x tail=%08x\n", size, thga->size, thga->bufp,
|
||||
osSyncPrintf("graph_alloc siz=%d thga size=%08x bufp=%08x head=%08x tail=%08x\n", size, thga->size, thga->start,
|
||||
thga->p, thga->d);
|
||||
}
|
||||
return THGA_AllocEnd(&gfxCtx->polyOpa, ALIGN16(size));
|
||||
return THGA_AllocTail(&gfxCtx->polyOpa, ALIGN16(size));
|
||||
}
|
||||
|
||||
void Graph_OpenDisps(Gfx** dispRefs, GraphicsContext* gfxCtx, const char* file, s32 line) {
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
* @see sched.c
|
||||
*/
|
||||
#include "global.h"
|
||||
#include "vt.h"
|
||||
#include "terminal.h"
|
||||
|
||||
vu32 gIrqMgrResetStatus = IRQ_RESET_STATUS_IDLE;
|
||||
volatile OSTime sIrqMgrResetTime = 0;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "global.h"
|
||||
#include "vt.h"
|
||||
#include "terminal.h"
|
||||
|
||||
s32 gScreenWidth = SCREEN_WIDTH;
|
||||
s32 gScreenHeight = SCREEN_HEIGHT;
|
||||
|
@ -80,7 +80,7 @@ void Main(void* arg) {
|
|||
|
||||
osSyncPrintf("タスクスケジューラの初期化\n"); // "Initialize the task scheduler"
|
||||
StackCheck_Init(&sSchedStackInfo, sSchedStack, STACK_TOP(sSchedStack), 0, 0x100, "sched");
|
||||
Sched_Init(&gScheduler, STACK_TOP(sSchedStack), THREAD_PRI_SCHED, D_80013960, 1, &gIrqMgr);
|
||||
Sched_Init(&gScheduler, STACK_TOP(sSchedStack), THREAD_PRI_SCHED, gViConfigModeType, 1, &gIrqMgr);
|
||||
|
||||
IrqMgr_AddClient(&gIrqMgr, &irqClient, &irqMgrMsgQueue);
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
* done while waiting for this operation to complete.
|
||||
*/
|
||||
#include "global.h"
|
||||
#include "vt.h"
|
||||
#include "terminal.h"
|
||||
|
||||
#define PADMGR_LOG(controllerNo, msg) \
|
||||
if (1) { \
|
||||
|
|
|
@ -50,6 +50,6 @@ void RcpUtils_Reset(void) {
|
|||
// Flush the RDP pipeline and freeze clock counter
|
||||
osDpSetStatus(DPC_SET_FREEZE | DPC_SET_FLUSH);
|
||||
// Halt the RSP, disable interrupt on break and set "task done" signal
|
||||
__osSpSetStatus(SP_SET_HALT | SP_SET_SIG2 | SP_CLR_INTR_BREAK);
|
||||
__osSpSetStatus(SP_SET_HALT | SP_SET_TASKDONE | SP_CLR_INTR_BREAK);
|
||||
RcpUtils_PrintRegisterStatus();
|
||||
}
|
||||
|
|
|
@ -650,7 +650,7 @@ void Sched_ThreadEntry(void* arg) {
|
|||
}
|
||||
}
|
||||
|
||||
void Sched_Init(Scheduler* sc, void* stack, OSPri priority, UNK_TYPE arg3, UNK_TYPE arg4, IrqMgr* irqMgr) {
|
||||
void Sched_Init(Scheduler* sc, void* stack, OSPri priority, u8 viModeType, UNK_TYPE arg4, IrqMgr* irqMgr) {
|
||||
bzero(sc, sizeof(Scheduler));
|
||||
sc->isFirstSwap = true;
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "global.h"
|
||||
#include "vt.h"
|
||||
#include "terminal.h"
|
||||
|
||||
/**
|
||||
* How much time the audio update on the audio thread (`func_800E4FE0`) took in total, between scheduling the last two
|
||||
|
@ -231,25 +231,26 @@ void SpeedMeter_DrawAllocEntries(SpeedMeter* meter, GraphicsContext* gfxCtx, Gam
|
|||
}
|
||||
|
||||
thga = (TwoHeadGfxArena*)&state->tha;
|
||||
SpeedMeter_InitAllocEntry(&entry, thga->size, thga->size - THA_GetSize((TwoHeadArena*)thga),
|
||||
//! @bug THA_GetRemaining call should be THGA_GetRemaining like the others below, harmless as-is
|
||||
SpeedMeter_InitAllocEntry(&entry, thga->size, thga->size - THA_GetRemaining(&thga->tha),
|
||||
GPACK_RGBA5551(0, 0, 255, 1), GPACK_RGBA5551(0, 255, 0, 1), ulx, lrx, y, y);
|
||||
SpeedMeter_DrawAllocEntry(&entry, gfxCtx);
|
||||
y++;
|
||||
|
||||
thga = &gfxCtx->polyOpa;
|
||||
SpeedMeter_InitAllocEntry(&entry, thga->size, thga->size - THGA_GetSize(thga), GPACK_RGBA5551(0, 0, 255, 1),
|
||||
SpeedMeter_InitAllocEntry(&entry, thga->size, thga->size - THGA_GetRemaining(thga), GPACK_RGBA5551(0, 0, 255, 1),
|
||||
GPACK_RGBA5551(255, 0, 255, 1), ulx, lrx, y, y);
|
||||
SpeedMeter_DrawAllocEntry(&entry, gfxCtx);
|
||||
y++;
|
||||
|
||||
thga = &gfxCtx->polyXlu;
|
||||
SpeedMeter_InitAllocEntry(&entry, thga->size, thga->size - THGA_GetSize(thga), GPACK_RGBA5551(0, 0, 255, 1),
|
||||
SpeedMeter_InitAllocEntry(&entry, thga->size, thga->size - THGA_GetRemaining(thga), GPACK_RGBA5551(0, 0, 255, 1),
|
||||
GPACK_RGBA5551(255, 255, 0, 1), ulx, lrx, y, y);
|
||||
SpeedMeter_DrawAllocEntry(&entry, gfxCtx);
|
||||
y++;
|
||||
|
||||
thga = &gfxCtx->overlay;
|
||||
SpeedMeter_InitAllocEntry(&entry, thga->size, thga->size - THGA_GetSize(thga), GPACK_RGBA5551(0, 0, 255, 1),
|
||||
SpeedMeter_InitAllocEntry(&entry, thga->size, thga->size - THGA_GetRemaining(thga), GPACK_RGBA5551(0, 0, 255, 1),
|
||||
GPACK_RGBA5551(255, 0, 0, 1), ulx, lrx, y, y);
|
||||
SpeedMeter_DrawAllocEntry(&entry, gfxCtx);
|
||||
y++;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "global.h"
|
||||
#include "vt.h"
|
||||
#include "terminal.h"
|
||||
|
||||
s32 Math3D_LineVsLineClosestTwoPoints(Vec3f* lineAPointA, Vec3f* lineAPointB, Vec3f* lineBPointA, Vec3f* lineBPointB,
|
||||
Vec3f* lineAClosestToB, Vec3f* lineBClosestToA);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "global.h"
|
||||
#include "vt.h"
|
||||
#include "terminal.h"
|
||||
|
||||
void Overlay_LoadGameState(GameStateOverlay* overlayEntry) {
|
||||
if (overlayEntry->loadedRamAddr != NULL) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "global.h"
|
||||
#include "quake.h"
|
||||
#include "vt.h"
|
||||
#include "terminal.h"
|
||||
|
||||
#include "overlays/actors/ovl_Arms_Hook/z_arms_hook.h"
|
||||
#include "overlays/actors/ovl_En_Part/z_en_part.h"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "global.h"
|
||||
#include "vt.h"
|
||||
#include "terminal.h"
|
||||
|
||||
u16 DynaSSNodeList_GetNextNodeIdx(DynaSSNodeList* nodeList);
|
||||
void BgCheck_GetStaticLookupIndicesFromPos(CollisionContext* colCtx, Vec3f* pos, Vec3i* sector);
|
||||
|
@ -149,7 +149,7 @@ void DynaSSNodeList_Initialize(PlayState* play, DynaSSNodeList* nodeList) {
|
|||
* Initialize DynaSSNodeList tbl
|
||||
*/
|
||||
void DynaSSNodeList_Alloc(PlayState* play, DynaSSNodeList* nodeList, s32 max) {
|
||||
nodeList->tbl = THA_AllocEndAlign(&play->state.tha, max * sizeof(SSNode), -2);
|
||||
nodeList->tbl = THA_AllocTailAlign(&play->state.tha, max * sizeof(SSNode), ALIGNOF_MASK(SSNode));
|
||||
|
||||
ASSERT(nodeList->tbl != NULL, "psst->tbl != NULL", "../z_bgcheck.c", 1811);
|
||||
|
||||
|
@ -1613,9 +1613,10 @@ void BgCheck_Allocate(CollisionContext* colCtx, PlayState* play, CollisionHeader
|
|||
colCtx->subdivAmount.z = 16;
|
||||
}
|
||||
}
|
||||
colCtx->lookupTbl = THA_AllocEndAlign(
|
||||
&play->state.tha,
|
||||
colCtx->subdivAmount.x * sizeof(StaticLookup) * colCtx->subdivAmount.y * colCtx->subdivAmount.z, ~1);
|
||||
colCtx->lookupTbl = THA_AllocTailAlign(&play->state.tha,
|
||||
colCtx->subdivAmount.x * sizeof(StaticLookup) * colCtx->subdivAmount.y *
|
||||
colCtx->subdivAmount.z,
|
||||
ALIGNOF_MASK(StaticLookup));
|
||||
if (colCtx->lookupTbl == NULL) {
|
||||
LogUtils_HungupThread("../z_bgcheck.c", 4176);
|
||||
}
|
||||
|
@ -2501,7 +2502,7 @@ void SSNodeList_Initialize(SSNodeList* this) {
|
|||
void SSNodeList_Alloc(PlayState* play, SSNodeList* this, s32 tblMax, s32 numPolys) {
|
||||
this->max = tblMax;
|
||||
this->count = 0;
|
||||
this->tbl = THA_AllocEndAlign(&play->state.tha, tblMax * sizeof(SSNode), -2);
|
||||
this->tbl = THA_AllocTailAlign(&play->state.tha, tblMax * sizeof(SSNode), ALIGNOF_MASK(SSNode));
|
||||
|
||||
ASSERT(this->tbl != NULL, "this->short_slist_node_tbl != NULL", "../z_bgcheck.c", 5975);
|
||||
|
||||
|
@ -2636,7 +2637,7 @@ void DynaPoly_NullPolyList(CollisionPoly** polyList) {
|
|||
* Allocate dyna.polyList
|
||||
*/
|
||||
void DynaPoly_AllocPolyList(PlayState* play, CollisionPoly** polyList, s32 numPolys) {
|
||||
*polyList = THA_AllocEndAlign(&play->state.tha, numPolys * sizeof(CollisionPoly), -2);
|
||||
*polyList = THA_AllocTailAlign(&play->state.tha, numPolys * sizeof(CollisionPoly), ALIGNOF_MASK(CollisionPoly));
|
||||
ASSERT(*polyList != NULL, "ptbl->pbuf != NULL", "../z_bgcheck.c", 6247);
|
||||
}
|
||||
|
||||
|
@ -2651,7 +2652,7 @@ void DynaPoly_NullVtxList(Vec3s** vtxList) {
|
|||
* Allocate dyna.vtxList
|
||||
*/
|
||||
void DynaPoly_AllocVtxList(PlayState* play, Vec3s** vtxList, s32 numVtx) {
|
||||
*vtxList = THA_AllocEndAlign(&play->state.tha, numVtx * sizeof(Vec3s), -2);
|
||||
*vtxList = THA_AllocTailAlign(&play->state.tha, numVtx * sizeof(Vec3s), ALIGNOF_MASK(Vec3s));
|
||||
ASSERT(*vtxList != NULL, "ptbl->pbuf != NULL", "../z_bgcheck.c", 6277);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "ultra64.h"
|
||||
#include "global.h"
|
||||
#include "quake.h"
|
||||
#include "vt.h"
|
||||
#include "terminal.h"
|
||||
#include "overlays/actors/ovl_En_Horse/z_en_horse.h"
|
||||
|
||||
s16 Camera_ChangeSettingFlags(Camera* camera, s16 setting, s16 flags);
|
||||
|
@ -816,10 +816,10 @@ Vec3f* Camera_BGCheckCorner(Vec3f* dst, Vec3f* linePointA, Vec3f* linePointB, Ca
|
|||
}
|
||||
|
||||
/**
|
||||
* Checks collision between at and eyeNext, if `checkEye` is set, if there is no collsion between
|
||||
* Checks collision between at and eyeNext, if `checkEye` is set, if there is no collision between
|
||||
* eyeNext->at, then eye->at is also checked.
|
||||
* Returns:
|
||||
* 0 if no collsion is found between at->eyeNext
|
||||
* 0 if no collision is found between at->eyeNext
|
||||
* 2 if the angle between the polys is between 60 degrees and 120 degrees
|
||||
* 3 ?
|
||||
* 6 if the angle between the polys is greater than 120 degrees
|
||||
|
@ -2531,7 +2531,7 @@ s32 Camera_Jump2(Camera* camera) {
|
|||
Camera_AddVecGeoToVec3f(&camBgChk.pos, at, &bgChkPara);
|
||||
if (Camera_BGCheckInfo(camera, at, &camBgChk)) {
|
||||
// Collision found between parallel at->eyeNext, set eye position to
|
||||
// first collsion point.
|
||||
// first collision point.
|
||||
*eye = bgChkPos;
|
||||
} else {
|
||||
// no collision found with the parallel at->eye, animate to be parallel
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "global.h"
|
||||
#include "vt.h"
|
||||
#include "terminal.h"
|
||||
#include "overlays/effects/ovl_Effect_Ss_HitMark/z_eff_ss_hitmark.h"
|
||||
|
||||
typedef s32 (*ColChkResetFunc)(PlayState*, Collider*);
|
||||
|
@ -2648,8 +2648,8 @@ void CollisionCheck_SetOCvsOC(Collider* left, ColliderInfo* leftInfo, Vec3f* lef
|
|||
f32 zDelta;
|
||||
Actor* leftActor = left->actor;
|
||||
Actor* rightActor = right->actor;
|
||||
s32 leftMassType;
|
||||
s32 rightMassType;
|
||||
s32 leftMassType;
|
||||
|
||||
left->ocFlags1 |= OC1_HIT;
|
||||
left->oc = rightActor;
|
||||
|
@ -2666,8 +2666,8 @@ void CollisionCheck_SetOCvsOC(Collider* left, ColliderInfo* leftInfo, Vec3f* lef
|
|||
if (leftActor == NULL || rightActor == NULL || left->ocFlags1 & OC1_NO_PUSH || right->ocFlags1 & OC1_NO_PUSH) {
|
||||
return;
|
||||
}
|
||||
rightMassType = CollisionCheck_GetMassType(leftActor->colChkInfo.mass);
|
||||
leftMassType = CollisionCheck_GetMassType(rightActor->colChkInfo.mass);
|
||||
leftMassType = CollisionCheck_GetMassType(leftActor->colChkInfo.mass);
|
||||
rightMassType = CollisionCheck_GetMassType(rightActor->colChkInfo.mass);
|
||||
leftMass = leftActor->colChkInfo.mass;
|
||||
rightMass = rightActor->colChkInfo.mass;
|
||||
totalMass = leftMass + rightMass;
|
||||
|
@ -2679,30 +2679,30 @@ void CollisionCheck_SetOCvsOC(Collider* left, ColliderInfo* leftInfo, Vec3f* lef
|
|||
zDelta = rightPos->z - leftPos->z;
|
||||
xzDist = sqrtf(SQ(xDelta) + SQ(zDelta));
|
||||
|
||||
if (rightMassType == MASSTYPE_IMMOVABLE) {
|
||||
if (leftMassType == MASSTYPE_IMMOVABLE) {
|
||||
if (leftMassType == MASSTYPE_IMMOVABLE) {
|
||||
if (rightMassType == MASSTYPE_IMMOVABLE) {
|
||||
return;
|
||||
} else { // leftMassType == MASS_HEAVY | MASS_NORMAL
|
||||
} else { // rightMassType == MASSTYPE_HEAVY or MASSTYPE_NORMAL
|
||||
leftDispRatio = 0;
|
||||
rightDispRatio = 1;
|
||||
}
|
||||
} else if (rightMassType == MASSTYPE_HEAVY) {
|
||||
if (leftMassType == MASSTYPE_IMMOVABLE) {
|
||||
} else if (leftMassType == MASSTYPE_HEAVY) {
|
||||
if (rightMassType == MASSTYPE_IMMOVABLE) {
|
||||
leftDispRatio = 1;
|
||||
rightDispRatio = 0;
|
||||
} else if (leftMassType == MASSTYPE_HEAVY) {
|
||||
} else if (rightMassType == MASSTYPE_HEAVY) {
|
||||
leftDispRatio = 0.5f;
|
||||
rightDispRatio = 0.5f;
|
||||
} else { // leftMassType == MASS_NORMAL
|
||||
} else { // rightMassType == MASSTYPE_NORMAL
|
||||
leftDispRatio = 0;
|
||||
rightDispRatio = 1;
|
||||
}
|
||||
} else { // rightMassType == MASS_NORMAL
|
||||
if (leftMassType == MASSTYPE_NORMAL) {
|
||||
} else { // leftMassType == MASSTYPE_NORMAL
|
||||
if (rightMassType == MASSTYPE_NORMAL) {
|
||||
inverseTotalMass = 1 / totalMass;
|
||||
leftDispRatio = rightMass * inverseTotalMass;
|
||||
rightDispRatio = leftMass * inverseTotalMass;
|
||||
} else { // leftMassType == MASS_HEAVY | MASS_IMMOVABLE
|
||||
} else { // rightMassType == MASSTYPE_HEAVY or MASSTYPE_IMMOVABLE
|
||||
leftDispRatio = 1;
|
||||
rightDispRatio = 0;
|
||||
}
|
||||
|
@ -3494,7 +3494,7 @@ s32 CollisionCheck_CylSideVsLineSeg(f32 radius, f32 height, f32 offset, Vec3f* a
|
|||
}
|
||||
radSqDiff = SQXZ(actorToItem) - SQ(radius);
|
||||
if (!IS_ZERO(SQXZ(itemStep))) {
|
||||
actorDotItemXZ = DOTXZ(2.0f * itemStep, actorToItem);
|
||||
actorDotItemXZ = (2.0f * itemStep.x * actorToItem.x) + (2.0f * itemStep.z * actorToItem.z);
|
||||
if (SQ(actorDotItemXZ) < (4.0f * SQXZ(itemStep) * radSqDiff)) {
|
||||
return 0;
|
||||
}
|
||||
|
@ -3511,10 +3511,10 @@ s32 CollisionCheck_CylSideVsLineSeg(f32 radius, f32 height, f32 offset, Vec3f* a
|
|||
if (intersect2 == true) {
|
||||
frac2 = (-actorDotItemXZ - closeDist) / (2.0f * SQXZ(itemStep));
|
||||
}
|
||||
} else if (!IS_ZERO(DOTXZ(2.0f * itemStep, actorToItem))) {
|
||||
} else if (!IS_ZERO((2.0f * itemStep.x * actorToItem.x) + (2.0f * itemStep.z * actorToItem.z))) {
|
||||
intersect1 = true;
|
||||
intersect2 = false;
|
||||
frac1 = -radSqDiff / DOTXZ(2.0f * itemStep, actorToItem);
|
||||
frac1 = -radSqDiff / ((2.0f * itemStep.x * actorToItem.x) + (2.0f * itemStep.z * actorToItem.z));
|
||||
} else {
|
||||
if (radSqDiff <= 0.0f) {
|
||||
test1 = (0.0f < actorToItem.y) && (actorToItem.y < height);
|
||||
|
|
|
@ -248,8 +248,8 @@ void func_80064824(PlayState* play, CutsceneContext* csCtx, CsCmdBase* cmd) {
|
|||
}
|
||||
break;
|
||||
case 6:
|
||||
if (play->envCtx.adjFogFar < 12800) {
|
||||
play->envCtx.adjFogFar += 35;
|
||||
if (play->envCtx.adjZFar < ENV_ZFAR_MAX) {
|
||||
play->envCtx.adjZFar += 35;
|
||||
}
|
||||
break;
|
||||
case 7:
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "global.h"
|
||||
#include "vt.h"
|
||||
#include "terminal.h"
|
||||
#include "assets/objects/gameplay_keep/gameplay_keep.h"
|
||||
|
||||
static Vtx sVertices[5] = {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "global.h"
|
||||
#include "vt.h"
|
||||
#include "terminal.h"
|
||||
|
||||
EffectSsInfo sEffectSsInfo = { 0 }; // "EffectSS2Info"
|
||||
|
||||
|
|
|
@ -748,7 +748,7 @@ void EffectSsFhgFlash_SpawnLightBall(PlayState* play, Vec3f* pos, Vec3f* velocit
|
|||
* Spawn a shock effect
|
||||
*
|
||||
* param determines where the ligntning should go
|
||||
* 0: dont attach to any actor. spawns at the position specified by pos
|
||||
* 0: don't attach to any actor. spawns at the position specified by pos
|
||||
* 1: spawn at one of Player's body parts, chosen at random
|
||||
* 2: spawn at one of Phantom Ganon's body parts, chosen at random
|
||||
*/
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
#include "global.h"
|
||||
#include "vt.h"
|
||||
#include "assets/objects/gameplay_keep/gameplay_keep.h"
|
||||
#include "assets/objects/object_d_hsblock/object_d_hsblock.h"
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "global.h"
|
||||
#include "vt.h"
|
||||
#include "terminal.h"
|
||||
|
||||
static Gfx sRCPSetupFade[] = {
|
||||
gsDPPipeSync(),
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "global.h"
|
||||
#include "vt.h"
|
||||
#include "terminal.h"
|
||||
#include "src/overlays/actors/ovl_En_Horse/z_en_horse.h"
|
||||
|
||||
s32 func_8006CFC0(s32 sceneId) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "global.h"
|
||||
#include "vt.h"
|
||||
#include "terminal.h"
|
||||
|
||||
#define MARKER_ESCAPE 0x00
|
||||
#define MARKER_SOI 0xD8
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "global.h"
|
||||
#include "vt.h"
|
||||
#include "terminal.h"
|
||||
|
||||
#define KALEIDO_OVERLAY(name, nameString) \
|
||||
{ \
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "global.h"
|
||||
#include "vt.h"
|
||||
#include "terminal.h"
|
||||
|
||||
void (*sKaleidoScopeUpdateFunc)(PlayState* play);
|
||||
void (*sKaleidoScopeDrawFunc)(PlayState* play);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "global.h"
|
||||
#include "ultra64.h"
|
||||
#include "vt.h"
|
||||
#include "terminal.h"
|
||||
#include "assets/objects/gameplay_keep/gameplay_keep.h"
|
||||
#include "assets/objects/gameplay_field_keep/gameplay_field_keep.h"
|
||||
|
||||
|
@ -319,7 +319,7 @@ void Environment_Init(PlayState* play2, EnvironmentContext* envCtx, s32 unused)
|
|||
|
||||
envCtx->adjAmbientColor[0] = envCtx->adjAmbientColor[1] = envCtx->adjAmbientColor[2] = envCtx->adjLight1Color[0] =
|
||||
envCtx->adjLight1Color[1] = envCtx->adjLight1Color[2] = envCtx->adjFogColor[0] = envCtx->adjFogColor[1] =
|
||||
envCtx->adjFogColor[2] = envCtx->adjFogNear = envCtx->adjFogFar = 0;
|
||||
envCtx->adjFogColor[2] = envCtx->adjFogNear = envCtx->adjZFar = 0;
|
||||
|
||||
envCtx->sunPos.x = -(Math_SinS(((void)0, gSaveContext.dayTime) - CLOCK_TIME(12, 0)) * 120.0f) * 25.0f;
|
||||
envCtx->sunPos.y = +(Math_CosS(((void)0, gSaveContext.dayTime) - CLOCK_TIME(12, 0)) * 120.0f) * 25.0f;
|
||||
|
@ -873,8 +873,8 @@ void Environment_UpdateRain(PlayState* play);
|
|||
|
||||
void Environment_Update(PlayState* play, EnvironmentContext* envCtx, LightContext* lightCtx, PauseContext* pauseCtx,
|
||||
MessageContext* msgCtx, GameOverContext* gameOverCtx, GraphicsContext* gfxCtx) {
|
||||
f32 sp8C;
|
||||
f32 sp88 = 0.0f;
|
||||
f32 timeChangeBlend;
|
||||
f32 configChangeBlend = 0.0f;
|
||||
u16 i;
|
||||
u16 j;
|
||||
u16 time;
|
||||
|
@ -986,16 +986,18 @@ void Environment_Update(PlayState* play, EnvironmentContext* envCtx, LightContex
|
|||
u8 blend8[2];
|
||||
s16 blend16[2];
|
||||
|
||||
sp8C = Environment_LerpWeight(sTimeBasedLightConfigs[envCtx->lightConfig][i].endTime,
|
||||
sTimeBasedLightConfigs[envCtx->lightConfig][i].startTime,
|
||||
((void)0, gSaveContext.skyboxTime));
|
||||
timeChangeBlend =
|
||||
Environment_LerpWeight(sTimeBasedLightConfigs[envCtx->lightConfig][i].endTime,
|
||||
sTimeBasedLightConfigs[envCtx->lightConfig][i].startTime,
|
||||
((void)0, gSaveContext.skyboxTime));
|
||||
|
||||
sSandstormColorIndex = sTimeBasedLightConfigs[envCtx->lightConfig][i].lightSetting & 3;
|
||||
sNextSandstormColorIndex = sTimeBasedLightConfigs[envCtx->lightConfig][i].nextLightSetting & 3;
|
||||
sSandstormLerpScale = sp8C;
|
||||
sSandstormLerpScale = timeChangeBlend;
|
||||
|
||||
if (envCtx->changeLightEnabled) {
|
||||
sp88 = ((f32)envCtx->changeDuration - envCtx->changeLightTimer) / envCtx->changeDuration;
|
||||
configChangeBlend =
|
||||
((f32)envCtx->changeDuration - envCtx->changeLightTimer) / envCtx->changeDuration;
|
||||
envCtx->changeLightTimer--;
|
||||
|
||||
if (envCtx->changeLightTimer <= 0) {
|
||||
|
@ -1011,15 +1013,15 @@ void Environment_Update(PlayState* play, EnvironmentContext* envCtx, LightContex
|
|||
.ambientColor[j],
|
||||
lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].nextLightSetting]
|
||||
.ambientColor[j],
|
||||
sp8C);
|
||||
timeChangeBlend);
|
||||
blend8[1] = LERP(
|
||||
lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].lightSetting]
|
||||
.ambientColor[j],
|
||||
lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i]
|
||||
.nextLightSetting]
|
||||
.ambientColor[j],
|
||||
sp8C);
|
||||
*(envCtx->lightSettings.ambientColor + j) = LERP(blend8[0], blend8[1], sp88);
|
||||
timeChangeBlend);
|
||||
*(envCtx->lightSettings.ambientColor + j) = LERP(blend8[0], blend8[1], configChangeBlend);
|
||||
}
|
||||
|
||||
// set light1 direction for the sun
|
||||
|
@ -1042,15 +1044,15 @@ void Environment_Update(PlayState* play, EnvironmentContext* envCtx, LightContex
|
|||
.light1Color[j],
|
||||
lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].nextLightSetting]
|
||||
.light1Color[j],
|
||||
sp8C);
|
||||
timeChangeBlend);
|
||||
blend8[1] = LERP(
|
||||
lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].lightSetting]
|
||||
.light1Color[j],
|
||||
lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i]
|
||||
.nextLightSetting]
|
||||
.light1Color[j],
|
||||
sp8C);
|
||||
*(envCtx->lightSettings.light1Color + j) = LERP(blend8[0], blend8[1], sp88);
|
||||
timeChangeBlend);
|
||||
*(envCtx->lightSettings.light1Color + j) = LERP(blend8[0], blend8[1], configChangeBlend);
|
||||
|
||||
// blend light2Color
|
||||
blend8[0] =
|
||||
|
@ -1058,15 +1060,15 @@ void Environment_Update(PlayState* play, EnvironmentContext* envCtx, LightContex
|
|||
.light2Color[j],
|
||||
lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].nextLightSetting]
|
||||
.light2Color[j],
|
||||
sp8C);
|
||||
timeChangeBlend);
|
||||
blend8[1] = LERP(
|
||||
lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].lightSetting]
|
||||
.light2Color[j],
|
||||
lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i]
|
||||
.nextLightSetting]
|
||||
.light2Color[j],
|
||||
sp8C);
|
||||
*(envCtx->lightSettings.light2Color + j) = LERP(blend8[0], blend8[1], sp88);
|
||||
timeChangeBlend);
|
||||
*(envCtx->lightSettings.light2Color + j) = LERP(blend8[0], blend8[1], configChangeBlend);
|
||||
}
|
||||
|
||||
// blend fogColor
|
||||
|
@ -1076,47 +1078,49 @@ void Environment_Update(PlayState* play, EnvironmentContext* envCtx, LightContex
|
|||
.fogColor[j],
|
||||
lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].nextLightSetting]
|
||||
.fogColor[j],
|
||||
sp8C);
|
||||
timeChangeBlend);
|
||||
blend8[1] = LERP(
|
||||
lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].lightSetting]
|
||||
.fogColor[j],
|
||||
lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i]
|
||||
.nextLightSetting]
|
||||
.fogColor[j],
|
||||
sp8C);
|
||||
*(envCtx->lightSettings.fogColor + j) = LERP(blend8[0], blend8[1], sp88);
|
||||
timeChangeBlend);
|
||||
*(envCtx->lightSettings.fogColor + j) = LERP(blend8[0], blend8[1], configChangeBlend);
|
||||
}
|
||||
|
||||
blend16[0] = LERP16(
|
||||
(lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].lightSetting].fogNear &
|
||||
0x3FF),
|
||||
(lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].nextLightSetting]
|
||||
.fogNear &
|
||||
0x3FF),
|
||||
sp8C);
|
||||
ENV_LIGHT_SETTINGS_FOG_NEAR(
|
||||
lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].lightSetting]
|
||||
.blendRateAndFogNear),
|
||||
ENV_LIGHT_SETTINGS_FOG_NEAR(
|
||||
lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].nextLightSetting]
|
||||
.blendRateAndFogNear),
|
||||
timeChangeBlend);
|
||||
blend16[1] = LERP16(
|
||||
lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].lightSetting]
|
||||
.fogNear &
|
||||
0x3FF,
|
||||
lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].nextLightSetting]
|
||||
.fogNear &
|
||||
0x3FF,
|
||||
sp8C);
|
||||
ENV_LIGHT_SETTINGS_FOG_NEAR(
|
||||
lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].lightSetting]
|
||||
.blendRateAndFogNear),
|
||||
ENV_LIGHT_SETTINGS_FOG_NEAR(
|
||||
lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i]
|
||||
.nextLightSetting]
|
||||
.blendRateAndFogNear),
|
||||
timeChangeBlend);
|
||||
|
||||
envCtx->lightSettings.fogNear = LERP16(blend16[0], blend16[1], sp88);
|
||||
envCtx->lightSettings.fogNear = LERP16(blend16[0], blend16[1], configChangeBlend);
|
||||
|
||||
blend16[0] = LERP16(
|
||||
lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].lightSetting].fogFar,
|
||||
lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].nextLightSetting].fogFar,
|
||||
sp8C);
|
||||
lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].lightSetting].zFar,
|
||||
lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].nextLightSetting].zFar,
|
||||
timeChangeBlend);
|
||||
blend16[1] = LERP16(
|
||||
lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].lightSetting]
|
||||
.fogFar,
|
||||
.zFar,
|
||||
lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].nextLightSetting]
|
||||
.fogFar,
|
||||
sp8C);
|
||||
.zFar,
|
||||
timeChangeBlend);
|
||||
|
||||
envCtx->lightSettings.fogFar = LERP16(blend16[0], blend16[1], sp88);
|
||||
envCtx->lightSettings.zFar = LERP16(blend16[0], blend16[1], configChangeBlend);
|
||||
|
||||
if (sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].nextLightSetting >=
|
||||
envCtx->numLightSettings) {
|
||||
|
@ -1142,11 +1146,13 @@ void Environment_Update(PlayState* play, EnvironmentContext* envCtx, LightContex
|
|||
envCtx->lightSettings.fogColor[i] = lightSettingsList[envCtx->lightSetting].fogColor[i];
|
||||
}
|
||||
|
||||
envCtx->lightSettings.fogNear = lightSettingsList[envCtx->lightSetting].fogNear & 0x3FF;
|
||||
envCtx->lightSettings.fogFar = lightSettingsList[envCtx->lightSetting].fogFar;
|
||||
envCtx->lightSettings.fogNear =
|
||||
ENV_LIGHT_SETTINGS_FOG_NEAR(lightSettingsList[envCtx->lightSetting].blendRateAndFogNear);
|
||||
envCtx->lightSettings.zFar = lightSettingsList[envCtx->lightSetting].zFar;
|
||||
envCtx->lightBlend = 1.0f;
|
||||
} else {
|
||||
u8 blendRate = (lightSettingsList[envCtx->lightSetting].fogNear >> 0xA) * 4;
|
||||
u8 blendRate =
|
||||
ENV_LIGHT_SETTINGS_BLEND_RATE_U8(lightSettingsList[envCtx->lightSetting].blendRateAndFogNear);
|
||||
|
||||
if (blendRate == 0) {
|
||||
blendRate++;
|
||||
|
@ -1184,12 +1190,13 @@ void Environment_Update(PlayState* play, EnvironmentContext* envCtx, LightContex
|
|||
LERP(lightSettingsList[envCtx->prevLightSetting].fogColor[i],
|
||||
lightSettingsList[envCtx->lightSetting].fogColor[i], envCtx->lightBlend);
|
||||
}
|
||||
envCtx->lightSettings.fogNear =
|
||||
LERP16(lightSettingsList[envCtx->prevLightSetting].fogNear & 0x3FF,
|
||||
lightSettingsList[envCtx->lightSetting].fogNear & 0x3FF, envCtx->lightBlend);
|
||||
envCtx->lightSettings.fogFar =
|
||||
LERP16(lightSettingsList[envCtx->prevLightSetting].fogFar,
|
||||
lightSettingsList[envCtx->lightSetting].fogFar, envCtx->lightBlend);
|
||||
envCtx->lightSettings.fogNear = LERP16(
|
||||
ENV_LIGHT_SETTINGS_FOG_NEAR(lightSettingsList[envCtx->prevLightSetting].blendRateAndFogNear),
|
||||
ENV_LIGHT_SETTINGS_FOG_NEAR(lightSettingsList[envCtx->lightSetting].blendRateAndFogNear),
|
||||
envCtx->lightBlend);
|
||||
envCtx->lightSettings.zFar =
|
||||
LERP16(lightSettingsList[envCtx->prevLightSetting].zFar,
|
||||
lightSettingsList[envCtx->lightSetting].zFar, envCtx->lightBlend);
|
||||
}
|
||||
|
||||
if (envCtx->lightSetting >= envCtx->numLightSettings) {
|
||||
|
@ -1254,18 +1261,18 @@ void Environment_Update(PlayState* play, EnvironmentContext* envCtx, LightContex
|
|||
// Adjust fog near and far if necessary
|
||||
adjustment = envCtx->lightSettings.fogNear + envCtx->adjFogNear;
|
||||
|
||||
if (adjustment <= 996) {
|
||||
if (adjustment <= ENV_FOGNEAR_MAX) {
|
||||
lightCtx->fogNear = adjustment;
|
||||
} else {
|
||||
lightCtx->fogNear = 996;
|
||||
lightCtx->fogNear = ENV_FOGNEAR_MAX;
|
||||
}
|
||||
|
||||
adjustment = envCtx->lightSettings.fogFar + envCtx->adjFogFar;
|
||||
adjustment = envCtx->lightSettings.zFar + envCtx->adjZFar;
|
||||
|
||||
if (adjustment <= 12800) {
|
||||
lightCtx->fogFar = adjustment;
|
||||
if (adjustment <= ENV_ZFAR_MAX) {
|
||||
lightCtx->zFar = adjustment;
|
||||
} else {
|
||||
lightCtx->fogFar = 12800;
|
||||
lightCtx->zFar = ENV_ZFAR_MAX;
|
||||
}
|
||||
|
||||
// When environment debug is enabled, various environment related variables can be configured via the reg editor
|
||||
|
@ -1286,7 +1293,7 @@ void Environment_Update(PlayState* play, EnvironmentContext* envCtx, LightContex
|
|||
R_ENV_FOG_COLOR(1) = lightCtx->fogColor[1];
|
||||
R_ENV_FOG_COLOR(2) = lightCtx->fogColor[2];
|
||||
|
||||
R_ENV_FOG_FAR = lightCtx->fogFar;
|
||||
R_ENV_Z_FAR = lightCtx->zFar;
|
||||
R_ENV_FOG_NEAR = lightCtx->fogNear;
|
||||
|
||||
R_ENV_LIGHT1_DIR(0) = envCtx->dirLight1.params.dir.x;
|
||||
|
@ -1317,7 +1324,7 @@ void Environment_Update(PlayState* play, EnvironmentContext* envCtx, LightContex
|
|||
lightCtx->fogColor[1] = R_ENV_FOG_COLOR(1);
|
||||
lightCtx->fogColor[2] = R_ENV_FOG_COLOR(2);
|
||||
lightCtx->fogNear = R_ENV_FOG_NEAR;
|
||||
lightCtx->fogFar = R_ENV_FOG_FAR;
|
||||
lightCtx->zFar = R_ENV_Z_FAR;
|
||||
|
||||
if (cREG(14)) {
|
||||
R_ENV_LIGHT1_DIR(0) = Math_CosS(cREG(10)) * Math_CosS(cREG(11)) * 120.0f;
|
||||
|
@ -1593,7 +1600,7 @@ void Environment_DrawLensFlare(PlayState* play, EnvironmentContext* envCtx, View
|
|||
alpha = alpha * lensFlareAlphas[i];
|
||||
alpha = CLAMP_MIN(alpha, 0.0f);
|
||||
|
||||
fogInfluence = (996 - play->lightCtx.fogNear) / 50.0f;
|
||||
fogInfluence = (ENV_FOGNEAR_MAX - play->lightCtx.fogNear) / 50.0f;
|
||||
|
||||
fogInfluence = CLAMP_MAX(fogInfluence, 1.0f);
|
||||
|
||||
|
@ -1640,7 +1647,7 @@ void Environment_DrawLensFlare(PlayState* play, EnvironmentContext* envCtx, View
|
|||
alpha = alpha * glareStrength;
|
||||
alpha = CLAMP_MIN(alpha, 0.0f);
|
||||
|
||||
fogInfluence = (996 - play->lightCtx.fogNear) / 50.0f;
|
||||
fogInfluence = (ENV_FOGNEAR_MAX - play->lightCtx.fogNear) / 50.0f;
|
||||
|
||||
fogInfluence = CLAMP_MAX(fogInfluence, 1.0f);
|
||||
|
||||
|
@ -2233,8 +2240,8 @@ void Environment_FadeInGameOverLights(PlayState* play) {
|
|||
play->envCtx.adjFogColor[i] = -255;
|
||||
}
|
||||
|
||||
if (play->envCtx.lightSettings.fogFar + play->envCtx.adjFogFar > 900) {
|
||||
play->envCtx.adjFogFar -= 100;
|
||||
if (play->envCtx.lightSettings.zFar + play->envCtx.adjZFar > 900) {
|
||||
play->envCtx.adjZFar -= 100;
|
||||
}
|
||||
|
||||
if (play->envCtx.lightSettings.fogNear + play->envCtx.adjFogNear > 950) {
|
||||
|
@ -2277,7 +2284,7 @@ void Environment_FadeOutGameOverLights(PlayState* play) {
|
|||
Math_SmoothStepToS(&play->envCtx.adjLight1Color[i], 0, 5, 12, 1);
|
||||
play->envCtx.adjFogColor[i] = 0;
|
||||
}
|
||||
play->envCtx.adjFogFar = 0;
|
||||
play->envCtx.adjZFar = 0;
|
||||
play->envCtx.adjFogNear = 0;
|
||||
} else {
|
||||
play->envCtx.fillScreen = true;
|
||||
|
|
|
@ -195,7 +195,7 @@ s32 Lights_FreeNode(LightNode* light) {
|
|||
void LightContext_Init(PlayState* play, LightContext* lightCtx) {
|
||||
LightContext_InitList(play, lightCtx);
|
||||
LightContext_SetAmbientColor(lightCtx, 80, 80, 80);
|
||||
LightContext_SetFog(lightCtx, 0, 0, 0, 996, 12800);
|
||||
LightContext_SetFog(lightCtx, 0, 0, 0, ENV_FOGNEAR_MAX, ENV_ZFAR_MAX);
|
||||
bzero(&sLightsBuffer, sizeof(sLightsBuffer));
|
||||
}
|
||||
|
||||
|
@ -205,12 +205,12 @@ void LightContext_SetAmbientColor(LightContext* lightCtx, u8 r, u8 g, u8 b) {
|
|||
lightCtx->ambientColor[2] = b;
|
||||
}
|
||||
|
||||
void LightContext_SetFog(LightContext* lightCtx, u8 r, u8 g, u8 b, s16 fogNear, s16 fogFar) {
|
||||
void LightContext_SetFog(LightContext* lightCtx, u8 r, u8 g, u8 b, s16 fogNear, s16 zFar) {
|
||||
lightCtx->fogColor[0] = r;
|
||||
lightCtx->fogColor[1] = g;
|
||||
lightCtx->fogColor[2] = b;
|
||||
lightCtx->fogNear = fogNear;
|
||||
lightCtx->fogFar = fogFar;
|
||||
lightCtx->zFar = zFar;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "global.h"
|
||||
#include "vt.h"
|
||||
#include "terminal.h"
|
||||
#include "assets/objects/gameplay_keep/gameplay_keep.h"
|
||||
#include "assets/textures/parameter_static/parameter_static.h"
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "global.h"
|
||||
#include "vt.h"
|
||||
#include "terminal.h"
|
||||
#include "assets/textures/parameter_static/parameter_static.h"
|
||||
|
||||
typedef struct {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "global.h"
|
||||
#include "message_data_static.h"
|
||||
#include "vt.h"
|
||||
#include "terminal.h"
|
||||
#include "assets/textures/parameter_static/parameter_static.h"
|
||||
|
||||
s16 sTextFade = false; // original name: key_off_flag ?
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "global.h"
|
||||
#include "quake.h"
|
||||
#include "vt.h"
|
||||
#include "terminal.h"
|
||||
#include "overlays/actors/ovl_En_Sw/z_en_sw.h"
|
||||
|
||||
static s16 sDisableAttention = false;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "global.h"
|
||||
#include "vt.h"
|
||||
#include "terminal.h"
|
||||
#include "assets/textures/parameter_static/parameter_static.h"
|
||||
#include "assets/textures/do_action_static/do_action_static.h"
|
||||
#include "assets/textures/icon_item_static/icon_item_static.h"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "global.h"
|
||||
#include "quake.h"
|
||||
#include "vt.h"
|
||||
#include "terminal.h"
|
||||
|
||||
void* D_8012D1F0 = NULL;
|
||||
UNK_TYPE D_8012D1F4 = 0; // unused
|
||||
|
@ -393,8 +393,8 @@ void Play_Init(GameState* thisx) {
|
|||
D_801614B0.a = 0;
|
||||
Flags_UnsetAllEnv(this);
|
||||
|
||||
osSyncPrintf("ZELDA ALLOC SIZE=%x\n", THA_GetSize(&this->state.tha));
|
||||
zAllocSize = THA_GetSize(&this->state.tha);
|
||||
osSyncPrintf("ZELDA ALLOC SIZE=%x\n", THA_GetRemaining(&this->state.tha));
|
||||
zAllocSize = THA_GetRemaining(&this->state.tha);
|
||||
zAlloc = (u32)GameState_Alloc(&this->state, zAllocSize, "../z_play.c", 2918);
|
||||
zAllocAligned = (zAlloc + 8) & ~0xF;
|
||||
ZeldaArena_Init((void*)zAllocAligned, zAllocSize - zAllocAligned + zAlloc);
|
||||
|
@ -1051,7 +1051,7 @@ void Play_Draw(PlayState* this) {
|
|||
POLY_OPA_DISP = Play_SetFog(this, POLY_OPA_DISP);
|
||||
POLY_XLU_DISP = Play_SetFog(this, POLY_XLU_DISP);
|
||||
|
||||
View_SetPerspective(&this->view, this->view.fovy, this->view.zNear, this->lightCtx.fogFar);
|
||||
View_SetPerspective(&this->view, this->view.fovy, this->view.zNear, this->lightCtx.zFar);
|
||||
View_Apply(&this->view, VIEW_ALL);
|
||||
|
||||
// The billboard matrix temporarily stores the viewing matrix
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "global.h"
|
||||
#include "vt.h"
|
||||
#include "terminal.h"
|
||||
|
||||
void func_80092320(PreNMIState* this) {
|
||||
this->state.running = false;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "global.h"
|
||||
#include "quake.h"
|
||||
#include "vt.h"
|
||||
#include "terminal.h"
|
||||
|
||||
typedef struct {
|
||||
/* 0x00 */ s16 index;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "global.h"
|
||||
#include "vt.h"
|
||||
#include "terminal.h"
|
||||
|
||||
Vec3f D_801270A0 = { 0.0f, 0.0f, 0.0f };
|
||||
|
||||
|
@ -153,7 +153,7 @@ void Room_DrawCullable(PlayState* play, Room* room, u32 flags) {
|
|||
entryBoundsNearZ = projectedPos.z - roomShapeCullableEntry->boundsSphereRadius;
|
||||
|
||||
// If the entry bounding sphere isn't fully beyond the rendered depth range
|
||||
if (entryBoundsNearZ < play->lightCtx.fogFar) {
|
||||
if (entryBoundsNearZ < play->lightCtx.zFar) {
|
||||
|
||||
// This entry will be rendered
|
||||
insert->entry = roomShapeCullableEntry;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "global.h"
|
||||
#include "vt.h"
|
||||
#include "terminal.h"
|
||||
|
||||
RomFile sNaviQuestHintFiles[];
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "global.h"
|
||||
#include "vt.h"
|
||||
#include "terminal.h"
|
||||
|
||||
#define ANIM_INTERP 1
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "global.h"
|
||||
#include "vt.h"
|
||||
#include "terminal.h"
|
||||
|
||||
// clang-format off
|
||||
MtxF sMtxFClear = {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "global.h"
|
||||
#include "vt.h"
|
||||
#include "terminal.h"
|
||||
|
||||
// these are the main substructs of save context.
|
||||
// we are going to hold off on splitting save context until later on,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "global.h"
|
||||
#include "vt.h"
|
||||
#include "terminal.h"
|
||||
|
||||
vu32 sLogOnNextViewInit = true;
|
||||
|
||||
|
|
|
@ -1,158 +1,190 @@
|
|||
#include "global.h"
|
||||
#include "ultra64/viint.h"
|
||||
|
||||
void ViMode_LogPrint(OSViMode* osViMode) {
|
||||
LOG_ADDRESS("osvimodep", osViMode, "../z_vimode.c", 87);
|
||||
LOG_ADDRESS("osvimodep->comRegs.ctrl", osViMode->comRegs.ctrl, "../z_vimode.c", 88);
|
||||
LOG_ADDRESS("osvimodep->comRegs.width", osViMode->comRegs.width, "../z_vimode.c", 89);
|
||||
LOG_ADDRESS("osvimodep->comRegs.burst", osViMode->comRegs.burst, "../z_vimode.c", 90);
|
||||
LOG_ADDRESS("osvimodep->comRegs.vSync", osViMode->comRegs.vSync, "../z_vimode.c", 91);
|
||||
LOG_ADDRESS("osvimodep->comRegs.hSync", osViMode->comRegs.hSync, "../z_vimode.c", 92);
|
||||
LOG_ADDRESS("osvimodep->comRegs.leap", osViMode->comRegs.leap, "../z_vimode.c", 93);
|
||||
LOG_ADDRESS("osvimodep->comRegs.hStart", osViMode->comRegs.hStart, "../z_vimode.c", 94);
|
||||
LOG_ADDRESS("osvimodep->comRegs.xScale", osViMode->comRegs.xScale, "../z_vimode.c", 95);
|
||||
LOG_ADDRESS("osvimodep->fldRegs[0].vStart", osViMode->fldRegs[0].vStart, "../z_vimode.c", 96);
|
||||
LOG_ADDRESS("osvimodep->fldRegs[0].vBurst", osViMode->fldRegs[0].vBurst, "../z_vimode.c", 97);
|
||||
LOG_ADDRESS("osvimodep->fldRegs[0].origin", osViMode->fldRegs[0].origin, "../z_vimode.c", 98);
|
||||
LOG_ADDRESS("osvimodep->fldRegs[0].yScale", osViMode->fldRegs[0].yScale, "../z_vimode.c", 99);
|
||||
LOG_ADDRESS("osvimodep->fldRegs[0].vIntr", osViMode->fldRegs[0].vIntr, "../z_vimode.c", 100);
|
||||
LOG_ADDRESS("osvimodep->fldRegs[1].vStart", osViMode->fldRegs[1].vStart, "../z_vimode.c", 101);
|
||||
LOG_ADDRESS("osvimodep->fldRegs[1].vBurst", osViMode->fldRegs[1].vBurst, "../z_vimode.c", 102);
|
||||
LOG_ADDRESS("osvimodep->fldRegs[1].origin", osViMode->fldRegs[1].origin, "../z_vimode.c", 103);
|
||||
LOG_ADDRESS("osvimodep->fldRegs[1].yScale", osViMode->fldRegs[1].yScale, "../z_vimode.c", 104);
|
||||
LOG_ADDRESS("osvimodep->fldRegs[1].vIntr", osViMode->fldRegs[1].vIntr, "../z_vimode.c", 105);
|
||||
LOG_HEX32("osvimodep->comRegs.ctrl", osViMode->comRegs.ctrl, "../z_vimode.c", 88);
|
||||
LOG_HEX32("osvimodep->comRegs.width", osViMode->comRegs.width, "../z_vimode.c", 89);
|
||||
LOG_HEX32("osvimodep->comRegs.burst", osViMode->comRegs.burst, "../z_vimode.c", 90);
|
||||
LOG_HEX32("osvimodep->comRegs.vSync", osViMode->comRegs.vSync, "../z_vimode.c", 91);
|
||||
LOG_HEX32("osvimodep->comRegs.hSync", osViMode->comRegs.hSync, "../z_vimode.c", 92);
|
||||
LOG_HEX32("osvimodep->comRegs.leap", osViMode->comRegs.leap, "../z_vimode.c", 93);
|
||||
LOG_HEX32("osvimodep->comRegs.hStart", osViMode->comRegs.hStart, "../z_vimode.c", 94);
|
||||
LOG_HEX32("osvimodep->comRegs.xScale", osViMode->comRegs.xScale, "../z_vimode.c", 95);
|
||||
LOG_HEX32("osvimodep->fldRegs[0].vStart", osViMode->fldRegs[0].vStart, "../z_vimode.c", 96);
|
||||
LOG_HEX32("osvimodep->fldRegs[0].vBurst", osViMode->fldRegs[0].vBurst, "../z_vimode.c", 97);
|
||||
LOG_HEX32("osvimodep->fldRegs[0].origin", osViMode->fldRegs[0].origin, "../z_vimode.c", 98);
|
||||
LOG_HEX32("osvimodep->fldRegs[0].yScale", osViMode->fldRegs[0].yScale, "../z_vimode.c", 99);
|
||||
LOG_HEX32("osvimodep->fldRegs[0].vIntr", osViMode->fldRegs[0].vIntr, "../z_vimode.c", 100);
|
||||
LOG_HEX32("osvimodep->fldRegs[1].vStart", osViMode->fldRegs[1].vStart, "../z_vimode.c", 101);
|
||||
LOG_HEX32("osvimodep->fldRegs[1].vBurst", osViMode->fldRegs[1].vBurst, "../z_vimode.c", 102);
|
||||
LOG_HEX32("osvimodep->fldRegs[1].origin", osViMode->fldRegs[1].origin, "../z_vimode.c", 103);
|
||||
LOG_HEX32("osvimodep->fldRegs[1].yScale", osViMode->fldRegs[1].yScale, "../z_vimode.c", 104);
|
||||
LOG_HEX32("osvimodep->fldRegs[1].vIntr", osViMode->fldRegs[1].vIntr, "../z_vimode.c", 105);
|
||||
}
|
||||
|
||||
// This function configures the custom VI mode (`viMode.customViMode`) based on the other flags in `viMode`.
|
||||
void ViMode_Configure(ViMode* viMode, s32 mode, s32 type, s32 unk_70, s32 unk_74, s32 unk_78, s32 unk_7C, s32 width,
|
||||
s32 height, s32 unk_left, s32 unk_right, s32 unk_top, s32 unk_bottom) {
|
||||
s32 not_70;
|
||||
s32 not_74;
|
||||
s32 not_78;
|
||||
s32 not_7C;
|
||||
s32 cond_4C;
|
||||
s32 cond_48;
|
||||
s32 cond_44;
|
||||
s32 cond_40;
|
||||
s32 cond_3C;
|
||||
s32 cond_38;
|
||||
s32 cond_34;
|
||||
/**
|
||||
* Configures the custom OSViMode for this ViMode
|
||||
*
|
||||
* @param viMode ViMode to configure the custom OSViMode for
|
||||
* @param type Identifying type for the OSViMode
|
||||
* @param tvType TV Type: NTSC, PAL, MPAL or FPAL
|
||||
* @param loRes Boolean: true = low resolution, false = high resolution.
|
||||
* Corresponds to "L" or "H" in libultra VI mode names
|
||||
* @param antialiasOff Boolean: true = point-sampling, false = anti-aliasing.
|
||||
* Corresponds to "P" or "A" in libultra VI mode names
|
||||
* @param modeN Boolean: controls interlacing mode, different based on resolution.
|
||||
* Corresponds to "N" or "F" in libultra VI mode names
|
||||
* @param fb16Bit Bolean: true = 16-bit framebuffer, false = 32-bit framebuffer.
|
||||
* Corresponds to "1" or "2" in libultra VI mode names
|
||||
* @param width Screen width
|
||||
* @param height Screen height
|
||||
* @param leftAdjust Left edge adjustment
|
||||
* @param rightAdjust Right edge adjustment
|
||||
* @param upperAdjust Upper edge adjustment
|
||||
* @param lowerAdjust Lower edge adjustment
|
||||
*/
|
||||
void ViMode_Configure(ViMode* viMode, s32 type, s32 tvType, s32 loRes, s32 antialiasOff, s32 modeN, s32 fb16Bit,
|
||||
s32 width, s32 height, s32 leftAdjust, s32 rightAdjust, s32 upperAdjust, s32 lowerAdjust) {
|
||||
s32 hiRes;
|
||||
s32 antialiasOn;
|
||||
s32 modeF;
|
||||
s32 fb32Bit;
|
||||
s32 hiResDeflicker; // deflickered interlacing
|
||||
s32 hiResInterlaced;
|
||||
s32 loResDeinterlaced;
|
||||
s32 loResInterlaced;
|
||||
s32 modeLAN1; // L=(lo res) A=(antialias) N=(deinterlace) 1=(16-bit)
|
||||
s32 modeLPN2; // L=(lo res) P=(point-sampled) N=(deinterlace) 2=(32-bit)
|
||||
s32 modeHPN2; // H=(hi res) P=(point-sampled) N=(normal interlacing) 2=(32-bit)
|
||||
s32 yScaleLo;
|
||||
s32 yScaleHi0;
|
||||
s32 yScaleHi1;
|
||||
s32 yScaleHiEvenField;
|
||||
s32 yScaleHiOddField;
|
||||
|
||||
not_70 = !unk_70;
|
||||
not_74 = !unk_74;
|
||||
not_78 = !unk_78;
|
||||
not_7C = !unk_7C;
|
||||
hiRes = !loRes;
|
||||
antialiasOn = !antialiasOff;
|
||||
modeF = !modeN;
|
||||
fb32Bit = !fb16Bit;
|
||||
|
||||
cond_4C = not_70 && not_78;
|
||||
cond_48 = not_70 && unk_78;
|
||||
cond_44 = unk_70 && unk_78;
|
||||
cond_40 = unk_70 && not_78;
|
||||
cond_3C = unk_70 && not_74 && unk_78 && unk_7C;
|
||||
cond_38 = unk_70 && unk_74 && unk_78 && not_7C;
|
||||
cond_34 = not_70 && unk_74 && unk_78 && not_7C;
|
||||
hiResDeflicker = hiRes && modeF;
|
||||
hiResInterlaced = hiRes && modeN;
|
||||
loResDeinterlaced = loRes && modeN;
|
||||
loResInterlaced = loRes && modeF;
|
||||
|
||||
unk_top &= ~1;
|
||||
unk_bottom &= ~1;
|
||||
modeLAN1 = loRes && antialiasOn && modeN && fb16Bit;
|
||||
modeLPN2 = loRes && antialiasOff && modeN && fb32Bit;
|
||||
modeHPN2 = hiRes && antialiasOff && modeN && fb32Bit;
|
||||
|
||||
yScaleLo = (cond_4C ? 2 : 1) * ((height << 11) / (SCREEN_HEIGHT * 2 + unk_bottom - unk_top) / (unk_70 ? 1 : 2));
|
||||
upperAdjust &= ~1;
|
||||
lowerAdjust &= ~1;
|
||||
|
||||
yScaleHi0 = not_78 ? (cond_40 ? 0x1000000 : 0x2000000) : 0;
|
||||
yScaleHi1 = not_78 ? (cond_40 ? 0x3000000 : 0x2000000) : 0;
|
||||
yScaleLo =
|
||||
(hiResDeflicker ? 2 : 1) * ((height << 11) / (SCREEN_HEIGHT * 2 + lowerAdjust - upperAdjust) / (loRes ? 1 : 2));
|
||||
|
||||
viMode->customViMode.type = mode;
|
||||
viMode->customViMode.comRegs.ctrl = OS_VI_UNK2000 | OS_VI_UNK1000 | OS_VI_GAMMA | OS_VI_GAMMA_DITHER |
|
||||
(!cond_44 ? OS_VI_UNK40 : 0) | (not_74 ? OS_VI_DIVOT : 0) |
|
||||
(not_7C ? OS_VI_UNK2 | OS_VI_UNK1 : OS_VI_UNK2);
|
||||
yScaleHiEvenField = modeF ? (loResInterlaced ? (F210(0.25) << 16) : (F210(0.5) << 16)) : 0;
|
||||
yScaleHiOddField = modeF ? (loResInterlaced ? (F210(0.75) << 16) : (F210(0.5) << 16)) : 0;
|
||||
|
||||
if (cond_3C) {
|
||||
viMode->customViMode.comRegs.ctrl |= 0x100;
|
||||
} else if (cond_38 | cond_34) {
|
||||
viMode->customViMode.comRegs.ctrl |= 0x300;
|
||||
} else if (unk_74) {
|
||||
viMode->customViMode.comRegs.ctrl |= 0x200;
|
||||
viMode->customViMode.type = type;
|
||||
viMode->customViMode.comRegs.ctrl = VI_CTRL_PIXEL_ADV(3) | VI_CTRL_GAMMA_ON | VI_CTRL_GAMMA_DITHER_ON |
|
||||
(!loResDeinterlaced ? VI_CTRL_SERRATE_ON : 0) |
|
||||
(antialiasOn ? VI_CTRL_DIVOT_ON : 0) |
|
||||
(fb32Bit ? VI_CTRL_TYPE_32 : VI_CTRL_TYPE_16);
|
||||
|
||||
if (modeLAN1) {
|
||||
// Anti-aliased, fetch extra lines as-needed
|
||||
viMode->customViMode.comRegs.ctrl |= VI_CTRL_ANTIALIAS_MODE_1;
|
||||
} else if (modeLPN2 | modeHPN2) {
|
||||
// Point-sampled, resampling disabled
|
||||
viMode->customViMode.comRegs.ctrl |= VI_CTRL_ANTIALIAS_MODE_3;
|
||||
} else {
|
||||
viMode->customViMode.comRegs.ctrl |= 0;
|
||||
if (antialiasOff) {
|
||||
// Point-sampled, resampling enabled
|
||||
viMode->customViMode.comRegs.ctrl |= VI_CTRL_ANTIALIAS_MODE_2;
|
||||
} else {
|
||||
// Anti-aliased, always fetch extra lines
|
||||
viMode->customViMode.comRegs.ctrl |= VI_CTRL_ANTIALIAS_MODE_0;
|
||||
}
|
||||
}
|
||||
|
||||
viMode->customViMode.comRegs.width = width * (cond_48 ? 2 : 1);
|
||||
viMode->customViMode.comRegs.width = width * (hiResInterlaced ? 2 : 1);
|
||||
|
||||
if (type == 1) {
|
||||
viMode->customViMode.comRegs.burst = 0x3E52239;
|
||||
viMode->customViMode.comRegs.vSync = 0x20C;
|
||||
viMode->customViMode.comRegs.hSync = 0xC15;
|
||||
viMode->customViMode.comRegs.leap = 0xC150C15;
|
||||
viMode->customViMode.comRegs.hStart = 0x6C02EC;
|
||||
viMode->customViMode.fldRegs[0].vStart = 0x2501FF;
|
||||
viMode->customViMode.fldRegs[0].vBurst = 0xE0204;
|
||||
} else if (type == 0) {
|
||||
viMode->customViMode.comRegs.burst = 0x404233A;
|
||||
viMode->customViMode.comRegs.vSync = 0x270;
|
||||
viMode->customViMode.comRegs.hSync = 0x150C69;
|
||||
viMode->customViMode.comRegs.leap = 0xC6F0C6E;
|
||||
viMode->customViMode.comRegs.hStart = 0x800300;
|
||||
viMode->customViMode.fldRegs[0].vStart = 0x5F0239;
|
||||
viMode->customViMode.fldRegs[0].vBurst = 0x9026B;
|
||||
} else if (type == 2) {
|
||||
viMode->customViMode.comRegs.burst = 0x4651E39;
|
||||
viMode->customViMode.comRegs.vSync = 0x20C;
|
||||
viMode->customViMode.comRegs.hSync = 0xC10;
|
||||
viMode->customViMode.comRegs.leap = 0xC1C0C1C;
|
||||
viMode->customViMode.comRegs.hStart = 0x6C02EC;
|
||||
viMode->customViMode.fldRegs[0].vStart = 0x2501FF;
|
||||
viMode->customViMode.fldRegs[0].vBurst = 0xE0204;
|
||||
if (tvType == OS_TV_NTSC) {
|
||||
viMode->customViMode.comRegs.burst = BURST(57, 34, 5, 62);
|
||||
viMode->customViMode.comRegs.vSync = VSYNC(524);
|
||||
viMode->customViMode.comRegs.hSync = HSYNC(3093, 0);
|
||||
viMode->customViMode.comRegs.leap = LEAP(3093, 3093);
|
||||
viMode->customViMode.comRegs.hStart = HSTART(108, 748);
|
||||
viMode->customViMode.fldRegs[0].vStart = START(37, 511);
|
||||
viMode->customViMode.fldRegs[0].vBurst = BURST(4, 2, 14, 0);
|
||||
} else if (tvType == OS_TV_PAL) {
|
||||
viMode->customViMode.comRegs.burst = BURST(58, 35, 4, 64);
|
||||
viMode->customViMode.comRegs.vSync = VSYNC(624);
|
||||
viMode->customViMode.comRegs.hSync = HSYNC(3177, 21);
|
||||
viMode->customViMode.comRegs.leap = LEAP(3183, 3182);
|
||||
viMode->customViMode.comRegs.hStart = HSTART(128, 768);
|
||||
viMode->customViMode.fldRegs[0].vStart = START(95, 569);
|
||||
viMode->customViMode.fldRegs[0].vBurst = BURST(107, 2, 9, 0);
|
||||
} else if (tvType == OS_TV_MPAL) {
|
||||
viMode->customViMode.comRegs.burst = BURST(57, 30, 5, 70);
|
||||
viMode->customViMode.comRegs.vSync = VSYNC(524);
|
||||
viMode->customViMode.comRegs.hSync = HSYNC(3088, 0);
|
||||
viMode->customViMode.comRegs.leap = LEAP(3100, 3100);
|
||||
viMode->customViMode.comRegs.hStart = HSTART(108, 748);
|
||||
viMode->customViMode.fldRegs[0].vStart = START(37, 511);
|
||||
viMode->customViMode.fldRegs[0].vBurst = BURST(4, 2, 14, 0);
|
||||
}
|
||||
|
||||
viMode->customViMode.fldRegs[1].vStart = viMode->customViMode.fldRegs[0].vStart;
|
||||
|
||||
viMode->customViMode.comRegs.hStart += (unk_left << 16) + (s16)unk_right;
|
||||
viMode->customViMode.fldRegs[0].vStart += (unk_top << 16) + (s16)unk_bottom;
|
||||
viMode->customViMode.fldRegs[1].vStart += (unk_top << 16) + (s16)unk_bottom;
|
||||
viMode->customViMode.comRegs.hStart += (leftAdjust << 16) + (s16)rightAdjust;
|
||||
viMode->customViMode.fldRegs[0].vStart += (upperAdjust << 16) + (s16)lowerAdjust;
|
||||
viMode->customViMode.fldRegs[1].vStart += (upperAdjust << 16) + (s16)lowerAdjust;
|
||||
|
||||
viMode->customViMode.fldRegs[1].vBurst = viMode->customViMode.fldRegs[0].vBurst;
|
||||
|
||||
if (cond_44) {
|
||||
if (loResDeinterlaced) {
|
||||
viMode->customViMode.comRegs.vSync++;
|
||||
if (type == 2) {
|
||||
viMode->customViMode.comRegs.hSync += 0x40001;
|
||||
if (tvType == OS_TV_MPAL) {
|
||||
viMode->customViMode.comRegs.hSync += HSYNC(1, 4);
|
||||
}
|
||||
if (type == 2) {
|
||||
viMode->customViMode.comRegs.leap += 0xFFFCFFFE;
|
||||
if (tvType == OS_TV_MPAL) {
|
||||
viMode->customViMode.comRegs.leap += LEAP((u16)-4, (u16)-2);
|
||||
}
|
||||
} else {
|
||||
viMode->customViMode.fldRegs[0].vStart += 0xFFFDFFFE;
|
||||
if (type == 2) {
|
||||
viMode->customViMode.fldRegs[0].vBurst += 0xFFFCFFFE;
|
||||
viMode->customViMode.fldRegs[0].vStart += START((u16)-3, (u16)-2);
|
||||
if (tvType == OS_TV_MPAL) {
|
||||
viMode->customViMode.fldRegs[0].vBurst += BURST((u8)-2, (u8)-1, 12, -1);
|
||||
}
|
||||
if (type == 0) {
|
||||
viMode->customViMode.fldRegs[1].vBurst += 0x2FFFE;
|
||||
if (tvType == OS_TV_PAL) {
|
||||
viMode->customViMode.fldRegs[1].vBurst += BURST((u8)-2, (u8)-1, 2, 0);
|
||||
}
|
||||
}
|
||||
|
||||
viMode->customViMode.comRegs.xScale = (width << 10) / (SCREEN_WIDTH * 2 + unk_right - unk_left);
|
||||
viMode->customViMode.comRegs.vCurrent = 0;
|
||||
viMode->customViMode.comRegs.xScale = (width << 10) / (SCREEN_WIDTH * 2 + rightAdjust - leftAdjust);
|
||||
viMode->customViMode.comRegs.vCurrent = VCURRENT(0);
|
||||
|
||||
viMode->customViMode.fldRegs[0].origin = width * 2 * (unk_7C ? 1 : 2);
|
||||
viMode->customViMode.fldRegs[1].origin = width * 2 * (unk_7C ? 1 : 2) * (unk_70 ? 1 : 2);
|
||||
viMode->customViMode.fldRegs[0].origin = ORIGIN(width * 2 * (fb16Bit ? 1 : 2));
|
||||
viMode->customViMode.fldRegs[1].origin = ORIGIN(width * 2 * (fb16Bit ? 1 : 2) * (loRes ? 1 : 2));
|
||||
|
||||
viMode->customViMode.fldRegs[0].yScale = yScaleLo | yScaleHi0;
|
||||
viMode->customViMode.fldRegs[1].yScale = yScaleLo | yScaleHi1;
|
||||
viMode->customViMode.fldRegs[0].yScale = yScaleLo | yScaleHiEvenField;
|
||||
viMode->customViMode.fldRegs[1].yScale = yScaleLo | yScaleHiOddField;
|
||||
|
||||
viMode->customViMode.fldRegs[0].vIntr = 2;
|
||||
viMode->customViMode.fldRegs[1].vIntr = 2;
|
||||
viMode->customViMode.fldRegs[0].vIntr = VINTR(2);
|
||||
viMode->customViMode.fldRegs[1].vIntr = VINTR(2);
|
||||
}
|
||||
|
||||
void ViMode_Save(ViMode* viMode) {
|
||||
SREG(48) = viMode->viModeBase;
|
||||
SREG(49) = viMode->viWidth;
|
||||
SREG(50) = viMode->viHeight;
|
||||
SREG(51) = viMode->unk_64;
|
||||
SREG(52) = viMode->unk_60;
|
||||
SREG(53) = viMode->unk_5C;
|
||||
SREG(54) = viMode->unk_58;
|
||||
R_VI_MODE_EDIT_STATE = viMode->editState;
|
||||
R_VI_MODE_EDIT_WIDTH = viMode->viWidth;
|
||||
R_VI_MODE_EDIT_HEIGHT = viMode->viHeight;
|
||||
R_VI_MODE_EDIT_ULY_ADJ = viMode->upperAdjust;
|
||||
R_VI_MODE_EDIT_LRY_ADJ = viMode->lowerAdjust;
|
||||
R_VI_MODE_EDIT_ULX_ADJ = viMode->leftAdjust;
|
||||
R_VI_MODE_EDIT_LRX_ADJ = viMode->rightAdjust;
|
||||
|
||||
if (SREG(58) == 1) {
|
||||
SREG(58) = 0;
|
||||
|
||||
switch (SREG(59)) {
|
||||
case 1:
|
||||
osSyncPrintf("osViModePalLan1\n");
|
||||
|
@ -171,33 +203,34 @@ void ViMode_Save(ViMode* viMode) {
|
|||
}
|
||||
|
||||
void ViMode_Load(ViMode* viMode) {
|
||||
if ((SREG(49) & ~3) == 1) {
|
||||
SREG(49) += 4;
|
||||
//! @bug This condition never passes as the lowest bit is always masked out to 0
|
||||
if ((R_VI_MODE_EDIT_WIDTH & ~3) == 1) {
|
||||
R_VI_MODE_EDIT_WIDTH += 4;
|
||||
}
|
||||
|
||||
viMode->viModeBase = SREG(48);
|
||||
viMode->viWidth = SREG(49) & ~3;
|
||||
viMode->viHeight = SREG(50);
|
||||
viMode->unk_64 = SREG(51);
|
||||
viMode->unk_60 = SREG(52);
|
||||
viMode->unk_5C = SREG(53);
|
||||
viMode->unk_58 = SREG(54);
|
||||
viMode->editState = R_VI_MODE_EDIT_STATE;
|
||||
viMode->viWidth = R_VI_MODE_EDIT_WIDTH & ~3;
|
||||
viMode->viHeight = R_VI_MODE_EDIT_HEIGHT;
|
||||
viMode->upperAdjust = R_VI_MODE_EDIT_ULY_ADJ;
|
||||
viMode->lowerAdjust = R_VI_MODE_EDIT_LRY_ADJ;
|
||||
viMode->leftAdjust = R_VI_MODE_EDIT_ULX_ADJ;
|
||||
viMode->rightAdjust = R_VI_MODE_EDIT_LRX_ADJ;
|
||||
}
|
||||
|
||||
void ViMode_Init(ViMode* viMode) {
|
||||
viMode->viModeBase = 0;
|
||||
viMode->editState = VI_MODE_EDIT_STATE_INACTIVE;
|
||||
viMode->viWidth = SCREEN_WIDTH;
|
||||
viMode->viHeight = SCREEN_HEIGHT;
|
||||
viMode->unk_5C = 0;
|
||||
viMode->unk_58 = 0;
|
||||
viMode->unk_64 = 0;
|
||||
viMode->unk_60 = 0;
|
||||
viMode->leftAdjust = 0;
|
||||
viMode->rightAdjust = 0;
|
||||
viMode->upperAdjust = 0;
|
||||
viMode->lowerAdjust = 0;
|
||||
viMode->viFeatures = OS_VI_DITHER_FILTER_ON | OS_VI_GAMMA_OFF;
|
||||
viMode->viTvType = osTvType;
|
||||
viMode->unk_7C = true;
|
||||
viMode->unk_78 = true;
|
||||
viMode->unk_74 = false;
|
||||
viMode->unk_70 = true;
|
||||
viMode->tvType = osTvType;
|
||||
viMode->fb16Bit = true;
|
||||
viMode->modeN = true;
|
||||
viMode->antialiasOff = false;
|
||||
viMode->loRes = true;
|
||||
|
||||
ViMode_Save(viMode);
|
||||
}
|
||||
|
@ -209,113 +242,140 @@ void ViMode_ConfigureFeatures(ViMode* viMode, s32 viFeatures) {
|
|||
u32 ctrl = viMode->customViMode.comRegs.ctrl;
|
||||
|
||||
if (viFeatures & OS_VI_GAMMA_ON) {
|
||||
ctrl |= OS_VI_GAMMA;
|
||||
ctrl |= VI_CTRL_GAMMA_ON;
|
||||
}
|
||||
if (viFeatures & OS_VI_GAMMA_OFF) {
|
||||
ctrl &= ~OS_VI_GAMMA;
|
||||
ctrl &= ~VI_CTRL_GAMMA_ON;
|
||||
}
|
||||
if (viFeatures & OS_VI_GAMMA_DITHER_ON) {
|
||||
ctrl |= OS_VI_GAMMA_DITHER;
|
||||
ctrl |= VI_CTRL_GAMMA_DITHER_ON;
|
||||
}
|
||||
if (viFeatures & OS_VI_GAMMA_DITHER_OFF) {
|
||||
ctrl &= ~OS_VI_GAMMA_DITHER;
|
||||
ctrl &= ~VI_CTRL_GAMMA_DITHER_ON;
|
||||
}
|
||||
if (viFeatures & OS_VI_DIVOT_ON) {
|
||||
ctrl |= OS_VI_DIVOT;
|
||||
ctrl |= VI_CTRL_DIVOT_ON;
|
||||
}
|
||||
if (viFeatures & OS_VI_DIVOT_OFF) {
|
||||
ctrl &= ~OS_VI_DIVOT;
|
||||
ctrl &= ~VI_CTRL_DIVOT_ON;
|
||||
}
|
||||
viMode->customViMode.comRegs.ctrl = ctrl;
|
||||
}
|
||||
|
||||
// This function uses controller input (C buttons + D pad) to reconfigure the custom VI mode
|
||||
/**
|
||||
* Updates the custom VI mode with controller input and any edits made with the REG editor
|
||||
* (through R_VI_MODE_EDIT_* entries)
|
||||
*/
|
||||
void ViMode_Update(ViMode* viMode, Input* input) {
|
||||
// Load state from REGs
|
||||
ViMode_Load(viMode);
|
||||
if ((viMode->viModeBase == 1) || (viMode->viModeBase == 2) || (viMode->viModeBase == 3)) {
|
||||
|
||||
if ((viMode->editState == VI_MODE_EDIT_STATE_ACTIVE) || (viMode->editState == VI_MODE_EDIT_STATE_2) ||
|
||||
(viMode->editState == VI_MODE_EDIT_STATE_3)) {
|
||||
gScreenWidth = viMode->viWidth;
|
||||
gScreenHeight = viMode->viHeight;
|
||||
|
||||
// Controls to reset the ViMode to defaults
|
||||
if (CHECK_BTN_ALL(input->cur.button, BTN_START | BTN_CUP | BTN_CRIGHT)) {
|
||||
ViMode_Init(viMode);
|
||||
}
|
||||
|
||||
// Controls to adjust the screen dimensions (upper-left)
|
||||
if (CHECK_BTN_ALL(input->cur.button, BTN_CUP)) {
|
||||
// upper
|
||||
if (CHECK_BTN_ALL(input->cur.button, BTN_DUP)) {
|
||||
viMode->unk_64--;
|
||||
viMode->upperAdjust--;
|
||||
}
|
||||
if (CHECK_BTN_ALL(input->cur.button, BTN_DDOWN)) {
|
||||
viMode->unk_64++;
|
||||
viMode->upperAdjust++;
|
||||
}
|
||||
// left
|
||||
if (CHECK_BTN_ALL(input->cur.button, BTN_DLEFT)) {
|
||||
viMode->unk_5C--;
|
||||
viMode->leftAdjust--;
|
||||
}
|
||||
if (CHECK_BTN_ALL(input->cur.button, BTN_DRIGHT)) {
|
||||
viMode->unk_5C++;
|
||||
viMode->leftAdjust++;
|
||||
}
|
||||
}
|
||||
|
||||
// Controls to adjust the screen dimensions (lower-right)
|
||||
if (CHECK_BTN_ALL(input->cur.button, BTN_CRIGHT)) {
|
||||
// lower
|
||||
if (CHECK_BTN_ALL(input->cur.button, BTN_DUP)) {
|
||||
viMode->unk_60--;
|
||||
viMode->lowerAdjust--;
|
||||
}
|
||||
if (CHECK_BTN_ALL(input->cur.button, BTN_DDOWN)) {
|
||||
viMode->unk_60++;
|
||||
viMode->lowerAdjust++;
|
||||
}
|
||||
// right
|
||||
if (CHECK_BTN_ALL(input->cur.button, BTN_DLEFT)) {
|
||||
viMode->unk_58--;
|
||||
viMode->rightAdjust--;
|
||||
}
|
||||
if (CHECK_BTN_ALL(input->cur.button, BTN_DRIGHT)) {
|
||||
viMode->unk_58++;
|
||||
viMode->rightAdjust++;
|
||||
}
|
||||
}
|
||||
|
||||
// Controls to adjust key features
|
||||
if (CHECK_BTN_ALL(input->cur.button, BTN_CDOWN)) {
|
||||
if (CHECK_BTN_ALL(input->press.button, BTN_DUP)) {
|
||||
viMode->unk_70 = !viMode->unk_70;
|
||||
viMode->loRes = !viMode->loRes;
|
||||
}
|
||||
if (CHECK_BTN_ALL(input->press.button, BTN_DDOWN)) {
|
||||
viMode->unk_74 = !viMode->unk_74;
|
||||
viMode->antialiasOff = !viMode->antialiasOff;
|
||||
}
|
||||
if (CHECK_BTN_ALL(input->press.button, BTN_DLEFT)) {
|
||||
viMode->unk_78 = !viMode->unk_78;
|
||||
viMode->modeN = !viMode->modeN;
|
||||
}
|
||||
if (CHECK_BTN_ALL(input->press.button, BTN_DRIGHT)) {
|
||||
viMode->unk_7C = !viMode->unk_7C;
|
||||
viMode->fb16Bit = !viMode->fb16Bit;
|
||||
}
|
||||
}
|
||||
if (viMode->viModeBase >= 2) {
|
||||
if (viMode->unk_5C < -16) {
|
||||
viMode->unk_5C = -16;
|
||||
|
||||
// Clamp adjustments
|
||||
if (viMode->editState >= VI_MODE_EDIT_STATE_2) {
|
||||
// Allow parts of the framebuffer to possibly be offscreen by a small margin
|
||||
if (viMode->leftAdjust < -16) {
|
||||
viMode->leftAdjust = -16;
|
||||
}
|
||||
if (viMode->unk_64 < -50) {
|
||||
viMode->unk_64 = -50;
|
||||
if (viMode->upperAdjust < -50) {
|
||||
viMode->upperAdjust = -50;
|
||||
}
|
||||
if (viMode->unk_58 > 16) {
|
||||
viMode->unk_58 = 16;
|
||||
if (viMode->rightAdjust > 16) {
|
||||
viMode->rightAdjust = 16;
|
||||
}
|
||||
if (viMode->unk_60 > 50) {
|
||||
viMode->unk_60 = 50;
|
||||
if (viMode->lowerAdjust > 50) {
|
||||
viMode->lowerAdjust = 50;
|
||||
}
|
||||
} else {
|
||||
if (viMode->unk_5C < 0) {
|
||||
viMode->unk_5C = 0;
|
||||
// Do not allow parts of the framebuffer to end up offscreen
|
||||
if (viMode->leftAdjust < 0) {
|
||||
viMode->leftAdjust = 0;
|
||||
}
|
||||
if (viMode->unk_64 < 0) {
|
||||
viMode->unk_64 = 0;
|
||||
if (viMode->upperAdjust < 0) {
|
||||
viMode->upperAdjust = 0;
|
||||
}
|
||||
if (viMode->unk_58 > 0) {
|
||||
viMode->unk_58 = 0;
|
||||
if (viMode->rightAdjust > 0) {
|
||||
viMode->rightAdjust = 0;
|
||||
}
|
||||
if (viMode->unk_60 > 0) {
|
||||
viMode->unk_60 = 0;
|
||||
if (viMode->lowerAdjust > 0) {
|
||||
viMode->lowerAdjust = 0;
|
||||
}
|
||||
}
|
||||
ViMode_Configure(viMode, OS_VI_UNK28, osTvType, viMode->unk_70, viMode->unk_74, viMode->unk_78, viMode->unk_7C,
|
||||
viMode->viWidth, viMode->viHeight, viMode->unk_5C, viMode->unk_58, viMode->unk_64,
|
||||
viMode->unk_60);
|
||||
|
||||
// Configure the custom VI mode with the selected settings
|
||||
ViMode_Configure(viMode, OS_VI_MPAL_LPN1, osTvType, viMode->loRes, viMode->antialiasOff, viMode->modeN,
|
||||
viMode->fb16Bit, viMode->viWidth, viMode->viHeight, viMode->leftAdjust, viMode->rightAdjust,
|
||||
viMode->upperAdjust, viMode->lowerAdjust);
|
||||
ViMode_ConfigureFeatures(viMode, viMode->viFeatures);
|
||||
if (viMode->viModeBase == 3) {
|
||||
|
||||
if (viMode->editState == VI_MODE_EDIT_STATE_3) {
|
||||
// Log comparison between the NTSC LAN1 mode and the custom mode
|
||||
ViMode_LogPrint(&osViModeNtscLan1);
|
||||
ViMode_LogPrint(&viMode->customViMode);
|
||||
viMode->viModeBase = 2;
|
||||
viMode->editState = VI_MODE_EDIT_STATE_2;
|
||||
}
|
||||
}
|
||||
// Save new state to REGs for interactive runtime editing
|
||||
ViMode_Save(viMode);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "global.h"
|
||||
#include "vt.h"
|
||||
#include "terminal.h"
|
||||
#include "z64environment.h"
|
||||
|
||||
u32 D_8012AC90[4] = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue