diff --git a/Dockerfile b/Dockerfile index edc487ef68..4f0095ed7d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,7 +18,7 @@ RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone & apt-get clean && \ rm -rf /var/lib/apt/lists/* -RUN python3 -m pip install --user colorama ansiwrap attrs watchdog python-Levenshtein +RUN python3 -m pip install --user colorama ansiwrap attrs watchdog python-Levenshtein "mapfile-parser>=1.2.1,<2.0.0" "rabbitizer>=1.0.0,<2.0.0" RUN python3 -m pip install --upgrade attrs pycparser ENV LANG C.UTF-8 diff --git a/Makefile b/Makefile index a645ae3109..3d6f626347 100644 --- a/Makefile +++ b/Makefile @@ -199,12 +199,14 @@ build/src/code/fmodf.o: OPTFLAGS := -g build/src/code/__osMemset.o: OPTFLAGS := -g build/src/code/__osMemmove.o: OPTFLAGS := -g -# Use signed chars instead of unsigned for code_800EC960.c (needed to match AudioDebug_ScrPrt) -build/src/code/code_800EC960.o: CFLAGS += -signed +build/src/audio/%.o: OPTFLAGS := -O2 + +# Use signed chars instead of unsigned for this audio file (needed to match AudioDebug_ScrPrt) +build/src/audio/general.o: CFLAGS += -signed # Put string literals in .data for some audio files (needed to match these files with literals) -build/src/code/code_800F7260.o: CFLAGS += -use_readwrite_const -build/src/code/code_800F9280.o: CFLAGS += -use_readwrite_const +build/src/audio/sfx.o: CFLAGS += -use_readwrite_const +build/src/audio/sequence.o: CFLAGS += -use_readwrite_const build/src/libultra/libc/absf.o: OPTFLAGS := -O2 -g3 build/src/libultra/libc/sqrt.o: OPTFLAGS := -O2 -g3 diff --git a/assets/xml/objects/object_bv.xml b/assets/xml/objects/object_bv.xml index b6ef9e45f9..204273fc01 100644 --- a/assets/xml/objects/object_bv.xml +++ b/assets/xml/objects/object_bv.xml @@ -1,7 +1,7 @@ - + diff --git a/assets/xml/objects/object_fd.xml b/assets/xml/objects/object_fd.xml index d915b38c2f..776a2ee494 100644 --- a/assets/xml/objects/object_fd.xml +++ b/assets/xml/objects/object_fd.xml @@ -1,7 +1,7 @@ - + diff --git a/assets/xml/objects/object_fhg.xml b/assets/xml/objects/object_fhg.xml index eb07d8eb34..d12a90cb08 100644 --- a/assets/xml/objects/object_fhg.xml +++ b/assets/xml/objects/object_fhg.xml @@ -18,7 +18,7 @@ - + diff --git a/assets/xml/objects/object_ganon.xml b/assets/xml/objects/object_ganon.xml index 79cba2ab36..094c1394fe 100644 --- a/assets/xml/objects/object_ganon.xml +++ b/assets/xml/objects/object_ganon.xml @@ -68,7 +68,7 @@ - + diff --git a/assets/xml/objects/object_goma.xml b/assets/xml/objects/object_goma.xml index e7a6d0a544..543d9ce2a1 100644 --- a/assets/xml/objects/object_goma.xml +++ b/assets/xml/objects/object_goma.xml @@ -159,7 +159,7 @@ - + diff --git a/assets/xml/objects/object_kingdodongo.xml b/assets/xml/objects/object_kingdodongo.xml index b3da9a6086..1aa1735cbe 100644 --- a/assets/xml/objects/object_kingdodongo.xml +++ b/assets/xml/objects/object_kingdodongo.xml @@ -48,7 +48,7 @@ - + diff --git a/assets/xml/objects/object_mo.xml b/assets/xml/objects/object_mo.xml index 165b4e112c..b191e8395e 100644 --- a/assets/xml/objects/object_mo.xml +++ b/assets/xml/objects/object_mo.xml @@ -1,7 +1,7 @@ - + diff --git a/assets/xml/objects/object_sst.xml b/assets/xml/objects/object_sst.xml index aa3c7d7d17..ba1fad8172 100644 --- a/assets/xml/objects/object_sst.xml +++ b/assets/xml/objects/object_sst.xml @@ -2,7 +2,7 @@ - + diff --git a/assets/xml/objects/object_tw.xml b/assets/xml/objects/object_tw.xml index b48c974872..126926356f 100644 --- a/assets/xml/objects/object_tw.xml +++ b/assets/xml/objects/object_tw.xml @@ -350,7 +350,7 @@ - + diff --git a/assets/xml/textures/map_name_static.xml b/assets/xml/textures/map_name_static.xml index 3baf69e4ee..7ede7da9f6 100644 --- a/assets/xml/textures/map_name_static.xml +++ b/assets/xml/textures/map_name_static.xml @@ -9,7 +9,7 @@ - + diff --git a/first_diff.py b/first_diff.py index 472ec1bccd..f956ca26a3 100755 --- a/first_diff.py +++ b/first_diff.py @@ -1,255 +1,58 @@ #!/usr/bin/env python3 -import os.path import argparse -from subprocess import check_call +from pathlib import Path -parser = argparse.ArgumentParser( - description="Find the first difference(s) between the built ROM and the base ROM." -) -parser.add_argument( - "-c", - "--count", - type=int, - default=5, - help="find up to this many instruction difference(s)", -) -parser.add_argument( - "-d", - "--diff", - dest="diff_args", - nargs="?", - action="store", - default=False, - const="prompt", - help="run diff.py on the result with the provided arguments" -) -parser.add_argument( - "-m", "--make", help="run make before finding difference(s)", action="store_true" -) -args = parser.parse_args() - -diff_count = args.count - -if args.make: - check_call(["make", "-j4", "COMPARE=0"]) - -baseimg = f"baserom.z64" -basemap = f"expected/build/z64.map" - -myimg = f"zelda_ocarina_mq_dbg.z64" -mymap = f"build/z64.map" - -if not os.path.isfile(baseimg): - print(f"{baseimg} must exist.") - exit(1) -if not os.path.isfile(myimg) or not os.path.isfile(mymap): - print(f"{myimg} and {mymap} must exist.") +try: + import rabbitizer +except ImportError: + print("Missing dependency rabbitizer, install it with `python3 -m pip install 'rabbitizer>=1.0.0,<2.0.0'`") exit(1) -mybin = open(myimg, "rb").read() -basebin = open(baseimg, "rb").read() - -if len(mybin) != len(basebin): - print("Modified ROM has different size...") +try: + import mapfile_parser +except ImportError: + print("Missing dependency mapfile_parser, install it with `python3 -m pip install 'mapfile-parser>=1.2.1,<2.0.0'`") exit(1) -if mybin == basebin: - print("No differences!") - exit(0) +def decodeInstruction(bytesDiff: bytes, mapFile: mapfile_parser.MapFile) -> str: + word = (bytesDiff[0] << 24) | (bytesDiff[1] << 16) | (bytesDiff[2] << 8) | (bytesDiff[3] << 0) + instr = rabbitizer.Instruction(word) + immOverride = None -def search_rom_address(target_addr): - ram_offset = None - prev_ram = 0 - prev_rom = 0 - prev_sym = "" - cur_file = "" - prev_file = cur_file - prev_line = "" - with open(mymap) as f: - for line in f: - if "load address" in line: - # Ignore .bss sections since we're looking for a ROM address - if ".bss" in line or ".bss" in prev_line: - ram_offset = None - continue - ram = int(line[16 : 16 + 18], 0) - rom = int(line[59 : 59 + 18], 0) - ram_offset = ram - rom - continue + if instr.isJumpWithAddress(): + # Instruction is a function call (jal) - prev_line = line + # Get the embedded address of the function call + symAddress = instr.getInstrIndexAsVram() - if ( - ram_offset is None - or "=" in line - or "*fill*" in line - or " 0x" not in line - ): - continue + # Search for the address in the mapfile + symInfo = mapFile.findSymbolByVramOrVrom(symAddress) + if symInfo is not None: + # Use the symbol from the mapfile instead of a raw value + immOverride = symInfo.symbol.name - ram = int(line[16 : 16 + 18], 0) - rom = ram - ram_offset - sym = line.split()[-1] + return instr.disassemble(immOverride=immOverride, extraLJust=-20) - if sym.startswith("0x"): - ram_offset = None - continue - if "/" in sym: - cur_file = sym - continue +def firstDiffMain(): + parser = argparse.ArgumentParser(description="Find the first difference(s) between the built ROM and the base ROM.") - if rom > target_addr: - return f"{prev_sym} (RAM 0x{prev_ram:X}, ROM 0x{prev_rom:X}, {prev_file})" + parser.add_argument("-c", "--count", type=int, default=5, help="find up to this many instruction difference(s)") + parser.add_argument("-v", "--version", help="Which version should be processed", default="mq_dbg") + parser.add_argument("-a", "--add-colons", action='store_true', help="Add colon between bytes" ) - prev_ram = ram - prev_rom = rom - prev_sym = sym - prev_file = cur_file + args = parser.parse_args() - return "at end of rom?" + buildFolder = Path("build") + BUILTROM = Path(f"zelda_ocarina_{args.version}.z64") + BUILTMAP = buildFolder / f"z64.map" -def parse_map(map_fname): - ram_offset = None - cur_file = "" - syms = {} - prev_sym = None - prev_line = "" - with open(map_fname) as f: - for line in f: - if "load address" in line: - ram = int(line[16 : 16 + 18], 0) - rom = int(line[59 : 59 + 18], 0) - ram_offset = ram - rom - continue + EXPECTEDROM = Path("baserom.z64") + EXPECTEDMAP = "expected" / BUILTMAP - prev_line = line + mapfile_parser.frontends.first_diff.doFirstDiff(BUILTMAP, EXPECTEDMAP, BUILTROM, EXPECTEDROM, args.count, mismatchSize=True, addColons=args.add_colons, bytesConverterCallback=decodeInstruction) - if ( - ram_offset is None - or "=" in line - or "*fill*" in line - or " 0x" not in line - ): - continue - - ram = int(line[16 : 16 + 18], 0) - rom = ram - ram_offset - sym = line.split()[-1] - - if sym.startswith("0x"): - ram_offset = None - continue - elif "/" in sym: - cur_file = sym - continue - - syms[sym] = (rom, cur_file, prev_sym, ram) - prev_sym = sym - - return syms - - -def map_diff(): - map1 = parse_map(mymap) - map2 = parse_map(basemap) - min_ram = None - found = None - for sym, addr in map1.items(): - if sym not in map2: - continue - if addr[0] != map2[sym][0]: - if min_ram is None or addr[0] < min_ram: - min_ram = addr[0] - found = (sym, addr[1], addr[2]) - if min_ram is None: - return False - else: - print( - f"Map appears to have shifted just before {found[0]} ({found[1]}) -- in {found[2]}?" - ) - if found[2] is not None and found[2] not in map2: - print( - f"(Base map file {basemap} out of date due to new or renamed symbols, so result may be imprecise.)" - ) - return True - - -def hexbytes(bs): - return ":".join("{:02X}".format(c) for c in bs) - - -found_instr_diff = [] -map_search_diff = [] -diffs = 0 -shift_cap = 1000 -for i in range(24, len(mybin), 4): - # (mybin[i:i+4] != basebin[i:i+4], but that's slightly slower in CPython...) - if diffs <= shift_cap and ( - mybin[i] != basebin[i] - or mybin[i + 1] != basebin[i + 1] - or mybin[i + 2] != basebin[i + 2] - or mybin[i + 3] != basebin[i + 3] - ): - if diffs == 0: - print(f"First difference at ROM addr 0x{i:X}, {search_rom_address(i)}") - print( - f"Bytes: {hexbytes(mybin[i : i + 4])} vs {hexbytes(basebin[i : i + 4])}" - ) - diffs += 1 - if ( - len(found_instr_diff) < diff_count - and mybin[i] >> 2 != basebin[i] >> 2 - and not search_rom_address(i) in map_search_diff - ): - found_instr_diff.append(i) - map_search_diff.append(search_rom_address(i)) - -if diffs == 0: - print("No differences but ROMs differ?") - exit() - -if len(found_instr_diff) > 0: - for i in found_instr_diff: - print(f"Instruction difference at ROM addr 0x{i:X}, {search_rom_address(i)}") - print( - f"Bytes: {hexbytes(mybin[i : i + 4])} vs {hexbytes(basebin[i : i + 4])}" - ) -print() - -definite_shift = diffs > shift_cap -if definite_shift: - print(f"Over {shift_cap} differing words, must be a shifted ROM.") -else: - print(f"{diffs} differing word(s).") - -if diffs > 100: - if not os.path.isfile(basemap): - print( - f"To find ROM shifts, copy a clean .map file to {basemap} and rerun this script." - ) - elif not map_diff(): - print(f"No ROM shift{' (!?)' if definite_shift else ''}") - -if args.diff_args: - if len(found_instr_diff) < 1: - print(f"No instruction difference to run diff.py on") - exit() - - diff_sym = search_rom_address(found_instr_diff[0]).split()[0] - if args.diff_args == "prompt": - diff_args = input("Call diff.py with which arguments? ") or "--" - else: - diff_args = args.diff_args - if diff_args[0] != "-": - diff_args = "-" + diff_args - check_call( - [ - "python3", - "diff.py", - diff_args, - diff_sym, - ] - ) +if __name__ == "__main__": + firstDiffMain() diff --git a/format.py b/format.py index 826a707834..51b7b6ac7b 100755 --- a/format.py +++ b/format.py @@ -14,8 +14,8 @@ from typing import List # clang-format, clang-tidy and clang-apply-replacements default version -# Version 11 is used when available for more consistency between contributors -CLANG_VER = 11 +# This specific version is used when available, for more consistency between contributors +CLANG_VER = 14 # Clang-Format options (see .clang-format for rules applied) FORMAT_OPTS = "-i -style=file" @@ -144,6 +144,12 @@ def format_files(src_files: List[str], extra_files: List[str], nb_jobs: int): def main(): parser = argparse.ArgumentParser(description="Format files in the codebase to enforce most style rules") + parser.add_argument( + "--show-paths", + dest="show_paths", + action="store_true", + help="Print the paths to the clang-* binaries used", + ) parser.add_argument("files", metavar="file", nargs="*") parser.add_argument( "-j", @@ -155,6 +161,13 @@ def main(): ) args = parser.parse_args() + if args.show_paths: + import shutil + + print("CLANG_FORMAT ->", shutil.which(CLANG_FORMAT)) + print("CLANG_TIDY ->", shutil.which(CLANG_TIDY)) + print("CLANG_APPLY_REPLACEMENTS ->", shutil.which(CLANG_APPLY_REPLACEMENTS)) + nb_jobs = args.jobs or multiprocessing.cpu_count() if nb_jobs > 1: if CLANG_APPLY_REPLACEMENTS is None: diff --git a/include/segment_symbols.h b/include/segment_symbols.h index 61e2a3cbb5..e0741dc8c4 100644 --- a/include/segment_symbols.h +++ b/include/segment_symbols.h @@ -64,10 +64,6 @@ DECLARE_SEGMENT(code) DECLARE_ROM_SEGMENT(code) DECLARE_BSS_SEGMENT(code) -DECLARE_OVERLAY_SEGMENT(title) -DECLARE_OVERLAY_SEGMENT(select) -DECLARE_OVERLAY_SEGMENT(opening) -DECLARE_OVERLAY_SEGMENT(file_choose) DECLARE_OVERLAY_SEGMENT(kaleido_scope) DECLARE_OVERLAY_SEGMENT(player_actor) DECLARE_OVERLAY_SEGMENT(map_mark_data) diff --git a/include/tables/gamestate_table.h b/include/tables/gamestate_table.h new file mode 100644 index 0000000000..280740fe2a --- /dev/null +++ b/include/tables/gamestate_table.h @@ -0,0 +1,16 @@ +/** + * Gamestate Table + * + * DEFINE_GAMESTATE should be used for gamestates with code loaded from an overlay + * - Argument 1: Gamestate type name (without State suffix, also used for Init and Destroy function names) + * - Argument 2: Gamestate id enum name + * - Argument 3: Gamestate overlay spec segment name + * + * DEFINE_GAMESTATE_INTERNAL should be used for gamestates that aren't an overlay, the first two arguments are the same as for DEFINE_GAMESTATE + */ +/* 0x00 */ DEFINE_GAMESTATE_INTERNAL(Setup, GAMESTATE_SETUP) +/* 0x01 */ DEFINE_GAMESTATE(MapSelect, GAMESTATE_MAP_SELECT, select) +/* 0x02 */ DEFINE_GAMESTATE(ConsoleLogo, GAMESTATE_CONSOLE_LOGO, title) +/* 0x03 */ DEFINE_GAMESTATE_INTERNAL(Play, GAMESTATE_PLAY) +/* 0x04 */ DEFINE_GAMESTATE(TitleSetup, GAMESTATE_TITLE_SETUP, opening) +/* 0x05 */ DEFINE_GAMESTATE(FileSelect, GAMESTATE_FILE_SELECT, file_choose) diff --git a/include/z64.h b/include/z64.h index 066d6af7b2..b0199887c2 100644 --- a/include/z64.h +++ b/include/z64.h @@ -448,9 +448,9 @@ typedef struct { } KaleidoMgrOverlay; // size = 0x1C typedef enum { - /* 0x00 */ KALEIDO_OVL_KALEIDO_SCOPE, - /* 0x01 */ KALEIDO_OVL_PLAYER_ACTOR, - /* 0x02 */ KALEIDO_OVL_MAX + /* 0 */ KALEIDO_OVL_KALEIDO_SCOPE, + /* 1 */ KALEIDO_OVL_PLAYER_ACTOR, + /* 2 */ KALEIDO_OVL_MAX } KaleidoOverlayType; typedef enum { @@ -697,6 +697,16 @@ typedef struct { /* 0x10 */ GameAllocEntry* head; } GameAlloc; // size = 0x14 +// Used in Graph_GetNextGameState in graph.c +#define DEFINE_GAMESTATE_INTERNAL(typeName, enumName) enumName, +#define DEFINE_GAMESTATE(typeName, enumName, name) DEFINE_GAMESTATE_INTERNAL(typeName, enumName) +typedef enum { +#include "tables/gamestate_table.h" + GAMESTATE_ID_MAX +} GameStateId; +#undef DEFINE_GAMESTATE +#undef DEFINE_GAMESTATE_INTERNAL + struct GameState; typedef void (*GameStateFunc)(struct GameState* gameState); @@ -781,7 +791,7 @@ typedef struct { typedef struct { /* 0x00 */ u8 numActors; /* 0x04 */ TransitionActorEntry* list; -} TransitionActorContext; +} TransitionActorContext; // size = 0x8 typedef enum { /* 0 */ PAUSE_BG_PRERENDER_OFF, // Inactive, do nothing. @@ -1076,8 +1086,8 @@ typedef struct DebugDispObject { } DebugDispObject; // size = 0x2C typedef enum { - MTXMODE_NEW, // generates a new matrix - MTXMODE_APPLY // applies transformation to the current matrix + /* 0 */ MTXMODE_NEW, // generates a new matrix + /* 1 */ MTXMODE_APPLY // applies transformation to the current matrix } MatrixMode; typedef struct StackEntry { @@ -1091,9 +1101,9 @@ typedef struct StackEntry { } StackEntry; typedef enum { - STACK_STATUS_OK = 0, - STACK_STATUS_WARNING = 1, - STACK_STATUS_OVERFLOW = 2 + /* 0 */ STACK_STATUS_OK, + /* 1 */ STACK_STATUS_WARNING, + /* 2 */ STACK_STATUS_OVERFLOW } StackStatus; typedef struct { @@ -1318,22 +1328,22 @@ typedef enum { } ViModeEditState; typedef struct { - /* 0x0000 */ OSViMode customViMode; - /* 0x0050 */ s32 viHeight; - /* 0x0054 */ s32 viWidth; - /* 0x0058 */ s32 rightAdjust; - /* 0x005C */ s32 leftAdjust; - /* 0x0060 */ s32 lowerAdjust; - /* 0x0064 */ s32 upperAdjust; - /* 0x0068 */ s32 editState; - /* 0x006C */ s32 tvType; - /* 0x0070 */ u32 loRes; - /* 0x0074 */ u32 antialiasOff; - /* 0x0078 */ u32 modeN; // Controls interlacing, the meaning of this mode is different based on choice of resolution - /* 0x007C */ u32 fb16Bit; - /* 0x0080 */ u32 viFeatures; - /* 0x0084 */ u32 unk_84; -} ViMode; + /* 0x00 */ OSViMode customViMode; + /* 0x50 */ s32 viHeight; + /* 0x54 */ s32 viWidth; + /* 0x58 */ s32 rightAdjust; + /* 0x5C */ s32 leftAdjust; + /* 0x60 */ s32 lowerAdjust; + /* 0x64 */ s32 upperAdjust; + /* 0x68 */ s32 editState; + /* 0x6C */ s32 tvType; + /* 0x70 */ u32 loRes; + /* 0x74 */ u32 antialiasOff; + /* 0x78 */ u32 modeN; // Controls interlacing, the meaning of this mode is different based on choice of resolution + /* 0x7C */ u32 fb16Bit; + /* 0x80 */ u32 viFeatures; + /* 0x84 */ u32 unk_84; +} ViMode; // size = 0x88 // Vis... typedef struct { diff --git a/include/z64save.h b/include/z64save.h index e1769c34d4..de2b65bf5d 100644 --- a/include/z64save.h +++ b/include/z64save.h @@ -318,12 +318,12 @@ typedef enum { } ButtonStatus; typedef enum { - /* 0x00 */ CHAMBER_CS_FOREST, - /* 0x01 */ CHAMBER_CS_FIRE, - /* 0x02 */ CHAMBER_CS_WATER, - /* 0x03 */ CHAMBER_CS_SPIRIT, - /* 0x04 */ CHAMBER_CS_SHADOW, - /* 0x05 */ CHAMBER_CS_LIGHT + /* 0 */ CHAMBER_CS_FOREST, + /* 1 */ CHAMBER_CS_FIRE, + /* 2 */ CHAMBER_CS_WATER, + /* 3 */ CHAMBER_CS_SPIRIT, + /* 4 */ CHAMBER_CS_SHADOW, + /* 5 */ CHAMBER_CS_LIGHT } ChamberCutsceneNum; typedef enum { diff --git a/include/z64skybox.h b/include/z64skybox.h index 7df2f56d77..d97efe4567 100644 --- a/include/z64skybox.h +++ b/include/z64skybox.h @@ -41,14 +41,20 @@ typedef enum { /* 0x27 */ SKYBOX_UNSET_27 = 39 } SkyboxId; +typedef enum { + /* 0 */ SKYBOX_DRAW_128, // 128x128 top/bottom faces, 128x64 side faces + /* 1 */ SKYBOX_DRAW_256_4FACE, // 256x256 all side faces with per-face palettes + /* 2 */ SKYBOX_DRAW_256_3FACE // 256x256 3/4 side faces with per-face palettes +} SkyboxDrawType; + typedef struct SkyboxContext { /* 0x000 */ char unk_00[0x128]; /* 0x128 */ void* staticSegments[2]; /* 0x130 */ u16 (*palettes)[256]; /* 0x134 */ Gfx (*dListBuf)[150]; - /* 0x138 */ Gfx* unk_138; + /* 0x138 */ Gfx* gfx; /* 0x13C */ Vtx* roomVtx; - /* 0x140 */ s16 unk_140; + /* 0x140 */ s16 drawType; /* 0x144 */ Vec3f rot; /* 0x150 */ char unk_150[0x10]; } SkyboxContext; // size = 0x160 diff --git a/spec b/spec index c515af7e92..375eb73dc6 100644 --- a/spec +++ b/spec @@ -387,8 +387,8 @@ beginseg include "build/src/code/PreRender.o" include "build/src/code/TwoHeadGfxArena.o" include "build/src/code/TwoHeadArena.o" - include "build/src/code/code_800C3C20.o" - include "build/src/code/audioMgr.o" + include "build/src/code/audio_stop_all_sfx.o" + include "build/src/code/audio_thread_manager.o" include "build/src/code/title_setup.o" include "build/src/code/game.o" include "build/src/code/gamealloc.o" @@ -417,22 +417,22 @@ beginseg include "build/src/code/kanread.o" include "build/src/code/ucode_disas.o" pad_text // audio library aligned to 32 bytes? - include "build/src/code/audio_data.o" - include "build/src/code/audio_synthesis.o" - include "build/src/code/audio_heap.o" - include "build/src/code/audio_load.o" - include "build/src/code/code_800E4FE0.o" - include "build/src/code/code_800E6840.o" - include "build/src/libultra/io/aisetnextbuf.o" - include "build/src/code/audio_playback.o" - include "build/src/code/audio_effects.o" - include "build/src/code/audio_seqplayer.o" - include "build/src/code/code_800EC960.o" - include "build/src/code/audio_sfx_params.o" - include "build/src/code/code_800F7260.o" - include "build/src/code/code_800F9280.o" - include "build/src/code/audio_external_data.o" - include "build/src/code/audio_init_params.o" + include "build/src/audio/lib/data.o" + include "build/src/audio/lib/synthesis.o" + include "build/src/audio/lib/heap.o" + include "build/src/audio/lib/load.o" + include "build/src/audio/lib/thread.o" + include "build/src/audio/lib/dcache.o" + include "build/src/audio/lib/aisetnextbuf.o" + include "build/src/audio/lib/playback.o" + include "build/src/audio/lib/effects.o" + include "build/src/audio/lib/seqplayer.o" + include "build/src/audio/general.o" + include "build/src/audio/sfx_params.o" + include "build/src/audio/sfx.o" + include "build/src/audio/sequence.o" + include "build/src/audio/data.o" + include "build/src/audio/session_config.o" include "build/src/code/logseverity.o" include "build/src/code/gfxprint.o" include "build/src/code/rcp_utils.o" diff --git a/src/code/audio_external_data.c b/src/audio/data.c similarity index 100% rename from src/code/audio_external_data.c rename to src/audio/data.c diff --git a/src/code/code_800EC960.c b/src/audio/general.c similarity index 100% rename from src/code/code_800EC960.c rename to src/audio/general.c diff --git a/src/libultra/io/aisetnextbuf.c b/src/audio/lib/aisetnextbuf.c similarity index 100% rename from src/libultra/io/aisetnextbuf.c rename to src/audio/lib/aisetnextbuf.c diff --git a/src/code/audio_data.c b/src/audio/lib/data.c similarity index 100% rename from src/code/audio_data.c rename to src/audio/lib/data.c diff --git a/src/code/code_800E6840.c b/src/audio/lib/dcache.c similarity index 100% rename from src/code/code_800E6840.c rename to src/audio/lib/dcache.c diff --git a/src/code/audio_effects.c b/src/audio/lib/effects.c similarity index 100% rename from src/code/audio_effects.c rename to src/audio/lib/effects.c diff --git a/src/code/audio_heap.c b/src/audio/lib/heap.c similarity index 100% rename from src/code/audio_heap.c rename to src/audio/lib/heap.c diff --git a/src/code/audio_load.c b/src/audio/lib/load.c similarity index 100% rename from src/code/audio_load.c rename to src/audio/lib/load.c diff --git a/src/code/audio_playback.c b/src/audio/lib/playback.c similarity index 100% rename from src/code/audio_playback.c rename to src/audio/lib/playback.c diff --git a/src/code/audio_seqplayer.c b/src/audio/lib/seqplayer.c similarity index 100% rename from src/code/audio_seqplayer.c rename to src/audio/lib/seqplayer.c diff --git a/src/code/audio_synthesis.c b/src/audio/lib/synthesis.c similarity index 100% rename from src/code/audio_synthesis.c rename to src/audio/lib/synthesis.c diff --git a/src/code/code_800E4FE0.c b/src/audio/lib/thread.c similarity index 100% rename from src/code/code_800E4FE0.c rename to src/audio/lib/thread.c diff --git a/src/code/code_800F9280.c b/src/audio/sequence.c similarity index 100% rename from src/code/code_800F9280.c rename to src/audio/sequence.c diff --git a/src/code/audio_init_params.c b/src/audio/session_config.c similarity index 100% rename from src/code/audio_init_params.c rename to src/audio/session_config.c diff --git a/src/code/code_800F7260.c b/src/audio/sfx.c similarity index 100% rename from src/code/code_800F7260.c rename to src/audio/sfx.c diff --git a/src/code/audio_sfx_params.c b/src/audio/sfx_params.c similarity index 100% rename from src/code/audio_sfx_params.c rename to src/audio/sfx_params.c diff --git a/src/code/PreRender.c b/src/code/PreRender.c index 44af417150..dc12fd2a5d 100644 --- a/src/code/PreRender.c +++ b/src/code/PreRender.c @@ -369,12 +369,12 @@ void PreRender_FetchFbufCoverage(PreRender* this, Gfx** gfxp) { // // G_RM_VISCVG is the following special render mode: // IM_RD : Allow read-modify-write operations on the framebuffer - // FORCE_BL : Apply the blender to all pixels rather than just edges - // (G_BL_CLR_IN * G_BL_0 + G_BL_CLR_BL * G_BL_A_MEM) / (G_BL_0 + G_BL_CLR_BL) = G_BL_A_MEM + // FORCE_BL : Apply the blender to all pixels rather than just edges, skip the division step of the blend formula + // (G_BL_CLR_IN * G_BL_0 + G_BL_CLR_BL * G_BL_A_MEM) = G_BL_CLR_BL * G_BL_A_MEM // - // G_BL_A_MEM ("memory alpha") is coverage, therefore this blender configuration emits only the coverage - // and discards any pixel colors. For an RGBA16 framebuffer, each of the three color channels r,g,b will - // receive the coverage value individually. + // G_BL_A_MEM ("memory alpha") is coverage, therefore this blender configuration emits only the coverage (up to a + // constant factor determined by blend color) and discards any pixel colors. For an RGBA16 framebuffer, each of the + // three color channels r,g,b will receive the coverage value individually. // // Also disables other modes such as alpha compare and texture perspective correction gDPSetOtherMode(gfx++, diff --git a/src/code/code_800C3C20.c b/src/code/audio_stop_all_sfx.c similarity index 100% rename from src/code/code_800C3C20.c rename to src/code/audio_stop_all_sfx.c diff --git a/src/code/audioMgr.c b/src/code/audio_thread_manager.c similarity index 100% rename from src/code/audioMgr.c rename to src/code/audio_thread_manager.c diff --git a/src/code/game.c b/src/code/game.c index 478fd709df..10fdcbefd9 100644 --- a/src/code/game.c +++ b/src/code/game.c @@ -489,7 +489,7 @@ void* GameState_Alloc(GameState* gameState, size_t size, char* file, s32 line) { } if (ret != NULL) { osSyncPrintf(VT_FGCOL(GREEN)); - osSyncPrintf("game_alloc(%08x) %08x-%08x [%s:%d]\n", size, ret, (u32)ret + size, file, line); + osSyncPrintf("game_alloc(%08x) %08x-%08x [%s:%d]\n", size, ret, (uintptr_t)ret + size, file, line); osSyncPrintf(VT_RST); } return ret; diff --git a/src/code/graph.c b/src/code/graph.c index e5309966c7..3d53f891cb 100644 --- a/src/code/graph.c +++ b/src/code/graph.c @@ -116,24 +116,15 @@ void Graph_InitTHGA(GraphicsContext* gfxCtx) { GameStateOverlay* Graph_GetNextGameState(GameState* gameState) { void* gameStateInitFunc = GameState_GetInit(gameState); - if (gameStateInitFunc == Setup_Init) { - return &gGameStateOverlayTable[0]; - } - if (gameStateInitFunc == MapSelect_Init) { - return &gGameStateOverlayTable[1]; - } - if (gameStateInitFunc == ConsoleLogo_Init) { - return &gGameStateOverlayTable[2]; - } - if (gameStateInitFunc == Play_Init) { - return &gGameStateOverlayTable[3]; - } - if (gameStateInitFunc == TitleSetup_Init) { - return &gGameStateOverlayTable[4]; - } - if (gameStateInitFunc == FileSelect_Init) { - return &gGameStateOverlayTable[5]; + // Generates code to match gameStateInitFunc to a gamestate entry and returns it if found +#define DEFINE_GAMESTATE_INTERNAL(typeName, enumName) \ + if (gameStateInitFunc == typeName##_Init) { \ + return &gGameStateOverlayTable[enumName]; \ } +#define DEFINE_GAMESTATE(typeName, enumName, name) DEFINE_GAMESTATE_INTERNAL(typeName, enumName) +#include "tables/gamestate_table.h" +#undef DEFINE_GAMESTATE +#undef DEFINE_GAMESTATE_INTERNAL LOG_ADDRESS("game_init_func", gameStateInitFunc, "../graph.c", 696); return NULL; @@ -421,16 +412,14 @@ void Graph_ThreadEntry(void* arg0) { GraphicsContext gfxCtx; GameState* gameState; u32 size; - GameStateOverlay* nextOvl; + GameStateOverlay* nextOvl = &gGameStateOverlayTable[GAMESTATE_SETUP]; GameStateOverlay* ovl; char faultMsg[0x50]; - nextOvl = &gGameStateOverlayTable[0]; - osSyncPrintf("グラフィックスレッド実行開始\n"); // "Start graphic thread execution" Graph_Init(&gfxCtx); - while (nextOvl) { + while (nextOvl != NULL) { ovl = nextOvl; Overlay_LoadGameState(ovl); diff --git a/src/code/loadfragment2.c b/src/code/loadfragment2.c index 8212572645..97002f9e9e 100644 --- a/src/code/loadfragment2.c +++ b/src/code/loadfragment2.c @@ -1,7 +1,8 @@ #include "global.h" void* Overlay_AllocateAndLoad(uintptr_t vromStart, uintptr_t vromEnd, void* vramStart, void* vramEnd) { - void* allocatedRamAddr = SystemArena_MallocRDebug((s32)vramEnd - (s32)vramStart, "../loadfragment2.c", 31); + void* allocatedRamAddr = + SystemArena_MallocRDebug((intptr_t)vramEnd - (intptr_t)vramStart, "../loadfragment2.c", 31); if (gOverlayLogSeverity >= 3) { osSyncPrintf("OVL:SPEC(%08x-%08x) REAL(%08x-%08x) OFFSET(%08x)\n", vramStart, vramEnd, allocatedRamAddr, diff --git a/src/code/z_actor.c b/src/code/z_actor.c index 637f7fceec..ac74078a99 100644 --- a/src/code/z_actor.c +++ b/src/code/z_actor.c @@ -731,7 +731,7 @@ void TitleCard_Draw(PlayState* play, TitleCardContext* titleCtx) { gDPSetPrimColor(OVERLAY_DISP++, 0, 0, (u8)titleCtx->intensity, (u8)titleCtx->intensity, (u8)titleCtx->intensity, (u8)titleCtx->alpha); - gDPLoadTextureBlock(OVERLAY_DISP++, (s32)titleCtx->texture + textureLanguageOffset, G_IM_FMT_IA, G_IM_SIZ_8b, + gDPLoadTextureBlock(OVERLAY_DISP++, (u8*)titleCtx->texture + textureLanguageOffset, G_IM_FMT_IA, G_IM_SIZ_8b, width, height, 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); @@ -742,7 +742,7 @@ void TitleCard_Draw(PlayState* play, TitleCardContext* titleCtx) { // If texture is bigger than 0x1000, display the rest if (height > 0) { - gDPLoadTextureBlock(OVERLAY_DISP++, (s32)titleCtx->texture + textureLanguageOffset + 0x1000, G_IM_FMT_IA, + gDPLoadTextureBlock(OVERLAY_DISP++, (u8*)titleCtx->texture + textureLanguageOffset + 0x1000, G_IM_FMT_IA, G_IM_SIZ_8b, width, height, 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); @@ -1963,6 +1963,9 @@ void Actor_DrawFaroresWindPointer(PlayState* play) { lightRadius = 500.0f * ratio; + //! @bug One of the conditions for this block checks an entrance index to see if the light ball should draw. + //! This does not account for the fact that some dungeons have multiple entrances. + //! If a dungeon is entered through a different entrance than the one that was saved, the light ball will not draw. if ((play->csCtx.state == CS_STATE_IDLE) && (((void)0, gSaveContext.respawn[RESPAWN_MODE_TOP].entranceIndex) == ((void)0, gSaveContext.entranceIndex)) && @@ -1995,6 +1998,8 @@ void Actor_DrawFaroresWindPointer(PlayState* play) { gSPDisplayList(POLY_XLU_DISP++, gEffFlash1DL); } + //! @bug This function call is not contained in the above block, meaning the light for Farore's Wind will draw in + //! every scene at the same position that it was originally set. Lights_PointNoGlowSetInfo(&D_8015BC00, ((void)0, gSaveContext.respawn[RESPAWN_MODE_TOP].pos.x), ((void)0, gSaveContext.respawn[RESPAWN_MODE_TOP].pos.y) + yOffset, ((void)0, gSaveContext.respawn[RESPAWN_MODE_TOP].pos.z), 255, 255, 255, lightRadius); @@ -2749,7 +2754,7 @@ Actor* Actor_Spawn(ActorContext* actorCtx, PlayState* play, s16 actorId, f32 pos ASSERT(actorId < ACTOR_ID_MAX, "profile < ACTOR_DLF_MAX", "../z_actor.c", 6883); name = overlayEntry->name != NULL ? overlayEntry->name : ""; - overlaySize = (u32)overlayEntry->vramEnd - (u32)overlayEntry->vramStart; + overlaySize = (uintptr_t)overlayEntry->vramEnd - (uintptr_t)overlayEntry->vramStart; if (HREG(20) != 0) { // "Actor class addition [%d:%s]" @@ -2807,17 +2812,19 @@ Actor* Actor_Spawn(ActorContext* actorCtx, PlayState* play, s16 actorId, f32 pos osSyncPrintf(VT_FGCOL(GREEN)); osSyncPrintf("OVL(a):Seg:%08x-%08x Ram:%08x-%08x Off:%08x %s\n", overlayEntry->vramStart, overlayEntry->vramEnd, overlayEntry->loadedRamAddr, - (u32)overlayEntry->loadedRamAddr + (u32)overlayEntry->vramEnd - (u32)overlayEntry->vramStart, - (u32)overlayEntry->vramStart - (u32)overlayEntry->loadedRamAddr, name); + (uintptr_t)overlayEntry->loadedRamAddr + (uintptr_t)overlayEntry->vramEnd - + (uintptr_t)overlayEntry->vramStart, + (uintptr_t)overlayEntry->vramStart - (uintptr_t)overlayEntry->loadedRamAddr, name); osSyncPrintf(VT_RST); overlayEntry->numLoaded = 0; } - actorInit = (void*)(u32)((overlayEntry->initInfo != NULL) - ? (void*)((u32)overlayEntry->initInfo - - (s32)((u32)overlayEntry->vramStart - (u32)overlayEntry->loadedRamAddr)) - : NULL); + actorInit = (void*)(uintptr_t)((overlayEntry->initInfo != NULL) + ? (void*)((uintptr_t)overlayEntry->initInfo - + (intptr_t)((uintptr_t)overlayEntry->vramStart - + (uintptr_t)overlayEntry->loadedRamAddr)) + : NULL); } objBankIndex = Object_GetIndex(&play->objectCtx, actorInit->objectId); diff --git a/src/code/z_actor_dlftbls.c b/src/code/z_actor_dlftbls.c index 22fa580d7b..69e84c436d 100644 --- a/src/code/z_actor_dlftbls.c +++ b/src/code/z_actor_dlftbls.c @@ -76,10 +76,10 @@ void ActorOverlayTable_FaultPrint(void* arg0, void* arg1) { FaultDrawer_Printf("No. RamStart- RamEnd cn Name\n"); for (i = 0, overlayEntry = &gActorOverlayTable[0]; i < gMaxActorId; i++, overlayEntry++) { - overlaySize = (u32)overlayEntry->vramEnd - (u32)overlayEntry->vramStart; + overlaySize = (uintptr_t)overlayEntry->vramEnd - (uintptr_t)overlayEntry->vramStart; if (overlayEntry->loadedRamAddr != NULL) { FaultDrawer_Printf("%3d %08x-%08x %3d %s\n", i, overlayEntry->loadedRamAddr, - (u32)overlayEntry->loadedRamAddr + overlaySize, overlayEntry->numLoaded, + (uintptr_t)overlayEntry->loadedRamAddr + overlaySize, overlayEntry->numLoaded, overlayEntry->name != NULL ? overlayEntry->name : ""); } } diff --git a/src/code/z_bgcheck.c b/src/code/z_bgcheck.c index 7dbc465be6..833bea98a4 100644 --- a/src/code/z_bgcheck.c +++ b/src/code/z_bgcheck.c @@ -2880,21 +2880,25 @@ void DynaPoly_AddBgActorToLookup(PlayState* play, DynaCollisionContext* dyna, s3 if (!(dyna->bitFlag & DYNAPOLY_INVALIDATE_LOOKUP) && (BgActor_IsTransformUnchanged(&dyna->bgActors[bgId]) == true)) { s32 pi; + for (pi = *polyStartIndex; pi < *polyStartIndex + pbgdata->numPolygons; pi++) { CollisionPoly* poly = &dyna->polyList[pi]; s16 normalY = poly->normal.y; if (normalY > COLPOLY_SNORMAL(0.5f)) { s16 polyIndex = pi; + DynaSSNodeList_SetSSListHead(&dyna->polyNodes, &dyna->bgActors[bgId].dynaLookup.floor, &polyIndex); } else if (normalY < COLPOLY_SNORMAL(-0.8f)) { if (!(dyna->bgActorFlags[bgId] & BGACTOR_CEILING_COLLISION_DISABLED)) { s16 polyIndex = pi; + DynaSSNodeList_SetSSListHead(&dyna->polyNodes, &dyna->bgActors[bgId].dynaLookup.ceiling, &polyIndex); } } else { s16 polyIndex = pi; + DynaSSNodeList_SetSSListHead(&dyna->polyNodes, &dyna->bgActors[bgId].dynaLookup.wall, &polyIndex); } } @@ -2914,6 +2918,7 @@ void DynaPoly_AddBgActorToLookup(PlayState* play, DynaCollisionContext* dyna, s3 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); @@ -2936,7 +2941,7 @@ void DynaPoly_AddBgActorToLookup(PlayState* play, DynaCollisionContext* dyna, s3 sphere->center.x = newCenterPoint.x; sphere->center.y = newCenterPoint.y; sphere->center.z = newCenterPoint.z; - newRadiusSq = -100.0f; + newRadiusSq = -SQ(10.0f); for (i = 0; i < pbgdata->numVertices; i++) { f32 radiusSq; @@ -2989,12 +2994,15 @@ void DynaPoly_AddBgActorToLookup(PlayState* play, DynaCollisionContext* dyna, s3 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); } } @@ -3013,7 +3021,7 @@ void DynaPoly_UnsetAllInteractFlags(PlayState* play, DynaCollisionContext* dyna, dynaActor = DynaPoly_GetActor(&play->colCtx, i); if (dynaActor != NULL && &dynaActor->actor == actor) { DynaPolyActor_UnsetAllInteractFlags((DynaPolyActor*)actor); - return; + break; } } } diff --git a/src/code/z_common_data.c b/src/code/z_common_data.c index dd039f8a28..94d8b7a3f8 100644 --- a/src/code/z_common_data.c +++ b/src/code/z_common_data.c @@ -14,7 +14,7 @@ void SaveContext_Init(void) { gSaveContext.forcedSeqId = NA_BGM_GENERAL_SFX; gSaveContext.nextCutsceneIndex = 0xFFEF; gSaveContext.cutsceneTrigger = 0; - gSaveContext.chamberCutsceneNum = 0; + gSaveContext.chamberCutsceneNum = CHAMBER_CS_FOREST; gSaveContext.nextDayTime = NEXT_TIME_NONE; gSaveContext.skyboxTime = 0; gSaveContext.dogIsLost = true; diff --git a/src/code/z_demo.c b/src/code/z_demo.c index e30c088ac2..c505f333ca 100644 --- a/src/code/z_demo.c +++ b/src/code/z_demo.c @@ -790,7 +790,7 @@ void CutsceneCmd_Destination(PlayState* play, CutsceneContext* csCtx, CsCmdDesti case CS_DEST_CHAMBER_OF_SAGES_FOREST_MEDALLION: play->nextEntranceIndex = ENTR_CHAMBER_OF_THE_SAGES_0; play->transitionTrigger = TRANS_TRIGGER_START; - gSaveContext.chamberCutsceneNum = 0; + gSaveContext.chamberCutsceneNum = CHAMBER_CS_FOREST; play->transitionType = TRANS_TYPE_FADE_WHITE; break; @@ -799,14 +799,14 @@ void CutsceneCmd_Destination(PlayState* play, CutsceneContext* csCtx, CsCmdDesti play->transitionTrigger = TRANS_TRIGGER_START; play->transitionType = TRANS_TYPE_FADE_WHITE; Item_Give(play, ITEM_MEDALLION_FIRE); - gSaveContext.chamberCutsceneNum = 1; + gSaveContext.chamberCutsceneNum = CHAMBER_CS_FIRE; break; case CS_DEST_CHAMBER_OF_SAGES_WATER_MEDALLION: play->nextEntranceIndex = ENTR_CHAMBER_OF_THE_SAGES_0; play->transitionTrigger = TRANS_TRIGGER_START; play->transitionType = TRANS_TYPE_FADE_WHITE; - gSaveContext.chamberCutsceneNum = 2; + gSaveContext.chamberCutsceneNum = CHAMBER_CS_WATER; break; case CS_DEST_HYRULE_FIELD_FLASHBACK: diff --git a/src/code/z_effect_soft_sprite.c b/src/code/z_effect_soft_sprite.c index 655ed040d7..55a1245a3f 100644 --- a/src/code/z_effect_soft_sprite.c +++ b/src/code/z_effect_soft_sprite.c @@ -11,7 +11,8 @@ void EffectSs_InitInfo(PlayState* play, s32 tableSize) { for (i = 0; i < ARRAY_COUNT(gEffectSsOverlayTable); i++) { overlay = &gEffectSsOverlayTable[i]; osSyncPrintf("effect index %3d:size=%6dbyte romsize=%6dbyte\n", i, - (u32)overlay->vramEnd - (u32)overlay->vramStart, overlay->vromEnd - overlay->vromStart); + (uintptr_t)overlay->vramEnd - (uintptr_t)overlay->vramStart, + overlay->vromEnd - overlay->vromStart); } sEffectSsInfo.table = GameState_Alloc(&play->state, tableSize * sizeof(EffectSs), "../z_effect_soft_sprite.c", 289); @@ -180,7 +181,7 @@ void EffectSs_Spawn(PlayState* play, s32 type, s32 priority, void* initParams) { } sEffectSsInfo.searchStartIndex = index + 1; - overlaySize = (u32)overlayEntry->vramEnd - (u32)overlayEntry->vramStart; + overlaySize = (uintptr_t)overlayEntry->vramEnd - (uintptr_t)overlayEntry->vramStart; if (overlayEntry->vramStart == NULL) { // "Not an overlay" @@ -212,10 +213,11 @@ void EffectSs_Spawn(PlayState* play, s32 type, s32 priority, void* initParams) { osSyncPrintf(VT_RST); } - initInfo = (void*)(u32)((overlayEntry->initInfo != NULL) - ? (void*)((u32)overlayEntry->initInfo - - (s32)((u32)overlayEntry->vramStart - (u32)overlayEntry->loadedRamAddr)) - : NULL); + initInfo = (void*)(uintptr_t)((overlayEntry->initInfo != NULL) + ? (void*)((uintptr_t)overlayEntry->initInfo - + (intptr_t)((uintptr_t)overlayEntry->vramStart - + (uintptr_t)overlayEntry->loadedRamAddr)) + : NULL); } if (initInfo->init == NULL) { diff --git a/src/code/z_game_dlftbls.c b/src/code/z_game_dlftbls.c index bfce662484..8e9f00fecb 100644 --- a/src/code/z_game_dlftbls.c +++ b/src/code/z_game_dlftbls.c @@ -1,18 +1,35 @@ #include "global.h" -#define GAMESTATE_OVERLAY(name, init, destroy, size) \ - { \ - NULL, (uintptr_t)_ovl_##name##SegmentRomStart, (uintptr_t)_ovl_##name##SegmentRomEnd, \ - _ovl_##name##SegmentStart, _ovl_##name##SegmentEnd, NULL, init, destroy, NULL, NULL, 0, size \ - } -#define GAMESTATE_OVERLAY_INTERNAL(init, destroy, size) \ - { NULL, 0, 0, NULL, NULL, NULL, init, destroy, NULL, NULL, 0, size } +// Linker symbol declarations (used in the table below) +#define DEFINE_GAMESTATE(typeName, enumName, name) DECLARE_OVERLAY_SEGMENT(name) +#define DEFINE_GAMESTATE_INTERNAL(typeName, enumName) + +#include "tables/gamestate_table.h" + +#undef DEFINE_GAMESTATE +#undef DEFINE_GAMESTATE_INTERNAL + +// Gamestate Overlay Table definition +#define DEFINE_GAMESTATE_INTERNAL(typeName, enumName) \ + { NULL, 0, 0, NULL, NULL, NULL, typeName##_Init, typeName##_Destroy, NULL, NULL, 0, sizeof(typeName##State) }, + +#define DEFINE_GAMESTATE(typeName, enumName, name) \ + { NULL, \ + (uintptr_t)_ovl_##name##SegmentRomStart, \ + (uintptr_t)_ovl_##name##SegmentRomEnd, \ + _ovl_##name##SegmentStart, \ + _ovl_##name##SegmentEnd, \ + NULL, \ + typeName##_Init, \ + typeName##_Destroy, \ + NULL, \ + NULL, \ + 0, \ + sizeof(typeName##State) }, GameStateOverlay gGameStateOverlayTable[] = { - GAMESTATE_OVERLAY_INTERNAL(Setup_Init, Setup_Destroy, sizeof(SetupState)), - GAMESTATE_OVERLAY(select, MapSelect_Init, MapSelect_Destroy, sizeof(MapSelectState)), - GAMESTATE_OVERLAY(title, ConsoleLogo_Init, ConsoleLogo_Destroy, sizeof(ConsoleLogoState)), - GAMESTATE_OVERLAY_INTERNAL(Play_Init, Play_Destroy, sizeof(PlayState)), - GAMESTATE_OVERLAY(opening, TitleSetup_Init, TitleSetup_Destroy, sizeof(TitleSetupState)), - GAMESTATE_OVERLAY(file_choose, FileSelect_Init, FileSelect_Destroy, sizeof(FileSelectState)), +#include "tables/gamestate_table.h" }; + +#undef DEFINE_GAMESTATE +#undef DEFINE_GAMESTATE_INTERNAL diff --git a/src/code/z_jpeg.c b/src/code/z_jpeg.c index 988d402ae6..2285eac8c9 100644 --- a/src/code/z_jpeg.c +++ b/src/code/z_jpeg.c @@ -102,7 +102,7 @@ void Jpeg_CopyToZbuffer(u16* src, u16* zbuffer, s32 x, s32 y) { * unaligned values in JPEG header files. */ u16 Jpeg_GetUnalignedU16(u8* ptr) { - if (((u32)ptr & 1) == 0) { + if (((uintptr_t)ptr & 1) == 0) { // Read the value normally if it's aligned to a 16-bit address. return *(u16*)ptr; } else { diff --git a/src/code/z_kaleido_manager.c b/src/code/z_kaleido_manager.c index 8a11d69bbc..dfae977042 100644 --- a/src/code/z_kaleido_manager.c +++ b/src/code/z_kaleido_manager.c @@ -24,18 +24,18 @@ void KaleidoManager_LoadOvl(KaleidoMgrOverlay* ovl) { osSyncPrintf(VT_FGCOL(GREEN)); osSyncPrintf("OVL(k):Seg:%08x-%08x Ram:%08x-%08x Off:%08x %s\n", ovl->vramStart, ovl->vramEnd, ovl->loadedRamAddr, - (u32)ovl->loadedRamAddr + (u32)ovl->vramEnd - (u32)ovl->vramStart, - (u32)ovl->vramStart - (u32)ovl->loadedRamAddr, ovl->name); + (uintptr_t)ovl->loadedRamAddr + (uintptr_t)ovl->vramEnd - (uintptr_t)ovl->vramStart, + (uintptr_t)ovl->vramStart - (uintptr_t)ovl->loadedRamAddr, ovl->name); osSyncPrintf(VT_RST); - ovl->offset = (u32)ovl->loadedRamAddr - (u32)ovl->vramStart; + ovl->offset = (uintptr_t)ovl->loadedRamAddr - (uintptr_t)ovl->vramStart; gKaleidoMgrCurOvl = ovl; } void KaleidoManager_ClearOvl(KaleidoMgrOverlay* ovl) { if (ovl->loadedRamAddr != NULL) { ovl->offset = 0; - bzero(ovl->loadedRamAddr, (u32)ovl->vramEnd - (u32)ovl->vramStart); + bzero(ovl->loadedRamAddr, (uintptr_t)ovl->vramEnd - (uintptr_t)ovl->vramStart); ovl->loadedRamAddr = NULL; gKaleidoMgrCurOvl = NULL; } @@ -47,7 +47,7 @@ void KaleidoManager_Init(PlayState* play) { u32 i; for (i = 0; i < ARRAY_COUNT(gKaleidoMgrOverlayTable); i++) { - size = (u32)gKaleidoMgrOverlayTable[i].vramEnd - (u32)gKaleidoMgrOverlayTable[i].vramStart; + size = (uintptr_t)gKaleidoMgrOverlayTable[i].vramEnd - (uintptr_t)gKaleidoMgrOverlayTable[i].vramStart; if (size > largestSize) { largestSize = size; } @@ -61,7 +61,7 @@ void KaleidoManager_Init(PlayState* play) { LogUtils_CheckNullPointer("KaleidoArea_allocp", sKaleidoAreaPtr, "../z_kaleido_manager.c", 151); osSyncPrintf(VT_FGCOL(GREEN)); - osSyncPrintf("KaleidoArea %08x - %08x\n", sKaleidoAreaPtr, (u32)sKaleidoAreaPtr + largestSize); + osSyncPrintf("KaleidoArea %08x - %08x\n", sKaleidoAreaPtr, (uintptr_t)sKaleidoAreaPtr + largestSize); osSyncPrintf(VT_RST); gKaleidoMgrCurOvl = NULL; @@ -85,7 +85,7 @@ void* KaleidoManager_GetRamAddr(void* vram) { if (ovl == NULL) { iter = &gKaleidoMgrOverlayTable[0]; for (i = 0; i < ARRAY_COUNT(gKaleidoMgrOverlayTable); i++) { - if (((u32)vram >= (u32)iter->vramStart) && ((u32)iter->vramEnd >= (u32)vram)) { + if (((uintptr_t)vram >= (uintptr_t)iter->vramStart) && ((uintptr_t)iter->vramEnd >= (uintptr_t)vram)) { KaleidoManager_LoadOvl(iter); ovl = iter; goto KaleidoManager_GetRamAddr_end; @@ -98,9 +98,10 @@ void* KaleidoManager_GetRamAddr(void* vram) { } KaleidoManager_GetRamAddr_end: - if ((ovl == NULL) || ((u32)vram < (u32)ovl->vramStart) || ((u32)vram >= (u32)ovl->vramEnd)) { + if ((ovl == NULL) || ((uintptr_t)vram < (uintptr_t)ovl->vramStart) || + ((uintptr_t)vram >= (uintptr_t)ovl->vramEnd)) { return NULL; } - return (void*)((u32)vram + ovl->offset); + return (void*)((uintptr_t)vram + ovl->offset); } diff --git a/src/code/z_kankyo.c b/src/code/z_kankyo.c index 958af3af0b..c1c90ebb09 100644 --- a/src/code/z_kankyo.c +++ b/src/code/z_kankyo.c @@ -12,13 +12,14 @@ typedef enum { } LightningBoltState; typedef struct { - /* 0x00 */ s32 mantissa; - /* 0x04 */ s32 exponent; -} ZBufValConversionEntry; // size = 0x8 + /* 0x00 */ s32 mantissaShift; // shift applied to the mantissa of the z buffer value + /* 0x04 */ s32 base; // 15.3 fixed-point base value for the exponent +} ZBufValConversionEntry; // size = 0x8 +// This table needs as many values as there are values for the 3-bit exponent ZBufValConversionEntry sZBufValConversionTable[1 << 3] = { - { 6, 0x00000 }, { 5, 0x20000 }, { 4, 0x30000 }, { 3, 0x38000 }, - { 2, 0x3C000 }, { 1, 0x3E000 }, { 0, 0x3F000 }, { 0, 0x3F800 }, + { 6, 0x0000 << 3 }, { 5, 0x4000 << 3 }, { 4, 0x6000 << 3 }, { 3, 0x7000 << 3 }, + { 2, 0x7800 << 3 }, { 1, 0x7C00 << 3 }, { 0, 0x7E00 << 3 }, { 0, 0x7F00 << 3 }, }; u8 gWeatherMode = WEATHER_MODE_CLEAR; // "E_wether_flg" @@ -225,9 +226,9 @@ u16 sSandstormScroll; * 4: dz value (unused) */ s32 Environment_ZBufValToFixedPoint(s32 zBufferVal) { - // base[exp] + mantissa << shift[exp] - s32 ret = (ZBUFVAL_MANTISSA(zBufferVal) << sZBufValConversionTable[ZBUFVAL_EXPONENT(zBufferVal)].mantissa) + - sZBufValConversionTable[ZBUFVAL_EXPONENT(zBufferVal)].exponent; + // base[exp] + (mantissa << shift[exp]) + s32 ret = (ZBUFVAL_MANTISSA(zBufferVal) << sZBufValConversionTable[ZBUFVAL_EXPONENT(zBufferVal)].mantissaShift) + + sZBufValConversionTable[ZBUFVAL_EXPONENT(zBufferVal)].base; return ret; } @@ -1377,7 +1378,7 @@ void Environment_DrawSunAndMoon(PlayState* play) { OPEN_DISPS(play->state.gfxCtx, "../z_kankyo.c", 2266); - if (play->csCtx.state != 0) { + if (play->csCtx.state != CS_STATE_IDLE) { Math_SmoothStepToF(&play->envCtx.sunPos.x, -(Math_SinS(((void)0, gSaveContext.dayTime) - CLOCK_TIME(12, 0)) * 120.0f) * 25.0f, 1.0f, 0.8f, 0.8f); diff --git a/src/code/z_lights.c b/src/code/z_lights.c index b230100bce..f01c49df2a 100644 --- a/src/code/z_lights.c +++ b/src/code/z_lights.c @@ -339,11 +339,18 @@ void Lights_GlowCheck(PlayState* play) { wY = multDest.y * cappedInvWDest; if ((multDest.z > 1.0f) && (fabsf(wX) < 1.0f) && (fabsf(wY) < 1.0f)) { - wZ = (s32)((multDest.z * cappedInvWDest) * 16352.0f) + 16352; - zBuf = gZBuffer[(s32)((wY * -120.0f) + 120.0f)][(s32)((wX * 160.0f) + 160.0f)] * 4; + // Compute screen z value assuming the viewport scale and translation both have value G_MAXZ / 2 + // The multiplication by 32 follows from how the RSP microcode computes the screen z value. + wZ = (s32)((multDest.z * cappedInvWDest) * ((G_MAXZ / 2) * 32)) + ((G_MAXZ / 2) * 32); + // Obtain the z-buffer value for the screen pixel corresponding to the center of the glow. + zBuf = gZBuffer[(s32)((wY * -(SCREEN_HEIGHT / 2)) + (SCREEN_HEIGHT / 2))] + [(s32)((wX * (SCREEN_WIDTH / 2)) + (SCREEN_WIDTH / 2))] + << 2; if (1) {} if (1) {} + // Compare the computed screen z value to the integer part of the z-buffer value in fixed point. If + // it is less than the value from the z-buffer the depth test passes and the glow can draw. if (wZ < (Environment_ZBufValToFixedPoint(zBuf) >> 3)) { params->drawGlow = true; } diff --git a/src/code/z_map_mark.c b/src/code/z_map_mark.c index e04d8a9d28..e84cbaaec9 100644 --- a/src/code/z_map_mark.c +++ b/src/code/z_map_mark.c @@ -55,7 +55,7 @@ static MapMarkData** sLoadedMarkDataTable; void MapMark_Init(PlayState* play) { MapMarkDataOverlay* overlay = &sMapMarkDataOvl; - u32 overlaySize = (u32)overlay->vramEnd - (u32)overlay->vramStart; + u32 overlaySize = (uintptr_t)overlay->vramEnd - (uintptr_t)overlay->vramStart; overlay->loadedRamAddr = GameState_Alloc(&play->state, overlaySize, "../z_map_mark.c", 235); LogUtils_CheckNullPointer("dlftbl->allocp", overlay->loadedRamAddr, "../z_map_mark.c", 236); @@ -63,10 +63,11 @@ void MapMark_Init(PlayState* play) { Overlay_Load(overlay->vromStart, overlay->vromEnd, overlay->vramStart, overlay->vramEnd, overlay->loadedRamAddr); sLoadedMarkDataTable = gMapMarkDataTable; - sLoadedMarkDataTable = (void*)(u32)( - (overlay->vramTable != NULL) - ? (void*)((u32)overlay->vramTable - (s32)((u32)overlay->vramStart - (u32)overlay->loadedRamAddr)) - : NULL); + sLoadedMarkDataTable = + (void*)(uintptr_t)((overlay->vramTable != NULL) + ? (void*)((uintptr_t)overlay->vramTable - + (intptr_t)((uintptr_t)overlay->vramStart - (uintptr_t)overlay->loadedRamAddr)) + : NULL); } void MapMark_ClearPointers(PlayState* play) { diff --git a/src/code/z_moji.c b/src/code/z_moji.c index 2709082378..a015492f5c 100644 --- a/src/code/z_moji.c +++ b/src/code/z_moji.c @@ -64,7 +64,7 @@ void Moji_DrawChar(GraphicsContext* gfxCtx, char c) { OPEN_DISPS(gfxCtx, "../z_moji.c", 86); - if ((u32)gMojiFontTLUTs & 0xF) { + if ((uintptr_t)gMojiFontTLUTs & 0xF) { osSyncPrintf("moji_tlut --> %X\n", gMojiFontTLUTs); } @@ -90,14 +90,14 @@ void Moji_DrawString(GraphicsContext* gfxCtx, const char* str) { OPEN_DISPS(gfxCtx, "../z_moji.c", 137); - if ((u32)gMojiFontTex & 0xF) { + if ((uintptr_t)gMojiFontTex & 0xF) { osSyncPrintf("font_ff --> %X\n", gMojiFontTex); } gDPPipeSync(POLY_OPA_DISP++); gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, sFontColorRed, sFontColorGreen, sFontColorBlue, sFontColorAlpha); - gDPLoadTextureBlock_4b(POLY_OPA_DISP++, (s32)gMojiFontTex, G_IM_FMT_CI, TEX_CHAR_COLS * TEX_CHAR_WIDTH, + gDPLoadTextureBlock_4b(POLY_OPA_DISP++, (intptr_t)gMojiFontTex, G_IM_FMT_CI, TEX_CHAR_COLS * TEX_CHAR_WIDTH, TEX_CHAR_ROWS * TEX_CHAR_HEIGHT, 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); diff --git a/src/code/z_play.c b/src/code/z_play.c index c953ae4be3..e254547833 100644 --- a/src/code/z_play.c +++ b/src/code/z_play.c @@ -217,8 +217,8 @@ void Play_Destroy(GameState* thisx) { void Play_Init(GameState* thisx) { PlayState* this = (PlayState*)thisx; GraphicsContext* gfxCtx = this->state.gfxCtx; - u32 zAlloc; - u32 zAllocAligned; + uintptr_t zAlloc; + uintptr_t zAllocAligned; size_t zAllocSize; Player* player; s32 playerStartBgCamIndex; @@ -332,7 +332,7 @@ void Play_Init(GameState* thisx) { gSaveContext.sceneLayer == 6) { osSyncPrintf("エンディングはじまるよー\n"); // "The ending starts" ((void (*)(void))0x81000000)(); - osSyncPrintf("出戻り?\n"); // "Return?" + osSyncPrintf("出戻り?\n"); // "Return?" } Cutscene_HandleEntranceTriggers(this); @@ -396,12 +396,11 @@ void Play_Init(GameState* thisx) { osSyncPrintf("ZELDA ALLOC SIZE=%x\n", THA_GetRemaining(&this->state.tha)); zAllocSize = THA_GetRemaining(&this->state.tha); - zAlloc = (u32)GameState_Alloc(&this->state, zAllocSize, "../z_play.c", 2918); + zAlloc = (uintptr_t)GameState_Alloc(&this->state, zAllocSize, "../z_play.c", 2918); zAllocAligned = (zAlloc + 8) & ~0xF; - ZeldaArena_Init((void*)zAllocAligned, zAllocSize - zAllocAligned + zAlloc); + ZeldaArena_Init((void*)zAllocAligned, zAllocSize - (zAllocAligned - zAlloc)); // "Zelda Heap" - osSyncPrintf("ゼルダヒープ %08x-%08x\n", zAllocAligned, - (s32)(zAllocAligned + zAllocSize) - (s32)(zAllocAligned - zAlloc)); + osSyncPrintf("ゼルダヒープ %08x-%08x\n", zAllocAligned, zAllocAligned + zAllocSize - (s32)(zAllocAligned - zAlloc)); Fault_AddClient(&D_801614B8, ZeldaArena_Display, NULL, NULL); Actor_InitContext(this, &this->actorCtx, this->playerEntry); @@ -1119,168 +1118,171 @@ void Play_Draw(PlayState* this) { TransitionTile_Draw(&sTransitionTile, &sp88); POLY_OPA_DISP = sp88; goto Play_Draw_DrawOverlayElements; - } else { - PreRender_SetValues(&this->pauseBgPreRender, SCREEN_WIDTH, SCREEN_HEIGHT, gfxCtx->curFrameBuffer, gZBuffer); + } - if (R_PAUSE_BG_PRERENDER_STATE == PAUSE_BG_PRERENDER_PROCESS) { - // Wait for the previous frame's display list to be processed, - // so that `pauseBgPreRender.fbufSave` and `pauseBgPreRender.cvgSave` are filled with the appropriate - // content and can be used by `PreRender_ApplyFilters` below. - Sched_FlushTaskQueue(); + PreRender_SetValues(&this->pauseBgPreRender, SCREEN_WIDTH, SCREEN_HEIGHT, gfxCtx->curFrameBuffer, gZBuffer); - PreRender_ApplyFilters(&this->pauseBgPreRender); + if (R_PAUSE_BG_PRERENDER_STATE == PAUSE_BG_PRERENDER_PROCESS) { + // Wait for the previous frame's display list to be processed, + // so that `pauseBgPreRender.fbufSave` and `pauseBgPreRender.cvgSave` are filled with the appropriate + // content and can be used by `PreRender_ApplyFilters` below. + Sched_FlushTaskQueue(); - R_PAUSE_BG_PRERENDER_STATE = PAUSE_BG_PRERENDER_READY; - } else if (R_PAUSE_BG_PRERENDER_STATE >= PAUSE_BG_PRERENDER_MAX) { - R_PAUSE_BG_PRERENDER_STATE = PAUSE_BG_PRERENDER_OFF; - } + PreRender_ApplyFilters(&this->pauseBgPreRender); - if (R_PAUSE_BG_PRERENDER_STATE == PAUSE_BG_PRERENDER_READY) { - Gfx* gfxP = POLY_OPA_DISP; + R_PAUSE_BG_PRERENDER_STATE = PAUSE_BG_PRERENDER_READY; + } else if (R_PAUSE_BG_PRERENDER_STATE >= PAUSE_BG_PRERENDER_MAX) { + R_PAUSE_BG_PRERENDER_STATE = PAUSE_BG_PRERENDER_OFF; + } - PreRender_RestoreFramebuffer(&this->pauseBgPreRender, &gfxP); - POLY_OPA_DISP = gfxP; + if (R_PAUSE_BG_PRERENDER_STATE == PAUSE_BG_PRERENDER_READY) { + Gfx* gfxP = POLY_OPA_DISP; - goto Play_Draw_DrawOverlayElements; - } else { - s32 roomDrawFlags; + PreRender_RestoreFramebuffer(&this->pauseBgPreRender, &gfxP); + POLY_OPA_DISP = gfxP; - if ((R_HREG_MODE != HREG_MODE_PLAY) || R_PLAY_DRAW_SKYBOX) { - if (this->skyboxId && (this->skyboxId != SKYBOX_UNSET_1D) && !this->envCtx.skyboxDisabled) { - if ((this->skyboxId == SKYBOX_NORMAL_SKY) || (this->skyboxId == SKYBOX_CUTSCENE_MAP)) { - Environment_UpdateSkybox(this->skyboxId, &this->envCtx, &this->skyboxCtx); - Skybox_Draw(&this->skyboxCtx, gfxCtx, this->skyboxId, this->envCtx.skyboxBlend, - this->view.eye.x, this->view.eye.y, this->view.eye.z); - } else if (this->skyboxCtx.unk_140 == 0) { - Skybox_Draw(&this->skyboxCtx, gfxCtx, this->skyboxId, 0, this->view.eye.x, this->view.eye.y, - this->view.eye.z); - } - } - } + goto Play_Draw_DrawOverlayElements; + } - if ((R_HREG_MODE != HREG_MODE_PLAY) || (R_PLAY_DRAW_ENV_FLAGS & PLAY_ENV_DRAW_SUN_AND_MOON)) { - if (!this->envCtx.sunMoonDisabled) { - Environment_DrawSunAndMoon(this); - } - } - - if ((R_HREG_MODE != HREG_MODE_PLAY) || (R_PLAY_DRAW_ENV_FLAGS & PLAY_ENV_DRAW_SKYBOX_FILTERS)) { - Environment_DrawSkyboxFilters(this); - } - - if ((R_HREG_MODE != HREG_MODE_PLAY) || (R_PLAY_DRAW_ENV_FLAGS & PLAY_ENV_DRAW_LIGHTNING)) { - Environment_UpdateLightningStrike(this); - Environment_DrawLightning(this, 0); - } - - if ((R_HREG_MODE != HREG_MODE_PLAY) || (R_PLAY_DRAW_ENV_FLAGS & PLAY_ENV_DRAW_LIGHTS)) { - sp228 = LightContext_NewLights(&this->lightCtx, gfxCtx); - Lights_BindAll(sp228, this->lightCtx.listHead, NULL); - Lights_Draw(sp228, gfxCtx); - } - - if ((R_HREG_MODE != HREG_MODE_PLAY) || (R_PLAY_DRAW_ROOM_FLAGS != 0)) { - if (VREG(94) == 0) { - if (R_HREG_MODE != HREG_MODE_PLAY) { - roomDrawFlags = ROOM_DRAW_OPA | ROOM_DRAW_XLU; - } else { - roomDrawFlags = R_PLAY_DRAW_ROOM_FLAGS; - } - Scene_Draw(this); - Room_Draw(this, &this->roomCtx.curRoom, roomDrawFlags & (ROOM_DRAW_OPA | ROOM_DRAW_XLU)); - Room_Draw(this, &this->roomCtx.prevRoom, roomDrawFlags & (ROOM_DRAW_OPA | ROOM_DRAW_XLU)); - } - } - - if ((R_HREG_MODE != HREG_MODE_PLAY) || R_PLAY_DRAW_SKYBOX) { - if ((this->skyboxCtx.unk_140 != 0) && (GET_ACTIVE_CAM(this)->setting != CAM_SET_PREREND_FIXED)) { - Vec3f quakeOffset; - - Camera_GetQuakeOffset(&quakeOffset, GET_ACTIVE_CAM(this)); - Skybox_Draw(&this->skyboxCtx, gfxCtx, this->skyboxId, 0, this->view.eye.x + quakeOffset.x, - this->view.eye.y + quakeOffset.y, this->view.eye.z + quakeOffset.z); - } - } - - if (this->envCtx.precipitation[PRECIP_RAIN_CUR] != 0) { - Environment_DrawRain(this, &this->view, gfxCtx); - } - - if ((R_HREG_MODE != HREG_MODE_PLAY) || (R_PLAY_DRAW_ROOM_FLAGS != 0)) { - Environment_FillScreen(gfxCtx, 0, 0, 0, this->bgCoverAlpha, FILL_SCREEN_OPA); - } - - if ((R_HREG_MODE != HREG_MODE_PLAY) || R_PLAY_DRAW_ACTORS) { - func_800315AC(this, &this->actorCtx); - } - - if ((R_HREG_MODE != HREG_MODE_PLAY) || R_PLAY_DRAW_LENS_FLARES) { - if (!this->envCtx.sunMoonDisabled) { - sp21C.x = this->view.eye.x + this->envCtx.sunPos.x; - sp21C.y = this->view.eye.y + this->envCtx.sunPos.y; - sp21C.z = this->view.eye.z + this->envCtx.sunPos.z; - Environment_DrawSunLensFlare(this, &this->envCtx, &this->view, gfxCtx, sp21C, 0); - } - Environment_DrawCustomLensFlare(this); - } - - if ((R_HREG_MODE != HREG_MODE_PLAY) || R_PLAY_DRAW_SCREEN_FILLS) { - if (MREG(64) != 0) { - Environment_FillScreen(gfxCtx, MREG(65), MREG(66), MREG(67), MREG(68), - FILL_SCREEN_OPA | FILL_SCREEN_XLU); - } - - switch (this->envCtx.fillScreen) { - case 1: - Environment_FillScreen(gfxCtx, this->envCtx.screenFillColor[0], - this->envCtx.screenFillColor[1], this->envCtx.screenFillColor[2], - this->envCtx.screenFillColor[3], FILL_SCREEN_OPA | FILL_SCREEN_XLU); - break; - default: - break; - } - } - - if ((R_HREG_MODE != HREG_MODE_PLAY) || R_PLAY_DRAW_SANDSTORM) { - if (this->envCtx.sandstormState != SANDSTORM_OFF) { - Environment_DrawSandstorm(this, this->envCtx.sandstormState); - } - } - - if ((R_HREG_MODE != HREG_MODE_PLAY) || R_PLAY_DRAW_DEBUG_OBJECTS) { - DebugDisplay_DrawObjects(this); - } - - if ((R_PAUSE_BG_PRERENDER_STATE == PAUSE_BG_PRERENDER_SETUP) || - (gTransitionTileState == TRANS_TILE_SETUP)) { - Gfx* gfxP = OVERLAY_DISP; - - // Copy the frame buffer contents at this point in the display list to the zbuffer - // The zbuffer must then stay untouched until unpausing - this->pauseBgPreRender.fbuf = gfxCtx->curFrameBuffer; - this->pauseBgPreRender.fbufSave = (u16*)gZBuffer; - PreRender_SaveFramebuffer(&this->pauseBgPreRender, &gfxP); - if (R_PAUSE_BG_PRERENDER_STATE == PAUSE_BG_PRERENDER_SETUP) { - this->pauseBgPreRender.cvgSave = (u8*)gfxCtx->curFrameBuffer; - PreRender_DrawCoverage(&this->pauseBgPreRender, &gfxP); - - R_PAUSE_BG_PRERENDER_STATE = PAUSE_BG_PRERENDER_PROCESS; - } else { - gTransitionTileState = TRANS_TILE_PROCESS; - } - OVERLAY_DISP = gfxP; - this->unk_121C7 = 2; - R_GRAPH_TASKSET00_FLAGS |= 1; - } else { - Play_Draw_DrawOverlayElements: - if ((R_HREG_MODE != HREG_MODE_PLAY) || R_PLAY_DRAW_OVERLAY_ELEMENTS) { - Play_DrawOverlayElements(this); - } + if ((R_HREG_MODE != HREG_MODE_PLAY) || R_PLAY_DRAW_SKYBOX) { + if (this->skyboxId && (this->skyboxId != SKYBOX_UNSET_1D) && !this->envCtx.skyboxDisabled) { + if ((this->skyboxId == SKYBOX_NORMAL_SKY) || (this->skyboxId == SKYBOX_CUTSCENE_MAP)) { + Environment_UpdateSkybox(this->skyboxId, &this->envCtx, &this->skyboxCtx); + Skybox_Draw(&this->skyboxCtx, gfxCtx, this->skyboxId, this->envCtx.skyboxBlend, this->view.eye.x, + this->view.eye.y, this->view.eye.z); + } else if (this->skyboxCtx.drawType == SKYBOX_DRAW_128) { + Skybox_Draw(&this->skyboxCtx, gfxCtx, this->skyboxId, 0, this->view.eye.x, this->view.eye.y, + this->view.eye.z); } } } + + if ((R_HREG_MODE != HREG_MODE_PLAY) || (R_PLAY_DRAW_ENV_FLAGS & PLAY_ENV_DRAW_SUN_AND_MOON)) { + if (!this->envCtx.sunMoonDisabled) { + Environment_DrawSunAndMoon(this); + } + } + + if ((R_HREG_MODE != HREG_MODE_PLAY) || (R_PLAY_DRAW_ENV_FLAGS & PLAY_ENV_DRAW_SKYBOX_FILTERS)) { + Environment_DrawSkyboxFilters(this); + } + + if ((R_HREG_MODE != HREG_MODE_PLAY) || (R_PLAY_DRAW_ENV_FLAGS & PLAY_ENV_DRAW_LIGHTNING)) { + Environment_UpdateLightningStrike(this); + Environment_DrawLightning(this, 0); + } + + if ((R_HREG_MODE != HREG_MODE_PLAY) || (R_PLAY_DRAW_ENV_FLAGS & PLAY_ENV_DRAW_LIGHTS)) { + sp228 = LightContext_NewLights(&this->lightCtx, gfxCtx); + Lights_BindAll(sp228, this->lightCtx.listHead, NULL); + Lights_Draw(sp228, gfxCtx); + } + + if ((R_HREG_MODE != HREG_MODE_PLAY) || (R_PLAY_DRAW_ROOM_FLAGS != 0)) { + if (VREG(94) == 0) { + s32 roomDrawFlags; + + if (R_HREG_MODE != HREG_MODE_PLAY) { + roomDrawFlags = ROOM_DRAW_OPA | ROOM_DRAW_XLU; + } else { + roomDrawFlags = R_PLAY_DRAW_ROOM_FLAGS; + } + Scene_Draw(this); + Room_Draw(this, &this->roomCtx.curRoom, roomDrawFlags & (ROOM_DRAW_OPA | ROOM_DRAW_XLU)); + Room_Draw(this, &this->roomCtx.prevRoom, roomDrawFlags & (ROOM_DRAW_OPA | ROOM_DRAW_XLU)); + } + } + + if ((R_HREG_MODE != HREG_MODE_PLAY) || R_PLAY_DRAW_SKYBOX) { + if ((this->skyboxCtx.drawType != SKYBOX_DRAW_128) && + (GET_ACTIVE_CAM(this)->setting != CAM_SET_PREREND_FIXED)) { + Vec3f quakeOffset; + + Camera_GetQuakeOffset(&quakeOffset, GET_ACTIVE_CAM(this)); + Skybox_Draw(&this->skyboxCtx, gfxCtx, this->skyboxId, 0, this->view.eye.x + quakeOffset.x, + this->view.eye.y + quakeOffset.y, this->view.eye.z + quakeOffset.z); + } + } + + if (this->envCtx.precipitation[PRECIP_RAIN_CUR] != 0) { + Environment_DrawRain(this, &this->view, gfxCtx); + } + + if ((R_HREG_MODE != HREG_MODE_PLAY) || (R_PLAY_DRAW_ROOM_FLAGS != 0)) { + Environment_FillScreen(gfxCtx, 0, 0, 0, this->bgCoverAlpha, FILL_SCREEN_OPA); + } + + if ((R_HREG_MODE != HREG_MODE_PLAY) || R_PLAY_DRAW_ACTORS) { + func_800315AC(this, &this->actorCtx); + } + + if ((R_HREG_MODE != HREG_MODE_PLAY) || R_PLAY_DRAW_LENS_FLARES) { + if (!this->envCtx.sunMoonDisabled) { + sp21C.x = this->view.eye.x + this->envCtx.sunPos.x; + sp21C.y = this->view.eye.y + this->envCtx.sunPos.y; + sp21C.z = this->view.eye.z + this->envCtx.sunPos.z; + Environment_DrawSunLensFlare(this, &this->envCtx, &this->view, gfxCtx, sp21C, 0); + } + Environment_DrawCustomLensFlare(this); + } + + if ((R_HREG_MODE != HREG_MODE_PLAY) || R_PLAY_DRAW_SCREEN_FILLS) { + if (MREG(64) != 0) { + Environment_FillScreen(gfxCtx, MREG(65), MREG(66), MREG(67), MREG(68), + FILL_SCREEN_OPA | FILL_SCREEN_XLU); + } + + switch (this->envCtx.fillScreen) { + case 1: + Environment_FillScreen(gfxCtx, this->envCtx.screenFillColor[0], this->envCtx.screenFillColor[1], + this->envCtx.screenFillColor[2], this->envCtx.screenFillColor[3], + FILL_SCREEN_OPA | FILL_SCREEN_XLU); + break; + default: + break; + } + } + + if ((R_HREG_MODE != HREG_MODE_PLAY) || R_PLAY_DRAW_SANDSTORM) { + if (this->envCtx.sandstormState != SANDSTORM_OFF) { + Environment_DrawSandstorm(this, this->envCtx.sandstormState); + } + } + + if ((R_HREG_MODE != HREG_MODE_PLAY) || R_PLAY_DRAW_DEBUG_OBJECTS) { + DebugDisplay_DrawObjects(this); + } + + if ((R_PAUSE_BG_PRERENDER_STATE == PAUSE_BG_PRERENDER_SETUP) || (gTransitionTileState == TRANS_TILE_SETUP)) { + Gfx* gfxP = OVERLAY_DISP; + + // Copy the frame buffer contents at this point in the display list to the zbuffer + // The zbuffer must then stay untouched until unpausing + this->pauseBgPreRender.fbuf = gfxCtx->curFrameBuffer; + this->pauseBgPreRender.fbufSave = (u16*)gZBuffer; + PreRender_SaveFramebuffer(&this->pauseBgPreRender, &gfxP); + if (R_PAUSE_BG_PRERENDER_STATE == PAUSE_BG_PRERENDER_SETUP) { + this->pauseBgPreRender.cvgSave = (u8*)gfxCtx->curFrameBuffer; + PreRender_DrawCoverage(&this->pauseBgPreRender, &gfxP); + + R_PAUSE_BG_PRERENDER_STATE = PAUSE_BG_PRERENDER_PROCESS; + } else { + gTransitionTileState = TRANS_TILE_PROCESS; + } + OVERLAY_DISP = gfxP; + this->unk_121C7 = 2; + R_GRAPH_TASKSET00_FLAGS |= 1; + goto Play_Draw_skip; + } + + Play_Draw_DrawOverlayElements: + if ((R_HREG_MODE != HREG_MODE_PLAY) || R_PLAY_DRAW_OVERLAY_ELEMENTS) { + Play_DrawOverlayElements(this); + } } +Play_Draw_skip: + if (this->view.unk_124 != 0) { Camera_Update(GET_ACTIVE_CAM(this)); View_UpdateViewingMatrix(&this->view); diff --git a/src/code/z_player_lib.c b/src/code/z_player_lib.c index 1bf76a9bb9..b2936ccff8 100644 --- a/src/code/z_player_lib.c +++ b/src/code/z_player_lib.c @@ -1650,7 +1650,7 @@ u32 Player_InitDrawPause(PlayState* play, u8* segment, SkelAnime* skelAnime) { ptr = segment + PAUSE_EQUIP_BUFFER_SIZE + PAUSE_PLAYER_SEGMENT_GAMEPLAY_KEEP_BUFFER_SIZE; DmaMgr_RequestSyncDebug(ptr, gObjectTable[linkObjectId].vromStart, size, "../z_player_lib.c", 2988); - ptr = (void*)ALIGN16((u32)ptr + size); + ptr = (void*)ALIGN16((uintptr_t)ptr + size); gSegments[4] = VIRTUAL_TO_PHYSICAL(segment + PAUSE_EQUIP_BUFFER_SIZE); gSegments[6] = diff --git a/src/code/z_room.c b/src/code/z_room.c index d636080b19..25850aa196 100644 --- a/src/code/z_room.c +++ b/src/code/z_room.c @@ -295,7 +295,7 @@ void Room_DrawBackground2D(Gfx** gfxP, void* tex, void* tlut, u16 width, u16 hei Room_DecodeJpeg(SEGMENTED_TO_VIRTUAL(tex)); bg = (uObjBg*)(gfx + 1); - gSPBranchList(gfx, (u32)bg + sizeof(uObjBg)); + gSPBranchList(gfx, (Gfx*)(bg + 1)); bg->b.imageX = 0; bg->b.imageW = width * (1 << 2); @@ -310,7 +310,7 @@ void Room_DrawBackground2D(Gfx** gfxP, void* tex, void* tlut, u16 width, u16 hei bg->b.imagePal = 0; bg->b.imageFlip = 0; - gfx = (Gfx*)((u32)bg + sizeof(uObjBg)); + gfx = (Gfx*)(bg + 1); if (fmt == G_IM_FMT_CI) { gDPLoadTLUT(gfx++, tlutCount, 256, tlut); @@ -574,7 +574,7 @@ u32 func_80096FE8(PlayState* play, RoomContext* roomCtx) { roomCtx->bufPtrs[0] = GameState_Alloc(&play->state, maxRoomSize, "../z_room.c", 946); // "Room buffer initial pointer=%08x" osSyncPrintf("部屋バッファ開始ポインタ=%08x\n", roomCtx->bufPtrs[0]); - roomCtx->bufPtrs[1] = (void*)((s32)roomCtx->bufPtrs[0] + maxRoomSize); + roomCtx->bufPtrs[1] = (void*)((uintptr_t)roomCtx->bufPtrs[0] + maxRoomSize); // "Room buffer end pointer=%08x" osSyncPrintf("部屋バッファ終了ポインタ=%08x\n", roomCtx->bufPtrs[1]); osSyncPrintf(VT_RST); @@ -600,7 +600,8 @@ s32 func_8009728C(PlayState* play, RoomContext* roomCtx, s32 roomNum) { ASSERT(roomNum < play->numRooms, "read_room_ID < game_play->room_rom_address.num", "../z_room.c", 1009); size = play->roomList[roomNum].vromEnd - play->roomList[roomNum].vromStart; - roomCtx->unk_34 = (void*)ALIGN16((u32)roomCtx->bufPtrs[roomCtx->unk_30] - ((size + 8) * roomCtx->unk_30 + 7)); + roomCtx->unk_34 = + (void*)ALIGN16((uintptr_t)roomCtx->bufPtrs[roomCtx->unk_30] - ((size + 8) * roomCtx->unk_30 + 7)); osCreateMesgQueue(&roomCtx->loadQueue, &roomCtx->loadMsg, 1); DmaMgr_RequestAsync(&roomCtx->dmaRequest, roomCtx->unk_34, play->roomList[roomNum].vromStart, size, 0, diff --git a/src/code/z_scene.c b/src/code/z_scene.c index 4c484945ee..8e36528691 100644 --- a/src/code/z_scene.c +++ b/src/code/z_scene.c @@ -11,11 +11,11 @@ s32 Object_Spawn(ObjectContext* objectCtx, s16 objectId) { osSyncPrintf("OBJECT[%d] SIZE %fK SEG=%x\n", objectId, size / 1024.0f, objectCtx->status[objectCtx->num].segment); - osSyncPrintf("num=%d adrs=%x end=%x\n", objectCtx->num, (s32)objectCtx->status[objectCtx->num].segment + size, + osSyncPrintf("num=%d adrs=%x end=%x\n", objectCtx->num, (uintptr_t)objectCtx->status[objectCtx->num].segment + size, objectCtx->spaceEnd); ASSERT(((objectCtx->num < OBJECT_EXCHANGE_BANK_MAX) && - (((s32)objectCtx->status[objectCtx->num].segment + size) < (u32)objectCtx->spaceEnd)), + (((uintptr_t)objectCtx->status[objectCtx->num].segment + size) < (uintptr_t)objectCtx->spaceEnd)), "this->num < OBJECT_EXCHANGE_BANK_MAX && (this->status[this->num].Segment + size) < this->endSegment", "../z_scene.c", 142); @@ -24,7 +24,7 @@ s32 Object_Spawn(ObjectContext* objectCtx, s16 objectId) { if (objectCtx->num < OBJECT_EXCHANGE_BANK_MAX - 1) { objectCtx->status[objectCtx->num + 1].segment = - (void*)ALIGN16((s32)objectCtx->status[objectCtx->num].segment + size); + (void*)ALIGN16((uintptr_t)objectCtx->status[objectCtx->num].segment + size); } objectCtx->num++; @@ -70,7 +70,7 @@ void Object_InitBank(PlayState* play, ObjectContext* objectCtx) { objectCtx->spaceStart = objectCtx->status[0].segment = GameState_Alloc(&play->state, spaceSize, "../z_scene.c", 219); - objectCtx->spaceEnd = (void*)((s32)objectCtx->spaceStart + spaceSize); + objectCtx->spaceEnd = (void*)((uintptr_t)objectCtx->spaceStart + spaceSize); objectCtx->mainKeepIndex = Object_Spawn(objectCtx, OBJECT_GAMEPLAY_KEEP); gSegments[4] = VIRTUAL_TO_PHYSICAL(objectCtx->status[objectCtx->mainKeepIndex].segment); @@ -129,7 +129,7 @@ void func_800981B8(ObjectContext* objectCtx) { size = gObjectTable[id].vromEnd - gObjectTable[id].vromStart; osSyncPrintf("OBJECT[%d] SIZE %fK SEG=%x\n", objectCtx->status[i].id, size / 1024.0f, objectCtx->status[i].segment); - osSyncPrintf("num=%d adrs=%x end=%x\n", objectCtx->num, (s32)objectCtx->status[i].segment + size, + osSyncPrintf("num=%d adrs=%x end=%x\n", objectCtx->num, (uintptr_t)objectCtx->status[i].segment + size, objectCtx->spaceEnd); DmaMgr_RequestSyncDebug(objectCtx->status[i].segment, gObjectTable[id].vromStart, size, "../z_scene.c", 342); } @@ -147,12 +147,12 @@ void* func_800982FC(ObjectContext* objectCtx, s32 bankIndex, s16 objectId) { size = objectFile->vromEnd - objectFile->vromStart; osSyncPrintf("OBJECT EXCHANGE NO=%2d BANK=%3d SIZE=%8.3fK\n", bankIndex, objectId, size / 1024.0f); - nextPtr = (void*)ALIGN16((s32)status->segment + size); + nextPtr = (void*)ALIGN16((uintptr_t)status->segment + size); ASSERT(nextPtr < objectCtx->spaceEnd, "nextptr < this->endSegment", "../z_scene.c", 381); // "Object exchange free size=%08x" - osSyncPrintf("オブジェクト入れ替え空きサイズ=%08x\n", (s32)objectCtx->spaceEnd - (s32)nextPtr); + osSyncPrintf("オブジェクト入れ替え空きサイズ=%08x\n", (uintptr_t)objectCtx->spaceEnd - (uintptr_t)nextPtr); return nextPtr; } diff --git a/src/code/z_skelanime.c b/src/code/z_skelanime.c index 6be89bafeb..bc8a9f392e 100644 --- a/src/code/z_skelanime.c +++ b/src/code/z_skelanime.c @@ -1073,8 +1073,8 @@ void SkelAnime_InitLink(PlayState* play, SkelAnime* skelAnime, FlexSkeletonHeade } else { ASSERT(limbBufCount == limbCount, "joint_buff_num == joint_num", "../z_skelanime.c", 2369); - skelAnime->jointTable = (Vec3s*)ALIGN16((u32)jointTable); - skelAnime->morphTable = (Vec3s*)ALIGN16((u32)morphTable); + skelAnime->jointTable = (Vec3s*)ALIGN16((uintptr_t)jointTable); + skelAnime->morphTable = (Vec3s*)ALIGN16((uintptr_t)morphTable); } if ((skelAnime->jointTable == NULL) || (skelAnime->morphTable == NULL)) { @@ -1307,7 +1307,7 @@ void LinkAnimation_BlendToJoint(PlayState* play, SkelAnime* skelAnime, LinkAnima AnimationContext_SetLoadFrame(play, animation1, (s32)frame1, skelAnime->limbCount, skelAnime->jointTable); - alignedBlendTable = (Vec3s*)ALIGN16((u32)blendTable); + alignedBlendTable = (Vec3s*)ALIGN16((uintptr_t)blendTable); AnimationContext_SetLoadFrame(play, animation2, (s32)frame2, skelAnime->limbCount, alignedBlendTable); AnimationContext_SetInterp(play, skelAnime->limbCount, skelAnime->jointTable, alignedBlendTable, blendWeight); @@ -1322,7 +1322,7 @@ void LinkAnimation_BlendToMorph(PlayState* play, SkelAnime* skelAnime, LinkAnima AnimationContext_SetLoadFrame(play, animation1, (s32)frame1, skelAnime->limbCount, skelAnime->morphTable); - alignedBlendTable = (Vec3s*)ALIGN16((u32)blendTable); + alignedBlendTable = (Vec3s*)ALIGN16((uintptr_t)blendTable); AnimationContext_SetLoadFrame(play, animation2, (s32)frame2, skelAnime->limbCount, alignedBlendTable); AnimationContext_SetInterp(play, skelAnime->limbCount, skelAnime->morphTable, alignedBlendTable, blendWeight); diff --git a/src/code/z_vr_box.c b/src/code/z_vr_box.c index 56cd74cb38..221038ea01 100644 --- a/src/code/z_vr_box.c +++ b/src/code/z_vr_box.c @@ -2,371 +2,452 @@ #include "terminal.h" #include "z64environment.h" -u32 D_8012AC90[4] = { - 0x00000000, - 0x00010000, - 0x00020000, - 0x00030000, -}; - -u16 D_8012ACA0[2][0x20] = { - { 0x00, 0x02, 0x0A, 0x0C, 0x02, 0x04, 0x0C, 0x0E, 0x0A, 0x0C, 0x14, 0x16, 0x0C, 0x0E, 0x16, 0x18, - 0x01, 0x03, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0B, 0x0D, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x15, 0x17 }, - { 0x14, 0x16, 0x1E, 0x20, 0x16, 0x18, 0x20, 0x22, 0x1E, 0x20, 0x28, 0x2A, 0x20, 0x22, 0x2A, 0x2C, - 0x15, 0x17, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1F, 0x21, 0x23, 0x24, 0x25, 0x26, 0x27, 0x29, 0x2B }, -}; - -s16 D_8012AD20[5] = { - 0x0000, 0x0FC0, 0x1F80, 0x2F40, 0x3F00, -}; - -s16 D_8012AD2C[9] = { - 0x0000, 0x07C0, 0x0F80, 0x1740, 0x1F00, 0x26C0, 0x2E80, 0x3640, 0x3E00, -}; - -s16 D_8012AD40[0x40] = { - 0x00, 0x10, 0x13, 0x12, 0x10, 0x01, 0x14, 0x13, 0x01, 0x11, 0x15, 0x14, 0x11, 0x05, 0x16, 0x15, - 0x12, 0x13, 0x17, 0x02, 0x13, 0x14, 0x03, 0x17, 0x14, 0x15, 0x18, 0x03, 0x15, 0x16, 0x07, 0x18, - 0x02, 0x17, 0x1A, 0x19, 0x17, 0x03, 0x1B, 0x1A, 0x03, 0x18, 0x1C, 0x1B, 0x18, 0x07, 0x1D, 0x1C, - 0x19, 0x1A, 0x1E, 0x0A, 0x1A, 0x1B, 0x0B, 0x1E, 0x1B, 0x1C, 0x1F, 0x0B, 0x1C, 0x1D, 0x0F, 0x1F, -}; - -u32 D_8012ADC0[6] = { - 0x00000000, 0x00002000, 0x00004000, 0x00006000, 0x00008000, 0x0000C000, -}; - -u16 D_8012ADD8[0x20] = { - 0x00, 0x02, 0x0A, 0x0C, 0x02, 0x04, 0x0C, 0x0E, 0x0A, 0x0C, 0x14, 0x16, 0x0C, 0x0E, 0x16, 0x18, - 0x01, 0x03, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0B, 0x0D, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x15, 0x17, -}; - -s16 D_8012AE18[5] = { - 0x0000, 0x07C0, 0x0F80, 0x1740, 0x1F00, -}; - -s16 D_8012AE24[5] = { - 0x0000, 0x07C0, 0x0F80, 0x1740, 0x1F00, -}; - -s16 D_8012AE30[5] = { - 0x0000, 0x07C0, 0x0F80, 0x07C0, 0x0000, -}; - -s16 D_8012AE3C[0x40] = { - 0x00, 0x10, 0x13, 0x12, 0x10, 0x01, 0x14, 0x13, 0x01, 0x11, 0x15, 0x14, 0x11, 0x05, 0x16, 0x15, - 0x12, 0x13, 0x17, 0x02, 0x13, 0x14, 0x03, 0x17, 0x14, 0x15, 0x18, 0x03, 0x15, 0x16, 0x07, 0x18, - 0x02, 0x17, 0x1A, 0x19, 0x17, 0x03, 0x1B, 0x1A, 0x03, 0x18, 0x1C, 0x1B, 0x18, 0x07, 0x1D, 0x1C, - 0x19, 0x1A, 0x1E, 0x0A, 0x1A, 0x1B, 0x0B, 0x1E, 0x1B, 0x1C, 0x1F, 0x0B, 0x1C, 0x1D, 0x0F, 0x1F, -}; - typedef struct { - /* 0x000 */ s32 unk_0; - /* 0x004 */ s32 unk_4; - /* 0x008 */ s32 unk_8; - /* 0x00C */ s32 unk_C; - /* 0x010 */ s32 unk_10; -} Struct_8012AF0C; // size = 0x14 + /* 0x000 */ s32 xStart; + /* 0x004 */ s32 yStart; + /* 0x008 */ s32 zStart; + /* 0x00C */ s32 outerIncrVal; + /* 0x010 */ s32 innerIncrVal; +} SkyboxFaceParams; // size = 0x14 -Struct_8012AF0C D_8012AEBC[4] = { - { -0x7E, 0x7C, -0x7E, 0x3F, -0x1F }, - { 0x7E, 0x7C, -0x7E, 0x3F, -0x1F }, - { 0x7E, 0x7C, 0x7E, -0x3F, -0x1F }, - { -0x7E, 0x7C, 0x7E, -0x3F, -0x1F }, +// Converts texture coordinate values to s10.5 fixed point +#define TC(x) ((s16)((x)*32)) + +// Texture offsets for each face in the static segment buffer +u32 sSkybox256TexOffsets[4] = { + 256 * 256 * 0, + 256 * 256 * 1, + 256 * 256 * 2, + 256 * 256 * 3, }; -Struct_8012AF0C D_8012AF0C[6] = { - { -0x40, 0x40, -0x40, 0x20, -0x20 }, { 0x40, 0x40, 0x40, -0x20, -0x20 }, { -0x40, 0x40, 0x40, -0x20, -0x20 }, - { 0x40, 0x40, -0x40, 0x20, -0x20 }, { -0x40, 0x40, 0x40, 0x20, -0x20 }, { -0x40, -0x40, -0x40, 0x20, 0x20 }, +// Maps vertex buffer index to coordinate buffer index +u16 sSkybox256VtxBufIndices[2][32] = { + { + 0, 2, 10, 12, 2, 4, 12, 14, 10, 12, 20, 22, 12, 14, 22, 24, + 1, 3, 5, 6, 7, 8, 9, 11, 13, 15, 16, 17, 18, 19, 21, 23, + }, + { + 20, 22, 30, 32, 22, 24, 32, 34, 30, 32, 40, 42, 32, 34, 42, 44, + 21, 23, 25, 26, 27, 28, 29, 31, 33, 35, 36, 37, 38, 39, 41, 43, + }, }; -s32 func_800ADBB0(SkyboxContext* skyboxCtx, Vtx* roomVtx, s32 arg2, s32 arg3, s32 arg4, s32 arg5, s32 arg6, s32 arg7, - s32 arg8, s32 arg9) { - u32 pad42C; - s32 pad428; - s32 sp424; +// S coordinates for all faces +s16 sSkybox256TexSCoords[5] = { + TC(126 * 0), TC(126 * 1), TC(126 * 2), TC(126 * 3), TC(126 * 4), +}; + +// T coordinates for all faces +s16 sSkybox256TexTCoords[9] = { + TC(62 * 0), TC(62 * 1), TC(62 * 2), TC(62 * 3), TC(62 * 4), TC(62 * 5), TC(62 * 6), TC(62 * 7), TC(62 * 8), +}; + +// Maps vertex index to vertex buffer index +s16 sSkybox256VtxIndices[64] = { + 0, 16, 19, 18, 16, 1, 20, 19, 1, 17, 21, 20, 17, 5, 22, 21, 18, 19, 23, 2, 19, 20, + 3, 23, 20, 21, 24, 3, 21, 22, 7, 24, 2, 23, 26, 25, 23, 3, 27, 26, 3, 24, 28, 27, + 24, 7, 29, 28, 25, 26, 30, 10, 26, 27, 11, 30, 27, 28, 31, 11, 28, 29, 15, 31, +}; + +/** + * Build the vertex and display list data for a skybox with 256x256 face textures. + * + * While the textures are nominally 256x256 the 4x8 tiles that cover it are only 63x31, therefore only a + * 253x249 area is ever sampled (253 = 4 * 63 + 1, the additional +1 accounts for bilinear filtering, + * similarly 249 = 8 * 31 + 1) + * + * Each texture dimension is padded to the next power of 2, resulting in a final size of 256x256. + */ +s32 Skybox_CalculateFace256(SkyboxContext* skyboxCtx, Vtx* roomVtx, s32 roomVtxStartIndex, s32 xStart, s32 yStart, + s32 zStart, s32 innerIncrVal, s32 outerIncrVal, s32 faceNum, s32 dlistBufStartIndex) { + u32 innerIncr; + s32 outerIncr; + s32 n; s32 i; s32 j; s32 k; u16 index; - s16 phi_t1; - s16 phi_a2_4; - s16 phi_a0_4; - s16 phi_t2_4; - s16 phi_ra; - s32 sp358[9 * 5]; - s32 sp2A4[9 * 5]; - s32 sp1F0[9 * 5]; - s32 sp13C[9 * 5]; - s32 sp88[9 * 5]; + s16 m; + s16 ult; + s16 uls; + s16 vtxIdx; + s16 l; + s32 xPoints[9 * 5]; + s32 yPoints[9 * 5]; + s32 zPoints[9 * 5]; + s32 tcS[9 * 5]; + s32 tcT[9 * 5]; s32 pad; - switch (arg8) { - case 0: + // Collect all vertex positions for this face + switch (faceNum) { + case 0: // xy plane case 2: - pad428 = arg4; + outerIncr = yStart; + + for (i = 0, k = 0; k < 9 * 5; i++) { + innerIncr = xStart; - for (i = 0, k = 0; k < 45; i++) { - pad42C = arg3; for (j = 0; j < 5; j++, k++) { - sp1F0[k] = arg5; - sp358[k] = pad42C; - sp2A4[k] = pad428; - sp13C[k] = D_8012AD20[j]; - sp88[k] = D_8012AD2C[i]; - pad42C += arg6; + zPoints[k] = zStart; + xPoints[k] = innerIncr; + yPoints[k] = outerIncr; + tcS[k] = sSkybox256TexSCoords[j]; + tcT[k] = sSkybox256TexTCoords[i]; + innerIncr += innerIncrVal; } - pad428 += arg7; + outerIncr += outerIncrVal; } break; - case 1: + case 1: // yz plane case 3: - pad428 = arg4; + outerIncr = yStart; + + for (i = 0, k = 0; k < 9 * 5; i++) { + innerIncr = zStart; - for (i = 0, k = 0; k < 45; i++) { - pad42C = arg5; for (j = 0; j < 5; j++, k++) { - sp358[k] = arg3; - sp2A4[k] = pad428; - sp1F0[k] = pad42C; - sp13C[k] = D_8012AD20[j]; - sp88[k] = D_8012AD2C[i]; - pad42C += arg6; + xPoints[k] = xStart; + yPoints[k] = outerIncr; + zPoints[k] = innerIncr; + tcS[k] = sSkybox256TexSCoords[j]; + tcT[k] = sSkybox256TexTCoords[i]; + innerIncr += innerIncrVal; } - pad428 += arg7; + outerIncr += outerIncrVal; } break; - case 4: + case 4: // xz plane case 5: - pad428 = arg5; + outerIncr = zStart; + + for (i = 0, k = 0; k < 9 * 5; i++) { + innerIncr = xStart; - for (i = 0, k = 0; k < 45; i++) { - pad42C = arg3; for (j = 0; j < 5; j++, k++) { - sp2A4[k] = arg4; - sp358[k] = pad42C; - sp1F0[k] = pad428; - sp13C[k] = D_8012AD20[j]; - sp88[k] = D_8012AD2C[i]; - pad42C += arg6; + yPoints[k] = yStart; + xPoints[k] = innerIncr; + zPoints[k] = outerIncr; + tcS[k] = sSkybox256TexSCoords[j]; + tcT[k] = sSkybox256TexTCoords[i]; + innerIncr += innerIncrVal; } - pad428 += arg7; + outerIncr += outerIncrVal; } break; } - for (phi_a2_4 = 0, sp424 = 0; sp424 < 2; sp424++) { - skyboxCtx->unk_138 = skyboxCtx->dListBuf[arg9 + sp424]; + // For a 256x256 texture with 63x31 tiles there are 32 tiles which requires at least 45 vertices, + // 45 > 32 (the maximum number of vertices that can be loaded at once) so it is split into two passes + for (ult = 0, n = 0; n < 2; n++) { + // Each iteration is 16 tiles of the texture, first iteration is the top 16 tiles - for (i = 0; i < 0x20; i++) { - index = D_8012ACA0[sp424][i]; + // Select gfx buffer + skyboxCtx->gfx = skyboxCtx->dListBuf[dlistBufStartIndex + n]; - roomVtx[arg2 + i].v.ob[0] = sp358[index]; - roomVtx[arg2 + i].v.ob[1] = sp2A4[index]; - roomVtx[arg2 + i].v.ob[2] = sp1F0[index]; - roomVtx[arg2 + i].v.flag = 0; - roomVtx[arg2 + i].v.tc[0] = sp13C[index]; - roomVtx[arg2 + i].v.tc[1] = sp88[index]; - roomVtx[arg2 + i].v.cn[1] = 0; - roomVtx[arg2 + i].v.cn[2] = 0; - roomVtx[arg2 + i].v.cn[0] = 255; + // Generate and load Vertex structures + for (i = 0; i < 32; i++) { + index = sSkybox256VtxBufIndices[n][i]; + + roomVtx[roomVtxStartIndex + i].v.ob[0] = xPoints[index]; + roomVtx[roomVtxStartIndex + i].v.ob[1] = yPoints[index]; + roomVtx[roomVtxStartIndex + i].v.ob[2] = zPoints[index]; + roomVtx[roomVtxStartIndex + i].v.flag = 0; + roomVtx[roomVtxStartIndex + i].v.tc[0] = tcS[index]; + roomVtx[roomVtxStartIndex + i].v.tc[1] = tcT[index]; + roomVtx[roomVtxStartIndex + i].v.cn[1] = 0; + roomVtx[roomVtxStartIndex + i].v.cn[2] = 0; + roomVtx[roomVtxStartIndex + i].v.cn[0] = 255; } - gSPVertex(skyboxCtx->unk_138++, &roomVtx[arg2], 32, 0); - arg2 += i; - gSPCullDisplayList(skyboxCtx->unk_138++, 0, 15); + gSPVertex(skyboxCtx->gfx++, &roomVtx[roomVtxStartIndex], 32, 0); + roomVtxStartIndex += i; // += 32 - for (phi_t2_4 = 0, phi_ra = 0; phi_ra < 4; phi_ra++, phi_a2_4 += 0x1F) { - for (phi_a0_4 = 0, phi_t1 = 0; phi_t1 < 4; phi_t1++, phi_a0_4 += 0x3F, phi_t2_4 += 4) { - gDPLoadTextureTile(skyboxCtx->unk_138++, (u32)skyboxCtx->staticSegments[0] + D_8012AC90[arg8], - G_IM_FMT_CI, G_IM_SIZ_8b, 256, 0, phi_a0_4, phi_a2_4, phi_a0_4 + 0x3F, - phi_a2_4 + 0x1F, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD, - G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD); - gSP1Quadrangle(skyboxCtx->unk_138++, D_8012AD40[phi_t2_4 + 1], D_8012AD40[phi_t2_4 + 2], - D_8012AD40[phi_t2_4 + 3], D_8012AD40[phi_t2_4 + 0], 3); + // Cull the face if not within the viewing volume + gSPCullDisplayList(skyboxCtx->gfx++, 0, 15); + + // Draw face, load the texture in several tiles to work around TMEM size limitations + for (vtxIdx = 0, l = 0; l < 4; l++, ult += 31) { + for (uls = 0, m = 0; m < 4; m++, uls += 63, vtxIdx += 4) { + gDPLoadTextureTile(skyboxCtx->gfx++, (u8*)skyboxCtx->staticSegments[0] + sSkybox256TexOffsets[faceNum], + G_IM_FMT_CI, G_IM_SIZ_8b, 256, 0, uls, ult, uls + 63, ult + 31, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, + G_TX_NOMASK, G_TX_NOLOD); + gSP1Quadrangle(skyboxCtx->gfx++, sSkybox256VtxIndices[vtxIdx + 1], sSkybox256VtxIndices[vtxIdx + 2], + sSkybox256VtxIndices[vtxIdx + 3], sSkybox256VtxIndices[vtxIdx + 0], 3); } } - gSPEndDisplayList(skyboxCtx->unk_138++); + gSPEndDisplayList(skyboxCtx->gfx++); } - return arg2; + return roomVtxStartIndex; } -s32 func_800AE2C0(SkyboxContext* skyboxCtx, Vtx* roomVtx, s32 arg2, s32 arg3, s32 arg4, s32 arg5, s32 arg6, s32 arg7, - s32 arg8) { +// Texture offsets for each face in the static segment buffer +u32 sSkybox128TexOffsets[6] = { + 128 * 64 * 0, 128 * 64 * 1, 128 * 64 * 2, 128 * 64 * 3, 128 * 64 * 4, 128 * 64 * 4 + 128 * 128, +}; + +// Maps vertex buffer index to coordinate buffer index +u16 sSkybox128VtxBufIndices[32] = { + 0, 2, 10, 12, 2, 4, 12, 14, 10, 12, 20, 22, 12, 14, 22, 24, 1, 3, 5, 6, 7, 8, 9, 11, 13, 15, 16, 17, 18, 19, 21, 23, +}; + +// S coordinates for all faces +s16 sSkybox128TexSCoords[5] = { + TC(62 * 0), TC(62 * 1), TC(62 * 2), TC(62 * 3), TC(62 * 4), +}; + +// T coordinates for top and bottom faces +s16 sSkybox128TexTCoordsXZ[5] = { + TC(62 * 0), TC(62 * 1), TC(62 * 2), TC(62 * 3), TC(62 * 4), +}; + +// T coordinates for side faces +s16 sSkybox128TexTCoords[5] = { + TC(62 * 0), TC(62 * 1), TC(62 * 2), TC(62 * 1), TC(62 * 0), +}; + +// Maps vertex index to vertex buffer index +s16 sSkybox128VtxIndices[64] = { + 0, 16, 19, 18, 16, 1, 20, 19, 1, 17, 21, 20, 17, 5, 22, 21, 18, 19, 23, 2, 19, 20, + 3, 23, 20, 21, 24, 3, 21, 22, 7, 24, 2, 23, 26, 25, 23, 3, 27, 26, 3, 24, 28, 27, + 24, 7, 29, 28, 25, 26, 30, 10, 26, 27, 11, 30, 27, 28, 31, 11, 28, 29, 15, 31, +}; + +/** + * Build the vertex and display list data for a skybox with 128x128 and 128x64 face textures. + * + * While the textures are nominally 128x128 (128x64) the 4x4 (4x2) tiles that cover it are only 31x31, + * therefore only a 125x125 (125x63) area is ever sampled (see `Skybox_CalculateFace256` for more details) + * + * Each texture dimension is padded to the next power of 2, resulting in a final size of 128x128 (128x64) + */ +s32 Skybox_CalculateFace128(SkyboxContext* skyboxCtx, Vtx* roomVtx, s32 roomVtxStartIndex, s32 xStart, s32 yStart, + s32 zStart, s32 innerIncrVal, s32 outerIncrVal, s32 faceNum) { s32 i; s32 j; s32 k; - s16 phi_a0_4; - s16 phi_t1; - s32 temp1; + s16 uls; + s16 m; + s32 outerIncr; u16 index; - s16 phi_a2_4; - s16 phi_ra; - s16 phi_t2_4; - s32 temp2; - s32 sp2B4[5 * 5]; - s32 sp250[5 * 5]; - s32 sp1EC[5 * 5]; - s32 sp188[5 * 5]; - s32 sp124[5 * 5]; + s16 ult; + s16 l; + s16 vtxIdx; + s32 innerIncr; + s32 xPoints[5 * 5]; + s32 yPoints[5 * 5]; + s32 zPoints[5 * 5]; + s32 tcS[5 * 5]; + s32 tcT[5 * 5]; s32 pad; - switch (arg8) { - case 0: + // Collect all vertex positions for this face + switch (faceNum) { + case 0: // xy plane case 1: - temp1 = arg4; + outerIncr = yStart; for (i = 0, k = 0; k < 25; i++) { - temp2 = arg3; + innerIncr = xStart; + for (j = 0; j < 5; j++, k++) { - sp1EC[k] = arg5; - sp2B4[k] = temp2; - sp250[k] = temp1; - sp188[k] = D_8012AE18[j]; - sp124[k] = D_8012AE30[i]; - temp2 += arg6; + zPoints[k] = zStart; + xPoints[k] = innerIncr; + yPoints[k] = outerIncr; + tcS[k] = sSkybox128TexSCoords[j]; + tcT[k] = sSkybox128TexTCoords[i]; + innerIncr += innerIncrVal; } - temp1 += arg7; + outerIncr += outerIncrVal; } break; - case 2: + case 2: // yz plane case 3: - temp1 = arg4; + outerIncr = yStart; for (i = 0, k = 0; k < 25; i++) { - temp2 = arg5; + innerIncr = zStart; + for (j = 0; j < 5; j++, k++) { - sp2B4[k] = arg3; - sp250[k] = temp1; - sp1EC[k] = temp2; - sp188[k] = D_8012AE18[j]; - sp124[k] = D_8012AE30[i]; - temp2 += arg6; + xPoints[k] = xStart; + yPoints[k] = outerIncr; + zPoints[k] = innerIncr; + tcS[k] = sSkybox128TexSCoords[j]; + tcT[k] = sSkybox128TexTCoords[i]; + innerIncr += innerIncrVal; } - temp1 += arg7; + outerIncr += outerIncrVal; } break; - case 4: + case 4: // xz plane case 5: - temp1 = arg5; + outerIncr = zStart; for (i = 0, k = 0; k < 25; i++) { - temp2 = arg3; + innerIncr = xStart; + for (j = 0; j < 5; j++, k++) { - sp250[k] = arg4; - sp2B4[k] = temp2; - sp1EC[k] = temp1; - sp188[k] = D_8012AE18[j]; - sp124[k] = D_8012AE24[i]; - temp2 += arg6; + yPoints[k] = yStart; + xPoints[k] = innerIncr; + zPoints[k] = outerIncr; + tcS[k] = sSkybox128TexSCoords[j]; + tcT[k] = sSkybox128TexTCoordsXZ[i]; + innerIncr += innerIncrVal; } - temp1 += arg7; + outerIncr += outerIncrVal; } break; } - skyboxCtx->unk_138 = &skyboxCtx->dListBuf[2 * arg8][0]; - for (i = 0; i < 0x20; i++) { - index = D_8012ADD8[i]; + // Select gfx buffer + skyboxCtx->gfx = &skyboxCtx->dListBuf[2 * faceNum][0]; - roomVtx[arg2 + i].v.ob[0] = sp2B4[index]; - roomVtx[arg2 + i].v.ob[1] = sp250[index]; - roomVtx[arg2 + i].v.ob[2] = sp1EC[index]; - roomVtx[arg2 + i].v.flag = 0; - roomVtx[arg2 + i].v.tc[0] = sp188[index]; - roomVtx[arg2 + i].v.tc[1] = sp124[index]; - roomVtx[arg2 + i].v.cn[1] = 0; - roomVtx[arg2 + i].v.cn[2] = 0; - roomVtx[arg2 + i].v.cn[0] = 255; + // Generate and load Vertex structures + for (i = 0; i < 32; i++) { + index = sSkybox128VtxBufIndices[i]; + + roomVtx[roomVtxStartIndex + i].v.ob[0] = xPoints[index]; + roomVtx[roomVtxStartIndex + i].v.ob[1] = yPoints[index]; + roomVtx[roomVtxStartIndex + i].v.ob[2] = zPoints[index]; + roomVtx[roomVtxStartIndex + i].v.flag = 0; + roomVtx[roomVtxStartIndex + i].v.tc[0] = tcS[index]; + roomVtx[roomVtxStartIndex + i].v.tc[1] = tcT[index]; + roomVtx[roomVtxStartIndex + i].v.cn[1] = 0; + roomVtx[roomVtxStartIndex + i].v.cn[2] = 0; + roomVtx[roomVtxStartIndex + i].v.cn[0] = 255; } - gSPVertex(skyboxCtx->unk_138++, &roomVtx[arg2], 32, 0); - arg2 += i; - gSPCullDisplayList(skyboxCtx->unk_138++, 0, 15); + gSPVertex(skyboxCtx->gfx++, &roomVtx[roomVtxStartIndex], 32, 0); + roomVtxStartIndex += i; - if ((arg8 == 4) || (arg8 == 5)) { - phi_a2_4 = 0; - for (phi_t2_4 = 0, phi_ra = 0; phi_ra < 4; phi_ra++, phi_a2_4 += 0x1F) { - for (phi_a0_4 = 0, phi_t1 = 0; phi_t1 < 4; phi_t1++, phi_a0_4 += 0x1F, phi_t2_4 += 4) { - gDPLoadMultiTile(skyboxCtx->unk_138++, (u32)skyboxCtx->staticSegments[0] + D_8012ADC0[arg8], 0, - G_TX_RENDERTILE, G_IM_FMT_CI, G_IM_SIZ_8b, 128, 0, phi_a0_4, phi_a2_4, phi_a0_4 + 0x1F, - phi_a2_4 + 0x1F, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD, - G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD); - gDPLoadMultiTile(skyboxCtx->unk_138++, (u32)skyboxCtx->staticSegments[1] + D_8012ADC0[arg8], 0x80, 1, - G_IM_FMT_CI, G_IM_SIZ_8b, 128, 0, phi_a0_4, phi_a2_4, phi_a0_4 + 0x1F, phi_a2_4 + 0x1F, - 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, + // Cull the face if not within the viewing volume + gSPCullDisplayList(skyboxCtx->gfx++, 0, 15); + + // Draw face, load the texture in several tiles to work around TMEM size limitations + if (faceNum == 4 || faceNum == 5) { + // top/bottom faces, 128x128 texture + + ult = 0; + for (vtxIdx = 0, l = 0; l < 4; l++, ult += 31) { + for (uls = 0, m = 0; m < 4; m++, uls += 31, vtxIdx += 4) { + gDPLoadMultiTile(skyboxCtx->gfx++, (u8*)skyboxCtx->staticSegments[0] + sSkybox128TexOffsets[faceNum], 0, + G_TX_RENDERTILE, G_IM_FMT_CI, G_IM_SIZ_8b, 128, 0, uls, ult, uls + 31, ult + 31, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD); - gSP1Quadrangle(skyboxCtx->unk_138++, D_8012AE3C[phi_t2_4 + 1], D_8012AE3C[phi_t2_4 + 2], - D_8012AE3C[phi_t2_4 + 3], D_8012AE3C[phi_t2_4 + 0], 3); + gDPLoadMultiTile(skyboxCtx->gfx++, (u8*)skyboxCtx->staticSegments[1] + sSkybox128TexOffsets[faceNum], + 0x80, 1, G_IM_FMT_CI, G_IM_SIZ_8b, 128, 0, uls, ult, uls + 31, ult + 31, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, + G_TX_NOMASK, G_TX_NOLOD); + gSP1Quadrangle(skyboxCtx->gfx++, sSkybox128VtxIndices[vtxIdx + 1], sSkybox128VtxIndices[vtxIdx + 2], + sSkybox128VtxIndices[vtxIdx + 3], sSkybox128VtxIndices[vtxIdx + 0], 3); } } } else { - phi_a2_4 = 0; - for (phi_t2_4 = 0, phi_ra = 0; phi_ra < 2; phi_ra++, phi_a2_4 += 0x1F) { - for (phi_a0_4 = 0, phi_t1 = 0; phi_t1 < 4; phi_t1++, phi_a0_4 += 0x1F, phi_t2_4 += 4) { - gDPLoadMultiTile(skyboxCtx->unk_138++, (u32)skyboxCtx->staticSegments[0] + D_8012ADC0[arg8], 0, - G_TX_RENDERTILE, G_IM_FMT_CI, G_IM_SIZ_8b, 128, 0, phi_a0_4, phi_a2_4, phi_a0_4 + 0x1F, - phi_a2_4 + 0x1F, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD, - G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD); - gDPLoadMultiTile(skyboxCtx->unk_138++, (u32)skyboxCtx->staticSegments[1] + D_8012ADC0[arg8], 0x80, 1, - G_IM_FMT_CI, G_IM_SIZ_8b, 128, 0, phi_a0_4, phi_a2_4, phi_a0_4 + 0x1F, phi_a2_4 + 0x1F, - 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, + // other faces, 128x64 texture + + ult = 0; + for (vtxIdx = 0, l = 0; l < 2; l++, ult += 31) { + for (uls = 0, m = 0; m < 4; m++, uls += 31, vtxIdx += 4) { + gDPLoadMultiTile(skyboxCtx->gfx++, (u8*)skyboxCtx->staticSegments[0] + sSkybox128TexOffsets[faceNum], 0, + G_TX_RENDERTILE, G_IM_FMT_CI, G_IM_SIZ_8b, 128, 0, uls, ult, uls + 31, ult + 31, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD); - gSP1Quadrangle(skyboxCtx->unk_138++, D_8012AE3C[phi_t2_4 + 1], D_8012AE3C[phi_t2_4 + 2], - D_8012AE3C[phi_t2_4 + 3], D_8012AE3C[phi_t2_4 + 0], 3); + gDPLoadMultiTile(skyboxCtx->gfx++, (u8*)skyboxCtx->staticSegments[1] + sSkybox128TexOffsets[faceNum], + 0x80, 1, G_IM_FMT_CI, G_IM_SIZ_8b, 128, 0, uls, ult, uls + 31, ult + 31, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, + G_TX_NOMASK, G_TX_NOLOD); + gSP1Quadrangle(skyboxCtx->gfx++, sSkybox128VtxIndices[vtxIdx + 1], sSkybox128VtxIndices[vtxIdx + 2], + sSkybox128VtxIndices[vtxIdx + 3], sSkybox128VtxIndices[vtxIdx + 0], 3); } } - phi_a2_4 -= 0x1F; - for (phi_ra = 0; phi_ra < 2; phi_ra++, phi_a2_4 -= 0x1F) { - for (phi_a0_4 = 0, phi_t1 = 0; phi_t1 < 4; phi_t1++, phi_a0_4 += 0x1F, phi_t2_4 += 4) { - gDPLoadMultiTile(skyboxCtx->unk_138++, (u32)skyboxCtx->staticSegments[0] + D_8012ADC0[arg8], 0, - G_TX_RENDERTILE, G_IM_FMT_CI, G_IM_SIZ_8b, 128, 0, phi_a0_4, phi_a2_4, phi_a0_4 + 0x1F, - phi_a2_4 + 0x1F, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD, - G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD); - gDPLoadMultiTile(skyboxCtx->unk_138++, (u32)skyboxCtx->staticSegments[1] + D_8012ADC0[arg8], 0x80, 1, - G_IM_FMT_CI, G_IM_SIZ_8b, 128, 0, phi_a0_4, phi_a2_4, phi_a0_4 + 0x1F, phi_a2_4 + 0x1F, - 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, + ult -= 31; + for (l = 0; l < 2; l++, ult -= 31) { + for (uls = 0, m = 0; m < 4; m++, uls += 31, vtxIdx += 4) { + gDPLoadMultiTile(skyboxCtx->gfx++, (u8*)skyboxCtx->staticSegments[0] + sSkybox128TexOffsets[faceNum], 0, + G_TX_RENDERTILE, G_IM_FMT_CI, G_IM_SIZ_8b, 128, 0, uls, ult, uls + 31, ult + 31, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD); - gSP1Quadrangle(skyboxCtx->unk_138++, D_8012AE3C[phi_t2_4 + 1], D_8012AE3C[phi_t2_4 + 2], - D_8012AE3C[phi_t2_4 + 3], D_8012AE3C[phi_t2_4 + 0], 3); + gDPLoadMultiTile(skyboxCtx->gfx++, (u8*)skyboxCtx->staticSegments[1] + sSkybox128TexOffsets[faceNum], + 0x80, 1, G_IM_FMT_CI, G_IM_SIZ_8b, 128, 0, uls, ult, uls + 31, ult + 31, 0, + G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, + G_TX_NOMASK, G_TX_NOLOD); + gSP1Quadrangle(skyboxCtx->gfx++, sSkybox128VtxIndices[vtxIdx + 1], sSkybox128VtxIndices[vtxIdx + 2], + sSkybox128VtxIndices[vtxIdx + 3], sSkybox128VtxIndices[vtxIdx + 0], 3); } } } - gSPEndDisplayList(skyboxCtx->unk_138++); - return arg2; + gSPEndDisplayList(skyboxCtx->gfx++); + return roomVtxStartIndex; } -void func_800AEFC8(SkyboxContext* skyboxCtx, s16 skyboxId) { - s32 i; - s32 j; - s32 phi_s3 = 0; +SkyboxFaceParams sSkybox256FaceParams[4] = { + { -126, 124, -126, 63, -31 }, + { 126, 124, -126, 63, -31 }, + { 126, 124, 126, -63, -31 }, + { -126, 124, 126, -63, -31 }, +}; + +/** + * Computes the display list for a skybox where each face is a 256x256 CI8 texture. + * The number of faces is determined by the skybox id or from the drawType field in SkyboxContext. + */ +void Skybox_Calculate256(SkyboxContext* skyboxCtx, s16 skyboxId) { + s32 faceNum; + s32 dlistBufStartIndex; + s32 roomVtxStartIndex = 0; if (skyboxId == SKYBOX_BAZAAR || (skyboxId > SKYBOX_HOUSE_KAKARIKO && skyboxId <= SKYBOX_BOMBCHU_SHOP)) { - for (j = 0, i = 0; i < 2; i++, j += 2) { - phi_s3 = func_800ADBB0(skyboxCtx, skyboxCtx->roomVtx, phi_s3, D_8012AEBC[i].unk_0, D_8012AEBC[i].unk_4, - D_8012AEBC[i].unk_8, D_8012AEBC[i].unk_C, D_8012AEBC[i].unk_10, i, j); + // 2 faces, one in xy plane and one in yz plane + for (dlistBufStartIndex = 0, faceNum = 0; faceNum < 2; faceNum++, dlistBufStartIndex += 2) { + roomVtxStartIndex = Skybox_CalculateFace256( + skyboxCtx, skyboxCtx->roomVtx, roomVtxStartIndex, sSkybox256FaceParams[faceNum].xStart, + sSkybox256FaceParams[faceNum].yStart, sSkybox256FaceParams[faceNum].zStart, + sSkybox256FaceParams[faceNum].outerIncrVal, sSkybox256FaceParams[faceNum].innerIncrVal, faceNum, + dlistBufStartIndex); } - } else if (skyboxCtx->unk_140 == 2) { - for (j = 0, i = 0; i < 3; i++, j += 2) { - phi_s3 = func_800ADBB0(skyboxCtx, skyboxCtx->roomVtx, phi_s3, D_8012AEBC[i].unk_0, D_8012AEBC[i].unk_4, - D_8012AEBC[i].unk_8, D_8012AEBC[i].unk_C, D_8012AEBC[i].unk_10, i, j); + } else if (skyboxCtx->drawType == SKYBOX_DRAW_256_3FACE) { + // 3 faces, 2 in xy plane and 1 in yz plane + for (dlistBufStartIndex = 0, faceNum = 0; faceNum < 3; faceNum++, dlistBufStartIndex += 2) { + roomVtxStartIndex = Skybox_CalculateFace256( + skyboxCtx, skyboxCtx->roomVtx, roomVtxStartIndex, sSkybox256FaceParams[faceNum].xStart, + sSkybox256FaceParams[faceNum].yStart, sSkybox256FaceParams[faceNum].zStart, + sSkybox256FaceParams[faceNum].outerIncrVal, sSkybox256FaceParams[faceNum].innerIncrVal, faceNum, + dlistBufStartIndex); } } else { - for (j = 0, i = 0; i < 4; i++, j += 2) { - phi_s3 = func_800ADBB0(skyboxCtx, skyboxCtx->roomVtx, phi_s3, D_8012AEBC[i].unk_0, D_8012AEBC[i].unk_4, - D_8012AEBC[i].unk_8, D_8012AEBC[i].unk_C, D_8012AEBC[i].unk_10, i, j); + // 4 faces, 2 in xy plane and 2 in yz plane + for (dlistBufStartIndex = 0, faceNum = 0; faceNum < 4; faceNum++, dlistBufStartIndex += 2) { + roomVtxStartIndex = Skybox_CalculateFace256( + skyboxCtx, skyboxCtx->roomVtx, roomVtxStartIndex, sSkybox256FaceParams[faceNum].xStart, + sSkybox256FaceParams[faceNum].yStart, sSkybox256FaceParams[faceNum].zStart, + sSkybox256FaceParams[faceNum].outerIncrVal, sSkybox256FaceParams[faceNum].innerIncrVal, faceNum, + dlistBufStartIndex); } } } -void func_800AF178(SkyboxContext* skyboxCtx, s32 arg1) { - s32 phi_s2 = 0; - s32 i; +SkyboxFaceParams sSkybox128FaceParams[6] = { + { -64, 64, -64, 32, -32 }, { 64, 64, 64, -32, -32 }, { -64, 64, 64, -32, -32 }, + { 64, 64, -64, 32, -32 }, { -64, 64, 64, 32, -32 }, { -64, -64, -64, 32, 32 }, +}; - for (i = 0; i < arg1; i++) { - phi_s2 = func_800AE2C0(skyboxCtx, skyboxCtx->roomVtx, phi_s2, D_8012AF0C[i].unk_0, D_8012AF0C[i].unk_4, - D_8012AF0C[i].unk_8, D_8012AF0C[i].unk_C, D_8012AF0C[i].unk_10, i); +/** + * Computes the display list for a skybox with up to 6 faces, where the sides are 128x64 CI8 textures and the + * top/bottom faces are 128x128 CI8 textures. + */ +void Skybox_Calculate128(SkyboxContext* skyboxCtx, s32 nFaces) { + s32 roomVtxStartIndex = 0; + s32 faceNum; + + for (faceNum = 0; faceNum < nFaces; faceNum++) { + roomVtxStartIndex = Skybox_CalculateFace128( + skyboxCtx, skyboxCtx->roomVtx, roomVtxStartIndex, sSkybox128FaceParams[faceNum].xStart, + sSkybox128FaceParams[faceNum].yStart, sSkybox128FaceParams[faceNum].zStart, + sSkybox128FaceParams[faceNum].outerIncrVal, sSkybox128FaceParams[faceNum].innerIncrVal, faceNum); } } @@ -375,7 +456,7 @@ void Skybox_Setup(PlayState* play, SkyboxContext* skyboxCtx, s16 skyboxId) { s16 i; u8 skybox1Index; u8 skybox2Index; - u32 start; + uintptr_t start; s32 skyboxConfig; switch (skyboxId) { @@ -447,7 +528,7 @@ void Skybox_Setup(PlayState* play, SkyboxContext* skyboxCtx, s16 skyboxId) { break; case SKYBOX_BAZAAR: - skyboxCtx->unk_140 = 1; + skyboxCtx->drawType = SKYBOX_DRAW_256_4FACE; start = (uintptr_t)_vr_SP1a_staticSegmentRomStart; size = (uintptr_t)_vr_SP1a_staticSegmentRomEnd - start; @@ -489,7 +570,7 @@ void Skybox_Setup(PlayState* play, SkyboxContext* skyboxCtx, s16 skyboxId) { DmaMgr_RequestSyncDebug((u8*)skyboxCtx->palettes + size, start, size, "../z_vr_box.c", 1175); break; case SKYBOX_MARKET_ADULT: - skyboxCtx->unk_140 = 1; + skyboxCtx->drawType = SKYBOX_DRAW_256_4FACE; start = (uintptr_t)_vr_RUVR_staticSegmentRomStart; size = (uintptr_t)_vr_RUVR_staticSegmentRomEnd - start; @@ -535,7 +616,7 @@ void Skybox_Setup(PlayState* play, SkyboxContext* skyboxCtx, s16 skyboxId) { size, "../z_vr_box.c", 1216); break; case SKYBOX_HOUSE_LINK: - skyboxCtx->unk_140 = 1; + skyboxCtx->drawType = SKYBOX_DRAW_256_4FACE; start = (uintptr_t)_vr_LHVR_staticSegmentRomStart; size = (uintptr_t)_vr_LHVR_staticSegmentRomEnd - start; @@ -553,7 +634,7 @@ void Skybox_Setup(PlayState* play, SkyboxContext* skyboxCtx, s16 skyboxId) { DmaMgr_RequestSyncDebug(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1233); break; case SKYBOX_MARKET_CHILD_DAY: - skyboxCtx->unk_140 = 1; + skyboxCtx->drawType = SKYBOX_DRAW_256_4FACE; start = (uintptr_t)_vr_MDVR_staticSegmentRomStart; size = (uintptr_t)_vr_MDVR_staticSegmentRomEnd - start; @@ -571,7 +652,7 @@ void Skybox_Setup(PlayState* play, SkyboxContext* skyboxCtx, s16 skyboxId) { DmaMgr_RequestSyncDebug(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1264); break; case SKYBOX_MARKET_CHILD_NIGHT: - skyboxCtx->unk_140 = 1; + skyboxCtx->drawType = SKYBOX_DRAW_256_4FACE; start = (uintptr_t)_vr_MNVR_staticSegmentRomStart; size = (uintptr_t)_vr_MNVR_staticSegmentRomEnd - start; @@ -591,7 +672,7 @@ void Skybox_Setup(PlayState* play, SkyboxContext* skyboxCtx, s16 skyboxId) { DmaMgr_RequestSyncDebug(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1279); break; case SKYBOX_HAPPY_MASK_SHOP: - skyboxCtx->unk_140 = 1; + skyboxCtx->drawType = SKYBOX_DRAW_256_4FACE; start = (uintptr_t)_vr_FCVR_staticSegmentRomStart; size = (uintptr_t)_vr_FCVR_staticSegmentRomEnd - start; @@ -610,7 +691,7 @@ void Skybox_Setup(PlayState* play, SkyboxContext* skyboxCtx, s16 skyboxId) { skyboxCtx->rot.y = 0.8f; break; case SKYBOX_HOUSE_KNOW_IT_ALL_BROTHERS: - skyboxCtx->unk_140 = 1; + skyboxCtx->drawType = SKYBOX_DRAW_256_4FACE; start = (uintptr_t)_vr_KHVR_staticSegmentRomStart; size = (uintptr_t)_vr_KHVR_staticSegmentRomEnd - start; @@ -628,7 +709,7 @@ void Skybox_Setup(PlayState* play, SkyboxContext* skyboxCtx, s16 skyboxId) { DmaMgr_RequestSyncDebug(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1308); break; case SKYBOX_HOUSE_OF_TWINS: - skyboxCtx->unk_140 = 2; + skyboxCtx->drawType = SKYBOX_DRAW_256_3FACE; start = (uintptr_t)_vr_K3VR_staticSegmentRomStart; size = (uintptr_t)_vr_K3VR_staticSegmentRomEnd - start; @@ -646,7 +727,7 @@ void Skybox_Setup(PlayState* play, SkyboxContext* skyboxCtx, s16 skyboxId) { DmaMgr_RequestSyncDebug(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1338); break; case SKYBOX_STABLES: - skyboxCtx->unk_140 = 1; + skyboxCtx->drawType = SKYBOX_DRAW_256_4FACE; start = (uintptr_t)_vr_MLVR_staticSegmentRomStart; size = (uintptr_t)_vr_MLVR_staticSegmentRomEnd - start; @@ -664,7 +745,7 @@ void Skybox_Setup(PlayState* play, SkyboxContext* skyboxCtx, s16 skyboxId) { DmaMgr_RequestSyncDebug(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1352); break; case SKYBOX_HOUSE_KAKARIKO: - skyboxCtx->unk_140 = 1; + skyboxCtx->drawType = SKYBOX_DRAW_256_4FACE; start = (uintptr_t)_vr_KKRVR_staticSegmentRomStart; size = (uintptr_t)_vr_KKRVR_staticSegmentRomEnd - start; @@ -682,7 +763,7 @@ void Skybox_Setup(PlayState* play, SkyboxContext* skyboxCtx, s16 skyboxId) { DmaMgr_RequestSyncDebug(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1366); break; case SKYBOX_KOKIRI_SHOP: - skyboxCtx->unk_140 = 1; + skyboxCtx->drawType = SKYBOX_DRAW_256_4FACE; start = (uintptr_t)_vr_KSVR_staticSegmentRomStart; size = (uintptr_t)_vr_KSVR_staticSegmentRomEnd - start; @@ -701,7 +782,7 @@ void Skybox_Setup(PlayState* play, SkyboxContext* skyboxCtx, s16 skyboxId) { skyboxCtx->rot.y = 0.8f; break; case SKYBOX_GORON_SHOP: - skyboxCtx->unk_140 = 1; + skyboxCtx->drawType = SKYBOX_DRAW_256_4FACE; start = (uintptr_t)_vr_GLVR_staticSegmentRomStart; size = (uintptr_t)_vr_GLVR_staticSegmentRomEnd - start; @@ -720,7 +801,7 @@ void Skybox_Setup(PlayState* play, SkyboxContext* skyboxCtx, s16 skyboxId) { skyboxCtx->rot.y = 0.8f; break; case SKYBOX_ZORA_SHOP: - skyboxCtx->unk_140 = 1; + skyboxCtx->drawType = SKYBOX_DRAW_256_4FACE; start = (uintptr_t)_vr_ZRVR_staticSegmentRomStart; size = (uintptr_t)_vr_ZRVR_staticSegmentRomEnd - start; @@ -739,7 +820,7 @@ void Skybox_Setup(PlayState* play, SkyboxContext* skyboxCtx, s16 skyboxId) { skyboxCtx->rot.y = 0.8f; break; case SKYBOX_POTION_SHOP_KAKARIKO: - skyboxCtx->unk_140 = 1; + skyboxCtx->drawType = SKYBOX_DRAW_256_4FACE; start = (uintptr_t)_vr_DGVR_staticSegmentRomStart; size = (uintptr_t)_vr_DGVR_staticSegmentRomEnd - start; @@ -758,7 +839,7 @@ void Skybox_Setup(PlayState* play, SkyboxContext* skyboxCtx, s16 skyboxId) { skyboxCtx->rot.y = 0.8f; break; case SKYBOX_POTION_SHOP_MARKET: - skyboxCtx->unk_140 = 1; + skyboxCtx->drawType = SKYBOX_DRAW_256_4FACE; start = (uintptr_t)_vr_ALVR_staticSegmentRomStart; size = (uintptr_t)_vr_ALVR_staticSegmentRomEnd - start; @@ -777,7 +858,7 @@ void Skybox_Setup(PlayState* play, SkyboxContext* skyboxCtx, s16 skyboxId) { skyboxCtx->rot.y = 0.8f; break; case SKYBOX_BOMBCHU_SHOP: - skyboxCtx->unk_140 = 1; + skyboxCtx->drawType = SKYBOX_DRAW_256_4FACE; start = (uintptr_t)_vr_NSVR_staticSegmentRomStart; size = (uintptr_t)_vr_NSVR_staticSegmentRomEnd - start; @@ -796,7 +877,7 @@ void Skybox_Setup(PlayState* play, SkyboxContext* skyboxCtx, s16 skyboxId) { skyboxCtx->rot.y = 0.8f; break; case SKYBOX_HOUSE_RICHARD: - skyboxCtx->unk_140 = 1; + skyboxCtx->drawType = SKYBOX_DRAW_256_4FACE; start = (uintptr_t)_vr_IPVR_staticSegmentRomStart; size = (uintptr_t)_vr_IPVR_staticSegmentRomEnd - start; @@ -814,7 +895,7 @@ void Skybox_Setup(PlayState* play, SkyboxContext* skyboxCtx, s16 skyboxId) { DmaMgr_RequestSyncDebug(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1519); break; case SKYBOX_HOUSE_IMPA: - skyboxCtx->unk_140 = 1; + skyboxCtx->drawType = SKYBOX_DRAW_256_4FACE; start = (uintptr_t)_vr_LBVR_staticSegmentRomStart; size = (uintptr_t)_vr_LBVR_staticSegmentRomEnd - start; @@ -832,7 +913,7 @@ void Skybox_Setup(PlayState* play, SkyboxContext* skyboxCtx, s16 skyboxId) { DmaMgr_RequestSyncDebug(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1533); break; case SKYBOX_TENT: - skyboxCtx->unk_140 = 2; + skyboxCtx->drawType = SKYBOX_DRAW_256_3FACE; start = (uintptr_t)_vr_TTVR_staticSegmentRomStart; size = (uintptr_t)_vr_TTVR_staticSegmentRomEnd - start; @@ -850,7 +931,7 @@ void Skybox_Setup(PlayState* play, SkyboxContext* skyboxCtx, s16 skyboxId) { DmaMgr_RequestSyncDebug(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1547); break; case SKYBOX_HOUSE_MIDO: - skyboxCtx->unk_140 = 2; + skyboxCtx->drawType = SKYBOX_DRAW_256_3FACE; start = (uintptr_t)_vr_K4VR_staticSegmentRomStart; size = (uintptr_t)_vr_K4VR_staticSegmentRomEnd - start; @@ -868,7 +949,7 @@ void Skybox_Setup(PlayState* play, SkyboxContext* skyboxCtx, s16 skyboxId) { DmaMgr_RequestSyncDebug(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1567); break; case SKYBOX_HOUSE_SARIA: - skyboxCtx->unk_140 = 2; + skyboxCtx->drawType = SKYBOX_DRAW_256_3FACE; start = (uintptr_t)_vr_K5VR_staticSegmentRomStart; size = (uintptr_t)_vr_K5VR_staticSegmentRomEnd - start; @@ -886,7 +967,7 @@ void Skybox_Setup(PlayState* play, SkyboxContext* skyboxCtx, s16 skyboxId) { DmaMgr_RequestSyncDebug(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1581); break; case SKYBOX_HOUSE_ALLEY: - skyboxCtx->unk_140 = 2; + skyboxCtx->drawType = SKYBOX_DRAW_256_3FACE; start = (uintptr_t)_vr_KR3VR_staticSegmentRomStart; size = (uintptr_t)_vr_KR3VR_staticSegmentRomEnd - start; @@ -911,40 +992,42 @@ void Skybox_Setup(PlayState* play, SkyboxContext* skyboxCtx, s16 skyboxId) { void Skybox_Init(GameState* state, SkyboxContext* skyboxCtx, s16 skyboxId) { PlayState* play = (PlayState*)state; - skyboxCtx->unk_140 = 0; + skyboxCtx->drawType = SKYBOX_DRAW_128; skyboxCtx->rot.x = skyboxCtx->rot.y = skyboxCtx->rot.z = 0.0f; + // DMA required assets based on skybox id Skybox_Setup(play, skyboxCtx, skyboxId); osSyncPrintf("\n\n\n********************\n\n\n" "TYPE=%d" "\n\n\n********************\n\n\n", skyboxId); + // Precompute vertices and display lists for drawing the skybox if (skyboxId != SKYBOX_NONE) { osSyncPrintf(VT_FGCOL(GREEN)); - if (skyboxCtx->unk_140 != 0) { + if (skyboxCtx->drawType != SKYBOX_DRAW_128) { skyboxCtx->dListBuf = GameState_Alloc(state, 8 * 150 * sizeof(Gfx), "../z_vr_box.c", 1636); ASSERT(skyboxCtx->dListBuf != NULL, "vr_box->dpList != NULL", "../z_vr_box.c", 1637); - skyboxCtx->roomVtx = GameState_Alloc(state, 256 * sizeof(Vtx), "../z_vr_box.c", 1639); + skyboxCtx->roomVtx = GameState_Alloc(state, 8 * 32 * sizeof(Vtx), "../z_vr_box.c", 1639); ASSERT(skyboxCtx->roomVtx != NULL, "vr_box->roomVtx != NULL", "../z_vr_box.c", 1640); - func_800AEFC8(skyboxCtx, skyboxId); + Skybox_Calculate256(skyboxCtx, skyboxId); } else { skyboxCtx->dListBuf = GameState_Alloc(state, 12 * 150 * sizeof(Gfx), "../z_vr_box.c", 1643); ASSERT(skyboxCtx->dListBuf != NULL, "vr_box->dpList != NULL", "../z_vr_box.c", 1644); if (skyboxId == SKYBOX_CUTSCENE_MAP) { - skyboxCtx->roomVtx = GameState_Alloc(state, 192 * sizeof(Vtx), "../z_vr_box.c", 1648); + skyboxCtx->roomVtx = GameState_Alloc(state, 6 * 32 * sizeof(Vtx), "../z_vr_box.c", 1648); ASSERT(skyboxCtx->roomVtx != NULL, "vr_box->roomVtx != NULL", "../z_vr_box.c", 1649); - func_800AF178(skyboxCtx, 6); + Skybox_Calculate128(skyboxCtx, 6); // compute all 6 faces } else { - skyboxCtx->roomVtx = GameState_Alloc(state, 160 * sizeof(Vtx), "../z_vr_box.c", 1653); + skyboxCtx->roomVtx = GameState_Alloc(state, 5 * 32 * sizeof(Vtx), "../z_vr_box.c", 1653); ASSERT(skyboxCtx->roomVtx != NULL, "vr_box->roomVtx != NULL", "../z_vr_box.c", 1654); - func_800AF178(skyboxCtx, 5); + Skybox_Calculate128(skyboxCtx, 5); // compute 5 faces, excludes the bottom face } } osSyncPrintf(VT_RST); diff --git a/src/code/z_vr_box_draw.c b/src/code/z_vr_box_draw.c index 60fa408d09..96a785118c 100644 --- a/src/code/z_vr_box_draw.c +++ b/src/code/z_vr_box_draw.c @@ -23,8 +23,8 @@ void Skybox_Draw(SkyboxContext* skyboxCtx, GraphicsContext* gfxCtx, s16 skyboxId gDPSetPrimColor(POLY_OPA_DISP++, 0x00, 0x00, 0, 0, 0, blend); gSPTexture(POLY_OPA_DISP++, 0x8000, 0x8000, 0, G_TX_RENDERTILE, G_ON); + // Prepare matrix sSkyboxDrawMatrix = Graph_Alloc(gfxCtx, sizeof(Mtx)); - Matrix_Translate(x, y, z, MTXMODE_NEW); Matrix_Scale(1.0f, 1.0f, 1.0f, MTXMODE_APPLY); Matrix_RotateX(skyboxCtx->rot.x, MTXMODE_APPLY); @@ -33,45 +33,61 @@ void Skybox_Draw(SkyboxContext* skyboxCtx, GraphicsContext* gfxCtx, s16 skyboxId Matrix_ToMtx(sSkyboxDrawMatrix, "../z_vr_box_draw.c", 76); gSPMatrix(POLY_OPA_DISP++, sSkyboxDrawMatrix, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); + // Enable magic square RGB dithering and bilinear filtering gDPSetColorDither(POLY_OPA_DISP++, G_CD_MAGICSQ); gDPSetTextureFilter(POLY_OPA_DISP++, G_TF_BILERP); + // All skyboxes use CI8 textures with an RGBA16 palette gDPLoadTLUT_pal256(POLY_OPA_DISP++, skyboxCtx->palettes[0]); gDPSetTextureLUT(POLY_OPA_DISP++, G_TT_RGBA16); + + // Enable texture filtering RDP pipeline stages for bilinear filtering gDPSetTextureConvert(POLY_OPA_DISP++, G_TC_FILT); - if (skyboxCtx->unk_140) { - gSPDisplayList(POLY_OPA_DISP++, skyboxCtx->dListBuf[0]); - gSPDisplayList(POLY_OPA_DISP++, skyboxCtx->dListBuf[1]); + if (skyboxCtx->drawType != SKYBOX_DRAW_128) { + // 256x256 textures, per-face palettes + // 2, 3 or 4 faces + + gSPDisplayList(POLY_OPA_DISP++, skyboxCtx->dListBuf[0]); // -z face upper + gSPDisplayList(POLY_OPA_DISP++, skyboxCtx->dListBuf[1]); // -z face lower gDPPipeSync(POLY_OPA_DISP++); gDPLoadTLUT_pal256(POLY_OPA_DISP++, skyboxCtx->palettes[1]); - gSPDisplayList(POLY_OPA_DISP++, skyboxCtx->dListBuf[2]); - gSPDisplayList(POLY_OPA_DISP++, skyboxCtx->dListBuf[3]); + gSPDisplayList(POLY_OPA_DISP++, skyboxCtx->dListBuf[2]); // +x face upper + gSPDisplayList(POLY_OPA_DISP++, skyboxCtx->dListBuf[3]); // +x face lower if (skyboxId != SKYBOX_BAZAAR) { - if (skyboxId <= SKYBOX_HOUSE_KAKARIKO || skyboxId > SKYBOX_BOMBCHU_SHOP) { - gDPPipeSync(POLY_OPA_DISP++); - gDPLoadTLUT_pal256(POLY_OPA_DISP++, skyboxCtx->palettes[2]); - gSPDisplayList(POLY_OPA_DISP++, skyboxCtx->dListBuf[4]); - gSPDisplayList(POLY_OPA_DISP++, skyboxCtx->dListBuf[5]); + if (skyboxId < SKYBOX_KOKIRI_SHOP || skyboxId > SKYBOX_BOMBCHU_SHOP) { + // Skip remaining faces for most shop skyboxes gDPPipeSync(POLY_OPA_DISP++); - if (skyboxCtx->unk_140 != 2) { + gDPLoadTLUT_pal256(POLY_OPA_DISP++, skyboxCtx->palettes[2]); + gSPDisplayList(POLY_OPA_DISP++, skyboxCtx->dListBuf[4]); // +z face upper + gSPDisplayList(POLY_OPA_DISP++, skyboxCtx->dListBuf[5]); // +z face lower + + // Note this pipesync is slightly misplaced and would be better off inside the condition + gDPPipeSync(POLY_OPA_DISP++); + + if (skyboxCtx->drawType != SKYBOX_DRAW_256_3FACE) { gDPLoadTLUT_pal256(POLY_OPA_DISP++, skyboxCtx->palettes[3]); - gSPDisplayList(POLY_OPA_DISP++, skyboxCtx->dListBuf[6]); - gSPDisplayList(POLY_OPA_DISP++, skyboxCtx->dListBuf[7]); + gSPDisplayList(POLY_OPA_DISP++, skyboxCtx->dListBuf[6]); // -x face upper + gSPDisplayList(POLY_OPA_DISP++, skyboxCtx->dListBuf[7]); // -x face lower } } } } else { - gSPDisplayList(POLY_OPA_DISP++, skyboxCtx->dListBuf[0]); - gSPDisplayList(POLY_OPA_DISP++, skyboxCtx->dListBuf[2]); - gSPDisplayList(POLY_OPA_DISP++, skyboxCtx->dListBuf[4]); - gSPDisplayList(POLY_OPA_DISP++, skyboxCtx->dListBuf[6]); - gSPDisplayList(POLY_OPA_DISP++, skyboxCtx->dListBuf[8]); + // 128x128 and 128x64 textures + // 5 or 6 faces + + // Draw each face + gSPDisplayList(POLY_OPA_DISP++, skyboxCtx->dListBuf[0]); // -z face + gSPDisplayList(POLY_OPA_DISP++, skyboxCtx->dListBuf[2]); // +z face + gSPDisplayList(POLY_OPA_DISP++, skyboxCtx->dListBuf[4]); // -x face + gSPDisplayList(POLY_OPA_DISP++, skyboxCtx->dListBuf[6]); // +x face + gSPDisplayList(POLY_OPA_DISP++, skyboxCtx->dListBuf[8]); // +y face if (skyboxId == SKYBOX_CUTSCENE_MAP) { - gSPDisplayList(POLY_OPA_DISP++, skyboxCtx->dListBuf[10]); + // Skip the bottom face in the cutscene map + gSPDisplayList(POLY_OPA_DISP++, skyboxCtx->dListBuf[10]); // -y face } } diff --git a/src/overlays/actors/ovl_Bg_Spot02_Objects/z_bg_spot02_objects.c b/src/overlays/actors/ovl_Bg_Spot02_Objects/z_bg_spot02_objects.c index 8cc8a71057..b303737467 100644 --- a/src/overlays/actors/ovl_Bg_Spot02_Objects/z_bg_spot02_objects.c +++ b/src/overlays/actors/ovl_Bg_Spot02_Objects/z_bg_spot02_objects.c @@ -127,7 +127,7 @@ void func_808AC908(BgSpot02Objects* this, PlayState* play) { static Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; Vec3f pos; - if (play->csCtx.state != 0) { + if (play->csCtx.state != CS_STATE_IDLE) { if (play->csCtx.actorCues[3] != NULL && play->csCtx.actorCues[3]->id == 2) { Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_GRAVE_EXPLOSION); SET_EVENTCHKINF(EVENTCHKINF_1D); @@ -199,7 +199,7 @@ void BgSpot02Objects_Draw(Actor* thisx, PlayState* play) { } void func_808ACC34(BgSpot02Objects* this, PlayState* play) { - if (play->csCtx.state != 0 && play->csCtx.actorCues[0] != NULL && play->csCtx.actorCues[0]->id == 2) { + if (play->csCtx.state != CS_STATE_IDLE && play->csCtx.actorCues[0] != NULL && play->csCtx.actorCues[0]->id == 2) { this->unk_16A++; if (this->unk_16A >= 12) { @@ -225,7 +225,7 @@ void func_808ACCB8(Actor* thisx, PlayState* play) { OPEN_DISPS(play->state.gfxCtx, "../z_bg_spot02_objects.c", 600); - if (play->csCtx.state != 0 && play->csCtx.actorCues[0] != NULL && play->csCtx.actorCues[0]->id == 2) { + if (play->csCtx.state != CS_STATE_IDLE && play->csCtx.actorCues[0] != NULL && play->csCtx.actorCues[0]->id == 2) { if (this->unk_16A < 5) { rate = (this->unk_16A / 5.0f); redPrim = greenPrim = bluePrim = 255; @@ -265,7 +265,7 @@ void func_808ACCB8(Actor* thisx, PlayState* play) { } void func_808AD3D4(BgSpot02Objects* this, PlayState* play) { - if (play->csCtx.state != 0 && play->csCtx.actorCues[2] != NULL && play->csCtx.actorCues[2]->id == 2) { + if (play->csCtx.state != CS_STATE_IDLE && play->csCtx.actorCues[2] != NULL && play->csCtx.actorCues[2]->id == 2) { if (this->timer == 2) { Actor_PlaySfx(&this->dyna.actor, NA_SE_IT_EXPLOSION_ICE); } @@ -285,7 +285,7 @@ void func_808AD450(Actor* thisx, PlayState* play) { OPEN_DISPS(play->state.gfxCtx, "../z_bg_spot02_objects.c", 736); - if (play->csCtx.state != 0 && play->csCtx.actorCues[2] != NULL) { + if (play->csCtx.state != CS_STATE_IDLE && play->csCtx.actorCues[2] != NULL) { u16 temp_v1 = CAM_BINANG_TO_DEG(play->csCtx.actorCues[2]->rot.z); if (this->unk_170 != temp_v1) { diff --git a/src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo.c b/src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo.c index a32b7967e5..2cffd30c8e 100644 --- a/src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo.c +++ b/src/overlays/actors/ovl_Boss_Dodongo/z_boss_dodongo.c @@ -404,8 +404,7 @@ void BossDodongo_IntroCutscene(BossDodongo* this, PlayState* play) { if (this->unk_198 == 0x5A) { if (!GET_EVENTCHKINF(EVENTCHKINF_71)) { TitleCard_InitBossName(play, &play->actorCtx.titleCtx, - SEGMENTED_TO_VIRTUAL(&object_kingdodongo_Blob_017410), 0xA0, 0xB4, 0x80, - 0x28); + SEGMENTED_TO_VIRTUAL(gKingDodongoTitleCardTex), 160, 180, 128, 40); } SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, 0, NA_BGM_FIRE_BOSS); } @@ -1226,10 +1225,9 @@ void BossDodongo_SpawnFire(BossDodongo* this, PlayState* play, s16 params) { void BossDodongo_UpdateDamage(BossDodongo* this, PlayState* play) { s32 pad; - ColliderInfo* item1; + ColliderInfo* item; u8 swordDamage; s32 damage; - ColliderInfo* item2; s16 i; if ((this->health <= 0) && (this->actionFunc != BossDodongo_DeathCutscene)) { @@ -1242,10 +1240,9 @@ void BossDodongo_UpdateDamage(BossDodongo* this, PlayState* play) { if (this->actionFunc == BossDodongo_Inhale) { for (i = 0; i < 19; i++) { if (this->collider.elements[i].info.bumperFlags & BUMP_HIT) { - item1 = this->collider.elements[i].info.acHitInfo; - item2 = item1; + item = this->collider.elements[i].info.acHitInfo; - if ((item2->toucher.dmgFlags & DMG_BOOMERANG) || (item2->toucher.dmgFlags & DMG_SLINGSHOT)) { + if ((item->toucher.dmgFlags & DMG_BOOMERANG) || (item->toucher.dmgFlags & DMG_SLINGSHOT)) { this->collider.elements[i].info.bumperFlags &= ~BUMP_HIT; this->unk_1C0 = 2; BossDodongo_SetupWalk(this); @@ -1258,9 +1255,9 @@ void BossDodongo_UpdateDamage(BossDodongo* this, PlayState* play) { if (this->collider.elements->info.bumperFlags & BUMP_HIT) { this->collider.elements->info.bumperFlags &= ~BUMP_HIT; - item1 = this->collider.elements[0].info.acHitInfo; + item = this->collider.elements[0].info.acHitInfo; if ((this->actionFunc == BossDodongo_Vulnerable) || (this->actionFunc == BossDodongo_LayDown)) { - swordDamage = damage = CollisionCheck_GetSwordDamage(item1->toucher.dmgFlags); + swordDamage = damage = CollisionCheck_GetSwordDamage(item->toucher.dmgFlags); if (damage != 0) { Actor_PlaySfx(&this->actor, NA_SE_EN_DODO_K_DAMAGE); diff --git a/src/overlays/actors/ovl_Boss_Fd/z_boss_fd.c b/src/overlays/actors/ovl_Boss_Fd/z_boss_fd.c index d06cf76e94..bb739b45b9 100644 --- a/src/overlays/actors/ovl_Boss_Fd/z_boss_fd.c +++ b/src/overlays/actors/ovl_Boss_Fd/z_boss_fd.c @@ -489,8 +489,8 @@ void BossFd_Fly(BossFd* this, PlayState* play) { SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, 0, NA_BGM_FIRE_BOSS); } if ((this->timers[3] == 130) && !GET_EVENTCHKINF(EVENTCHKINF_73)) { - TitleCard_InitBossName(play, &play->actorCtx.titleCtx, - SEGMENTED_TO_VIRTUAL(gVolvagiaBossTitleCardTex), 0xA0, 0xB4, 0x80, 0x28); + TitleCard_InitBossName(play, &play->actorCtx.titleCtx, SEGMENTED_TO_VIRTUAL(gVolvagiaTitleCardTex), + 160, 180, 128, 40); } if (this->timers[3] <= 100) { this->subCamEyeVel.x = this->subCamEyeVel.y = this->subCamEyeVel.z = 2.0f; diff --git a/src/overlays/actors/ovl_Boss_Goma/z_boss_goma.c b/src/overlays/actors/ovl_Boss_Goma/z_boss_goma.c index 11c191dec3..463c45a737 100644 --- a/src/overlays/actors/ovl_Boss_Goma/z_boss_goma.c +++ b/src/overlays/actors/ovl_Boss_Goma/z_boss_goma.c @@ -921,7 +921,7 @@ void BossGoma_Encounter(BossGoma* this, PlayState* play) { if (!GET_EVENTCHKINF(EVENTCHKINF_70)) { TitleCard_InitBossName(play, &play->actorCtx.titleCtx, SEGMENTED_TO_VIRTUAL(gGohmaTitleCardTex), - 0xA0, 0xB4, 0x80, 0x28); + 160, 180, 128, 40); } SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, 0, NA_BGM_BOSS); diff --git a/src/overlays/actors/ovl_Boss_Mo/z_boss_mo.c b/src/overlays/actors/ovl_Boss_Mo/z_boss_mo.c index 8f9aad30f6..ef7b74aa55 100644 --- a/src/overlays/actors/ovl_Boss_Mo/z_boss_mo.c +++ b/src/overlays/actors/ovl_Boss_Mo/z_boss_mo.c @@ -1420,8 +1420,8 @@ void BossMo_IntroCs(BossMo* this, PlayState* play) { SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, 0, NA_BGM_BOSS); } if (this->timers[2] == 130) { - TitleCard_InitBossName(play, &play->actorCtx.titleCtx, SEGMENTED_TO_VIRTUAL(gMorphaTitleCardTex), 0xA0, - 0xB4, 0x80, 0x28); + TitleCard_InitBossName(play, &play->actorCtx.titleCtx, SEGMENTED_TO_VIRTUAL(gMorphaTitleCardTex), 160, + 180, 128, 40); SET_EVENTCHKINF(EVENTCHKINF_74); } break; diff --git a/src/overlays/actors/ovl_Boss_Tw/z_boss_tw.c b/src/overlays/actors/ovl_Boss_Tw/z_boss_tw.c index 939495375a..67b9086c11 100644 --- a/src/overlays/actors/ovl_Boss_Tw/z_boss_tw.c +++ b/src/overlays/actors/ovl_Boss_Tw/z_boss_tw.c @@ -2214,8 +2214,8 @@ void BossTw_TwinrovaIntroCS(BossTw* this, PlayState* play) { play->envCtx.prevLightSetting = 1; play->envCtx.lightSetting = 1; play->envCtx.lightBlend = 0.0f; - TitleCard_InitBossName(play, &play->actorCtx.titleCtx, SEGMENTED_TO_VIRTUAL(gTwinrovaTitleCardTex), - 0xA0, 0xB4, 0x80, 0x28); + TitleCard_InitBossName(play, &play->actorCtx.titleCtx, SEGMENTED_TO_VIRTUAL(gTwinrovaTitleCardTex), 160, + 180, 128, 40); SET_EVENTCHKINF(EVENTCHKINF_75); SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, 0, NA_BGM_BOSS); } diff --git a/src/overlays/actors/ovl_Boss_Va/z_boss_va.c b/src/overlays/actors/ovl_Boss_Va/z_boss_va.c index b79795f444..9a7d0c55bc 100644 --- a/src/overlays/actors/ovl_Boss_Va/z_boss_va.c +++ b/src/overlays/actors/ovl_Boss_Va/z_boss_va.c @@ -974,7 +974,7 @@ void BossVa_BodyIntro(BossVa* this, PlayState* play) { if (!GET_EVENTCHKINF(EVENTCHKINF_76)) { TitleCard_InitBossName(play, &play->actorCtx.titleCtx, SEGMENTED_TO_VIRTUAL(gBarinadeTitleCardTex), - 0xA0, 0xB4, 0x80, 0x28); + 160, 180, 128, 40); } if (Rand_ZeroOne() < 0.1f) { diff --git a/src/overlays/actors/ovl_Demo_Du/z_demo_du.c b/src/overlays/actors/ovl_Demo_Du/z_demo_du.c index 0c03001fec..a796f9aeba 100644 --- a/src/overlays/actors/ovl_Demo_Du/z_demo_du.c +++ b/src/overlays/actors/ovl_Demo_Du/z_demo_du.c @@ -194,7 +194,7 @@ void func_80969FB4(DemoDu* this, PlayState* play) { void DemoDu_CsFireMedallion_AdvanceTo01(DemoDu* this, PlayState* play) { s32 pad[2]; - if ((gSaveContext.chamberCutsceneNum == 1) && !IS_CUTSCENE_LAYER) { + if ((gSaveContext.chamberCutsceneNum == CHAMBER_CS_FIRE) && !IS_CUTSCENE_LAYER) { Player* player = GET_PLAYER(play); this->updateIndex = CS_FIREMEDALLION_SUBSCENE(1); diff --git a/src/overlays/actors/ovl_Demo_Gt/z_demo_gt.c b/src/overlays/actors/ovl_Demo_Gt/z_demo_gt.c index 573fbe6270..da65153be0 100644 --- a/src/overlays/actors/ovl_Demo_Gt/z_demo_gt.c +++ b/src/overlays/actors/ovl_Demo_Gt/z_demo_gt.c @@ -786,7 +786,7 @@ void func_8097FCE4(DemoGt* this, PlayState* play) { Vec3f vec; u16 csCurFrame = play->csCtx.curFrame; - if (csCurFrame == 0x1F7 || kREG(1) == 4) { + if (csCurFrame == 503 || kREG(1) == 4) { vec.x = this->dyna.actor.world.pos.x + 300.0f; vec.y = this->dyna.actor.world.pos.y + 560.0f; vec.z = this->dyna.actor.world.pos.z - 377.0f; diff --git a/src/overlays/actors/ovl_Demo_Im/z_demo_im.c b/src/overlays/actors/ovl_Demo_Im/z_demo_im.c index 41b42de04e..39a95aac41 100644 --- a/src/overlays/actors/ovl_Demo_Im/z_demo_im.c +++ b/src/overlays/actors/ovl_Demo_Im/z_demo_im.c @@ -326,7 +326,7 @@ void func_80985430(DemoIm* this, PlayState* play) { void func_8098544C(DemoIm* this, PlayState* play) { s32 pad[2]; - if ((gSaveContext.chamberCutsceneNum == 4) && !IS_CUTSCENE_LAYER) { + if ((gSaveContext.chamberCutsceneNum == CHAMBER_CS_SHADOW) && !IS_CUTSCENE_LAYER) { Player* player = GET_PLAYER(play); this->action = 1; diff --git a/src/overlays/actors/ovl_Demo_Sa/z_demo_sa.c b/src/overlays/actors/ovl_Demo_Sa/z_demo_sa.c index d9ecd19811..20770c0ff0 100644 --- a/src/overlays/actors/ovl_Demo_Sa/z_demo_sa.c +++ b/src/overlays/actors/ovl_Demo_Sa/z_demo_sa.c @@ -253,7 +253,7 @@ void func_8098E960(DemoSa* this, PlayState* play) { s32 pad[2]; Player* player; - if ((gSaveContext.chamberCutsceneNum == 0) && !IS_CUTSCENE_LAYER) { + if ((gSaveContext.chamberCutsceneNum == CHAMBER_CS_FOREST) && !IS_CUTSCENE_LAYER) { player = GET_PLAYER(play); this->action = 1; play->csCtx.script = D_8099010C; diff --git a/src/overlays/actors/ovl_Efc_Erupc/z_efc_erupc.c b/src/overlays/actors/ovl_Efc_Erupc/z_efc_erupc.c index c4c19eff69..6d53836aa1 100644 --- a/src/overlays/actors/ovl_Efc_Erupc/z_efc_erupc.c +++ b/src/overlays/actors/ovl_Efc_Erupc/z_efc_erupc.c @@ -50,7 +50,7 @@ void EfcErupc_UpdateAction(EfcErupc* this, PlayState* play) { Vec3f accel; s32 i; - if (play->csCtx.state != 0) { + if (play->csCtx.state != CS_STATE_IDLE) { if (play->csCtx.actorCues[1] != NULL) { if (play->csCtx.actorCues[1]->id == 2) { if (this->unk_150 == 30) { @@ -73,7 +73,7 @@ void EfcErupc_UpdateAction(EfcErupc* this, PlayState* play) { } } } - if (play->csCtx.state != 0) { + if (play->csCtx.state != CS_STATE_IDLE) { if (play->csCtx.actorCues[2] != NULL) { switch (play->csCtx.actorCues[2]->id) { case 2: @@ -135,7 +135,7 @@ void EfcErupc_Draw(Actor* thisx, PlayState* play) { gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_efc_erupc.c", 321), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - if (play->csCtx.state != 0) { + if (play->csCtx.state != CS_STATE_IDLE) { if ((play->csCtx.actorCues[1] != NULL) && (play->csCtx.actorCues[1]->id == 2)) { gSPDisplayList(POLY_XLU_DISP++, object_efc_erupc_DL_002570); } @@ -144,7 +144,7 @@ void EfcErupc_Draw(Actor* thisx, PlayState* play) { Matrix_Scale(3.4f, 3.4f, 3.4f, MTXMODE_APPLY); gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_efc_erupc.c", 333), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); - if (play->csCtx.state != 0) { + if (play->csCtx.state != CS_STATE_IDLE) { CsCmdActorCue* cue = play->csCtx.actorCues[2]; if (cue != NULL) { diff --git a/src/overlays/actors/ovl_En_Fish/z_en_fish.c b/src/overlays/actors/ovl_En_Fish/z_en_fish.c index 52f27d2f36..e4728a0bfa 100644 --- a/src/overlays/actors/ovl_En_Fish/z_en_fish.c +++ b/src/overlays/actors/ovl_En_Fish/z_en_fish.c @@ -742,7 +742,7 @@ void EnFish_RespawningUpdate(EnFish* this, PlayState* play) { void EnFish_Update(Actor* thisx, PlayState* play) { EnFish* this = (EnFish*)thisx; - if ((D_80A17010 == NULL) && (this->actor.params == FISH_DROPPED) && (play->csCtx.state != 0) && + if ((D_80A17010 == NULL) && (this->actor.params == FISH_DROPPED) && (play->csCtx.state != CS_STATE_IDLE) && (play->csCtx.actorCues[1] != NULL)) { EnFish_SetCutsceneData(this); } diff --git a/src/overlays/actors/ovl_En_Go/z_en_go.c b/src/overlays/actors/ovl_En_Go/z_en_go.c index 689dc6670f..c8bcfc8d46 100644 --- a/src/overlays/actors/ovl_En_Go/z_en_go.c +++ b/src/overlays/actors/ovl_En_Go/z_en_go.c @@ -427,7 +427,7 @@ s32 EnGo_IsCameraModified(EnGo* this, PlayState* play) { return 0; } - xyzDistSq = (this->actor.scale.x / 0.01f) * 10000.0f; + xyzDistSq = (this->actor.scale.x / 0.01f) * SQ(100.0f); if ((this->actor.params & 0xF0) == 0x90) { Camera_ChangeSetting(mainCam, CAM_SET_DIRECTED_YAW); xyzDistSq *= 4.8f; diff --git a/src/overlays/actors/ovl_En_Horse/z_en_horse.c b/src/overlays/actors/ovl_En_Horse/z_en_horse.c index 63be1fc35d..860a74af95 100644 --- a/src/overlays/actors/ovl_En_Horse/z_en_horse.c +++ b/src/overlays/actors/ovl_En_Horse/z_en_horse.c @@ -148,10 +148,10 @@ static ColliderJntSphInit sJntSphInit = { static CollisionCheckInfoInit D_80A65F38 = { 10, 35, 100, MASS_HEAVY }; typedef struct { - s16 sceneId; - Vec3s pos; - s16 angle; -} EnHorseSpawnpoint; + /* 0x0 */ s16 sceneId; + /* 0x2 */ Vec3s pos; + /* 0x8 */ s16 angle; +} EnHorseSpawnpoint; // size = 0xA static EnHorseSpawnpoint sHorseSpawns[] = { { SCENE_HYRULE_FIELD, 16, 0, 1341, 0 }, @@ -330,18 +330,15 @@ static EnHorseSpawnpoint sHorseSpawns[] = { }; typedef struct { - s16 zMin; - s16 zMax; - - s16 xMin; - s16 xMax; - s16 xOffset; - - s16 angle; - s16 angleRange; - - Vec3s pos; -} BridgeJumpPoint; + /* 0x00 */ s16 zMin; + /* 0x02 */ s16 zMax; + /* 0x04 */ s16 xMin; + /* 0x06 */ s16 xMax; + /* 0x08 */ s16 xOffset; + /* 0x0A */ s16 angle; + /* 0x0C */ s16 angleRange; + /* 0x0E */ Vec3s pos; +} BridgeJumpPoint; // size = 0x14 static BridgeJumpPoint sBridgeJumps[] = { { -195, -40, 225, 120, 360, -0x4000, 0x7D0, -270, -52, -117 }, @@ -349,17 +346,17 @@ static BridgeJumpPoint sBridgeJumps[] = { }; typedef struct { - s16 x; - s16 y; - s16 z; - s16 speedXZ; - s16 angle; -} RaceWaypoint; + /* 0x0 */ s16 x; + /* 0x2 */ s16 y; + /* 0x4 */ s16 z; + /* 0x6 */ s16 speedXZ; + /* 0x8 */ s16 angle; +} RaceWaypoint; // size = 0xA typedef struct { - s32 numWaypoints; - RaceWaypoint* waypoints; -} RaceInfo; + /* 0x0 */ s32 numWaypoints; + /* 0x4 */ RaceWaypoint* waypoints; +} RaceInfo; // size = 0x8 static RaceWaypoint sIngoRaceWaypoints[] = { { 1056, 1, -1540, 11, 0x2A8D }, { 1593, 1, -985, 10, 0xFC27 }, { 1645, 1, -221, 11, 0xE891 }, @@ -407,9 +404,9 @@ static EnHorseCsFunc sCutsceneActionFuncs[] = { }; typedef struct { - s32 cueId; - s32 csFuncIdx; -} CsActionEntry; + /* 0x0 */ s32 cueId; + /* 0x4 */ s32 csFuncIdx; +} CsActionEntry; // size = 0x8 static CsActionEntry sCsActionTable[] = { { 36, 1 }, { 37, 2 }, { 38, 3 }, { 64, 4 }, { 65, 5 }, @@ -420,29 +417,29 @@ static RaceWaypoint sHbaWaypoints[] = { { 3600, 1413, -4100, 11, 0x0000 }, { 3600, 1413, 360, 11, 0x0000 }, }; -static RaceInfo sHbaInfo = { 5, sHbaWaypoints }; +static RaceInfo sHbaInfo = { ARRAY_COUNT(sHbaWaypoints), sHbaWaypoints }; static EnHorseActionFunc sActionFuncs[] = { - EnHorse_Frozen, - EnHorse_Inactive, - EnHorse_Idle, - EnHorse_FollowPlayer, - EnHorse_UpdateIngoRace, - EnHorse_MountedIdle, - EnHorse_MountedIdleWhinneying, - EnHorse_MountedTurn, - EnHorse_MountedWalk, - EnHorse_MountedTrot, - EnHorse_MountedGallop, - EnHorse_MountedRearing, - EnHorse_Stopping, - EnHorse_Reverse, - EnHorse_LowJump, - EnHorse_HighJump, - EnHorse_BridgeJump, - EnHorse_CutsceneUpdate, - EnHorse_UpdateHorsebackArchery, - EnHorse_FleePlayer, + EnHorse_Frozen, // ENHORSE_ACT_FROZEN + EnHorse_Inactive, // ENHORSE_ACT_INACTIVE + EnHorse_Idle, // ENHORSE_ACT_IDLE + EnHorse_FollowPlayer, // ENHORSE_ACT_FOLLOW_PLAYER + EnHorse_UpdateIngoRace, // ENHORSE_ACT_INGO_RACE + EnHorse_MountedIdle, // ENHORSE_ACT_MOUNTED_IDLE + EnHorse_MountedIdleWhinneying, // ENHORSE_ACT_MOUNTED_IDLE_WHINNEYING + EnHorse_MountedTurn, // ENHORSE_ACT_MOUNTED_TURN + EnHorse_MountedWalk, // ENHORSE_ACT_MOUNTED_WALK + EnHorse_MountedTrot, // ENHORSE_ACT_MOUNTED_TROT + EnHorse_MountedGallop, // ENHORSE_ACT_MOUNTED_GALLOP + EnHorse_MountedRearing, // ENHORSE_ACT_MOUNTED_REARING + EnHorse_Stopping, // ENHORSE_ACT_STOPPING + EnHorse_Reverse, // ENHORSE_ACT_REVERSE + EnHorse_LowJump, // ENHORSE_ACT_LOW_JUMP + EnHorse_HighJump, // ENHORSE_ACT_HIGH_JUMP + EnHorse_BridgeJump, // ENHORSE_ACT_BRIDGE_JUMP + EnHorse_CutsceneUpdate, // ENHORSE_ACT_CS_UPDATE + EnHorse_UpdateHorsebackArchery, // ENHORSE_ACT_HBA + EnHorse_FleePlayer, // ENHORSE_ACT_FLEE_PLAYER }; s32 EnHorse_BgCheckBridgeJumpPoint(EnHorse* this, PlayState* play) { @@ -460,7 +457,7 @@ s32 EnHorse_BgCheckBridgeJumpPoint(EnHorse* this, PlayState* play) { return false; } - for (i = 0; i < 2; i++) { + for (i = 0; i < ARRAY_COUNT(sBridgeJumps); i++) { xMin = sBridgeJumps[i].xMin; xMax = (xMin + sBridgeJumps[i].xMax) + sBridgeJumps[i].xOffset; if (xMax < xMin) { @@ -492,7 +489,7 @@ s32 EnHorse_CheckBridgeJumps(EnHorse* this, PlayState* play) { return false; } - for (i = 0; i != 2; i++) { + for (i = 0; i < ARRAY_COUNT(sBridgeJumps); i++) { xMin = sBridgeJumps[i].xMin; xMax = sBridgeJumps[i].xMax + xMin; @@ -518,10 +515,10 @@ s32 EnHorse_CheckBridgeJumps(EnHorse* this, PlayState* play) { return false; } -void EnHorse_RaceWaypointPos(RaceWaypoint* waypoints, s32 idx, Vec3f* pos) { - pos->x = waypoints[idx].x; - pos->y = waypoints[idx].y; - pos->z = waypoints[idx].z; +void EnHorse_RaceWaypointPos(RaceWaypoint* waypoints, s32 index, Vec3f* pos) { + pos->x = waypoints[index].x; + pos->y = waypoints[index].y; + pos->z = waypoints[index].z; } void EnHorse_RotateToPoint(EnHorse* this, PlayState* play, Vec3f* pos, s16 turnAmount) { @@ -672,7 +669,7 @@ s32 EnHorse_Spawn(EnHorse* this, PlayState* play) { Player* player; Vec3f spawnPos; - for (i = 0; i < 169; i++) { + for (i = 0; i < ARRAY_COUNT(sHorseSpawns); i++) { if (sHorseSpawns[i].sceneId == play->sceneId) { player = GET_PLAYER(play); if (play->sceneId != SCENE_LON_LON_RANCH || @@ -690,7 +687,7 @@ s32 EnHorse_Spawn(EnHorse* this, PlayState* play) { dist = Math3D_Vec3f_DistXYZ(&player->actor.world.pos, &spawnPos); if (play->sceneId) {} - if (!(minDist < dist) && !func_80A5BBBC(play, this, &spawnPos)) { + if (!((minDist < dist) || func_80A5BBBC(play, this, &spawnPos))) { minDist = dist; this->actor.world.pos.x = sHorseSpawns[i].pos.x; this->actor.world.pos.y = sHorseSpawns[i].pos.y; @@ -723,7 +720,7 @@ s32 EnHorse_PlayerCanMove(EnHorse* this, PlayState* play) { if ((player->stateFlags1 & PLAYER_STATE1_0) || func_8002DD78(GET_PLAYER(play)) == 1 || (player->stateFlags1 & PLAYER_STATE1_20) || ((this->stateFlags & ENHORSE_FLAG_19) && !this->inRace) || - this->action == ENHORSE_ACT_HBA || player->actor.flags & ACTOR_FLAG_8 || play->csCtx.state != 0) { + this->action == ENHORSE_ACT_HBA || player->actor.flags & ACTOR_FLAG_8 || play->csCtx.state != CS_STATE_IDLE) { return false; } return true; @@ -945,7 +942,7 @@ void EnHorse_Frozen(EnHorse* this, PlayState* play) { EnHorse_StartMountedIdleResetAnim(this); } else if (this->actor.params == 9) { this->actor.params = 5; - if (play->csCtx.state != 0) { + if (play->csCtx.state != CS_STATE_IDLE) { EnHorse_StartMountedIdle(this); } else { this->actor.speed = 8.0f; @@ -1998,17 +1995,17 @@ void EnHorse_InitIngoHorse(EnHorse* this) { } } -void EnHorse_SetIngoAnimation(s32 idx, f32 curFrame, s32 arg2, s16* animIdxOut, f32* curFrameOut) { - *animIdxOut = sIngoAnimations[idx]; +void EnHorse_SetIngoAnimation(s32 index, f32 curFrame, s32 arg2, s16* animIdxOut, f32* curFrameOut) { + *animIdxOut = sIngoAnimations[index]; *curFrameOut = curFrame; - if (idx == 3 || idx == 7 || idx == 8 || idx == 4) { + if ((index == 3) || (index == 7) || (index == 8) || (index == 4)) { *curFrameOut = 0.0f; } if (arg2 == 1) { - if (idx == 5) { + if (index == 5) { *animIdxOut = 4; *curFrameOut = curFrame; - } else if (idx == 6) { + } else if (index == 6) { *animIdxOut = 3; *curFrameOut = curFrame; } diff --git a/src/overlays/actors/ovl_En_Ko/z_en_ko.c b/src/overlays/actors/ovl_En_Ko/z_en_ko.c index 83e3d6547f..d0f6538da2 100644 --- a/src/overlays/actors/ovl_En_Ko/z_en_ko.c +++ b/src/overlays/actors/ovl_En_Ko/z_en_ko.c @@ -957,7 +957,7 @@ s32 EnKo_AdultSaved(EnKo* this, PlayState* play) { void func_80A9877C(EnKo* this, PlayState* play) { Player* player = GET_PLAYER(play); - if ((play->csCtx.state != 0) || gDebugCamEnabled) { + if ((play->csCtx.state != CS_STATE_IDLE) || gDebugCamEnabled) { this->interactInfo.trackPos = play->view.eye; this->interactInfo.yOffset = 40.0f; if (ENKO_TYPE != ENKO_TYPE_CHILD_0) { diff --git a/src/overlays/actors/ovl_En_Nb/z_en_nb.c b/src/overlays/actors/ovl_En_Nb/z_en_nb.c index cc3aced0c9..91bafad3ec 100644 --- a/src/overlays/actors/ovl_En_Nb/z_en_nb.c +++ b/src/overlays/actors/ovl_En_Nb/z_en_nb.c @@ -341,7 +341,7 @@ void EnNb_SetupChamberCsImpl(EnNb* this, PlayState* play) { s32 pad[2]; Player* player; - if ((gSaveContext.chamberCutsceneNum == 3) && !IS_CUTSCENE_LAYER) { + if ((gSaveContext.chamberCutsceneNum == CHAMBER_CS_SPIRIT) && !IS_CUTSCENE_LAYER) { player = GET_PLAYER(play); this->action = NB_CHAMBER_UNDERGROUND; play->csCtx.script = D_80AB431C; diff --git a/src/overlays/actors/ovl_En_Owl/z_en_owl.c b/src/overlays/actors/ovl_En_Owl/z_en_owl.c index d53918d3a7..463b39f892 100644 --- a/src/overlays/actors/ovl_En_Owl/z_en_owl.c +++ b/src/overlays/actors/ovl_En_Owl/z_en_owl.c @@ -753,7 +753,7 @@ void func_80ACB748(EnOwl* this, PlayState* play) { case 8: case 9: func_800F436C(&D_80ACD62C, NA_SE_EV_FLYING_AIR - SFX_FLAG, weight * 2.0f); - if ((play->csCtx.curFrame >= 420) || ((0xC1 < play->csCtx.curFrame && (play->csCtx.curFrame <= 280)))) { + if ((play->csCtx.curFrame >= 420) || ((193 < play->csCtx.curFrame && (play->csCtx.curFrame <= 280)))) { func_800F4414(&D_80ACD62C, NA_SE_EN_OWL_FLUTTER, weight * 2.0f); } if (play->csCtx.curFrame == 217) { diff --git a/src/overlays/actors/ovl_En_Reeba/z_en_reeba.c b/src/overlays/actors/ovl_En_Reeba/z_en_reeba.c index 565c291d47..f1e5c4d263 100644 --- a/src/overlays/actors/ovl_En_Reeba/z_en_reeba.c +++ b/src/overlays/actors/ovl_En_Reeba/z_en_reeba.c @@ -536,7 +536,6 @@ void EnReeba_CheckDamage(EnReeba* this, PlayState* play) { this->stunType = LEEVER_STUN_NONE; switch (this->actor.colChkInfo.damageEffect) { - case LEEVER_DMGEFF_UNUSED: case LEEVER_DMGEFF_BOOMERANG: if ((this->actor.colChkInfo.health > 1) && (this->stunType != LEEVER_STUN_OTHER)) { diff --git a/src/overlays/actors/ovl_En_Ru1/z_en_ru1.c b/src/overlays/actors/ovl_En_Ru1/z_en_ru1.c index 1e9ccb6042..545bc7d0fd 100644 --- a/src/overlays/actors/ovl_En_Ru1/z_en_ru1.c +++ b/src/overlays/actors/ovl_En_Ru1/z_en_ru1.c @@ -7,6 +7,7 @@ #include "z_en_ru1.h" #include "assets/objects/object_ru1/object_ru1.h" #include "terminal.h" +#include "overlays/actors/ovl_Demo_Effect/z_demo_effect.h" #define FLAGS (ACTOR_FLAG_0 | ACTOR_FLAG_4 | ACTOR_FLAG_26) @@ -324,7 +325,7 @@ Actor* func_80AEB124(PlayState* play) { Actor* actorIt = play->actorCtx.actorLists[ACTORCAT_BOSS].head; while (actorIt != NULL) { - if ((actorIt->id == ACTOR_DEMO_EFFECT) && ((actorIt->params & 0xFF) == 0x15)) { + if ((actorIt->id == ACTOR_DEMO_EFFECT) && ((actorIt->params & 0xFF) == DEMO_EFFECT_JEWEL_ZORA)) { return actorIt; } actorIt = actorIt->next; @@ -586,7 +587,7 @@ void func_80AEBBF4(EnRu1* this) { void func_80AEBC30(PlayState* play) { Player* player; - if (play->csCtx.curFrame == 0xCD) { + if (play->csCtx.curFrame == 205) { player = GET_PLAYER(play); Audio_PlaySfxGeneral(NA_SE_EV_DIVE_INTO_WATER, &player->actor.projectedPos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); @@ -594,7 +595,7 @@ void func_80AEBC30(PlayState* play) { } void func_80AEBC84(EnRu1* this, PlayState* play) { - if (play->csCtx.curFrame == 0x82) { + if (play->csCtx.curFrame == 130) { func_80078914(&this->actor.projectedPos, NA_SE_VO_RT_LAUGH_0); } } diff --git a/src/overlays/actors/ovl_En_Ru2/z_en_ru2.c b/src/overlays/actors/ovl_En_Ru2/z_en_ru2.c index c140b24269..d50bdd8f86 100644 --- a/src/overlays/actors/ovl_En_Ru2/z_en_ru2.c +++ b/src/overlays/actors/ovl_En_Ru2/z_en_ru2.c @@ -115,7 +115,7 @@ void func_80AF2608(EnRu2* this) { s16* unk_2A6 = &this->unk_2A6; s16* unk_2A4 = &this->unk_2A4; - if (!DECR(*unk_2A6)) { + if (DECR(*unk_2A6) == 0) { *unk_2A6 = Rand_S16Offset(0x3C, 0x3C); } @@ -263,7 +263,7 @@ void func_80AF2AB4(EnRu2* this, PlayState* play) { Player* player; s16 temp; - if ((gSaveContext.chamberCutsceneNum == 2) && !IS_CUTSCENE_LAYER) { + if ((gSaveContext.chamberCutsceneNum == CHAMBER_CS_WATER) && !IS_CUTSCENE_LAYER) { player = GET_PLAYER(play); this->action = 1; play->csCtx.script = D_80AF411C; diff --git a/src/overlays/actors/ovl_En_Xc/z_en_xc.c b/src/overlays/actors/ovl_En_Xc/z_en_xc.c index 64757c5040..b926b4087a 100644 --- a/src/overlays/actors/ovl_En_Xc/z_en_xc.c +++ b/src/overlays/actors/ovl_En_Xc/z_en_xc.c @@ -88,7 +88,7 @@ void EnXc_SetEyePattern(EnXc* this) { s16* blinkTimer = &this->blinkTimer; s16* eyePattern = &this->eyeIdx; - if (!DECR(*blinkTimer)) { + if (DECR(*blinkTimer) == 0) { *blinkTimer = Rand_S16Offset(60, 60); } @@ -120,7 +120,7 @@ s32 EnXc_AnimIsFinished(EnXc* this) { CsCmdActorCue* EnXc_GetCue(PlayState* play, s32 cueChannel) { CsCmdActorCue* cue = NULL; - if (play->csCtx.state != 0) { + if (play->csCtx.state != CS_STATE_IDLE) { cue = play->csCtx.actorCues[cueChannel]; } return cue; @@ -422,15 +422,15 @@ void EnXc_SetColossusAppearSFX(EnXc* this, PlayState* play) { sceneId = play->sceneId; if (sceneId == SCENE_DESERT_COLOSSUS) { CutsceneContext* csCtx = &play->csCtx; - u16 frameCount = csCtx->curFrame; + u16 csCurFrame = csCtx->curFrame; f32 wDest[2]; - if (frameCount == 119) { + if (csCurFrame == 119) { Vec3f pos = { -611.0f, 728.0f, -2.0f }; SkinMatrix_Vec3fMtxFMultXYZW(&play->viewProjectionMtxF, &pos, &sXyzDist, wDest); func_80078914(&sXyzDist, NA_SE_EV_JUMP_CONC); - } else if (frameCount == 164) { + } else if (csCurFrame == 164) { Vec3f pos = { -1069.0f, 38.0f, 0.0f }; s32 pad; @@ -462,9 +462,9 @@ void EnXc_SetColossusWindSFX(PlayState* play) { if (sceneId == SCENE_DESERT_COLOSSUS) { CutsceneContext* csCtx = &play->csCtx; - u16 frameCount = csCtx->curFrame; + u16 csCurFrame = csCtx->curFrame; - if ((frameCount >= 120) && (frameCount < 164)) { + if ((csCurFrame >= 120) && (csCurFrame < 164)) { s32 pad; Vec3f* eye = &play->view.eye; @@ -723,9 +723,8 @@ void func_80B3DAF0(EnXc* this, PlayState* play) { cueId = cue->id; if (cueId == 3 || cueId == 11 || cueId == 12 || cueId == 13 || cueId == 23) { - f32 frameCount; + f32 frameCount = Animation_GetLastFrame(&gSheikPullingOutHarpAnim); - frameCount = Animation_GetLastFrame(&gSheikPullingOutHarpAnim); Animation_Change(&this->skelAnime, &gSheikPullingOutHarpAnim, 1.0f, 0.0f, frameCount, ANIMMODE_ONCE, -4.0f); this->action = SHEIK_ACTION_7; this->drawMode = SHEIK_DRAW_PULLING_OUT_HARP; @@ -765,7 +764,7 @@ void EnXc_SetupPlayingHarpAction(EnXc* this, PlayState* play, s32 animFinished) void func_80B3DCA8(EnXc* this, PlayState* play) { f32 frameCount; - if (play->csCtx.state != 0) { + if (play->csCtx.state != CS_STATE_IDLE) { CsCmdActorCue* cue = play->csCtx.actorCues[4]; if (cue != NULL && cue->id == 8) { @@ -814,7 +813,7 @@ void func_80B3DE78(EnXc* this, s32 animFinished) { } void EnXc_SetupReverseAccel(EnXc* this, PlayState* play) { - if (play->csCtx.state != 0) { + if (play->csCtx.state != CS_STATE_IDLE) { CsCmdActorCue* cue = play->csCtx.actorCues[4]; if (cue != NULL && cue->id == 4) { @@ -866,7 +865,7 @@ void func_80B3E164(EnXc* this, PlayState* play) { } void EnXc_SetupDisappear(EnXc* this, PlayState* play) { - if (play->csCtx.state != 0) { + if (play->csCtx.state != CS_STATE_IDLE) { CsCmdActorCue* cue = play->csCtx.actorCues[4]; if (cue != NULL && cue->id == 9) { @@ -1400,9 +1399,9 @@ void EnXc_LakeHyliaDive(PlayState* play) { void func_80B3F534(PlayState* play) { CutsceneContext* csCtx = &play->csCtx; - u16 frameCount = csCtx->curFrame; + u16 csCurFrame = csCtx->curFrame; - if (frameCount == 310) { + if (csCurFrame == 310) { Actor_Spawn(&play->actorCtx, play, ACTOR_DOOR_WARP1, -1044.0f, -1243.0f, 7458.0f, 0, 0, 0, WARP_DESTINATION); } } diff --git a/src/overlays/actors/ovl_En_Zl2/z_en_zl2.c b/src/overlays/actors/ovl_En_Zl2/z_en_zl2.c index 544a3422aa..915579331e 100644 --- a/src/overlays/actors/ovl_En_Zl2/z_en_zl2.c +++ b/src/overlays/actors/ovl_En_Zl2/z_en_zl2.c @@ -1233,9 +1233,9 @@ void func_80B5154C(EnZl2* this, PlayState* play) { EnZl2_UpdateEyes(this); } else { csCtx = &play->csCtx; - if (csCtx->curFrame < 0x5F0) { + if (csCtx->curFrame < 1520) { func_80B4EBB8(this); - } else if (csCtx->curFrame == 0x5F0) { + } else if (csCtx->curFrame == 1520) { this->unk_27C = 0.0f; } else { func_80B4EC48(this); diff --git a/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c b/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c index 11bd9849b4..5cc51f5abf 100644 --- a/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c +++ b/src/overlays/actors/ovl_Object_Kankyo/z_object_kankyo.c @@ -722,7 +722,7 @@ void ObjectKankyo_DrawSnow(Actor* thisx, PlayState* play2) { } void ObjectKankyo_Lightning(ObjectKankyo* this, PlayState* play) { - if (play->csCtx.state != 0 && play->csCtx.actorCues[0] != NULL) { + if (play->csCtx.state != CS_STATE_IDLE && play->csCtx.actorCues[0] != NULL) { switch (this->effects[0].state) { case 0: this->effects[0].timer = 0; @@ -797,7 +797,7 @@ void ObjectKankyo_WaitForSunGraveSparkObject(ObjectKankyo* this, PlayState* play } void ObjectKankyo_SunGraveSpark(ObjectKankyo* this, PlayState* play) { - if (play->csCtx.state != 0) { + if (play->csCtx.state != CS_STATE_IDLE) { if (play->csCtx.actorCues[1] != NULL && play->csCtx.actorCues[1]->id == 2) { Actor_PlaySfx(&this->actor, NA_SE_EN_BIRI_SPARK - SFX_FLAG); if ((s16)this->effects[0].alpha + 20 > 255) { @@ -818,7 +818,7 @@ void ObjectKankyo_DrawSunGraveSpark(Actor* thisx, PlayState* play2) { f32 weight; OPEN_DISPS(play->state.gfxCtx, "../z_object_kankyo.c", 1324); - if (play->csCtx.state != 0) { + if (play->csCtx.state != CS_STATE_IDLE) { if (play->csCtx.actorCues[1] != NULL && play->csCtx.actorCues[1]->id == 2 && this->requiredObjectLoaded) { // apparently, light waves with larger amplitudes look brighter, so the name 'amplitude' kind of works here if (this->effects[0].state == 0) { @@ -896,7 +896,7 @@ void ObjectKankyo_WaitForBeamObject(ObjectKankyo* this, PlayState* play) { void ObjectKankyo_Beams(ObjectKankyo* this, PlayState* play) { u8 i; - if (play->csCtx.state != 0) { + if (play->csCtx.state != CS_STATE_IDLE) { for (i = 0; i < 6; i++) { if (play->csCtx.actorCues[i + 1] != NULL && play->csCtx.actorCues[i + 1]->id == 2) { if (this->effects[i].size == 0.1f) { diff --git a/src/overlays/actors/ovl_player_actor/z_player.c b/src/overlays/actors/ovl_player_actor/z_player.c index 422c5e24b6..77715481ae 100644 --- a/src/overlays/actors/ovl_player_actor/z_player.c +++ b/src/overlays/actors/ovl_player_actor/z_player.c @@ -11922,9 +11922,9 @@ void func_8084CBF4(Player* this, f32 arg1, f32 arg2) { if ((this->unk_878 != 0.0f) && (arg2 <= this->skelAnime.curFrame)) { if (arg1 < fabsf(this->unk_878)) { if (this->unk_878 >= 0.0f) { - dir = 1; + dir = 1.0f; } else { - dir = -1; + dir = -1.0f; } temp = dir * arg1; } else { @@ -13052,7 +13052,7 @@ void func_8084F698(Player* this, PlayState* play) { void func_8084F710(Player* this, PlayState* play) { s32 pad; - if ((this->unk_84F != 0) && (play->csCtx.curFrame < 0x131)) { + if ((this->unk_84F != 0) && (play->csCtx.curFrame < 305)) { this->actor.gravity = 0.0f; this->actor.velocity.y = 0.0f; } else if (D_80853600 < 150.0f) { diff --git a/src/overlays/gamestates/ovl_file_choose/z_file_choose.c b/src/overlays/gamestates/ovl_file_choose/z_file_choose.c index 18f90b6278..4205e2ad25 100644 --- a/src/overlays/gamestates/ovl_file_choose/z_file_choose.c +++ b/src/overlays/gamestates/ovl_file_choose/z_file_choose.c @@ -1482,7 +1482,7 @@ void FileSelect_LoadGame(GameState* thisx) { gSaveContext.nextTransitionType = TRANS_NEXT_TYPE_DEFAULT; gSaveContext.nextCutsceneIndex = 0xFFEF; gSaveContext.cutsceneTrigger = 0; - gSaveContext.chamberCutsceneNum = 0; + gSaveContext.chamberCutsceneNum = CHAMBER_CS_FOREST; gSaveContext.nextDayTime = NEXT_TIME_NONE; gSaveContext.retainWeatherMode = false; diff --git a/src/overlays/gamestates/ovl_file_choose/z_file_copy_erase.c b/src/overlays/gamestates/ovl_file_choose/z_file_copy_erase.c index b8fdbb1d7c..29a4e8950a 100644 --- a/src/overlays/gamestates/ovl_file_choose/z_file_copy_erase.c +++ b/src/overlays/gamestates/ovl_file_choose/z_file_copy_erase.c @@ -828,7 +828,7 @@ void FileSelect_SetupEraseConfirm2(GameState* thisx) { } /** - * Allow the player to confirm their chioce to erase or return back to erase select. + * Allow the player to confirm their choice to erase or return back to erase select. * Update function for `CM_ERASE_CONFIRM` */ void FileSelect_EraseConfirm(GameState* thisx) { diff --git a/sym_info.py b/sym_info.py index 753fb9a1a1..4fb7aa220d 100755 --- a/sym_info.py +++ b/sym_info.py @@ -1,139 +1,29 @@ #!/usr/bin/env python3 -import os.path import argparse +from pathlib import Path -parser = argparse.ArgumentParser( - description="Display various information about a symbol or address." -) -parser.add_argument( - "name", - type=str, - default="", - help="symbol name or ROM/RAM address to lookup" -) -parser.add_argument( - "-e", - "--expected", - dest="use_expected", - action="store_true", - help="use the map file in expected/build/ instead of build/" -) -args = parser.parse_args() - -mymap = "build/z64.map" -if args.use_expected: - mymap = f"expected/{mymap}" - -if not os.path.isfile(mymap): - print(f"{mymap} must exist.") +try: + import mapfile_parser +except ImportError: + print("Missing dependency mapfile_parser, install it with `python3 -m pip install 'mapfile-parser>=1.2.1,<2.0.0'`") exit(1) -def search_address(target_addr): - is_ram = target_addr & 0x80000000 - ram_offset = None - prev_ram = 0 - prev_rom = 0 - prev_sym = "" - cur_file = "" - prev_file = cur_file - prev_line = "" - with open(mymap) as f: - for line in f: - if "load address" in line: - # Ignore .bss sections if we're looking for a ROM address - if not is_ram and (".bss" in line or ".bss" in prev_line): - ram_offset = None - continue - ram = int(line[16 : 16 + 18], 0) - rom = int(line[59 : 59 + 18], 0) - ram_offset = ram - rom - continue +def symInfoMain(): + parser = argparse.ArgumentParser(description="Display various information about a symbol or address.") + parser.add_argument("symname", help="symbol name or VROM/VRAM address to lookup") + parser.add_argument("-e", "--expected", dest="use_expected", action="store_true", help="use the map file in expected/build/ instead of build/") - prev_line = line + args = parser.parse_args() - if ( - ram_offset is None - or "=" in line - or "*fill*" in line - or " 0x" not in line - ): - continue + BUILTMAP = Path(f"build") / f"z64.map" - ram = int(line[16 : 16 + 18], 0) - rom = ram - ram_offset - sym = line.split()[-1] + mapPath = BUILTMAP + if args.use_expected: + mapPath = "expected" / BUILTMAP - if sym.startswith("0x"): - ram_offset = None - continue - if "/" in sym: - cur_file = sym - continue + mapfile_parser.frontends.sym_info.doSymInfo(mapPath, args.symname) - if rom == target_addr or (is_ram and ram == target_addr): - return f"{sym} (RAM 0x{ram:X}, ROM 0x{rom:X}, {cur_file})" - if rom > target_addr or (is_ram and ram > target_addr): - offset = target_addr - prev_ram if is_ram else target_addr - prev_rom - return f"at 0x{offset:X} bytes inside {prev_sym} (RAM 0x{prev_ram:X}, ROM 0x{prev_rom:X}, {prev_file})" - - prev_ram = ram - prev_rom = rom - prev_sym = sym - prev_file = cur_file - - return "at end of rom?" - - -def search_symbol(target_sym): - ram_offset = None - cur_file = "" - prev_line = "" - with open(mymap) as f: - for line in f: - if "load address" in line: - ram = int(line[16 : 16 + 18], 0) - rom = int(line[59 : 59 + 18], 0) - ram_offset = ram - rom - continue - - prev_line = line - - if ( - ram_offset is None - or "=" in line - or "*fill*" in line - or " 0x" not in line - ): - continue - - ram = int(line[16 : 16 + 18], 0) - rom = ram - ram_offset - sym = line.split()[-1] - - if sym.startswith("0x"): - ram_offset = None - continue - elif "/" in sym: - cur_file = sym - continue - - if sym == target_sym: - return (rom, cur_file, ram) - - return None - - -try: - target_addr = int(args.name, 0) - print(args.name, "is", search_address(target_addr)) -except ValueError: - sym_info = search_symbol(args.name) - if sym_info is not None: - sym_rom = sym_info[0] - sym_file = sym_info[1] - sym_ram = sym_info[2] - print(f"Symbol {args.name} (RAM: 0x{sym_ram:08X}, ROM: 0x{sym_rom:06X}, {sym_file})") - else: - print(f"Symbol {args.name} not found in map file {mymap}") +if __name__ == "__main__": + symInfoMain() diff --git a/tools/assist.py b/tools/assist.py index 53c9bcd936..587cd5e1fc 100755 --- a/tools/assist.py +++ b/tools/assist.py @@ -1,11 +1,11 @@ -#!/usr/bin/python3 +#!/usr/bin/env python3 import argparse -from collections import OrderedDict import os -import re -import pickle import sys +from collections import OrderedDict + +gAddressWidth = 18 # if your ld >= 2.40 change this to 10 script_dir = os.path.dirname(os.path.realpath(__file__)) root_dir = script_dir + "/../" @@ -54,8 +54,8 @@ def parse_map(fname): if "noload" in line or "noload" in prev_line: ram_offset = None continue - ram = int(line[16 : 16 + 18], 0) - rom = int(line[59 : 59 + 18], 0) + ram = int(line[16 : 16 + gAddressWidth], 0) + rom = int(line[16 + gAddressWidth + 25 : 16 + gAddressWidth + 25 + gAddressWidth], 0) ram_offset = ram - rom continue prev_line = line @@ -67,7 +67,7 @@ def parse_map(fname): or " 0x" not in line ): continue - ram = int(line[16 : 16 + 18], 0) + ram = int(line[16 : 16 + gAddressWidth], 0) rom = ram - ram_offset fn = line.split()[-1] if "0x" in fn: diff --git a/tools/ido_recomp/linux/5.3/as0 b/tools/ido_recomp/linux/5.3/as0 index 15c1691077..cdac712e5f 100755 Binary files a/tools/ido_recomp/linux/5.3/as0 and b/tools/ido_recomp/linux/5.3/as0 differ diff --git a/tools/ido_recomp/linux/5.3/as1 b/tools/ido_recomp/linux/5.3/as1 index 1a24f18b28..f89911f80f 100755 Binary files a/tools/ido_recomp/linux/5.3/as1 and b/tools/ido_recomp/linux/5.3/as1 differ diff --git a/tools/ido_recomp/linux/5.3/cc b/tools/ido_recomp/linux/5.3/cc index 65f0d1b2d2..be5bed557d 100755 Binary files a/tools/ido_recomp/linux/5.3/cc and b/tools/ido_recomp/linux/5.3/cc differ diff --git a/tools/ido_recomp/linux/5.3/cfe b/tools/ido_recomp/linux/5.3/cfe index cbb4f9d441..c257f65a62 100755 Binary files a/tools/ido_recomp/linux/5.3/cfe and b/tools/ido_recomp/linux/5.3/cfe differ diff --git a/tools/ido_recomp/linux/5.3/ugen b/tools/ido_recomp/linux/5.3/ugen index 119d2817bc..d356300bfc 100755 Binary files a/tools/ido_recomp/linux/5.3/ugen and b/tools/ido_recomp/linux/5.3/ugen differ diff --git a/tools/ido_recomp/linux/5.3/ujoin b/tools/ido_recomp/linux/5.3/ujoin index 4091986a86..5a3162799e 100755 Binary files a/tools/ido_recomp/linux/5.3/ujoin and b/tools/ido_recomp/linux/5.3/ujoin differ diff --git a/tools/ido_recomp/linux/5.3/uld b/tools/ido_recomp/linux/5.3/uld index 653ff37dfa..a65a2239ba 100755 Binary files a/tools/ido_recomp/linux/5.3/uld and b/tools/ido_recomp/linux/5.3/uld differ diff --git a/tools/ido_recomp/linux/5.3/umerge b/tools/ido_recomp/linux/5.3/umerge index 4b00ffa36c..36fa5ac6e6 100755 Binary files a/tools/ido_recomp/linux/5.3/umerge and b/tools/ido_recomp/linux/5.3/umerge differ diff --git a/tools/ido_recomp/linux/5.3/uopt b/tools/ido_recomp/linux/5.3/uopt index d5ba32fbd9..f446420873 100755 Binary files a/tools/ido_recomp/linux/5.3/uopt and b/tools/ido_recomp/linux/5.3/uopt differ diff --git a/tools/ido_recomp/linux/5.3/usplit b/tools/ido_recomp/linux/5.3/usplit index 17d9d3d5d3..5aa4151ed4 100755 Binary files a/tools/ido_recomp/linux/5.3/usplit and b/tools/ido_recomp/linux/5.3/usplit differ diff --git a/tools/ido_recomp/linux/7.1/as0 b/tools/ido_recomp/linux/7.1/as0 index e9ef71c63b..1a69a14a5b 100755 Binary files a/tools/ido_recomp/linux/7.1/as0 and b/tools/ido_recomp/linux/7.1/as0 differ diff --git a/tools/ido_recomp/linux/7.1/as1 b/tools/ido_recomp/linux/7.1/as1 index 4750790630..047cfdd7fd 100755 Binary files a/tools/ido_recomp/linux/7.1/as1 and b/tools/ido_recomp/linux/7.1/as1 differ diff --git a/tools/ido_recomp/linux/7.1/cc b/tools/ido_recomp/linux/7.1/cc index 6c68698f36..61c43ede1a 100755 Binary files a/tools/ido_recomp/linux/7.1/cc and b/tools/ido_recomp/linux/7.1/cc differ diff --git a/tools/ido_recomp/linux/7.1/cfe b/tools/ido_recomp/linux/7.1/cfe index 2b52669deb..75235c1125 100755 Binary files a/tools/ido_recomp/linux/7.1/cfe and b/tools/ido_recomp/linux/7.1/cfe differ diff --git a/tools/ido_recomp/linux/7.1/ugen b/tools/ido_recomp/linux/7.1/ugen index 340a282c9e..32d8d0be6e 100755 Binary files a/tools/ido_recomp/linux/7.1/ugen and b/tools/ido_recomp/linux/7.1/ugen differ diff --git a/tools/ido_recomp/linux/7.1/ujoin b/tools/ido_recomp/linux/7.1/ujoin index 3752698d8a..49b35ba6a5 100755 Binary files a/tools/ido_recomp/linux/7.1/ujoin and b/tools/ido_recomp/linux/7.1/ujoin differ diff --git a/tools/ido_recomp/linux/7.1/uld b/tools/ido_recomp/linux/7.1/uld index 2b76d0c18b..756d30cd43 100755 Binary files a/tools/ido_recomp/linux/7.1/uld and b/tools/ido_recomp/linux/7.1/uld differ diff --git a/tools/ido_recomp/linux/7.1/umerge b/tools/ido_recomp/linux/7.1/umerge index 03d68a8f24..569e56e767 100755 Binary files a/tools/ido_recomp/linux/7.1/umerge and b/tools/ido_recomp/linux/7.1/umerge differ diff --git a/tools/ido_recomp/linux/7.1/uopt b/tools/ido_recomp/linux/7.1/uopt index feef7f7491..349d1d6ffd 100755 Binary files a/tools/ido_recomp/linux/7.1/uopt and b/tools/ido_recomp/linux/7.1/uopt differ diff --git a/tools/ido_recomp/linux/7.1/usplit b/tools/ido_recomp/linux/7.1/usplit index 090200ab5c..563c5f8a2e 100755 Binary files a/tools/ido_recomp/linux/7.1/usplit and b/tools/ido_recomp/linux/7.1/usplit differ diff --git a/tools/ido_recomp/macos/5.3/as0 b/tools/ido_recomp/macos/5.3/as0 index 46e69e09bd..1d2b7a7254 100755 Binary files a/tools/ido_recomp/macos/5.3/as0 and b/tools/ido_recomp/macos/5.3/as0 differ diff --git a/tools/ido_recomp/macos/5.3/as1 b/tools/ido_recomp/macos/5.3/as1 index f723cc5c1c..44fada1c50 100755 Binary files a/tools/ido_recomp/macos/5.3/as1 and b/tools/ido_recomp/macos/5.3/as1 differ diff --git a/tools/ido_recomp/macos/5.3/cc b/tools/ido_recomp/macos/5.3/cc index d583c6b5bd..9e3c8f8c99 100755 Binary files a/tools/ido_recomp/macos/5.3/cc and b/tools/ido_recomp/macos/5.3/cc differ diff --git a/tools/ido_recomp/macos/5.3/cfe b/tools/ido_recomp/macos/5.3/cfe index 92f76465ac..86d98c79d3 100755 Binary files a/tools/ido_recomp/macos/5.3/cfe and b/tools/ido_recomp/macos/5.3/cfe differ diff --git a/tools/ido_recomp/macos/5.3/ugen b/tools/ido_recomp/macos/5.3/ugen index 7be477312d..add44a34df 100755 Binary files a/tools/ido_recomp/macos/5.3/ugen and b/tools/ido_recomp/macos/5.3/ugen differ diff --git a/tools/ido_recomp/macos/5.3/ujoin b/tools/ido_recomp/macos/5.3/ujoin index e69611f41e..5e7ed4789d 100755 Binary files a/tools/ido_recomp/macos/5.3/ujoin and b/tools/ido_recomp/macos/5.3/ujoin differ diff --git a/tools/ido_recomp/macos/5.3/uld b/tools/ido_recomp/macos/5.3/uld index 2bcce1cd6c..64fc3899cf 100755 Binary files a/tools/ido_recomp/macos/5.3/uld and b/tools/ido_recomp/macos/5.3/uld differ diff --git a/tools/ido_recomp/macos/5.3/umerge b/tools/ido_recomp/macos/5.3/umerge index 7fdf06e8de..c66ef9f2fb 100755 Binary files a/tools/ido_recomp/macos/5.3/umerge and b/tools/ido_recomp/macos/5.3/umerge differ diff --git a/tools/ido_recomp/macos/5.3/uopt b/tools/ido_recomp/macos/5.3/uopt index e9b8cbe626..0872f9c171 100755 Binary files a/tools/ido_recomp/macos/5.3/uopt and b/tools/ido_recomp/macos/5.3/uopt differ diff --git a/tools/ido_recomp/macos/5.3/usplit b/tools/ido_recomp/macos/5.3/usplit index cb28e320cd..2a7c351880 100755 Binary files a/tools/ido_recomp/macos/5.3/usplit and b/tools/ido_recomp/macos/5.3/usplit differ diff --git a/tools/ido_recomp/macos/7.1/as0 b/tools/ido_recomp/macos/7.1/as0 index cdb4f91213..9a2fd2f0af 100755 Binary files a/tools/ido_recomp/macos/7.1/as0 and b/tools/ido_recomp/macos/7.1/as0 differ diff --git a/tools/ido_recomp/macos/7.1/as1 b/tools/ido_recomp/macos/7.1/as1 index 93370b4950..e91f7d1a2f 100755 Binary files a/tools/ido_recomp/macos/7.1/as1 and b/tools/ido_recomp/macos/7.1/as1 differ diff --git a/tools/ido_recomp/macos/7.1/cc b/tools/ido_recomp/macos/7.1/cc index 96d45690b8..b487956f20 100755 Binary files a/tools/ido_recomp/macos/7.1/cc and b/tools/ido_recomp/macos/7.1/cc differ diff --git a/tools/ido_recomp/macos/7.1/cfe b/tools/ido_recomp/macos/7.1/cfe index a9f0b56fc8..f86fc3743f 100755 Binary files a/tools/ido_recomp/macos/7.1/cfe and b/tools/ido_recomp/macos/7.1/cfe differ diff --git a/tools/ido_recomp/macos/7.1/ugen b/tools/ido_recomp/macos/7.1/ugen index 801337b485..1e9839b4eb 100755 Binary files a/tools/ido_recomp/macos/7.1/ugen and b/tools/ido_recomp/macos/7.1/ugen differ diff --git a/tools/ido_recomp/macos/7.1/ujoin b/tools/ido_recomp/macos/7.1/ujoin index 620e624f01..d2512e9341 100755 Binary files a/tools/ido_recomp/macos/7.1/ujoin and b/tools/ido_recomp/macos/7.1/ujoin differ diff --git a/tools/ido_recomp/macos/7.1/uld b/tools/ido_recomp/macos/7.1/uld index a7826480f3..a746a8236e 100755 Binary files a/tools/ido_recomp/macos/7.1/uld and b/tools/ido_recomp/macos/7.1/uld differ diff --git a/tools/ido_recomp/macos/7.1/umerge b/tools/ido_recomp/macos/7.1/umerge index 0f19780515..a561c08012 100755 Binary files a/tools/ido_recomp/macos/7.1/umerge and b/tools/ido_recomp/macos/7.1/umerge differ diff --git a/tools/ido_recomp/macos/7.1/uopt b/tools/ido_recomp/macos/7.1/uopt index 5281514996..30817f201d 100755 Binary files a/tools/ido_recomp/macos/7.1/uopt and b/tools/ido_recomp/macos/7.1/uopt differ diff --git a/tools/ido_recomp/macos/7.1/usplit b/tools/ido_recomp/macos/7.1/usplit index cc539bdb14..2472794531 100755 Binary files a/tools/ido_recomp/macos/7.1/usplit and b/tools/ido_recomp/macos/7.1/usplit differ diff --git a/tools/ido_recomp/windows/5.3/as0.exe b/tools/ido_recomp/windows/5.3/as0.exe index 10c16ca69e..0c49260857 100755 Binary files a/tools/ido_recomp/windows/5.3/as0.exe and b/tools/ido_recomp/windows/5.3/as0.exe differ diff --git a/tools/ido_recomp/windows/5.3/as1.exe b/tools/ido_recomp/windows/5.3/as1.exe index 0ddac02bb5..2d79cc536a 100755 Binary files a/tools/ido_recomp/windows/5.3/as1.exe and b/tools/ido_recomp/windows/5.3/as1.exe differ diff --git a/tools/ido_recomp/windows/5.3/cc.exe b/tools/ido_recomp/windows/5.3/cc.exe index fdbaea21d3..7c08eac812 100755 Binary files a/tools/ido_recomp/windows/5.3/cc.exe and b/tools/ido_recomp/windows/5.3/cc.exe differ diff --git a/tools/ido_recomp/windows/5.3/cfe.exe b/tools/ido_recomp/windows/5.3/cfe.exe index abe1063c6d..2f5de5f18b 100755 Binary files a/tools/ido_recomp/windows/5.3/cfe.exe and b/tools/ido_recomp/windows/5.3/cfe.exe differ diff --git a/tools/ido_recomp/windows/5.3/ugen.exe b/tools/ido_recomp/windows/5.3/ugen.exe index be08a43c9a..0f919c2348 100755 Binary files a/tools/ido_recomp/windows/5.3/ugen.exe and b/tools/ido_recomp/windows/5.3/ugen.exe differ diff --git a/tools/ido_recomp/windows/5.3/ujoin.exe b/tools/ido_recomp/windows/5.3/ujoin.exe index b01b5c3353..f1397ee0c9 100755 Binary files a/tools/ido_recomp/windows/5.3/ujoin.exe and b/tools/ido_recomp/windows/5.3/ujoin.exe differ diff --git a/tools/ido_recomp/windows/5.3/uld.exe b/tools/ido_recomp/windows/5.3/uld.exe index 34cad1400a..d415d9ba00 100755 Binary files a/tools/ido_recomp/windows/5.3/uld.exe and b/tools/ido_recomp/windows/5.3/uld.exe differ diff --git a/tools/ido_recomp/windows/5.3/umerge.exe b/tools/ido_recomp/windows/5.3/umerge.exe index 3ce31e0cb6..23bf7b2516 100755 Binary files a/tools/ido_recomp/windows/5.3/umerge.exe and b/tools/ido_recomp/windows/5.3/umerge.exe differ diff --git a/tools/ido_recomp/windows/5.3/uopt.exe b/tools/ido_recomp/windows/5.3/uopt.exe index c1fb98c0da..248beabc70 100755 Binary files a/tools/ido_recomp/windows/5.3/uopt.exe and b/tools/ido_recomp/windows/5.3/uopt.exe differ diff --git a/tools/ido_recomp/windows/5.3/usplit.exe b/tools/ido_recomp/windows/5.3/usplit.exe index d179f1e136..6ac2a6382b 100755 Binary files a/tools/ido_recomp/windows/5.3/usplit.exe and b/tools/ido_recomp/windows/5.3/usplit.exe differ diff --git a/tools/ido_recomp/windows/7.1/as0.exe b/tools/ido_recomp/windows/7.1/as0.exe index 1a375d73e8..346827a49d 100755 Binary files a/tools/ido_recomp/windows/7.1/as0.exe and b/tools/ido_recomp/windows/7.1/as0.exe differ diff --git a/tools/ido_recomp/windows/7.1/as1.exe b/tools/ido_recomp/windows/7.1/as1.exe index 4778d2db69..7076875b9f 100755 Binary files a/tools/ido_recomp/windows/7.1/as1.exe and b/tools/ido_recomp/windows/7.1/as1.exe differ diff --git a/tools/ido_recomp/windows/7.1/cc.exe b/tools/ido_recomp/windows/7.1/cc.exe index 887b7cc499..53bf834332 100755 Binary files a/tools/ido_recomp/windows/7.1/cc.exe and b/tools/ido_recomp/windows/7.1/cc.exe differ diff --git a/tools/ido_recomp/windows/7.1/cfe.exe b/tools/ido_recomp/windows/7.1/cfe.exe index 6f5fd9e8db..0286c3fa5a 100755 Binary files a/tools/ido_recomp/windows/7.1/cfe.exe and b/tools/ido_recomp/windows/7.1/cfe.exe differ diff --git a/tools/ido_recomp/windows/7.1/ugen.exe b/tools/ido_recomp/windows/7.1/ugen.exe index fcc03538ca..30577e396a 100755 Binary files a/tools/ido_recomp/windows/7.1/ugen.exe and b/tools/ido_recomp/windows/7.1/ugen.exe differ diff --git a/tools/ido_recomp/windows/7.1/ujoin.exe b/tools/ido_recomp/windows/7.1/ujoin.exe index 9fb3a3f4fa..18fc825bc3 100755 Binary files a/tools/ido_recomp/windows/7.1/ujoin.exe and b/tools/ido_recomp/windows/7.1/ujoin.exe differ diff --git a/tools/ido_recomp/windows/7.1/uld.exe b/tools/ido_recomp/windows/7.1/uld.exe index 4a0cc8fe2f..a0bb885938 100755 Binary files a/tools/ido_recomp/windows/7.1/uld.exe and b/tools/ido_recomp/windows/7.1/uld.exe differ diff --git a/tools/ido_recomp/windows/7.1/umerge.exe b/tools/ido_recomp/windows/7.1/umerge.exe index 7cc0b1be6a..3e6698adac 100755 Binary files a/tools/ido_recomp/windows/7.1/umerge.exe and b/tools/ido_recomp/windows/7.1/umerge.exe differ diff --git a/tools/ido_recomp/windows/7.1/uopt.exe b/tools/ido_recomp/windows/7.1/uopt.exe index 4fbd1ab578..ae714d5280 100755 Binary files a/tools/ido_recomp/windows/7.1/uopt.exe and b/tools/ido_recomp/windows/7.1/uopt.exe differ diff --git a/tools/ido_recomp/windows/7.1/usplit.exe b/tools/ido_recomp/windows/7.1/usplit.exe index 5c0da6fe6b..f61837d0fd 100755 Binary files a/tools/ido_recomp/windows/7.1/usplit.exe and b/tools/ido_recomp/windows/7.1/usplit.exe differ