1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-07-12 10:54:44 +00:00

Merge branch 'main' into doc_pause_menu

This commit is contained in:
Dragorn421 2024-02-28 21:05:45 +01:00
commit 77d9a1ec7a
No known key found for this signature in database
GPG key ID: 381AEBAF3D429335
282 changed files with 8441 additions and 7222 deletions

View file

@ -23,4 +23,4 @@ AllowShortEnumsOnASingleLine: false
AlignEscapedNewlines: Left AlignEscapedNewlines: Left
AlignTrailingComments: true AlignTrailingComments: true
SortIncludes: false SortIncludes: false
TypenameMacros: ['BAD_RETURN'] TypenameMacros: ['BAD_RETURN', 'ALIGNED']

View file

@ -181,10 +181,6 @@ endif
OBJDUMP_FLAGS := -d -r -z -Mreg-names=32 OBJDUMP_FLAGS := -d -r -z -Mreg-names=32
DISASM_DATA_DIR := tools/disasm/$(VERSION)
DISASM_FLAGS += --custom-suffix _unknown --sequential-label-names --no-use-fpccsr --no-cop0-named-registers
DISASM_FLAGS += --config-dir $(DISASM_DATA_DIR) --symbol-addrs $(DISASM_DATA_DIR)/functions.txt --symbol-addrs $(DISASM_DATA_DIR)/variables.txt
#### Files #### #### Files ####
# ROM image # ROM image
@ -223,11 +219,6 @@ O_FILES := $(foreach f,$(S_FILES:.s=.o),$(BUILD_DIR)/$f) \
OVL_RELOC_FILES := $(shell $(CPP) $(CPPFLAGS) $(SPEC) | $(SPEC_REPLACE_VARS) | grep -o '[^"]*_reloc.o' ) OVL_RELOC_FILES := $(shell $(CPP) $(CPPFLAGS) $(SPEC) | $(SPEC_REPLACE_VARS) | grep -o '[^"]*_reloc.o' )
DISASM_BASEROM := $(BASEROM_DIR)/baserom-decompressed.z64
DISASM_DATA_FILES := $(wildcard $(DISASM_DATA_DIR)/*.csv) $(wildcard $(DISASM_DATA_DIR)/*.txt)
DISASM_S_FILES := $(shell test -e $(PYTHON) && $(PYTHON) tools/disasm/list_generated_files.py -o $(EXPECTED_DIR) --config-dir $(DISASM_DATA_DIR))
DISASM_O_FILES := $(DISASM_S_FILES:.s=.o)
# Automatic dependency files # Automatic dependency files
# (Only asm_processor dependencies and reloc dependencies are handled for now) # (Only asm_processor dependencies and reloc dependencies are handled for now)
DEP_FILES := $(O_FILES:.o=.asmproc.d) $(OVL_RELOC_FILES:.o=.d) DEP_FILES := $(O_FILES:.o=.asmproc.d) $(OVL_RELOC_FILES:.o=.d)
@ -247,7 +238,7 @@ $(BUILD_DIR)/src/boot/stackcheck.o: OPTFLAGS := -O2
$(BUILD_DIR)/src/code/__osMalloc.o: OPTFLAGS := -O2 $(BUILD_DIR)/src/code/__osMalloc.o: OPTFLAGS := -O2
$(BUILD_DIR)/src/code/code_800FC620.o: OPTFLAGS := -O2 $(BUILD_DIR)/src/code/code_800FC620.o: OPTFLAGS := -O2
$(BUILD_DIR)/src/code/code_800FCE80.o: OPTFLAGS := -O2 $(BUILD_DIR)/src/code/code_800FCE80.o: OPTFLAGS := -O2
$(BUILD_DIR)/src/code/code_800FD970.o: OPTFLAGS := -O2 $(BUILD_DIR)/src/code/rand.o: OPTFLAGS := -O2
$(BUILD_DIR)/src/code/gfxprint.o: OPTFLAGS := -O2 $(BUILD_DIR)/src/code/gfxprint.o: OPTFLAGS := -O2
$(BUILD_DIR)/src/code/jpegutils.o: OPTFLAGS := -O2 $(BUILD_DIR)/src/code/jpegutils.o: OPTFLAGS := -O2
$(BUILD_DIR)/src/code/jpegdecoder.o: OPTFLAGS := -O2 $(BUILD_DIR)/src/code/jpegdecoder.o: OPTFLAGS := -O2
@ -370,9 +361,12 @@ setup: venv
# TODO: for now, we only extract assets from the Debug ROM # TODO: for now, we only extract assets from the Debug ROM
ifeq ($(VERSION),gc-eu-mq-dbg) ifeq ($(VERSION),gc-eu-mq-dbg)
$(PYTHON) extract_assets.py -j$(N_THREADS) $(PYTHON) extract_assets.py -j$(N_THREADS)
$(PYTHON) tools/msgdis.py --text-out assets/text/message_data.h --staff-text-out assets/text/message_data_staff.h
endif endif
disasm: $(DISASM_O_FILES) disasm:
$(RM) -r $(EXPECTED_DIR)
VERSION=$(VERSION) DISASM_BASEROM=$(BASEROM_DIR)/baserom-decompressed.z64 DISASM_DIR=$(EXPECTED_DIR) PYTHON=$(PYTHON) AS_CMD='$(AS) $(ASFLAGS)' LD=$(LD) ./tools/disasm/do_disasm.sh
run: $(ROM) run: $(ROM)
ifeq ($(N64_EMULATOR),) ifeq ($(N64_EMULATOR),)
@ -494,13 +488,6 @@ $(BUILD_DIR)/assets/%.bin.inc.c: assets/%.bin
$(BUILD_DIR)/assets/%.jpg.inc.c: assets/%.jpg $(BUILD_DIR)/assets/%.jpg.inc.c: assets/%.jpg
$(ZAPD) bren -eh -i $< -o $@ $(ZAPD) bren -eh -i $< -o $@
$(EXPECTED_DIR)/.disasm: $(DISASM_DATA_FILES)
$(PYTHON) tools/disasm/disasm.py $(DISASM_FLAGS) $(DISASM_BASEROM) -o $(EXPECTED_DIR) --split-functions $(EXPECTED_DIR)/functions
touch $@
$(EXPECTED_DIR)/%.o: $(EXPECTED_DIR)/.disasm
$(AS) $(ASFLAGS) $(@:.o=.s) -o $@
-include $(DEP_FILES) -include $(DEP_FILES)
# Print target for debugging # Print target for debugging

View file

@ -103,6 +103,7 @@ cd oot
#### 3. Prepare a base ROM #### 3. Prepare a base ROM
Place a copy of the Master Quest (Debug) ROM inside the `baseroms/gc-eu-mq-dbg/` folder. Place a copy of the Master Quest (Debug) ROM inside the `baseroms/gc-eu-mq-dbg/` folder.
If you are under WSL, you can run the command `explorer.exe .` to open the current directory in the Windows file explorer.
Rename the file to `baserom.z64`, `baserom.n64` or `baserom.v64`, depending on the original extension. Rename the file to `baserom.z64`, `baserom.n64` or `baserom.v64`, depending on the original extension.
@ -115,7 +116,7 @@ make setup
``` ```
This downloads some dependencies (from pip), and compiles tools for the build process. This downloads some dependencies (from pip), and compiles tools for the build process.
Then it generates a new ROM "baseroms/gc-eu-mq-dbg/baserom-decompressed.z64" that will have the overdump removed and the header patched. Then it generates a new ROM `baseroms/gc-eu-mq-dbg/baserom-decompressed.z64` that will have the overdump removed and the header patched.
It will also extract the individual assets from the ROM. It will also extract the individual assets from the ROM.
#### 5. Build the ROM #### 5. Build the ROM

View file

@ -13,6 +13,7 @@
glabel sFaultDrawer glabel sFaultDrawer
.space 0x3C .space 0x3C
.space 0x04 # padding
glabel D_8016B6BC glabel D_8016B6C0
.space 0x24 .space 0x20

View file

@ -96,7 +96,7 @@ def processZAPDArgs(argsZ):
def main(): def main():
parser = argparse.ArgumentParser(description="baserom asset extractor") parser = argparse.ArgumentParser(description="baserom asset extractor")
parser.add_argument("-s", "--single", help="asset path relative to assets/, e.g. objects/gameplay_keep") parser.add_argument("-s", "--single", help="asset path relative to assets/, e.g. objects/gameplay_keep")
parser.add_argument("-f", "--force", help="Force the extraction of every xml instead of checking the touched ones, and text (overwriting current files).", action="store_true") parser.add_argument("-f", "--force", help="Force the extraction of every xml instead of checking the touched ones (overwriting current files).", action="store_true")
parser.add_argument("-j", "--jobs", help="Number of cpu cores to extract with.") parser.add_argument("-j", "--jobs", help="Number of cpu cores to extract with.")
parser.add_argument("-u", "--unaccounted", help="Enables ZAPD unaccounted detector warning system.", action="store_true") parser.add_argument("-u", "--unaccounted", help="Enables ZAPD unaccounted detector warning system.", action="store_true")
parser.add_argument("-Z", help="Pass the argument on to ZAPD, e.g. `-ZWunaccounted` to warn about unaccounted blocks in XMLs. Each argument should be passed separately, *without* the leading dash.", metavar="ZAPD_ARG", action="append") parser.add_argument("-Z", help="Pass the argument on to ZAPD, e.g. `-ZWunaccounted` to warn about unaccounted blocks in XMLs. Each argument should be passed separately, *without* the leading dash.", metavar="ZAPD_ARG", action="append")
@ -128,21 +128,6 @@ def main():
del extractedAssetsTracker[fullPath] del extractedAssetsTracker[fullPath]
ExtractFunc(fullPath) ExtractFunc(fullPath)
else: else:
extract_text_path = "assets/text/message_data.h"
extract_staff_text_path = "assets/text/message_data_staff.h"
# Only extract text if the header does not already exist, or if --force was passed
if not args.force:
if os.path.isfile(extract_text_path):
extract_text_path = None
if os.path.isfile(extract_staff_text_path):
extract_staff_text_path = None
if extract_text_path is not None or extract_staff_text_path is not None:
print("Extracting text")
from tools import msgdis
msgdis.extract_all_text(extract_text_path, extract_staff_text_path)
xmlFiles = [] xmlFiles = []
for currentPath, _, files in os.walk(os.path.join("assets", "xml")): for currentPath, _, files in os.walk(os.path.join("assets", "xml")):
for file in files: for file in files:

View file

@ -8,9 +8,9 @@
#define ALIGN256(val) (((val) + 0xFF) & ~0xFF) #define ALIGN256(val) (((val) + 0xFF) & ~0xFF)
#ifdef __GNUC__ #ifdef __GNUC__
#define ALIGNED8 __attribute__ ((aligned (8))) #define ALIGNED(n) __attribute__ ((aligned (n)))
#else #else
#define ALIGNED8 #define ALIGNED(n)
#endif #endif
#ifdef __sgi /* IDO compiler */ #ifdef __sgi /* IDO compiler */

View file

@ -44,7 +44,7 @@ void Fault_Init(void);
// Fatal Errors // Fatal Errors
NORETURN void Fault_AddHungupAndCrashImpl(const char* exp1, const char* exp2); NORETURN void Fault_AddHungupAndCrashImpl(const char* exp1, const char* exp2);
NORETURN void Fault_AddHungupAndCrash(const char* file, s32 line); NORETURN void Fault_AddHungupAndCrash(const char* file, int line);
// Client Registration // Client Registration

View file

@ -39,7 +39,7 @@ void isPrintfInit(void);
void rmonPrintf(const char* fmt, ...); void rmonPrintf(const char* fmt, ...);
#if OOT_DEBUG #if OOT_DEBUG
void* is_proutSyncPrintf(void* arg, const char* str, size_t count); void* is_proutSyncPrintf(void* arg, const char* str, size_t count);
NORETURN void func_80002384(const char* exp, const char* file, u32 line); NORETURN void func_80002384(const char* exp, const char* file, int line);
#endif #endif
OSPiHandle* osDriveRomInit(void); OSPiHandle* osDriveRomInit(void);
void Mio0_Decompress(u8* src, u8* dst); void Mio0_Decompress(u8* src, u8* dst);
@ -51,11 +51,11 @@ u32 StackCheck_CheckAll(void);
u32 StackCheck_Check(StackEntry* entry); u32 StackCheck_Check(StackEntry* entry);
#if OOT_DEBUG #if OOT_DEBUG
void LogUtils_LogHexDump(void* ptr, s32 size0); void LogUtils_LogHexDump(void* ptr, s32 size0);
void LogUtils_CheckNullPointer(const char* exp, void* ptr, const char* file, s32 line); void LogUtils_CheckNullPointer(const char* exp, void* ptr, const char* file, int line);
void LogUtils_CheckValidPointer(const char* exp, void* ptr, const char* file, s32 line); void LogUtils_CheckValidPointer(const char* exp, void* ptr, const char* file, int line);
void LogUtils_LogThreadId(const char* name, s32 line); void LogUtils_LogThreadId(const char* name, int line);
#endif #endif
void LogUtils_HungupThread(const char* name, s32 line); void LogUtils_HungupThread(const char* name, int line);
void LogUtils_ResetHungup(void); void LogUtils_ResetHungup(void);
void __osPiCreateAccessQueue(void); void __osPiCreateAccessQueue(void);
void __osPiGetAccess(void); void __osPiGetAccess(void);
@ -913,10 +913,10 @@ void ZeldaArena_Cleanup(void);
u8 ZeldaArena_IsInitialized(void); u8 ZeldaArena_IsInitialized(void);
#if OOT_DEBUG #if OOT_DEBUG
void ZeldaArena_CheckPointer(void* ptr, u32 size, const char* name, const char* action); void ZeldaArena_CheckPointer(void* ptr, u32 size, const char* name, const char* action);
void* ZeldaArena_MallocDebug(u32 size, const char* file, s32 line); void* ZeldaArena_MallocDebug(u32 size, const char* file, int line);
void* ZeldaArena_MallocRDebug(u32 size, const char* file, s32 line); void* ZeldaArena_MallocRDebug(u32 size, const char* file, int line);
void* ZeldaArena_ReallocDebug(void* ptr, u32 newSize, const char* file, s32 line); void* ZeldaArena_ReallocDebug(void* ptr, u32 newSize, const char* file, int line);
void ZeldaArena_FreeDebug(void* ptr, const char* file, s32 line); void ZeldaArena_FreeDebug(void* ptr, const char* file, int line);
void ZeldaArena_Display(void); void ZeldaArena_Display(void);
#endif #endif
void MapMark_Init(PlayState* play); void MapMark_Init(PlayState* play);
@ -1155,10 +1155,10 @@ void Sram_WriteSramHeader(SramContext* sramCtx);
void Sram_InitSram(GameState* gameState, SramContext* sramCtx); void Sram_InitSram(GameState* gameState, SramContext* sramCtx);
void Sram_Alloc(GameState* gameState, SramContext* sramCtx); void Sram_Alloc(GameState* gameState, SramContext* sramCtx);
void Sram_Init(PlayState* play, SramContext* sramCtx); void Sram_Init(PlayState* play, SramContext* sramCtx);
void SsSram_Init(u32 addr, u8 handleType, u8 handleDomain, u8 handleLatency, u8 handlePageSize, u8 handleRelDuration, void SsSram_Init(s32 addr, u8 handleType, u8 handleDomain, u8 handleLatency, u8 handlePageSize, u8 handleRelDuration,
u8 handlePulse, u32 handleSpeed); u8 handlePulse, u32 handleSpeed);
void SsSram_Dma(void* dramAddr, size_t size, s32 direction); void SsSram_Dma(void* dramAddr, size_t size, s32 direction);
void SsSram_ReadWrite(u32 addr, void* dramAddr, size_t size, s32 direction); void SsSram_ReadWrite(s32 addr, void* dramAddr, size_t size, s32 direction);
View* View_New(GraphicsContext* gfxCtx); View* View_New(GraphicsContext* gfxCtx);
void View_Free(View* view); void View_Free(View* view);
void View_Init(View*, GraphicsContext*); void View_Init(View*, GraphicsContext*);
@ -1316,8 +1316,8 @@ void GameState_Destroy(GameState* gameState);
GameStateFunc GameState_GetInit(GameState* gameState); GameStateFunc GameState_GetInit(GameState* gameState);
u32 GameState_IsRunning(GameState* gameState); u32 GameState_IsRunning(GameState* gameState);
#if OOT_DEBUG #if OOT_DEBUG
void* GameState_Alloc(GameState* gameState, size_t size, char* file, s32 line); void* GameState_Alloc(GameState* gameState, size_t size, const char* file, int line);
void* GameAlloc_MallocDebug(GameAlloc* this, u32 size, const char* file, s32 line); void* GameAlloc_MallocDebug(GameAlloc* this, u32 size, const char* file, int line);
#endif #endif
void* GameAlloc_Malloc(GameAlloc* this, u32 size); void* GameAlloc_Malloc(GameAlloc* this, u32 size);
void GameAlloc_Free(GameAlloc* this, void* data); void GameAlloc_Free(GameAlloc* this, void* data);
@ -1333,8 +1333,8 @@ void Graph_ThreadEntry(void*);
void* Graph_Alloc(GraphicsContext* gfxCtx, size_t size); void* Graph_Alloc(GraphicsContext* gfxCtx, size_t size);
void* Graph_Alloc2(GraphicsContext* gfxCtx, size_t size); void* Graph_Alloc2(GraphicsContext* gfxCtx, size_t size);
#if OOT_DEBUG #if OOT_DEBUG
void Graph_OpenDisps(Gfx** dispRefs, GraphicsContext* gfxCtx, const char* file, s32 line); void Graph_OpenDisps(Gfx** dispRefs, GraphicsContext* gfxCtx, const char* file, int line);
void Graph_CloseDisps(Gfx** dispRefs, GraphicsContext* gfxCtx, const char* file, s32 line); void Graph_CloseDisps(Gfx** dispRefs, GraphicsContext* gfxCtx, const char* file, int line);
#endif #endif
Gfx* Gfx_Open(Gfx* gfx); Gfx* Gfx_Open(Gfx* gfx);
Gfx* Gfx_Close(Gfx* gfx, Gfx* dst); Gfx* Gfx_Close(Gfx* gfx, Gfx* dst);
@ -1437,8 +1437,8 @@ void Matrix_TranslateRotateZYX(Vec3f* translation, Vec3s* rotation);
void Matrix_SetTranslateRotateYXZ(f32 translateX, f32 translateY, f32 translateZ, Vec3s* rot); void Matrix_SetTranslateRotateYXZ(f32 translateX, f32 translateY, f32 translateZ, Vec3s* rot);
Mtx* Matrix_MtxFToMtx(MtxF* src, Mtx* dest); Mtx* Matrix_MtxFToMtx(MtxF* src, Mtx* dest);
#if OOT_DEBUG #if OOT_DEBUG
Mtx* Matrix_ToMtx(Mtx* dest, char* file, s32 line); Mtx* Matrix_ToMtx(Mtx* dest, const char* file, int line);
Mtx* Matrix_NewMtx(GraphicsContext* gfxCtx, char* file, s32 line); Mtx* Matrix_NewMtx(GraphicsContext* gfxCtx, const char* file, int line);
#else #else
Mtx* Matrix_ToMtx(Mtx* dest); Mtx* Matrix_ToMtx(Mtx* dest);
Mtx* Matrix_NewMtx(GraphicsContext* gfxCtx); Mtx* Matrix_NewMtx(GraphicsContext* gfxCtx);
@ -1453,7 +1453,7 @@ void Matrix_MtxFToYXZRotS(MtxF* mf, Vec3s* rotDest, s32 flag);
void Matrix_MtxFToZYXRotS(MtxF* mf, Vec3s* rotDest, s32 flag); void Matrix_MtxFToZYXRotS(MtxF* mf, Vec3s* rotDest, s32 flag);
void Matrix_RotateAxis(f32 angle, Vec3f* axis, u8 mode); void Matrix_RotateAxis(f32 angle, Vec3f* axis, u8 mode);
#if OOT_DEBUG #if OOT_DEBUG
MtxF* Matrix_CheckFloats(MtxF* mf, char* file, s32 line); MtxF* Matrix_CheckFloats(MtxF* mf, const char* file, int line);
#endif #endif
void Matrix_SetTranslateScaleMtx2(Mtx* mtx, f32 scaleX, f32 scaleY, f32 scaleZ, f32 translateX, f32 translateY, void Matrix_SetTranslateScaleMtx2(Mtx* mtx, f32 scaleX, f32 scaleY, f32 scaleZ, f32 translateX, f32 translateY,
f32 translateZ); f32 translateZ);
@ -1476,10 +1476,10 @@ void DebugArena_Cleanup(void);
u8 DebugArena_IsInitialized(void); u8 DebugArena_IsInitialized(void);
#if OOT_DEBUG #if OOT_DEBUG
void DebugArena_CheckPointer(void* ptr, u32 size, const char* name, const char* action); void DebugArena_CheckPointer(void* ptr, u32 size, const char* name, const char* action);
void* DebugArena_MallocDebug(u32 size, const char* file, s32 line); void* DebugArena_MallocDebug(u32 size, const char* file, int line);
void* DebugArena_MallocRDebug(u32 size, const char* file, s32 line); void* DebugArena_MallocRDebug(u32 size, const char* file, int line);
void* DebugArena_ReallocDebug(void* ptr, u32 newSize, const char* file, s32 line); void* DebugArena_ReallocDebug(void* ptr, u32 newSize, const char* file, int line);
void DebugArena_FreeDebug(void* ptr, const char* file, s32 line); void DebugArena_FreeDebug(void* ptr, const char* file, int line);
void DebugArena_Display(void); void DebugArena_Display(void);
#endif #endif
void UCodeDisas_Init(UCodeDisas*); void UCodeDisas_Init(UCodeDisas*);
@ -1774,10 +1774,10 @@ void SystemArena_Init(void* start, u32 size);
void SystemArena_Cleanup(void); void SystemArena_Cleanup(void);
u8 SystemArena_IsInitialized(void); u8 SystemArena_IsInitialized(void);
#if OOT_DEBUG #if OOT_DEBUG
void* SystemArena_MallocDebug(u32 size, const char* file, s32 line); void* SystemArena_MallocDebug(u32 size, const char* file, int line);
void* SystemArena_MallocRDebug(u32 size, const char* file, s32 line); void* SystemArena_MallocRDebug(u32 size, const char* file, int line);
void* SystemArena_ReallocDebug(void* ptr, u32 newSize, const char* file, s32 line); void* SystemArena_ReallocDebug(void* ptr, u32 newSize, const char* file, int line);
void SystemArena_FreeDebug(void* ptr, const char* file, s32 line); void SystemArena_FreeDebug(void* ptr, const char* file, int line);
void SystemArena_Display(void); void SystemArena_Display(void);
#endif #endif
u32 Rand_Next(void); u32 Rand_Next(void);
@ -1799,10 +1799,10 @@ void* __osRealloc(Arena* arena, void* ptr, u32 newSize);
void ArenaImpl_GetSizes(Arena* arena, u32* outMaxFree, u32* outFree, u32* outAlloc); void ArenaImpl_GetSizes(Arena* arena, u32* outMaxFree, u32* outFree, u32* outAlloc);
u32 __osCheckArena(Arena* arena); u32 __osCheckArena(Arena* arena);
#if OOT_DEBUG #if OOT_DEBUG
void* __osMallocDebug(Arena* arena, u32 size, const char* file, s32 line); void* __osMallocDebug(Arena* arena, u32 size, const char* file, int line);
void* __osMallocRDebug(Arena* arena, u32 size, const char* file, s32 line); void* __osMallocRDebug(Arena* arena, u32 size, const char* file, int line);
void __osFreeDebug(Arena* arena, void* ptr, const char* file, s32 line); void __osFreeDebug(Arena* arena, void* ptr, const char* file, int line);
void* __osReallocDebug(Arena* arena, void* ptr, u32 newSize, const char* file, s32 line); void* __osReallocDebug(Arena* arena, void* ptr, u32 newSize, const char* file, int line);
void __osDisplayArena(Arena* arena); void __osDisplayArena(Arena* arena);
#endif #endif
s32 PrintUtils_VPrintf(PrintCallback* pfn, const char* fmt, va_list args); s32 PrintUtils_VPrintf(PrintCallback* pfn, const char* fmt, va_list args);

View file

@ -1,3 +1,8 @@
# Evaluate this file only once in case it's included more than once
.ifndef _MACRO_INC_GUARD
.internal _MACRO_INC_GUARD
.set _MACRO_INC_GUARD, 1
.macro glabel label .macro glabel label
.global \label .global \label
\label: \label:
@ -47,3 +52,5 @@
.set $fs4f, $f29 .set $fs4f, $f29
.set $fs5, $f30 .set $fs5, $f30
.set $fs5f, $f31 .set $fs5f, $f31
.endif

View file

@ -114,7 +114,7 @@
// argument errors instead. // argument errors instead.
// Note some tools define __sgi but preprocess with a modern cpp implementation, // Note some tools define __sgi but preprocess with a modern cpp implementation,
// ensure that these do not use the IDO workaround to avoid errors. // ensure that these do not use the IDO workaround to avoid errors.
#define IDO_PRINTF_WORKAROUND (__sgi && !__GNUC__ && !PERMUTER && !M2CTX) #define IDO_PRINTF_WORKAROUND (__sgi && !__GNUC__ && !M2CTX)
#if OOT_DEBUG #if OOT_DEBUG
#define PRINTF osSyncPrintf #define PRINTF osSyncPrintf

View file

@ -119,6 +119,12 @@
#define BTN_B 0x4000 #define BTN_B 0x4000
#define BTN_A 0x8000 #define BTN_A 0x8000
#ifdef __GNUC__
// Ensure data cache coherency for OSPifRam structures by aligning to the data cache line size.
// On older compilers such as IDO this was done by placing each OSPifRam at the top of the file it is declared in,
// however file alignment should not be relied on in general.
__attribute__((aligned(0x10)))
#endif
typedef union { typedef union {
struct { struct {
/* 0x00 */ u32 ram[15]; /* 0x00 */ u32 ram[15];

View file

@ -143,13 +143,17 @@ extern u16 D_801333D0;
extern Vec3f gSfxDefaultPos; extern Vec3f gSfxDefaultPos;
extern f32 gSfxDefaultFreqAndVolScale; extern f32 gSfxDefaultFreqAndVolScale;
extern s8 gSfxDefaultReverb; extern s8 gSfxDefaultReverb;
#if OOT_DEBUG
extern u8 D_801333F0; extern u8 D_801333F0;
extern u8 gAudioSfxSwapOff; extern u8 gAudioSfxSwapOff;
extern u8 D_801333F8; extern u8 D_801333F8;
#endif
extern u8 gSeqCmdWritePos; extern u8 gSeqCmdWritePos;
extern u8 gSeqCmdReadPos; extern u8 gSeqCmdReadPos;
extern u8 gStartSeqDisabled; extern u8 gStartSeqDisabled;
#if OOT_DEBUG
extern u8 gAudioDebugPrintSeqCmd; extern u8 gAudioDebugPrintSeqCmd;
#endif
extern u8 gSoundModeList[]; extern u8 gSoundModeList[];
extern u8 gAudioSpecId; extern u8 gAudioSpecId;
extern u8 D_80133418; extern u8 D_80133418;
@ -231,6 +235,5 @@ extern u64 gGfxSPTaskYieldBuffer[OS_YIELD_DATA_SIZE / sizeof(u64)]; // 0xC00 byt
extern u64 gGfxSPTaskStack[SP_DRAM_STACK_SIZE64]; // 0x400 bytes extern u64 gGfxSPTaskStack[SP_DRAM_STACK_SIZE64]; // 0x400 bytes
extern GfxPool gGfxPools[2]; // 0x24820 bytes extern GfxPool gGfxPools[2]; // 0x24820 bytes
extern u8 gAudioHeap[0x38000]; // 0x38000 bytes extern u8 gAudioHeap[0x38000]; // 0x38000 bytes
extern u8 gSystemHeap[];
#endif #endif

View file

@ -717,7 +717,7 @@ typedef struct ArenaNode {
/* 0x0C */ struct ArenaNode* prev; /* 0x0C */ struct ArenaNode* prev;
#if OOT_DEBUG // TODO: This debug info is also present in N64 retail builds #if OOT_DEBUG // TODO: This debug info is also present in N64 retail builds
/* 0x10 */ const char* filename; /* 0x10 */ const char* filename;
/* 0x14 */ s32 line; /* 0x14 */ int line;
/* 0x18 */ OSId threadId; /* 0x18 */ OSId threadId;
/* 0x1C */ Arena* arena; /* 0x1C */ Arena* arena;
/* 0x20 */ OSTime time; /* 0x20 */ OSTime time;
@ -755,7 +755,12 @@ typedef struct OverlayRelocationSection {
/* 0x14 */ u32 relocations[1]; // size is nRelocations /* 0x14 */ u32 relocations[1]; // size is nRelocations
} OverlayRelocationSection; // size >= 0x18 } OverlayRelocationSection; // size >= 0x18
typedef struct { // This struct is used at osAppNMIBuffer which is not at an 8-byte aligned address. This causes an unaligned access
// crash if the OSTime variables use 64-bit load/store instructions, which is the case in any MIPS ABI other than O32
// where 64-bit load/store instructions are emulated with 2x 32-bit load/store instructions. The alignment attribute
// conveys that this structure will not always be 8-bytes aligned, allowing a modern compiler to generate non-crashing
// code for accessing these. This is not an issue in the original compiler as it only output O32 ABI code.
ALIGNED(4) typedef struct {
/* 0x00 */ u32 resetting; /* 0x00 */ u32 resetting;
/* 0x04 */ u32 resetCount; /* 0x04 */ u32 resetCount;
/* 0x08 */ OSTime duration; /* 0x08 */ OSTime duration;

View file

@ -9,7 +9,7 @@ typedef struct {
/* 0x04 */ void* dramAddr; // DRAM address (destination) /* 0x04 */ void* dramAddr; // DRAM address (destination)
/* 0x08 */ size_t size; // File Transfer size /* 0x08 */ size_t size; // File Transfer size
/* 0x0C */ const char* filename; // Filename for debugging /* 0x0C */ const char* filename; // Filename for debugging
/* 0x10 */ s32 line; // Line for debugging /* 0x10 */ int line; // Line number for debugging
/* 0x14 */ s32 unk_14; /* 0x14 */ s32 unk_14;
/* 0x18 */ OSMesgQueue* notifyQueue; // Message queue for the notification message /* 0x18 */ OSMesgQueue* notifyQueue; // Message queue for the notification message
/* 0x1C */ OSMesg notifyMsg; // Completion notification message /* 0x1C */ OSMesg notifyMsg; // Completion notification message
@ -48,8 +48,8 @@ s32 DmaMgr_RequestAsync(DmaRequest* req, void* ram, uintptr_t vrom, size_t size,
s32 DmaMgr_RequestSync(void* ram, uintptr_t vrom, size_t size); s32 DmaMgr_RequestSync(void* ram, uintptr_t vrom, size_t size);
#if OOT_DEBUG #if OOT_DEBUG
s32 DmaMgr_RequestAsyncDebug(DmaRequest* req, void* ram, uintptr_t vrom, size_t size, u32 unk5, OSMesgQueue* queue, s32 DmaMgr_RequestAsyncDebug(DmaRequest* req, void* ram, uintptr_t vrom, size_t size, u32 unk5, OSMesgQueue* queue,
OSMesg msg, const char* file, s32 line); OSMesg msg, const char* file, int line);
s32 DmaMgr_RequestSyncDebug(void* ram, uintptr_t vrom, size_t size, const char* file, s32 line); s32 DmaMgr_RequestSyncDebug(void* ram, uintptr_t vrom, size_t size, const char* file, int line);
#endif #endif
// Special-purpose DMA Requests // Special-purpose DMA Requests

View file

@ -14,6 +14,6 @@ pycparser
toml toml
# tools # tools
mapfile-parser>=1.2.1,<2.0.0 mapfile-parser>=2.3.5,<3.0.0
rabbitizer>=1.0.0,<2.0.0 rabbitizer>=1.0.0,<2.0.0
spimdisasm>=1.20.0,<2.0.0 spimdisasm>=1.21.0,<2.0.0

View file

@ -5,16 +5,34 @@
import argparse import argparse
import collections import collections
from colorama import Fore, Style
from dataclasses import dataclass from dataclasses import dataclass
import difflib import difflib
from enum import Enum
import itertools import itertools
import math import math
from pathlib import Path from pathlib import Path
import re import re
import subprocess import subprocess
import sys import sys
from typing import Iterator, List, Optional, Tuple import multiprocessing
import multiprocessing.pool
from typing import Dict, Iterator, List, Optional, Tuple
def green(s: str) -> str:
return f"{Fore.GREEN}{s}{Style.RESET_ALL}"
def red(s: str) -> str:
return f"{Fore.RED}{s}{Style.RESET_ALL}"
# Make interrupting with ^C less jank
# https://stackoverflow.com/questions/72967793/keyboardinterrupt-with-python-multiprocessing-pool
def set_sigint_ignored():
import signal
signal.signal(signal.SIGINT, signal.SIG_IGN)
@dataclass @dataclass
@ -68,30 +86,25 @@ def parse_inst(func_name: str, line: str) -> Inst:
return Inst(func_name, mnemonic, regs, imm, None, None) return Inst(func_name, mnemonic, regs, imm, None, None)
def run_objdump(path: Path) -> List[Inst]: def run_objdump(path: Path, args: List[str]) -> str:
if not path.exists(): if not path.exists():
raise Exception(f"file {path} does not exist") raise Exception(f"file {path} does not exist")
command = [ command = ["mips-linux-gnu-objdump"] + args + [str(path)]
"mips-linux-gnu-objdump",
"-drz",
"-m",
"mips:4300",
"-j",
".text",
str(path),
]
try: try:
lines = subprocess.run( return subprocess.run(
command, command,
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.PIPE, stderr=subprocess.PIPE,
check=True, check=True,
encoding="utf-8", encoding="utf-8",
).stdout.splitlines() ).stdout
except subprocess.CalledProcessError as e: except subprocess.CalledProcessError as e:
return [] return ""
def disassemble(path: Path) -> List[Inst]:
lines = run_objdump(path, ["-drz", "-m", "mips:4300", "-j", ".text"]).splitlines()
result = [] result = []
func_name = None func_name = None
@ -156,14 +169,47 @@ def has_diff(inst1: Inst, inst2: Inst) -> bool:
return inst1 != inst2 return inst1 != inst2
def get_section_sizes(path: Path) -> Dict[str, int]:
lines = run_objdump(path, ["-h"]).splitlines()
if len(lines) < 5:
return {}
result = {}
for i in range(5, len(lines), 2):
parts = lines[i].split()
name = parts[1]
size = int(parts[2], 16)
# Pad to 0x10-byte alignment
result[parts[1]] = (size + 0xF) & ~0xF
return result
def get_section_hex_dump(path: Path, section: str) -> List[str]:
lines = run_objdump(path, ["-s", "-j", section]).splitlines()
return lines[4:]
def parse_hex_dump(lines: List[str]) -> bytes:
result = bytearray()
for line in lines:
data = line[6:41].replace(" ", "")
result.extend(bytes.fromhex(data))
# pad to 0x10-byte alignment
while len(result) % 0x10:
result.append(0)
return result
def find_functions_with_diffs(version: str, c_path: str): def find_functions_with_diffs(version: str, c_path: str):
object_path = Path(c_path).with_suffix(".o") object_path = Path(c_path).with_suffix(".o")
expected_dir = Path("expected/build") / version expected_dir = Path("expected/build") / version
build_dir = Path("build") / version build_dir = Path("build") / version
insts1 = run_objdump(expected_dir / object_path) insts1 = disassemble(expected_dir / object_path)
insts2 = run_objdump(build_dir / object_path) insts2 = disassemble(build_dir / object_path)
functions_with_diffs = collections.OrderedDict() functions_with_diffs = collections.OrderedDict()
for inst1, inst2 in pair_instructions(insts1, insts2): for inst1, inst2 in pair_instructions(insts1, insts2):
@ -184,49 +230,156 @@ def find_functions_with_diffs(version: str, c_path: str):
print(f" {func_name}") print(f" {func_name}")
def print_summary(version: str, csv: bool): def find_data_diffs(version: str, c_path: str):
object_path = Path(c_path).with_suffix(".o")
expected_dir = Path("expected/build") / version expected_dir = Path("expected/build") / version
build_dir = Path("build") / version build_dir = Path("build") / version
if csv: sizes1 = get_section_sizes(expected_dir / object_path)
print("path,expected,actual,added,removed,changed,progress") sizes2 = get_section_sizes(build_dir / object_path)
for object_file in sorted(expected_dir.glob("src/**/*.o")): rodata_dump1 = get_section_hex_dump(expected_dir / object_path, ".rodata")
object_path = object_file.relative_to(expected_dir) rodata_dump2 = get_section_hex_dump(build_dir / object_path, ".rodata")
c_path = object_path.with_suffix(".c") rodata1 = parse_hex_dump(rodata_dump1)
rodata2 = parse_hex_dump(rodata_dump2)
insts1 = run_objdump(expected_dir / object_path) rodata_matches = rodata1 == rodata2
insts2 = run_objdump(build_dir / object_path) data_size_matches = sizes1.get(".data", 0) == sizes2.get(".data", 0)
bss_size_matches = sizes1.get(".bss", 0) == sizes2.get(".bss", 0)
added = 0 if rodata_matches:
removed = 0 print(f"{c_path} .rodata OK")
changed = 0 else:
for inst1, inst2 in pair_instructions(insts1, insts2): print(
if inst1 is None and inst2 is not None: f"{c_path} .rodata differs: expected size 0x{sizes1.get('.rodata', 0):04x} vs build size 0x{sizes2.get('.rodata', 0):04x}"
added += 1 )
elif inst1 is not None and inst2 is None: print(f" expected:")
removed += 1 print("\n".join(rodata_dump1))
elif inst1 is not None and inst2 is not None and has_diff(inst1, inst2): print(f" build:")
changed += 1 print("\n".join(rodata_dump2))
if insts1: if data_size_matches:
progress = max(1.0 - (added + removed + changed) / len(insts1), 0) print(f"{c_path} .data size OK")
else: else:
progress = 1.0 print(
f"{c_path} .data size differs: expected size 0x{sizes1.get('.data', 0):04x} vs build size 0x{sizes2.get('.data', 0):04x}"
)
if csv: if bss_size_matches:
print( print(f"{c_path} .bss size OK")
f"{c_path},{len(insts1)},{len(insts2)},{added},{removed},{changed},{progress:.3f}" else:
print(
f"{c_path} .bss size differs: expected size 0x{sizes1.get('.bss', 0):04x} vs build size 0x{sizes2.get('.bss', 0):04x}"
)
@dataclass
class ObjectDataForComparison:
insts1: List[Inst]
insts2: List[Inst]
sizes1: Dict[str, int]
sizes2: Dict[str, int]
rodata1: bytes
rodata2: bytes
def get_object_data_for_comparison(object1: Path, object2: Path):
insts1 = disassemble(object1)
insts2 = disassemble(object2)
sizes1 = get_section_sizes(object1)
sizes2 = get_section_sizes(object2)
rodata_dump1 = get_section_hex_dump(object1, ".rodata")
rodata_dump2 = get_section_hex_dump(object2, ".rodata")
rodata1 = parse_hex_dump(rodata_dump1)
rodata2 = parse_hex_dump(rodata_dump2)
return ObjectDataForComparison(insts1, insts2, sizes1, sizes2, rodata1, rodata2)
def print_summary(version: str, csv: bool, only_not_ok: bool):
expected_dir = Path("expected/build") / version
build_dir = Path("build") / version
expected_object_files = sorted(expected_dir.glob("src/**/*.o"))
comparison_data_list: List[multiprocessing.pool.AsyncResult] = []
with multiprocessing.Pool(initializer=set_sigint_ignored) as p:
for expected_object in expected_object_files:
build_object = build_dir / expected_object.relative_to(expected_dir)
comparison_data_list.append(
p.apply_async(
get_object_data_for_comparison,
(expected_object, build_object),
)
) )
elif progress == 1.0: if csv:
print(f" OK {c_path}") print("path,expected,actual,.text,.rodata,.data size,.bss size")
else: for expected_object, data_async in zip(
print(f" {math.floor(progress * 100):>2}% {c_path}") expected_object_files, comparison_data_list
):
c_path = expected_object.relative_to(expected_dir).with_suffix(".c")
data = data_async.get()
insts1 = data.insts1
insts2 = data.insts2
added = 0
removed = 0
changed = 0
for inst1, inst2 in pair_instructions(insts1, insts2):
if inst1 is None and inst2 is not None:
added += 1
elif inst1 is not None and inst2 is None:
removed += 1
elif inst1 is not None and inst2 is not None and has_diff(inst1, inst2):
changed += 1
if insts1:
text_progress = max(1.0 - (added + removed + changed) / len(insts1), 0)
else:
text_progress = 1.0
sizes1 = data.sizes1
sizes2 = data.sizes2
rodata1 = data.rodata1
rodata2 = data.rodata2
rodata_matches = rodata1 == rodata2
data_size_matches = sizes1.get(".data", 0) == sizes2.get(".data", 0)
bss_size_matches = sizes1.get(".bss", 0) == sizes2.get(".bss", 0)
if only_not_ok:
if (
text_progress == 1
and rodata_matches
and data_size_matches
and bss_size_matches
):
continue
if csv:
print(
f"{c_path},{len(insts1)},{len(insts2)},{text_progress:.3f},{rodata_matches},{data_size_matches},{bss_size_matches}"
)
else:
ok = green("OK")
diff = red("diff")
text_progress_str = (
ok
if text_progress == 1
else red(f"{math.floor(text_progress * 100):>2}%")
)
rodata_str = ok if rodata_matches else diff
data_size_str = ok if data_size_matches else diff
bss_size_str = ok if bss_size_matches else diff
print(
f"text:{text_progress_str:<13} rodata:{rodata_str:<13} data size:{data_size_str:<13} bss size:{bss_size_str:<13} {c_path}"
)
sys.stdout.flush()
if __name__ == "__main__": if __name__ == "__main__":
parser = argparse.ArgumentParser( parser = argparse.ArgumentParser(description="Calculate progress matching retail")
description="Calculate progress matching .text sections"
)
parser.add_argument( parser.add_argument(
"file", "file",
metavar="FILE", metavar="FILE",
@ -236,10 +389,24 @@ if __name__ == "__main__":
parser.add_argument( parser.add_argument(
"-v", "--version", help="version to compare", default="gc-eu-mq" "-v", "--version", help="version to compare", default="gc-eu-mq"
) )
parser.add_argument(
"--data",
help="diff .data size, .bss size, and .rodata contents instead of text",
action="store_true",
)
parser.add_argument(
"--not-ok",
help="only print non-OK files",
action="store_true",
dest="only_not_ok",
)
parser.add_argument("--csv", help="print summary CSV", action="store_true") parser.add_argument("--csv", help="print summary CSV", action="store_true")
args = parser.parse_args() args = parser.parse_args()
if args.file is not None: if args.file is not None:
find_functions_with_diffs(args.version, args.file) if args.data:
find_data_diffs(args.version, args.file)
else:
find_functions_with_diffs(args.version, args.file)
else: else:
print_summary(args.version, args.csv) print_summary(args.version, args.csv, args.only_not_ok)

68
spec
View file

@ -20,13 +20,17 @@ beginseg
include "$(BUILD_DIR)/src/boot/z_std_dma.o" include "$(BUILD_DIR)/src/boot/z_std_dma.o"
include "$(BUILD_DIR)/src/boot/yaz0.o" include "$(BUILD_DIR)/src/boot/yaz0.o"
include "$(BUILD_DIR)/src/boot/z_locale.o" include "$(BUILD_DIR)/src/boot/z_locale.o"
#if OOT_DEBUG
include "$(BUILD_DIR)/src/boot/assert.o" include "$(BUILD_DIR)/src/boot/assert.o"
#endif
include "$(BUILD_DIR)/src/boot/is_debug.o" include "$(BUILD_DIR)/src/boot/is_debug.o"
include "$(BUILD_DIR)/src/libultra/io/driverominit.o" include "$(BUILD_DIR)/src/libultra/io/driverominit.o"
include "$(BUILD_DIR)/src/boot/mio0.o" include "$(BUILD_DIR)/src/boot/mio0.o"
include "$(BUILD_DIR)/src/boot/stackcheck.o" include "$(BUILD_DIR)/src/boot/stackcheck.o"
include "$(BUILD_DIR)/src/boot/logutils.o" include "$(BUILD_DIR)/src/boot/logutils.o"
#if OOT_DEBUG
include "$(BUILD_DIR)/src/libultra/libc/sprintf.o" include "$(BUILD_DIR)/src/libultra/libc/sprintf.o"
#endif
include "$(BUILD_DIR)/src/libultra/io/piacs.o" include "$(BUILD_DIR)/src/libultra/io/piacs.o"
include "$(BUILD_DIR)/src/libultra/os/sendmesg.o" include "$(BUILD_DIR)/src/libultra/os/sendmesg.o"
include "$(BUILD_DIR)/src/libultra/os/stopthread.o" include "$(BUILD_DIR)/src/libultra/os/stopthread.o"
@ -57,10 +61,14 @@ beginseg
include "$(BUILD_DIR)/src/libultra/os/probetlb.o" include "$(BUILD_DIR)/src/libultra/os/probetlb.o"
include "$(BUILD_DIR)/src/libultra/os/getmemsize.o" include "$(BUILD_DIR)/src/libultra/os/getmemsize.o"
include "$(BUILD_DIR)/src/libultra/os/seteventmesg.o" include "$(BUILD_DIR)/src/libultra/os/seteventmesg.o"
#if OOT_DEBUG
include "$(BUILD_DIR)/src/libultra/libc/xprintf.o" include "$(BUILD_DIR)/src/libultra/libc/xprintf.o"
#endif
include "$(BUILD_DIR)/src/libultra/os/unmaptlball.o" include "$(BUILD_DIR)/src/libultra/os/unmaptlball.o"
include "$(BUILD_DIR)/src/libultra/io/epidma.o" include "$(BUILD_DIR)/src/libultra/io/epidma.o"
#if OOT_DEBUG
include "$(BUILD_DIR)/src/libultra/libc/string.o" include "$(BUILD_DIR)/src/libultra/libc/string.o"
#endif
include "$(BUILD_DIR)/src/libultra/os/invalicache.o" include "$(BUILD_DIR)/src/libultra/os/invalicache.o"
include "$(BUILD_DIR)/src/libultra/os/createmesgqueue.o" include "$(BUILD_DIR)/src/libultra/os/createmesgqueue.o"
include "$(BUILD_DIR)/src/libultra/os/invaldcache.o" include "$(BUILD_DIR)/src/libultra/os/invaldcache.o"
@ -88,17 +96,23 @@ beginseg
include "$(BUILD_DIR)/src/libultra/io/epiread.o" include "$(BUILD_DIR)/src/libultra/io/epiread.o"
include "$(BUILD_DIR)/src/libultra/io/visetspecial.o" include "$(BUILD_DIR)/src/libultra/io/visetspecial.o"
include "$(BUILD_DIR)/src/libultra/io/cartrominit.o" include "$(BUILD_DIR)/src/libultra/io/cartrominit.o"
#if OOT_DEBUG
include "$(BUILD_DIR)/src/libultra/io/vimodefpallan1.o" include "$(BUILD_DIR)/src/libultra/io/vimodefpallan1.o"
#endif
include "$(BUILD_DIR)/src/libultra/os/setfpccsr.o" include "$(BUILD_DIR)/src/libultra/os/setfpccsr.o"
include "$(BUILD_DIR)/src/libultra/os/getfpccsr.o" include "$(BUILD_DIR)/src/libultra/os/getfpccsr.o"
#if OOT_DEBUG
include "$(BUILD_DIR)/src/libultra/io/epiwrite.o" include "$(BUILD_DIR)/src/libultra/io/epiwrite.o"
#endif
include "$(BUILD_DIR)/src/libultra/os/maptlbrdb.o" include "$(BUILD_DIR)/src/libultra/os/maptlbrdb.o"
include "$(BUILD_DIR)/src/libultra/os/yieldthread.o" include "$(BUILD_DIR)/src/libultra/os/yieldthread.o"
include "$(BUILD_DIR)/src/libultra/os/getcause.o" include "$(BUILD_DIR)/src/libultra/os/getcause.o"
include "$(BUILD_DIR)/src/libultra/io/epirawwrite.o" include "$(BUILD_DIR)/src/libultra/io/epirawwrite.o"
#if OOT_DEBUG
include "$(BUILD_DIR)/src/libultra/libc/xlitob.o" include "$(BUILD_DIR)/src/libultra/libc/xlitob.o"
include "$(BUILD_DIR)/src/libultra/libc/ldiv.o" include "$(BUILD_DIR)/src/libultra/libc/ldiv.o"
include "$(BUILD_DIR)/src/libultra/libc/xldtob.o" include "$(BUILD_DIR)/src/libultra/libc/xldtob.o"
#endif
include "$(BUILD_DIR)/src/boot/build.o" include "$(BUILD_DIR)/src/boot/build.o"
include "$(BUILD_DIR)/src/libultra/io/sirawwrite.o" include "$(BUILD_DIR)/src/libultra/io/sirawwrite.o"
include "$(BUILD_DIR)/src/libultra/io/vimgr.o" include "$(BUILD_DIR)/src/libultra/io/vimgr.o"
@ -342,7 +356,9 @@ beginseg
include "$(BUILD_DIR)/src/code/z_lights.o" include "$(BUILD_DIR)/src/code/z_lights.o"
include "$(BUILD_DIR)/src/code/z_malloc.o" include "$(BUILD_DIR)/src/code/z_malloc.o"
include "$(BUILD_DIR)/src/code/z_map_mark.o" include "$(BUILD_DIR)/src/code/z_map_mark.o"
#if OOT_DEBUG
include "$(BUILD_DIR)/src/code/z_moji.o" include "$(BUILD_DIR)/src/code/z_moji.o"
#endif
include "$(BUILD_DIR)/src/code/z_prenmi_buff.o" include "$(BUILD_DIR)/src/code/z_prenmi_buff.o"
include "$(BUILD_DIR)/src/code/z_nulltask.o" include "$(BUILD_DIR)/src/code/z_nulltask.o"
include "$(BUILD_DIR)/src/code/z_olib.o" include "$(BUILD_DIR)/src/code/z_olib.o"
@ -369,7 +385,9 @@ beginseg
include "$(BUILD_DIR)/src/code/z_sram.o" include "$(BUILD_DIR)/src/code/z_sram.o"
include "$(BUILD_DIR)/src/code/z_ss_sram.o" include "$(BUILD_DIR)/src/code/z_ss_sram.o"
include "$(BUILD_DIR)/src/code/z_rumble.o" include "$(BUILD_DIR)/src/code/z_rumble.o"
#if OOT_DEBUG
include "$(BUILD_DIR)/data/z_text.data.o" include "$(BUILD_DIR)/data/z_text.data.o"
#endif
include "$(BUILD_DIR)/data/unk_8012ABC0.data.o" include "$(BUILD_DIR)/data/unk_8012ABC0.data.o"
include "$(BUILD_DIR)/src/code/z_view.o" include "$(BUILD_DIR)/src/code/z_view.o"
include "$(BUILD_DIR)/src/code/z_vimode.o" include "$(BUILD_DIR)/src/code/z_vimode.o"
@ -385,9 +403,13 @@ beginseg
include "$(BUILD_DIR)/src/code/z_fbdemo_circle.o" include "$(BUILD_DIR)/src/code/z_fbdemo_circle.o"
include "$(BUILD_DIR)/src/code/z_fbdemo_fade.o" include "$(BUILD_DIR)/src/code/z_fbdemo_fade.o"
include "$(BUILD_DIR)/src/code/shrink_window.o" include "$(BUILD_DIR)/src/code/shrink_window.o"
#if OOT_DEBUG
include "$(BUILD_DIR)/src/code/db_camera.o" include "$(BUILD_DIR)/src/code/db_camera.o"
#endif
include "$(BUILD_DIR)/src/code/code_800BB0A0.o" include "$(BUILD_DIR)/src/code/code_800BB0A0.o"
#if OOT_DEBUG
include "$(BUILD_DIR)/src/code/mempak.o" include "$(BUILD_DIR)/src/code/mempak.o"
#endif
include "$(BUILD_DIR)/src/code/z_kaleido_manager.o" include "$(BUILD_DIR)/src/code/z_kaleido_manager.o"
include "$(BUILD_DIR)/src/code/z_kaleido_scope_call.o" include "$(BUILD_DIR)/src/code/z_kaleido_scope_call.o"
include "$(BUILD_DIR)/src/code/z_play.o" include "$(BUILD_DIR)/src/code/z_play.o"
@ -415,7 +437,9 @@ beginseg
include "$(BUILD_DIR)/src/code/sys_rumble.o" include "$(BUILD_DIR)/src/code/sys_rumble.o"
include "$(BUILD_DIR)/src/code/code_800D31A0.o" include "$(BUILD_DIR)/src/code/code_800D31A0.o"
include "$(BUILD_DIR)/src/code/irqmgr.o" include "$(BUILD_DIR)/src/code/irqmgr.o"
#if OOT_DEBUG
include "$(BUILD_DIR)/src/code/debug_malloc.o" include "$(BUILD_DIR)/src/code/debug_malloc.o"
#endif
include "$(BUILD_DIR)/src/code/fault.o" include "$(BUILD_DIR)/src/code/fault.o"
include "$(BUILD_DIR)/src/code/fault_drawer.o" include "$(BUILD_DIR)/src/code/fault_drawer.o"
#ifndef NON_MATCHING #ifndef NON_MATCHING
@ -423,7 +447,9 @@ beginseg
include "$(BUILD_DIR)/data/fault_drawer.bss.o" include "$(BUILD_DIR)/data/fault_drawer.bss.o"
#endif #endif
include "$(BUILD_DIR)/src/code/kanread.o" include "$(BUILD_DIR)/src/code/kanread.o"
#if OOT_DEBUG
include "$(BUILD_DIR)/src/code/ucode_disas.o" include "$(BUILD_DIR)/src/code/ucode_disas.o"
#endif
pad_text // audio library aligned to 32 bytes? pad_text // audio library aligned to 32 bytes?
include "$(BUILD_DIR)/src/audio/lib/data.o" include "$(BUILD_DIR)/src/audio/lib/data.o"
include "$(BUILD_DIR)/src/audio/lib/synthesis.o" include "$(BUILD_DIR)/src/audio/lib/synthesis.o"
@ -445,7 +471,9 @@ beginseg
include "$(BUILD_DIR)/src/code/gfxprint.o" include "$(BUILD_DIR)/src/code/gfxprint.o"
include "$(BUILD_DIR)/src/code/rcp_utils.o" include "$(BUILD_DIR)/src/code/rcp_utils.o"
include "$(BUILD_DIR)/src/code/loadfragment2.o" include "$(BUILD_DIR)/src/code/loadfragment2.o"
#if OOT_DEBUG
include "$(BUILD_DIR)/src/code/mtxuty-cvt.o" include "$(BUILD_DIR)/src/code/mtxuty-cvt.o"
#endif
include "$(BUILD_DIR)/src/code/relocation.o" include "$(BUILD_DIR)/src/code/relocation.o"
include "$(BUILD_DIR)/src/code/load.o" include "$(BUILD_DIR)/src/code/load.o"
include "$(BUILD_DIR)/src/code/code_800FC620.o" include "$(BUILD_DIR)/src/code/code_800FC620.o"
@ -454,13 +482,18 @@ beginseg
include "$(BUILD_DIR)/src/code/code_800FCE80.o" include "$(BUILD_DIR)/src/code/code_800FCE80.o"
include "$(BUILD_DIR)/src/code/fp.o" include "$(BUILD_DIR)/src/code/fp.o"
include "$(BUILD_DIR)/src/code/system_malloc.o" include "$(BUILD_DIR)/src/code/system_malloc.o"
include "$(BUILD_DIR)/src/code/code_800FD970.o" include "$(BUILD_DIR)/src/code/rand.o"
include "$(BUILD_DIR)/src/code/__osMalloc.o" include "$(BUILD_DIR)/src/code/__osMalloc.o"
#if !OOT_DEBUG
include "$(BUILD_DIR)/src/libultra/libc/sprintf.o"
#endif
include "$(BUILD_DIR)/src/code/printutils.o" include "$(BUILD_DIR)/src/code/printutils.o"
include "$(BUILD_DIR)/src/code/sleep.o" include "$(BUILD_DIR)/src/code/sleep.o"
include "$(BUILD_DIR)/src/code/jpegutils.o" include "$(BUILD_DIR)/src/code/jpegutils.o"
include "$(BUILD_DIR)/src/code/jpegdecoder.o" include "$(BUILD_DIR)/src/code/jpegdecoder.o"
#if OOT_DEBUG
include "$(BUILD_DIR)/src/libultra/io/pfsfreeblocks.o" include "$(BUILD_DIR)/src/libultra/io/pfsfreeblocks.o"
#endif
include "$(BUILD_DIR)/src/libultra/mgu/scale.o" include "$(BUILD_DIR)/src/libultra/mgu/scale.o"
include "$(BUILD_DIR)/src/libultra/gu/sinf.o" include "$(BUILD_DIR)/src/libultra/gu/sinf.o"
include "$(BUILD_DIR)/src/libultra/gu/sins.o" include "$(BUILD_DIR)/src/libultra/gu/sins.o"
@ -473,19 +506,29 @@ beginseg
include "$(BUILD_DIR)/src/libultra/io/sprawdma.o" include "$(BUILD_DIR)/src/libultra/io/sprawdma.o"
include "$(BUILD_DIR)/src/libultra/io/sirawdma.o" include "$(BUILD_DIR)/src/libultra/io/sirawdma.o"
include "$(BUILD_DIR)/src/libultra/io/sptaskyield.o" include "$(BUILD_DIR)/src/libultra/io/sptaskyield.o"
#if OOT_DEBUG
include "$(BUILD_DIR)/src/libultra/io/pfsreadwritefile.o" include "$(BUILD_DIR)/src/libultra/io/pfsreadwritefile.o"
include "$(BUILD_DIR)/src/libultra/io/pfsgetstatus.o" include "$(BUILD_DIR)/src/libultra/io/pfsgetstatus.o"
#endif
include "$(BUILD_DIR)/src/libultra/mgu/mtxidentf.o" include "$(BUILD_DIR)/src/libultra/mgu/mtxidentf.o"
include "$(BUILD_DIR)/src/libultra/gu/lookat.o" include "$(BUILD_DIR)/src/libultra/gu/lookat.o"
#if OOT_DEBUG
include "$(BUILD_DIR)/src/libultra/io/pfsallocatefile.o" include "$(BUILD_DIR)/src/libultra/io/pfsallocatefile.o"
#endif
include "$(BUILD_DIR)/src/libultra/os/stoptimer.o" include "$(BUILD_DIR)/src/libultra/os/stoptimer.o"
#if OOT_DEBUG
include "$(BUILD_DIR)/src/libultra/io/contpfs.o" include "$(BUILD_DIR)/src/libultra/io/contpfs.o"
include "$(BUILD_DIR)/src/libultra/mgu/mtxl2f.o" include "$(BUILD_DIR)/src/libultra/mgu/mtxl2f.o"
include "$(BUILD_DIR)/src/libultra/io/pfsfindfile.o" include "$(BUILD_DIR)/src/libultra/io/pfsfindfile.o"
#endif
include "$(BUILD_DIR)/src/libultra/gu/sqrtf.o" include "$(BUILD_DIR)/src/libultra/gu/sqrtf.o"
include "$(BUILD_DIR)/src/libultra/os/afterprenmi.o" include "$(BUILD_DIR)/src/libultra/os/afterprenmi.o"
include "$(BUILD_DIR)/src/libultra/io/contquery.o" include "$(BUILD_DIR)/src/libultra/io/contquery.o"
include "$(BUILD_DIR)/src/libultra/gu/lookathil.o" include "$(BUILD_DIR)/src/libultra/gu/lookathil.o"
#if !OOT_DEBUG
include "$(BUILD_DIR)/src/libultra/libc/xprintf.o"
include "$(BUILD_DIR)/src/libultra/libc/string.o"
#endif
include "$(BUILD_DIR)/src/libultra/io/sp.o" include "$(BUILD_DIR)/src/libultra/io/sp.o"
include "$(BUILD_DIR)/src/libultra/mgu/mtxident.o" include "$(BUILD_DIR)/src/libultra/mgu/mtxident.o"
include "$(BUILD_DIR)/src/libultra/gu/position.o" include "$(BUILD_DIR)/src/libultra/gu/position.o"
@ -496,25 +539,44 @@ beginseg
include "$(BUILD_DIR)/src/libultra/mgu/normalize.o" include "$(BUILD_DIR)/src/libultra/mgu/normalize.o"
include "$(BUILD_DIR)/src/libultra/io/dpgetstat.o" include "$(BUILD_DIR)/src/libultra/io/dpgetstat.o"
include "$(BUILD_DIR)/src/libultra/io/dpsetstat.o" include "$(BUILD_DIR)/src/libultra/io/dpsetstat.o"
#if OOT_DEBUG
include "$(BUILD_DIR)/src/libultra/io/pfsdeletefile.o" include "$(BUILD_DIR)/src/libultra/io/pfsdeletefile.o"
#endif
include "$(BUILD_DIR)/src/libultra/gu/ortho.o" include "$(BUILD_DIR)/src/libultra/gu/ortho.o"
include "$(BUILD_DIR)/src/libultra/gu/cosf.o" include "$(BUILD_DIR)/src/libultra/gu/cosf.o"
include "$(BUILD_DIR)/src/libultra/gu/libm_vals.o" include "$(BUILD_DIR)/src/libultra/gu/libm_vals.o"
include "$(BUILD_DIR)/src/libultra/gu/coss.o" include "$(BUILD_DIR)/src/libultra/gu/coss.o"
include "$(BUILD_DIR)/src/libultra/io/visetevent.o" include "$(BUILD_DIR)/src/libultra/io/visetevent.o"
#if OOT_DEBUG
include "$(BUILD_DIR)/src/libultra/io/pfsisplug.o" include "$(BUILD_DIR)/src/libultra/io/pfsisplug.o"
#endif
include "$(BUILD_DIR)/src/libultra/gu/us2dex.o" include "$(BUILD_DIR)/src/libultra/gu/us2dex.o"
include "$(BUILD_DIR)/src/libultra/io/pfsselectbank.o" include "$(BUILD_DIR)/src/libultra/io/pfsselectbank.o"
include "$(BUILD_DIR)/src/libultra/io/contsetch.o" include "$(BUILD_DIR)/src/libultra/io/contsetch.o"
#if OOT_DEBUG
include "$(BUILD_DIR)/src/libultra/io/pfsfilestate.o" include "$(BUILD_DIR)/src/libultra/io/pfsfilestate.o"
include "$(BUILD_DIR)/src/libultra/io/pfsinitpak.o" include "$(BUILD_DIR)/src/libultra/io/pfsinitpak.o"
include "$(BUILD_DIR)/src/libultra/io/pfschecker.o" include "$(BUILD_DIR)/src/libultra/io/pfschecker.o"
#endif
include "$(BUILD_DIR)/src/libultra/io/aigetlen.o" include "$(BUILD_DIR)/src/libultra/io/aigetlen.o"
include "$(BUILD_DIR)/src/libultra/mgu/translate.o" include "$(BUILD_DIR)/src/libultra/mgu/translate.o"
include "$(BUILD_DIR)/src/libultra/io/contramwrite.o" include "$(BUILD_DIR)/src/libultra/io/contramwrite.o"
#if !OOT_DEBUG
include "$(BUILD_DIR)/src/libultra/io/vimodefpallan1.o"
include "$(BUILD_DIR)/src/libultra/io/pfsgetstatus.o"
include "$(BUILD_DIR)/src/libultra/io/contpfs.o"
#endif
include "$(BUILD_DIR)/src/libultra/io/contramread.o" include "$(BUILD_DIR)/src/libultra/io/contramread.o"
include "$(BUILD_DIR)/src/libultra/io/crc.o" include "$(BUILD_DIR)/src/libultra/io/crc.o"
#if !OOT_DEBUG
include "$(BUILD_DIR)/src/libultra/io/pfsisplug.o"
#endif
include "$(BUILD_DIR)/src/libultra/os/settimer.o" include "$(BUILD_DIR)/src/libultra/os/settimer.o"
#if !OOT_DEBUG
include "$(BUILD_DIR)/src/libultra/libc/xldtob.o"
include "$(BUILD_DIR)/src/libultra/libc/ldiv.o"
include "$(BUILD_DIR)/src/libultra/libc/xlitob.o"
#endif
include "$(BUILD_DIR)/src/libultra/io/spgetstat.o" include "$(BUILD_DIR)/src/libultra/io/spgetstat.o"
include "$(BUILD_DIR)/src/libultra/io/spsetstat.o" include "$(BUILD_DIR)/src/libultra/io/spsetstat.o"
include "$(BUILD_DIR)/src/libultra/os/writebackdcacheall.o" include "$(BUILD_DIR)/src/libultra/os/writebackdcacheall.o"
@ -542,7 +604,7 @@ beginseg
align 0x40 align 0x40
include "$(BUILD_DIR)/src/buffers/zbuffer.o" include "$(BUILD_DIR)/src/buffers/zbuffer.o"
include "$(BUILD_DIR)/src/buffers/gfxbuffers.o" include "$(BUILD_DIR)/src/buffers/gfxbuffers.o"
include "$(BUILD_DIR)/src/buffers/heaps.o" include "$(BUILD_DIR)/src/buffers/audio_heap.o"
endseg endseg
beginseg beginseg
@ -2911,7 +2973,7 @@ beginseg
name "ovl_En_Mb" name "ovl_En_Mb"
compress compress
include "$(BUILD_DIR)/src/overlays/actors/ovl_En_Mb/z_en_mb.o" include "$(BUILD_DIR)/src/overlays/actors/ovl_En_Mb/z_en_mb.o"
include "$(BUILD_DIR)/src/overlays/actors/ovl_En_Mb/ovl_En_Mb_reloc.o" include "$(BUILD_DIR)/src/overlays/actors/ovl_En_Mb/ovl_En_Mb_reloc.o"
endseg endseg
beginseg beginseg

View file

@ -44,18 +44,20 @@ s8 gSfxDefaultReverb = 0;
s32 D_801333EC = 0; // unused s32 D_801333EC = 0; // unused
#if OOT_DEBUG
u8 D_801333F0 = 0; u8 D_801333F0 = 0;
u8 gAudioSfxSwapOff = 0; u8 gAudioSfxSwapOff = 0;
u8 D_801333F8 = 0; u8 D_801333F8 = 0;
s32 D_801333FC = 0; // unused s32 D_801333FC = 0; // unused
#endif
u8 gSeqCmdWritePos = 0; u8 gSeqCmdWritePos = 0;
u8 gSeqCmdReadPos = 0; u8 gSeqCmdReadPos = 0;
u8 gStartSeqDisabled = false; u8 gStartSeqDisabled = false;
#if OOT_DEBUG
u8 gAudioDebugPrintSeqCmd = true; u8 gAudioDebugPrintSeqCmd = true;
#endif
u8 gSoundModeList[] = { u8 gSoundModeList[] = {
SOUNDMODE_STEREO, SOUNDMODE_STEREO,

View file

@ -1212,8 +1212,10 @@ OcarinaSongButtons gOcarinaSongButtons[OCARINA_SONG_MAX] = {
{ 0, { 0 } }, { 0, { 0 } },
}; };
#if OOT_DEBUG
u32 sAudioUpdateStartTime; u32 sAudioUpdateStartTime;
u32 sAudioUpdateEndTime; u32 sAudioUpdateEndTime;
#endif
f32 D_8016B7A8; f32 D_8016B7A8;
f32 D_8016B7AC; f32 D_8016B7AC;
f32 D_8016B7B0; f32 D_8016B7B0;
@ -1223,20 +1225,26 @@ FreqLerp sWaterfallFreqScaleLerp;
f32 D_8016B7D8; f32 D_8016B7D8;
s8 D_8016B7DC; s8 D_8016B7DC;
f32 D_8016B7E0; f32 D_8016B7E0;
#if OOT_DEBUG
u16 D_8016B7E4; u16 D_8016B7E4;
struct { struct {
char str[5]; char str[5];
u16 num; u16 num;
} sAudioScrPrtBuf[SCROLL_PRINT_BUF_SIZE]; } sAudioScrPrtBuf[SCROLL_PRINT_BUF_SIZE];
#endif
u8 sRiverSoundMainBgmVol; u8 sRiverSoundMainBgmVol;
u8 sRiverSoundMainBgmCurrentVol; u8 sRiverSoundMainBgmCurrentVol;
u8 sRiverSoundMainBgmLower; u8 sRiverSoundMainBgmLower;
u8 sRiverSoundMainBgmRestore; u8 sRiverSoundMainBgmRestore;
u8 sGanonsTowerVol; u8 sGanonsTowerVol;
SfxPlayerState sSfxChannelState[0x10]; SfxPlayerState sSfxChannelState[0x10];
#if OOT_DEBUG
char sBinToStrBuf[0x20]; char sBinToStrBuf[0x20];
#endif
u8 sMalonSingingTimer; u8 sMalonSingingTimer;
#if OOT_DEBUG
u8 sAudioSpecPeakNumNotes[0x12]; u8 sAudioSpecPeakNumNotes[0x12];
#endif
u8 sMalonSingingDisabled; u8 sMalonSingingDisabled;
u8 D_8016B9F3; u8 D_8016B9F3;
u8 sFanfareStartTimer; u8 sFanfareStartTimer;
@ -1264,8 +1272,10 @@ u16 sMusicStaffCurHeldLength[OCARINA_SONG_MAX];
u16 sMusicStaffExpectedLength[OCARINA_SONG_MAX]; u16 sMusicStaffExpectedLength[OCARINA_SONG_MAX];
u8 sMusicStaffExpectedPitch[OCARINA_SONG_MAX]; u8 sMusicStaffExpectedPitch[OCARINA_SONG_MAX];
OcarinaNote sScarecrowsLongSongSecondNote; OcarinaNote sScarecrowsLongSongSecondNote;
#if OOT_DEBUG
u8 sIsMalonSinging; u8 sIsMalonSinging;
f32 sMalonSingingDist; f32 sMalonSingingDist;
#endif
void PadMgr_RequestPadData(PadMgr* padMgr, Input* inputs, s32 gameRequest); void PadMgr_RequestPadData(PadMgr* padMgr, Input* inputs, s32 gameRequest);

View file

@ -1,7 +1,7 @@
#include "global.h" #include "global.h"
// clang-format off // clang-format off
s16 gSawtoothWaveSample[] = { ALIGNED(16) s16 gSawtoothWaveSample[] = {
// Frequency of 1 // Frequency of 1
0, 1023, 2047, 3071, 4095, 5119, 6143, 7167, 0, 1023, 2047, 3071, 4095, 5119, 6143, 7167,
8191, 9215, 10239, 11263, 12287, 13311, 14335, 15359, 8191, 9215, 10239, 11263, 12287, 13311, 14335, 15359,
@ -43,7 +43,7 @@ s16 gSawtoothWaveSample[] = {
0, 8191, 16383, 24575, -32767, -24575, -16383, -8191, 0, 8191, 16383, 24575, -32767, -24575, -16383, -8191,
}; };
s16 gTriangleWaveSample[] = { ALIGNED(16) s16 gTriangleWaveSample[] = {
// Frequency of 1 // Frequency of 1
0, 2047, 4095, 6143, 8191, 10239, 12287, 14335, 0, 2047, 4095, 6143, 8191, 10239, 12287, 14335,
16383, 18431, 20479, 22527, 24575, 26623, 28671, 30719, 16383, 18431, 20479, 22527, 24575, 26623, 28671, 30719,
@ -85,7 +85,7 @@ s16 gTriangleWaveSample[] = {
0, 16383, 32767, 16383, 0, -16383, -32767, -16383, 0, 16383, 32767, 16383, 0, -16383, -32767, -16383,
}; };
s16 gSineWaveSample[] = { ALIGNED(16) s16 gSineWaveSample[] = {
// Frequency of 1 // Frequency of 1
0, 3211, 6392, 9511, 12539, 15446, 18204, 20787, 0, 3211, 6392, 9511, 12539, 15446, 18204, 20787,
23169, 25329, 27244, 28897, 30272, 31356, 32137, 32609, 23169, 25329, 27244, 28897, 30272, 31356, 32137, 32609,
@ -127,7 +127,7 @@ s16 gSineWaveSample[] = {
0, 23169, 32767, 23169, 0, -23169, -32767, -23169, 0, 23169, 32767, 23169, 0, -23169, -32767, -23169,
}; };
s16 gSquareWaveSample[] = { ALIGNED(16) s16 gSquareWaveSample[] = {
// Frequency of 1 // Frequency of 1
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@ -169,7 +169,7 @@ s16 gSquareWaveSample[] = {
0, 0, 32767, 32767, 0, 0, -32767, -32767, 0, 0, 32767, 32767, 0, 0, -32767, -32767,
}; };
s16 gWhiteNoiseSample[] = { ALIGNED(16) s16 gWhiteNoiseSample[] = {
// Frequency of 1 // Frequency of 1
0, -25689, -25791, 27803, -27568, -21030, 22174, 6298, 0, -25689, -25791, 27803, -27568, -21030, 22174, 6298,
27071, -18531, 28649, 2284, 3380, 6890, -12682, -21114, 27071, -18531, 28649, 2284, 3380, 6890, -12682, -21114,
@ -212,7 +212,7 @@ s16 gWhiteNoiseSample[] = {
}; };
// Sine White Noise? // Sine White Noise?
s16 D_8012EA90[] = { ALIGNED(16) s16 D_8012EA90[] = {
// Frequency of 1 // Frequency of 1
0, 16316, 20148, 20257, 27209, -32657, 29264, 27259, 0, 16316, 20148, 20257, 27209, -32657, 29264, 27259,
-29394, -21494, -26410, 30770, 30033, 29130, 20206, 14129, -29394, -21494, -26410, 30770, 30033, 29130, 20206, 14129,
@ -255,7 +255,7 @@ s16 D_8012EA90[] = {
}; };
// Pulse Wave (duty cycle = 12.5%) // Pulse Wave (duty cycle = 12.5%)
s16 gEighthPulseWaveSample[] = { ALIGNED(16) s16 gEighthPulseWaveSample[] = {
// Frequency of 1 // Frequency of 1
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@ -298,7 +298,7 @@ s16 gEighthPulseWaveSample[] = {
}; };
// Pulse Wave (duty cycle = 25%) // Pulse Wave (duty cycle = 25%)
s16 gQuarterPulseWaveSample[] = { ALIGNED(16) s16 gQuarterPulseWaveSample[] = {
// Frequency of 1 // Frequency of 1
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@ -686,7 +686,7 @@ f32 gDefaultPanVolume[] = {
0.086471f, 0.074143f, 0.061803f, 0.049454f, 0.037097f, 0.024734f, 0.012368f, 0.0f, 0.086471f, 0.074143f, 0.061803f, 0.049454f, 0.037097f, 0.024734f, 0.012368f, 0.0f,
}; };
s16 gLowPassFilterData[16 * 8] = { ALIGNED(16) s16 gLowPassFilterData[16 * 8] = {
/* 0x0 */ 0, 0, 0, 32767, 0, 0, 0, 0, // Identity filter (delta function) /* 0x0 */ 0, 0, 0, 32767, 0, 0, 0, 0, // Identity filter (delta function)
/* 0x1 */ 3854, 4188, 4398, 4469, 4398, 4188, 3854, 3416, /* 0x1 */ 3854, 4188, 4398, 4469, 4398, 4188, 3854, 3416,
/* 0x2 */ 3415, 4314, 4915, 5126, 4915, 4314, 3415, 2351, /* 0x2 */ 3415, 4314, 4915, 5126, 4915, 4314, 3415, 2351,
@ -705,7 +705,7 @@ s16 gLowPassFilterData[16 * 8] = {
/* 0xF */ 841, -853, 863, 26829, 863, -853, 841, -820, /* 0xF */ 841, -853, 863, 26829, 863, -853, 841, -820,
}; };
s16 gHighPassFilterData[15 * 8] = { ALIGNED(16) s16 gHighPassFilterData[15 * 8] = {
/* 0x0 */ -289, -291, -289, 30736, -289, -291, -289, -290, /* 0x0 */ -289, -291, -289, 30736, -289, -291, -289, -290,
/* 0x1 */ -464, -467, -467, 29506, -467, -467, -464, -463, /* 0x1 */ -464, -467, -467, 29506, -467, -467, -464, -463,
/* 0x2 */ -662, -670, -672, 28101, -672, -670, -662, -656, /* 0x2 */ -662, -670, -672, 28101, -672, -670, -662, -656,
@ -723,7 +723,7 @@ s16 gHighPassFilterData[15 * 8] = {
/* 0xE */ -772, -3, -6985, 17240, -6985, -3, -772, -3, /* 0xE */ -772, -3, -6985, 17240, -6985, -3, -772, -3,
}; };
s16 D_80130418[8 * 8] = { ALIGNED(16) s16 D_80130418[8 * 8] = {
/* 0x0 */ 0, 6392, 12539, 18204, 23169, 27244, 30272, 32137, /* 0x0 */ 0, 6392, 12539, 18204, 23169, 27244, 30272, 32137,
/* 0x1 */ 32767, 32137, 30272, 27244, 23169, 18204, 12539, 6392, /* 0x1 */ 32767, 32137, 30272, 27244, 23169, 18204, 12539, 6392,
/* 0x2 */ 0, -3211, -6392, -9511, -12539, -15446, -18204, -20787, /* 0x2 */ 0, -3211, -6392, -9511, -12539, -15446, -18204, -20787,

View file

@ -1133,9 +1133,19 @@ void AudioLoad_Init(void* heap, u32 heapSize) {
s32 i; s32 i;
u8* audioContextPtr = (u8*)&gAudioCtx; u8* audioContextPtr = (u8*)&gAudioCtx;
#ifndef AVOID_UB
//! @bug This clearing loop sets one extra byte to 0 following gAudioCtx.
//! In practice this is harmless as it would set the most significant byte in gAudioCustomUpdateFunction to 0,
//! which was just reset to NULL above.
for (i = sizeof(gAudioCtx); i >= 0; i--) { for (i = sizeof(gAudioCtx); i >= 0; i--) {
*audioContextPtr++ = 0; *audioContextPtr++ = 0;
} }
#else
// Avoid out-of-bounds variable access
for (i = sizeof(gAudioCtx); i > 0; i--) {
*audioContextPtr++ = 0;
}
#endif
} }
// 1000 is a conversion from seconds to milliseconds // 1000 is a conversion from seconds to milliseconds

View file

@ -33,9 +33,12 @@ ActiveSfx gActiveSfx[7][3];
u8 sCurSfxPlayerChannelIndex; u8 sCurSfxPlayerChannelIndex;
u8 gSfxBankMuted[7]; u8 gSfxBankMuted[7];
UnusedBankLerp sUnusedBankLerp[7]; UnusedBankLerp sUnusedBankLerp[7];
#if OOT_DEBUG
u16 gAudioSfxSwapSource[10]; u16 gAudioSfxSwapSource[10];
u16 gAudioSfxSwapTarget[10]; u16 gAudioSfxSwapTarget[10];
u8 gAudioSfxSwapMode[10]; u8 gAudioSfxSwapMode[10];
#endif
void Audio_SetSfxBanksMute(u16 muteMask) { void Audio_SetSfxBanksMute(u16 muteMask) {
u8 bankId; u8 bankId;

View file

@ -46,7 +46,8 @@ void Idle_ThreadEntry(void* arg) {
PRINTF("ダイナミックバッファのサイズは %d キロバイトです\n", 0x92); PRINTF("ダイナミックバッファのサイズは %d キロバイトです\n", 0x92);
PRINTF("FIFOバッファのサイズは %d キロバイトです\n", 0x60); PRINTF("FIFOバッファのサイズは %d キロバイトです\n", 0x60);
PRINTF("YIELDバッファのサイズは %d キロバイトです\n", 3); PRINTF("YIELDバッファのサイズは %d キロバイトです\n", 3);
PRINTF("オーディオヒープのサイズは %d キロバイトです\n", ((intptr_t)gSystemHeap - (intptr_t)gAudioHeap) / 1024); PRINTF("オーディオヒープのサイズは %d キロバイトです\n",
((intptr_t)&gAudioHeap[ARRAY_COUNT(gAudioHeap)] - (intptr_t)gAudioHeap) / 1024);
PRINTF(VT_RST); PRINTF(VT_RST);
osCreateViManager(OS_PRIORITY_VIMGR); osCreateViManager(OS_PRIORITY_VIMGR);

View file

@ -1,11 +1,11 @@
#include "global.h" #include "global.h"
OSPiHandle* sISVHandle; // official name : is_Handle
#define gISVDbgPrnAdrs ((ISVDbg*)0xB3FF0000) #define gISVDbgPrnAdrs ((ISVDbg*)0xB3FF0000)
#define ASCII_TO_U32(a, b, c, d) ((u32)((a << 24) | (b << 16) | (c << 8) | (d << 0))) #define ASCII_TO_U32(a, b, c, d) ((u32)((a << 24) | (b << 16) | (c << 8) | (d << 0)))
#if OOT_DEBUG #if OOT_DEBUG
OSPiHandle* sISVHandle; // official name : is_Handle
void isPrintfInit(void) { void isPrintfInit(void) {
sISVHandle = osCartRomInit(); sISVHandle = osCartRomInit();
osEPiWriteIo(sISVHandle, (u32)&gISVDbgPrnAdrs->put, 0); osEPiWriteIo(sISVHandle, (u32)&gISVDbgPrnAdrs->put, 0);
@ -95,7 +95,7 @@ void* is_proutSyncPrintf(void* arg, const char* str, size_t count) {
return (void*)1; return (void*)1;
} }
NORETURN void func_80002384(const char* exp, const char* file, u32 line) { NORETURN void func_80002384(const char* exp, const char* file, int line) {
osSyncPrintf("File:%s Line:%d %s \n", file, line, exp); osSyncPrintf("File:%s Line:%d %s \n", file, line, exp);
while (true) { while (true) {
; ;

View file

@ -2,7 +2,7 @@
#include "terminal.h" #include "terminal.h"
#if OOT_DEBUG #if OOT_DEBUG
f32 LogUtils_CheckFloatRange(const char* exp, s32 line, const char* valueName, f32 value, const char* minName, f32 min, f32 LogUtils_CheckFloatRange(const char* exp, int line, const char* valueName, f32 value, const char* minName, f32 min,
const char* maxName, f32 max) { const char* maxName, f32 max) {
if (value < min || max < value) { if (value < min || max < value) {
PRINTF("%s %d: range error %s(%f) < %s(%f) < %s(%f)\n", exp, line, minName, min, valueName, value, maxName, PRINTF("%s %d: range error %s(%f) < %s(%f) < %s(%f)\n", exp, line, minName, min, valueName, value, maxName,
@ -11,7 +11,7 @@ f32 LogUtils_CheckFloatRange(const char* exp, s32 line, const char* valueName, f
return value; return value;
} }
s32 LogUtils_CheckIntRange(const char* exp, s32 line, const char* valueName, s32 value, const char* minName, s32 min, s32 LogUtils_CheckIntRange(const char* exp, int line, const char* valueName, s32 value, const char* minName, s32 min,
const char* maxName, s32 max) { const char* maxName, s32 max) {
if (value < min || max < value) { if (value < min || max < value) {
PRINTF("%s %d: range error %s(%d) < %s(%d) < %s(%d)\n", exp, line, minName, min, valueName, value, maxName, PRINTF("%s %d: range error %s(%d) < %s(%d) < %s(%d)\n", exp, line, minName, min, valueName, value, maxName,
@ -73,11 +73,11 @@ void LogUtils_LogHexDump(void* ptr, s32 size0) {
} }
} }
void LogUtils_LogPointer(s32 value, u32 max, void* ptr, const char* name, const char* file, s32 line) { void LogUtils_LogPointer(s32 value, u32 max, void* ptr, const char* name, const char* file, int line) {
PRINTF(VT_COL(RED, WHITE) "%s %d %s[%d] max=%u ptr=%08x\n" VT_RST, file, line, name, value, max, ptr); PRINTF(VT_COL(RED, WHITE) "%s %d %s[%d] max=%u ptr=%08x\n" VT_RST, file, line, name, value, max, ptr);
} }
void LogUtils_CheckBoundary(const char* name, s32 value, s32 unk, const char* file, s32 line) { void LogUtils_CheckBoundary(const char* name, s32 value, s32 unk, const char* file, int line) {
u32 mask = (unk - 1); u32 mask = (unk - 1);
if (value & mask) { if (value & mask) {
@ -85,24 +85,24 @@ void LogUtils_CheckBoundary(const char* name, s32 value, s32 unk, const char* fi
} }
} }
void LogUtils_CheckNullPointer(const char* exp, void* ptr, const char* file, s32 line) { void LogUtils_CheckNullPointer(const char* exp, void* ptr, const char* file, int line) {
if (ptr == NULL) { if (ptr == NULL) {
PRINTF(VT_COL(RED, WHITE) "%s %d:%s は はヌルポインタです\n" VT_RST, file, line, exp); PRINTF(VT_COL(RED, WHITE) "%s %d:%s は はヌルポインタです\n" VT_RST, file, line, exp);
} }
} }
void LogUtils_CheckValidPointer(const char* exp, void* ptr, const char* file, s32 line) { void LogUtils_CheckValidPointer(const char* exp, void* ptr, const char* file, int line) {
if (ptr == NULL || (u32)ptr < 0x80000000 || (0x80000000 + osMemSize) <= (u32)ptr) { if (ptr == NULL || (u32)ptr < 0x80000000 || (0x80000000 + osMemSize) <= (u32)ptr) {
PRINTF(VT_COL(RED, WHITE) "%s %d:ポインタ %s(%08x) が異常です\n" VT_RST, file, line, exp, ptr); PRINTF(VT_COL(RED, WHITE) "%s %d:ポインタ %s(%08x) が異常です\n" VT_RST, file, line, exp, ptr);
} }
} }
void LogUtils_LogThreadId(const char* name, s32 line) { void LogUtils_LogThreadId(const char* name, int line) {
PRINTF("<%d %s %d>", osGetThreadId(NULL), name, line); PRINTF("<%d %s %d>", osGetThreadId(NULL), name, line);
} }
#endif #endif
void LogUtils_HungupThread(const char* name, s32 line) { void LogUtils_HungupThread(const char* name, int line) {
OSId threadId = osGetThreadId(NULL); OSId threadId = osGetThreadId(NULL);
PRINTF("*** HungUp in thread %d, [%s:%d] ***\n", threadId, name, line); PRINTF("*** HungUp in thread %d, [%s:%d] ***\n", threadId, name, line);

View file

@ -98,6 +98,11 @@ u32 StackCheck_GetState(StackEntry* entry) {
ret = STACK_STATUS_OK; ret = STACK_STATUS_OK;
} }
#if !OOT_DEBUG
// This string is still in .rodata for retail builds
(void)"(null)";
#endif
PRINTF("head=%08x tail=%08x last=%08x used=%08x free=%08x [%s]\n", entry->head, entry->tail, last, used, free, PRINTF("head=%08x tail=%08x last=%08x used=%08x free=%08x [%s]\n", entry->head, entry->tail, last, used, free,
entry->name != NULL ? entry->name : "(null)"); entry->name != NULL ? entry->name : "(null)");
PRINTF(VT_RST); PRINTF(VT_RST);

View file

@ -1,6 +1,6 @@
#include "global.h" #include "global.h"
u8 sYaz0DataBuffer[0x400]; ALIGNED(16) u8 sYaz0DataBuffer[0x400];
u8* sYaz0DataBufferEnd; u8* sYaz0DataBufferEnd;
uintptr_t sYaz0CurRomStart; uintptr_t sYaz0CurRomStart;
size_t sYaz0CurSize; size_t sYaz0CurSize;

View file

@ -598,7 +598,7 @@ void DmaMgr_Init(void) {
* @see DmaMgr_RequestAsync * @see DmaMgr_RequestAsync
*/ */
s32 DmaMgr_RequestAsyncDebug(DmaRequest* req, void* ram, uintptr_t vrom, size_t size, u32 unk5, OSMesgQueue* queue, s32 DmaMgr_RequestAsyncDebug(DmaRequest* req, void* ram, uintptr_t vrom, size_t size, u32 unk5, OSMesgQueue* queue,
OSMesg msg, const char* file, s32 line) { OSMesg msg, const char* file, int line) {
req->filename = file; req->filename = file;
req->line = line; req->line = line;
return DmaMgr_RequestAsync(req, ram, vrom, size, unk5, queue, msg); return DmaMgr_RequestAsync(req, ram, vrom, size, unk5, queue, msg);
@ -609,7 +609,7 @@ s32 DmaMgr_RequestAsyncDebug(DmaRequest* req, void* ram, uintptr_t vrom, size_t
* *
* @see DmaMgr_RequestSync * @see DmaMgr_RequestSync
*/ */
s32 DmaMgr_RequestSyncDebug(void* ram, uintptr_t vrom, size_t size, const char* file, s32 line) { s32 DmaMgr_RequestSyncDebug(void* ram, uintptr_t vrom, size_t size, const char* file, int line) {
DmaRequest req; DmaRequest req;
s32 ret; s32 ret;
OSMesgQueue queue; OSMesgQueue queue;

3
src/buffers/audio_heap.c Normal file
View file

@ -0,0 +1,3 @@
#include "z64.h"
ALIGNED(16) u8 gAudioHeap[0x38000];

View file

@ -1,13 +1,9 @@
#include "z64.h" #include "z64.h"
// 0x18000 bytes ALIGNED(16) u64 gGfxSPTaskOutputBuffer[0x3000];
u64 gGfxSPTaskOutputBuffer[0x3000];
// 0xC00 bytes ALIGNED(16) u64 gGfxSPTaskYieldBuffer[OS_YIELD_DATA_SIZE / sizeof(u64)];
u64 gGfxSPTaskYieldBuffer[OS_YIELD_DATA_SIZE / sizeof(u64)];
// 0x400 bytes ALIGNED(16) u64 gGfxSPTaskStack[SP_DRAM_STACK_SIZE64];
u64 gGfxSPTaskStack[SP_DRAM_STACK_SIZE64];
// 0x12410 bytes each; 0x24820 bytes total ALIGNED(16) GfxPool gGfxPools[2];
GfxPool gGfxPools[2];

View file

@ -1,6 +0,0 @@
#include "z64.h"
// 0x38000 bytes
u8 gAudioHeap[0x38000];
u8 gSystemHeap[UNK_SIZE];

View file

@ -1,4 +1,3 @@
#include "z64.h" #include "z64.h"
// 0x25800 bytes ALIGNED(64) u16 gZBuffer[SCREEN_HEIGHT][SCREEN_WIDTH];
u16 gZBuffer[SCREEN_HEIGHT][SCREEN_WIDTH];

View file

@ -681,6 +681,14 @@ void PreRender_AntiAliasFilter(PreRender* this, s32 x, s32 y) {
(((a2) >= (a1)) ? (((a3) >= (a2)) ? (a2) : (((a1) >= (a3)) ? (a1) : (a3))) \ (((a2) >= (a1)) ? (((a3) >= (a2)) ? (a2) : (((a1) >= (a3)) ? (a1) : (a3))) \
: (((a2) >= (a3)) ? (a2) : (((a3) >= (a1)) ? (a1) : (a3)))) : (((a2) >= (a3)) ? (a2) : (((a3) >= (a1)) ? (a1) : (a3))))
#if OOT_DEBUG
#define R_HREG_MODE_DEBUG R_HREG_MODE
#else
#define R_HREG_MODE_DEBUG ((void)0, 0)
#endif
#define PRERENDER_DIVOT_CONTROL (R_HREG_MODE_DEBUG == HREG_MODE_PRERENDER ? R_PRERENDER_DIVOT_CONTROL : 0)
/** /**
* Applies the Video Interface divot filter to an image. * Applies the Video Interface divot filter to an image.
* *
@ -696,7 +704,7 @@ void PreRender_AntiAliasFilter(PreRender* this, s32 x, s32 y) {
void PreRender_DivotFilter(PreRender* this) { void PreRender_DivotFilter(PreRender* this) {
s32 x; s32 x;
s32 y; s32 y;
s32 pad1; s32 cvg;
u8* buffR = alloca(this->width); u8* buffR = alloca(this->width);
u8* buffG = alloca(this->width); u8* buffG = alloca(this->width);
u8* buffB = alloca(this->width); u8* buffB = alloca(this->width);
@ -704,14 +712,14 @@ void PreRender_DivotFilter(PreRender* this) {
s32 pxR; s32 pxR;
s32 pxG; s32 pxG;
s32 pxB; s32 pxB;
Color_RGBA16 pxIn;
Color_RGBA16 pxOut;
for (y = 0; y < this->height; y++) { for (y = 0; y < this->height; y++) {
// The divot filter is applied row-by-row as it only needs to use pixels that are horizontally adjacent // The divot filter is applied row-by-row as it only needs to use pixels that are horizontally adjacent
// Decompose each pixel into color channels // Decompose each pixel into color channels
for (x = 0; x < this->width; x++) { for (x = 0; x < this->width; x++) {
Color_RGBA16 pxIn;
pxIn.rgba = this->fbufSave[x + y * this->width]; pxIn.rgba = this->fbufSave[x + y * this->width];
buffR[x] = pxIn.r; buffR[x] = pxIn.r;
buffG[x] = pxIn.g; buffG[x] = pxIn.g;
@ -721,8 +729,7 @@ void PreRender_DivotFilter(PreRender* this) {
// Apply the divot filter itself. For pixels with partial coverage, the filter selects the median value from a // Apply the divot filter itself. For pixels with partial coverage, the filter selects the median value from a
// window of 3 pixels in a horizontal row and uses that as the value for the center pixel. // window of 3 pixels in a horizontal row and uses that as the value for the center pixel.
for (x = 1; x < this->width - 1; x++) { for (x = 1; x < this->width - 1; x++) {
Color_RGBA16 pxOut; cvg = this->cvgSave[x + y * this->width];
s32 cvg = this->cvgSave[x + y * this->width];
// Reject pixels with full coverage. The hardware video filter divot circuit checks if all 3 pixels in the // Reject pixels with full coverage. The hardware video filter divot circuit checks if all 3 pixels in the
// window have partial coverage, here only the center pixel is checked. // window have partial coverage, here only the center pixel is checked.
@ -732,11 +739,10 @@ void PreRender_DivotFilter(PreRender* this) {
} }
// This condition is checked before entering this function, it will always pass if it runs. // This condition is checked before entering this function, it will always pass if it runs.
if ((R_HREG_MODE == HREG_MODE_PRERENDER ? R_PRERENDER_DIVOT_CONTROL : 0) != 0) { if (PRERENDER_DIVOT_CONTROL != 0) {
if ((R_HREG_MODE == HREG_MODE_PRERENDER ? R_PRERENDER_DIVOT_CONTROL : 0) != 0) {} if (PRERENDER_DIVOT_CONTROL != 0) {}
if ((R_HREG_MODE == HREG_MODE_PRERENDER ? R_PRERENDER_DIVOT_CONTROL : 0) == if (PRERENDER_DIVOT_CONTROL == PRERENDER_DIVOT_PARTIAL_CVG_RED) {
PRERENDER_DIVOT_PARTIAL_CVG_RED) {
// Fill the pixel with full red, likely for debugging // Fill the pixel with full red, likely for debugging
pxR = 31; pxR = 31;
pxG = 0; pxG = 0;
@ -747,8 +753,7 @@ void PreRender_DivotFilter(PreRender* this) {
u8* windowG = &buffG[x - 1]; u8* windowG = &buffG[x - 1];
u8* windowB = &buffB[x - 1]; u8* windowB = &buffB[x - 1];
if ((R_HREG_MODE == HREG_MODE_PRERENDER ? R_PRERENDER_DIVOT_CONTROL : 0) == if (PRERENDER_DIVOT_CONTROL == PRERENDER_DIVOT_PRINT_COLOR) {
PRERENDER_DIVOT_PRINT_COLOR) {
PRINTF("red=%3d %3d %3d %3d grn=%3d %3d %3d %3d blu=%3d %3d %3d %3d \n", windowR[0], windowR[1], PRINTF("red=%3d %3d %3d %3d grn=%3d %3d %3d %3d blu=%3d %3d %3d %3d \n", windowR[0], windowR[1],
windowR[2], MEDIAN3(windowR[0], windowR[1], windowR[2]), windowG[0], windowG[1], windowR[2], MEDIAN3(windowR[0], windowR[1], windowR[2]), windowG[0], windowG[1],
windowG[2], MEDIAN3(windowG[0], windowG[1], windowG[2]), windowB[0], windowB[1], windowG[2], MEDIAN3(windowG[0], windowG[1], windowG[2]), windowB[0], windowB[1],
@ -758,8 +763,7 @@ void PreRender_DivotFilter(PreRender* this) {
// Sample the median value from the 3 pixel wide window // Sample the median value from the 3 pixel wide window
// (Both blocks contain the same code) // (Both blocks contain the same code)
if ((R_HREG_MODE == HREG_MODE_PRERENDER ? R_PRERENDER_DIVOT_CONTROL : 0) == if (PRERENDER_DIVOT_CONTROL == PRERENDER_DIVOT_ALTERNATE_COLOR) {
PRERENDER_DIVOT_ALTERNATE_COLOR) {
pxR = MEDIAN3(windowR[0], windowR[1], windowR[2]); pxR = MEDIAN3(windowR[0], windowR[1], windowR[2]);
pxG = MEDIAN3(windowG[0], windowG[1], windowG[2]); pxG = MEDIAN3(windowG[0], windowG[1], windowG[2]);
pxB = MEDIAN3(windowB[0], windowB[1], windowB[2]); pxB = MEDIAN3(windowB[0], windowB[1], windowB[2]);
@ -803,11 +807,9 @@ void PreRender_ApplyFilters(PreRender* this) {
} }
} }
#if OOT_DEBUG if (PRERENDER_DIVOT_CONTROL != 0) {
if ((R_HREG_MODE == HREG_MODE_PRERENDER ? R_PRERENDER_DIVOT_CONTROL : 0) != 0) {
// Apply divot filter // Apply divot filter
PreRender_DivotFilter(this); PreRender_DivotFilter(this);
} }
#endif
} }
} }

View file

@ -100,7 +100,7 @@ void ArenaImpl_UnsetCheckFreeBlock(Arena* arena) {
arena->flag &= ~CHECK_FREE_BLOCK_FLAG; arena->flag &= ~CHECK_FREE_BLOCK_FLAG;
} }
void ArenaImpl_SetDebugInfo(ArenaNode* node, const char* file, s32 line, Arena* arena) { void ArenaImpl_SetDebugInfo(ArenaNode* node, const char* file, int line, Arena* arena) {
node->filename = file; node->filename = file;
node->line = line; node->line = line;
node->threadId = osGetThreadId(NULL); node->threadId = osGetThreadId(NULL);
@ -254,7 +254,7 @@ void __osMalloc_FreeBlockTest(Arena* arena, ArenaNode* node) {
} }
} }
void* __osMalloc_NoLockDebug(Arena* arena, u32 size, const char* file, s32 line) { void* __osMalloc_NoLockDebug(Arena* arena, u32 size, const char* file, int line) {
ArenaNode* iter; ArenaNode* iter;
u32 blockSize; u32 blockSize;
ArenaNode* newNode; ArenaNode* newNode;
@ -299,7 +299,7 @@ void* __osMalloc_NoLockDebug(Arena* arena, u32 size, const char* file, s32 line)
return alloc; return alloc;
} }
void* __osMallocDebug(Arena* arena, u32 size, const char* file, s32 line) { void* __osMallocDebug(Arena* arena, u32 size, const char* file, int line) {
void* alloc; void* alloc;
ArenaImpl_Lock(arena); ArenaImpl_Lock(arena);
@ -309,7 +309,7 @@ void* __osMallocDebug(Arena* arena, u32 size, const char* file, s32 line) {
return alloc; return alloc;
} }
void* __osMallocRDebug(Arena* arena, u32 size, const char* file, s32 line) { void* __osMallocRDebug(Arena* arena, u32 size, const char* file, int line) {
ArenaNode* iter; ArenaNode* iter;
ArenaNode* newNode; ArenaNode* newNode;
u32 blockSize; u32 blockSize;
@ -528,7 +528,7 @@ void __osFree(Arena* arena, void* ptr) {
} }
#if OOT_DEBUG #if OOT_DEBUG
void __osFree_NoLockDebug(Arena* arena, void* ptr, const char* file, s32 line) { void __osFree_NoLockDebug(Arena* arena, void* ptr, const char* file, int line) {
ArenaNode* node; ArenaNode* node;
ArenaNode* next; ArenaNode* next;
ArenaNode* prev; ArenaNode* prev;
@ -586,7 +586,7 @@ void __osFree_NoLockDebug(Arena* arena, void* ptr, const char* file, s32 line) {
} }
} }
void __osFreeDebug(Arena* arena, void* ptr, const char* file, s32 line) { void __osFreeDebug(Arena* arena, void* ptr, const char* file, int line) {
ArenaImpl_Lock(arena); ArenaImpl_Lock(arena);
__osFree_NoLockDebug(arena, ptr, file, line); __osFree_NoLockDebug(arena, ptr, file, line);
ArenaImpl_Unlock(arena); ArenaImpl_Unlock(arena);
@ -695,7 +695,7 @@ void* __osRealloc(Arena* arena, void* ptr, u32 newSize) {
} }
#if OOT_DEBUG #if OOT_DEBUG
void* __osReallocDebug(Arena* arena, void* ptr, u32 newSize, const char* file, s32 line) { void* __osReallocDebug(Arena* arena, void* ptr, u32 newSize, const char* file, int line) {
return __osRealloc(arena, ptr, newSize); return __osRealloc(arena, ptr, newSize);
} }
#endif #endif
@ -852,7 +852,11 @@ u32 __osCheckArena(Arena* arena) {
while (iter != NULL) { while (iter != NULL) {
if (iter && iter->magic == NODE_MAGIC) { if (iter && iter->magic == NODE_MAGIC) {
// "Oops!! (%08x %08x)" // "Oops!! (%08x %08x)"
#if OOT_DEBUG
osSyncPrintf(VT_COL(RED, WHITE) "おおっと!! (%08x %08x)\n" VT_RST, iter, iter->magic); osSyncPrintf(VT_COL(RED, WHITE) "おおっと!! (%08x %08x)\n" VT_RST, iter, iter->magic);
#else
osSyncPrintf("おおっと!! (%08x %08x)\n", iter, iter->magic);
#endif
error = 1; error = 1;
break; break;
} }

View file

@ -105,7 +105,7 @@ void AudioMgr_ThreadEntry(void* arg) {
IrqMgr_AddClient(audioMgr->irqMgr, &irqClient, &audioMgr->interruptQueue); IrqMgr_AddClient(audioMgr->irqMgr, &irqClient, &audioMgr->interruptQueue);
// Spin waiting for events // Spin waiting for events
while (true) { for (;;) {
osRecvMesg(&audioMgr->interruptQueue, (OSMesg*)&msg, OS_MESG_BLOCK); osRecvMesg(&audioMgr->interruptQueue, (OSMesg*)&msg, OS_MESG_BLOCK);
switch (*msg) { switch (*msg) {

View file

@ -1,79 +0,0 @@
#include "global.h"
// The latest generated random number, used to generate the next number in the sequence.
static u32 sRandInt = 1;
// Space to store a value to be re-interpreted as a float.
static u32 sRandFloat;
/**
* Gets the next integer in the sequence of pseudo-random numbers.
*/
u32 Rand_Next(void) {
return sRandInt = (sRandInt * 1664525) + 1013904223;
}
/**
* Seeds the pseudo-random number generator by providing a starting value.
*/
void Rand_Seed(u32 seed) {
sRandInt = seed;
}
/**
* Returns a pseudo-random floating-point number between 0.0f and 1.0f, by generating
* the next integer and masking it to an IEEE-754 compliant floating-point number
* between 1.0f and 2.0f, returning the result subtract 1.0f.
*/
f32 Rand_ZeroOne(void) {
sRandInt = (sRandInt * 1664525) + 1013904223;
sRandFloat = ((sRandInt >> 9) | 0x3F800000);
return *((f32*)&sRandFloat) - 1.0f;
}
/**
* Returns a pseudo-random floating-point number between -0.5f and 0.5f by the same
* manner in which Rand_ZeroOne generates its result.
*/
f32 Rand_Centered(void) {
sRandInt = (sRandInt * 1664525) + 1013904223;
sRandFloat = ((sRandInt >> 9) | 0x3F800000);
return *((f32*)&sRandFloat) - 1.5f;
}
/**
* Seeds a pseudo-random number at rndNum with a provided seed.
*/
void Rand_Seed_Variable(u32* rndNum, u32 seed) {
*rndNum = seed;
}
/**
* Generates the next pseudo-random integer from the provided rndNum.
*/
u32 Rand_Next_Variable(u32* rndNum) {
return *rndNum = (*rndNum * 1664525) + 1013904223;
}
/**
* Generates the next pseudo-random floating-point number between 0.0f and
* 1.0f from the provided rndNum.
*/
f32 Rand_ZeroOne_Variable(u32* rndNum) {
u32 next = (*rndNum * 1664525) + 1013904223;
sRandFloat = ((*rndNum = next) >> 9) | 0x3F800000;
return *((f32*)&sRandFloat) - 1.0f;
}
/**
* Generates the next pseudo-random floating-point number between -0.5f and
* 0.5f from the provided rndNum.
*/
f32 Rand_Centered_Variable(u32* rndNum) {
u32 next = (*rndNum * 1664525) + 1013904223;
*rndNum = next;
sRandFloat = (next >> 9) | 0x3F800000;
return *((f32*)&sRandFloat) - 1.5f;
}

View file

@ -36,7 +36,7 @@ void* DebugArena_Malloc(u32 size) {
} }
#if OOT_DEBUG #if OOT_DEBUG
void* DebugArena_MallocDebug(u32 size, const char* file, s32 line) { void* DebugArena_MallocDebug(u32 size, const char* file, int line) {
void* ptr = __osMallocDebug(&sDebugArena, size, file, line); void* ptr = __osMallocDebug(&sDebugArena, size, file, line);
DEBUG_ARENA_CHECK_POINTER(ptr, size, "debug_malloc_DEBUG", "確保"); // "Secure" DEBUG_ARENA_CHECK_POINTER(ptr, size, "debug_malloc_DEBUG", "確保"); // "Secure"
@ -52,7 +52,7 @@ void* DebugArena_MallocR(u32 size) {
} }
#if OOT_DEBUG #if OOT_DEBUG
void* DebugArena_MallocRDebug(u32 size, const char* file, s32 line) { void* DebugArena_MallocRDebug(u32 size, const char* file, int line) {
void* ptr = __osMallocRDebug(&sDebugArena, size, file, line); void* ptr = __osMallocRDebug(&sDebugArena, size, file, line);
DEBUG_ARENA_CHECK_POINTER(ptr, size, "debug_malloc_r_DEBUG", "確保"); // "Secure" DEBUG_ARENA_CHECK_POINTER(ptr, size, "debug_malloc_r_DEBUG", "確保"); // "Secure"
@ -67,7 +67,7 @@ void* DebugArena_Realloc(void* ptr, u32 newSize) {
} }
#if OOT_DEBUG #if OOT_DEBUG
void* DebugArena_ReallocDebug(void* ptr, u32 newSize, const char* file, s32 line) { void* DebugArena_ReallocDebug(void* ptr, u32 newSize, const char* file, int line) {
ptr = __osReallocDebug(&sDebugArena, ptr, newSize, file, line); ptr = __osReallocDebug(&sDebugArena, ptr, newSize, file, line);
DEBUG_ARENA_CHECK_POINTER(ptr, newSize, "debug_realloc_DEBUG", "再確保"); // "Re-securing" DEBUG_ARENA_CHECK_POINTER(ptr, newSize, "debug_realloc_DEBUG", "再確保"); // "Re-securing"
return ptr; return ptr;
@ -79,7 +79,7 @@ void DebugArena_Free(void* ptr) {
} }
#if OOT_DEBUG #if OOT_DEBUG
void DebugArena_FreeDebug(void* ptr, const char* file, s32 line) { void DebugArena_FreeDebug(void* ptr, const char* file, int line) {
__osFreeDebug(&sDebugArena, ptr, file, line); __osFreeDebug(&sDebugArena, ptr, file, line);
} }
#endif #endif

View file

@ -1322,7 +1322,7 @@ NORETURN void Fault_AddHungupAndCrashImpl(const char* exp1, const char* exp2) {
* Like `Fault_AddHungupAndCrashImpl`, however provides a fixed message containing * Like `Fault_AddHungupAndCrashImpl`, however provides a fixed message containing
* filename and line number * filename and line number
*/ */
NORETURN void Fault_AddHungupAndCrash(const char* file, s32 line) { NORETURN void Fault_AddHungupAndCrash(const char* file, int line) {
char msg[256]; char msg[256];
sprintf(msg, "HungUp %s:%d", file, line); sprintf(msg, "HungUp %s:%d", file, line);

View file

@ -102,11 +102,11 @@ FaultDrawer sFaultDrawerDefault = {
#ifndef NON_MATCHING #ifndef NON_MATCHING
// TODO: match .bss (has reordering issues) // TODO: match .bss (has reordering issues)
extern FaultDrawer sFaultDrawer; extern FaultDrawer sFaultDrawer;
extern char D_8016B6BC[0x24]; extern char D_8016B6C0[0x20];
#else #else
// Non-matching version for struct shiftability // Non-matching version for struct shiftability
FaultDrawer sFaultDrawer; FaultDrawer sFaultDrawer;
char D_8016B6BC[0x24]; char D_8016B6C0[0x20];
#endif #endif
void FaultDrawer_SetOsSyncPrintfEnabled(u32 enabled) { void FaultDrawer_SetOsSyncPrintfEnabled(u32 enabled) {

View file

@ -6,10 +6,11 @@ VisCvg sVisCvg;
VisZBuf sVisZBuf; VisZBuf sVisZBuf;
VisMono sVisMono; VisMono sVisMono;
ViMode sViMode; ViMode sViMode;
#if OOT_DEBUG
FaultClient sGameFaultClient; FaultClient sGameFaultClient;
u16 sLastButtonPressed; u16 sLastButtonPressed;
#if OOT_DEBUG
void GameState_FaultPrint(void) { void GameState_FaultPrint(void) {
static char sBtnChars[] = "ABZSuldr*+LRudlr"; static char sBtnChars[] = "ABZSuldr*+LRudlr";
s32 i; s32 i;
@ -408,7 +409,10 @@ void GameState_Init(GameState* gameState, GameStateFunc init, GraphicsContext* g
gameState->destroy = NULL; gameState->destroy = NULL;
gameState->running = 1; gameState->running = 1;
startTime = osGetTime(); startTime = osGetTime();
gameState->size = gameState->init = 0;
// Thse assignments must be written this way for matching and to avoid a warning due to casting a pointer to an
// integer without a cast. This assigns init = NULL and size = 0.
gameState->size = (u32)(gameState->init = NULL);
{ {
s32 requiredScopeTemp; s32 requiredScopeTemp;
@ -494,7 +498,7 @@ u32 GameState_IsRunning(GameState* gameState) {
} }
#if OOT_DEBUG #if OOT_DEBUG
void* GameState_Alloc(GameState* gameState, size_t size, char* file, s32 line) { void* GameState_Alloc(GameState* gameState, size_t size, const char* file, int line) {
void* ret; void* ret;
if (THA_IsCrash(&gameState->tha)) { if (THA_IsCrash(&gameState->tha)) {

View file

@ -13,7 +13,7 @@ void GameAlloc_Log(GameAlloc* this) {
} }
#if OOT_DEBUG #if OOT_DEBUG
void* GameAlloc_MallocDebug(GameAlloc* this, u32 size, const char* file, s32 line) { void* GameAlloc_MallocDebug(GameAlloc* this, u32 size, const char* file, int line) {
GameAllocEntry* ptr = SystemArena_MallocDebug(size + sizeof(GameAllocEntry), file, line); GameAllocEntry* ptr = SystemArena_MallocDebug(size + sizeof(GameAllocEntry), file, line);
if (ptr != NULL) { if (ptr != NULL) {

View file

@ -14,8 +14,13 @@ OSTime sGraphPrevUpdateEndTime;
*/ */
OSTime sGraphPrevTaskTimeStart; OSTime sGraphPrevTaskTimeStart;
#if OOT_DEBUG
FaultClient sGraphFaultClient; FaultClient sGraphFaultClient;
#endif
CfbInfo sGraphCfbInfos[3]; CfbInfo sGraphCfbInfos[3];
#if OOT_DEBUG
FaultClient sGraphUcodeFaultClient; FaultClient sGraphUcodeFaultClient;
UCodeInfo D_8012D230[3] = { UCodeInfo D_8012D230[3] = {
@ -30,7 +35,6 @@ UCodeInfo D_8012D248[3] = {
{ UCODE_S2DEX, gspS2DEX2d_fifoTextStart }, { UCODE_S2DEX, gspS2DEX2d_fifoTextStart },
}; };
#if OOT_DEBUG
void Graph_FaultClient(void) { void Graph_FaultClient(void) {
void* nextFb = osViGetNextFramebuffer(); void* nextFb = osViGetNextFramebuffer();
void* newFb = (SysCfb_GetFbPtr(0) != nextFb) ? SysCfb_GetFbPtr(0) : SysCfb_GetFbPtr(1); void* newFb = (SysCfb_GetFbPtr(0) != nextFb) ? SysCfb_GetFbPtr(0) : SysCfb_GetFbPtr(1);
@ -501,7 +505,7 @@ void* Graph_Alloc2(GraphicsContext* gfxCtx, size_t size) {
} }
#if OOT_DEBUG #if OOT_DEBUG
void Graph_OpenDisps(Gfx** dispRefs, GraphicsContext* gfxCtx, const char* file, s32 line) { void Graph_OpenDisps(Gfx** dispRefs, GraphicsContext* gfxCtx, const char* file, int line) {
if (R_HREG_MODE == HREG_MODE_UCODE_DISAS && R_UCODE_DISAS_LOG_MODE != 4) { if (R_HREG_MODE == HREG_MODE_UCODE_DISAS && R_UCODE_DISAS_LOG_MODE != 4) {
dispRefs[0] = gfxCtx->polyOpa.p; dispRefs[0] = gfxCtx->polyOpa.p;
dispRefs[1] = gfxCtx->polyXlu.p; dispRefs[1] = gfxCtx->polyXlu.p;
@ -513,7 +517,7 @@ void Graph_OpenDisps(Gfx** dispRefs, GraphicsContext* gfxCtx, const char* file,
} }
} }
void Graph_CloseDisps(Gfx** dispRefs, GraphicsContext* gfxCtx, const char* file, s32 line) { void Graph_CloseDisps(Gfx** dispRefs, GraphicsContext* gfxCtx, const char* file, int line) {
if (R_HREG_MODE == HREG_MODE_UCODE_DISAS && R_UCODE_DISAS_LOG_MODE != 4) { if (R_HREG_MODE == HREG_MODE_UCODE_DISAS && R_UCODE_DISAS_LOG_MODE != 4) {
if (dispRefs[0] + 1 == gfxCtx->polyOpa.p) { if (dispRefs[0] + 1 == gfxCtx->polyOpa.p) {
gfxCtx->polyOpa.p = dispRefs[0]; gfxCtx->polyOpa.p = dispRefs[0];

View file

@ -1,6 +1,8 @@
#include "global.h" #include "global.h"
#include "terminal.h" #include "terminal.h"
extern u8 _buffersSegmentEnd[];
s32 gScreenWidth = SCREEN_WIDTH; s32 gScreenWidth = SCREEN_WIDTH;
s32 gScreenHeight = SCREEN_HEIGHT; s32 gScreenHeight = SCREEN_HEIGHT;
u32 gSystemHeapSize = 0; u32 gSystemHeapSize = 0;
@ -29,7 +31,8 @@ OSMesg sSerialMsgBuf[1];
void Main_LogSystemHeap(void) { void Main_LogSystemHeap(void) {
PRINTF(VT_FGCOL(GREEN)); PRINTF(VT_FGCOL(GREEN));
// "System heap size% 08x (% dKB) Start address% 08x" // "System heap size% 08x (% dKB) Start address% 08x"
PRINTF("システムヒープサイズ %08x(%dKB) 開始アドレス %08x\n", gSystemHeapSize, gSystemHeapSize / 1024, gSystemHeap); PRINTF("システムヒープサイズ %08x(%dKB) 開始アドレス %08x\n", gSystemHeapSize, gSystemHeapSize / 1024,
_buffersSegmentEnd);
PRINTF(VT_RST); PRINTF(VT_RST);
} }
#endif #endif
@ -48,7 +51,7 @@ void Main(void* arg) {
PreNmiBuff_Init(gAppNmiBufferPtr); PreNmiBuff_Init(gAppNmiBufferPtr);
Fault_Init(); Fault_Init();
SysCfb_Init(0); SysCfb_Init(0);
systemHeapStart = (uintptr_t)gSystemHeap; systemHeapStart = (uintptr_t)_buffersSegmentEnd;
fb = (uintptr_t)SysCfb_GetFbPtr(0); fb = (uintptr_t)SysCfb_GetFbPtr(0);
gSystemHeapSize = fb - systemHeapStart; gSystemHeapSize = fb - systemHeapStart;
// "System heap initalization" // "System heap initalization"

162
src/code/rand.c Normal file
View file

@ -0,0 +1,162 @@
/**
* @file rand.c
*
* This file implements the primary random number generator the game relies on. The generator is pseudo-random and
* implemented as a Linear Congruential Generator (LCG).
*
* A LCG computes random numbers sequentially via the relation
* X(n+1) = (a * X(n) + c) mod m
* where m is the modulus, a is the multiplier and c is the increment.
*
* These three parameters (a,c,m) completely specify the LCG and should be chosen such that
* - m > 0
* - 0 < a < m
* - 0 <= c < m
*
* The period of the LCG (a, c, m) is the smallest period p such that X(n + p) = X(n), past n=p the sequence will repeat
* itself in its outputs.
* A good LCG should have the maximum possible period, which will be equal to m as there are at most m possible values
* for X. This occurs when (Hull, T.E., & Dobell, A.R. (1962). Random Number Generators. Siam Review, 4, 230-254.):
* - m,c are relatively prime, that is the only integer that divides both m and c with no remainder is 1.
* - a - 1 is divisible by all prime factors of m.
* - a - 1 is divisible by 4 if m is divisible by 4.
*
* Ideally m is chosen to be a large power of 2 so that the modulo operation is inexpensive to compute. In this case the
* prime factors of m = 2^k are just k copies of 2. For k > 1 m is divisible by 4, so a - 1 must be divisible by 4. 2^k
* and c can easily be made relatively prime by making c an odd number.
* If we let k=32 to match the size of an integer, the modulo operation is made implicit by the width of the data type
* and becomes free to compute.
*
* The parameter a should be selected such that a-1 is divisible by 4 (and hence divisible by 2) and c should be any odd
* number. The precise values should fare well against the spectral test, a measure of "how random" a particular LCG is.
* A pair (a,c) that satisfies these requirements is (1664525, 1013904223), recommended by "Numerical Recipes in C: The
* Art of Scientific Computing" (p. 284).
*
* Therefore, the LCG with parameters (1664525, 1013904223, 2^32) that is implemented in this file has a maximal period
* of 2^32 and produces high-quality pseudo-random numbers.
*
* @note If sampling the LCG for a n-bit number it is important to use the upper n bits instead of the lower n bits of
* the LCG output. The lower n bits only have a period of 2^n which may significantly worsen the quality of the
* resulting random numbers compared to the quality of the full 32-bit result.
*
* @note Original name: qrand.c
*/
#include "ultra64.h"
#define RAND_MULTIPLIER 1664525
#define RAND_INCREMENT 1013904223
/**
* The latest generated random number, used to generate the next number in the sequence.
*
* @note Original name: __qrand_idum
*/
static u32 sRandInt = 1;
/**
* Space to store a value to be re-interpreted as a float.
*
* @note Orignal name: __qrand_itemp
*/
static fu sRandFloat;
/**
* Gets the next integer in the sequence of pseudo-random numbers.
*
* @note Original name: qrand
*/
u32 Rand_Next(void) {
return sRandInt = sRandInt * RAND_MULTIPLIER + RAND_INCREMENT;
}
/**
* Seeds the pseudo-random number generator by providing a starting value.
*
* @note Original name: sqrand
*/
void Rand_Seed(u32 seed) {
sRandInt = seed;
}
/**
* Returns a pseudo-random floating-point number between 0.0f and 1.0f, by generating the next integer and masking it
* to an IEEE-754 compliant floating-point number between 1.0f and 2.0f, returning the result subtract 1.0f.
*
* @note This technique for generating pseudo-random floats is recommended as a particularly fast but potentially
* non-portable generator in "Numerical Recipes in C: The Art of Scientic Computing", pp. 284-5.
*
* @note Original name: fqrand
*/
f32 Rand_ZeroOne(void) {
sRandInt = sRandInt * RAND_MULTIPLIER + RAND_INCREMENT;
// Samples the upper 23 bits to avoid effectively reducing the LCG period.
sRandFloat.i = (sRandInt >> 9) | 0x3F800000;
return sRandFloat.f - 1.0f;
}
/**
* Returns a pseudo-random floating-point number between -0.5f and 0.5f by the same manner in which Rand_ZeroOne
* generates its result.
*
* @see Rand_ZeroOne
*
* @note Original name: fqrand2
*/
f32 Rand_Centered(void) {
sRandInt = sRandInt * RAND_MULTIPLIER + RAND_INCREMENT;
sRandFloat.i = (sRandInt >> 9) | 0x3F800000;
return sRandFloat.f - 1.5f;
}
//! All functions below are unused variants of the above four, that use a provided random number variable instead of the
//! internal `sRandInt`
/**
* Seeds a pseudo-random number at rndNum with a provided starting value.
*
* @see Rand_Seed
*
* @note Original name: sqrand_r
*/
void Rand_Seed_Variable(u32* rndNum, u32 seed) {
*rndNum = seed;
}
/**
* Generates the next pseudo-random integer from the provided rndNum.
*
* @see Rand_Next
*
* @note Original name: qrand_r
*/
u32 Rand_Next_Variable(u32* rndNum) {
return *rndNum = (*rndNum) * RAND_MULTIPLIER + RAND_INCREMENT;
}
/**
* Generates the next pseudo-random floating-point number between 0.0f and 1.0f from the provided rndNum.
*
* @see Rand_ZeroOne
*
* @note Original name: fqrand_r
*/
f32 Rand_ZeroOne_Variable(u32* rndNum) {
u32 next = (*rndNum) * RAND_MULTIPLIER + RAND_INCREMENT;
sRandFloat.i = ((*rndNum = next) >> 9) | 0x3F800000;
return sRandFloat.f - 1.0f;
}
/**
* Generates the next pseudo-random floating-point number between -0.5f and 0.5f from the provided rndNum.
*
* @see Rand_ZeroOne, Rand_Centered
*
* @note Original name: fqrand2_r
*/
f32 Rand_Centered_Variable(u32* rndNum) {
u32 next = (*rndNum) * RAND_MULTIPLIER + RAND_INCREMENT;
sRandFloat.i = ((*rndNum = next) >> 9) | 0x3F800000;
return sRandFloat.f - 1.5f;
}

View file

@ -45,14 +45,14 @@
#define RDP_DONE_MSG 668 #define RDP_DONE_MSG 668
#define NOTIFY_MSG 670 // original name: ENTRY_MSG #define NOTIFY_MSG 670 // original name: ENTRY_MSG
vs32 sSchedDebugPrintfEnabled = false;
OSTime sRSPGfxTimeStart; OSTime sRSPGfxTimeStart;
OSTime sRSPAudioTimeStart; OSTime sRSPAudioTimeStart;
OSTime sRSPOtherTimeStart; OSTime sRSPOtherTimeStart;
OSTime sRDPTimeStart; OSTime sRDPTimeStart;
#if OOT_DEBUG #if OOT_DEBUG
vs32 sSchedDebugPrintfEnabled = false;
#define SCHED_DEBUG_PRINTF \ #define SCHED_DEBUG_PRINTF \
if (sSchedDebugPrintfEnabled) \ if (sSchedDebugPrintfEnabled) \
PRINTF PRINTF

View file

@ -605,11 +605,11 @@ Mtx* Matrix_MtxFToMtx(MtxF* src, Mtx* dest) {
#if OOT_DEBUG #if OOT_DEBUG
Mtx* Matrix_ToMtx(Mtx* dest, char* file, s32 line) { Mtx* Matrix_ToMtx(Mtx* dest, const char* file, int line) {
return Matrix_MtxFToMtx(MATRIX_CHECK_FLOATS(sCurrentMatrix, file, line), dest); return Matrix_MtxFToMtx(MATRIX_CHECK_FLOATS(sCurrentMatrix, file, line), dest);
} }
Mtx* Matrix_NewMtx(GraphicsContext* gfxCtx, char* file, s32 line) { Mtx* Matrix_NewMtx(GraphicsContext* gfxCtx, const char* file, int line) {
return Matrix_ToMtx(GRAPH_ALLOC(gfxCtx, sizeof(Mtx)), file, line); return Matrix_ToMtx(GRAPH_ALLOC(gfxCtx, sizeof(Mtx)), file, line);
} }
@ -970,7 +970,7 @@ void Matrix_RotateAxis(f32 angle, Vec3f* axis, u8 mode) {
} }
#if OOT_DEBUG #if OOT_DEBUG
MtxF* Matrix_CheckFloats(MtxF* mf, char* file, s32 line) { MtxF* Matrix_CheckFloats(MtxF* mf, const char* file, int line) {
s32 i, j; s32 i, j;
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {

View file

@ -36,7 +36,7 @@ void* SystemArena_Malloc(u32 size) {
} }
#if OOT_DEBUG #if OOT_DEBUG
void* SystemArena_MallocDebug(u32 size, const char* file, s32 line) { void* SystemArena_MallocDebug(u32 size, const char* file, int line) {
void* ptr = __osMallocDebug(&gSystemArena, size, file, line); void* ptr = __osMallocDebug(&gSystemArena, size, file, line);
SYSTEM_ARENA_CHECK_POINTER(ptr, size, "malloc_DEBUG", "確保"); // "Secure" SYSTEM_ARENA_CHECK_POINTER(ptr, size, "malloc_DEBUG", "確保"); // "Secure"
@ -52,7 +52,7 @@ void* SystemArena_MallocR(u32 size) {
} }
#if OOT_DEBUG #if OOT_DEBUG
void* SystemArena_MallocRDebug(u32 size, const char* file, s32 line) { void* SystemArena_MallocRDebug(u32 size, const char* file, int line) {
void* ptr = __osMallocRDebug(&gSystemArena, size, file, line); void* ptr = __osMallocRDebug(&gSystemArena, size, file, line);
SYSTEM_ARENA_CHECK_POINTER(ptr, size, "malloc_r_DEBUG", "確保"); // "Secure" SYSTEM_ARENA_CHECK_POINTER(ptr, size, "malloc_r_DEBUG", "確保"); // "Secure"
@ -67,7 +67,7 @@ void* SystemArena_Realloc(void* ptr, u32 newSize) {
} }
#if OOT_DEBUG #if OOT_DEBUG
void* SystemArena_ReallocDebug(void* ptr, u32 newSize, const char* file, s32 line) { void* SystemArena_ReallocDebug(void* ptr, u32 newSize, const char* file, int line) {
ptr = __osReallocDebug(&gSystemArena, ptr, newSize, file, line); ptr = __osReallocDebug(&gSystemArena, ptr, newSize, file, line);
SYSTEM_ARENA_CHECK_POINTER(ptr, newSize, "realloc_DEBUG", "再確保"); // "Re-securing" SYSTEM_ARENA_CHECK_POINTER(ptr, newSize, "realloc_DEBUG", "再確保"); // "Re-securing"
return ptr; return ptr;
@ -79,7 +79,7 @@ void SystemArena_Free(void* ptr) {
} }
#if OOT_DEBUG #if OOT_DEBUG
void SystemArena_FreeDebug(void* ptr, const char* file, s32 line) { void SystemArena_FreeDebug(void* ptr, const char* file, int line) {
__osFreeDebug(&gSystemArena, ptr, file, line); __osFreeDebug(&gSystemArena, ptr, file, line);
} }
#endif #endif

View file

@ -23,6 +23,8 @@
#undef DEFINE_ACTOR_UNSET #undef DEFINE_ACTOR_UNSET
// Actor Overlay Table definition // Actor Overlay Table definition
#if OOT_DEBUG
#define DEFINE_ACTOR(name, _1, allocType, nameString) \ #define DEFINE_ACTOR(name, _1, allocType, nameString) \
{ (uintptr_t)_ovl_##name##SegmentRomStart, \ { (uintptr_t)_ovl_##name##SegmentRomStart, \
(uintptr_t)_ovl_##name##SegmentRomEnd, \ (uintptr_t)_ovl_##name##SegmentRomEnd, \
@ -37,6 +39,24 @@
#define DEFINE_ACTOR_INTERNAL(name, _1, allocType, nameString) \ #define DEFINE_ACTOR_INTERNAL(name, _1, allocType, nameString) \
{ 0, 0, NULL, NULL, NULL, &name##_InitVars, nameString, allocType, 0 }, { 0, 0, NULL, NULL, NULL, &name##_InitVars, nameString, allocType, 0 },
#else
// Actor name is set to NULL in retail builds
#define DEFINE_ACTOR(name, _1, allocType, _3) \
{ (uintptr_t)_ovl_##name##SegmentRomStart, \
(uintptr_t)_ovl_##name##SegmentRomEnd, \
_ovl_##name##SegmentStart, \
_ovl_##name##SegmentEnd, \
NULL, \
&name##_InitVars, \
NULL, \
allocType, \
0 },
#define DEFINE_ACTOR_INTERNAL(name, _1, allocType, _3) { 0, 0, NULL, NULL, NULL, &name##_InitVars, NULL, allocType, 0 },
#endif
#define DEFINE_ACTOR_UNSET(_0) { 0 }, #define DEFINE_ACTOR_UNSET(_0) { 0 },
ActorOverlay gActorOverlayTable[] = { ActorOverlay gActorOverlayTable[] = {

View file

@ -79,10 +79,11 @@ u16 sSurfaceMaterialToSfxOffset[SURFACE_MATERIAL_MAX] = {
SURFACE_SFX_OFFSET_CARPET, // SURFACE_MATERIAL_CARPET SURFACE_SFX_OFFSET_CARPET, // SURFACE_MATERIAL_CARPET
}; };
#if OOT_DEBUG
/** /**
* original name: T_BGCheck_PosErrorCheck * original name: T_BGCheck_PosErrorCheck
*/ */
s32 BgCheck_PosErrorCheck(Vec3f* pos, char* file, s32 line) { s32 BgCheck_PosErrorCheck(Vec3f* pos, const char* file, int line) {
if (pos->x >= BGCHECK_XYZ_ABSMAX || pos->x <= -BGCHECK_XYZ_ABSMAX || pos->y >= BGCHECK_XYZ_ABSMAX || if (pos->x >= BGCHECK_XYZ_ABSMAX || pos->x <= -BGCHECK_XYZ_ABSMAX || pos->y >= BGCHECK_XYZ_ABSMAX ||
pos->y <= -BGCHECK_XYZ_ABSMAX || pos->z >= BGCHECK_XYZ_ABSMAX || pos->z <= -BGCHECK_XYZ_ABSMAX) { pos->y <= -BGCHECK_XYZ_ABSMAX || pos->z >= BGCHECK_XYZ_ABSMAX || pos->z <= -BGCHECK_XYZ_ABSMAX) {
PRINTF(VT_FGCOL(RED)); PRINTF(VT_FGCOL(RED));
@ -94,6 +95,7 @@ s32 BgCheck_PosErrorCheck(Vec3f* pos, char* file, s32 line) {
} }
return false; return false;
} }
#endif
/** /**
* Set SSNode * Set SSNode
@ -194,30 +196,24 @@ void BgCheck_Vec3fToVec3s(Vec3s* dst, Vec3f* src) {
* Get CollisionPoly's lowest y point * Get CollisionPoly's lowest y point
*/ */
s16 CollisionPoly_GetMinY(CollisionPoly* poly, Vec3s* vtxList) { s16 CollisionPoly_GetMinY(CollisionPoly* poly, Vec3s* vtxList) {
s32 a;
s32 b;
s32 c;
s16 min;
//! @bug Due to rounding errors, some polys with a slight slope have a y normal of 1.0f/-1.0f. As such, this //! @bug Due to rounding errors, some polys with a slight slope have a y normal of 1.0f/-1.0f. As such, this
//! optimization returns the wrong minimum y for a subset of these polys. //! optimization returns the wrong minimum y for a subset of these polys.
if (poly->normal.y == COLPOLY_SNORMAL(1.0f) || poly->normal.y == COLPOLY_SNORMAL(-1.0f)) { if (poly->normal.y == COLPOLY_SNORMAL(1.0f) || poly->normal.y == COLPOLY_SNORMAL(-1.0f)) {
return vtxList[COLPOLY_VTX_INDEX(poly->flags_vIA)].y; return vtxList[COLPOLY_VTX_INDEX(poly->flags_vIA)].y;
} } else {
s32 a = COLPOLY_VTX_INDEX(poly->flags_vIA);
s32 b = COLPOLY_VTX_INDEX(poly->flags_vIB);
s32 c = poly->vIC;
s16 min = vtxList[a].y;
a = COLPOLY_VTX_INDEX(poly->flags_vIA); if (min > vtxList[b].y) {
b = COLPOLY_VTX_INDEX(poly->flags_vIB); min = vtxList[b].y;
c = poly->vIC; }
if (min < vtxList[c].y) {
min = vtxList[a].y; return min;
}
if (min > vtxList[b].y) { return vtxList[c].y;
min = vtxList[b].y;
} }
if (min < vtxList[c].y) {
return min;
}
return vtxList[c].y;
} }
/** /**
@ -491,8 +487,8 @@ void StaticLookup_AddPolyToSSList(CollisionContext* colCtx, SSList* ssList, Coll
SSNode* curNode; SSNode* curNode;
SSNode* nextNode; SSNode* nextNode;
s32 polyYMin; s32 polyYMin;
u16 newNodeId;
s16 curPolyId; s16 curPolyId;
u16 newNodeId;
// if list is null // if list is null
if (ssList->head == SS_NULL) { if (ssList->head == SS_NULL) {
@ -514,6 +510,8 @@ void StaticLookup_AddPolyToSSList(CollisionContext* colCtx, SSList* ssList, Coll
while (true) { while (true) {
// if at the end of the list // if at the end of the list
if (curNode->next == SS_NULL) { if (curNode->next == SS_NULL) {
s32 pad;
newNodeId = SSNodeList_GetNextNodeIdx(&colCtx->polyNodes); newNodeId = SSNodeList_GetNextNodeIdx(&colCtx->polyNodes);
SSNode_SetValue(&colCtx->polyNodes.tbl[newNodeId], &polyId, SS_NULL); SSNode_SetValue(&colCtx->polyNodes.tbl[newNodeId], &polyId, SS_NULL);
curNode->next = newNodeId; curNode->next = newNodeId;
@ -681,8 +679,8 @@ s32 BgCheck_ComputeWallDisplacement(CollisionContext* colCtx, CollisionPoly* pol
s32 BgCheck_SphVsStaticWall(StaticLookup* lookup, CollisionContext* colCtx, u16 xpFlags, f32* outX, f32* outZ, s32 BgCheck_SphVsStaticWall(StaticLookup* lookup, CollisionContext* colCtx, u16 xpFlags, f32* outX, f32* outZ,
Vec3f* pos, f32 radius, CollisionPoly** outPoly) { Vec3f* pos, f32 radius, CollisionPoly** outPoly) {
Vec3f resultPos; Vec3f resultPos;
f32 temp_f2; f32 zTemp;
f32 temp_f2_2; f32 xTemp;
f32 planeDist; f32 planeDist;
f32 intersect; f32 intersect;
s32 result; s32 result;
@ -690,17 +688,14 @@ s32 BgCheck_SphVsStaticWall(StaticLookup* lookup, CollisionContext* colCtx, u16
CollisionPoly* polyList; CollisionPoly* polyList;
SSNode* curNode; SSNode* curNode;
f32 invNormalXZ; f32 invNormalXZ;
f32 zTemp;
f32 xTemp;
s32 polyId; s32 polyId;
f32 normalXZ; f32 normalXZ;
f32 nx; f32 nx;
f32 ny; f32 ny;
f32 nz; f32 nz;
f32 temp_f16; s32 pad;
Vec3s* vtxList; Vec3s* vtxList;
u16 pad; f32 temp_f16;
f32 zMin; f32 zMin;
f32 zMax; f32 zMax;
f32 xMin; f32 xMin;
@ -780,8 +775,10 @@ s32 BgCheck_SphVsStaticWall(StaticLookup* lookup, CollisionContext* colCtx, u16
} }
} }
if (CollisionPoly_CheckZIntersectApprox(curPoly, vtxList, resultPos.x, pos->y, &intersect)) { if (CollisionPoly_CheckZIntersectApprox(curPoly, vtxList, resultPos.x, pos->y, &intersect)) {
if (fabsf(intersect - resultPos.z) <= radius / temp_f16) { f32 zIntersectDist = intersect - resultPos.z;
if ((intersect - resultPos.z) * nz <= 4.0f) {
if (fabsf(zIntersectDist) <= radius / temp_f16) {
if (zIntersectDist * nz <= 4.0f) {
BgCheck_ComputeWallDisplacement(colCtx, curPoly, &resultPos.x, &resultPos.z, nx, ny, nz, BgCheck_ComputeWallDisplacement(colCtx, curPoly, &resultPos.x, &resultPos.z, nx, ny, nz,
invNormalXZ, planeDist, radius, outPoly); invNormalXZ, planeDist, radius, outPoly);
result = true; result = true;
@ -790,9 +787,8 @@ s32 BgCheck_SphVsStaticWall(StaticLookup* lookup, CollisionContext* colCtx, u16
} }
if (curNode->next == SS_NULL) { if (curNode->next == SS_NULL) {
break; break;
} else {
curNode = &colCtx->polyNodes.tbl[curNode->next];
} }
curNode = &colCtx->polyNodes.tbl[curNode->next];
} }
curNode = &colCtx->polyNodes.tbl[lookup->wall.head]; curNode = &colCtx->polyNodes.tbl[lookup->wall.head];
@ -861,8 +857,10 @@ s32 BgCheck_SphVsStaticWall(StaticLookup* lookup, CollisionContext* colCtx, u16
} }
} }
if (CollisionPoly_CheckXIntersectApprox(curPoly, vtxList, pos->y, resultPos.z, &intersect)) { if (CollisionPoly_CheckXIntersectApprox(curPoly, vtxList, pos->y, resultPos.z, &intersect)) {
if (fabsf(intersect - resultPos.x) <= radius / temp_f16) { f32 xIntersectDist = intersect - resultPos.x;
if ((intersect - resultPos.x) * nx <= 4.0f) {
if (fabsf(xIntersectDist) <= radius / temp_f16) {
if (xIntersectDist * nx <= 4.0f) {
BgCheck_ComputeWallDisplacement(colCtx, curPoly, &resultPos.x, &resultPos.z, nx, ny, nz, BgCheck_ComputeWallDisplacement(colCtx, curPoly, &resultPos.x, &resultPos.z, nx, ny, nz,
invNormalXZ, planeDist, radius, outPoly); invNormalXZ, planeDist, radius, outPoly);
result = true; result = true;
@ -871,10 +869,8 @@ s32 BgCheck_SphVsStaticWall(StaticLookup* lookup, CollisionContext* colCtx, u16
} }
if (curNode->next == SS_NULL) { if (curNode->next == SS_NULL) {
break; break;
} else {
curNode = &colCtx->polyNodes.tbl[curNode->next];
continue;
} }
curNode = &colCtx->polyNodes.tbl[curNode->next];
} }
*outX = resultPos.x; *outX = resultPos.x;
@ -909,6 +905,9 @@ s32 BgCheck_CheckStaticCeiling(StaticLookup* lookup, u16 xpFlags, CollisionConte
*outY = pos->y; *outY = pos->y;
while (true) { while (true) {
f32 intersectDist;
f32 ny;
curPolyId = curNode->polyId; curPolyId = curNode->polyId;
if (COLPOLY_VTX_CHECK_FLAGS_ANY(colCtx->colHeader->polyList[curPolyId].flags_vIA, xpFlags)) { if (COLPOLY_VTX_CHECK_FLAGS_ANY(colCtx->colHeader->polyList[curPolyId].flags_vIA, xpFlags)) {
if (curNode->next == SS_NULL) { if (curNode->next == SS_NULL) {
@ -921,8 +920,8 @@ s32 BgCheck_CheckStaticCeiling(StaticLookup* lookup, u16 xpFlags, CollisionConte
curPoly = &polyList[curPolyId]; curPoly = &polyList[curPolyId];
if (CollisionPoly_CheckYIntersectApprox2(curPoly, vtxList, pos->x, pos->z, &ceilingY)) { if (CollisionPoly_CheckYIntersectApprox2(curPoly, vtxList, pos->x, pos->z, &ceilingY)) {
f32 intersectDist = ceilingY - *outY; intersectDist = ceilingY - *outY;
f32 ny = COLPOLY_GET_NORMAL(curPoly->normal.y); ny = COLPOLY_GET_NORMAL(curPoly->normal.y);
if (intersectDist > 0.0f && intersectDist < checkHeight && intersectDist * ny <= 0) { if (intersectDist > 0.0f && intersectDist < checkHeight && intersectDist * ny <= 0) {
*outY = ceilingY - checkHeight; *outY = ceilingY - checkHeight;
@ -958,7 +957,6 @@ s32 BgCheck_CheckLineAgainstSSList(SSList* ssList, CollisionContext* colCtx, u16
s32 result; s32 result;
f32 minY; f32 minY;
f32 distSq; f32 distSq;
s16 polyId;
result = false; result = false;
polyList = colCtx->colHeader->polyList; polyList = colCtx->colHeader->polyList;
@ -968,7 +966,8 @@ s32 BgCheck_CheckLineAgainstSSList(SSList* ssList, CollisionContext* colCtx, u16
curNode = &colCtx->polyNodes.tbl[ssList->head]; curNode = &colCtx->polyNodes.tbl[ssList->head];
while (true) { while (true) {
polyId = curNode->polyId; s16 polyId = curNode->polyId;
checkedPoly = &colCtx->polyNodes.polyCheckTbl[polyId]; checkedPoly = &colCtx->polyNodes.polyCheckTbl[polyId];
if (*checkedPoly == true || COLPOLY_VTX_CHECK_FLAGS_ANY(polyList[polyId].flags_vIA, xpFlags1) || if (*checkedPoly == true || COLPOLY_VTX_CHECK_FLAGS_ANY(polyList[polyId].flags_vIA, xpFlags1) ||
@ -1051,13 +1050,12 @@ s32 BgCheck_SphVsFirstStaticPolyList(SSNode* node, u16 xpFlags, CollisionContext
CollisionPoly** outPoly) { CollisionPoly** outPoly) {
CollisionPoly* polyList = colCtx->colHeader->polyList; CollisionPoly* polyList = colCtx->colHeader->polyList;
Vec3s* vtxList = colCtx->colHeader->vtxList; Vec3s* vtxList = colCtx->colHeader->vtxList;
CollisionPoly* curPoly;
u16 nextId;
s16 curPolyId;
while (true) { while (true) {
curPolyId = node->polyId; u16 nextId;
curPoly = &polyList[curPolyId]; s16 curPolyId = node->polyId;
CollisionPoly* curPoly = &polyList[curPolyId];
if (COLPOLY_VTX_CHECK_FLAGS_ANY(colCtx->colHeader->polyList[curPolyId].flags_vIA, xpFlags)) { if (COLPOLY_VTX_CHECK_FLAGS_ANY(colCtx->colHeader->polyList[curPolyId].flags_vIA, xpFlags)) {
if (node->next == SS_NULL) { if (node->next == SS_NULL) {
break; break;
@ -1542,10 +1540,10 @@ void BgCheck_Allocate(CollisionContext* colCtx, PlayState* play, CollisionHeader
u32 tblMax; u32 tblMax;
u32 memSize; u32 memSize;
u32 lookupTblMemSize; u32 lookupTblMemSize;
SSNodeList* nodeList;
s32 useCustomSubdivisions;
u32 customMemSize;
s32 customNodeListMax; s32 customNodeListMax;
SSNodeList* nodeList;
u32 customMemSize;
s32 useCustomSubdivisions;
s32 i; s32 i;
colCtx->colHeader = colHeader; colCtx->colHeader = colHeader;
@ -1717,11 +1715,15 @@ f32 BgCheck_RaycastDownImpl(PlayState* play, CollisionContext* colCtx, u16 xpFla
if (checkPos.y < colCtx->minBounds.y) { if (checkPos.y < colCtx->minBounds.y) {
break; break;
} }
#if OOT_DEBUG
if (BgCheck_PosErrorCheck(&checkPos, "../z_bgcheck.c", 4410)) { if (BgCheck_PosErrorCheck(&checkPos, "../z_bgcheck.c", 4410)) {
if (actor != NULL) { if (actor != NULL) {
PRINTF("こいつ,pself_actor->name %d\n", actor->id); PRINTF("こいつ,pself_actor->name %d\n", actor->id);
} }
} }
#endif
lookup = BgCheck_GetStaticLookup(colCtx, lookupTbl, &checkPos); lookup = BgCheck_GetStaticLookup(colCtx, lookupTbl, &checkPos);
if (lookup == NULL) { if (lookup == NULL) {
checkPos.y -= colCtx->subdivLength.y; checkPos.y -= colCtx->subdivLength.y;
@ -1735,16 +1737,16 @@ f32 BgCheck_RaycastDownImpl(PlayState* play, CollisionContext* colCtx, u16 xpFla
checkPos.y -= colCtx->subdivLength.y; checkPos.y -= colCtx->subdivLength.y;
} }
dynaRaycastDown.play = play;
dynaRaycastDown.colCtx = colCtx; dynaRaycastDown.colCtx = colCtx;
dynaRaycastDown.xpFlags = xpFlags; dynaRaycastDown.xpFlags = xpFlags;
dynaRaycastDown.resultPoly = outPoly;
dynaRaycastDown.yIntersect = yIntersect; dynaRaycastDown.yIntersect = yIntersect;
dynaRaycastDown.pos = pos; dynaRaycastDown.pos = pos;
dynaRaycastDown.bgId = outBgId;
dynaRaycastDown.actor = actor; dynaRaycastDown.actor = actor;
dynaRaycastDown.downChkFlags = downChkFlags; dynaRaycastDown.downChkFlags = downChkFlags;
dynaRaycastDown.chkDist = chkDist; dynaRaycastDown.chkDist = chkDist;
dynaRaycastDown.play = play;
dynaRaycastDown.resultPoly = outPoly;
dynaRaycastDown.bgId = outBgId;
yIntersectDyna = BgCheck_RaycastDownDyna(&dynaRaycastDown); yIntersectDyna = BgCheck_RaycastDownDyna(&dynaRaycastDown);
@ -1951,11 +1953,11 @@ s32 BgCheck_CheckWallImpl(CollisionContext* colCtx, u16 xpFlags, Vec3f* posResul
Vec3f checkLinePrev; Vec3f checkLinePrev;
f32 n2XZDist; f32 n2XZDist;
f32 n3XZDist; f32 n3XZDist;
f32 nx3, nz3;
s32 bccFlags; s32 bccFlags;
f32 nx;
f32 nz;
Vec3f posIntersect2; Vec3f posIntersect2;
s32 bgId2; s32 bgId2;
f32 nx, ny, nz; // unit normal of polygon
result = false; result = false;
*outBgId = BGCHECK_SCENE; *outBgId = BGCHECK_SCENE;
@ -1966,12 +1968,14 @@ s32 BgCheck_CheckWallImpl(CollisionContext* colCtx, u16 xpFlags, Vec3f* posResul
dy = posNext->y - posPrev->y; dy = posNext->y - posPrev->y;
dz = posNext->z - posPrev->z; dz = posNext->z - posPrev->z;
#if OOT_DEBUG
if (BgCheck_PosErrorCheck(posNext, "../z_bgcheck.c", 4831) == true || if (BgCheck_PosErrorCheck(posNext, "../z_bgcheck.c", 4831) == true ||
BgCheck_PosErrorCheck(posPrev, "../z_bgcheck.c", 4832) == true) { BgCheck_PosErrorCheck(posPrev, "../z_bgcheck.c", 4832) == true) {
if (actor != NULL) { if (actor != NULL) {
PRINTF("こいつ,pself_actor->name %d\n", actor->id); PRINTF("こいつ,pself_actor->name %d\n", actor->id);
} }
} }
#endif
// if there's movement on the xz plane, and argA flag is 0, // if there's movement on the xz plane, and argA flag is 0,
if ((dx != 0.0f || dz != 0.0f) && (argA & 1) == 0) { if ((dx != 0.0f || dz != 0.0f) && (argA & 1) == 0) {
@ -1980,7 +1984,8 @@ s32 BgCheck_CheckWallImpl(CollisionContext* colCtx, u16 xpFlags, Vec3f* posResul
result = BgCheck_CheckLineImpl(colCtx, xpFlags, COLPOLY_IGNORE_NONE, posPrev, posNext, &posIntersect, &poly, result = BgCheck_CheckLineImpl(colCtx, xpFlags, COLPOLY_IGNORE_NONE, posPrev, posNext, &posIntersect, &poly,
&bgId, actor, 1.0f, BGCHECK_CHECK_ALL & ~BGCHECK_CHECK_CEILING); &bgId, actor, 1.0f, BGCHECK_CHECK_ALL & ~BGCHECK_CHECK_CEILING);
if (result) { if (result) {
ny = COLPOLY_GET_NORMAL(poly->normal.y); f32 ny = COLPOLY_GET_NORMAL(poly->normal.y);
// if poly is floor, push result underneath the floor // if poly is floor, push result underneath the floor
if (ny > 0.5f) { if (ny > 0.5f) {
posResult->x = posIntersect.x; posResult->x = posIntersect.x;
@ -2061,8 +2066,9 @@ s32 BgCheck_CheckWallImpl(CollisionContext* colCtx, u16 xpFlags, Vec3f* posResul
if (dynaPolyCollision == true || *outBgId != BGCHECK_SCENE) { if (dynaPolyCollision == true || *outBgId != BGCHECK_SCENE) {
if (BgCheck_CheckLineImpl(colCtx, xpFlags, COLPOLY_IGNORE_NONE, posPrev, posResult, &posIntersect2, &poly, if (BgCheck_CheckLineImpl(colCtx, xpFlags, COLPOLY_IGNORE_NONE, posPrev, posResult, &posIntersect2, &poly,
&bgId2, actor, 1.0f, BGCHECK_CHECK_ONE_FACE | BGCHECK_CHECK_WALL)) { &bgId2, actor, 1.0f, BGCHECK_CHECK_ONE_FACE | BGCHECK_CHECK_WALL)) {
nx3 = COLPOLY_GET_NORMAL(poly->normal.x); f32 nx3 = COLPOLY_GET_NORMAL(poly->normal.x);
nz3 = COLPOLY_GET_NORMAL(poly->normal.z); f32 nz3 = COLPOLY_GET_NORMAL(poly->normal.z);
n3XZDist = sqrtf(SQ(nx3) + SQ(nz3)); n3XZDist = sqrtf(SQ(nx3) + SQ(nz3));
// if poly is not a "flat" floor or "flat" ceiling // if poly is not a "flat" floor or "flat" ceiling
@ -2155,11 +2161,15 @@ s32 BgCheck_CheckCeilingImpl(CollisionContext* colCtx, u16 xpFlags, f32* outY, V
*outBgId = BGCHECK_SCENE; *outBgId = BGCHECK_SCENE;
*outY = pos->y; *outY = pos->y;
#if OOT_DEBUG
if (BgCheck_PosErrorCheck(pos, "../z_bgcheck.c", 5206) == true) { if (BgCheck_PosErrorCheck(pos, "../z_bgcheck.c", 5206) == true) {
if (actor != NULL) { if (actor != NULL) {
PRINTF("こいつ,pself_actor->name %d\n", actor->id); PRINTF("こいつ,pself_actor->name %d\n", actor->id);
} }
} }
#endif
lookupTbl = colCtx->lookupTbl; lookupTbl = colCtx->lookupTbl;
if (!BgCheck_PosInStaticBoundingBox(colCtx, pos)) { if (!BgCheck_PosInStaticBoundingBox(colCtx, pos)) {
return false; return false;
@ -2222,13 +2232,10 @@ s32 BgCheck_CheckLineImpl(CollisionContext* colCtx, u16 xpFlags1, u16 xpFlags2,
Vec3f posBTemp = *posB; Vec3f posBTemp = *posB;
Vec3f sectorMin; Vec3f sectorMin;
Vec3f sectorMax; Vec3f sectorMax;
s32 k;
StaticLookup* lookup;
s32 j;
StaticLookup* jLookup;
s32 temp_lo;
*outBgId = BGCHECK_SCENE; *outBgId = BGCHECK_SCENE;
#if OOT_DEBUG
if (BgCheck_PosErrorCheck(posA, "../z_bgcheck.c", 5334) == true || if (BgCheck_PosErrorCheck(posA, "../z_bgcheck.c", 5334) == true ||
BgCheck_PosErrorCheck(posB, "../z_bgcheck.c", 5335) == true) { BgCheck_PosErrorCheck(posB, "../z_bgcheck.c", 5335) == true) {
if (actor != NULL) { if (actor != NULL) {
@ -2237,6 +2244,7 @@ s32 BgCheck_CheckLineImpl(CollisionContext* colCtx, u16 xpFlags1, u16 xpFlags2,
PRINTF("pself_actor == NULLで犯人不明\n"); PRINTF("pself_actor == NULLで犯人不明\n");
} }
} }
#endif
BgCheck_ResetPolyCheckTbl(&colCtx->polyNodes, colCtx->colHeader->numPolygons); BgCheck_ResetPolyCheckTbl(&colCtx->polyNodes, colCtx->colHeader->numPolygons);
BgCheck_GetStaticLookupIndicesFromPos(colCtx, posA, (Vec3i*)&subdivMin); BgCheck_GetStaticLookupIndicesFromPos(colCtx, posA, (Vec3i*)&subdivMin);
@ -2247,6 +2255,10 @@ s32 BgCheck_CheckLineImpl(CollisionContext* colCtx, u16 xpFlags1, u16 xpFlags2,
*outPoly = NULL; *outPoly = NULL;
if (subdivMin[0] != subdivMax[0] || subdivMin[1] != subdivMax[1] || subdivMin[2] != subdivMax[2]) { if (subdivMin[0] != subdivMax[0] || subdivMin[1] != subdivMax[1] || subdivMin[2] != subdivMax[2]) {
s32 k;
s32 temp_lo;
s32 j;
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
if (subdivMax[i] < subdivMin[i]) { if (subdivMax[i] < subdivMin[i]) {
j = subdivMax[i]; j = subdivMax[i];
@ -2260,12 +2272,14 @@ s32 BgCheck_CheckLineImpl(CollisionContext* colCtx, u16 xpFlags1, u16 xpFlags2,
sectorMax.z = colCtx->subdivLength.z + sectorMin.z; sectorMax.z = colCtx->subdivLength.z + sectorMin.z;
for (i = subdivMin[2]; i < subdivMax[2] + 1; i++) { for (i = subdivMin[2]; i < subdivMax[2] + 1; i++) {
jLookup = iLookup + subdivMin[1] * colCtx->subdivAmount.x; StaticLookup* jLookup = iLookup + subdivMin[1] * colCtx->subdivAmount.x;
sectorMin.y = subdivMin[1] * colCtx->subdivLength.y + colCtx->minBounds.y; sectorMin.y = subdivMin[1] * colCtx->subdivLength.y + colCtx->minBounds.y;
sectorMax.y = colCtx->subdivLength.y + sectorMin.y; sectorMax.y = colCtx->subdivLength.y + sectorMin.y;
for (j = subdivMin[1]; j < subdivMax[1] + 1; j++) { for (j = subdivMin[1]; j < subdivMax[1] + 1; j++) {
lookup = jLookup + subdivMin[0]; StaticLookup* lookup = jLookup + subdivMin[0];
sectorMin.x = subdivMin[0] * colCtx->subdivLength.x + colCtx->minBounds.x; sectorMin.x = subdivMin[0] * colCtx->subdivLength.x + colCtx->minBounds.x;
sectorMax.x = colCtx->subdivLength.x + sectorMin.x; sectorMax.x = colCtx->subdivLength.x + sectorMin.x;
@ -2443,11 +2457,14 @@ s32 BgCheck_SphVsFirstPolyImpl(CollisionContext* colCtx, u16 xpFlags, CollisionP
StaticLookup* lookup; StaticLookup* lookup;
*outBgId = BGCHECK_SCENE; *outBgId = BGCHECK_SCENE;
#if OOT_DEBUG
if (BgCheck_PosErrorCheck(center, "../z_bgcheck.c", 5852) == true) { if (BgCheck_PosErrorCheck(center, "../z_bgcheck.c", 5852) == true) {
if (actor != NULL) { if (actor != NULL) {
PRINTF("こいつ,pself_actor->name %d\n", actor->id); PRINTF("こいつ,pself_actor->name %d\n", actor->id);
} }
} }
#endif
lookup = BgCheck_GetStaticLookup(colCtx, colCtx->lookupTbl, center); lookup = BgCheck_GetStaticLookup(colCtx, colCtx->lookupTbl, center);
if (lookup == NULL) { if (lookup == NULL) {
@ -2784,12 +2801,12 @@ void DynaPoly_DeleteBgActor(PlayState* play, DynaCollisionContext* dyna, s32 bgI
PRINTF(VT_RST); PRINTF(VT_RST);
if (!DynaPoly_IsBgIdBgActor(bgId)) { if (!DynaPoly_IsBgIdBgActor(bgId)) {
#if OOT_DEBUG
if (bgId == -1) { if (bgId == -1) {
PRINTF(VT_FGCOL(GREEN)); PRINTF(VT_FGCOL(GREEN));
// "The index that should have been deleted(? ) was(== -1), processing aborted." // "The index that should have been deleted(? ) was(== -1), processing aborted."
PRINTF("DynaPolyInfo_delReserve():削除されているはずの(?)\nインデックス(== -1)のため,処理を中止します。\n"); PRINTF("DynaPolyInfo_delReserve():削除されているはずの(?)\nインデックス(== -1)のため,処理を中止します。\n");
PRINTF(VT_RST); PRINTF(VT_RST);
return;
} else { } else {
PRINTF(VT_FGCOL(RED)); PRINTF(VT_FGCOL(RED));
// "Unable to deallocate index / index unallocated, processing aborted." // "Unable to deallocate index / index unallocated, processing aborted."
@ -2797,15 +2814,17 @@ void DynaPoly_DeleteBgActor(PlayState* play, DynaCollisionContext* dyna, s32 bgI
"確保していない出来なかったインデックスの解放のため、処理を中止します。index == %d\n", "確保していない出来なかったインデックスの解放のため、処理を中止します。index == %d\n",
bgId); bgId);
PRINTF(VT_RST); PRINTF(VT_RST);
return;
} }
} #endif
actor = DynaPoly_GetActor(&play->colCtx, bgId);
if (actor != NULL) {
actor->bgId = BGACTOR_NEG_ONE; } else {
dyna->bgActors[bgId].actor = NULL; actor = DynaPoly_GetActor(&play->colCtx, bgId);
dyna->bgActorFlags[bgId] |= BGACTOR_1; if (actor != NULL) {
actor->bgId = BGACTOR_NEG_ONE;
dyna->bgActors[bgId].actor = NULL;
dyna->bgActorFlags[bgId] |= BGACTOR_1;
}
} }
} }
@ -2821,7 +2840,7 @@ void DynaPoly_AddBgActorToLookup(PlayState* play, DynaCollisionContext* dyna, s3
MtxF mtx; MtxF mtx;
Actor* actor; Actor* actor;
s32 pad; s32 pad;
s32 pad2; f32 radiusSq;
f32 numVtxInverse; f32 numVtxInverse;
s32 i; s32 i;
Vec3f pos; Vec3f pos;
@ -2851,6 +2870,7 @@ void DynaPoly_AddBgActorToLookup(PlayState* play, DynaCollisionContext* dyna, s3
return; return;
} }
#if OOT_DEBUG
if (!(dyna->polyListMax >= *polyStartIndex + pbgdata->numPolygons)) { if (!(dyna->polyListMax >= *polyStartIndex + pbgdata->numPolygons)) {
PRINTF(VT_FGCOL(RED)); PRINTF(VT_FGCOL(RED));
// "do not use if %d exceeds %d" // "do not use if %d exceeds %d"
@ -2869,6 +2889,7 @@ void DynaPoly_AddBgActorToLookup(PlayState* play, DynaCollisionContext* dyna, s3
"pdyna_poly_info->poly_num >= *pstart_poly_index + pbgdata->poly_num", "../z_bgcheck.c", 6687); "pdyna_poly_info->poly_num >= *pstart_poly_index + pbgdata->poly_num", "../z_bgcheck.c", 6687);
ASSERT(dyna->vtxListMax >= *vtxStartIndex + pbgdata->numVertices, ASSERT(dyna->vtxListMax >= *vtxStartIndex + pbgdata->numVertices,
"pdyna_poly_info->vert_num >= *pstart_vert_index + pbgdata->vtx_num", "../z_bgcheck.c", 6688); "pdyna_poly_info->vert_num >= *pstart_vert_index + pbgdata->vtx_num", "../z_bgcheck.c", 6688);
#endif
if (!(dyna->bitFlag & DYNAPOLY_INVALIDATE_LOOKUP) && if (!(dyna->bitFlag & DYNAPOLY_INVALIDATE_LOOKUP) &&
(BgActor_IsTransformUnchanged(&dyna->bgActors[bgId]) == true)) { (BgActor_IsTransformUnchanged(&dyna->bgActors[bgId]) == true)) {
@ -2898,111 +2919,111 @@ void DynaPoly_AddBgActorToLookup(PlayState* play, DynaCollisionContext* dyna, s3
*polyStartIndex += pbgdata->numPolygons; *polyStartIndex += pbgdata->numPolygons;
*vtxStartIndex += pbgdata->numVertices; *vtxStartIndex += pbgdata->numVertices;
} else { return;
SkinMatrix_SetTranslateRotateYXZScale(
&mtx, dyna->bgActors[bgId].curTransform.scale.x, dyna->bgActors[bgId].curTransform.scale.y,
dyna->bgActors[bgId].curTransform.scale.z, dyna->bgActors[bgId].curTransform.rot.x,
dyna->bgActors[bgId].curTransform.rot.y, dyna->bgActors[bgId].curTransform.rot.z,
dyna->bgActors[bgId].curTransform.pos.x, dyna->bgActors[bgId].curTransform.pos.y,
dyna->bgActors[bgId].curTransform.pos.z);
numVtxInverse = 1.0f / pbgdata->numVertices;
newCenterPoint.x = newCenterPoint.y = newCenterPoint.z = 0.0f;
for (i = 0; i < pbgdata->numVertices; i++) {
Vec3f vtx;
Vec3f vtxT; // Vtx after mtx transform
Math_Vec3s_ToVec3f(&vtx, &pbgdata->vtxList[i]);
SkinMatrix_Vec3fMtxFMultXYZ(&mtx, &vtx, &vtxT);
BgCheck_Vec3fToVec3s(&dyna->vtxList[*vtxStartIndex + i], &vtxT);
if (i == 0) {
dyna->bgActors[bgId].minY = dyna->bgActors[bgId].maxY = vtxT.y;
} else if (vtxT.y < dyna->bgActors[bgId].minY) {
dyna->bgActors[bgId].minY = vtxT.y;
} else if (dyna->bgActors[bgId].maxY < vtxT.y) {
dyna->bgActors[bgId].maxY = vtxT.y;
}
newCenterPoint.x += vtxT.x;
newCenterPoint.y += vtxT.y;
newCenterPoint.z += vtxT.z;
}
newCenterPoint.x *= numVtxInverse;
newCenterPoint.y *= numVtxInverse;
newCenterPoint.z *= numVtxInverse;
sphere->center.x = newCenterPoint.x;
sphere->center.y = newCenterPoint.y;
sphere->center.z = newCenterPoint.z;
newRadiusSq = -SQ(10.0f);
for (i = 0; i < pbgdata->numVertices; i++) {
f32 radiusSq;
newVtx.x = dyna->vtxList[*vtxStartIndex + i].x;
newVtx.y = dyna->vtxList[*vtxStartIndex + i].y;
newVtx.z = dyna->vtxList[*vtxStartIndex + i].z;
radiusSq = Math3D_Vec3fDistSq(&newVtx, &newCenterPoint);
if (newRadiusSq < radiusSq) {
newRadiusSq = radiusSq;
}
}
sphere->radius = sqrtf(newRadiusSq) * 1.1f;
for (i = 0; i < pbgdata->numPolygons; i++) {
CollisionPoly* newPoly = &dyna->polyList[*polyStartIndex + i];
f32 newNormMagnitude;
*newPoly = pbgdata->polyList[i];
// Yeah, this is all kinds of fake, but my God, it matches.
newPoly->flags_vIA = (COLPOLY_VTX_INDEX(newPoly->flags_vIA) + *vtxStartIndex) |
COLPOLY_VTX_FLAGS_MASKED((*newPoly).flags_vIA);
newPoly->flags_vIB = (COLPOLY_VTX_INDEX(newPoly->flags_vIB) + *vtxStartIndex) |
COLPOLY_VTX_FLAGS_MASKED((*newPoly).flags_vIB);
newPoly->vIC = *vtxStartIndex + newPoly->vIC;
dVtxList = dyna->vtxList;
vtxA.x = dVtxList[(u32)COLPOLY_VTX_INDEX(newPoly->flags_vIA)].x;
vtxA.y = dVtxList[(u32)COLPOLY_VTX_INDEX(newPoly->flags_vIA)].y;
vtxA.z = dVtxList[(u32)COLPOLY_VTX_INDEX(newPoly->flags_vIA)].z;
vtxB.x = dVtxList[(u32)COLPOLY_VTX_INDEX(newPoly->flags_vIB)].x;
vtxB.y = dVtxList[(u32)COLPOLY_VTX_INDEX(newPoly->flags_vIB)].y;
vtxB.z = dVtxList[(u32)COLPOLY_VTX_INDEX(newPoly->flags_vIB)].z;
vtxC.x = dVtxList[newPoly->vIC].x;
vtxC.y = dVtxList[newPoly->vIC].y;
vtxC.z = dVtxList[newPoly->vIC].z;
Math3D_SurfaceNorm(&vtxA, &vtxB, &vtxC, &newNormal);
newNormMagnitude = Math3D_Vec3fMagnitude(&newNormal);
if (!IS_ZERO(newNormMagnitude)) {
newNormal.x *= (1.0f / newNormMagnitude);
newNormal.y *= (1.0f / newNormMagnitude);
newNormal.z *= (1.0f / newNormMagnitude);
newPoly->normal.x = COLPOLY_SNORMAL(newNormal.x);
newPoly->normal.y = COLPOLY_SNORMAL(newNormal.y);
newPoly->normal.z = COLPOLY_SNORMAL(newNormal.z);
}
newPoly->dist = -DOTXYZ(newNormal, dVtxList[(u32)COLPOLY_VTX_INDEX(newPoly->flags_vIA)]);
if (newNormal.y > 0.5f) {
s16 polyId = *polyStartIndex + i;
DynaSSNodeList_SetSSListHead(&dyna->polyNodes, &dyna->bgActors[bgId].dynaLookup.floor, &polyId);
} else if (newNormal.y < -0.8f) {
s16 polyId = *polyStartIndex + i;
DynaSSNodeList_SetSSListHead(&dyna->polyNodes, &dyna->bgActors[bgId].dynaLookup.ceiling, &polyId);
} else {
s16 polyId = *polyStartIndex + i;
DynaSSNodeList_SetSSListHead(&dyna->polyNodes, &dyna->bgActors[bgId].dynaLookup.wall, &polyId);
}
}
*polyStartIndex += pbgdata->numPolygons;
*vtxStartIndex += pbgdata->numVertices;
} }
SkinMatrix_SetTranslateRotateYXZScale(
&mtx, dyna->bgActors[bgId].curTransform.scale.x, dyna->bgActors[bgId].curTransform.scale.y,
dyna->bgActors[bgId].curTransform.scale.z, dyna->bgActors[bgId].curTransform.rot.x,
dyna->bgActors[bgId].curTransform.rot.y, dyna->bgActors[bgId].curTransform.rot.z,
dyna->bgActors[bgId].curTransform.pos.x, dyna->bgActors[bgId].curTransform.pos.y,
dyna->bgActors[bgId].curTransform.pos.z);
numVtxInverse = 1.0f / pbgdata->numVertices;
newCenterPoint.x = newCenterPoint.y = newCenterPoint.z = 0.0f;
for (i = 0; i < pbgdata->numVertices; i++) {
Vec3f vtx;
Vec3f vtxT; // Vtx after mtx transform
s32 pad2;
Math_Vec3s_ToVec3f(&vtx, &pbgdata->vtxList[i]);
SkinMatrix_Vec3fMtxFMultXYZ(&mtx, &vtx, &vtxT);
BgCheck_Vec3fToVec3s(&dyna->vtxList[*vtxStartIndex + i], &vtxT);
if (i == 0) {
dyna->bgActors[bgId].minY = dyna->bgActors[bgId].maxY = vtxT.y;
} else if (vtxT.y < dyna->bgActors[bgId].minY) {
dyna->bgActors[bgId].minY = vtxT.y;
} else if (dyna->bgActors[bgId].maxY < vtxT.y) {
dyna->bgActors[bgId].maxY = vtxT.y;
}
newCenterPoint.x += vtxT.x;
newCenterPoint.y += vtxT.y;
newCenterPoint.z += vtxT.z;
}
newCenterPoint.x *= numVtxInverse;
newCenterPoint.y *= numVtxInverse;
newCenterPoint.z *= numVtxInverse;
sphere->center.x = newCenterPoint.x;
sphere->center.y = newCenterPoint.y;
sphere->center.z = newCenterPoint.z;
newRadiusSq = -SQ(10.0f);
for (i = 0; i < pbgdata->numVertices; i++) {
newVtx.x = dyna->vtxList[*vtxStartIndex + i].x;
newVtx.y = dyna->vtxList[*vtxStartIndex + i].y;
newVtx.z = dyna->vtxList[*vtxStartIndex + i].z;
radiusSq = Math3D_Vec3fDistSq(&newVtx, &newCenterPoint);
if (newRadiusSq < radiusSq) {
newRadiusSq = radiusSq;
}
}
sphere->radius = sqrtf(newRadiusSq) * 1.1f;
for (i = 0; i < pbgdata->numPolygons; i++) {
CollisionPoly* newPoly = &dyna->polyList[*polyStartIndex + i];
f32 newNormMagnitude;
*newPoly = pbgdata->polyList[i];
// Yeah, this is all kinds of fake, but my God, it matches.
newPoly->flags_vIA =
(COLPOLY_VTX_INDEX(newPoly->flags_vIA) + *vtxStartIndex) | COLPOLY_VTX_FLAGS_MASKED((*newPoly).flags_vIA);
newPoly->flags_vIB =
(COLPOLY_VTX_INDEX(newPoly->flags_vIB) + *vtxStartIndex) | COLPOLY_VTX_FLAGS_MASKED((*newPoly).flags_vIB);
newPoly->vIC = *vtxStartIndex + newPoly->vIC;
dVtxList = dyna->vtxList;
vtxA.x = dVtxList[(u32)COLPOLY_VTX_INDEX(newPoly->flags_vIA)].x;
vtxA.y = dVtxList[(u32)COLPOLY_VTX_INDEX(newPoly->flags_vIA)].y;
vtxA.z = dVtxList[(u32)COLPOLY_VTX_INDEX(newPoly->flags_vIA)].z;
vtxB.x = dVtxList[(u32)COLPOLY_VTX_INDEX(newPoly->flags_vIB)].x;
vtxB.y = dVtxList[(u32)COLPOLY_VTX_INDEX(newPoly->flags_vIB)].y;
vtxB.z = dVtxList[(u32)COLPOLY_VTX_INDEX(newPoly->flags_vIB)].z;
vtxC.x = dVtxList[newPoly->vIC].x;
vtxC.y = dVtxList[newPoly->vIC].y;
vtxC.z = dVtxList[newPoly->vIC].z;
Math3D_SurfaceNorm(&vtxA, &vtxB, &vtxC, &newNormal);
newNormMagnitude = Math3D_Vec3fMagnitude(&newNormal);
if (!IS_ZERO(newNormMagnitude)) {
newNormal.x *= (1.0f / newNormMagnitude);
newNormal.y *= (1.0f / newNormMagnitude);
newNormal.z *= (1.0f / newNormMagnitude);
newPoly->normal.x = COLPOLY_SNORMAL(newNormal.x);
newPoly->normal.y = COLPOLY_SNORMAL(newNormal.y);
newPoly->normal.z = COLPOLY_SNORMAL(newNormal.z);
}
newPoly->dist = -DOTXYZ(newNormal, dVtxList[(u32)COLPOLY_VTX_INDEX(newPoly->flags_vIA)]);
if (newNormal.y > 0.5f) {
s16 polyId = *polyStartIndex + i;
DynaSSNodeList_SetSSListHead(&dyna->polyNodes, &dyna->bgActors[bgId].dynaLookup.floor, &polyId);
} else if (newNormal.y < -0.8f) {
s16 polyId = *polyStartIndex + i;
DynaSSNodeList_SetSSListHead(&dyna->polyNodes, &dyna->bgActors[bgId].dynaLookup.ceiling, &polyId);
} else {
s16 polyId = *polyStartIndex + i;
DynaSSNodeList_SetSSListHead(&dyna->polyNodes, &dyna->bgActors[bgId].dynaLookup.wall, &polyId);
}
}
*polyStartIndex += pbgdata->numPolygons;
*vtxStartIndex += pbgdata->numVertices;
} }
void DynaPoly_UnsetAllInteractFlags(PlayState* play, DynaCollisionContext* dyna, Actor* actor) { void DynaPoly_UnsetAllInteractFlags(PlayState* play, DynaCollisionContext* dyna, Actor* actor) {
@ -3155,7 +3176,7 @@ f32 BgCheck_RaycastDownDyna(DynaRaycastDown* dynaRaycastDown) {
s32 i2; s32 i2;
s32 isPaused; s32 isPaused;
DynaPolyActor* dynaActor; DynaPolyActor* dynaActor;
s32 pad; CollisionPoly* poly;
Vec3f polyVtx[3]; Vec3f polyVtx[3];
Vec3f polyNorm; Vec3f polyNorm;
u32 polyIndex; u32 polyIndex;
@ -3167,7 +3188,6 @@ f32 BgCheck_RaycastDownDyna(DynaRaycastDown* dynaRaycastDown) {
Vec3f vtx; Vec3f vtx;
f32 intersect; f32 intersect;
ScaleRotPos* curTransform; ScaleRotPos* curTransform;
CollisionPoly* poly;
result = BGCHECK_Y_MIN; result = BGCHECK_Y_MIN;
*dynaRaycastDown->bgId = BGCHECK_SCENE; *dynaRaycastDown->bgId = BGCHECK_SCENE;
@ -3239,9 +3259,12 @@ f32 BgCheck_RaycastDownDyna(DynaRaycastDown* dynaRaycastDown) {
vtxList = dynaRaycastDown->dyna->bgActors[*dynaRaycastDown->bgId].colHeader->vtxList; vtxList = dynaRaycastDown->dyna->bgActors[*dynaRaycastDown->bgId].colHeader->vtxList;
for (i2 = 0; i2 < 3; i2++) { for (i2 = 0; i2 < 3; i2++) {
s32 pad;
Math_Vec3s_ToVec3f(&vtx, &vtxList[COLPOLY_VTX_INDEX(poly->vtxData[i2])]); Math_Vec3s_ToVec3f(&vtx, &vtxList[COLPOLY_VTX_INDEX(poly->vtxData[i2])]);
SkinMatrix_Vec3fMtxFMultXYZ(&srpMtx, &vtx, &polyVtx[i2]); SkinMatrix_Vec3fMtxFMultXYZ(&srpMtx, &vtx, &polyVtx[i2]);
} }
Math3D_SurfaceNorm(&polyVtx[0], &polyVtx[1], &polyVtx[2], &polyNorm); Math3D_SurfaceNorm(&polyVtx[0], &polyVtx[1], &polyVtx[2], &polyNorm);
magnitude = Math3D_Vec3fMagnitude(&polyNorm); magnitude = Math3D_Vec3fMagnitude(&polyNorm);
@ -3290,8 +3313,6 @@ s32 BgCheck_SphVsDynaWallInBgActor(CollisionContext* colCtx, u16 xpFlags, DynaCo
f32 invNormalXZ; f32 invNormalXZ;
f32 planeDist; f32 planeDist;
f32 temp_f18; f32 temp_f18;
f32 zIntersectDist;
f32 xIntersectDist;
f32 zMin; f32 zMin;
f32 zMax; f32 zMax;
f32 xMin; f32 xMin;
@ -3360,8 +3381,10 @@ s32 BgCheck_SphVsDynaWallInBgActor(CollisionContext* colCtx, u16 xpFlags, DynaCo
} }
} }
if (CollisionPoly_CheckZIntersectApprox(poly, dyna->vtxList, resultPos.x, pos->y, &intersect)) { if (CollisionPoly_CheckZIntersectApprox(poly, dyna->vtxList, resultPos.x, pos->y, &intersect)) {
if (fabsf(intersect - resultPos.z) <= radius / temp_f18) { f32 zIntersectDist = intersect - resultPos.z;
if ((intersect - resultPos.z) * nz <= 4.0f) {
if (fabsf(zIntersectDist) <= radius / temp_f18) {
if (zIntersectDist * nz <= 4.0f) {
if (BgCheck_ComputeWallDisplacement(colCtx, poly, &resultPos.x, &resultPos.z, nx, ny, nz, if (BgCheck_ComputeWallDisplacement(colCtx, poly, &resultPos.x, &resultPos.z, nx, ny, nz,
invNormalXZ, planeDist, radius, outPoly)) { invNormalXZ, planeDist, radius, outPoly)) {
*outBgId = bgId; *outBgId = bgId;
@ -3434,7 +3457,8 @@ s32 BgCheck_SphVsDynaWallInBgActor(CollisionContext* colCtx, u16 xpFlags, DynaCo
} }
if (CollisionPoly_CheckXIntersectApprox(poly, dyna->vtxList, pos->y, resultPos.z, &intersect)) { if (CollisionPoly_CheckXIntersectApprox(poly, dyna->vtxList, pos->y, resultPos.z, &intersect)) {
xIntersectDist = intersect - resultPos.x; f32 xIntersectDist = intersect - resultPos.x;
if (fabsf(xIntersectDist) <= radius / temp_f18) { if (fabsf(xIntersectDist) <= radius / temp_f18) {
if (xIntersectDist * nx <= 4.0f) { if (xIntersectDist * nx <= 4.0f) {
if (BgCheck_ComputeWallDisplacement(colCtx, poly, &resultPos.x, &resultPos.z, nx, ny, nz, if (BgCheck_ComputeWallDisplacement(colCtx, poly, &resultPos.x, &resultPos.z, nx, ny, nz,
@ -4223,6 +4247,8 @@ f32 sZorasDomainWaterBoxMaxZ = -967.0f;
s32 WaterBox_GetSurface1(PlayState* play, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface, s32 WaterBox_GetSurface1(PlayState* play, CollisionContext* colCtx, f32 x, f32 z, f32* ySurface,
WaterBox** outWaterBox) { WaterBox** outWaterBox) {
if (play->sceneId == SCENE_ZORAS_DOMAIN) { if (play->sceneId == SCENE_ZORAS_DOMAIN) {
s32 pad;
if (sZorasDomainWaterBoxMinX < x && x < sZorasDomainWaterBoxMaxX && sZorasDomainWaterBoxMinY < *ySurface && if (sZorasDomainWaterBoxMinX < x && x < sZorasDomainWaterBoxMaxX && sZorasDomainWaterBoxMinY < *ySurface &&
*ySurface < sZorasDomainWaterBoxMaxY && sZorasDomainWaterBoxMinZ < z && z < sZorasDomainWaterBoxMaxZ) { *ySurface < sZorasDomainWaterBoxMaxY && sZorasDomainWaterBoxMinZ < z && z < sZorasDomainWaterBoxMaxZ) {
*outWaterBox = &sZorasDomainWaterBox; *outWaterBox = &sZorasDomainWaterBox;

View file

@ -7048,12 +7048,16 @@ void Camera_Init(Camera* camera, View* view, CollisionContext* colCtx, PlayState
R_CAM_DATA(i) = sCamDataRegsInit[i]; R_CAM_DATA(i) = sCamDataRegsInit[i];
} }
#if OOT_DEBUG
DebugCamera_Reset(camera, &D_8015BD80); DebugCamera_Reset(camera, &D_8015BD80);
#endif
sInitRegs = false; sInitRegs = false;
PREG(88) = -1; PREG(88) = -1;
} }
camera->play = D_8015BD7C = play; camera->play = D_8015BD7C = play;
#if OOT_DEBUG
DebugCamera_Init(&D_8015BD80, camera); DebugCamera_Init(&D_8015BD80, camera);
#endif
curUID = sNextUID; curUID = sNextUID;
sNextUID++; sNextUID++;
while (curUID != 0) { while (curUID != 0) {
@ -7722,7 +7726,9 @@ Vec3s Camera_Update(Camera* camera) {
if (CHECK_BTN_ALL(D_8015BD7C->state.input[2].press.button, BTN_START)) { if (CHECK_BTN_ALL(D_8015BD7C->state.input[2].press.button, BTN_START)) {
gDebugCamEnabled ^= 1; gDebugCamEnabled ^= 1;
if (gDebugCamEnabled) { if (gDebugCamEnabled) {
#if OOT_DEBUG
DebugCamera_Enable(&D_8015BD80, camera); DebugCamera_Enable(&D_8015BD80, camera);
#endif
} else if (camera->play->csCtx.state != CS_STATE_IDLE) { } else if (camera->play->csCtx.state != CS_STATE_IDLE) {
Cutscene_StopManual(camera->play, &camera->play->csCtx); Cutscene_StopManual(camera->play, &camera->play->csCtx);
} }
@ -7731,7 +7737,9 @@ Vec3s Camera_Update(Camera* camera) {
// Debug cam update // Debug cam update
if (gDebugCamEnabled) { if (gDebugCamEnabled) {
camera->play->view.fovy = D_8015BD80.fov; camera->play->view.fovy = D_8015BD80.fov;
#if OOT_DEBUG
DebugCamera_Update(&D_8015BD80, camera); DebugCamera_Update(&D_8015BD80, camera);
#endif
View_LookAt(&camera->play->view, &D_8015BD80.eye, &D_8015BD80.at, &D_8015BD80.unk_1C); View_LookAt(&camera->play->view, &D_8015BD80.eye, &D_8015BD80.at, &D_8015BD80.unk_1C);
if (R_DEBUG_CAM_UPDATE) { if (R_DEBUG_CAM_UPDATE) {
PRINTF("camera: debug out\n"); PRINTF("camera: debug out\n");

View file

@ -1,7 +1,6 @@
#include "global.h" #include "global.h"
// The use of ALIGNED8 here is just a temporary solution until the SaveContext is re-structured ALIGNED(16) SaveContext gSaveContext;
ALIGNED8 SaveContext gSaveContext;
u32 D_8015FA88; u32 D_8015FA88;
u32 D_8015FA8C; u32 D_8015FA8C;

View file

@ -29,6 +29,7 @@ Color_RGBA8 sDebugCamTextColors[] = {
{ 128, 255, 32, 128 }, // DEBUG_CAM_TEXT_GREEN { 128, 255, 32, 128 }, // DEBUG_CAM_TEXT_GREEN
}; };
#if OOT_DEBUG
InputCombo sRegGroupInputCombos[REG_GROUPS] = { InputCombo sRegGroupInputCombos[REG_GROUPS] = {
{ BTN_L, BTN_CUP }, // REG { BTN_L, BTN_CUP }, // REG
{ BTN_L, BTN_CLEFT }, // SREG { BTN_L, BTN_CLEFT }, // SREG
@ -93,6 +94,7 @@ char sRegGroupChars[REG_GROUPS] = {
'k', // kREG 'k', // kREG
'b', // bREG 'b', // bREG
}; };
#endif
void Regs_Init(void) { void Regs_Init(void) {
s32 i; s32 i;

View file

@ -40,6 +40,22 @@ Gfx sTransTileSetupDL[] = {
gsSPEndDisplayList(), gsSPEndDisplayList(),
}; };
#define SET_VERTEX(vtx, x, y, z, s, t, nx, ny, nz, alpha) \
{ \
Vtx_tn* vtxn = &(vtx)->n; \
vtxn->ob[0] = (x); \
vtxn->ob[1] = (y); \
vtxn->ob[2] = (z); \
vtxn->flag = 0; \
vtxn->tc[0] = (s); \
vtxn->tc[1] = (t); \
vtxn->n[0] = (nx); \
vtxn->n[1] = (ny); \
vtxn->n[2] = (nz); \
vtxn->a = (alpha); \
} \
(void)0
void TransitionTile_InitGraphics(TransitionTile* this) { void TransitionTile_InitGraphics(TransitionTile* this) {
s32 frame; s32 frame;
s32 col; s32 col;
@ -61,20 +77,7 @@ void TransitionTile_InitGraphics(TransitionTile* this) {
for (row = 0; row < this->rows + 1; row++) { for (row = 0; row < this->rows + 1; row++) {
colTex = 0; colTex = 0;
for (col = 0; col < this->cols + 1; col++) { for (col = 0; col < this->cols + 1; col++) {
Vtx_tn* vtxn = &vtx->n; SET_VERTEX(vtx++, col * 0x20, row * 0x20, -5, colTex << 6, rowTex << 6, 0, 0, 120, 255);
vtx++;
vtxn->tc[0] = colTex << 6;
vtxn->ob[0] = col * 0x20;
vtxn->ob[1] = row * 0x20;
vtxn->ob[2] = -5;
vtxn->flag = 0;
vtxn->tc[1] = rowTex << 6;
vtxn->n[0] = 0;
vtxn->n[1] = 0;
vtxn->n[2] = 120;
vtxn->a = 255;
colTex += 0x20; colTex += 0x20;
} }

View file

@ -62,7 +62,7 @@ void TransitionFade_Update(void* thisx, s32 updateRate) {
break; break;
case TRANS_FADE_TYPE_ONE_WAY: case TRANS_FADE_TYPE_ONE_WAY:
this->timer += updateRate; ((TransitionFade*)thisx)->timer += updateRate;
if (this->timer >= gSaveContext.transFadeDuration) { if (this->timer >= gSaveContext.transFadeDuration) {
this->timer = gSaveContext.transFadeDuration; this->timer = gSaveContext.transFadeDuration;
this->isDone = true; this->isDone = true;

View file

@ -162,6 +162,8 @@ void SkelCurve_DrawLimb(PlayState* play, s32 limbIndex, SkelCurve* skelCurve, Ov
OPEN_DISPS(play->state.gfxCtx, "../z_fcurve_data_skelanime.c", 279); OPEN_DISPS(play->state.gfxCtx, "../z_fcurve_data_skelanime.c", 279);
if (1) {}
Matrix_Push(); Matrix_Push();
if ((overrideLimbDraw == NULL) || if ((overrideLimbDraw == NULL) ||

View file

@ -80,9 +80,10 @@ void KaleidoManager_Destroy(void) {
void* KaleidoManager_GetRamAddr(void* vram) { void* KaleidoManager_GetRamAddr(void* vram) {
KaleidoMgrOverlay* iter = gKaleidoMgrCurOvl; KaleidoMgrOverlay* iter = gKaleidoMgrCurOvl;
KaleidoMgrOverlay* ovl = iter; KaleidoMgrOverlay* ovl = iter;
u32 i;
if (ovl == NULL) { if (ovl == NULL) {
u32 i;
iter = &gKaleidoMgrOverlayTable[0]; iter = &gKaleidoMgrOverlayTable[0];
for (i = 0; i < ARRAY_COUNT(gKaleidoMgrOverlayTable); i++) { for (i = 0; i < ARRAY_COUNT(gKaleidoMgrOverlayTable); i++) {
if (((uintptr_t)vram >= (uintptr_t)iter->vramStart) && ((uintptr_t)iter->vramEnd >= (uintptr_t)vram)) { if (((uintptr_t)vram >= (uintptr_t)iter->vramStart) && ((uintptr_t)iter->vramEnd >= (uintptr_t)vram)) {

View file

@ -56,19 +56,25 @@ void KaleidoScopeCall_Update(PlayState* play) {
KaleidoMgrOverlay* kaleidoScopeOvl = &gKaleidoMgrOverlayTable[KALEIDO_OVL_KALEIDO_SCOPE]; KaleidoMgrOverlay* kaleidoScopeOvl = &gKaleidoMgrOverlayTable[KALEIDO_OVL_KALEIDO_SCOPE];
PauseContext* pauseCtx = &play->pauseCtx; PauseContext* pauseCtx = &play->pauseCtx;
if (IS_PAUSED(pauseCtx)) { if (IS_PAUSED(&play->pauseCtx)) {
if (pauseCtx->state == PAUSE_STATE_WAIT_LETTERBOX) { if (pauseCtx->state == PAUSE_STATE_WAIT_LETTERBOX) {
if (Letterbox_GetSize() == 0) { if (Letterbox_GetSize() == 0) {
#if OOT_DEBUG
R_HREG_MODE = HREG_MODE_UCODE_DISAS; R_HREG_MODE = HREG_MODE_UCODE_DISAS;
R_UCODE_DISAS_LOG_MODE = 3; R_UCODE_DISAS_LOG_MODE = 3;
#endif
R_PAUSE_BG_PRERENDER_STATE = PAUSE_BG_PRERENDER_SETUP; R_PAUSE_BG_PRERENDER_STATE = PAUSE_BG_PRERENDER_SETUP;
pauseCtx->mainState = PAUSE_MAIN_STATE_IDLE; pauseCtx->mainState = PAUSE_MAIN_STATE_IDLE;
pauseCtx->savePromptState = PAUSE_SAVE_PROMPT_STATE_APPEARING; pauseCtx->savePromptState = PAUSE_SAVE_PROMPT_STATE_APPEARING;
pauseCtx->state = (pauseCtx->state & 0xFFFF) + 1; // PAUSE_STATE_WAIT_BG_PRERENDER pauseCtx->state = (pauseCtx->state & 0xFFFF) + 1; // PAUSE_STATE_WAIT_BG_PRERENDER
} }
} else if (pauseCtx->state == PAUSE_STATE_8) { } else if (pauseCtx->state == PAUSE_STATE_8) {
#if OOT_DEBUG
R_HREG_MODE = HREG_MODE_UCODE_DISAS; R_HREG_MODE = HREG_MODE_UCODE_DISAS;
R_UCODE_DISAS_LOG_MODE = 3; R_UCODE_DISAS_LOG_MODE = 3;
#endif
R_PAUSE_BG_PRERENDER_STATE = PAUSE_BG_PRERENDER_SETUP; R_PAUSE_BG_PRERENDER_STATE = PAUSE_BG_PRERENDER_SETUP;
pauseCtx->mainState = PAUSE_MAIN_STATE_IDLE; pauseCtx->mainState = PAUSE_MAIN_STATE_IDLE;
pauseCtx->savePromptState = PAUSE_SAVE_PROMPT_STATE_APPEARING; pauseCtx->savePromptState = PAUSE_SAVE_PROMPT_STATE_APPEARING;

View file

@ -50,7 +50,7 @@ void KaleidoSetup_Update(PlayState* play) {
(play->sceneId != SCENE_BOMBCHU_BOWLING_ALLEY || !Flags_GetSwitch(play, 0x38))) { (play->sceneId != SCENE_BOMBCHU_BOWLING_ALLEY || !Flags_GetSwitch(play, 0x38))) {
if (CHECK_BTN_ALL(input->cur.button, BTN_L) && CHECK_BTN_ALL(input->press.button, BTN_CUP)) { if (CHECK_BTN_ALL(input->cur.button, BTN_L) && CHECK_BTN_ALL(input->press.button, BTN_CUP)) {
if (BREG(0)) { if (OOT_DEBUG && BREG(0)) {
pauseCtx->debugState = 3; pauseCtx->debugState = 3;
} }
} else if (CHECK_BTN_ALL(input->press.button, BTN_START)) { } else if (CHECK_BTN_ALL(input->press.button, BTN_START)) {
@ -102,22 +102,23 @@ void KaleidoSetup_Update(PlayState* play) {
void KaleidoSetup_Init(PlayState* play) { void KaleidoSetup_Init(PlayState* play) {
PauseContext* pauseCtx = &play->pauseCtx; PauseContext* pauseCtx = &play->pauseCtx;
u64 temp = 0; // Necessary to match
pauseCtx->state = PAUSE_STATE_OFF; pauseCtx->state = PAUSE_STATE_OFF;
pauseCtx->debugState = 0; pauseCtx->debugState = 0;
pauseCtx->alpha = 0;
pauseCtx->switchPageTimer = 0;
pauseCtx->mainState = PAUSE_MAIN_STATE_IDLE;
pauseCtx->nextPageMode = 0;
pauseCtx->pageIndex = PAUSE_ITEM;
pauseCtx->itemPageRoll = pauseCtx->equipPageRoll = pauseCtx->mapPageRoll = pauseCtx->questPageRoll = 160.0f;
// Setting the eye xz here is irrelevant, it's set on pausing in KaleidoSetup_Update // Setting the eye xz here is irrelevant, it's set on pausing in KaleidoSetup_Update
// x = -PAUSE_EYE_DIST * PAUSE_ITEM_X
pauseCtx->eye.x = pauseCtx->eye.y = 0.0f;
pauseCtx->eye.z = -PAUSE_EYE_DIST * PAUSE_ITEM_Z; pauseCtx->eye.z = -PAUSE_EYE_DIST * PAUSE_ITEM_Z;
pauseCtx->eye.y = 0.0f;
pauseCtx->eye.x = 0.0f; // -PAUSE_EYE_DIST * PAUSE_ITEM_X
pauseCtx->savePromptOffsetDepth_ = 936.0f; pauseCtx->savePromptOffsetDepth_ = 936.0f;
pauseCtx->itemPageRoll = pauseCtx->equipPageRoll = pauseCtx->mapPageRoll = pauseCtx->questPageRoll = 160.0f;
pauseCtx->alpha = 0;
// mainState = PAUSE_MAIN_STATE_IDLE , pageIndex = PAUSE_ITEM
pauseCtx->switchPageTimer = pauseCtx->mainState = pauseCtx->nextPageMode = pauseCtx->pageIndex = 0;
pauseCtx->rollRotSavePrompt_ = -314.0f; pauseCtx->rollRotSavePrompt_ = -314.0f;
pauseCtx->cursorPoint[PAUSE_ITEM] = 0; pauseCtx->cursorPoint[PAUSE_ITEM] = 0;
@ -130,8 +131,8 @@ void KaleidoSetup_Init(PlayState* play) {
pauseCtx->cursorY[PAUSE_ITEM] = 0; pauseCtx->cursorY[PAUSE_ITEM] = 0;
pauseCtx->cursorX[PAUSE_MAP] = 0; pauseCtx->cursorX[PAUSE_MAP] = 0;
pauseCtx->cursorY[PAUSE_MAP] = 0; pauseCtx->cursorY[PAUSE_MAP] = 0;
pauseCtx->cursorX[PAUSE_QUEST] = temp; pauseCtx->cursorX[PAUSE_QUEST] = 0;
pauseCtx->cursorY[PAUSE_QUEST] = temp; pauseCtx->cursorY[PAUSE_QUEST] = 0;
pauseCtx->cursorX[PAUSE_EQUIP] = EQUIP_VALUE_SWORD_KOKIRI; pauseCtx->cursorX[PAUSE_EQUIP] = EQUIP_VALUE_SWORD_KOKIRI;
pauseCtx->cursorY[PAUSE_EQUIP] = EQUIP_TYPE_SWORD; pauseCtx->cursorY[PAUSE_EQUIP] = EQUIP_TYPE_SWORD;

View file

@ -9,8 +9,10 @@ void func_8006EE50(Font* font, u16 arg1, u16 arg2) {
* at `codePointIndex`. The value of `character` is the ASCII codepoint subtract ' '/0x20. * at `codePointIndex`. The value of `character` is the ASCII codepoint subtract ' '/0x20.
*/ */
void Font_LoadChar(Font* font, u8 character, u16 codePointIndex) { void Font_LoadChar(Font* font, u8 character, u16 codePointIndex) {
u8 charTmp = character;
DMA_REQUEST_SYNC(&font->charTexBuf[codePointIndex], DMA_REQUEST_SYNC(&font->charTexBuf[codePointIndex],
(uintptr_t)_nes_font_staticSegmentRomStart + character * FONT_CHAR_TEX_SIZE, FONT_CHAR_TEX_SIZE, (uintptr_t)_nes_font_staticSegmentRomStart + charTmp * FONT_CHAR_TEX_SIZE, FONT_CHAR_TEX_SIZE,
"../z_kanfont.c", 93); "../z_kanfont.c", 93);
} }
@ -31,10 +33,7 @@ void Font_LoadMessageBoxIcon(Font* font, u16 icon) {
* the font buffer. * the font buffer.
*/ */
void Font_LoadOrderedFont(Font* font) { void Font_LoadOrderedFont(Font* font) {
u8* fontBuf;
uintptr_t fontStatic;
s32 len; s32 len;
s32 jj;
s32 codePointIndex; s32 codePointIndex;
s32 fontBufIndex; s32 fontBufIndex;
u32 offset; u32 offset;
@ -44,23 +43,22 @@ void Font_LoadOrderedFont(Font* font) {
DMA_REQUEST_SYNC(font->msgBuf, (uintptr_t)_nes_message_data_staticSegmentRomStart + font->msgOffset, len, DMA_REQUEST_SYNC(font->msgBuf, (uintptr_t)_nes_message_data_staticSegmentRomStart + font->msgOffset, len,
"../z_kanfont.c", 122); "../z_kanfont.c", 122);
PRINTF("msg_data=%x, msg_data0=%x jj=%x\n", font->msgOffset, font->msgLength, jj = len);
len = jj; PRINTF("msg_data=%x, msg_data0=%x jj=%x\n", font->msgOffset, font->msgLength, len * 1);
for (fontBufIndex = 0, codePointIndex = 0; font->msgBuf[codePointIndex] != MESSAGE_END; codePointIndex++) {
if (codePointIndex > len) { fontBufIndex = 0;
for (codePointIndex = 0; font->msgBuf[codePointIndex] != MESSAGE_END; codePointIndex++) {
if (codePointIndex > (len * 1)) {
PRINTF(" エラー!!! error───\n"); PRINTF(" エラー!!! error───\n");
return; return;
} }
if (font->msgBuf[codePointIndex] != MESSAGE_NEWLINE) { if (font->msgBuf[codePointIndex] != MESSAGE_NEWLINE) {
fontBuf = font->fontBuf + fontBufIndex * 8;
fontStatic = (uintptr_t)_nes_font_staticSegmentRomStart;
PRINTF("nes_mes_buf[%d]=%d\n", codePointIndex, font->msgBuf[codePointIndex]); PRINTF("nes_mes_buf[%d]=%d\n", codePointIndex, font->msgBuf[codePointIndex]);
offset = (font->msgBuf[codePointIndex] - ' ') * FONT_CHAR_TEX_SIZE; offset = (font->msgBuf[codePointIndex] - ' ') * FONT_CHAR_TEX_SIZE;
DMA_REQUEST_SYNC(fontBuf, fontStatic + offset, FONT_CHAR_TEX_SIZE, "../z_kanfont.c", 134); DMA_REQUEST_SYNC(font->fontBuf + fontBufIndex * 8, (uintptr_t)_nes_font_staticSegmentRomStart + offset,
FONT_CHAR_TEX_SIZE, "../z_kanfont.c", 134);
fontBufIndex += FONT_CHAR_TEX_SIZE / 8; fontBufIndex += FONT_CHAR_TEX_SIZE / 8;
} }
} }

View file

@ -252,7 +252,8 @@ void Environment_Init(PlayState* play2, EnvironmentContext* envCtx, s32 unused)
gSaveContext.sunsSongState = SUNSSONG_INACTIVE; gSaveContext.sunsSongState = SUNSSONG_INACTIVE;
if (((void)0, gSaveContext.save.dayTime) > CLOCK_TIME(18, 0) || //! FAKE: (void)0 on CLOCK_TIME(18, 0)
if (((void)0, gSaveContext.save.dayTime) > ((void)0, CLOCK_TIME(18, 0)) ||
((void)0, gSaveContext.save.dayTime) < CLOCK_TIME(6, 30)) { ((void)0, gSaveContext.save.dayTime) < CLOCK_TIME(6, 30)) {
((void)0, gSaveContext.save.nightFlag = 1); ((void)0, gSaveContext.save.nightFlag = 1);
} else { } else {
@ -335,12 +336,17 @@ void Environment_Init(PlayState* play2, EnvironmentContext* envCtx, s32 unused)
envCtx->lightSettingOverride = LIGHT_SETTING_OVERRIDE_NONE; envCtx->lightSettingOverride = LIGHT_SETTING_OVERRIDE_NONE;
envCtx->lightBlendRateOverride = LIGHT_BLENDRATE_OVERRIDE_NONE; envCtx->lightBlendRateOverride = LIGHT_BLENDRATE_OVERRIDE_NONE;
R_ENV_TIME_SPEED_OLD = gTimeSpeed = envCtx->sceneTimeSpeed = 0; envCtx->sceneTimeSpeed = 0;
gTimeSpeed = envCtx->sceneTimeSpeed;
#if OOT_DEBUG
R_ENV_TIME_SPEED_OLD = gTimeSpeed;
R_ENV_DISABLE_DBG = true; R_ENV_DISABLE_DBG = true;
if (CREG(3) != 0) { if (CREG(3) != 0) {
gSaveContext.chamberCutsceneNum = CREG(3) - 1; gSaveContext.chamberCutsceneNum = CREG(3) - 1;
} }
#endif
play->envCtx.precipitation[PRECIP_RAIN_MAX] = 0; play->envCtx.precipitation[PRECIP_RAIN_MAX] = 0;
play->envCtx.precipitation[PRECIP_RAIN_CUR] = 0; play->envCtx.precipitation[PRECIP_RAIN_CUR] = 0;
@ -405,6 +411,7 @@ void Environment_Init(PlayState* play2, EnvironmentContext* envCtx, s32 unused)
gSkyboxIsChanging = false; gSkyboxIsChanging = false;
gSaveContext.retainWeatherMode = false; gSaveContext.retainWeatherMode = false;
#if OOT_DEBUG
R_ENV_LIGHT1_DIR(0) = 80; R_ENV_LIGHT1_DIR(0) = 80;
R_ENV_LIGHT1_DIR(1) = 80; R_ENV_LIGHT1_DIR(1) = 80;
R_ENV_LIGHT1_DIR(2) = 80; R_ENV_LIGHT1_DIR(2) = 80;
@ -419,6 +426,8 @@ void Environment_Init(PlayState* play2, EnvironmentContext* envCtx, s32 unused)
cREG(12) = 0; cREG(12) = 0;
cREG(13) = 0; cREG(13) = 0;
cREG(14) = 0; cREG(14) = 0;
#endif
gUseCutsceneCam = true; gUseCutsceneCam = true;
for (i = 0; i < ARRAY_COUNT(sLightningBolts); i++) { for (i = 0; i < ARRAY_COUNT(sLightningBolts); i++) {
@ -512,10 +521,9 @@ u8 Environment_SmoothStepToS8(s8* pvalue, s8 target, u8 scale, u8 step, u8 minSt
f32 Environment_LerpWeight(u16 max, u16 min, u16 val) { f32 Environment_LerpWeight(u16 max, u16 min, u16 val) {
f32 diff = max - min; f32 diff = max - min;
f32 ret;
if (diff != 0.0f) { if (diff != 0.0f) {
ret = 1.0f - (max - val) / diff; f32 ret = 1.0f - (max - val) / diff;
if (!(ret >= 1.0f)) { if (!(ret >= 1.0f)) {
return ret; return ret;
@ -700,10 +708,12 @@ void Environment_UpdateSkybox(u8 skyboxId, EnvironmentContext* envCtx, SkyboxCon
} }
} }
#if OOT_DEBUG
if (newSkybox1Index == 0xFF) { if (newSkybox1Index == 0xFF) {
// "Environment VR data acquisition failed! Report to Sasaki!" // "Environment VR data acquisition failed! Report to Sasaki!"
PRINTF(VT_COL(RED, WHITE) "\n環境VRデータ取得失敗! ささきまでご報告を!" VT_RST); PRINTF(VT_COL(RED, WHITE) "\n環境VRデータ取得失敗! ささきまでご報告を!" VT_RST);
} }
#endif
if ((envCtx->skybox1Index != newSkybox1Index) && (envCtx->skyboxDmaState == SKYBOX_DMA_INACTIVE)) { if ((envCtx->skybox1Index != newSkybox1Index) && (envCtx->skyboxDmaState == SKYBOX_DMA_INACTIVE)) {
envCtx->skyboxDmaState = SKYBOX_DMA_TEXTURE1_START; envCtx->skyboxDmaState = SKYBOX_DMA_TEXTURE1_START;
@ -815,6 +825,7 @@ void Environment_DisableUnderwaterLights(PlayState* play) {
} }
} }
#if OOT_DEBUG
void Environment_PrintDebugInfo(PlayState* play, Gfx** gfx) { void Environment_PrintDebugInfo(PlayState* play, Gfx** gfx) {
GfxPrint printer; GfxPrint printer;
s32 pad[2]; s32 pad[2];
@ -869,6 +880,7 @@ void Environment_PrintDebugInfo(PlayState* play, Gfx** gfx) {
*gfx = GfxPrint_Close(&printer); *gfx = GfxPrint_Close(&printer);
GfxPrint_Destroy(&printer); GfxPrint_Destroy(&printer);
} }
#endif
void Environment_PlayTimeBasedSequence(PlayState* play); void Environment_PlayTimeBasedSequence(PlayState* play);
void Environment_UpdateRain(PlayState* play); void Environment_UpdateRain(PlayState* play);
@ -881,7 +893,7 @@ void Environment_Update(PlayState* play, EnvironmentContext* envCtx, LightContex
u16 j; u16 j;
u16 time; u16 time;
EnvLightSettings* lightSettingsList = play->envCtx.lightSettingsList; EnvLightSettings* lightSettingsList = play->envCtx.lightSettingsList;
s32 adjustment; u8 blendRate;
if ((((void)0, gSaveContext.gameMode) != GAMEMODE_NORMAL) && if ((((void)0, gSaveContext.gameMode) != GAMEMODE_NORMAL) &&
(((void)0, gSaveContext.gameMode) != GAMEMODE_END_CREDITS)) { (((void)0, gSaveContext.gameMode) != GAMEMODE_END_CREDITS)) {
@ -951,6 +963,7 @@ void Environment_Update(PlayState* play, EnvironmentContext* envCtx, LightContex
gSaveContext.save.nightFlag = 0; gSaveContext.save.nightFlag = 0;
} }
#if OOT_DEBUG
if (R_ENABLE_ARENA_DBG != 0 || CREG(2) != 0) { if (R_ENABLE_ARENA_DBG != 0 || CREG(2) != 0) {
Gfx* displayList; Gfx* displayList;
Gfx* prevDisplayList; Gfx* prevDisplayList;
@ -967,249 +980,247 @@ void Environment_Update(PlayState* play, EnvironmentContext* envCtx, LightContex
if (1) {} if (1) {}
CLOSE_DISPS(play->state.gfxCtx, "../z_kankyo.c", 1690); CLOSE_DISPS(play->state.gfxCtx, "../z_kankyo.c", 1690);
} }
#endif
if ((envCtx->lightSettingOverride != LIGHT_SETTING_OVERRIDE_NONE) && if ((envCtx->lightSettingOverride != LIGHT_SETTING_OVERRIDE_NONE) &&
(envCtx->lightBlendOverride != LIGHT_BLEND_OVERRIDE_FULL_CONTROL) && (envCtx->lightBlendOverride != LIGHT_BLEND_OVERRIDE_FULL_CONTROL) &&
(envCtx->lightSetting != envCtx->lightSettingOverride) && (envCtx->lightBlend >= 1.0f) && (envCtx->lightSetting != envCtx->lightSettingOverride) && (envCtx->lightBlend >= 1.0f) &&
(envCtx->lightSettingOverride <= LIGHT_SETTING_MAX)) { (envCtx->lightSettingOverride <= LIGHT_SETTING_MAX)) {
envCtx->lightBlend = 0.0f;
envCtx->prevLightSetting = envCtx->lightSetting; envCtx->prevLightSetting = envCtx->lightSetting;
envCtx->lightSetting = envCtx->lightSettingOverride; envCtx->lightSetting = envCtx->lightSettingOverride;
envCtx->lightBlend = 0.0f;
} }
if (envCtx->lightSettingOverride != LIGHT_SETTING_OVERRIDE_FULL_CONTROL) { if (envCtx->lightSettingOverride == LIGHT_SETTING_OVERRIDE_FULL_CONTROL) {
if ((envCtx->lightMode == LIGHT_MODE_TIME) && // Do nothing; Skip updating lights based on time or light settings
(envCtx->lightSettingOverride == LIGHT_SETTING_OVERRIDE_NONE)) { } else if ((envCtx->lightMode == LIGHT_MODE_TIME) &&
for (i = 0; i < ARRAY_COUNT(sTimeBasedLightConfigs[envCtx->lightConfig]); i++) { (envCtx->lightSettingOverride == LIGHT_SETTING_OVERRIDE_NONE)) {
if ((gSaveContext.skyboxTime >= sTimeBasedLightConfigs[envCtx->lightConfig][i].startTime) && for (i = 0; i < ARRAY_COUNT(sTimeBasedLightConfigs[envCtx->lightConfig]); i++) {
((gSaveContext.skyboxTime < sTimeBasedLightConfigs[envCtx->lightConfig][i].endTime) || if ((gSaveContext.skyboxTime >= sTimeBasedLightConfigs[envCtx->lightConfig][i].startTime) &&
sTimeBasedLightConfigs[envCtx->lightConfig][i].endTime == 0xFFFF)) { ((gSaveContext.skyboxTime < sTimeBasedLightConfigs[envCtx->lightConfig][i].endTime) ||
u8 blend8[2]; sTimeBasedLightConfigs[envCtx->lightConfig][i].endTime == 0xFFFF)) {
s16 blend16[2]; u8 blend8[2];
s16 blend16[2];
timeChangeBlend = timeChangeBlend = Environment_LerpWeight(sTimeBasedLightConfigs[envCtx->lightConfig][i].endTime,
Environment_LerpWeight(sTimeBasedLightConfigs[envCtx->lightConfig][i].endTime, sTimeBasedLightConfigs[envCtx->lightConfig][i].startTime,
sTimeBasedLightConfigs[envCtx->lightConfig][i].startTime, ((void)0, gSaveContext.skyboxTime));
((void)0, gSaveContext.skyboxTime));
sSandstormColorIndex = sTimeBasedLightConfigs[envCtx->lightConfig][i].lightSetting & 3; sSandstormColorIndex = sTimeBasedLightConfigs[envCtx->lightConfig][i].lightSetting & 3;
sNextSandstormColorIndex = sTimeBasedLightConfigs[envCtx->lightConfig][i].nextLightSetting & 3; sNextSandstormColorIndex = sTimeBasedLightConfigs[envCtx->lightConfig][i].nextLightSetting & 3;
sSandstormLerpScale = timeChangeBlend; sSandstormLerpScale = timeChangeBlend;
if (envCtx->changeLightEnabled) { if (envCtx->changeLightEnabled) {
configChangeBlend = configChangeBlend =
((f32)envCtx->changeDuration - envCtx->changeLightTimer) / envCtx->changeDuration; ((f32)envCtx->changeDuration - envCtx->changeLightTimer) / envCtx->changeDuration;
envCtx->changeLightTimer--; envCtx->changeLightTimer--;
if (envCtx->changeLightTimer <= 0) { if (envCtx->changeLightTimer <= 0) {
envCtx->changeLightEnabled = false; envCtx->changeLightEnabled = false;
envCtx->lightConfig = envCtx->changeLightNextConfig; envCtx->lightConfig = envCtx->changeLightNextConfig;
}
} }
}
for (j = 0; j < 3; j++) { for (j = 0; j < 3; j++) {
// blend ambient color // blend ambient color
blend8[0] = blend8[0] =
LERP(lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].lightSetting] LERP(lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].lightSetting]
.ambientColor[j], .ambientColor[j],
lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].nextLightSetting] lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].nextLightSetting]
.ambientColor[j], .ambientColor[j],
timeChangeBlend); timeChangeBlend);
blend8[1] = LERP( blend8[1] = LERP(
lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].lightSetting]
.ambientColor[j],
lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i]
.nextLightSetting]
.ambientColor[j],
timeChangeBlend);
*(envCtx->lightSettings.ambientColor + j) = LERP(blend8[0], blend8[1], configChangeBlend);
}
// set light1 direction for the sun
envCtx->lightSettings.light1Dir[0] =
-(Math_SinS(((void)0, gSaveContext.save.dayTime) - CLOCK_TIME(12, 0)) * 120.0f);
envCtx->lightSettings.light1Dir[1] =
Math_CosS(((void)0, gSaveContext.save.dayTime) - CLOCK_TIME(12, 0)) * 120.0f;
envCtx->lightSettings.light1Dir[2] =
Math_CosS(((void)0, gSaveContext.save.dayTime) - CLOCK_TIME(12, 0)) * 20.0f;
// set light2 direction for the moon
envCtx->lightSettings.light2Dir[0] = -envCtx->lightSettings.light1Dir[0];
envCtx->lightSettings.light2Dir[1] = -envCtx->lightSettings.light1Dir[1];
envCtx->lightSettings.light2Dir[2] = -envCtx->lightSettings.light1Dir[2];
for (j = 0; j < 3; j++) {
// blend light1Color
blend8[0] =
LERP(lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].lightSetting]
.light1Color[j],
lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].nextLightSetting]
.light1Color[j],
timeChangeBlend);
blend8[1] = LERP(
lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].lightSetting]
.light1Color[j],
lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i]
.nextLightSetting]
.light1Color[j],
timeChangeBlend);
*(envCtx->lightSettings.light1Color + j) = LERP(blend8[0], blend8[1], configChangeBlend);
// blend light2Color
blend8[0] =
LERP(lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].lightSetting]
.light2Color[j],
lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].nextLightSetting]
.light2Color[j],
timeChangeBlend);
blend8[1] = LERP(
lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].lightSetting]
.light2Color[j],
lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i]
.nextLightSetting]
.light2Color[j],
timeChangeBlend);
*(envCtx->lightSettings.light2Color + j) = LERP(blend8[0], blend8[1], configChangeBlend);
}
// blend fogColor
for (j = 0; j < 3; j++) {
blend8[0] =
LERP(lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].lightSetting]
.fogColor[j],
lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].nextLightSetting]
.fogColor[j],
timeChangeBlend);
blend8[1] = LERP(
lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].lightSetting]
.fogColor[j],
lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i]
.nextLightSetting]
.fogColor[j],
timeChangeBlend);
*(envCtx->lightSettings.fogColor + j) = LERP(blend8[0], blend8[1], configChangeBlend);
}
blend16[0] = LERP16(
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(
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], configChangeBlend);
blend16[0] = LERP16(
lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].lightSetting].zFar,
lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].nextLightSetting].zFar,
timeChangeBlend);
blend16[1] = LERP16(
lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].lightSetting] lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].lightSetting]
.zFar, .ambientColor[j],
lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].nextLightSetting] lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].nextLightSetting]
.zFar, .ambientColor[j],
timeChangeBlend); timeChangeBlend);
envCtx->lightSettings.ambientColor[j] = LERP(blend8[0], blend8[1], configChangeBlend);
envCtx->lightSettings.zFar = LERP16(blend16[0], blend16[1], configChangeBlend);
if (sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].nextLightSetting >=
envCtx->numLightSettings) {
// "The color palette setting seems to be wrong!"
PRINTF(VT_COL(RED, WHITE) "\nカラーパレットの設定がおかしいようです!" VT_RST);
// "Palette setting = [] Last palette number = []"
PRINTF(VT_COL(RED, WHITE) "\n設定パレット=[%d] 最後パレット番号=[%d]\n" VT_RST,
sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].nextLightSetting,
envCtx->numLightSettings - 1);
}
break;
}
}
} else {
if (!envCtx->lightBlendEnabled) {
for (i = 0; i < 3; i++) {
envCtx->lightSettings.ambientColor[i] = lightSettingsList[envCtx->lightSetting].ambientColor[i];
envCtx->lightSettings.light1Dir[i] = lightSettingsList[envCtx->lightSetting].light1Dir[i];
envCtx->lightSettings.light1Color[i] = lightSettingsList[envCtx->lightSetting].light1Color[i];
envCtx->lightSettings.light2Dir[i] = lightSettingsList[envCtx->lightSetting].light2Dir[i];
envCtx->lightSettings.light2Color[i] = lightSettingsList[envCtx->lightSetting].light2Color[i];
envCtx->lightSettings.fogColor[i] = lightSettingsList[envCtx->lightSetting].fogColor[i];
} }
envCtx->lightSettings.fogNear = // set light1 direction for the sun
ENV_LIGHT_SETTINGS_FOG_NEAR(lightSettingsList[envCtx->lightSetting].blendRateAndFogNear); envCtx->lightSettings.light1Dir[0] =
envCtx->lightSettings.zFar = lightSettingsList[envCtx->lightSetting].zFar; -(Math_SinS(((void)0, gSaveContext.save.dayTime) - CLOCK_TIME(12, 0)) * 120.0f);
envCtx->lightBlend = 1.0f; envCtx->lightSettings.light1Dir[1] =
} else { Math_CosS(((void)0, gSaveContext.save.dayTime) - CLOCK_TIME(12, 0)) * 120.0f;
u8 blendRate = envCtx->lightSettings.light1Dir[2] =
ENV_LIGHT_SETTINGS_BLEND_RATE_U8(lightSettingsList[envCtx->lightSetting].blendRateAndFogNear); Math_CosS(((void)0, gSaveContext.save.dayTime) - CLOCK_TIME(12, 0)) * 20.0f;
if (blendRate == 0) { // set light2 direction for the moon
blendRate++; envCtx->lightSettings.light2Dir[0] = -envCtx->lightSettings.light1Dir[0];
envCtx->lightSettings.light2Dir[1] = -envCtx->lightSettings.light1Dir[1];
envCtx->lightSettings.light2Dir[2] = -envCtx->lightSettings.light1Dir[2];
for (j = 0; j < 3; j++) {
// blend light1Color
blend8[0] =
LERP(lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].lightSetting]
.light1Color[j],
lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].nextLightSetting]
.light1Color[j],
timeChangeBlend);
blend8[1] = LERP(
lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].lightSetting]
.light1Color[j],
lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].nextLightSetting]
.light1Color[j],
timeChangeBlend);
envCtx->lightSettings.light1Color[j] = LERP(blend8[0], blend8[1], configChangeBlend);
// blend light2Color
blend8[0] =
LERP(lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].lightSetting]
.light2Color[j],
lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].nextLightSetting]
.light2Color[j],
timeChangeBlend);
blend8[1] = LERP(
lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].lightSetting]
.light2Color[j],
lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].nextLightSetting]
.light2Color[j],
timeChangeBlend);
envCtx->lightSettings.light2Color[j] = LERP(blend8[0], blend8[1], configChangeBlend);
} }
if (envCtx->lightBlendRateOverride != LIGHT_BLENDRATE_OVERRIDE_NONE) { // blend fogColor
blendRate = envCtx->lightBlendRateOverride; for (j = 0; j < 3; j++) {
blend8[0] = LERP(
lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].lightSetting].fogColor[j],
lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].nextLightSetting]
.fogColor[j],
timeChangeBlend);
blend8[1] = LERP(
lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].lightSetting]
.fogColor[j],
lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].nextLightSetting]
.fogColor[j],
timeChangeBlend);
envCtx->lightSettings.fogColor[j] = LERP(blend8[0], blend8[1], configChangeBlend);
} }
if (envCtx->lightBlendOverride == LIGHT_BLEND_OVERRIDE_NONE) { blend16[0] =
envCtx->lightBlend += blendRate / 255.0f; LERP16(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(
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], configChangeBlend);
blend16[0] =
LERP16(lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].lightSetting].zFar,
lightSettingsList[sTimeBasedLightConfigs[envCtx->lightConfig][i].nextLightSetting].zFar,
timeChangeBlend);
blend16[1] = LERP16(
lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].lightSetting].zFar,
lightSettingsList[sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].nextLightSetting]
.zFar,
timeChangeBlend);
envCtx->lightSettings.zFar = LERP16(blend16[0], blend16[1], configChangeBlend);
#if OOT_DEBUG
if (sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].nextLightSetting >=
envCtx->numLightSettings) {
// "The color palette setting seems to be wrong!"
PRINTF(VT_COL(RED, WHITE) "\nカラーパレットの設定がおかしいようです!" VT_RST);
// "Palette setting = [] Last palette number = []"
PRINTF(VT_COL(RED, WHITE) "\n設定パレット=[%d] 最後パレット番号=[%d]\n" VT_RST,
sTimeBasedLightConfigs[envCtx->changeLightNextConfig][i].nextLightSetting,
envCtx->numLightSettings - 1);
} }
#endif
if (envCtx->lightBlend > 1.0f) { break;
envCtx->lightBlend = 1.0f;
}
for (i = 0; i < 3; i++) {
envCtx->lightSettings.ambientColor[i] =
LERP(lightSettingsList[envCtx->prevLightSetting].ambientColor[i],
lightSettingsList[envCtx->lightSetting].ambientColor[i], envCtx->lightBlend);
envCtx->lightSettings.light1Dir[i] =
LERP16(lightSettingsList[envCtx->prevLightSetting].light1Dir[i],
lightSettingsList[envCtx->lightSetting].light1Dir[i], envCtx->lightBlend);
envCtx->lightSettings.light1Color[i] =
LERP(lightSettingsList[envCtx->prevLightSetting].light1Color[i],
lightSettingsList[envCtx->lightSetting].light1Color[i], envCtx->lightBlend);
envCtx->lightSettings.light2Dir[i] =
LERP16(lightSettingsList[envCtx->prevLightSetting].light2Dir[i],
lightSettingsList[envCtx->lightSetting].light2Dir[i], envCtx->lightBlend);
envCtx->lightSettings.light2Color[i] =
LERP(lightSettingsList[envCtx->prevLightSetting].light2Color[i],
lightSettingsList[envCtx->lightSetting].light2Color[i], envCtx->lightBlend);
envCtx->lightSettings.fogColor[i] =
LERP(lightSettingsList[envCtx->prevLightSetting].fogColor[i],
lightSettingsList[envCtx->lightSetting].fogColor[i], 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) {
// "The color palette seems to be wrong!"
PRINTF("\n" VT_FGCOL(RED) "カラーパレットがおかしいようです!");
// "Palette setting = [] Last palette number = []"
PRINTF("\n" VT_FGCOL(YELLOW) "設定パレット=[%d] パレット数=[%d]\n" VT_RST, envCtx->lightSetting,
envCtx->numLightSettings);
} }
} }
} else {
if (!envCtx->lightBlendEnabled) {
for (i = 0; i < 3; i++) {
envCtx->lightSettings.ambientColor[i] = lightSettingsList[envCtx->lightSetting].ambientColor[i];
envCtx->lightSettings.light1Dir[i] = lightSettingsList[envCtx->lightSetting].light1Dir[i];
envCtx->lightSettings.light1Color[i] = lightSettingsList[envCtx->lightSetting].light1Color[i];
envCtx->lightSettings.light2Dir[i] = lightSettingsList[envCtx->lightSetting].light2Dir[i];
envCtx->lightSettings.light2Color[i] = lightSettingsList[envCtx->lightSetting].light2Color[i];
envCtx->lightSettings.fogColor[i] = lightSettingsList[envCtx->lightSetting].fogColor[i];
}
envCtx->lightSettings.fogNear =
ENV_LIGHT_SETTINGS_FOG_NEAR(lightSettingsList[envCtx->lightSetting].blendRateAndFogNear);
envCtx->lightSettings.zFar = lightSettingsList[envCtx->lightSetting].zFar;
envCtx->lightBlend = 1.0f;
} else {
blendRate =
ENV_LIGHT_SETTINGS_BLEND_RATE_U8(lightSettingsList[envCtx->lightSetting].blendRateAndFogNear);
if (blendRate == 0) {
blendRate++;
}
if (envCtx->lightBlendRateOverride != LIGHT_BLENDRATE_OVERRIDE_NONE) {
blendRate = envCtx->lightBlendRateOverride;
}
if (envCtx->lightBlendOverride == LIGHT_BLEND_OVERRIDE_NONE) {
envCtx->lightBlend += blendRate / 255.0f;
}
if (envCtx->lightBlend > 1.0f) {
envCtx->lightBlend = 1.0f;
}
for (i = 0; i < 3; i++) {
envCtx->lightSettings.ambientColor[i] =
LERP(lightSettingsList[envCtx->prevLightSetting].ambientColor[i],
lightSettingsList[envCtx->lightSetting].ambientColor[i], envCtx->lightBlend);
envCtx->lightSettings.light1Dir[i] =
LERP16(lightSettingsList[envCtx->prevLightSetting].light1Dir[i],
lightSettingsList[envCtx->lightSetting].light1Dir[i], envCtx->lightBlend);
envCtx->lightSettings.light1Color[i] =
LERP(lightSettingsList[envCtx->prevLightSetting].light1Color[i],
lightSettingsList[envCtx->lightSetting].light1Color[i], envCtx->lightBlend);
envCtx->lightSettings.light2Dir[i] =
LERP16(lightSettingsList[envCtx->prevLightSetting].light2Dir[i],
lightSettingsList[envCtx->lightSetting].light2Dir[i], envCtx->lightBlend);
envCtx->lightSettings.light2Color[i] =
LERP(lightSettingsList[envCtx->prevLightSetting].light2Color[i],
lightSettingsList[envCtx->lightSetting].light2Color[i], envCtx->lightBlend);
envCtx->lightSettings.fogColor[i] =
LERP(lightSettingsList[envCtx->prevLightSetting].fogColor[i],
lightSettingsList[envCtx->lightSetting].fogColor[i], 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 OOT_DEBUG
if (envCtx->lightSetting >= envCtx->numLightSettings) {
// "The color palette seems to be wrong!"
PRINTF("\n" VT_FGCOL(RED) "カラーパレットがおかしいようです!");
// "Palette setting = [] Last palette number = []"
PRINTF("\n" VT_FGCOL(YELLOW) "設定パレット=[%d] パレット数=[%d]\n" VT_RST, envCtx->lightSetting,
envCtx->numLightSettings);
}
#endif
} }
envCtx->lightBlendEnabled = true; envCtx->lightBlendEnabled = true;
@ -1261,22 +1272,20 @@ void Environment_Update(PlayState* play, EnvironmentContext* envCtx, LightContex
envCtx->dirLight2.params.dir.z = envCtx->lightSettings.light2Dir[2]; envCtx->dirLight2.params.dir.z = envCtx->lightSettings.light2Dir[2];
// Adjust fog near and far if necessary // Adjust fog near and far if necessary
adjustment = envCtx->lightSettings.fogNear + envCtx->adjFogNear;
if (adjustment <= ENV_FOGNEAR_MAX) { if ((envCtx->lightSettings.fogNear + envCtx->adjFogNear) <= ENV_FOGNEAR_MAX) {
lightCtx->fogNear = adjustment; lightCtx->fogNear = envCtx->lightSettings.fogNear + envCtx->adjFogNear;
} else { } else {
lightCtx->fogNear = ENV_FOGNEAR_MAX; lightCtx->fogNear = ENV_FOGNEAR_MAX;
} }
adjustment = envCtx->lightSettings.zFar + envCtx->adjZFar; if ((envCtx->lightSettings.zFar + envCtx->adjZFar) <= ENV_ZFAR_MAX) {
lightCtx->zFar = envCtx->lightSettings.zFar + envCtx->adjZFar;
if (adjustment <= ENV_ZFAR_MAX) {
lightCtx->zFar = adjustment;
} else { } else {
lightCtx->zFar = ENV_ZFAR_MAX; lightCtx->zFar = ENV_ZFAR_MAX;
} }
#if OOT_DEBUG
// When environment debug is enabled, various environment related variables can be configured via the reg editor // When environment debug is enabled, various environment related variables can be configured via the reg editor
if (R_ENV_DISABLE_DBG) { if (R_ENV_DISABLE_DBG) {
R_ENV_AMBIENT_COLOR(0) = lightCtx->ambientColor[0]; R_ENV_AMBIENT_COLOR(0) = lightCtx->ambientColor[0];
@ -1357,6 +1366,7 @@ void Environment_Update(PlayState* play, EnvironmentContext* envCtx, LightContex
envCtx->windDirection.z = R_ENV_WIND_DIR(2); envCtx->windDirection.z = R_ENV_WIND_DIR(2);
envCtx->windSpeed = R_ENV_WIND_SPEED; envCtx->windSpeed = R_ENV_WIND_SPEED;
} }
#endif
if ((envCtx->dirLight1.params.dir.x == 0) && (envCtx->dirLight1.params.dir.y == 0) && if ((envCtx->dirLight1.params.dir.x == 0) && (envCtx->dirLight1.params.dir.y == 0) &&
(envCtx->dirLight1.params.dir.z == 0)) { (envCtx->dirLight1.params.dir.z == 0)) {
@ -2366,9 +2376,6 @@ void Environment_DrawSandstorm(PlayState* play, u8 sandstormState) {
Color_RGBA8 envColor; Color_RGBA8 envColor;
s32 pad; s32 pad;
f32 sp98; f32 sp98;
u16 sp96;
u16 sp94;
u16 sp92;
switch (sandstormState) { switch (sandstormState) {
case SANDSTORM_ACTIVE: case SANDSTORM_ACTIVE:
@ -2475,25 +2482,27 @@ void Environment_DrawSandstorm(PlayState* play, u8 sandstormState) {
envColor.g = ((envColor.g * sp98) + ((6.0f - sp98) * primColor.g)) * (1.0f / 6.0f); envColor.g = ((envColor.g * sp98) + ((6.0f - sp98) * primColor.g)) * (1.0f / 6.0f);
envColor.b = ((envColor.b * sp98) + ((6.0f - sp98) * primColor.b)) * (1.0f / 6.0f); envColor.b = ((envColor.b * sp98) + ((6.0f - sp98) * primColor.b)) * (1.0f / 6.0f);
sp96 = (s32)(sSandstormScroll * (11.0f / 6.0f)); {
sp94 = (s32)(sSandstormScroll * (9.0f / 6.0f)); u16 sp96 = (s32)(sSandstormScroll * (11.0f / 6.0f));
sp92 = (s32)(sSandstormScroll * (6.0f / 6.0f)); u16 sp94 = (s32)(sSandstormScroll * (9.0f / 6.0f));
u16 sp92 = (s32)(sSandstormScroll * (6.0f / 6.0f));
OPEN_DISPS(play->state.gfxCtx, "../z_kankyo.c", 4044); OPEN_DISPS(play->state.gfxCtx, "../z_kankyo.c", 4044);
POLY_XLU_DISP = Gfx_SetupDL_64(POLY_XLU_DISP); POLY_XLU_DISP = Gfx_SetupDL_64(POLY_XLU_DISP);
gDPSetAlphaDither(POLY_XLU_DISP++, G_AD_NOISE); gDPSetAlphaDither(POLY_XLU_DISP++, G_AD_NOISE);
gDPSetColorDither(POLY_XLU_DISP++, G_CD_NOISE); gDPSetColorDither(POLY_XLU_DISP++, G_CD_NOISE);
gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, primColor.r, primColor.g, primColor.b, play->envCtx.sandstormPrimA); gDPSetPrimColor(POLY_XLU_DISP++, 0, 0x80, primColor.r, primColor.g, primColor.b, play->envCtx.sandstormPrimA);
gDPSetEnvColor(POLY_XLU_DISP++, envColor.r, envColor.g, envColor.b, play->envCtx.sandstormEnvA); gDPSetEnvColor(POLY_XLU_DISP++, envColor.r, envColor.g, envColor.b, play->envCtx.sandstormEnvA);
gSPSegment(POLY_XLU_DISP++, 0x08, gSPSegment(POLY_XLU_DISP++, 0x08,
Gfx_TwoTexScroll(play->state.gfxCtx, G_TX_RENDERTILE, (u32)sp96 % 4096, 0, 512, 32, 1, (u32)sp94 % 4096, Gfx_TwoTexScroll(play->state.gfxCtx, G_TX_RENDERTILE, (u32)sp96 % 4096, 0, 512, 32, 1,
4095 - ((u32)sp92 % 4096), 256, 64)); (u32)sp94 % 4096, 4095 - ((u32)sp92 % 4096), 256, 64));
gDPSetTextureLUT(POLY_XLU_DISP++, G_TT_NONE); gDPSetTextureLUT(POLY_XLU_DISP++, G_TT_NONE);
gSPDisplayList(POLY_XLU_DISP++, gFieldSandstormDL); gSPDisplayList(POLY_XLU_DISP++, gFieldSandstormDL);
CLOSE_DISPS(play->state.gfxCtx, "../z_kankyo.c", 4068); CLOSE_DISPS(play->state.gfxCtx, "../z_kankyo.c", 4068);
}
sSandstormScroll += (s32)sp98; sSandstormScroll += (s32)sp98;
} }

View file

@ -35,7 +35,7 @@ void* ZeldaArena_Malloc(u32 size) {
} }
#if OOT_DEBUG #if OOT_DEBUG
void* ZeldaArena_MallocDebug(u32 size, const char* file, s32 line) { void* ZeldaArena_MallocDebug(u32 size, const char* file, int line) {
void* ptr = __osMallocDebug(&sZeldaArena, size, file, line); void* ptr = __osMallocDebug(&sZeldaArena, size, file, line);
ZELDA_ARENA_CHECK_POINTER(ptr, size, "zelda_malloc_DEBUG", "確保"); // "Secure" ZELDA_ARENA_CHECK_POINTER(ptr, size, "zelda_malloc_DEBUG", "確保"); // "Secure"
@ -51,7 +51,7 @@ void* ZeldaArena_MallocR(u32 size) {
} }
#if OOT_DEBUG #if OOT_DEBUG
void* ZeldaArena_MallocRDebug(u32 size, const char* file, s32 line) { void* ZeldaArena_MallocRDebug(u32 size, const char* file, int line) {
void* ptr = __osMallocRDebug(&sZeldaArena, size, file, line); void* ptr = __osMallocRDebug(&sZeldaArena, size, file, line);
ZELDA_ARENA_CHECK_POINTER(ptr, size, "zelda_malloc_r_DEBUG", "確保"); // "Secure" ZELDA_ARENA_CHECK_POINTER(ptr, size, "zelda_malloc_r_DEBUG", "確保"); // "Secure"
@ -66,7 +66,7 @@ void* ZeldaArena_Realloc(void* ptr, u32 newSize) {
} }
#if OOT_DEBUG #if OOT_DEBUG
void* ZeldaArena_ReallocDebug(void* ptr, u32 newSize, const char* file, s32 line) { void* ZeldaArena_ReallocDebug(void* ptr, u32 newSize, const char* file, int line) {
ptr = __osReallocDebug(&sZeldaArena, ptr, newSize, file, line); ptr = __osReallocDebug(&sZeldaArena, ptr, newSize, file, line);
ZELDA_ARENA_CHECK_POINTER(ptr, newSize, "zelda_realloc_DEBUG", "再確保"); // "Re-securing" ZELDA_ARENA_CHECK_POINTER(ptr, newSize, "zelda_realloc_DEBUG", "再確保"); // "Re-securing"
return ptr; return ptr;
@ -78,7 +78,7 @@ void ZeldaArena_Free(void* ptr) {
} }
#if OOT_DEBUG #if OOT_DEBUG
void ZeldaArena_FreeDebug(void* ptr, const char* file, s32 line) { void ZeldaArena_FreeDebug(void* ptr, const char* file, int line) {
__osFreeDebug(&sZeldaArena, ptr, file, line); __osFreeDebug(&sZeldaArena, ptr, file, line);
} }
#endif #endif

View file

@ -118,8 +118,8 @@ void MapMark_DrawForDungeon(PlayState* play) {
markInfo->textureWidth, markInfo->textureHeight, 0, G_TX_NOMIRROR | G_TX_WRAP, markInfo->textureWidth, markInfo->textureHeight, 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); G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
rectLeft = (GREG(94) + markPoint->x + 204) << 2; rectLeft = ((OOT_DEBUG ? GREG(94) : 0) + markPoint->x + 204) << 2;
rectTop = (GREG(95) + markPoint->y + 140) << 2; rectTop = ((OOT_DEBUG ? GREG(95) : 0) + markPoint->y + 140) << 2;
gSPTextureRectangle(OVERLAY_DISP++, rectLeft, rectTop, markInfo->rectWidth + rectLeft, gSPTextureRectangle(OVERLAY_DISP++, rectLeft, rectTop, markInfo->rectWidth + rectLeft,
rectTop + markInfo->rectHeight, G_TX_RENDERTILE, 0, 0, markInfo->dsdx, rectTop + markInfo->rectHeight, G_TX_RENDERTILE, 0, 0, markInfo->dsdx,
markInfo->dtdy); markInfo->dtdy);

View file

@ -291,17 +291,15 @@ void Message_GrowTextbox(MessageContext* msgCtx) {
void Message_FindMessage(PlayState* play, u16 textId) { void Message_FindMessage(PlayState* play, u16 textId) {
const char* foundSeg; const char* foundSeg;
const char* nextSeg; const char* nextSeg;
Font* font = &play->msgCtx.font;
MessageTableEntry* messageTableEntry = sNesMessageEntryTablePtr; MessageTableEntry* messageTableEntry = sNesMessageEntryTablePtr;
const char** languageSegmentTable; const char** languageSegmentTable;
Font* font;
const char* seg; const char* seg;
if (gSaveContext.language == LANGUAGE_ENG) { if (gSaveContext.language == LANGUAGE_ENG) {
seg = messageTableEntry->segment; seg = messageTableEntry->segment;
while (messageTableEntry->textId != 0xFFFF) { while (messageTableEntry->textId != 0xFFFF) {
font = &play->msgCtx.font;
if (messageTableEntry->textId == textId) { if (messageTableEntry->textId == textId) {
foundSeg = messageTableEntry->segment; foundSeg = messageTableEntry->segment;
font->charTexBuf[0] = messageTableEntry->typePos; font->charTexBuf[0] = messageTableEntry->typePos;
@ -323,8 +321,6 @@ void Message_FindMessage(PlayState* play, u16 textId) {
seg = messageTableEntry->segment; seg = messageTableEntry->segment;
while (messageTableEntry->textId != 0xFFFF) { while (messageTableEntry->textId != 0xFFFF) {
font = &play->msgCtx.font;
if (messageTableEntry->textId == textId) { if (messageTableEntry->textId == textId) {
foundSeg = *languageSegmentTable; foundSeg = *languageSegmentTable;
font->charTexBuf[0] = messageTableEntry->typePos; font->charTexBuf[0] = messageTableEntry->typePos;
@ -344,7 +340,6 @@ void Message_FindMessage(PlayState* play, u16 textId) {
} }
// "Message not found!!!" // "Message not found!!!"
PRINTF(" メッセージが,見つからなかった!!! = %x\n", textId); PRINTF(" メッセージが,見つからなかった!!! = %x\n", textId);
font = &play->msgCtx.font;
messageTableEntry = sNesMessageEntryTablePtr; messageTableEntry = sNesMessageEntryTablePtr;
if (gSaveContext.language == LANGUAGE_ENG) { if (gSaveContext.language == LANGUAGE_ENG) {
@ -368,13 +363,11 @@ void Message_FindCreditsMessage(PlayState* play, u16 textId) {
const char* foundSeg; const char* foundSeg;
const char* nextSeg; const char* nextSeg;
const char* seg; const char* seg;
Font* font = &play->msgCtx.font;
MessageTableEntry* messageTableEntry = sStaffMessageEntryTablePtr; MessageTableEntry* messageTableEntry = sStaffMessageEntryTablePtr;
Font* font;
seg = messageTableEntry->segment; seg = messageTableEntry->segment;
while (messageTableEntry->textId != 0xFFFF) { while (messageTableEntry->textId != 0xFFFF) {
font = &play->msgCtx.font;
if (messageTableEntry->textId == textId) { if (messageTableEntry->textId == textId) {
foundSeg = messageTableEntry->segment; foundSeg = messageTableEntry->segment;
font->charTexBuf[0] = messageTableEntry->typePos; font->charTexBuf[0] = messageTableEntry->typePos;
@ -981,7 +974,8 @@ void Message_DrawText(PlayState* play, Gfx** gfxP) {
sMessageHasSetSfx = true; sMessageHasSetSfx = true;
// "Sound (SE)" // "Sound (SE)"
PRINTF("サウンド(SE)\n"); PRINTF("サウンド(SE)\n");
sfxHi = msgCtx->msgBufDecoded[i + 1] << 8; sfxHi = msgCtx->msgBufDecoded[i + 1];
sfxHi <<= 8;
Audio_PlaySfxGeneral(sfxHi | msgCtx->msgBufDecoded[i + 2], &gSfxDefaultPos, 4, Audio_PlaySfxGeneral(sfxHi | msgCtx->msgBufDecoded[i + 2], &gSfxDefaultPos, 4,
&gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb);
} }
@ -1369,8 +1363,8 @@ void Message_Decode(PlayState* play) {
} }
if (loadChar) { if (loadChar) {
Font_LoadChar(font, digits[i] + '0' - ' ', charTexIdx); Font_LoadChar(font, digits[i] + '0' - ' ', charTexIdx);
msgCtx->msgBufDecoded[decodedBufPos] = digits[i] + '0';
charTexIdx += FONT_CHAR_TEX_SIZE; charTexIdx += FONT_CHAR_TEX_SIZE;
msgCtx->msgBufDecoded[decodedBufPos] = digits[i] + '0';
PRINTF("%x(%x) ", digits[i] + '0' - ' ', digits[i]); PRINTF("%x(%x) ", digits[i] + '0' - ' ', digits[i]);
decodedBufPos++; decodedBufPos++;
} }
@ -1390,8 +1384,8 @@ void Message_Decode(PlayState* play) {
for (i = 0; i < 2; i++) { for (i = 0; i < 2; i++) {
if (i == 1 || digits[i] != 0) { if (i == 1 || digits[i] != 0) {
Font_LoadChar(font, digits[i] + '0' - ' ', charTexIdx); Font_LoadChar(font, digits[i] + '0' - ' ', charTexIdx);
msgCtx->msgBufDecoded[decodedBufPos] = digits[i] + '0';
charTexIdx += FONT_CHAR_TEX_SIZE; charTexIdx += FONT_CHAR_TEX_SIZE;
msgCtx->msgBufDecoded[decodedBufPos] = digits[i] + '0';
PRINTF("%x(%x) ", digits[i] + '0' - ' ', digits[i]); PRINTF("%x(%x) ", digits[i] + '0' - ' ', digits[i]);
decodedBufPos++; decodedBufPos++;
} }
@ -1579,9 +1573,10 @@ void Message_OpenText(PlayState* play, u16 textId) {
Font* font = &msgCtx->font; Font* font = &msgCtx->font;
s16 textBoxType; s16 textBoxType;
if (msgCtx->msgMode == MSGMODE_NONE) { // clang-format off
gSaveContext.prevHudVisibilityMode = gSaveContext.hudVisibilityMode; if (msgCtx->msgMode == MSGMODE_NONE) { gSaveContext.prevHudVisibilityMode = gSaveContext.hudVisibilityMode; }
} // clang-format on
if (R_SCENE_CAM_TYPE == SCENE_CAM_TYPE_FIXED_SHOP_VIEWPOINT) { if (R_SCENE_CAM_TYPE == SCENE_CAM_TYPE_FIXED_SHOP_VIEWPOINT) {
Interface_ChangeHudVisibilityMode(HUD_VISIBILITY_A_HEARTS_MAGIC_FORCE); Interface_ChangeHudVisibilityMode(HUD_VISIBILITY_A_HEARTS_MAGIC_FORCE);
} }
@ -1707,6 +1702,7 @@ void Message_StartTextbox(PlayState* play, u16 textId, Actor* actor) {
} }
void Message_ContinueTextbox(PlayState* play, u16 textId) { void Message_ContinueTextbox(PlayState* play, u16 textId) {
s32 pad;
MessageContext* msgCtx = &play->msgCtx; MessageContext* msgCtx = &play->msgCtx;
PRINTF(VT_FGCOL(GREEN)); PRINTF(VT_FGCOL(GREEN));
@ -2951,6 +2947,7 @@ void Message_DrawMain(PlayState* play, Gfx** p) {
*p = gfx; *p = gfx;
} }
#if OOT_DEBUG
/** /**
* If the s16 variable pointed to by `var` changes in value, a black bar and white box * If the s16 variable pointed to by `var` changes in value, a black bar and white box
* are briefly drawn onto the screen. It can only watch one variable per build due to * are briefly drawn onto the screen. It can only watch one variable per build due to
@ -3002,14 +2999,19 @@ void Message_DrawDebugText(PlayState* play, Gfx** p) {
*p = GfxPrint_Close(&printer); *p = GfxPrint_Close(&printer);
GfxPrint_Destroy(&printer); GfxPrint_Destroy(&printer);
} }
#endif
void Message_Draw(PlayState* play) { void Message_Draw(PlayState* play) {
Gfx* plusOne; Gfx* plusOne;
Gfx* polyOpaP; Gfx* polyOpaP;
#if OOT_DEBUG
s16 watchVar; s16 watchVar;
#endif
OPEN_DISPS(play->state.gfxCtx, "../z_message_PAL.c", 3554); OPEN_DISPS(play->state.gfxCtx, "../z_message_PAL.c", 3554);
#if OOT_DEBUG
watchVar = gSaveContext.save.info.scarecrowLongSongSet; watchVar = gSaveContext.save.info.scarecrowLongSongSet;
Message_DrawDebugVariableChanged(&watchVar, play->state.gfxCtx); Message_DrawDebugVariableChanged(&watchVar, play->state.gfxCtx);
if (BREG(0) != 0 && play->msgCtx.textId != 0) { if (BREG(0) != 0 && play->msgCtx.textId != 0) {
@ -3021,6 +3023,8 @@ void Message_Draw(PlayState* play) {
POLY_OPA_DISP = plusOne; POLY_OPA_DISP = plusOne;
} }
if (1) {} if (1) {}
#endif
plusOne = Gfx_Open(polyOpaP = POLY_OPA_DISP); plusOne = Gfx_Open(polyOpaP = POLY_OPA_DISP);
gSPDisplayList(OVERLAY_DISP++, plusOne); gSPDisplayList(OVERLAY_DISP++, plusOne);
Message_DrawMain(play, &plusOne); Message_DrawMain(play, &plusOne);
@ -3063,6 +3067,7 @@ void Message_Update(PlayState* play) {
s16 playerFocusScreenPosY; s16 playerFocusScreenPosY;
s16 actorFocusScreenPosY; s16 actorFocusScreenPosY;
#if OOT_DEBUG
if (BREG(0) != 0) { if (BREG(0) != 0) {
if (CHECK_BTN_ALL(input->press.button, BTN_DDOWN) && CHECK_BTN_ALL(input->cur.button, BTN_L)) { if (CHECK_BTN_ALL(input->press.button, BTN_DDOWN) && CHECK_BTN_ALL(input->cur.button, BTN_L)) {
PRINTF("msgno=%d\n", D_80153D78); PRINTF("msgno=%d\n", D_80153D78);
@ -3088,256 +3093,257 @@ void Message_Update(PlayState* play) {
} }
} }
} }
#endif
if (msgCtx->msgLength == 0) { if (msgCtx->msgLength != 0) {
return;
}
switch (msgCtx->msgMode) { switch (msgCtx->msgMode) {
case MSGMODE_TEXT_START: case MSGMODE_TEXT_START:
D_8014B2F4++; D_8014B2F4++;
var = false; var = false;
if (R_SCENE_CAM_TYPE == SCENE_CAM_TYPE_FIXED_MARKET) { if (R_SCENE_CAM_TYPE == SCENE_CAM_TYPE_FIXED_MARKET) {
if (D_8014B2F4 >= 4) { if (D_8014B2F4 >= 4) {
var = true;
}
} else if (R_SCENE_CAM_TYPE != SCENE_CAM_TYPE_DEFAULT ||
play->sceneId == SCENE_CASTLE_COURTYARD_GUARDS_DAY) {
var = true;
} else if (D_8014B2F4 >= 4 || msgCtx->talkActor == NULL) {
var = true; var = true;
} }
} else if (R_SCENE_CAM_TYPE != SCENE_CAM_TYPE_DEFAULT ||
play->sceneId == SCENE_CASTLE_COURTYARD_GUARDS_DAY) {
var = true;
} else if (D_8014B2F4 >= 4 || msgCtx->talkActor == NULL) {
var = true;
}
if (var) { if (var) {
if (msgCtx->talkActor != NULL) { if (msgCtx->talkActor != NULL) {
Actor_GetScreenPos(play, &GET_PLAYER(play)->actor, &focusScreenPosX, &playerFocusScreenPosY); Actor_GetScreenPos(play, &GET_PLAYER(play)->actor, &focusScreenPosX, &playerFocusScreenPosY);
Actor_GetScreenPos(play, msgCtx->talkActor, &focusScreenPosX, &actorFocusScreenPosY); Actor_GetScreenPos(play, msgCtx->talkActor, &focusScreenPosX, &actorFocusScreenPosY);
if (playerFocusScreenPosY >= actorFocusScreenPosY) { if (playerFocusScreenPosY >= actorFocusScreenPosY) {
averageY = ((playerFocusScreenPosY - actorFocusScreenPosY) / 2) + actorFocusScreenPosY; averageY = ((playerFocusScreenPosY - actorFocusScreenPosY) / 2) + actorFocusScreenPosY;
} else {
averageY = ((actorFocusScreenPosY - playerFocusScreenPosY) / 2) + playerFocusScreenPosY;
}
PRINTF("dxpos=%d dypos=%d dypos1 dypos2=%d\n", focusScreenPosX, averageY,
playerFocusScreenPosY, actorFocusScreenPosY);
} else { } else {
averageY = ((actorFocusScreenPosY - playerFocusScreenPosY) / 2) + playerFocusScreenPosY; R_TEXTBOX_X = R_TEXTBOX_X_TARGET;
R_TEXTBOX_Y = R_TEXTBOX_Y_TARGET;
} }
PRINTF("dxpos=%d dypos=%d dypos1 dypos2=%d\n", focusScreenPosX, averageY, playerFocusScreenPosY,
actorFocusScreenPosY);
} else {
R_TEXTBOX_X = R_TEXTBOX_X_TARGET;
R_TEXTBOX_Y = R_TEXTBOX_Y_TARGET;
}
var = msgCtx->textBoxType; var = msgCtx->textBoxType;
if (!msgCtx->textBoxPos) { // variable position if (!msgCtx->textBoxPos) { // variable position
if (R_SCENE_CAM_TYPE != SCENE_CAM_TYPE_DEFAULT || if (R_SCENE_CAM_TYPE != SCENE_CAM_TYPE_DEFAULT ||
play->sceneId == SCENE_CASTLE_COURTYARD_GUARDS_DAY) { play->sceneId == SCENE_CASTLE_COURTYARD_GUARDS_DAY) {
if (averageY < XREG(92)) { if (averageY < XREG(92)) {
R_TEXTBOX_Y_TARGET = sTextboxLowerYPositions[var]; R_TEXTBOX_Y_TARGET = sTextboxLowerYPositions[var];
} else {
R_TEXTBOX_Y_TARGET = sTextboxUpperYPositions[var];
}
} else if (play->sceneId == SCENE_MARKET_DAY || play->sceneId == SCENE_MARKET_NIGHT ||
play->sceneId == SCENE_MARKET_RUINS) {
if (averageY < XREG(93)) {
R_TEXTBOX_Y_TARGET = sTextboxLowerYPositions[var];
} else {
R_TEXTBOX_Y_TARGET = sTextboxUpperYPositions[var];
}
} else { } else {
R_TEXTBOX_Y_TARGET = sTextboxUpperYPositions[var]; if (averageY < XREG(94)) {
} R_TEXTBOX_Y_TARGET = sTextboxLowerYPositions[var];
} else if (play->sceneId == SCENE_MARKET_DAY || play->sceneId == SCENE_MARKET_NIGHT || } else {
play->sceneId == SCENE_MARKET_RUINS) { R_TEXTBOX_Y_TARGET = sTextboxUpperYPositions[var];
if (averageY < XREG(93)) { }
R_TEXTBOX_Y_TARGET = sTextboxLowerYPositions[var];
} else {
R_TEXTBOX_Y_TARGET = sTextboxUpperYPositions[var];
} }
} else if (msgCtx->textBoxPos == TEXTBOX_POS_TOP) {
R_TEXTBOX_Y_TARGET = sTextboxUpperYPositions[var];
} else if (msgCtx->textBoxPos == TEXTBOX_POS_MIDDLE) {
R_TEXTBOX_Y_TARGET = sTextboxMidYPositions[var];
} else { } else {
if (averageY < XREG(94)) { R_TEXTBOX_Y_TARGET = sTextboxLowerYPositions[var];
R_TEXTBOX_Y_TARGET = sTextboxLowerYPositions[var];
} else {
R_TEXTBOX_Y_TARGET = sTextboxUpperYPositions[var];
}
} }
} else if (msgCtx->textBoxPos == TEXTBOX_POS_TOP) {
R_TEXTBOX_Y_TARGET = sTextboxUpperYPositions[var];
} else if (msgCtx->textBoxPos == TEXTBOX_POS_MIDDLE) {
R_TEXTBOX_Y_TARGET = sTextboxMidYPositions[var];
} else {
R_TEXTBOX_Y_TARGET = sTextboxLowerYPositions[var];
}
R_TEXTBOX_X_TARGET = sTextboxXPositions[var]; R_TEXTBOX_X_TARGET = sTextboxXPositions[var];
R_TEXTBOX_END_YPOS = sTextboxEndIconYOffset[var] + R_TEXTBOX_Y_TARGET; R_TEXTBOX_END_YPOS = sTextboxEndIconYOffset[var] + R_TEXTBOX_Y_TARGET;
R_TEXT_CHOICE_YPOS(0) = R_TEXTBOX_Y_TARGET + 20; R_TEXT_CHOICE_YPOS(0) = R_TEXTBOX_Y_TARGET + 20;
R_TEXT_CHOICE_YPOS(1) = R_TEXTBOX_Y_TARGET + 32; R_TEXT_CHOICE_YPOS(1) = R_TEXTBOX_Y_TARGET + 32;
R_TEXT_CHOICE_YPOS(2) = R_TEXTBOX_Y_TARGET + 44; R_TEXT_CHOICE_YPOS(2) = R_TEXTBOX_Y_TARGET + 44;
PRINTF("message->msg_disp_type=%x\n", msgCtx->textBoxProperties & 0xF0); PRINTF("message->msg_disp_type=%x\n", msgCtx->textBoxProperties & 0xF0);
if (msgCtx->textBoxType == TEXTBOX_TYPE_NONE_BOTTOM || if (msgCtx->textBoxType == TEXTBOX_TYPE_NONE_BOTTOM ||
msgCtx->textBoxType == TEXTBOX_TYPE_NONE_NO_SHADOW) { msgCtx->textBoxType == TEXTBOX_TYPE_NONE_NO_SHADOW) {
msgCtx->msgMode = MSGMODE_TEXT_STARTING; msgCtx->msgMode = MSGMODE_TEXT_STARTING;
R_TEXTBOX_X = R_TEXTBOX_X_TARGET; R_TEXTBOX_X = R_TEXTBOX_X_TARGET;
R_TEXTBOX_Y = R_TEXTBOX_Y_TARGET; R_TEXTBOX_Y = R_TEXTBOX_Y_TARGET;
R_TEXTBOX_WIDTH = 256; R_TEXTBOX_WIDTH = 256;
R_TEXTBOX_HEIGHT = 64; R_TEXTBOX_HEIGHT = 64;
R_TEXTBOX_TEXWIDTH = 512; R_TEXTBOX_TEXWIDTH = 512;
R_TEXTBOX_TEXHEIGHT = 512; R_TEXTBOX_TEXHEIGHT = 512;
} else { } else {
Message_GrowTextbox(msgCtx); Message_GrowTextbox(msgCtx);
Audio_PlaySfxIfNotInCutscene(NA_SE_NONE); Audio_PlaySfxIfNotInCutscene(NA_SE_NONE);
msgCtx->stateTimer = 0; msgCtx->stateTimer = 0;
msgCtx->msgMode = MSGMODE_TEXT_BOX_GROWING; msgCtx->msgMode = MSGMODE_TEXT_BOX_GROWING;
}
} }
} break;
break; case MSGMODE_TEXT_BOX_GROWING:
case MSGMODE_TEXT_BOX_GROWING: Message_GrowTextbox(msgCtx);
Message_GrowTextbox(msgCtx); break;
break; case MSGMODE_TEXT_STARTING:
case MSGMODE_TEXT_STARTING: msgCtx->msgMode = MSGMODE_TEXT_NEXT_MSG;
msgCtx->msgMode = MSGMODE_TEXT_NEXT_MSG; if (YREG(31) == 0) {
if (YREG(31) == 0) { Interface_SetDoAction(play, DO_ACTION_NEXT);
Interface_SetDoAction(play, DO_ACTION_NEXT); }
} break;
break; case MSGMODE_TEXT_NEXT_MSG:
case MSGMODE_TEXT_NEXT_MSG:
Message_Decode(play);
if (sTextFade) {
Interface_ChangeHudVisibilityMode(HUD_VISIBILITY_NOTHING);
}
if (D_80153D74 != 0) {
msgCtx->textDrawPos = msgCtx->decodedTextLen;
D_80153D74 = 0;
}
break;
case MSGMODE_TEXT_CONTINUING:
msgCtx->stateTimer--;
if (msgCtx->stateTimer == 0) {
Message_Decode(play); Message_Decode(play);
} if (sTextFade) {
break; Interface_ChangeHudVisibilityMode(HUD_VISIBILITY_NOTHING);
case MSGMODE_TEXT_DISPLAYING: }
if (msgCtx->textBoxType != TEXTBOX_TYPE_NONE_BOTTOM && YREG(31) == 0 && if (D_80153D74 != 0) {
CHECK_BTN_ALL(play->state.input[0].press.button, BTN_B) && !msgCtx->textUnskippable) { msgCtx->textDrawPos = msgCtx->decodedTextLen;
sTextboxSkipped = true; D_80153D74 = 0;
msgCtx->textDrawPos = msgCtx->decodedTextLen; }
} break;
break; case MSGMODE_TEXT_CONTINUING:
case MSGMODE_TEXT_AWAIT_INPUT:
if (YREG(31) == 0 && Message_ShouldAdvance(play)) {
msgCtx->msgMode = MSGMODE_TEXT_DISPLAYING;
msgCtx->textDrawPos++;
}
break;
case MSGMODE_TEXT_DELAYED_BREAK:
msgCtx->stateTimer--;
if (msgCtx->stateTimer == 0) {
msgCtx->msgMode = MSGMODE_TEXT_NEXT_MSG;
}
break;
case MSGMODE_TEXT_AWAIT_NEXT:
if (Message_ShouldAdvance(play)) {
msgCtx->msgMode = MSGMODE_TEXT_NEXT_MSG;
msgCtx->textUnskippable = false;
msgCtx->msgBufPos++;
}
break;
case MSGMODE_TEXT_DONE:
if (msgCtx->textboxEndType == TEXTBOX_ENDTYPE_FADING) {
msgCtx->stateTimer--; msgCtx->stateTimer--;
if (msgCtx->stateTimer == 0) { if (msgCtx->stateTimer == 0) {
Message_CloseTextbox(play); Message_Decode(play);
} }
} else if (msgCtx->textboxEndType != TEXTBOX_ENDTYPE_PERSISTENT &&
msgCtx->textboxEndType != TEXTBOX_ENDTYPE_EVENT && YREG(31) == 0) {
if (msgCtx->textboxEndType == TEXTBOX_ENDTYPE_2_CHOICE && play->msgCtx.ocarinaMode == OCARINA_MODE_01) {
if (Message_ShouldAdvance(play)) {
PRINTF("OCARINA_MODE=%d -> ", play->msgCtx.ocarinaMode);
play->msgCtx.ocarinaMode = (msgCtx->choiceIndex == 0) ? OCARINA_MODE_02 : OCARINA_MODE_04;
PRINTF("InRaceSeq=%d(%d) OCARINA_MODE=%d --> ", GET_EVENTINF_HORSES_STATE(), 1,
play->msgCtx.ocarinaMode);
Message_CloseTextbox(play);
PRINTF("OCARINA_MODE=%d\n", play->msgCtx.ocarinaMode);
}
} else if (Message_ShouldAdvanceSilent(play)) {
PRINTF("select=%d\n", msgCtx->textboxEndType);
if (msgCtx->textboxEndType == TEXTBOX_ENDTYPE_HAS_NEXT) {
Audio_PlaySfxGeneral(NA_SE_SY_MESSAGE_PASS, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale,
&gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb);
Message_ContinueTextbox(play, sNextTextId);
} else {
Audio_PlaySfxGeneral(NA_SE_SY_DECIDE, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale,
&gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb);
Message_CloseTextbox(play);
}
}
}
break;
case MSGMODE_TEXT_CLOSING:
msgCtx->stateTimer--;
if (msgCtx->stateTimer != 0) {
break; break;
} case MSGMODE_TEXT_DISPLAYING:
if ((msgCtx->textId >= 0xC2 && msgCtx->textId < 0xC7) || if (msgCtx->textBoxType != TEXTBOX_TYPE_NONE_BOTTOM && YREG(31) == 0 &&
(msgCtx->textId >= 0xFA && msgCtx->textId < 0xFE)) { CHECK_BTN_ALL(play->state.input[0].press.button, BTN_B) && !msgCtx->textUnskippable) {
gSaveContext.healthAccumulator = 0x140; // Refill 20 hearts sTextboxSkipped = true;
} msgCtx->textDrawPos = msgCtx->decodedTextLen;
if (msgCtx->textId == 0x301F || msgCtx->textId == 0xA || msgCtx->textId == 0xC || msgCtx->textId == 0xCF || }
msgCtx->textId == 0x21C || msgCtx->textId == 9 || msgCtx->textId == 0x4078 || break;
msgCtx->textId == 0x2015 || msgCtx->textId == 0x3040) { case MSGMODE_TEXT_AWAIT_INPUT:
gSaveContext.prevHudVisibilityMode = HUD_VISIBILITY_ALL; if (YREG(31) == 0 && Message_ShouldAdvance(play)) {
} msgCtx->msgMode = MSGMODE_TEXT_DISPLAYING;
if (play->csCtx.state == 0) { msgCtx->textDrawPos++;
PRINTF(VT_FGCOL(GREEN)); }
PRINTF("day_time=%x active_camera=%d ", gSaveContext.save.cutsceneIndex, play->activeCamId); break;
case MSGMODE_TEXT_DELAYED_BREAK:
if (msgCtx->textId != 0x2061 && msgCtx->textId != 0x2025 && msgCtx->textId != 0x208C && msgCtx->stateTimer--;
((msgCtx->textId < 0x88D || msgCtx->textId >= 0x893) || msgCtx->choiceIndex != 0) && if (msgCtx->stateTimer == 0) {
(msgCtx->textId != 0x3055 && gSaveContext.save.cutsceneIndex < 0xFFF0)) { msgCtx->msgMode = MSGMODE_TEXT_NEXT_MSG;
PRINTF("=== day_time=%x ", ((void)0, gSaveContext.save.cutsceneIndex)); }
if (play->activeCamId == CAM_ID_MAIN) { break;
if (gSaveContext.prevHudVisibilityMode == HUD_VISIBILITY_NO_CHANGE || case MSGMODE_TEXT_AWAIT_NEXT:
gSaveContext.prevHudVisibilityMode == HUD_VISIBILITY_NOTHING || if (Message_ShouldAdvance(play)) {
gSaveContext.prevHudVisibilityMode == HUD_VISIBILITY_NOTHING_ALT) { msgCtx->msgMode = MSGMODE_TEXT_NEXT_MSG;
gSaveContext.prevHudVisibilityMode = HUD_VISIBILITY_ALL; msgCtx->textUnskippable = false;
msgCtx->msgBufPos++;
}
break;
case MSGMODE_TEXT_DONE:
if (msgCtx->textboxEndType == TEXTBOX_ENDTYPE_FADING) {
msgCtx->stateTimer--;
if (msgCtx->stateTimer == 0) {
Message_CloseTextbox(play);
}
} else if (msgCtx->textboxEndType != TEXTBOX_ENDTYPE_PERSISTENT &&
msgCtx->textboxEndType != TEXTBOX_ENDTYPE_EVENT && YREG(31) == 0) {
if (msgCtx->textboxEndType == TEXTBOX_ENDTYPE_2_CHOICE &&
play->msgCtx.ocarinaMode == OCARINA_MODE_01) {
if (Message_ShouldAdvance(play)) {
PRINTF("OCARINA_MODE=%d -> ", play->msgCtx.ocarinaMode);
play->msgCtx.ocarinaMode = (msgCtx->choiceIndex == 0) ? OCARINA_MODE_02 : OCARINA_MODE_04;
PRINTF("InRaceSeq=%d(%d) OCARINA_MODE=%d --> ", GET_EVENTINF_HORSES_STATE(), 1,
play->msgCtx.ocarinaMode);
Message_CloseTextbox(play);
PRINTF("OCARINA_MODE=%d\n", play->msgCtx.ocarinaMode);
}
} else if (Message_ShouldAdvanceSilent(play)) {
PRINTF("select=%d\n", msgCtx->textboxEndType);
if (msgCtx->textboxEndType == TEXTBOX_ENDTYPE_HAS_NEXT) {
Audio_PlaySfxGeneral(NA_SE_SY_MESSAGE_PASS, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale,
&gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb);
Message_ContinueTextbox(play, sNextTextId);
} else {
Audio_PlaySfxGeneral(NA_SE_SY_DECIDE, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale,
&gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb);
Message_CloseTextbox(play);
} }
gSaveContext.hudVisibilityMode = HUD_VISIBILITY_NO_CHANGE;
Interface_ChangeHudVisibilityMode(gSaveContext.prevHudVisibilityMode);
} }
} }
} break;
PRINTF(VT_RST); case MSGMODE_TEXT_CLOSING:
msgCtx->msgLength = 0; msgCtx->stateTimer--;
msgCtx->msgMode = MSGMODE_NONE; if (msgCtx->stateTimer != 0) {
interfaceCtx->unk_1FA = interfaceCtx->unk_1FC = 0; break;
msgCtx->textId = msgCtx->stateTimer = 0; }
if ((msgCtx->textId >= 0xC2 && msgCtx->textId < 0xC7) ||
(msgCtx->textId >= 0xFA && msgCtx->textId < 0xFE)) {
gSaveContext.healthAccumulator = 0x140; // Refill 20 hearts
}
if (msgCtx->textId == 0x301F || msgCtx->textId == 0xA || msgCtx->textId == 0xC ||
msgCtx->textId == 0xCF || msgCtx->textId == 0x21C || msgCtx->textId == 9 ||
msgCtx->textId == 0x4078 || msgCtx->textId == 0x2015 || msgCtx->textId == 0x3040) {
gSaveContext.prevHudVisibilityMode = HUD_VISIBILITY_ALL;
}
if (play->csCtx.state == 0) {
PRINTF(VT_FGCOL(GREEN));
PRINTF("day_time=%x active_camera=%d ", gSaveContext.save.cutsceneIndex, play->activeCamId);
if (msgCtx->textboxEndType == TEXTBOX_ENDTYPE_PERSISTENT) { if (msgCtx->textId != 0x2061 && msgCtx->textId != 0x2025 && msgCtx->textId != 0x208C &&
msgCtx->textboxEndType = TEXTBOX_ENDTYPE_DEFAULT; ((msgCtx->textId < 0x88D || msgCtx->textId >= 0x893) || msgCtx->choiceIndex != 0) &&
play->msgCtx.ocarinaMode = OCARINA_MODE_02; (msgCtx->textId != 0x3055 && gSaveContext.save.cutsceneIndex < 0xFFF0)) {
} else { PRINTF("=== day_time=%x ", ((void)0, gSaveContext.save.cutsceneIndex));
msgCtx->textboxEndType = TEXTBOX_ENDTYPE_DEFAULT; if (play->activeCamId == CAM_ID_MAIN) {
} if (gSaveContext.prevHudVisibilityMode == HUD_VISIBILITY_NO_CHANGE ||
if ((s32)(gSaveContext.save.info.inventory.questItems & 0xF0000000) == (4 << QUEST_HEART_PIECE_COUNT)) { gSaveContext.prevHudVisibilityMode == HUD_VISIBILITY_NOTHING ||
gSaveContext.save.info.inventory.questItems ^= (4 << QUEST_HEART_PIECE_COUNT); gSaveContext.prevHudVisibilityMode == HUD_VISIBILITY_NOTHING_ALT) {
gSaveContext.save.info.playerData.healthCapacity += 0x10; gSaveContext.prevHudVisibilityMode = HUD_VISIBILITY_ALL;
gSaveContext.save.info.playerData.health += 0x10; }
} gSaveContext.hudVisibilityMode = HUD_VISIBILITY_NO_CHANGE;
if (msgCtx->ocarinaAction != OCARINA_ACTION_CHECK_NOWARP_DONE) { Interface_ChangeHudVisibilityMode(gSaveContext.prevHudVisibilityMode);
if (sLastPlayedSong == OCARINA_SONG_SARIAS) { }
//! @bug The last played song is not unset often, and if something interrupts the message system
// before it reaches this point after playing Saria's song, the song will be "stored".
// Later, if the ocarina has not been played and another textbox is closed, this handling
// for Saria's song will be carried out.
player->naviTextId = -0xE0;
player->naviActor->flags |= ACTOR_FLAG_16;
}
if (msgCtx->ocarinaAction == OCARINA_ACTION_FREE_PLAY_DONE &&
(play->msgCtx.ocarinaMode == OCARINA_MODE_01 || play->msgCtx.ocarinaMode == OCARINA_MODE_0B)) {
play->msgCtx.ocarinaMode = OCARINA_MODE_04;
if (msgCtx->unk_E3F2 == OCARINA_SONG_SUNS) {
play->msgCtx.ocarinaMode = OCARINA_MODE_01;
} }
} }
} PRINTF(VT_RST);
sLastPlayedSong = 0xFF; msgCtx->msgLength = 0;
PRINTF("OCARINA_MODE=%d chk_ocarina_no=%d\n", play->msgCtx.ocarinaMode, msgCtx->unk_E3F2); msgCtx->msgMode = MSGMODE_NONE;
break; interfaceCtx->unk_1FA = interfaceCtx->unk_1FC = 0;
case MSGMODE_PAUSED: msgCtx->textId = msgCtx->stateTimer = 0;
break;
default: if (msgCtx->textboxEndType == TEXTBOX_ENDTYPE_PERSISTENT) {
msgCtx->lastOcarinaButtonIndex = OCARINA_BTN_INVALID; msgCtx->textboxEndType = TEXTBOX_ENDTYPE_DEFAULT;
break; play->msgCtx.ocarinaMode = OCARINA_MODE_02;
} else {
msgCtx->textboxEndType = TEXTBOX_ENDTYPE_DEFAULT;
}
if ((s32)(gSaveContext.save.info.inventory.questItems & 0xF0000000) == (4 << QUEST_HEART_PIECE_COUNT)) {
gSaveContext.save.info.inventory.questItems ^= (4 << QUEST_HEART_PIECE_COUNT);
gSaveContext.save.info.playerData.healthCapacity += 0x10;
gSaveContext.save.info.playerData.health += 0x10;
}
if (msgCtx->ocarinaAction != OCARINA_ACTION_CHECK_NOWARP_DONE) {
if (sLastPlayedSong == OCARINA_SONG_SARIAS) {
//! @bug The last played song is not unset often, and if something interrupts the message system
// before it reaches this point after playing Saria's song, the song will be "stored".
// Later, if the ocarina has not been played and another textbox is closed, this handling
// for Saria's song will be carried out.
player->naviTextId = -0xE0;
player->naviActor->flags |= ACTOR_FLAG_16;
}
if (msgCtx->ocarinaAction == OCARINA_ACTION_FREE_PLAY_DONE &&
(play->msgCtx.ocarinaMode == OCARINA_MODE_01 || play->msgCtx.ocarinaMode == OCARINA_MODE_0B)) {
play->msgCtx.ocarinaMode = OCARINA_MODE_04;
if (msgCtx->unk_E3F2 == OCARINA_SONG_SUNS) {
play->msgCtx.ocarinaMode = OCARINA_MODE_01;
}
}
}
sLastPlayedSong = 0xFF;
PRINTF("OCARINA_MODE=%d chk_ocarina_no=%d\n", play->msgCtx.ocarinaMode, msgCtx->unk_E3F2);
break;
case MSGMODE_PAUSED:
break;
default:
msgCtx->lastOcarinaButtonIndex = OCARINA_BTN_INVALID;
break;
}
} }
} }

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -10,9 +10,12 @@ TransitionTile sTransitionTile;
s32 gTransitionTileState; s32 gTransitionTileState;
VisMono sPlayVisMono; VisMono sPlayVisMono;
Color_RGBA8_u32 gVisMonoColor; Color_RGBA8_u32 gVisMonoColor;
#if OOT_DEBUG
FaultClient D_801614B8; FaultClient D_801614B8;
#endif
s16 sTransitionFillTimer; s16 sTransitionFillTimer;
u64 sDebugCutsceneScriptBuf[0xA00];
void Play_SpawnScene(PlayState* this, s32 sceneId, s32 spawn); void Play_SpawnScene(PlayState* this, s32 sceneId, s32 spawn);
@ -451,7 +454,10 @@ void Play_Init(GameState* thisx) {
AnimationContext_Update(this, &this->animationCtx); AnimationContext_Update(this, &this->animationCtx);
gSaveContext.respawnFlag = 0; gSaveContext.respawnFlag = 0;
if (OOT_DEBUG && R_USE_DEBUG_CUTSCENE) { #if OOT_DEBUG
if (R_USE_DEBUG_CUTSCENE) {
static u64 sDebugCutsceneScriptBuf[0xA00];
gDebugCutsceneScript = sDebugCutsceneScriptBuf; gDebugCutsceneScript = sDebugCutsceneScriptBuf;
PRINTF("\nkawauso_data=[%x]", gDebugCutsceneScript); PRINTF("\nkawauso_data=[%x]", gDebugCutsceneScript);
@ -459,6 +465,7 @@ void Play_Init(GameState* thisx) {
// Presumably the ROM was larger at a previous point in development when this debug feature was used. // Presumably the ROM was larger at a previous point in development when this debug feature was used.
DmaMgr_DmaRomToRam(0x03FEB000, gDebugCutsceneScript, sizeof(sDebugCutsceneScriptBuf)); DmaMgr_DmaRomToRam(0x03FEB000, gDebugCutsceneScript, sizeof(sDebugCutsceneScriptBuf));
} }
#endif
} }
void Play_Update(PlayState* this) { void Play_Update(PlayState* this) {

View file

@ -152,6 +152,7 @@ void SkelAnime_DrawFlexLimbLod(PlayState* play, s32 limbIndex, void** skeleton,
} }
(*mtx)++; (*mtx)++;
} else if (limbDList != NULL) { } else if (limbDList != NULL) {
if (1) {}
MATRIX_TO_MTX(*mtx, "../z_skelanime.c", 954); MATRIX_TO_MTX(*mtx, "../z_skelanime.c", 954);
(*mtx)++; (*mtx)++;
} }
@ -366,6 +367,7 @@ void SkelAnime_DrawFlexLimbOpa(PlayState* play, s32 limbIndex, void** skeleton,
gSPDisplayList(POLY_OPA_DISP++, newDList); gSPDisplayList(POLY_OPA_DISP++, newDList);
(*limbMatrices)++; (*limbMatrices)++;
} else if (limbDList != NULL) { } else if (limbDList != NULL) {
if (1) {}
MATRIX_TO_MTX(*limbMatrices, "../z_skelanime.c", 1249); MATRIX_TO_MTX(*limbMatrices, "../z_skelanime.c", 1249);
(*limbMatrices)++; (*limbMatrices)++;
} }
@ -467,7 +469,7 @@ void SkelAnime_GetFrameData(AnimationHeader* animation, s32 frame, s32 limbCount
u16 staticIndexMax = animHeader->staticIndexMax; u16 staticIndexMax = animHeader->staticIndexMax;
s32 i; s32 i;
for (i = 0; i < limbCount; i++, frameTable++, jointIndices++) { for (i = 0; i < limbCount; i++) {
if ((frameTable == NULL) || (jointIndices == NULL) || (dynamicData == NULL) || (staticData == NULL)) { if ((frameTable == NULL) || (jointIndices == NULL) || (dynamicData == NULL) || (staticData == NULL)) {
LOG_ADDRESS("out", frameTable, "../z_skelanime.c", 1392); LOG_ADDRESS("out", frameTable, "../z_skelanime.c", 1392);
LOG_ADDRESS("ref_tbl", jointIndices, "../z_skelanime.c", 1393); LOG_ADDRESS("ref_tbl", jointIndices, "../z_skelanime.c", 1393);
@ -481,6 +483,8 @@ void SkelAnime_GetFrameData(AnimationHeader* animation, s32 frame, s32 limbCount
(jointIndices->y >= staticIndexMax) ? dynamicData[jointIndices->y] : staticData[jointIndices->y]; (jointIndices->y >= staticIndexMax) ? dynamicData[jointIndices->y] : staticData[jointIndices->y];
frameTable->z = frameTable->z =
(jointIndices->z >= staticIndexMax) ? dynamicData[jointIndices->z] : staticData[jointIndices->z]; (jointIndices->z >= staticIndexMax) ? dynamicData[jointIndices->z] : staticData[jointIndices->z];
jointIndices++;
frameTable++;
} }
} }
@ -1024,10 +1028,11 @@ void AnimationContext_Update(PlayState* play, AnimationContext* animationCtx) {
AnimationContext_LoadFrame, AnimationContext_CopyAll, AnimationContext_Interp, AnimationContext_LoadFrame, AnimationContext_CopyAll, AnimationContext_Interp,
AnimationContext_CopyTrue, AnimationContext_CopyFalse, AnimationContext_MoveActor, AnimationContext_CopyTrue, AnimationContext_CopyFalse, AnimationContext_MoveActor,
}; };
AnimationEntry* entry; AnimationEntry* entry = animationCtx->entries;
for (entry = animationCtx->entries; animationCtx->animationCount != 0; entry++, animationCtx->animationCount--) { for (; animationCtx->animationCount != 0; animationCtx->animationCount--) {
animFuncs[entry->type](play, &entry->data); animFuncs[entry->type](play, &entry->data);
entry++;
} }
sAnimQueueFlags = 1; sAnimQueueFlags = 1;

View file

@ -511,8 +511,7 @@ void Sram_WriteSave(SramContext* sramCtx) {
gSaveContext.save.info.checksum = 0; gSaveContext.save.info.checksum = 0;
ptr = (u16*)&gSaveContext; ptr = (u16*)&gSaveContext;
checksum = 0; checksum = j = 0;
j = 0;
for (offset = 0; offset < CHECKSUM_SIZE; offset++) { for (offset = 0; offset < CHECKSUM_SIZE; offset++) {
if (++j == 0x20) { if (++j == 0x20) {
@ -612,12 +611,15 @@ void Sram_VerifyAndLoadAllSaves(FileSelectState* fileSelect, SramContext* sramCt
bzero(&gSaveContext.save.entranceIndex, sizeof(s32)); bzero(&gSaveContext.save.entranceIndex, sizeof(s32));
bzero(&gSaveContext.save.linkAge, sizeof(s32)); bzero(&gSaveContext.save.linkAge, sizeof(s32));
bzero(&gSaveContext.save.cutsceneIndex, sizeof(s32)); bzero(&gSaveContext.save.cutsceneIndex, sizeof(s32));
// note that gSaveContext.save.dayTime is not actually the sizeof(s32) //! @bug gSaveContext.save.dayTime is a u16 but is cleared as a 32-bit value. This is harmless as-is
//! since it is followed by nightFlag which is also reset here, but can become an issue if the save
//! layout is changed.
bzero(&gSaveContext.save.dayTime, sizeof(s32)); bzero(&gSaveContext.save.dayTime, sizeof(s32));
bzero(&gSaveContext.save.nightFlag, sizeof(s32)); bzero(&gSaveContext.save.nightFlag, sizeof(s32));
bzero(&gSaveContext.save.totalDays, sizeof(s32)); bzero(&gSaveContext.save.totalDays, sizeof(s32));
bzero(&gSaveContext.save.bgsDayCount, sizeof(s32)); bzero(&gSaveContext.save.bgsDayCount, sizeof(s32));
#if OOT_DEBUG
if (!slotNum) { if (!slotNum) {
Sram_InitDebugSave(); Sram_InitDebugSave();
gSaveContext.save.info.playerData.newf[0] = 'Z'; gSaveContext.save.info.playerData.newf[0] = 'Z';
@ -633,6 +635,9 @@ void Sram_VerifyAndLoadAllSaves(FileSelectState* fileSelect, SramContext* sramCt
} else { } else {
Sram_InitNewSave(); Sram_InitNewSave();
} }
#else
Sram_InitNewSave();
#endif
ptr = (u16*)&gSaveContext; ptr = (u16*)&gSaveContext;
PRINTF("\n--------------------------------------------------------------\n"); PRINTF("\n--------------------------------------------------------------\n");
@ -718,20 +723,26 @@ void Sram_InitSave(FileSelectState* fileSelect, SramContext* sramCtx) {
u16* ptr; u16* ptr;
u16 checksum; u16 checksum;
#if OOT_DEBUG
if (fileSelect->buttonIndex != 0) { if (fileSelect->buttonIndex != 0) {
Sram_InitNewSave(); Sram_InitNewSave();
} else { } else {
Sram_InitDebugSave(); Sram_InitDebugSave();
} }
#else
Sram_InitNewSave();
#endif
gSaveContext.save.entranceIndex = ENTR_LINKS_HOUSE_0; gSaveContext.save.entranceIndex = ENTR_LINKS_HOUSE_0;
gSaveContext.save.linkAge = LINK_AGE_CHILD; gSaveContext.save.linkAge = LINK_AGE_CHILD;
gSaveContext.save.dayTime = CLOCK_TIME(10, 0); gSaveContext.save.dayTime = CLOCK_TIME(10, 0);
gSaveContext.save.cutsceneIndex = 0xFFF1; gSaveContext.save.cutsceneIndex = 0xFFF1;
#if OOT_DEBUG
if (fileSelect->buttonIndex == 0) { if (fileSelect->buttonIndex == 0) {
gSaveContext.save.cutsceneIndex = 0; gSaveContext.save.cutsceneIndex = 0;
} }
#endif
for (offset = 0; offset < 8; offset++) { for (offset = 0; offset < 8; offset++) {
gSaveContext.save.info.playerData.playerName[offset] = fileSelect->fileNames[fileSelect->buttonIndex][offset]; gSaveContext.save.info.playerData.playerName[offset] = fileSelect->fileNames[fileSelect->buttonIndex][offset];
@ -753,10 +764,8 @@ void Sram_InitSave(FileSelectState* fileSelect, SramContext* sramCtx) {
PRINTF("\n$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$\n"); PRINTF("\n$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$\n");
ptr = (u16*)&gSaveContext; ptr = (u16*)&gSaveContext;
j = 0;
checksum = 0;
for (offset = 0; offset < CHECKSUM_SIZE; offset++) { for (j = 0, checksum = 0, offset = 0; offset < CHECKSUM_SIZE; offset++) {
PRINTF("%x ", *ptr); PRINTF("%x ", *ptr);
checksum += *ptr++; checksum += *ptr++;
if (++j == 0x20) { if (++j == 0x20) {
@ -893,6 +902,7 @@ void Sram_InitSram(GameState* gameState, SramContext* sramCtx) {
Sram_WriteSramHeader(sramCtx); Sram_WriteSramHeader(sramCtx);
} }
#if OOT_DEBUG
if (CHECK_BTN_ANY(gameState->input[2].cur.button, BTN_DRIGHT)) { if (CHECK_BTN_ANY(gameState->input[2].cur.button, BTN_DRIGHT)) {
bzero(sramCtx->readBuff, SRAM_SIZE); bzero(sramCtx->readBuff, SRAM_SIZE);
for (i = 0; i < CHECKSUM_SIZE; i++) { for (i = 0; i < CHECKSUM_SIZE; i++) {
@ -901,6 +911,7 @@ void Sram_InitSram(GameState* gameState, SramContext* sramCtx) {
SsSram_ReadWrite(OS_K1_TO_PHYSICAL(0xA8000000), sramCtx->readBuff, SRAM_SIZE, OS_WRITE); SsSram_ReadWrite(OS_K1_TO_PHYSICAL(0xA8000000), sramCtx->readBuff, SRAM_SIZE, OS_WRITE);
PRINTF("SRAM破壊!!!!!!\n"); // "SRAM destruction! ! ! ! ! !" PRINTF("SRAM破壊!!!!!!\n"); // "SRAM destruction! ! ! ! ! !"
} }
#endif
// "GOOD! GOOD! Size = %d + %d = %d" // "GOOD! GOOD! Size = %d + %d = %d"
PRINTF(" サイズ=%d + %d %d\n", sizeof(SaveInfo), 4, sizeof(SaveInfo) + 4); PRINTF(" サイズ=%d + %d %d\n", sizeof(SaveInfo), 4, sizeof(SaveInfo) + 4);

View file

@ -9,7 +9,7 @@ typedef struct {
SsSramContext sSsSramContext = { 0 }; SsSramContext sSsSramContext = { 0 };
void SsSram_Init(u32 addr, u8 handleType, u8 handleDomain, u8 handleLatency, u8 handlePageSize, u8 handleRelDuration, void SsSram_Init(s32 addr, u8 handleType, u8 handleDomain, u8 handleLatency, u8 handlePageSize, u8 handleRelDuration,
u8 handlePulse, u32 handleSpeed) { u8 handlePulse, u32 handleSpeed) {
u32 prevInt; u32 prevInt;
OSPiHandle* handle = &sSsSramContext.piHandle; OSPiHandle* handle = &sSsSramContext.piHandle;
@ -49,7 +49,7 @@ void SsSram_Dma(void* dramAddr, size_t size, s32 direction) {
osInvalDCache(dramAddr, size); osInvalDCache(dramAddr, size);
} }
void SsSram_ReadWrite(u32 addr, void* dramAddr, size_t size, s32 direction) { void SsSram_ReadWrite(s32 addr, void* dramAddr, size_t size, s32 direction) {
PRINTF("ssSRAMReadWrite:%08x %08x %08x %d\n", addr, dramAddr, size, direction); PRINTF("ssSRAMReadWrite:%08x %08x %08x %d\n", addr, dramAddr, size, direction);
SsSram_Init(addr, DEVICE_TYPE_SRAM, PI_DOMAIN2, 5, 0xD, 2, 0xC, 0); SsSram_Init(addr, DEVICE_TYPE_SRAM, PI_DOMAIN2, 5, 0xD, 2, 0xC, 0);
SsSram_Dma(dramAddr, size, direction); SsSram_Dma(dramAddr, size, direction);

View file

@ -47,14 +47,18 @@ extern u16 D_0E000000[];
void VisZBuf_Init(VisZBuf* this) { void VisZBuf_Init(VisZBuf* this) {
this->vis.type = VIS_ZBUF_TYPE_IA; this->vis.type = VIS_ZBUF_TYPE_IA;
this->vis.scissorType = VIS_NO_SETSCISSOR; this->vis.scissorType = VIS_NO_SETSCISSOR;
this->vis.primColor.r = 255; this->vis.primColor.r = 255;
this->vis.primColor.g = 255; this->vis.primColor.g = 255;
this->vis.primColor.b = 255; this->vis.primColor.b = 255;
this->vis.primColor.a = 255; this->vis.primColor.a = 255;
// clang-format off
this->vis.envColor.r = 0; \
this->vis.envColor.g = 0; \
this->vis.envColor.b = 0; \
this->vis.envColor.a = 255; this->vis.envColor.a = 255;
this->vis.envColor.r = 0; // clang-format on
this->vis.envColor.g = 0;
this->vis.envColor.b = 0;
} }
void VisZBuf_Destroy(VisZBuf* this) { void VisZBuf_Destroy(VisZBuf* this) {

View file

@ -139,25 +139,6 @@ void ArmsHook_AttachHookToActor(ArmsHook* this, Actor* actor) {
void ArmsHook_Shoot(ArmsHook* this, PlayState* play) { void ArmsHook_Shoot(ArmsHook* this, PlayState* play) {
Player* player = GET_PLAYER(play); Player* player = GET_PLAYER(play);
Actor* touchedActor;
Actor* grabbed;
Vec3f bodyDistDiffVec;
Vec3f newPos;
f32 bodyDistDiff;
f32 phi_f16;
DynaPolyActor* dynaPolyActor;
f32 curGrabbedDist;
f32 grabbedDist;
s32 pad;
CollisionPoly* poly;
s32 bgId;
Vec3f intersectPos;
Vec3f prevFrameDiff;
Vec3f sp60;
f32 polyNormalX;
f32 polyNormalZ;
f32 velocity;
s32 pad1;
if ((this->actor.parent == NULL) || (!Player_HoldsHookshot(player))) { if ((this->actor.parent == NULL) || (!Player_HoldsHookshot(player))) {
ArmsHook_DetachHookFromActor(this); ArmsHook_DetachHookFromActor(this);
@ -170,7 +151,8 @@ void ArmsHook_Shoot(ArmsHook* this, PlayState* play) {
if ((this->timer != 0) && (this->collider.base.atFlags & AT_HIT) && if ((this->timer != 0) && (this->collider.base.atFlags & AT_HIT) &&
(this->collider.elem.atHitElem->elemType != ELEMTYPE_UNK4)) { (this->collider.elem.atHitElem->elemType != ELEMTYPE_UNK4)) {
touchedActor = this->collider.base.at; Actor* touchedActor = this->collider.base.at;
if ((touchedActor->update != NULL) && (touchedActor->flags & (ACTOR_FLAG_9 | ACTOR_FLAG_10))) { if ((touchedActor->update != NULL) && (touchedActor->flags & (ACTOR_FLAG_9 | ACTOR_FLAG_10))) {
if (this->collider.elem.atHitElem->bumperFlags & BUMP_HOOKABLE) { if (this->collider.elem.atHitElem->bumperFlags & BUMP_HOOKABLE) {
ArmsHook_AttachHookToActor(this, touchedActor); ArmsHook_AttachHookToActor(this, touchedActor);
@ -182,7 +164,20 @@ void ArmsHook_Shoot(ArmsHook* this, PlayState* play) {
this->timer = 0; this->timer = 0;
Audio_PlaySfxGeneral(NA_SE_IT_ARROW_STICK_CRE, &this->actor.projectedPos, 4, &gSfxDefaultFreqAndVolScale, Audio_PlaySfxGeneral(NA_SE_IT_ARROW_STICK_CRE, &this->actor.projectedPos, 4, &gSfxDefaultFreqAndVolScale,
&gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb);
} else if (DECR(this->timer) == 0) { return;
}
if (DECR(this->timer) == 0) {
Actor* grabbed;
Vec3f bodyDistDiffVec;
Vec3f newPos;
f32 bodyDistDiff;
f32 phi_f16;
s32 pad1;
f32 curGrabbedDist;
f32 grabbedDist;
f32 velocity;
grabbed = this->grabbed; grabbed = this->grabbed;
if (grabbed != NULL) { if (grabbed != NULL) {
if ((grabbed->update == NULL) || !CHECK_FLAG_ALL(grabbed->flags, ACTOR_FLAG_13)) { if ((grabbed->update == NULL) || !CHECK_FLAG_ALL(grabbed->flags, ACTOR_FLAG_13)) {
@ -250,6 +245,12 @@ void ArmsHook_Shoot(ArmsHook* this, PlayState* play) {
} }
} }
} else { } else {
CollisionPoly* poly;
s32 bgId;
Vec3f intersectPos;
Vec3f prevFrameDiff;
Vec3f sp60;
Actor_MoveXZGravity(&this->actor); Actor_MoveXZGravity(&this->actor);
Math_Vec3f_Diff(&this->actor.world.pos, &this->actor.prevPos, &prevFrameDiff); Math_Vec3f_Diff(&this->actor.world.pos, &this->actor.prevPos, &prevFrameDiff);
Math_Vec3f_Sum(&this->unk_1E8, &prevFrameDiff, &this->unk_1E8); Math_Vec3f_Sum(&this->unk_1E8, &prevFrameDiff, &this->unk_1E8);
@ -260,13 +261,17 @@ void ArmsHook_Shoot(ArmsHook* this, PlayState* play) {
if (BgCheck_EntityLineTest1(&play->colCtx, &sp60, &this->unk_1E8, &intersectPos, &poly, true, true, true, true, if (BgCheck_EntityLineTest1(&play->colCtx, &sp60, &this->unk_1E8, &intersectPos, &poly, true, true, true, true,
&bgId) && &bgId) &&
!func_8002F9EC(play, &this->actor, poly, bgId, &intersectPos)) { !func_8002F9EC(play, &this->actor, poly, bgId, &intersectPos)) {
polyNormalX = COLPOLY_GET_NORMAL(poly->normal.x); f32 polyNormalX = COLPOLY_GET_NORMAL(poly->normal.x);
polyNormalZ = COLPOLY_GET_NORMAL(poly->normal.z); f32 polyNormalZ = COLPOLY_GET_NORMAL(poly->normal.z);
s32 pad;
Math_Vec3f_Copy(&this->actor.world.pos, &intersectPos); Math_Vec3f_Copy(&this->actor.world.pos, &intersectPos);
this->actor.world.pos.x += 10.0f * polyNormalX; this->actor.world.pos.x += 10.0f * polyNormalX;
this->actor.world.pos.z += 10.0f * polyNormalZ; this->actor.world.pos.z += 10.0f * polyNormalZ;
this->timer = 0; this->timer = 0;
if (SurfaceType_CanHookshot(&play->colCtx, poly, bgId)) { if (SurfaceType_CanHookshot(&play->colCtx, poly, bgId)) {
DynaPolyActor* dynaPolyActor;
if (bgId != BGCHECK_SCENE) { if (bgId != BGCHECK_SCENE) {
dynaPolyActor = DynaPoly_GetActor(&play->colCtx, bgId); dynaPolyActor = DynaPoly_GetActor(&play->colCtx, bgId);
if (dynaPolyActor != NULL) { if (dynaPolyActor != NULL) {
@ -308,6 +313,8 @@ void ArmsHook_Draw(Actor* thisx, PlayState* play) {
if ((player->actor.draw != NULL) && (player->rightHandType == PLAYER_MODELTYPE_RH_HOOKSHOT)) { if ((player->actor.draw != NULL) && (player->rightHandType == PLAYER_MODELTYPE_RH_HOOKSHOT)) {
OPEN_DISPS(play->state.gfxCtx, "../z_arms_hook.c", 850); OPEN_DISPS(play->state.gfxCtx, "../z_arms_hook.c", 850);
if (1) {}
if ((ArmsHook_Shoot != this->actionFunc) || (this->timer <= 0)) { if ((ArmsHook_Shoot != this->actionFunc) || (this->timer <= 0)) {
Matrix_MultVec3f(&D_80865B70, &this->unk_1E8); Matrix_MultVec3f(&D_80865B70, &this->unk_1E8);
Matrix_MultVec3f(&D_80865B88, &hookNewTip); Matrix_MultVec3f(&D_80865B88, &hookNewTip);

View file

@ -90,17 +90,21 @@ static InitChainEntry sInitChain[] = {
static Vec3f D_8086E0E0 = { 0.0f, 140.0f, 0.0f }; static Vec3f D_8086E0E0 = { 0.0f, 140.0f, 0.0f };
void BgBdanSwitch_InitDynaPoly(BgBdanSwitch* this, PlayState* play, CollisionHeader* collision, s32 flag) { void BgBdanSwitch_InitDynaPoly(BgBdanSwitch* this, PlayState* play, CollisionHeader* collision, s32 flag) {
s16 pad1; s32 pad;
CollisionHeader* colHeader = NULL; CollisionHeader* colHeader = NULL;
s16 pad2;
DynaPolyActor_Init(&this->dyna, flag); DynaPolyActor_Init(&this->dyna, flag);
CollisionHeader_GetVirtual(collision, &colHeader); CollisionHeader_GetVirtual(collision, &colHeader);
this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader);
#if OOT_DEBUG
if (this->dyna.bgId == BG_ACTOR_MAX) { if (this->dyna.bgId == BG_ACTOR_MAX) {
s32 pad2;
PRINTF("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", "../z_bg_bdan_switch.c", 325, PRINTF("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", "../z_bg_bdan_switch.c", 325,
this->dyna.actor.id, this->dyna.actor.params); this->dyna.actor.id, this->dyna.actor.params);
} }
#endif
} }
void BgBdanSwitch_InitCollision(BgBdanSwitch* this, PlayState* play) { void BgBdanSwitch_InitCollision(BgBdanSwitch* this, PlayState* play) {

View file

@ -252,7 +252,7 @@ void BgDyYoseizo_ChooseType(BgDyYoseizo* this, PlayState* play) {
} }
if (givingReward) { if (givingReward) {
if (!IS_CUTSCENE_LAYER) { if (!IS_CUTSCENE_LAYER || !OOT_DEBUG) {
if (play->sceneId != SCENE_GREAT_FAIRYS_FOUNTAIN_MAGIC) { if (play->sceneId != SCENE_GREAT_FAIRYS_FOUNTAIN_MAGIC) {
switch (this->fountainType) { switch (this->fountainType) {
case FAIRY_SPELL_FARORES_WIND: case FAIRY_SPELL_FARORES_WIND:

View file

@ -97,12 +97,11 @@ void BgGanonOtyuka_Destroy(Actor* thisx, PlayState* play2) {
void BgGanonOtyuka_WaitToFall(BgGanonOtyuka* this, PlayState* play) { void BgGanonOtyuka_WaitToFall(BgGanonOtyuka* this, PlayState* play) {
Actor* thisx = &this->dyna.actor; Actor* thisx = &this->dyna.actor;
Actor* prop; Actor* prop;
BgGanonOtyuka* platform; s16 i;
f32 dx; f32 dx;
f32 dy; f32 dy;
f32 dz; f32 dz;
Vec3f center; Vec3f center;
s16 i;
if (this->isFalling || ((play->actorCtx.unk_02 != 0) && (this->dyna.actor.xyzDistToPlayerSq < SQ(70.0f)))) { if (this->isFalling || ((play->actorCtx.unk_02 != 0) && (this->dyna.actor.xyzDistToPlayerSq < SQ(70.0f)))) {
PRINTF("OTC O 1\n"); PRINTF("OTC O 1\n");
@ -113,20 +112,19 @@ void BgGanonOtyuka_WaitToFall(BgGanonOtyuka* this, PlayState* play) {
if ((prop == thisx) || (prop->id != ACTOR_BG_GANON_OTYUKA)) { if ((prop == thisx) || (prop->id != ACTOR_BG_GANON_OTYUKA)) {
prop = prop->next; prop = prop->next;
continue; continue;
}
platform = (BgGanonOtyuka*)prop;
dx = platform->dyna.actor.world.pos.x - this->dyna.actor.world.pos.x + D_80876A68[i].x;
dy = platform->dyna.actor.world.pos.y - this->dyna.actor.world.pos.y;
dz = platform->dyna.actor.world.pos.z - this->dyna.actor.world.pos.z + D_80876A68[i].z;
if ((fabsf(dx) < 10.0f) && (fabsf(dy) < 10.0f) && (fabsf(dz) < 10.0f)) {
platform->visibleSides |= sSides[i];
break;
} else { } else {
prop = prop->next; BgGanonOtyuka* platform = (BgGanonOtyuka*)prop;
dx = platform->dyna.actor.world.pos.x - this->dyna.actor.world.pos.x + D_80876A68[i].x;
dy = platform->dyna.actor.world.pos.y - this->dyna.actor.world.pos.y;
dz = platform->dyna.actor.world.pos.z - this->dyna.actor.world.pos.z + D_80876A68[i].z;
if ((fabsf(dx) < 10.0f) && (fabsf(dy) < 10.0f) && (fabsf(dz) < 10.0f)) {
platform->visibleSides |= sSides[i];
break;
}
} }
prop = prop->next;
} }
} }

View file

@ -125,15 +125,18 @@ void func_8087AF38(BgGndSoulmeiro* this, PlayState* play) {
} else if ((this->unk_198 % 6) == 0) { } else if ((this->unk_198 % 6) == 0) {
s32 i; s32 i;
s16 temp_2 = Rand_ZeroOne() * (10922.0f); // This should be: 0x10000 / 6.0f s16 temp_2 = Rand_ZeroOne() * (10922.0f); // This should be: 0x10000 / 6.0f
s16 temp_1;
f32 temp_3;
f32 temp_4;
f32 distXZ;
vecA.y = 0.0f; vecA.y = 0.0f;
vecB.y = thisx->world.pos.y; vecB.y = thisx->world.pos.y;
for (i = 0; i < 6; i++) { for (i = 0; i < 6; i++) {
s16 temp_1 = Rand_CenteredFloat(0x2800) + temp_2; temp_1 = Rand_CenteredFloat(0x2800) + temp_2;
f32 temp_3 = Math_SinS(temp_1); temp_3 = Math_SinS(temp_1);
f32 temp_4 = Math_CosS(temp_1); temp_4 = Math_CosS(temp_1);
f32 distXZ;
vecB.x = thisx->world.pos.x + (120.0f * temp_3); vecB.x = thisx->world.pos.x + (120.0f * temp_3);
vecB.z = thisx->world.pos.z + (120.0f * temp_4); vecB.z = thisx->world.pos.z + (120.0f * temp_4);

View file

@ -315,8 +315,6 @@ void BgHakaGate_DrawFlame(BgHakaGate* this, PlayState* play) {
if (this->vFlameScale > 0) { if (this->vFlameScale > 0) {
OPEN_DISPS(play->state.gfxCtx, "../z_bg_haka_gate.c", 716); OPEN_DISPS(play->state.gfxCtx, "../z_bg_haka_gate.c", 716);
if (1) {}
Gfx_SetupDL_25Xlu(play->state.gfxCtx); Gfx_SetupDL_25Xlu(play->state.gfxCtx);
gSPSegment(POLY_XLU_DISP++, 0x08, gSPSegment(POLY_XLU_DISP++, 0x08,
Gfx_TwoTexScroll(play->state.gfxCtx, G_TX_RENDERTILE, 0, 0, 0x20, 0x40, 1, 0, Gfx_TwoTexScroll(play->state.gfxCtx, G_TX_RENDERTILE, 0, 0, 0x20, 0x40, 1, 0,
@ -327,6 +325,9 @@ void BgHakaGate_DrawFlame(BgHakaGate* this, PlayState* play) {
Matrix_Translate(thisx->world.pos.x, thisx->world.pos.y + 15.0f, thisx->world.pos.z, MTXMODE_NEW); Matrix_Translate(thisx->world.pos.x, thisx->world.pos.y + 15.0f, thisx->world.pos.z, MTXMODE_NEW);
Matrix_RotateY(BINANG_TO_RAD(Camera_GetCamDirYaw(GET_ACTIVE_CAM(play))), MTXMODE_APPLY); Matrix_RotateY(BINANG_TO_RAD(Camera_GetCamDirYaw(GET_ACTIVE_CAM(play))), MTXMODE_APPLY);
scale = this->vFlameScale * 0.00001f; scale = this->vFlameScale * 0.00001f;
if (1) {}
Matrix_Scale(scale, scale, scale, MTXMODE_APPLY); Matrix_Scale(scale, scale, scale, MTXMODE_APPLY);
gSPMatrix(POLY_XLU_DISP++, MATRIX_NEW(play->state.gfxCtx, "../z_bg_haka_gate.c", 744), gSPMatrix(POLY_XLU_DISP++, MATRIX_NEW(play->state.gfxCtx, "../z_bg_haka_gate.c", 744),
G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);

View file

@ -85,14 +85,14 @@ void BgHakaMegane_Destroy(Actor* thisx, PlayState* play) {
} }
void func_8087DB24(BgHakaMegane* this, PlayState* play) { void func_8087DB24(BgHakaMegane* this, PlayState* play) {
CollisionHeader* colHeader;
CollisionHeader* collision;
if (Object_IsLoaded(&play->objectCtx, this->requiredObjectSlot)) { if (Object_IsLoaded(&play->objectCtx, this->requiredObjectSlot)) {
this->dyna.actor.objectSlot = this->requiredObjectSlot; this->dyna.actor.objectSlot = this->requiredObjectSlot;
this->dyna.actor.draw = BgHakaMegane_Draw; this->dyna.actor.draw = BgHakaMegane_Draw;
Actor_SetObjectDependency(play, &this->dyna.actor); Actor_SetObjectDependency(play, &this->dyna.actor);
if (play->roomCtx.curRoom.lensMode != LENS_MODE_HIDE_ACTORS) { if (play->roomCtx.curRoom.lensMode != LENS_MODE_HIDE_ACTORS) {
CollisionHeader* colHeader;
CollisionHeader* collision;
this->actionFunc = func_8087DBF0; this->actionFunc = func_8087DBF0;
collision = sCollisionHeaders[this->dyna.actor.params]; collision = sCollisionHeaders[this->dyna.actor.params];
if (collision != NULL) { if (collision != NULL) {

View file

@ -199,7 +199,11 @@ void BgHakaShip_Draw(Actor* thisx, PlayState* play) {
f32 angleTemp; f32 angleTemp;
OPEN_DISPS(play->state.gfxCtx, "../z_bg_haka_ship.c", 528); OPEN_DISPS(play->state.gfxCtx, "../z_bg_haka_ship.c", 528);
Gfx_SetupDL_25Opa(play->state.gfxCtx); Gfx_SetupDL_25Opa(play->state.gfxCtx);
if (1) {}
if (this->dyna.actor.params == 0) { if (this->dyna.actor.params == 0) {
gSPMatrix(POLY_OPA_DISP++, MATRIX_NEW(play->state.gfxCtx, "../z_bg_haka_ship.c", 534), gSPMatrix(POLY_OPA_DISP++, MATRIX_NEW(play->state.gfxCtx, "../z_bg_haka_ship.c", 534),
G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
@ -220,7 +224,9 @@ void BgHakaShip_Draw(Actor* thisx, PlayState* play) {
G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW);
gSPDisplayList(POLY_OPA_DISP++, object_haka_objects_DL_00E910); gSPDisplayList(POLY_OPA_DISP++, object_haka_objects_DL_00E910);
} }
CLOSE_DISPS(play->state.gfxCtx, "../z_bg_haka_ship.c", 568); CLOSE_DISPS(play->state.gfxCtx, "../z_bg_haka_ship.c", 568);
if (this->actionFunc == BgHakaShip_CutsceneStationary || this->actionFunc == BgHakaShip_Move) { if (this->actionFunc == BgHakaShip_CutsceneStationary || this->actionFunc == BgHakaShip_Move) {
s32 pad; s32 pad;
Vec3f sp2C; Vec3f sp2C;

View file

@ -352,6 +352,7 @@ void func_808806BC(BgHakaTrap* this, PlayState* play) {
f32 floorHeight; f32 floorHeight;
f32 yIntersect; f32 yIntersect;
s32 i; s32 i;
s32 bgId;
this->dyna.actor.velocity.y *= 1.6f; this->dyna.actor.velocity.y *= 1.6f;
@ -366,8 +367,6 @@ void func_808806BC(BgHakaTrap* this, PlayState* play) {
floorHeight = this->dyna.actor.floorHeight; floorHeight = this->dyna.actor.floorHeight;
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
s32 bgId;
yIntersect = yIntersect =
BgCheck_EntityRaycastDown4(&play->colCtx, &this->dyna.actor.floorPoly, &bgId, &this->dyna.actor, &vector) - BgCheck_EntityRaycastDown4(&play->colCtx, &this->dyna.actor.floorPoly, &bgId, &this->dyna.actor, &vector) -
25.0f; 25.0f;

View file

@ -490,6 +490,8 @@ void BgHeavyBlock_Draw(Actor* thisx, PlayState* play) {
OPEN_DISPS(play->state.gfxCtx, "../z_bg_heavy_block.c", 904); OPEN_DISPS(play->state.gfxCtx, "../z_bg_heavy_block.c", 904);
if (1) {}
if (BgHeavyBlock_LiftedUp == this->actionFunc) { if (BgHeavyBlock_LiftedUp == this->actionFunc) {
Matrix_SetTranslateRotateYXZ(player->leftHandPos.x, player->leftHandPos.y, player->leftHandPos.z, Matrix_SetTranslateRotateYXZ(player->leftHandPos.x, player->leftHandPos.y, player->leftHandPos.z,
&thisx->shape.rot); &thisx->shape.rot);

View file

@ -86,11 +86,12 @@ void BgHidanCurtain_Init(Actor* thisx, PlayState* play) {
this->treasureFlag = (thisx->params >> 6) & 0x3F; this->treasureFlag = (thisx->params >> 6) & 0x3F;
thisx->params &= 0x3F; thisx->params &= 0x3F;
if ((this->actor.params < 0) || (this->actor.params > 0x3F)) { if (OOT_DEBUG && ((this->actor.params < 0) || (this->actor.params > 0x3F))) {
// "Save bit is not set" // "Save bit is not set"
PRINTF("Warning : object のセーブビットが設定されていない(%s %d)(arg_data 0x%04x)\n", "../z_bg_hidan_curtain.c", PRINTF("Warning : object のセーブビットが設定されていない(%s %d)(arg_data 0x%04x)\n", "../z_bg_hidan_curtain.c",
373, this->actor.params); 373, this->actor.params);
} }
Actor_SetScale(&this->actor, hcParams->scale); Actor_SetScale(&this->actor, hcParams->scale);
Collider_InitCylinder(play, &this->collider); Collider_InitCylinder(play, &this->collider);
Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit); Collider_SetCylinder(play, &this->collider, &this->actor, &sCylinderInit);

View file

@ -58,8 +58,7 @@ static CollisionCheckInfoInit sColChkInfoInit = { 1, 80, 100, MASS_IMMOVABLE };
void BgHidanFirewall_Init(Actor* thisx, PlayState* play) { void BgHidanFirewall_Init(Actor* thisx, PlayState* play) {
BgHidanFirewall* this = (BgHidanFirewall*)thisx; BgHidanFirewall* this = (BgHidanFirewall*)thisx;
this->actor.scale.x = 0.12f; this->actor.scale.x = this->actor.scale.z = 0.12f;
this->actor.scale.z = 0.12f;
this->actor.scale.y = 0.01f; this->actor.scale.y = 0.01f;
this->unk_150 = 0; this->unk_150 = 0;

View file

@ -347,11 +347,13 @@ void func_80888A58(BgHidanHamstep* this, PlayState* play) {
Actor_MoveXZGravity(&this->dyna.actor); Actor_MoveXZGravity(&this->dyna.actor);
func_80888694(this, (BgHidanHamstep*)this->dyna.actor.parent); func_80888694(this, (BgHidanHamstep*)this->dyna.actor.parent);
#if OOT_DEBUG
if (((this->dyna.actor.params & 0xFF) <= 0) || ((this->dyna.actor.params & 0xFF) >= 6)) { if (((this->dyna.actor.params & 0xFF) <= 0) || ((this->dyna.actor.params & 0xFF) >= 6)) {
// "[Hammer Step] arg_data strange (arg_data = %d)" // "[Hammer Step] arg_data strange (arg_data = %d)"
PRINTF("【ハンマーステップ】 arg_data おかしい (arg_data = %d)", this->dyna.actor.params); PRINTF("【ハンマーステップ】 arg_data おかしい (arg_data = %d)", this->dyna.actor.params);
PRINTF("%s %d\n", "../z_bg_hidan_hamstep.c", 696); PRINTF("%s %d\n", "../z_bg_hidan_hamstep.c", 696);
} }
#endif
if (((this->dyna.actor.world.pos.y - this->dyna.actor.home.pos.y) <= if (((this->dyna.actor.world.pos.y - this->dyna.actor.home.pos.y) <=
sYPosOffsets[(this->dyna.actor.params & 0xFF) - 1]) && sYPosOffsets[(this->dyna.actor.params & 0xFF) - 1]) &&

View file

@ -82,6 +82,7 @@ void BgHidanHrock_Init(Actor* thisx, PlayState* play) {
s32 i; s32 i;
s32 j; s32 j;
CollisionHeader* collisionHeader = NULL; CollisionHeader* collisionHeader = NULL;
Vec3f* vtx;
Actor_ProcessInitChain(thisx, sInitChain); Actor_ProcessInitChain(thisx, sInitChain);
this->unk_16A = thisx->params & 0x3F; this->unk_16A = thisx->params & 0x3F;
@ -103,7 +104,7 @@ void BgHidanHrock_Init(Actor* thisx, PlayState* play) {
if (1) { if (1) {
for (j = 0; j < 3; j++) { for (j = 0; j < 3; j++) {
Vec3f* vtx = &colliderElementInit->dim.vtx[j]; vtx = &colliderElementInit->dim.vtx[j];
vertices[j].x = vtx->z * sinRotY + (thisx->home.pos.x + vtx->x * cosRotY); vertices[j].x = vtx->z * sinRotY + (thisx->home.pos.x + vtx->x * cosRotY);
vertices[j].y = vtx->y + thisx->home.pos.y; vertices[j].y = vtx->y + thisx->home.pos.y;

View file

@ -73,9 +73,12 @@ void BgHidanKousi_Init(Actor* thisx, PlayState* play) {
((s32)thisx->params >> 8) & 0xFF); ((s32)thisx->params >> 8) & 0xFF);
Actor_ProcessInitChain(thisx, sInitChain); Actor_ProcessInitChain(thisx, sInitChain);
#if OOT_DEBUG
if (((thisx->params & 0xFF) < 0) || ((thisx->params & 0xFF) >= 3)) { if (((thisx->params & 0xFF) < 0) || ((thisx->params & 0xFF) >= 3)) {
PRINTF("arg_data おかしい 【格子】\n"); PRINTF("arg_data おかしい 【格子】\n");
} }
#endif
CollisionHeader_GetVirtual(sMetalFencesCollisions[thisx->params & 0xFF], &colHeader); CollisionHeader_GetVirtual(sMetalFencesCollisions[thisx->params & 0xFF], &colHeader);
this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, thisx, colHeader); this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, thisx, colHeader);

View file

@ -130,9 +130,10 @@ void func_8088CEC0(BgHidanSekizou* this, s32 arg1, s16 arg2) {
s32 end = start + 3; s32 end = start + 3;
f32 sp30 = Math_SinS(arg2); f32 sp30 = Math_SinS(arg2);
f32 sp2C = Math_CosS(arg2); f32 sp2C = Math_CosS(arg2);
ColliderJntSphElement* element;
for (i = start; i < end; i++) { for (i = start; i < end; i++) {
ColliderJntSphElement* element = &this->collider.elements[i]; element = &this->collider.elements[i];
element->dim.worldSphere.center.x = this->dyna.actor.home.pos.x + (sp2C * element->dim.modelSphere.center.x) + element->dim.worldSphere.center.x = this->dyna.actor.home.pos.x + (sp2C * element->dim.modelSphere.center.x) +
(sp30 * element->dim.modelSphere.center.z); (sp30 * element->dim.modelSphere.center.z);
@ -301,8 +302,8 @@ Gfx* func_8088D9F4(PlayState* play, BgHidanSekizou* this, s16 arg2, MtxF* arg3,
f32 phi_f12; f32 phi_f12;
arg6 = (((arg6 + arg2) % 8) * 7) * (1 / 7.0f); arg6 = (((arg6 + arg2) % 8) * 7) * (1 / 7.0f);
arg2++;
gSPSegment(arg7++, 9, SEGMENTED_TO_VIRTUAL(sFireballsTexs[arg6])); gSPSegment(arg7++, 9, SEGMENTED_TO_VIRTUAL(sFireballsTexs[arg6]));
arg2++;
if (arg2 != 4) { if (arg2 != 4) {
phi_f12 = arg2 + ((4 - this->unk_170) / 4.0f); phi_f12 = arg2 + ((4 - this->unk_170) / 4.0f);
} else { } else {

View file

@ -115,17 +115,20 @@ void BgIceShelter_InitColliders(BgIceShelter* this, PlayState* play) {
void BgIceShelter_InitDynaPoly(BgIceShelter* this, PlayState* play, CollisionHeader* collision, s32 moveFlag) { void BgIceShelter_InitDynaPoly(BgIceShelter* this, PlayState* play, CollisionHeader* collision, s32 moveFlag) {
s32 pad; s32 pad;
CollisionHeader* colHeader = NULL; CollisionHeader* colHeader = NULL;
s32 pad2;
DynaPolyActor_Init(&this->dyna, moveFlag); DynaPolyActor_Init(&this->dyna, moveFlag);
CollisionHeader_GetVirtual(collision, &colHeader); CollisionHeader_GetVirtual(collision, &colHeader);
this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader);
#if OOT_DEBUG
if (this->dyna.bgId == BG_ACTOR_MAX) { if (this->dyna.bgId == BG_ACTOR_MAX) {
s32 pad2;
// "Warning : move BG registration failed" // "Warning : move BG registration failed"
PRINTF("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", "../z_bg_ice_shelter.c", 362, PRINTF("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", "../z_bg_ice_shelter.c", 362,
this->dyna.actor.id, this->dyna.actor.params); this->dyna.actor.id, this->dyna.actor.params);
} }
#endif
} }
void BgIceShelter_RotateY(Vec3f* dest, Vec3f* src, s16 angle) { void BgIceShelter_RotateY(Vec3f* dest, Vec3f* src, s16 angle) {
@ -144,7 +147,6 @@ static InitChainEntry sInitChain[] = {
}; };
void BgIceShelter_Init(Actor* thisx, PlayState* play) { void BgIceShelter_Init(Actor* thisx, PlayState* play) {
static Vec3f kzIceScale = { 0.18f, 0.27f, 0.24f };
BgIceShelter* this = (BgIceShelter*)thisx; BgIceShelter* this = (BgIceShelter*)thisx;
s16 type = BGICESHELTER_GET_TYPE(&this->dyna.actor); s16 type = BGICESHELTER_GET_TYPE(&this->dyna.actor);
@ -158,7 +160,9 @@ void BgIceShelter_Init(Actor* thisx, PlayState* play) {
} }
if (type == RED_ICE_KING_ZORA) { if (type == RED_ICE_KING_ZORA) {
Math_Vec3f_Copy(&this->dyna.actor.scale, &kzIceScale); static Vec3f sKingZoraRedIceScale = { 0.18f, 0.27f, 0.24f };
Math_Vec3f_Copy(&this->dyna.actor.scale, &sKingZoraRedIceScale);
} else { } else {
Actor_SetScale(&this->dyna.actor, sRedIceScales[type]); Actor_SetScale(&this->dyna.actor, sRedIceScales[type]);
} }

View file

@ -49,7 +49,6 @@ void BgIceShutter_Init(Actor* thisx, PlayState* play) {
f32 sp24; f32 sp24;
CollisionHeader* colHeader; CollisionHeader* colHeader;
s32 sp28; s32 sp28;
f32 temp_f6;
colHeader = NULL; colHeader = NULL;
Actor_ProcessInitChain(&this->dyna.actor, sInitChain); Actor_ProcessInitChain(&this->dyna.actor, sInitChain);
@ -78,7 +77,8 @@ void BgIceShutter_Init(Actor* thisx, PlayState* play) {
} }
if (sp28 == 2) { if (sp28 == 2) {
temp_f6 = Math_SinS(this->dyna.actor.shape.rot.x) * 50.0f; f32 temp_f6 = Math_SinS(this->dyna.actor.shape.rot.x) * 50.0f;
this->dyna.actor.focus.pos.x = this->dyna.actor.focus.pos.x =
(Math_SinS(this->dyna.actor.shape.rot.y) * temp_f6) + this->dyna.actor.home.pos.x; (Math_SinS(this->dyna.actor.shape.rot.y) * temp_f6) + this->dyna.actor.home.pos.x;
this->dyna.actor.focus.pos.y = this->dyna.actor.home.pos.y; this->dyna.actor.focus.pos.y = this->dyna.actor.home.pos.y;

View file

@ -69,17 +69,20 @@ static InitChainEntry sInitChain[] = {
void BgJya1flift_InitDynapoly(BgJya1flift* this, PlayState* play, CollisionHeader* collision, s32 moveFlag) { void BgJya1flift_InitDynapoly(BgJya1flift* this, PlayState* play, CollisionHeader* collision, s32 moveFlag) {
s32 pad; s32 pad;
CollisionHeader* colHeader = NULL; CollisionHeader* colHeader = NULL;
s32 pad2;
DynaPolyActor_Init(&this->dyna, moveFlag); DynaPolyActor_Init(&this->dyna, moveFlag);
CollisionHeader_GetVirtual(collision, &colHeader); CollisionHeader_GetVirtual(collision, &colHeader);
this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader);
#if OOT_DEBUG
if (this->dyna.bgId == BG_ACTOR_MAX) { if (this->dyna.bgId == BG_ACTOR_MAX) {
s32 pad2;
// "Warning : move BG login failed" // "Warning : move BG login failed"
PRINTF("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", "../z_bg_jya_1flift.c", 179, PRINTF("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", "../z_bg_jya_1flift.c", 179,
this->dyna.actor.id, this->dyna.actor.params); this->dyna.actor.id, this->dyna.actor.params);
} }
#endif
} }
void BgJya1flift_InitCollision(Actor* thisx, PlayState* play) { void BgJya1flift_InitCollision(Actor* thisx, PlayState* play) {

View file

@ -45,15 +45,19 @@ static InitChainEntry sInitChain[] = {
void BgJyaAmishutter_InitDynaPoly(BgJyaAmishutter* this, PlayState* play, CollisionHeader* collision, s32 flag) { void BgJyaAmishutter_InitDynaPoly(BgJyaAmishutter* this, PlayState* play, CollisionHeader* collision, s32 flag) {
s32 pad1; s32 pad1;
CollisionHeader* colHeader = NULL; CollisionHeader* colHeader = NULL;
s32 pad2;
DynaPolyActor_Init(&this->dyna, flag); DynaPolyActor_Init(&this->dyna, flag);
CollisionHeader_GetVirtual(collision, &colHeader); CollisionHeader_GetVirtual(collision, &colHeader);
this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader);
#if OOT_DEBUG
if (this->dyna.bgId == BG_ACTOR_MAX) { if (this->dyna.bgId == BG_ACTOR_MAX) {
s32 pad2;
PRINTF("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", "../z_bg_jya_amishutter.c", 129, PRINTF("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", "../z_bg_jya_amishutter.c", 129,
this->dyna.actor.id, this->dyna.actor.params); this->dyna.actor.id, this->dyna.actor.params);
} }
#endif
} }
void BgJyaAmishutter_Init(Actor* thisx, PlayState* play) { void BgJyaAmishutter_Init(Actor* thisx, PlayState* play) {

View file

@ -74,10 +74,12 @@ void BgJyaBigmirror_HandleCobra(Actor* thisx, PlayState* play) {
this->puzzleFlags &= ~cobraPuzzleFlags[i]; this->puzzleFlags &= ~cobraPuzzleFlags[i];
} }
#if OOT_DEBUG
if (curCobraInfo->cobra->dyna.actor.update == NULL) { if (curCobraInfo->cobra->dyna.actor.update == NULL) {
// "Cobra deleted" // "Cobra deleted"
PRINTF("Error : コブラ削除された (%s %d)\n", "../z_bg_jya_bigmirror.c", 203); PRINTF("Error : コブラ削除された (%s %d)\n", "../z_bg_jya_bigmirror.c", 203);
} }
#endif
} else { } else {
curCobraInfo->cobra = (BgJyaCobra*)Actor_SpawnAsChild( curCobraInfo->cobra = (BgJyaCobra*)Actor_SpawnAsChild(
&play->actorCtx, &this->actor, play, ACTOR_BG_JYA_COBRA, curSpawnData->pos.x, curSpawnData->pos.y, &play->actorCtx, &this->actor, play, ACTOR_BG_JYA_COBRA, curSpawnData->pos.x, curSpawnData->pos.y,
@ -136,17 +138,10 @@ void BgJyaBigmirror_HandleMirRay(Actor* thisx, PlayState* play) {
this->lightBeams[1] = NULL; this->lightBeams[1] = NULL;
this->lightBeams[0] = NULL; this->lightBeams[0] = NULL;
} else { } else {
puzzleSolved = !!(this->puzzleFlags & (BIGMIR_PUZZLE_IN_STATUE_ROOM | BIGMIR_PUZZLE_IN_1ST_TOP_ROOM)); // Only spawn if puzzle solved
lightBeamToggles[0] = (this->puzzleFlags & (BIGMIR_PUZZLE_IN_STATUE_ROOM | BIGMIR_PUZZLE_IN_1ST_TOP_ROOM)) &&
if (puzzleSolved) { (this->puzzleFlags & BIGMIR_PUZZLE_COBRA2_SOLVED) &&
puzzleSolved = !!(this->puzzleFlags & BIGMIR_PUZZLE_COBRA2_SOLVED); (this->puzzleFlags & BIGMIR_PUZZLE_COBRA1_SOLVED);
if (puzzleSolved) {
puzzleSolved = !!(this->puzzleFlags & BIGMIR_PUZZLE_COBRA1_SOLVED);
}
}
lightBeamToggles[0] = puzzleSolved; // Only spawn if puzzle solved
if (1) {}
lightBeamToggles[1] = lightBeamToggles[2] = lightBeamToggles[1] = lightBeamToggles[2] =
this->puzzleFlags & (BIGMIR_PUZZLE_IN_1ST_TOP_ROOM | BIGMIR_PUZZLE_IN_2ND_TOP_ROOM); this->puzzleFlags & (BIGMIR_PUZZLE_IN_1ST_TOP_ROOM | BIGMIR_PUZZLE_IN_2ND_TOP_ROOM);
@ -158,10 +153,12 @@ void BgJyaBigmirror_HandleMirRay(Actor* thisx, PlayState* play) {
Actor_Spawn(&play->actorCtx, play, ACTOR_MIR_RAY, sMirRayPositions[i].x, sMirRayPositions[i].y, Actor_Spawn(&play->actorCtx, play, ACTOR_MIR_RAY, sMirRayPositions[i].x, sMirRayPositions[i].y,
sMirRayPositions[i].z, 0, 0, 0, sMirRayParamsVals[i]); sMirRayPositions[i].z, 0, 0, 0, sMirRayParamsVals[i]);
#if OOT_DEBUG
if (this->lightBeams[i] == NULL) { if (this->lightBeams[i] == NULL) {
// "Mir Ray generation failed" // "Mir Ray generation failed"
PRINTF("Error : Mir Ray 発生失敗 (%s %d)\n", "../z_bg_jya_bigmirror.c", 310); PRINTF("Error : Mir Ray 発生失敗 (%s %d)\n", "../z_bg_jya_bigmirror.c", 310);
} }
#endif
} }
} else { } else {
if (this->lightBeams[i] != NULL) { if (this->lightBeams[i] != NULL) {

View file

@ -63,19 +63,22 @@ static InitChainEntry sInitChain[] = {
}; };
void BgJyaBombiwa_SetupDynaPoly(BgJyaBombiwa* this, PlayState* play, CollisionHeader* collision, s32 flag) { void BgJyaBombiwa_SetupDynaPoly(BgJyaBombiwa* this, PlayState* play, CollisionHeader* collision, s32 flag) {
s16 pad1; s32 pad1;
CollisionHeader* colHeader = NULL; CollisionHeader* colHeader = NULL;
s16 pad2;
DynaPolyActor_Init(&this->dyna, flag); DynaPolyActor_Init(&this->dyna, flag);
CollisionHeader_GetVirtual(collision, &colHeader); CollisionHeader_GetVirtual(collision, &colHeader);
this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader);
#if OOT_DEBUG
if (this->dyna.bgId == BG_ACTOR_MAX) { if (this->dyna.bgId == BG_ACTOR_MAX) {
s32 pad2;
// "Warning: move BG registration failed" // "Warning: move BG registration failed"
PRINTF("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", "../z_bg_jya_bombiwa.c", 174, PRINTF("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", "../z_bg_jya_bombiwa.c", 174,
this->dyna.actor.id, this->dyna.actor.params); this->dyna.actor.id, this->dyna.actor.params);
} }
#endif
} }
void BgJyaBombiwa_InitCollider(BgJyaBombiwa* this, PlayState* play) { void BgJyaBombiwa_InitCollider(BgJyaBombiwa* this, PlayState* play) {

View file

@ -118,27 +118,34 @@ void func_808958F0(Vec3f* dest, Vec3f* src, f32 arg2, f32 arg3) {
void BgJyaCobra_InitDynapoly(BgJyaCobra* this, PlayState* play, CollisionHeader* collision, s32 flags) { void BgJyaCobra_InitDynapoly(BgJyaCobra* this, PlayState* play, CollisionHeader* collision, s32 flags) {
s32 pad; s32 pad;
CollisionHeader* colHeader = NULL; CollisionHeader* colHeader = NULL;
s32 pad2;
DynaPolyActor_Init(&this->dyna, flags); DynaPolyActor_Init(&this->dyna, flags);
CollisionHeader_GetVirtual(collision, &colHeader); CollisionHeader_GetVirtual(collision, &colHeader);
this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader);
#if OOT_DEBUG
if (this->dyna.bgId == BG_ACTOR_MAX) { if (this->dyna.bgId == BG_ACTOR_MAX) {
s32 pad2;
// "Warning : move BG Registration Failure" // "Warning : move BG Registration Failure"
PRINTF("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", "../z_bg_jya_cobra.c", 247, PRINTF("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", "../z_bg_jya_cobra.c", 247,
this->dyna.actor.id, this->dyna.actor.params); this->dyna.actor.id, this->dyna.actor.params);
} }
#endif
} }
void BgJyaCobra_SpawnRay(BgJyaCobra* this, PlayState* play) { void BgJyaCobra_SpawnRay(BgJyaCobra* this, PlayState* play) {
Actor_SpawnAsChild(&play->actorCtx, &this->dyna.actor, play, ACTOR_MIR_RAY, this->dyna.actor.world.pos.x, Actor_SpawnAsChild(&play->actorCtx, &this->dyna.actor, play, ACTOR_MIR_RAY, this->dyna.actor.world.pos.x,
this->dyna.actor.world.pos.y + 57.0f, this->dyna.actor.world.pos.z, 0, 0, 0, 6); this->dyna.actor.world.pos.y + 57.0f, this->dyna.actor.world.pos.z, 0, 0, 0, 6);
#if OOT_DEBUG
if (this->dyna.actor.child == NULL) { if (this->dyna.actor.child == NULL) {
PRINTF(VT_FGCOL(RED)); PRINTF(VT_FGCOL(RED));
// " : Mir Ray occurrence failure" // " : Mir Ray occurrence failure"
PRINTF(" : Mir Ray 発生失敗 (%s %d)\n", "../z_bg_jya_cobra.c", 270); PRINTF(" : Mir Ray 発生失敗 (%s %d)\n", "../z_bg_jya_cobra.c", 270);
PRINTF(VT_RST); PRINTF(VT_RST);
} }
#endif
} }
void func_80895A70(BgJyaCobra* this) { void func_80895A70(BgJyaCobra* this) {

View file

@ -106,10 +106,13 @@ void BgJyaIronobj_SpawnPillarParticles(BgJyaIronobj* this, PlayState* play, EnIk
f32 sins; f32 sins;
s32 pad[2]; s32 pad[2];
#if OOT_DEBUG
if (enIk->unk_2FF <= 0 || enIk->unk_2FF >= 4) { if (enIk->unk_2FF <= 0 || enIk->unk_2FF >= 4) {
PRINTF("Error 攻撃方法が分からない(%s %d)\n", "../z_bg_jya_ironobj.c", 233, enIk->unk_2FF); PRINTF("Error 攻撃方法が分からない(%s %d)\n", "../z_bg_jya_ironobj.c", 233, enIk->unk_2FF);
return; return;
} }
#endif
PRINTF("¢ attack_type(%d)\n", enIk->unk_2FF); PRINTF("¢ attack_type(%d)\n", enIk->unk_2FF);
rotY = Actor_WorldYawTowardActor(&this->dyna.actor, &enIk->actor) + D_808994D8[enIk->unk_2FF - 1]; rotY = Actor_WorldYawTowardActor(&this->dyna.actor, &enIk->actor) + D_808994D8[enIk->unk_2FF - 1];
@ -169,10 +172,13 @@ void BgJyaIronobj_SpawnThroneParticles(BgJyaIronobj* this, PlayState* play, EnIk
f32 sins; f32 sins;
s32 pad[2]; s32 pad[2];
#if OOT_DEBUG
if (enIk->unk_2FF <= 0 || enIk->unk_2FF >= 4) { if (enIk->unk_2FF <= 0 || enIk->unk_2FF >= 4) {
PRINTF("Error 攻撃方法が分からない(%s %d)\n", "../z_bg_jya_ironobj.c", 362, enIk->unk_2FF); PRINTF("Error 攻撃方法が分からない(%s %d)\n", "../z_bg_jya_ironobj.c", 362, enIk->unk_2FF);
return; return;
} }
#endif
PRINTF("¢ attack_type(%d)\n", enIk->unk_2FF); PRINTF("¢ attack_type(%d)\n", enIk->unk_2FF);
rotY = Actor_WorldYawTowardActor(&this->dyna.actor, &enIk->actor) + D_808994D8[enIk->unk_2FF - 1]; rotY = Actor_WorldYawTowardActor(&this->dyna.actor, &enIk->actor) + D_808994D8[enIk->unk_2FF - 1];
for (i = 0; i < 8; i++) { for (i = 0; i < 8; i++) {

View file

@ -43,15 +43,19 @@ static InitChainEntry sInitChain[] = {
void BgJyaKanaami_InitDynaPoly(BgJyaKanaami* this, PlayState* play, CollisionHeader* collision, s32 flag) { void BgJyaKanaami_InitDynaPoly(BgJyaKanaami* this, PlayState* play, CollisionHeader* collision, s32 flag) {
s32 pad; s32 pad;
CollisionHeader* colHeader = NULL; CollisionHeader* colHeader = NULL;
s32 pad2;
DynaPolyActor_Init(&this->dyna, flag); DynaPolyActor_Init(&this->dyna, flag);
CollisionHeader_GetVirtual(collision, &colHeader); CollisionHeader_GetVirtual(collision, &colHeader);
this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader);
#if OOT_DEBUG
if (this->dyna.bgId == BG_ACTOR_MAX) { if (this->dyna.bgId == BG_ACTOR_MAX) {
s32 pad2;
PRINTF("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", "../z_bg_jya_kanaami.c", 145, PRINTF("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", "../z_bg_jya_kanaami.c", 145,
this->dyna.actor.id, this->dyna.actor.params); this->dyna.actor.id, this->dyna.actor.params);
} }
#endif
} }
void BgJyaKanaami_Init(Actor* thisx, PlayState* play) { void BgJyaKanaami_Init(Actor* thisx, PlayState* play) {

View file

@ -217,10 +217,11 @@ void BgJyaMegami_DetectLight(BgJyaMegami* this, PlayState* play) {
void BgJyaMegami_SetupExplode(BgJyaMegami* this) { void BgJyaMegami_SetupExplode(BgJyaMegami* this) {
u32 i; u32 i;
Vec3f* pos = &this->dyna.actor.world.pos;
this->actionFunc = BgJyaMegami_Explode; this->actionFunc = BgJyaMegami_Explode;
for (i = 0; i < ARRAY_COUNT(this->pieces); i++) { for (i = 0; i < ARRAY_COUNT(this->pieces); i++) {
Math_Vec3f_Copy(&this->pieces[i].pos, &this->dyna.actor.world.pos); Math_Vec3f_Copy(&this->pieces[i].pos, pos);
this->pieces[i].vel.x = sPiecesInit[i].velX; this->pieces[i].vel.x = sPiecesInit[i].velX;
} }
this->explosionTimer = 0; this->explosionTimer = 0;

View file

@ -62,15 +62,19 @@ static InitChainEntry sInitChain[] = {
void BgJyaZurerukabe_InitDynaPoly(BgJyaZurerukabe* this, PlayState* play, CollisionHeader* collision, s32 flag) { void BgJyaZurerukabe_InitDynaPoly(BgJyaZurerukabe* this, PlayState* play, CollisionHeader* collision, s32 flag) {
s32 pad; s32 pad;
CollisionHeader* colHeader = NULL; CollisionHeader* colHeader = NULL;
s32 pad2;
DynaPolyActor_Init(&this->dyna, flag); DynaPolyActor_Init(&this->dyna, flag);
CollisionHeader_GetVirtual(collision, &colHeader); CollisionHeader_GetVirtual(collision, &colHeader);
this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader);
#if OOT_DEBUG
if (this->dyna.bgId == BG_ACTOR_MAX) { if (this->dyna.bgId == BG_ACTOR_MAX) {
s32 pad2;
PRINTF("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", "../z_bg_jya_zurerukabe.c", 194, PRINTF("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", "../z_bg_jya_zurerukabe.c", 194,
this->dyna.actor.id, this->dyna.actor.params); this->dyna.actor.id, this->dyna.actor.params);
} }
#endif
} }
void func_8089B4C8(BgJyaZurerukabe* this, PlayState* play) { void func_8089B4C8(BgJyaZurerukabe* this, PlayState* play) {

View file

@ -182,7 +182,14 @@ void BgMizuBwall_Init(Actor* thisx, PlayState* play) {
this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader);
switch ((u16)this->dyna.actor.params & 0xF) { switch ((u16)this->dyna.actor.params & 0xF) {
case MIZUBWALL_FLOOR: case MIZUBWALL_FLOOR: {
f32 sin;
f32 cos;
s32 i;
s32 j;
Vec3f offset;
Vec3f vtx[3];
if (Flags_GetSwitch(play, ((u16)this->dyna.actor.params >> 8) & 0x3F)) { if (Flags_GetSwitch(play, ((u16)this->dyna.actor.params >> 8) & 0x3F)) {
DynaPoly_DisableCollision(play, &play->colCtx.dyna, this->dyna.bgId); DynaPoly_DisableCollision(play, &play->colCtx.dyna, this->dyna.bgId);
this->dList = NULL; this->dList = NULL;
@ -194,12 +201,8 @@ void BgMizuBwall_Init(Actor* thisx, PlayState* play) {
this->dyna.actor.params); this->dyna.actor.params);
Actor_Kill(&this->dyna.actor); Actor_Kill(&this->dyna.actor);
} else { } else {
f32 sin = Math_SinS(this->dyna.actor.shape.rot.y); sin = Math_SinS(this->dyna.actor.shape.rot.y);
f32 cos = Math_CosS(this->dyna.actor.shape.rot.y); cos = Math_CosS(this->dyna.actor.shape.rot.y);
s32 i;
s32 j;
Vec3f offset;
Vec3f vtx[3];
for (i = 0; i < ARRAY_COUNT(sTrisElementInitFloor); i++) { for (i = 0; i < ARRAY_COUNT(sTrisElementInitFloor); i++) {
for (j = 0; j < 3; j++) { for (j = 0; j < 3; j++) {
@ -217,7 +220,15 @@ void BgMizuBwall_Init(Actor* thisx, PlayState* play) {
} }
} }
break; break;
case MIZUBWALL_RUTO_ROOM: }
case MIZUBWALL_RUTO_ROOM: {
f32 sin;
f32 cos;
s32 i;
s32 j;
Vec3f offset;
Vec3f vtx[3];
if (Flags_GetSwitch(play, ((u16)this->dyna.actor.params >> 8) & 0x3F)) { if (Flags_GetSwitch(play, ((u16)this->dyna.actor.params >> 8) & 0x3F)) {
DynaPoly_DisableCollision(play, &play->colCtx.dyna, this->dyna.bgId); DynaPoly_DisableCollision(play, &play->colCtx.dyna, this->dyna.bgId);
this->dList = NULL; this->dList = NULL;
@ -229,12 +240,8 @@ void BgMizuBwall_Init(Actor* thisx, PlayState* play) {
this->dyna.actor.params); this->dyna.actor.params);
Actor_Kill(&this->dyna.actor); Actor_Kill(&this->dyna.actor);
} else { } else {
f32 sin = Math_SinS(this->dyna.actor.shape.rot.y); sin = Math_SinS(this->dyna.actor.shape.rot.y);
f32 cos = Math_CosS(this->dyna.actor.shape.rot.y); cos = Math_CosS(this->dyna.actor.shape.rot.y);
s32 i;
s32 j;
Vec3f offset;
Vec3f vtx[3];
for (i = 0; i < ARRAY_COUNT(sTrisElementInitRutoWall); i++) { for (i = 0; i < ARRAY_COUNT(sTrisElementInitRutoWall); i++) {
for (j = 0; j < 3; j++) { for (j = 0; j < 3; j++) {
@ -252,7 +259,15 @@ void BgMizuBwall_Init(Actor* thisx, PlayState* play) {
} }
} }
break; break;
case MIZUBWALL_UNUSED: }
case MIZUBWALL_UNUSED: {
f32 sin;
f32 cos;
s32 i;
s32 j;
Vec3f offset;
Vec3f vtx[3];
if (Flags_GetSwitch(play, ((u16)this->dyna.actor.params >> 8) & 0x3F)) { if (Flags_GetSwitch(play, ((u16)this->dyna.actor.params >> 8) & 0x3F)) {
DynaPoly_DisableCollision(play, &play->colCtx.dyna, this->dyna.bgId); DynaPoly_DisableCollision(play, &play->colCtx.dyna, this->dyna.bgId);
this->dList = NULL; this->dList = NULL;
@ -264,12 +279,8 @@ void BgMizuBwall_Init(Actor* thisx, PlayState* play) {
this->dyna.actor.params); this->dyna.actor.params);
Actor_Kill(&this->dyna.actor); Actor_Kill(&this->dyna.actor);
} else { } else {
f32 sin = Math_SinS(this->dyna.actor.shape.rot.y); sin = Math_SinS(this->dyna.actor.shape.rot.y);
f32 cos = Math_CosS(this->dyna.actor.shape.rot.y); cos = Math_CosS(this->dyna.actor.shape.rot.y);
s32 i;
s32 j;
Vec3f offset;
Vec3f vtx[3];
for (i = 0; i < ARRAY_COUNT(sTrisElementInitFloor); i++) { for (i = 0; i < ARRAY_COUNT(sTrisElementInitFloor); i++) {
for (j = 0; j < 3; j++) { for (j = 0; j < 3; j++) {
@ -289,7 +300,15 @@ void BgMizuBwall_Init(Actor* thisx, PlayState* play) {
} }
} }
break; break;
case MIZUBWALL_STINGER_ROOM_1: }
case MIZUBWALL_STINGER_ROOM_1: {
f32 sin;
f32 cos;
s32 i;
s32 j;
Vec3f offset;
Vec3f vtx[3];
if (Flags_GetSwitch(play, ((u16)this->dyna.actor.params >> 8) & 0x3F)) { if (Flags_GetSwitch(play, ((u16)this->dyna.actor.params >> 8) & 0x3F)) {
DynaPoly_DisableCollision(play, &play->colCtx.dyna, this->dyna.bgId); DynaPoly_DisableCollision(play, &play->colCtx.dyna, this->dyna.bgId);
this->dList = NULL; this->dList = NULL;
@ -302,12 +321,8 @@ void BgMizuBwall_Init(Actor* thisx, PlayState* play) {
this->dyna.actor.params); this->dyna.actor.params);
Actor_Kill(&this->dyna.actor); Actor_Kill(&this->dyna.actor);
} else { } else {
f32 sin = Math_SinS(this->dyna.actor.shape.rot.y); sin = Math_SinS(this->dyna.actor.shape.rot.y);
f32 cos = Math_CosS(this->dyna.actor.shape.rot.y); cos = Math_CosS(this->dyna.actor.shape.rot.y);
s32 i;
s32 j;
Vec3f offset;
Vec3f vtx[3];
for (i = 0; i < ARRAY_COUNT(sTrisElementInitFloor); i++) { for (i = 0; i < ARRAY_COUNT(sTrisElementInitFloor); i++) {
for (j = 0; j < 3; j++) { for (j = 0; j < 3; j++) {
@ -327,7 +342,15 @@ void BgMizuBwall_Init(Actor* thisx, PlayState* play) {
} }
} }
break; break;
case MIZUBWALL_STINGER_ROOM_2: }
case MIZUBWALL_STINGER_ROOM_2: {
f32 sin;
f32 cos;
s32 i;
s32 j;
Vec3f offset;
Vec3f vtx[3];
if (Flags_GetSwitch(play, ((u16)this->dyna.actor.params >> 8) & 0x3F)) { if (Flags_GetSwitch(play, ((u16)this->dyna.actor.params >> 8) & 0x3F)) {
DynaPoly_DisableCollision(play, &play->colCtx.dyna, this->dyna.bgId); DynaPoly_DisableCollision(play, &play->colCtx.dyna, this->dyna.bgId);
this->dList = NULL; this->dList = NULL;
@ -340,12 +363,8 @@ void BgMizuBwall_Init(Actor* thisx, PlayState* play) {
this->dyna.actor.params); this->dyna.actor.params);
Actor_Kill(&this->dyna.actor); Actor_Kill(&this->dyna.actor);
} else { } else {
f32 sin = Math_SinS(this->dyna.actor.shape.rot.y); sin = Math_SinS(this->dyna.actor.shape.rot.y);
f32 cos = Math_CosS(this->dyna.actor.shape.rot.y); cos = Math_CosS(this->dyna.actor.shape.rot.y);
s32 i;
s32 j;
Vec3f offset;
Vec3f vtx[3];
for (i = 0; i < ARRAY_COUNT(sTrisElementInitFloor); i++) { for (i = 0; i < ARRAY_COUNT(sTrisElementInitFloor); i++) {
for (j = 0; j < 3; j++) { for (j = 0; j < 3; j++) {
@ -365,6 +384,7 @@ void BgMizuBwall_Init(Actor* thisx, PlayState* play) {
} }
} }
break; break;
}
} }
} }
@ -377,9 +397,8 @@ void BgMizuBwall_Destroy(Actor* thisx, PlayState* play) {
} }
void BgMizuBwall_SetAlpha(BgMizuBwall* this, PlayState* play) { void BgMizuBwall_SetAlpha(BgMizuBwall* this, PlayState* play) {
f32 waterLevel = play->colCtx.colHeader->waterBoxes[2].ySurface; WaterBox* waterBoxes = play->colCtx.colHeader->waterBoxes;
f32 waterLevel = waterBoxes[2].ySurface;
if (play->colCtx.colHeader->waterBoxes) {}
if (waterLevel < WATER_TEMPLE_WATER_F1_Y) { if (waterLevel < WATER_TEMPLE_WATER_F1_Y) {
this->scrollAlpha1 = 255; this->scrollAlpha1 = 255;

View file

@ -53,6 +53,7 @@ static InitChainEntry sInitChain[] = {
u32 BgMizuWater_GetWaterLevelActionIndex(s16 switchFlag, PlayState* play) { u32 BgMizuWater_GetWaterLevelActionIndex(s16 switchFlag, PlayState* play) {
u32 ret; u32 ret;
#if OOT_DEBUG
if (bREG(0) != 0) { if (bREG(0) != 0) {
switch (bREG(1)) { switch (bREG(1)) {
case 0: case 0:
@ -67,6 +68,8 @@ u32 BgMizuWater_GetWaterLevelActionIndex(s16 switchFlag, PlayState* play) {
} }
bREG(0) = 0; bREG(0) = 0;
} }
#endif
if (Flags_GetSwitch(play, WATER_TEMPLE_WATER_F1_FLAG) && (switchFlag != WATER_TEMPLE_WATER_F1_FLAG)) { if (Flags_GetSwitch(play, WATER_TEMPLE_WATER_F1_FLAG) && (switchFlag != WATER_TEMPLE_WATER_F1_FLAG)) {
ret = 3; ret = 3;
} else if (Flags_GetSwitch(play, WATER_TEMPLE_WATER_F2_FLAG) && (switchFlag != WATER_TEMPLE_WATER_F2_FLAG)) { } else if (Flags_GetSwitch(play, WATER_TEMPLE_WATER_F2_FLAG) && (switchFlag != WATER_TEMPLE_WATER_F2_FLAG)) {
@ -297,10 +300,13 @@ void BgMizuWater_Update(Actor* thisx, PlayState* play) {
s32 unk1; s32 unk1;
s32 pad; s32 pad;
#if OOT_DEBUG
if (bREG(15) == 0) { if (bREG(15) == 0) {
PRINTF("%x %x %x\n", Flags_GetSwitch(play, WATER_TEMPLE_WATER_F1_FLAG), PRINTF("%x %x %x\n", Flags_GetSwitch(play, WATER_TEMPLE_WATER_F1_FLAG),
Flags_GetSwitch(play, WATER_TEMPLE_WATER_F2_FLAG), Flags_GetSwitch(play, WATER_TEMPLE_WATER_F3_FLAG)); Flags_GetSwitch(play, WATER_TEMPLE_WATER_F2_FLAG), Flags_GetSwitch(play, WATER_TEMPLE_WATER_F3_FLAG));
} }
#endif
if (this->type == 0) { if (this->type == 0) {
posY = this->actor.world.pos.y; posY = this->actor.world.pos.y;
unk0 = 0; unk0 = 0;

View file

@ -53,17 +53,20 @@ void BgMoriBigst_SetupAction(BgMoriBigst* this, BgMoriBigstActionFunc actionFunc
void BgMoriBigst_InitDynapoly(BgMoriBigst* this, PlayState* play, CollisionHeader* collision, s32 moveFlag) { void BgMoriBigst_InitDynapoly(BgMoriBigst* this, PlayState* play, CollisionHeader* collision, s32 moveFlag) {
s32 pad; s32 pad;
CollisionHeader* colHeader = NULL; CollisionHeader* colHeader = NULL;
s32 pad2;
DynaPolyActor_Init(&this->dyna, moveFlag); DynaPolyActor_Init(&this->dyna, moveFlag);
CollisionHeader_GetVirtual(collision, &colHeader); CollisionHeader_GetVirtual(collision, &colHeader);
this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader); this->dyna.bgId = DynaPoly_SetBgActor(play, &play->colCtx.dyna, &this->dyna.actor, colHeader);
#if OOT_DEBUG
if (this->dyna.bgId == BG_ACTOR_MAX) { if (this->dyna.bgId == BG_ACTOR_MAX) {
s32 pad2;
// "Warning : move BG login failed" // "Warning : move BG login failed"
PRINTF("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", "../z_bg_mori_bigst.c", 190, PRINTF("Warning : move BG 登録失敗(%s %d)(name %d)(arg_data 0x%04x)\n", "../z_bg_mori_bigst.c", 190,
this->dyna.actor.id, this->dyna.actor.params); this->dyna.actor.id, this->dyna.actor.params);
} }
#endif
} }
void BgMoriBigst_Init(Actor* thisx, PlayState* play) { void BgMoriBigst_Init(Actor* thisx, PlayState* play) {

Some files were not shown because too many files have changed in this diff Show more