1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-05-09 18:43:45 +00:00

merge main

This commit is contained in:
fig02 2025-04-30 15:19:16 -04:00
commit 07aaf900d7
272 changed files with 520 additions and 535 deletions

View file

@ -40,8 +40,6 @@ COMPILER ?= ido
VERSION ?= gc-eu-mq-dbg
# Number of threads to extract and compress with.
N_THREADS ?= $(shell nproc)
# Check code syntax with host compiler.
RUN_CC_CHECK ?= 1
# If DEBUG_OBJECTS is 1, produce additional debugging files such as objdump output or raw binaries for assets
DEBUG_OBJECTS ?= 0
# Set prefix to mips binutils binaries (mips-linux-gnu-ld => 'mips-linux-gnu-') - Change at your own risk!
@ -368,8 +366,8 @@ CPPFLAGS += -P -xc -fno-dollars-in-identifiers $(CPP_DEFINES)
ASFLAGS += -march=vr4300 -32 -no-pad-sections -Iinclude -I$(EXTRACTED_DIR)
ifeq ($(COMPILER),gcc)
CFLAGS += $(CPP_DEFINES) $(GBI_DEFINES) -G 0 -nostdinc $(INC) -march=vr4300 -mfix4300 -mabi=32 -mno-abicalls -mdivide-breaks -fno-PIC -fno-common -ffreestanding -funsigned-char -fbuiltin -fno-builtin-sinf -fno-builtin-cosf $(CHECK_WARNINGS)
CCASFLAGS += $(CPP_DEFINES) $(GBI_DEFINES) -G 0 -nostdinc $(INC) -march=vr4300 -mfix4300 -mabi=32 -mno-abicalls -fno-PIC -fno-common -Wa,-no-pad-sections
CFLAGS += $(CPP_DEFINES) $(GBI_DEFINES) -G 0 -nostdinc -MD $(INC) -march=vr4300 -mfix4300 -mabi=32 -mno-abicalls -mdivide-breaks -fno-PIC -fno-common -ffreestanding -funsigned-char -fbuiltin -fno-builtin-sinf -fno-builtin-cosf $(CHECK_WARNINGS)
CCASFLAGS += $(CPP_DEFINES) $(GBI_DEFINES) -G 0 -nostdinc -MD $(INC) -march=vr4300 -mfix4300 -mabi=32 -mno-abicalls -fno-PIC -fno-common -Wa,-no-pad-sections
MIPS_VERSION := -mips3
else
# Suppress warnings for wrong number of macro arguments (to fake variadic
@ -387,7 +385,7 @@ endif
ifeq ($(COMPILER),ido)
# Have CC_CHECK pretend to be a MIPS compiler
MIPS_BUILTIN_DEFS := -D_MIPS_ISA_MIPS2=2 -D_MIPS_ISA=_MIPS_ISA_MIPS2 -D_ABIO32=1 -D_MIPS_SIM=_ABIO32 -D_MIPS_SZINT=32 -D_MIPS_SZLONG=32 -D_MIPS_SZPTR=32
CC_CHECK = gcc -fno-builtin -fsyntax-only -funsigned-char -std=gnu90 -D_LANGUAGE_C $(CPP_DEFINES) $(MIPS_BUILTIN_DEFS) $(GBI_DEFINES) $(INC) $(CHECK_WARNINGS)
CC_CHECK = gcc -nostdinc -MD -fno-builtin -fsyntax-only -funsigned-char -std=gnu90 -D_LANGUAGE_C $(CPP_DEFINES) $(MIPS_BUILTIN_DEFS) $(GBI_DEFINES) $(INC) $(CHECK_WARNINGS)
ifeq ($(shell getconf LONG_BIT), 32)
# Work around memory allocation bug in QEMU
export QEMU_GUEST_BASE := 1
@ -396,7 +394,7 @@ ifeq ($(COMPILER),ido)
CC_CHECK += -m32
endif
else
RUN_CC_CHECK := 0
CC_CHECK = @:
endif
OBJDUMP_FLAGS := -d -r -z -Mreg-names=32
@ -468,7 +466,7 @@ SOUNDFONT_EXTRACT_XMLS := $(foreach dir,$(SOUNDFONT_EXTRACT_DIRS),$(wildcard $(d
SOUNDFONT_BUILD_XMLS := $(foreach f,$(SOUNDFONT_XMLS),$(BUILD_DIR)/$f) $(foreach f,$(SOUNDFONT_EXTRACT_XMLS),$(f:$(EXTRACTED_DIR)/%=$(BUILD_DIR)/%))
SOUNDFONT_O_FILES := $(foreach f,$(SOUNDFONT_BUILD_XMLS),$(f:.xml=.o))
SOUNDFONT_HEADERS := $(foreach f,$(SOUNDFONT_BUILD_XMLS),$(f:.xml=.h))
SOUNDFONT_DEP_FILES := $(foreach f,$(SOUNDFONT_O_FILES),$(f:.o=.d))
SOUNDFONT_DEP_FILES := $(foreach f,$(SOUNDFONT_O_FILES),$(f:.o=.c.d))
SEQUENCE_FILES := $(foreach dir,$(SEQUENCE_DIRS),$(wildcard $(dir)/*.seq))
SEQUENCE_EXTRACT_FILES := $(foreach dir,$(SEQUENCE_EXTRACT_DIRS),$(wildcard $(dir)/*.seq))
@ -502,7 +500,7 @@ OVL_RELOC_FILES := $(filter %_reloc.o,$(SPEC_O_FILES))
# Automatic dependency files
# (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=.d) $(O_FILES:.o=.asmproc.d) $(OVL_RELOC_FILES:.o=.d) $(BUILD_DIR)/spec.d
TEXTURE_FILES_PNG_EXTRACTED := $(foreach dir,$(ASSET_BIN_DIRS_EXTRACTED),$(wildcard $(dir)/*.png))
TEXTURE_FILES_PNG_COMMITTED := $(foreach dir,$(ASSET_BIN_DIRS_COMMITTED),$(wildcard $(dir)/*.png))
@ -860,7 +858,7 @@ $(O_FILES): | asset_files
.PHONY: o_files asset_files
$(BUILD_DIR)/spec: $(SPEC) $(SPEC_INCLUDES)
$(CPP) $(CPPFLAGS) -I. $< | $(BUILD_DIR_REPLACE) > $@
$(CPP) $(CPPFLAGS) -MD -MF $@.d -MT $@ -I. $< | $(BUILD_DIR_REPLACE) > $@
$(LDSCRIPT): $(BUILD_DIR)/spec
$(MKLDSCRIPT) $< $@
@ -872,7 +870,7 @@ $(BUILD_DIR)/baserom/%.o: $(EXTRACTED_DIR)/baserom/%
$(OBJCOPY) -I binary -O elf32-big $< $@
$(BUILD_DIR)/data/%.o: data/%.s
$(CPP) $(CPPFLAGS) -Iinclude $< | $(AS) $(ASFLAGS) -o $@
$(CPP) $(CPPFLAGS) -MD -MF $(@:.o=.d) -MT $@ -Iinclude $< | $(AS) $(ASFLAGS) -o $@
ifeq ($(PLATFORM),IQUE)
NES_CHARMAP := assets/text/charmap.chn.txt
@ -881,24 +879,23 @@ else
endif
$(BUILD_DIR)/assets/text/%.enc.nes.h: assets/text/%.h $(EXTRACTED_DIR)/text/%.h $(NES_CHARMAP)
$(CPP) $(CPPFLAGS) -I$(EXTRACTED_DIR) $< | $(PYTHON) tools/msgenc.py --encoding utf-8 --charmap $(NES_CHARMAP) - $@
$(CPP) $(CPPFLAGS) -I$(EXTRACTED_DIR) -MD -MF $(@:.o=.d) -MT $@ $< | $(PYTHON) tools/msgenc.py --encoding utf-8 --charmap $(NES_CHARMAP) - $@
$(BUILD_DIR)/assets/text/%.enc.jpn.h: assets/text/%.h $(EXTRACTED_DIR)/text/%.h assets/text/charmap.jpn.txt
$(CPP) $(CPPFLAGS) -I$(EXTRACTED_DIR) $< | $(PYTHON) tools/msgenc.py --encoding SHIFT-JIS --wchar --charmap assets/text/charmap.jpn.txt - $@
$(CPP) $(CPPFLAGS) -I$(EXTRACTED_DIR) -MD -MF $(@:.o=.d) -MT $@ $< | $(PYTHON) tools/msgenc.py --encoding SHIFT-JIS --wchar --charmap assets/text/charmap.jpn.txt - $@
# Dependencies for files including message data headers
# TODO remove when full header dependencies are used.
# Dependencies for encoded message headers. These dependencies are not automatic as these headers are generated
# as part of the build. A clean build must know to generate them before the relevant .d files are created.
$(BUILD_DIR)/assets/text/jpn_message_data_static.o: $(BUILD_DIR)/assets/text/message_data.enc.jpn.h
$(BUILD_DIR)/assets/text/nes_message_data_static.o: $(BUILD_DIR)/assets/text/message_data.enc.nes.h
$(BUILD_DIR)/assets/text/ger_message_data_static.o: $(BUILD_DIR)/assets/text/message_data.enc.nes.h
$(BUILD_DIR)/assets/text/fra_message_data_static.o: $(BUILD_DIR)/assets/text/message_data.enc.nes.h
$(BUILD_DIR)/assets/text/staff_message_data_static.o: $(BUILD_DIR)/assets/text/message_data_staff.enc.nes.h
$(BUILD_DIR)/src/code/z_message.o: assets/text/message_data.h assets/text/message_data_staff.h
$(BUILD_DIR)/assets/text/%.o: assets/text/%.c
ifneq ($(COMPILER),gcc)
# Preprocess text with modern cpp for varargs macros
$(CPP) -undef -D_LANGUAGE_C -D__sgi $(CPPFLAGS) $(INC) $< -o $(@:.o=.c)
$(CPP) -undef -D_LANGUAGE_C -D__sgi $(CPPFLAGS) -MD -MT $@ $(INC) $< -o $(@:.o=.c)
$(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -o $@ $(@:.o=.c)
else
$(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -o $@ $<
@ -906,17 +903,19 @@ endif
$(OBJCOPY) -O binary --only-section .rodata $@ $@.bin
$(BUILD_DIR)/assets/%.o: assets/%.c
$(CC_CHECK) $< -o $@
$(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -o $@ $<
$(OBJCOPY_CMD)
$(BUILD_DIR)/assets/%.o: $(EXTRACTED_DIR)/assets/%.c
$(CC_CHECK) $< -o $@
$(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -o $@ $<
$(OBJCOPY_CMD)
# Assemble the ROM header with GNU AS always
$(BUILD_DIR)/src/makerom/rom_header.o: src/makerom/rom_header.s
ifeq ($(COMPILER),ido)
$(CPP) $(CPPFLAGS) $(MIPS_BUILTIN_DEFS) $(INC) $< | $(AS) $(ASFLAGS) -o $@
$(CPP) $(CPPFLAGS) $(MIPS_BUILTIN_DEFS) $(INC) -MD -MF $(@:.o=.d) -MT $@ $< | $(AS) $(ASFLAGS) -o $@
else
$(CCAS) -c $(CCASFLAGS) $(MIPS_VERSION) $(ASOPTFLAGS) -o $@ $<
endif
@ -927,12 +926,15 @@ $(BUILD_DIR)/src/makerom/ipl3.o: $(EXTRACTED_DIR)/incbin/ipl3
$(BUILD_DIR)/src/%.o: src/%.s
ifeq ($(COMPILER),ido)
# For header dependencies
$(CPP) $(MIPS_BUILTIN_DEFS) $(CPPFLAGS) -x assembler-with-cpp $(INC) -MD -MF $(@:.o=.d) -MT $@ $< -o /dev/null
$(CCAS) -c $(CCASFLAGS) $(MIPS_VERSION) $(ASOPTFLAGS) -o $(@:.o=.tmp.o) $<
# IDO generates bad symbol tables, fix the symbol table with strip..
$(STRIP) $(@:.o=.tmp.o) -N dummy-symbol-name
# but strip doesn't know about file-relative offsets in .mdebug and doesn't relocate them, ld will
# segfault unless .mdebug is removed
$(OBJCOPY) --remove-section .mdebug $(@:.o=.tmp.o) $@
@$(RM) $(@:.o=.tmp.o)
else
$(CCAS) -c $(CCASFLAGS) $(MIPS_VERSION) $(ASOPTFLAGS) -o $@ $<
endif
@ -944,6 +946,8 @@ $(BUILD_DIR)/src/code/z_message_z_game_over.o: $(BUILD_DIR)/src/code/z_message.o
$(LD) -r -G 0 -T linker_scripts/data_with_rodata.ld -o $@ $^
$(PYTHON) tools/patch_data_with_rodata_mdebug.py $@
DEP_FILES += $(BUILD_DIR)/src/code/z_message.d $(BUILD_DIR)/src/code/z_game_over.d
$(BUILD_DIR)/dmadata_table_spec.h $(BUILD_DIR)/compress_ranges.txt: $(BUILD_DIR)/spec
$(MKDMADATA) $< $(BUILD_DIR)/dmadata_table_spec.h $(BUILD_DIR)/compress_ranges.txt
@ -951,34 +955,18 @@ $(BUILD_DIR)/dmadata_table_spec.h $(BUILD_DIR)/compress_ranges.txt: $(BUILD_DIR)
$(BUILD_DIR)/src/boot/z_std_dma.o: $(BUILD_DIR)/dmadata_table_spec.h
$(BUILD_DIR)/src/dmadata/dmadata.o: $(BUILD_DIR)/dmadata_table_spec.h
# Dependencies for files including from include/tables/
# TODO remove when full header dependencies are used.
$(BUILD_DIR)/src/code/graph.o: include/tables/gamestate_table.h
$(BUILD_DIR)/src/code/object_table.o: include/tables/object_table.h
$(BUILD_DIR)/src/code/z_actor.o: include/tables/actor_table.h # so uses of ACTOR_ID_MAX update when the table length changes
$(BUILD_DIR)/src/code/z_actor_dlftbls.o: include/tables/actor_table.h
$(BUILD_DIR)/src/code/z_effect_soft_sprite_dlftbls.o: include/tables/effect_ss_table.h
$(BUILD_DIR)/src/code/z_game_dlftbls.o: include/tables/gamestate_table.h
$(BUILD_DIR)/src/code/z_scene_table.o: include/tables/scene_table.h include/tables/entrance_table.h
$(BUILD_DIR)/src/audio/general.o: $(SEQUENCE_TABLE) include/tables/sfx/*.h
$(BUILD_DIR)/src/audio/sfx_params.o: include/tables/sfx/*.h
$(BUILD_DIR)/src/%.o: src/%.c
ifneq ($(RUN_CC_CHECK),0)
$(CC_CHECK) $<
endif
$(CC_CHECK) $< -o $@
$(PREPROCESS) $(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -o $@ $<
$(POSTPROCESS_OBJ) $@
$(OBJDUMP_CMD)
$(BUILD_DIR)/src/audio/session_init.o: src/audio/session_init.c $(BUILD_DIR)/assets/audio/soundfont_sizes.h $(BUILD_DIR)/assets/audio/sequence_sizes.h
ifneq ($(RUN_CC_CHECK),0)
$(CC_CHECK) $<
endif
$(CC_CHECK) $< -o $@
$(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -o $(@:.o=.tmp) $<
$(LD) -r -T linker_scripts/data_with_rodata.ld -o $@ $(@:.o=.tmp)
$(PYTHON) tools/patch_data_with_rodata_mdebug.py $@
@$(OBJDUMP) $(OBJDUMP_FLAGS) $@ > $(@:.o=.s)
$(OBJDUMP_CMD)
ifeq ($(PLATFORM),IQUE)
ifneq ($(NON_MATCHING),1)
@ -1075,11 +1063,12 @@ $(BUILD_DIR)/assets/audio/soundfonts/%.xml: $(EXTRACTED_DIR)/assets/audio/soundf
$(BUILD_DIR)/assets/audio/soundfonts/%.c $(BUILD_DIR)/assets/audio/soundfonts/%.h $(BUILD_DIR)/assets/audio/soundfonts/%.name: $(BUILD_DIR)/assets/audio/soundfonts/%.xml | $(SAMPLEBANK_BUILD_XMLS) $(AIFC_FILES)
# This rule can be triggered for either the .c or .h file, so $@ may refer to either the .c or .h file. A simple
# substitution $(@:.c=.h) will fail ~50% of the time with -j. Instead, don't assume anything about the suffix of $@.
$(SFC) $(SFCFLAGS) --makedepend $(basename $@).d $< $(basename $@).c $(basename $@).h $(basename $@).name
$(SFC) $(SFCFLAGS) --makedepend $(basename $@).c.d $< $(basename $@).c $(basename $@).h $(basename $@).name
-include $(SOUNDFONT_DEP_FILES)
$(BUILD_DIR)/assets/audio/soundfonts/%.o: $(BUILD_DIR)/assets/audio/soundfonts/%.c $(BUILD_DIR)/assets/audio/soundfonts/%.name
$(CPP) $(MIPS_BUILTIN_DEFS) $(CPPFLAGS) -x assembler-with-cpp $(INC) -I include/audio -MD -MF $(@:.o=.d) -MT $@ $< -o /dev/null
# compile c to unlinked object
$(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -I include/audio -o $(@:.o=.tmp) $<
# partial link
@ -1100,11 +1089,11 @@ endif
# then assemble the sequences...
$(BUILD_DIR)/assets/audio/sequences/%.o: assets/audio/sequences/%.seq include/audio/aseq.h $(SEQUENCE_TABLE) | $(SOUNDFONT_HEADERS)
$(SEQ_CPP) $(SEQ_CPPFLAGS) $< -o $(@:.o=.s) -MMD -MT $@
$(SEQ_CPP) $(SEQ_CPPFLAGS) -MD -MT $@ $< -o $(@:.o=.s)
$(AS) $(ASFLAGS) -I $(BUILD_DIR)/assets/audio/soundfonts -I include/audio -I $(dir $<) $(@:.o=.s) -o $@
$(BUILD_DIR)/assets/audio/sequences/%.o: $(EXTRACTED_DIR)/assets/audio/sequences/%.seq include/audio/aseq.h $(SEQUENCE_TABLE) | $(SOUNDFONT_HEADERS)
$(SEQ_CPP) $(SEQ_CPPFLAGS) $< -o $(@:.o=.s) -MMD -MT $@
$(SEQ_CPP) $(SEQ_CPPFLAGS) -MD -MT $@ $< -o $(@:.o=.s)
$(AS) $(ASFLAGS) -I $(BUILD_DIR)/assets/audio/soundfonts -I include/audio -I $(dir $<) $(@:.o=.s) -o $@
ifeq ($(AUDIO_BUILD_DEBUG),1)
$(OBJCOPY) -O binary -j.data $@ $(@:.o=.aseq)
@ -1138,9 +1127,7 @@ $(BUILD_DIR)/src/audio/tables/sequence_table.o: src/audio/tables/sequence_table.
$(BUILD_DIR)/src/audio/tables/sequence_table.o: CFLAGS += -I include/tables
$(BUILD_DIR)/src/audio/tables/%.o: src/audio/tables/%.c
ifneq ($(RUN_CC_CHECK),0)
$(CC_CHECK) $<
endif
$(CC_CHECK) $< -o $@
$(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTFLAGS) -o $(@:.o=.tmp) $<
$(LD) -r -T linker_scripts/data_with_rodata.ld $(@:.o=.tmp) -o $@
$(PYTHON) tools/patch_data_with_rodata_mdebug.py $@

View file

@ -55,12 +55,12 @@ cd build-binutils
Configure the build
```bash
../binutils-2.35/configure --target=mips-linux-gnu --prefix=/opt/cross --disable-gprof --disable-gdb --disable-werror
../binutils-2.35/configure --target=mips-linux-gnu --prefix=/opt/cross --with-system-zlib --disable-gprof --disable-gdb --disable-werror
```
Make and install binutils
```bash
make -j
make -j$(nproc)
sudo make install
```
@ -82,3 +82,44 @@ If this worked, you can now delete the temporary directory `~/binutils-tmp`.
Apple's version of `make` is very out-of-date, so you should use the brew-installed `gmake` in place of `make` in this repo from now on.
You should now be able to continue from [step 2](../README.md#2-clone-the-repository) of the Linux instructions.
## 4. Building GCC (optional)
If you'd like to compile with GCC instead of IDO (e.g. for modding), you can build it from source similarly to how we built binutils:
Install dependences
```bash
brew install gcc@14 gmp isl libmpc mpfr
```
Create and enter local working dir
```bash
mkdir ~/gcc-tmp
cd ~/gcc-tmp
```
Get and extract gcc source
```bash
curl -O https://ftp.gnu.org/gnu/gcc/gcc-14.2.0/gcc-14.2.0.tar.xz
tar xvf gcc-14.2.0.tar.xz
```
Create and enter a build directory
```bash
mkdir build-gcc
cd build-gcc
```
Configure the build
```bash
CC=gcc-14 CXX=g++-14 ../gcc-14.2.0/configure --target=mips-linux-gnu --prefix=/opt/cross --disable-nls --enable-languages=c --with-gmp=$(brew --prefix)/opt/gmp --with-mpfr=$(brew --prefix)/opt/mpfr --with-mpc=$(brew --prefix)/opt/libmpc --with-isl=$(brew --prefix)/opt/isl
```
Make and install gcc
```bash
CC=gcc-14 CXX=g++-14 make all-gcc -j$(nproc)
sudo make install-gcc
```
If this worked, you can now delete the temporary directory `~/gcc-tmp`.

8
include/array_count.h Normal file
View file

@ -0,0 +1,8 @@
#ifndef ARRAY_COUNT_H
#define ARRAY_COUNT_H
#define ARRAY_COUNT(arr) (s32)(sizeof(arr) / sizeof(arr[0]))
#define ARRAY_COUNTU(arr) (u32)(sizeof(arr) / sizeof(arr[0]))
#define ARRAY_COUNT_2D(arr) (s32)(sizeof(arr) / sizeof(arr[0][0]))
#endif

13
include/avoid_ub.h Normal file
View file

@ -0,0 +1,13 @@
#ifndef AVOID_UB_H
#define AVOID_UB_H
/**
* This macro is used when the return type of a function is incorrect
*/
#ifndef AVOID_UB
#define BAD_RETURN(type) type
#else
#define BAD_RETURN(type) void
#endif
#endif

View file

@ -2,7 +2,6 @@
#define BUFFERS_H
#include "gfx.h"
#include "macros.h"
#include "ultra64.h"
extern u16 gZBuffer[SCREEN_HEIGHT][SCREEN_WIDTH]; // 0x25800 bytes

View file

@ -33,4 +33,6 @@ typedef union Color_RGBA16 {
u16 rgba;
} Color_RGBA16;
#define RGBA8(r, g, b, a) ((((r) & 0xFF) << 24) | (((g) & 0xFF) << 16) | (((b) & 0xFF) << 8) | (((a) & 0xFF) << 0))
#endif

View file

@ -1,9 +1,10 @@
#ifndef FAULT_H
#define FAULT_H
#include "ultra64.h"
#include "attributes.h"
#include "libu64/debug.h"
#include "libu64/pad.h"
#include "attributes.h"
#include "ultra64.h"
#if !PLATFORM_N64
// These are the same as the 3-bit ansi color codes
@ -50,6 +51,12 @@ void Fault_Init(void);
NORETURN void Fault_AddHungupAndCrashImpl(const char* exp1, const char* exp2);
NORETURN void Fault_AddHungupAndCrash(const char* file, int line);
#if PLATFORM_N64 || DEBUG_FEATURES
#define HUNGUP_AND_CRASH(file, line) Fault_AddHungupAndCrash(file, line)
#else
#define HUNGUP_AND_CRASH(file, line) LogUtils_HungupThread(file, line)
#endif
// Client Registration
void Fault_AddClient(FaultClient* client, void* callback, void* arg0, void* arg1);

View file

@ -7,6 +7,9 @@
#include "thga.h"
#include "versions.h"
#define SCREEN_WIDTH 320
#define SCREEN_HEIGHT 240
// Texture memory size, 4 KiB
#define TMEM_SIZE 0x1000
@ -124,4 +127,39 @@ void Graph_ThreadEntry(void*);
extern u64 gMojiFontTLUTs[4][4]; // original name: "moji_tlut"
extern u64 gMojiFontTex[]; // original name: "font_ff"
/**
* `x` vertex x
* `y` vertex y
* `z` vertex z
* `s` texture s coordinate
* `t` texture t coordinate
* `crnx` red component of color vertex, or x component of normal vertex
* `cgny` green component of color vertex, or y component of normal vertex
* `cbnz` blue component of color vertex, or z component of normal vertex
* `a` alpha
*/
#define VTX(x,y,z,s,t,crnx,cgny,cbnz,a) { { { x, y, z }, 0, { s, t }, { crnx, cgny, cbnz, a } } }
#define VTX_T(x,y,z,s,t,cr,cg,cb,a) { { x, y, z }, 0, { s, t }, { cr, cg, cb, a } }
#define gDPSetTileCustom(pkt, fmt, siz, uls, ult, lrs, lrt, pal, \
cms, cmt, masks, maskt, shifts, shiftt) \
_DW({ \
gDPPipeSync(pkt); \
gDPTileSync(pkt); \
gDPSetTile(pkt, fmt, siz, \
(((((lrs) - (uls) + 1) * siz##_TILE_BYTES) + 7) >> 3), 0, \
G_TX_LOADTILE, 0, cmt, maskt, shiftt, cms, masks, \
shifts); \
gDPTileSync(pkt); \
gDPSetTile(pkt, fmt, siz, \
(((((lrs) - (uls) + 1) * siz##_LINE_BYTES) + 7) >> 3), 0, \
G_TX_RENDERTILE, pal, cmt, maskt, shiftt, cms, masks, shifts); \
gDPSetTileSize(pkt, G_TX_RENDERTILE, \
(uls) << G_TEXTURE_IMAGE_FRAC, \
(ult) << G_TEXTURE_IMAGE_FRAC, \
(lrs) << G_TEXTURE_IMAGE_FRAC, \
(lrt) << G_TEXTURE_IMAGE_FRAC); \
})
#endif

View file

@ -1,6 +0,0 @@
#ifndef GLOBAL_H
#define GLOBAL_H
#include "macros.h"
#endif

12
include/language_array.h Normal file
View file

@ -0,0 +1,12 @@
#ifndef LANGUAGE_ARRAY_H
#define LANGUAGE_ARRAY_H
#include "versions.h"
#if OOT_NTSC
#define LANGUAGE_ARRAY(jpn, eng, ger, fra) { jpn, eng }
#else
#define LANGUAGE_ARRAY(jpn, eng, ger, fra) { eng, ger, fra }
#endif
#endif

View file

@ -1,90 +0,0 @@
#ifndef MACROS_H
#define MACROS_H
#include "versions.h"
#define SCREEN_WIDTH 320
#define SCREEN_HEIGHT 240
#ifndef AVOID_UB
#define BAD_RETURN(type) type
#else
#define BAD_RETURN(type) void
#endif
#define ARRAY_COUNT(arr) (s32)(sizeof(arr) / sizeof(arr[0]))
#define ARRAY_COUNTU(arr) (u32)(sizeof(arr) / sizeof(arr[0]))
#define ARRAY_COUNT_2D(arr) (s32)(sizeof(arr) / sizeof(arr[0][0]))
#define PHYSICAL_TO_VIRTUAL(addr) (void*)((uintptr_t)(addr) + 0x80000000)
#define VIRTUAL_TO_PHYSICAL(addr) (uintptr_t)((u8*)(addr) - 0x80000000)
#define ABS(x) ((x) >= 0 ? (x) : -(x))
#define DECR(x) ((x) == 0 ? 0 : --(x))
#define CLAMP(x, min, max) ((x) < (min) ? (min) : (x) > (max) ? (max) : (x))
#define CLAMP_MAX(x, max) ((x) > (max) ? (max) : (x))
#define CLAMP_MIN(x, min) ((x) < (min) ? (min) : (x))
#define SWAP(type, a, b) \
{ \
type _temp = (a); \
(a) = (b); \
(b) = _temp; \
} \
(void)0
#define RGBA8(r, g, b, a) ((((r) & 0xFF) << 24) | (((g) & 0xFF) << 16) | (((b) & 0xFF) << 8) | (((a) & 0xFF) << 0))
#define CHECK_FLAG_ALL(flags, mask) (((flags) & (mask)) == (mask))
#if PLATFORM_N64 || DEBUG_FEATURES
#define HUNGUP_AND_CRASH(file, line) Fault_AddHungupAndCrash(file, line)
#else
#define HUNGUP_AND_CRASH(file, line) LogUtils_HungupThread(file, line)
#endif
#define MATRIX_FINALIZE_AND_LOAD(pkt, gfxCtx, file, line) \
gSPMatrix(pkt, MATRIX_FINALIZE(gfxCtx, file, line), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW)
#if OOT_NTSC
#define LANGUAGE_ARRAY(jpn, eng, ger, fra) { jpn, eng }
#else
#define LANGUAGE_ARRAY(jpn, eng, ger, fra) { eng, ger, fra }
#endif
/**
* `x` vertex x
* `y` vertex y
* `z` vertex z
* `s` texture s coordinate
* `t` texture t coordinate
* `crnx` red component of color vertex, or x component of normal vertex
* `cgny` green component of color vertex, or y component of normal vertex
* `cbnz` blue component of color vertex, or z component of normal vertex
* `a` alpha
*/
#define VTX(x,y,z,s,t,crnx,cgny,cbnz,a) { { { x, y, z }, 0, { s, t }, { crnx, cgny, cbnz, a } } }
#define VTX_T(x,y,z,s,t,cr,cg,cb,a) { { x, y, z }, 0, { s, t }, { cr, cg, cb, a } }
#define gDPSetTileCustom(pkt, fmt, siz, uls, ult, lrs, lrt, pal, \
cms, cmt, masks, maskt, shifts, shiftt) \
_DW({ \
gDPPipeSync(pkt); \
gDPTileSync(pkt); \
gDPSetTile(pkt, fmt, siz, \
(((((lrs) - (uls) + 1) * siz##_TILE_BYTES) + 7) >> 3), 0, \
G_TX_LOADTILE, 0, cmt, maskt, shiftt, cms, masks, \
shifts); \
gDPTileSync(pkt); \
gDPSetTile(pkt, fmt, siz, \
(((((lrs) - (uls) + 1) * siz##_LINE_BYTES) + 7) >> 3), 0, \
G_TX_RENDERTILE, pal, cmt, maskt, shiftt, cms, masks, shifts); \
gDPSetTileSize(pkt, G_TX_RENDERTILE, \
(uls) << G_TEXTURE_IMAGE_FRAC, \
(ult) << G_TEXTURE_IMAGE_FRAC, \
(lrs) << G_TEXTURE_IMAGE_FRAC, \
(lrt) << G_TEXTURE_IMAGE_FRAC); \
})
#endif

View file

@ -64,6 +64,9 @@ Mtx* Matrix_Finalize(struct GraphicsContext* gfxCtx);
#endif
#define MATRIX_FINALIZE_AND_LOAD(pkt, gfxCtx, file, line) \
gSPMatrix(pkt, MATRIX_FINALIZE(gfxCtx, file, line), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW)
/* Vector operations */
void Matrix_MultVec3f(Vec3f* src, Vec3f* dest);

View file

@ -4,6 +4,8 @@
// TODO: This file still exists ONLY to provide neccesary headers to extracted assets.
// After assets are modified to include the headers they need directly, delete this file.
#include "array_count.h"
#include "gfx.h"
#include "sequence.h"
#include "sys_matrix.h"
#include "ultra64.h"

View file

@ -160,6 +160,8 @@ typedef struct ActorShape {
// Flag controlling the use of `Actor.sfx`. Do not use directly. See Actor_PlaySfx_FlaggedTimer
#define ACTOR_FLAG_SFX_TIMER (1 << 28)
#define ACTOR_FLAGS_CHECK_ALL(thisx, mask) (((thisx)->flags & (mask)) == (mask))
#define COLORFILTER_GET_COLORINTENSITY(colorFilterParams) (((colorFilterParams) & 0x1F00) >> 5)
#define COLORFILTER_GET_DURATION(colorFilterParams) ((colorFilterParams) & 0xFF)

View file

@ -1,10 +1,10 @@
#ifndef Z64_ANIMATION_H
#define Z64_ANIMATION_H
#include "avoid_ub.h"
#include "ultra64.h"
#include "z64dma.h"
#include "z64math.h"
#include "macros.h"
struct PlayState;
struct Actor;

View file

@ -1,11 +1,8 @@
#ifndef Z64MATH_H
#define Z64MATH_H
#include "ultra64.h"
#include "math.h"
#define SQ(x) ((x)*(x))
#define VEC_SET(V,X,Y,Z) (V).x=(X);(V).y=(Y);(V).z=(Z)
#include "ultra64.h"
typedef union FloatInt {
f32 f;
@ -95,6 +92,27 @@ typedef VecSphGeo VecSph;
// Pitch is 0 along the xz-plane (horizon)
typedef VecSphGeo VecGeo;
/**
* Macros
*/
// General number macros
#define SQ(x) ((x)*(x))
#define ABS(x) ((x) >= 0 ? (x) : -(x))
#define DECR(x) ((x) == 0 ? 0 : --(x))
#define CLAMP(x, min, max) ((x) < (min) ? (min) : (x) > (max) ? (max) : (x))
#define CLAMP_MAX(x, max) ((x) > (max) ? (max) : (x))
#define CLAMP_MIN(x, min) ((x) < (min) ? (min) : (x))
#define SWAP(type, a, b) \
{ \
type _temp = (a); \
(a) = (b); \
(b) = _temp; \
} \
(void)0
// LERP macros
#define LERP(x, y, scale) (((y) - (x)) * (scale) + (x))
#define LERP32(x, y, scale) ((s32)(((y) - (x)) * (scale)) + (x))
#define LERP16(x, y, scale) ((s16)(((y) - (x)) * (scale)) + (x))
@ -110,6 +128,7 @@ typedef VecSphGeo VecGeo;
(dst)->z = (v0)->z + (((v1)->z - (v0)->z) * t); \
}
// Floating point macros
#define IS_ZERO(f) (fabsf(f) < 0.008f)
// Casting a float to an integer, when the float value is larger than what the integer type can hold,
@ -145,6 +164,7 @@ typedef VecSphGeo VecGeo;
#define CAM_BINANG_TO_DEG(binang) ((f32)(binang) * (360.0001525f / 65535.0f))
// Vector macros
#define VEC_SET(V,X,Y,Z) (V).x=(X);(V).y=(Y);(V).z=(Z)
#define SQXZ(vec) ((vec).x * (vec).x + (vec).z * (vec).z)
#define DOTXZ(vec1, vec2) ((vec1).x * (vec2).x + (vec1).z * (vec2).z)
#define SQXYZ(vec) ((vec).x * (vec).x + (vec).y * (vec).y + (vec).z * (vec).z)

View file

@ -592,14 +592,11 @@ typedef enum LinkAge {
(EVENTCHKINF_MASK(EVENTCHKINF_CARPENTER_0_RESCUED) | EVENTCHKINF_MASK(EVENTCHKINF_CARPENTER_1_RESCUED) | \
EVENTCHKINF_MASK(EVENTCHKINF_CARPENTER_2_RESCUED) | EVENTCHKINF_MASK(EVENTCHKINF_CARPENTER_3_RESCUED))
#define GET_EVENTCHKINF_CARPENTERS_ALL_RESCUED() \
CHECK_FLAG_ALL(gSaveContext.save.info.eventChkInf[EVENTCHKINF_INDEX_CARPENTERS_RESCUED], \
EVENTCHKINF_CARPENTERS_ALL_RESCUED_MASK)
#define GET_EVENTCHKINF_CARPENTERS_ALL_RESCUED() \
((gSaveContext.save.info.eventChkInf[EVENTCHKINF_INDEX_CARPENTERS_RESCUED] & EVENTCHKINF_CARPENTERS_ALL_RESCUED_MASK) == (EVENTCHKINF_CARPENTERS_ALL_RESCUED_MASK))
#define GET_EVENTCHKINF_CARPENTERS_ALL_RESCUED2() \
CHECK_FLAG_ALL(gSaveContext.save.info.eventChkInf[EVENTCHKINF_INDEX_CARPENTERS_RESCUED] & \
(EVENTCHKINF_CARPENTERS_ALL_RESCUED_MASK | 0xF0), \
EVENTCHKINF_CARPENTERS_ALL_RESCUED_MASK)
#define GET_EVENTCHKINF_CARPENTERS_ALL_RESCUED2() \
((gSaveContext.save.info.eventChkInf[EVENTCHKINF_INDEX_CARPENTERS_RESCUED] & (EVENTCHKINF_CARPENTERS_ALL_RESCUED_MASK | 0xF0) & EVENTCHKINF_CARPENTERS_ALL_RESCUED_MASK) == (EVENTCHKINF_CARPENTERS_ALL_RESCUED_MASK))
#define ENDAIKU_CARPENTER_RESCUED_MASK(carpenterType) (1 << (carpenterType))

View file

@ -1,7 +1,7 @@
#ifndef Z64SCENE_H
#define Z64SCENE_H
#include "macros.h"
#include "avoid_ub.h"
#include "ultra64.h"
#include "z64bgcheck.h"
#include "z64environment.h"

View file

@ -1,7 +1,7 @@
#ifndef Z64VIEW_H
#define Z64VIEW_H
#include "macros.h"
#include "avoid_ub.h"
#include "ultra64.h"
#include "z64math.h"

View file

@ -1,7 +1,7 @@
#include "array_count.h"
#include "sfx.h"
#include "ultra64.h"
#include "z64audio.h"
#include "macros.h"
#include "sfx.h"
// sSfxRequests ring buffer endpoints. read index <= write index, wrapping around mod 256.
u8 gSfxRequestWriteIndex = 0;

View file

@ -1,5 +1,5 @@
#include "libu64/gfxprint.h"
#include "ultra64.h"
#include "array_count.h"
#include "attributes.h"
#include "audiothread_cmd.h"
#include "controller.h"
@ -8,12 +8,11 @@
#include "seqcmd.h"
#include "sequence.h"
#include "sfx.h"
#include "ultra64.h"
#include "versions.h"
#include "z64audio.h"
#include "z64ocarina.h"
#include "global.h"
#define ABS_ALT(x) ((x) < 0 ? -(x) : (x))
#if !PLATFORM_N64

View file

@ -1,6 +1,8 @@
/**
* Original Filename: system.c
*/
#include "array_count.h"
#include "attributes.h"
#include "buffers.h"
#include "segment_symbols.h"
@ -8,8 +10,6 @@
#include "versions.h"
#include "z64audio.h"
#include "global.h"
#define MK_ASYNC_MSG(retData, tableType, id, loadStatus) \
(((retData) << 24) | ((tableType) << 16) | ((id) << 8) | (loadStatus))
#define ASYNC_TBLTYPE(v) ((u8)(v >> 16))

View file

@ -1,5 +1,4 @@
#include "ultra64.h"
#include "macros.h"
#include "z64audio.h"
void Audio_InitNoteSub(Note* note, NoteSubEu* sub, NoteSubAttributes* attrs) {

View file

@ -15,9 +15,9 @@
* Otherwise, each set of instructions has its own command interpreter
*/
#include "audio/aseq.h"
#include "array_count.h"
#include "assert.h"
#include "attributes.h"
#include "macros.h"
#include "ultra64.h"
#include "z64audio.h"

View file

@ -1,8 +1,9 @@
/**
* Original Filename: sub_sys.c
*/
#include "array_count.h"
#include "audiothread_cmd.h"
#include "macros.h"
#include "ultra64.h"
#include "versions.h"
#include "z64audio.h"

View file

@ -17,15 +17,14 @@
* Nor are these commands to be confused with the internal audio commands used to transfer requests from
* the graph thread to the audio thread.
*/
#include "array_count.h"
#include "audiothread_cmd.h"
#include "ultra64.h"
#include "ultra64/abi.h"
#include "seqcmd.h"
#include "sfx.h"
#include "ultra64.h"
#include "ultra64/abi.h"
#include "z64audio.h"
#include "macros.h"
// Direct audio command (skips the queueing system)
#define SEQCMD_SET_SEQPLAYER_VOLUME_NOW(seqPlayerIndex, duration, volume) \
Audio_ProcessSeqCmd((SEQCMD_OP_SET_SEQPLAYER_VOLUME << 28) | ((u8)(seqPlayerIndex) << 24) | \

View file

@ -1,8 +1,7 @@
#include "array_count.h"
#include "buffers.h"
#include "z64audio.h"
#include "global.h"
#include "assets/audio/sequence_sizes.h"
#include "assets/audio/soundfont_sizes.h"

View file

@ -1,5 +1,5 @@
#include "array_count.h"
#include "audiothread_cmd.h"
#include "macros.h"
#include "printf.h"
#include "sfx.h"
#include "terminal.h"

View file

@ -12,8 +12,6 @@
#include "z_locale.h"
#include "z64thread.h"
#include "global.h"
#pragma increment_block_number "gc-eu:0 gc-eu-mq:0 gc-jp:0 gc-jp-ce:0 gc-jp-mq:0 gc-us:0 gc-us-mq:0 ntsc-1.2:128"
StackEntry sBootThreadInfo;

View file

@ -7,8 +7,6 @@
#include "regs.h"
#include "sched.h"
#include "global.h"
s32 func_80001714(void);
OSTask D_800067C0_unknown = {

View file

@ -1,3 +1,4 @@
#include "array_count.h"
#include "buffers.h"
#include "build.h"
#include "idle.h"
@ -13,8 +14,6 @@
#include "z64thread.h"
#include "z64dma.h"
#include "global.h"
#pragma increment_block_number "gc-eu:192 gc-eu-mq:192 gc-jp:192 gc-jp-ce:192 gc-jp-mq:192 gc-us:192 gc-us-mq:192" \
"ntsc-1.0:192 ntsc-1.1:192 ntsc-1.2:192 pal-1.0:192 pal-1.1:192"

View file

@ -2,8 +2,6 @@
#include "terminal.h"
#include "idle.h"
#include "global.h"
s8 D_80009430 = 1;
vu8 gViConfigBlack = true;
u8 gViConfigAdditionalScanLines = 0;

View file

@ -11,9 +11,6 @@
#include "vi_mode.h"
#include "z_locale.h"
#include "macros.h"
#include "global.h"
s32 gCurrentRegion = 0;
typedef struct LocaleCartInfo {

View file

@ -21,6 +21,7 @@
#include "libc64/sleep.h"
#include "libc64/sprintf.h"
#include "libu64/debug.h"
#include "array_count.h"
#include "attributes.h"
#include "carthandle.h"
#include "fault.h"
@ -44,8 +45,6 @@
#include "z64dma.h"
#include "z64thread.h"
#include "global.h"
#pragma increment_block_number "gc-eu:0 gc-eu-mq:0 gc-jp:0 gc-jp-ce:0 gc-jp-mq:0 gc-us:0 gc-us-mq:0 ntsc-1.2:66" \
"pal-1.0:64 pal-1.1:64"

View file

@ -1,6 +1,5 @@
#include "alignment.h"
#include "buffers.h"
#include "macros.h"
#include "ultra64/ultratypes.h"
ALIGNED(64) u16 gZBuffer[SCREEN_HEIGHT][SCREEN_WIDTH];

View file

@ -13,9 +13,6 @@
#include "printf.h"
#include "regs.h"
#include "macros.h"
#include "global.h"
void PreRender_SetValuesSave(PreRender* this, u32 width, u32 height, void* fbuf, void* zbuf, void* cvg) {
this->widthSave = width;
this->heightSave = height;

View file

@ -1,7 +1,6 @@
#include "array_count.h"
#include "sfx.h"
#include "ultra64.h"
#include "macros.h"
u8 sSfxBankIds[] = {
BANK_PLAYER, BANK_ITEM, BANK_ENV, BANK_ENEMY, BANK_SYSTEM, BANK_OCARINA, BANK_VOICE,

View file

@ -5,6 +5,7 @@
* and sending the audio rsp tasks generated by the driver to the task scheduler.
*/
#include "array_count.h"
#include "audiomgr.h"
#include "printf.h"
#include "regs.h"
@ -12,8 +13,6 @@
#include "translation.h"
#include "z64dma.h"
#include "macros.h"
void AudioMgr_NotifyTaskDone(AudioMgr* audioMgr) {
AudioTask* task = audioMgr->rspTask;

View file

@ -1,4 +1,5 @@
#include "libu64/gfxprint.h"
#include "array_count.h"
#include "attributes.h"
#include "controller.h"
#include "db_camera.h"

View file

@ -3,8 +3,6 @@
#include "printf.h"
#include "translation.h"
#include "macros.h"
#define LOG_SEVERITY_NOLOG 0
#define LOG_SEVERITY_ERROR 2
#define LOG_SEVERITY_VERBOSE 3

View file

@ -41,13 +41,15 @@
* DPad-Down disables sending fault pages over osSyncPrintf.
*/
#pragma increment_block_number "gc-eu:192 gc-eu-mq:192 gc-eu-mq-dbg:192 gc-jp:192 gc-jp-ce:192 gc-jp-mq:192 gc-us:192" \
"gc-us-mq:192 ique-cn:192"
#pragma increment_block_number "gc-eu:160 gc-eu-mq:160 gc-eu-mq-dbg:160 gc-jp:160 gc-jp-ce:160 gc-jp-mq:160 gc-us:160" \
"gc-us-mq:160 ique-cn:160"
#include "libc64/sleep.h"
#include "libc64/sprintf.h"
#include "alloca.h"
#include "array_count.h"
#include "controller.h"
#include "gfx.h"
#include "padmgr.h"
#include "fault.h"
#include "stack.h"
@ -56,8 +58,6 @@
#include "translation.h"
#include "z64thread.h"
#include "global.h"
void Fault_Init(void);
void Fault_SetOsSyncPrintfEnabled(u32 enabled);
void Fault_DrawRecImpl(s32 xStart, s32 yStart, s32 xEnd, s32 yEnd, u16 color);

View file

@ -5,11 +5,11 @@
* the crash screen implemented by fault.c
*/
#include "array_count.h"
#include "fault.h"
#include "gfx.h"
#include "terminal.h"
#include "global.h"
#pragma increment_block_number "gc-eu:0 gc-eu-mq:0 gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128"
typedef struct FaultDrawer {

View file

@ -1,8 +1,10 @@
#include "libc64/os_malloc.h"
#include "libc64/sleep.h"
#include "libc64/sprintf.h"
#include "array_count.h"
#include "controller.h"
#include "fault.h"
#include "gfx.h"
#include "padmgr.h"
#include "segmented_address.h"
#include "stack.h"
@ -11,9 +13,7 @@
#include "z64thread.h"
#include "translation.h"
#include "global.h"
#pragma increment_block_number "ntsc-1.0:176 ntsc-1.1:176 ntsc-1.2:176 pal-1.0:176 pal-1.1:176"
#pragma increment_block_number "ntsc-1.0:144 ntsc-1.1:144 ntsc-1.2:144 pal-1.0:144 pal-1.1:144"
typedef struct FaultMgr {
OSThread thread;

View file

@ -2,6 +2,7 @@
#include "libc64/os_malloc.h"
#include "libu64/debug.h"
#include "libu64/gfxprint.h"
#include "array_count.h"
#include "audiomgr.h"
#include "buffers.h"
#include "controller.h"
@ -31,9 +32,6 @@
#include "z64play.h"
#include "z64vis.h"
#include "macros.h"
#include "global.h"
#pragma increment_block_number "gc-eu:128 gc-eu-mq:128 gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128"
SpeedMeter D_801664D0;

View file

@ -3,8 +3,6 @@
#include "gamealloc.h"
#include "printf.h"
#include "macros.h"
void GameAlloc_Log(GameAlloc* this) {
GameAllocEntry* iter;

View file

@ -1,7 +1,7 @@
#include "libc64/malloc.h"
#include "libc64/sprintf.h"
#include "libu64/debug.h"
#include "array_count.h"
#include "buffers.h"
#include "console_logo_state.h"
#include "controller.h"
@ -30,9 +30,6 @@
#include "z64save.h"
#include "z64play.h"
#include "macros.h"
#include "global.h"
#define GFXPOOL_HEAD_MAGIC 0x1234
#define GFXPOOL_TAIL_MAGIC 0x5678

View file

@ -33,6 +33,7 @@
* @see sched.c
*/
#include "libu64/debug.h"
#include "array_count.h"
#include "irqmgr.h"
#include "printf.h"
#include "stackcheck.h"
@ -41,8 +42,6 @@
#include "versions.h"
#include "z64thread.h"
#include "macros.h"
vu32 gIrqMgrResetStatus = IRQ_RESET_STATUS_IDLE;
volatile OSTime sIrqMgrResetTime = 0;
volatile OSTime gIrqMgrRetraceTime = 0;

View file

@ -19,6 +19,7 @@ extern struct IrqMgr gIrqMgr;
#include "libc64/malloc.h"
#include "libu64/rcp_utils.h"
#include "libu64/runtime.h"
#include "array_count.h"
#include "audiomgr.h"
#include "debug_arena.h"
#include "fault.h"
@ -42,10 +43,8 @@ extern struct IrqMgr gIrqMgr;
#include "z64debug.h"
#include "z64thread.h"
#include "global.h"
#pragma increment_block_number "gc-eu:128 gc-eu-mq:128 gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128" \
"ique-cn:0 ntsc-1.0:35 ntsc-1.1:35 ntsc-1.2:35 pal-1.0:33 pal-1.1:33"
"ique-cn:0 ntsc-1.0:34 ntsc-1.1:34 ntsc-1.2:34 pal-1.0:32 pal-1.1:32"
extern u8 _buffersSegmentEnd[];

View file

@ -11,8 +11,6 @@
#include "padmgr.h"
#include "printf.h"
#include "macros.h"
#define MEMPAK_MAX_FILES 11
OSPfs sMempakPfsHandle;

View file

@ -1,10 +1,9 @@
#include "array_count.h"
#include "segment_symbols.h"
#include "romfile.h"
#include "ultra64.h"
#include "z64object.h"
#include "macros.h"
s16 gLinkObjectIds[] = { OBJECT_LINK_BOY, OBJECT_LINK_CHILD };
u32 gObjectTableSize = ARRAY_COUNT(gObjectTable);

View file

@ -30,7 +30,7 @@
*/
#include "libu64/debug.h"
#include "libu64/padsetup.h"
#include "macros.h"
#include "array_count.h"
#include "padmgr.h"
#include "printf.h"
#include "fault.h"

View file

@ -41,6 +41,7 @@
*/
#include "libu64/debug.h"
#include "libu64/rcp_utils.h"
#include "array_count.h"
#include "fault.h"
#include "irqmgr.h"
#include "main.h"
@ -53,9 +54,6 @@
#include "vi_mode.h"
#include "z64thread.h"
#include "macros.h"
#include "global.h"
#define RSP_DONE_MSG 667
#define RDP_DONE_MSG 668
#define NOTIFY_MSG 670 // original name: ENTRY_MSG

View file

@ -2,8 +2,6 @@
#include "printf.h"
#include "regs.h"
#include "macros.h"
typedef enum LetterboxState {
/* 0 */ LETTERBOX_STATE_IDLE,
/* 1 */ LETTERBOX_STATE_GROWING,

View file

@ -2,6 +2,7 @@
"pal-1.0:0 pal-1.1:0"
#include "libc64/malloc.h"
#include "libu64/debug.h"
#include "array_count.h"
#include "gfx.h"
#include "printf.h"
#include "regs.h"

View file

@ -2,12 +2,11 @@
#include "libu64/debug.h"
#include "attributes.h"
#include "gfx.h"
#include "line_numbers.h"
#include "printf.h"
#include "translation.h"
#include "global.h"
#pragma increment_block_number "gc-eu:128 gc-eu-mq:128 gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128" \
"pal-1.1:128"

View file

@ -4,8 +4,6 @@
#include "sys_freeze.h"
#include "terminal.h"
#include "macros.h"
NORETURN void func_800D31A0(void) {
PRINTF(VT_FGCOL(RED) "\n**** Freeze!! ****\n" VT_RST);
for (;;) {

View file

@ -7,8 +7,6 @@
#include "z_lib.h"
#include "z64math.h"
#include "macros.h"
#pragma increment_block_number "gc-eu:77 gc-eu-mq:77 gc-jp:77 gc-jp-ce:77 gc-jp-mq:77 gc-us:77 gc-us-mq:77 ique-cn:67" \
"ntsc-1.0:64 ntsc-1.1:64 ntsc-1.2:64 pal-1.0:64 pal-1.1:64"

View file

@ -1,6 +1,6 @@
#include "array_count.h"
#include "sys_math.h"
#include "z64math.h"
#include "macros.h"
static u16 sAtan2Tbl[] = {
0x0000, 0x000A, 0x0014, 0x001F, 0x0029, 0x0033, 0x003D, 0x0047, 0x0051, 0x005C, 0x0066, 0x0070, 0x007A, 0x0084,

View file

@ -3,7 +3,6 @@
#if DEBUG_FEATURES
#include "fault.h"
#endif
#include "macros.h"
#include "printf.h"
#include "sys_matrix.h"
#include "ultra64.h"

View file

@ -4,8 +4,6 @@
#include "translation.h"
#include "z64save.h"
#include "global.h"
void Setup_InitImpl(SetupState* this) {
PRINTF(T("ゼルダ共通データ初期化\n", "Zelda common data initialization\n"));
SaveContext_Init();

View file

@ -1,12 +1,11 @@
#include "ucode_disas.h"
#include "ultra64.h"
#include "ultra64/gs2dex.h"
#include "libu64/mtxuty-cvt.h"
#include "ultra64/gs2dex.h"
#include "array_count.h"
#include "printf.h"
#include "segmented_address.h"
#include "translation.h"
#include "macros.h"
#include "ucode_disas.h"
#include "ultra64.h"
#if DEBUG_FEATURES
@ -61,7 +60,7 @@ typedef void (*UcodeDisasCallback)(UCodeDisas*, u32);
void* UCodeDisas_TranslateAddr(UCodeDisas* this, uintptr_t addr) {
uintptr_t physical = this->segments[SEGMENT_NUMBER(addr)] + SEGMENT_OFFSET(addr);
return PHYSICAL_TO_VIRTUAL(physical);
return OS_PHYSICAL_TO_K0(physical);
}
F3dzexConst sUCodeDisasGeometryModes[] = {

View file

@ -6,8 +6,6 @@
#include "ultra64.h"
#include "z_game_dlftbls.h"
#include "macros.h"
void Overlay_LoadGameState(GameStateOverlay* overlayEntry) {
if (overlayEntry->loadedRamAddr != NULL) {
PRINTF(T("既にリンクされています\n", "Already linked\n"));

View file

@ -1,5 +1,6 @@
#include "libc64/math64.h"
#include "libu64/overlay.h"
#include "array_count.h"
#include "fault.h"
#include "gfx.h"
#include "gfx_setupdl.h"
@ -27,8 +28,6 @@
#include "z64save.h"
#include "z64skin_matrix.h"
#include "global.h"
#include "overlays/actors/ovl_Arms_Hook/z_arms_hook.h"
#include "overlays/actors/ovl_En_Part/z_en_part.h"
@ -595,7 +594,7 @@ void Attention_Update(Attention* attention, Player* player, Actor* playerFocusAc
attention->reticleFadeAlphaControl = 0;
}
lockOnSfxId = CHECK_FLAG_ALL(playerFocusActor->flags, ACTOR_FLAG_ATTENTION_ENABLED | ACTOR_FLAG_HOSTILE)
lockOnSfxId = ACTOR_FLAGS_CHECK_ALL(playerFocusActor, ACTOR_FLAG_ATTENTION_ENABLED | ACTOR_FLAG_HOSTILE)
? NA_SE_SY_LOCK_ON
: NA_SE_SY_LOCK_ON_HUMAN;
Sfx_PlaySfxCentered(lockOnSfxId);
@ -931,7 +930,7 @@ void Actor_SetScale(Actor* actor, f32 scale) {
}
void Actor_SetObjectDependency(PlayState* play, Actor* actor) {
gSegments[6] = VIRTUAL_TO_PHYSICAL(play->objectCtx.slots[actor->objectSlot].segment);
gSegments[6] = OS_K0_TO_PHYSICAL(play->objectCtx.slots[actor->objectSlot].segment);
}
void Actor_Init(Actor* actor, PlayState* play) {
@ -3467,9 +3466,9 @@ void Attention_FindActorInCategory(PlayState* play, ActorContext* actorCtx, Play
while (actor != NULL) {
if ((actor->update != NULL) && ((Player*)actor != player) &&
CHECK_FLAG_ALL(actor->flags, ACTOR_FLAG_ATTENTION_ENABLED)) {
ACTOR_FLAGS_CHECK_ALL(actor, ACTOR_FLAG_ATTENTION_ENABLED)) {
if ((actorCategory == ACTORCAT_ENEMY) &&
CHECK_FLAG_ALL(actor->flags, ACTOR_FLAG_ATTENTION_ENABLED | ACTOR_FLAG_HOSTILE) &&
ACTOR_FLAGS_CHECK_ALL(actor, ACTOR_FLAG_ATTENTION_ENABLED | ACTOR_FLAG_HOSTILE) &&
(actor->xyzDistToPlayerSq < SQ(500.0f)) && (actor->xyzDistToPlayerSq < sBgmEnemyDistSq)) {
actorCtx->attention.bgmEnemy = actor;
sBgmEnemyDistSq = actor->xyzDistToPlayerSq;

View file

@ -3,8 +3,6 @@
#include "segment_symbols.h"
#include "z_actor_dlftbls.h"
#include "macros.h"
// Linker symbol declarations (used in the table below)
#define DEFINE_ACTOR(name, _1, _2, _3) DECLARE_OVERLAY_SEGMENT(name)
#define DEFINE_ACTOR_INTERNAL(_0, _1, _2, _3)

View file

@ -82,7 +82,7 @@ void func_80043334(CollisionContext* colCtx, Actor* actor, s32 bgId) {
if (dynaActor != NULL) {
DynaPolyActor_SetActorOnTop(dynaActor);
if (CHECK_FLAG_ALL(actor->flags, ACTOR_FLAG_CAN_PRESS_SWITCHES)) {
if (ACTOR_FLAGS_CHECK_ALL(actor, ACTOR_FLAG_CAN_PRESS_SWITCHES)) {
DynaPolyActor_SetSwitchPressed(dynaActor);
}
}

View file

@ -1,4 +1,5 @@
#include "libu64/debug.h"
#include "array_count.h"
#include "attributes.h"
#include "line_numbers.h"
#include "printf.h"

View file

@ -1,10 +1,10 @@
#include "libc64/math64.h"
#include "libc64/qrand.h"
#include "ultra64.h"
#include "array_count.h"
#include "attributes.h"
#include "controller.h"
#include "db_camera.h"
#include "gfx.h"
#include "letterbox.h"
#include "one_point_cutscene.h"
#include "quake.h"
@ -14,6 +14,7 @@
#include "sys_math3d.h"
#include "terminal.h"
#include "translation.h"
#include "ultra64.h"
#include "z_lib.h"
#include "zelda_arena.h"
#include "z64audio.h"
@ -3660,7 +3661,7 @@ s32 Camera_KeepOn3(Camera* camera) {
}
#pragma increment_block_number "gc-eu:128 gc-eu-mq:128 gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128" \
"ique-cn:128 ntsc-1.0:128 ntsc-1.1:128 ntsc-1.2:128 pal-1.0:128 pal-1.1:128"
"ique-cn:128 ntsc-1.0:86 ntsc-1.1:86 ntsc-1.2:86 pal-1.0:86 pal-1.1:86"
s32 Camera_KeepOn4(Camera* camera) {
static Vec3f D_8015BD50;

View file

@ -1,5 +1,5 @@
#include "array_count.h"
#include "ultra64.h"
#include "global.h"
typedef struct CameraModeValue {
s16 val;

View file

@ -1,9 +1,8 @@
#include "array_count.h"
#include "printf.h"
#include "translation.h"
#include "z64collision_check.h"
#include "macros.h"
static DamageTable sDamageTablePresets[] = {
{ {
// 0

View file

@ -1,5 +1,4 @@
#include "gfx.h"
#include "macros.h"
#include "printf.h"
#include "regs.h"
#include "sfx.h"

View file

@ -2,7 +2,6 @@
#include "z64math.h"
#include "z64camera.h"
#include "z64cutscene_spline.h"
#include "macros.h"
// The code in this file is very similar to a spline system used in Super Mario 64 for cutscene camera movement

View file

@ -1,6 +1,7 @@
#include "libc64/malloc.h"
#include "libu64/gfxprint.h"
#include "libu64/pad.h"
#include "array_count.h"
#include "color.h"
#include "controller.h"
#include "gfx.h"
@ -10,8 +11,6 @@
#include "ultra64.h"
#include "z64debug.h"
#include "macros.h"
typedef struct DebugCamTextBufferEntry {
/* 0x0 */ u8 x;
/* 0x1 */ u8 y;

View file

@ -1,7 +1,8 @@
#pragma increment_block_number "gc-eu:128 gc-eu-mq:128 gc-jp:128 gc-jp-ce:128 gc-jp-mq:128 gc-us:128 gc-us-mq:128" \
"ique-cn:128 ntsc-1.0:0 ntsc-1.1:0 ntsc-1.2:0 pal-1.0:0 pal-1.1:0"
#include "global.h"
#include "libu64/gfxprint.h"
#include "array_count.h"
#include "controller.h"
#include "gfx.h"
#include "gfxalloc.h"

View file

@ -9,9 +9,6 @@
#include "z64effect.h"
#include "z64skin_matrix.h"
#include "macros.h"
#include "global.h"
#include "z64.h" // required for gameplay keep, the header doesnt include any external dependencies
#include "assets/objects/gameplay_keep/gameplay_keep.h"

View file

@ -1,4 +1,5 @@
#include "libc64/qrand.h"
#include "array_count.h"
#include "gfx.h"
#include "gfx_setupdl.h"
#include "printf.h"
@ -9,9 +10,6 @@
#include "z64play.h"
#include "z64skin_matrix.h"
#include "macros.h"
#include "global.h"
#include "assets/objects/gameplay_keep/gameplay_keep.h"
static Vtx sVertices[5] = {

View file

@ -1,4 +1,5 @@
#include "libc64/qrand.h"
#include "array_count.h"
#include "gfx.h"
#include "gfx_setupdl.h"
#include "printf.h"
@ -8,9 +9,6 @@
#include "z64play.h"
#include "z64skin_matrix.h"
#include "macros.h"
#include "global.h"
#include "assets/objects/gameplay_keep/gameplay_keep.h"
// original name: "spark"

View file

@ -1,4 +1,5 @@
#include "libu64/overlay.h"
#include "array_count.h"
#include "printf.h"
#include "sfx.h"
#include "terminal.h"

View file

@ -1,4 +1,5 @@
#include "libc64/qrand.h"
#include "array_count.h"
#include "gfx.h"
#include "gfx_setupdl.h"
#include "rand.h"
@ -70,7 +71,7 @@ void EffectSs_DrawGEffect(PlayState* play, EffectSs* this, void* texture) {
SkinMatrix_SetScale(&mfScale, scale, scale, scale);
SkinMatrix_MtxFMtxFMult(&mfTrans, &play->billboardMtxF, &mfTransBillboard);
SkinMatrix_MtxFMtxFMult(&mfTransBillboard, &mfScale, &mfResult);
gSegments[6] = VIRTUAL_TO_PHYSICAL(objectPtr);
gSegments[6] = OS_K0_TO_PHYSICAL(objectPtr);
gSPSegment(POLY_XLU_DISP++, 0x06, objectPtr);
mtx = SkinMatrix_MtxFToNewMtx(gfxCtx, &mfResult);

View file

@ -1,3 +1,4 @@
#include "array_count.h"
#include "ultra64.h"
#include "z64cutscene_flags.h"
#include "z64play.h"

View file

@ -19,8 +19,6 @@
#include "z64math.h"
#include "z64transition_instances.h"
#include "macros.h"
// color framebuffer
extern u16 D_0F000000[];

View file

@ -1,10 +1,9 @@
#include "transition_circle.h"
#include "color.h"
#include "gfx.h"
#include "sfx.h"
#include "global.h"
typedef enum TransitionCircleDirection {
/* 0 */ TRANS_CIRCLE_DIR_IN,
/* 1 */ TRANS_CIRCLE_DIR_OUT

View file

@ -9,8 +9,6 @@
#include "z64save.h"
#include "z64transition_instances.h"
#include "macros.h"
typedef enum TransitionFadeDirection {
/* 0 */ TRANS_FADE_DIR_IN,
/* 1 */ TRANS_FADE_DIR_OUT

View file

@ -1,6 +1,5 @@
#include "transition_triforce.h"
#include "global.h"
#include "printf.h"
#include "assets/code/fbdemo_triforce/z_fbdemo_triforce.c"

View file

@ -2,7 +2,6 @@
* File: z_fcurve_data.c
* Description: Interpolation functions for use with Curve SkelAnime
*/
#include "global.h"
#include "z64curve.h"
#define FCURVE_INTERP_CUBIC 0 // Interpolate using a Hermite cubic spline

View file

@ -4,7 +4,6 @@
#include "controller.h"
#include "libu64/pad.h"
#include "macros.h"
void FrameAdvance_Init(FrameAdvanceContext* frameAdvCtx) {
frameAdvCtx->timer = 0;

View file

@ -1,3 +1,4 @@
#include "array_count.h"
#include "letterbox.h"
#include "regs.h"
#include "rumble.h"
@ -7,9 +8,6 @@
#include "z64play.h"
#include "z64save.h"
#include "macros.h"
#include "global.h"
void GameOver_Init(PlayState* play) {
play->gameOverCtx.state = GAMEOVER_INACTIVE;
}

View file

@ -1,3 +1,4 @@
#include "array_count.h"
#include "terminal.h"
#include "z_lib.h"
#include "printf.h"

View file

@ -1,13 +1,13 @@
#include "global.h"
#include "ultra64.h"
#include "attributes.h"
#include "jpeg.h"
#include "array_count.h"
#include "attributes.h"
#include "gfx.h"
#include "printf.h"
#include "sys_ucode.h"
#include "terminal.h"
#include "translation.h"
#include "macros.h"
#include "ultra64.h"
#define MARKER_ESCAPE 0x00
#define MARKER_SOI 0xD8
@ -48,12 +48,12 @@ void Jpeg_ScheduleDecoderTask(JpegContext* ctx) {
JpegWork* workBuf = ctx->workBuf;
s32 pad[2];
workBuf->taskData.address = VIRTUAL_TO_PHYSICAL(&workBuf->data);
workBuf->taskData.address = OS_K0_TO_PHYSICAL(&workBuf->data);
workBuf->taskData.mode = ctx->mode;
workBuf->taskData.mbCount = 4;
workBuf->taskData.qTableYPtr = VIRTUAL_TO_PHYSICAL(&workBuf->qTableY);
workBuf->taskData.qTableUPtr = VIRTUAL_TO_PHYSICAL(&workBuf->qTableU);
workBuf->taskData.qTableVPtr = VIRTUAL_TO_PHYSICAL(&workBuf->qTableV);
workBuf->taskData.qTableYPtr = OS_K0_TO_PHYSICAL(&workBuf->qTableY);
workBuf->taskData.qTableUPtr = OS_K0_TO_PHYSICAL(&workBuf->qTableU);
workBuf->taskData.qTableVPtr = OS_K0_TO_PHYSICAL(&workBuf->qTableV);
sJpegTask.t.flags = 0;
sJpegTask.t.ucode_boot = SysUcode_GetUCodeBoot();

View file

@ -1,5 +1,6 @@
#include "libu64/debug.h"
#include "libu64/overlay.h"
#include "array_count.h"
#include "kaleido_manager.h"
#include "printf.h"
#include "segment_symbols.h"
@ -7,8 +8,6 @@
#include "translation.h"
#include "z64play.h"
#include "macros.h"
#define KALEIDO_OVERLAY(name, nameString) \
{ NULL, ROM_FILE(ovl_##name), _ovl_##name##SegmentStart, _ovl_##name##SegmentEnd, 0, nameString, }

View file

@ -10,8 +10,6 @@
#include "translation.h"
#include "z64play.h"
#include "global.h"
void (*sKaleidoScopeUpdateFunc)(PlayState* play);
void (*sKaleidoScopeDrawFunc)(PlayState* play);
f32 gBossMarkScale;

View file

@ -8,8 +8,6 @@
#include "z64font.h"
#include "z64message.h"
#include "macros.h"
/**
* Loads a texture from kanji for the requested `character` into the character texture buffer
* at `codePointIndex`. The value of `character` is the SHIFT-JIS encoding of the character.

View file

@ -3,6 +3,7 @@
#include "libc64/qrand.h"
#include "libu64/gfxprint.h"
#include "array_count.h"
#include "buffers.h"
#include "gfx.h"
#include "gfx_setupdl.h"

View file

@ -3,7 +3,6 @@
#include "ichain.h"
#include "printf.h"
#include "regs.h"
#include "macros.h"
#include "sys_math.h"
#include "rand.h"
#include "sfx.h"

View file

@ -1,3 +1,4 @@
#include "avoid_ub.h"
#include "buffers.h"
#include "gfx.h"
#include "gfx_setupdl.h"

View file

@ -2,8 +2,6 @@
#include "printf.h"
#include "translation.h"
#include "global.h"
#define LOG_SEVERITY_NOLOG 0
#define LOG_SEVERITY_ERROR 2
#define LOG_SEVERITY_VERBOSE 3

View file

@ -17,8 +17,6 @@
#include "z64player.h"
#include "z64save.h"
#include "global.h"
#include "assets/objects/gameplay_keep/gameplay_keep.h"
#include "assets/textures/parameter_static/parameter_static.h"

View file

@ -16,8 +16,6 @@
#include "assets/textures/parameter_static/parameter_static.h"
#include "global.h"
typedef struct MapMarkInfo {
/* 0x00 */ void* texture;
/* 0x04 */ u32 imageFormat;

View file

@ -1,9 +1,11 @@
#include "libu64/gfxprint.h"
#include "array_count.h"
#include "attributes.h"
#include "controller.h"
#include "gfx.h"
#include "gfx_setupdl.h"
#include "gfxalloc.h"
#include "language_array.h"
#include "memory_utils.h"
#include "message_data_static.h"
#if PLATFORM_N64
@ -22,8 +24,6 @@
#include "z64player.h"
#include "z64save.h"
#include "global.h"
#include "assets/textures/parameter_static/parameter_static.h"
#pragma increment_block_number "gc-eu:0 gc-eu-mq:0 gc-jp:0 gc-jp-ce:0 gc-jp-mq:0 gc-us:0 gc-us-mq:0 ntsc-1.0:32" \

View file

@ -3,10 +3,7 @@
*/
#include "gfx.h"
#include "macros.h"
#include "printf.h"
#include "global.h"
// how big to draw the characters on screen
#define DISP_CHAR_WIDTH 8

View file

@ -1,6 +1,8 @@
#include "one_point_cutscene.h"
#include "libc64/math64.h"
#include "libc64/qrand.h"
#include "one_point_cutscene.h"
#include "array_count.h"
#include "printf.h"
#include "quake.h"
#include "sfx.h"

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