1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-07-13 11:24:40 +00:00

Merge branch 'master' (early part) into doc_pause_menu

This commit is contained in:
Dragorn421 2023-08-15 14:57:47 +02:00
commit 47bd5d9525
No known key found for this signature in database
GPG key ID: 381AEBAF3D429335
151 changed files with 1016 additions and 1151 deletions

View file

@ -18,7 +18,7 @@ RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone &
apt-get clean && \ apt-get clean && \
rm -rf /var/lib/apt/lists/* 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 RUN python3 -m pip install --upgrade attrs pycparser
ENV LANG C.UTF-8 ENV LANG C.UTF-8

View file

@ -199,12 +199,14 @@ build/src/code/fmodf.o: OPTFLAGS := -g
build/src/code/__osMemset.o: OPTFLAGS := -g build/src/code/__osMemset.o: OPTFLAGS := -g
build/src/code/__osMemmove.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/audio/%.o: OPTFLAGS := -O2
build/src/code/code_800EC960.o: CFLAGS += -signed
# 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) # 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/audio/sfx.o: CFLAGS += -use_readwrite_const
build/src/code/code_800F9280.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/absf.o: OPTFLAGS := -O2 -g3
build/src/libultra/libc/sqrt.o: OPTFLAGS := -O2 -g3 build/src/libultra/libc/sqrt.o: OPTFLAGS := -O2 -g3

View file

@ -1,7 +1,7 @@
<Root> <Root>
<File Name="object_bv" Segment="6"> <File Name="object_bv" Segment="6">
<!-- Boss title card --> <!-- Boss title card -->
<Texture Name="gBarinadeTitleCardTex" OutName="barinade_title_card" Format="i8" Width="128" Height="120" Offset="0x1230"/> <Texture Name="gBarinadeTitleCardTex" OutName="barinade_title_card" Format="ia8" Width="128" Height="120" Offset="0x1230"/>
<Skeleton Name="gBarinadeBodySkel" Type="Normal" LimbType="Standard" Offset="0x15B18"/> <Skeleton Name="gBarinadeBodySkel" Type="Normal" LimbType="Standard" Offset="0x15B18"/>
<Skeleton Name="gBarinadeSupportSkel" Type="Flex" LimbType="Standard" Offset="0x17498"/> <Skeleton Name="gBarinadeSupportSkel" Type="Flex" LimbType="Standard" Offset="0x17498"/>

View file

@ -1,7 +1,7 @@
<Root> <Root>
<File Name="object_fd" Segment="6"> <File Name="object_fd" Segment="6">
<!-- Boss title card --> <!-- Boss title card -->
<Texture Name="gVolvagiaBossTitleCardTex" OutName="volvagia_boss_title_card" Format="i8" Width="128" Height="120" Offset="0xD700"/> <Texture Name="gVolvagiaTitleCardTex" OutName="volvagia_title_card" Format="ia8" Width="128" Height="120" Offset="0xD700"/>
<!-- Skeletons --> <!-- Skeletons -->
<Skeleton Name="gVolvagiaLeftArmSkel" Type="Normal" LimbType="Standard" Offset="0x114E0"/> <Skeleton Name="gVolvagiaLeftArmSkel" Type="Normal" LimbType="Standard" Offset="0x114E0"/>

View file

@ -18,7 +18,7 @@
<Animation Name="gPhantomHorseFenceJumpAnim" Offset="0xC180"/> <Animation Name="gPhantomHorseFenceJumpAnim" Offset="0xC180"/>
<!-- Boss title card --> <!-- Boss title card -->
<Texture Name="gPhantomGanonTitleCardTex" OutName="phantom_ganon_title_card" Format="i8" Width="128" Height="120" Offset="0x59A0"/> <Texture Name="gPhantomGanonTitleCardTex" OutName="phantom_ganon_title_card" Format="ia8" Width="128" Height="120" Offset="0x59A0"/>
<!-- Energy attack DLists --> <!-- Energy attack DLists -->
<DList Name="gPhantomWarpDL" Offset="0xFAA0"/> <DList Name="gPhantomWarpDL" Offset="0xFAA0"/>

View file

@ -68,7 +68,7 @@
<DList Name="gGanondorfRightHandOpenDL" Offset="0xC9E8"/> <DList Name="gGanondorfRightHandOpenDL" Offset="0xC9E8"/>
<!-- Ganondorf Title Card Texture --> <!-- Ganondorf Title Card Texture -->
<Texture Name="gGanondorfTitleCardTex" OutName="ganondorf_title_card" Format="i8" Width="128" Height="40" Offset="0xCF00"/> <Texture Name="gGanondorfTitleCardTex" OutName="ganondorf_title_card" Format="ia8" Width="128" Height="40" Offset="0xCF00"/>
<!-- Ganondorf Animation --> <!-- Ganondorf Animation -->
<Animation Name="gGanondorfEndingFloatAnim" Offset="0x11348"/> <!-- Original name is "ONOLEE" (lit. "Curse you!" from his in-game dialogue) --> <Animation Name="gGanondorfEndingFloatAnim" Offset="0x11348"/> <!-- Original name is "ONOLEE" (lit. "Curse you!" from his in-game dialogue) -->

View file

@ -159,7 +159,7 @@
<Texture Name="gGohmaIrisTex" OutName="gohma_iris" Format="rgba16" Width="32" Height="32" Offset="0x193A8"/> <Texture Name="gGohmaIrisTex" OutName="gohma_iris" Format="rgba16" Width="32" Height="32" Offset="0x193A8"/>
<!-- Boss title card --> <!-- Boss title card -->
<Texture Name="gGohmaTitleCardTex" OutName="gohma_title_card" Format="i8" Width="128" Height="120" Offset="0x19BA8"/> <Texture Name="gGohmaTitleCardTex" OutName="gohma_title_card" Format="ia8" Width="128" Height="120" Offset="0x19BA8"/>
<!-- Door --> <!-- Door -->
<DList Name="gGohmaDoorDL" Offset="0x1EC20"/> <DList Name="gGohmaDoorDL" Offset="0x1EC20"/>

View file

@ -48,7 +48,7 @@
<Texture Name="object_kingdodongo_Tex_016D90" OutName="tex_00016D90" Format="rgba16" Width="8" Height="8" Offset="0x16D90"/> <Texture Name="object_kingdodongo_Tex_016D90" OutName="tex_00016D90" Format="rgba16" Width="8" Height="8" Offset="0x16D90"/>
<Texture Name="object_kingdodongo_Tex_016E10" OutName="tex_00016E10" Format="rgba16" Width="32" Height="16" Offset="0x16E10"/> <Texture Name="object_kingdodongo_Tex_016E10" OutName="tex_00016E10" Format="rgba16" Width="32" Height="16" Offset="0x16E10"/>
<Texture Name="object_kingdodongo_Tex_017210" OutName="tex_00017210" Format="rgba16" Width="8" Height="32" Offset="0x17210"/> <Texture Name="object_kingdodongo_Tex_017210" OutName="tex_00017210" Format="rgba16" Width="8" Height="32" Offset="0x17210"/>
<Blob Name="object_kingdodongo_Blob_017410" Size="0x3C00" Offset="0x17410"/> <!-- title card texture --> <Texture Name="gKingDodongoTitleCardTex" OutName="king_dodongo_title_card" Format="ia8" Width="128" Height="120" Offset="0x17410"/>
<Limb Name="object_kingdodongo_Limb_01B010" LimbType="Standard" Offset="0x1B010"/> <Limb Name="object_kingdodongo_Limb_01B010" LimbType="Standard" Offset="0x1B010"/>
<Limb Name="object_kingdodongo_Limb_01B01C" LimbType="Standard" Offset="0x1B01C"/> <Limb Name="object_kingdodongo_Limb_01B01C" LimbType="Standard" Offset="0x1B01C"/>
<Limb Name="object_kingdodongo_Limb_01B028" LimbType="Standard" Offset="0x1B028"/> <Limb Name="object_kingdodongo_Limb_01B028" LimbType="Standard" Offset="0x1B028"/>

View file

@ -1,7 +1,7 @@
<Root> <Root>
<File Name="object_mo" Segment="6"> <File Name="object_mo" Segment="6">
<!-- Morpha's Title Card --> <!-- Morpha's Title Card -->
<Texture Name="gMorphaTitleCardTex" Format="i8" Width="128" Height="120" Offset="0x1010"/> <Texture Name="gMorphaTitleCardTex" Format="ia8" Width="128" Height="120" Offset="0x1010"/>
<!-- DLists for Morpha's Core --> <!-- DLists for Morpha's Core -->
<DList Name="gMorphaCoreMembraneDL" Offset="0x6700"/> <DList Name="gMorphaCoreMembraneDL" Offset="0x6700"/>

View file

@ -2,7 +2,7 @@
<ExternalFile XmlPath="objects/gameplay_keep.xml" OutPath="assets/objects/gameplay_keep/"/> <ExternalFile XmlPath="objects/gameplay_keep.xml" OutPath="assets/objects/gameplay_keep/"/>
<File Name="object_sst" Segment="6"> <File Name="object_sst" Segment="6">
<!-- Boss Title Card --> <!-- Boss Title Card -->
<Texture Name="gBongoTitleCardTex" OutName="bongo_title_card" Format="i8" Width="128" Height="120" Offset="0x13D80"/> <Texture Name="gBongoTitleCardTex" OutName="bongo_title_card" Format="ia8" Width="128" Height="120" Offset="0x13D80"/>
<!-- Skeletons --> <!-- Skeletons -->
<Skeleton Name="gBongoLeftHandSkel" Type="Flex" LimbType="Standard" Offset="0x04DE0"/> <Skeleton Name="gBongoLeftHandSkel" Type="Flex" LimbType="Standard" Offset="0x04DE0"/>

View file

@ -350,7 +350,7 @@
<DList Name="gTwinrovaBroomFireTrailDL" Offset="0x2E098"/> <DList Name="gTwinrovaBroomFireTrailDL" Offset="0x2E098"/>
<!-- Twinrova Title Card --> <!-- Twinrova Title Card -->
<Texture Name="gTwinrovaTitleCardTex" OutName="twinrova_title_card" Format="i8" Width="128" Height="120" Offset="0x2E170"/> <Texture Name="gTwinrovaTitleCardTex" OutName="twinrova_title_card" Format="ia8" Width="128" Height="120" Offset="0x2E170"/>
<!-- Twinrova Limbs --> <!-- Twinrova Limbs -->
<Limb Name="gTwinrovaPelvisLimb" LimbType="Standard" Offset="0x31D70"/> <Limb Name="gTwinrovaPelvisLimb" LimbType="Standard" Offset="0x31D70"/>

View file

@ -9,7 +9,7 @@
<Texture Name="gHyliaLakesidePointNameENGTex" OutName="hylia_lakeside_point_name_eng" Format="ia4" Width="128" Height="16" Offset="0xc00"/> <Texture Name="gHyliaLakesidePointNameENGTex" OutName="hylia_lakeside_point_name_eng" Format="ia4" Width="128" Height="16" Offset="0xc00"/>
<Texture Name="gLonLonRanchPointNameENGTex" OutName="lon_lon_ranch_point_name_eng" Format="ia4" Width="128" Height="16" Offset="0x1000"/> <Texture Name="gLonLonRanchPointNameENGTex" OutName="lon_lon_ranch_point_name_eng" Format="ia4" Width="128" Height="16" Offset="0x1000"/>
<Texture Name="gMarketPointNameENGTex" OutName="market_point_name_eng" Format="ia4" Width="128" Height="16" Offset="0x1400"/> <Texture Name="gMarketPointNameENGTex" OutName="market_point_name_eng" Format="ia4" Width="128" Height="16" Offset="0x1400"/>
<Texture Name="gHyruleFieldPointNameENGTex" OutName="hyrulefield_point_name_eng" Format="ia4" Width="128" Height="16" Offset="0x1800"/> <Texture Name="gHyruleFieldPointNameENGTex" OutName="hyrule_field_point_name_eng" Format="ia4" Width="128" Height="16" Offset="0x1800"/>
<Texture Name="gDeathMountainPointNameENGTex" OutName="death_mountain_point_name_eng" Format="ia4" Width="128" Height="16" Offset="0x1c00"/> <Texture Name="gDeathMountainPointNameENGTex" OutName="death_mountain_point_name_eng" Format="ia4" Width="128" Height="16" Offset="0x1c00"/>
<Texture Name="gKakarikoVillagePointNameENGTex" OutName="kakariko_village_point_name_eng" Format="ia4" Width="128" Height="16" Offset="0x2000"/> <Texture Name="gKakarikoVillagePointNameENGTex" OutName="kakariko_village_point_name_eng" Format="ia4" Width="128" Height="16" Offset="0x2000"/>
<Texture Name="gLostWoodsPointNameENGTex" OutName="lost_woods_point_name_eng" Format="ia4" Width="128" Height="16" Offset="0x2400"/> <Texture Name="gLostWoodsPointNameENGTex" OutName="lost_woods_point_name_eng" Format="ia4" Width="128" Height="16" Offset="0x2400"/>

View file

@ -1,255 +1,58 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import os.path
import argparse import argparse
from subprocess import check_call from pathlib import Path
parser = argparse.ArgumentParser( try:
description="Find the first difference(s) between the built ROM and the base ROM." import rabbitizer
) except ImportError:
parser.add_argument( print("Missing dependency rabbitizer, install it with `python3 -m pip install 'rabbitizer>=1.0.0,<2.0.0'`")
"-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.")
exit(1) exit(1)
mybin = open(myimg, "rb").read() try:
basebin = open(baseimg, "rb").read() import mapfile_parser
except ImportError:
if len(mybin) != len(basebin): print("Missing dependency mapfile_parser, install it with `python3 -m pip install 'mapfile-parser>=1.2.1,<2.0.0'`")
print("Modified ROM has different size...")
exit(1) 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): if instr.isJumpWithAddress():
ram_offset = None # Instruction is a function call (jal)
prev_ram = 0
prev_rom = 0
prev_sym = "<start of rom>"
cur_file = "<no 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
prev_line = line # Get the embedded address of the function call
symAddress = instr.getInstrIndexAsVram()
if ( # Search for the address in the mapfile
ram_offset is None symInfo = mapFile.findSymbolByVramOrVrom(symAddress)
or "=" in line if symInfo is not None:
or "*fill*" in line # Use the symbol from the mapfile instead of a raw value
or " 0x" not in line immOverride = symInfo.symbol.name
):
continue
ram = int(line[16 : 16 + 18], 0) return instr.disassemble(immOverride=immOverride, extraLJust=-20)
rom = ram - ram_offset
sym = line.split()[-1]
if sym.startswith("0x"): def firstDiffMain():
ram_offset = None parser = argparse.ArgumentParser(description="Find the first difference(s) between the built ROM and the base ROM.")
continue
if "/" in sym:
cur_file = sym
continue
if rom > target_addr: parser.add_argument("-c", "--count", type=int, default=5, help="find up to this many instruction difference(s)")
return f"{prev_sym} (RAM 0x{prev_ram:X}, ROM 0x{prev_rom:X}, {prev_file})" 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 args = parser.parse_args()
prev_rom = rom
prev_sym = sym
prev_file = cur_file
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): EXPECTEDROM = Path("baserom.z64")
ram_offset = None EXPECTEDMAP = "expected" / BUILTMAP
cur_file = "<no 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
prev_line = line mapfile_parser.frontends.first_diff.doFirstDiff(BUILTMAP, EXPECTEDMAP, BUILTROM, EXPECTEDROM, args.count, mismatchSize=True, addColons=args.add_colons, bytesConverterCallback=decodeInstruction)
if ( if __name__ == "__main__":
ram_offset is None firstDiffMain()
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,
]
)

View file

@ -14,8 +14,8 @@ from typing import List
# clang-format, clang-tidy and clang-apply-replacements default version # clang-format, clang-tidy and clang-apply-replacements default version
# Version 11 is used when available for more consistency between contributors # This specific version is used when available, for more consistency between contributors
CLANG_VER = 11 CLANG_VER = 14
# Clang-Format options (see .clang-format for rules applied) # Clang-Format options (see .clang-format for rules applied)
FORMAT_OPTS = "-i -style=file" 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(): def main():
parser = argparse.ArgumentParser(description="Format files in the codebase to enforce most style rules") 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("files", metavar="file", nargs="*")
parser.add_argument( parser.add_argument(
"-j", "-j",
@ -155,6 +161,13 @@ def main():
) )
args = parser.parse_args() 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() nb_jobs = args.jobs or multiprocessing.cpu_count()
if nb_jobs > 1: if nb_jobs > 1:
if CLANG_APPLY_REPLACEMENTS is None: if CLANG_APPLY_REPLACEMENTS is None:

View file

@ -64,10 +64,6 @@ DECLARE_SEGMENT(code)
DECLARE_ROM_SEGMENT(code) DECLARE_ROM_SEGMENT(code)
DECLARE_BSS_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(kaleido_scope)
DECLARE_OVERLAY_SEGMENT(player_actor) DECLARE_OVERLAY_SEGMENT(player_actor)
DECLARE_OVERLAY_SEGMENT(map_mark_data) DECLARE_OVERLAY_SEGMENT(map_mark_data)

View file

@ -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)

View file

@ -448,9 +448,9 @@ typedef struct {
} KaleidoMgrOverlay; // size = 0x1C } KaleidoMgrOverlay; // size = 0x1C
typedef enum { typedef enum {
/* 0x00 */ KALEIDO_OVL_KALEIDO_SCOPE, /* 0 */ KALEIDO_OVL_KALEIDO_SCOPE,
/* 0x01 */ KALEIDO_OVL_PLAYER_ACTOR, /* 1 */ KALEIDO_OVL_PLAYER_ACTOR,
/* 0x02 */ KALEIDO_OVL_MAX /* 2 */ KALEIDO_OVL_MAX
} KaleidoOverlayType; } KaleidoOverlayType;
typedef enum { typedef enum {
@ -697,6 +697,16 @@ typedef struct {
/* 0x10 */ GameAllocEntry* head; /* 0x10 */ GameAllocEntry* head;
} GameAlloc; // size = 0x14 } 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; struct GameState;
typedef void (*GameStateFunc)(struct GameState* gameState); typedef void (*GameStateFunc)(struct GameState* gameState);
@ -781,7 +791,7 @@ typedef struct {
typedef struct { typedef struct {
/* 0x00 */ u8 numActors; /* 0x00 */ u8 numActors;
/* 0x04 */ TransitionActorEntry* list; /* 0x04 */ TransitionActorEntry* list;
} TransitionActorContext; } TransitionActorContext; // size = 0x8
typedef enum { typedef enum {
/* 0 */ PAUSE_BG_PRERENDER_OFF, // Inactive, do nothing. /* 0 */ PAUSE_BG_PRERENDER_OFF, // Inactive, do nothing.
@ -1076,8 +1086,8 @@ typedef struct DebugDispObject {
} DebugDispObject; // size = 0x2C } DebugDispObject; // size = 0x2C
typedef enum { typedef enum {
MTXMODE_NEW, // generates a new matrix /* 0 */ MTXMODE_NEW, // generates a new matrix
MTXMODE_APPLY // applies transformation to the current matrix /* 1 */ MTXMODE_APPLY // applies transformation to the current matrix
} MatrixMode; } MatrixMode;
typedef struct StackEntry { typedef struct StackEntry {
@ -1091,9 +1101,9 @@ typedef struct StackEntry {
} StackEntry; } StackEntry;
typedef enum { typedef enum {
STACK_STATUS_OK = 0, /* 0 */ STACK_STATUS_OK,
STACK_STATUS_WARNING = 1, /* 1 */ STACK_STATUS_WARNING,
STACK_STATUS_OVERFLOW = 2 /* 2 */ STACK_STATUS_OVERFLOW
} StackStatus; } StackStatus;
typedef struct { typedef struct {
@ -1318,22 +1328,22 @@ typedef enum {
} ViModeEditState; } ViModeEditState;
typedef struct { typedef struct {
/* 0x0000 */ OSViMode customViMode; /* 0x00 */ OSViMode customViMode;
/* 0x0050 */ s32 viHeight; /* 0x50 */ s32 viHeight;
/* 0x0054 */ s32 viWidth; /* 0x54 */ s32 viWidth;
/* 0x0058 */ s32 rightAdjust; /* 0x58 */ s32 rightAdjust;
/* 0x005C */ s32 leftAdjust; /* 0x5C */ s32 leftAdjust;
/* 0x0060 */ s32 lowerAdjust; /* 0x60 */ s32 lowerAdjust;
/* 0x0064 */ s32 upperAdjust; /* 0x64 */ s32 upperAdjust;
/* 0x0068 */ s32 editState; /* 0x68 */ s32 editState;
/* 0x006C */ s32 tvType; /* 0x6C */ s32 tvType;
/* 0x0070 */ u32 loRes; /* 0x70 */ u32 loRes;
/* 0x0074 */ u32 antialiasOff; /* 0x74 */ u32 antialiasOff;
/* 0x0078 */ u32 modeN; // Controls interlacing, the meaning of this mode is different based on choice of resolution /* 0x78 */ u32 modeN; // Controls interlacing, the meaning of this mode is different based on choice of resolution
/* 0x007C */ u32 fb16Bit; /* 0x7C */ u32 fb16Bit;
/* 0x0080 */ u32 viFeatures; /* 0x80 */ u32 viFeatures;
/* 0x0084 */ u32 unk_84; /* 0x84 */ u32 unk_84;
} ViMode; } ViMode; // size = 0x88
// Vis... // Vis...
typedef struct { typedef struct {

View file

@ -318,12 +318,12 @@ typedef enum {
} ButtonStatus; } ButtonStatus;
typedef enum { typedef enum {
/* 0x00 */ CHAMBER_CS_FOREST, /* 0 */ CHAMBER_CS_FOREST,
/* 0x01 */ CHAMBER_CS_FIRE, /* 1 */ CHAMBER_CS_FIRE,
/* 0x02 */ CHAMBER_CS_WATER, /* 2 */ CHAMBER_CS_WATER,
/* 0x03 */ CHAMBER_CS_SPIRIT, /* 3 */ CHAMBER_CS_SPIRIT,
/* 0x04 */ CHAMBER_CS_SHADOW, /* 4 */ CHAMBER_CS_SHADOW,
/* 0x05 */ CHAMBER_CS_LIGHT /* 5 */ CHAMBER_CS_LIGHT
} ChamberCutsceneNum; } ChamberCutsceneNum;
typedef enum { typedef enum {

View file

@ -41,14 +41,20 @@ typedef enum {
/* 0x27 */ SKYBOX_UNSET_27 = 39 /* 0x27 */ SKYBOX_UNSET_27 = 39
} SkyboxId; } 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 { typedef struct SkyboxContext {
/* 0x000 */ char unk_00[0x128]; /* 0x000 */ char unk_00[0x128];
/* 0x128 */ void* staticSegments[2]; /* 0x128 */ void* staticSegments[2];
/* 0x130 */ u16 (*palettes)[256]; /* 0x130 */ u16 (*palettes)[256];
/* 0x134 */ Gfx (*dListBuf)[150]; /* 0x134 */ Gfx (*dListBuf)[150];
/* 0x138 */ Gfx* unk_138; /* 0x138 */ Gfx* gfx;
/* 0x13C */ Vtx* roomVtx; /* 0x13C */ Vtx* roomVtx;
/* 0x140 */ s16 unk_140; /* 0x140 */ s16 drawType;
/* 0x144 */ Vec3f rot; /* 0x144 */ Vec3f rot;
/* 0x150 */ char unk_150[0x10]; /* 0x150 */ char unk_150[0x10];
} SkyboxContext; // size = 0x160 } SkyboxContext; // size = 0x160

36
spec
View file

@ -387,8 +387,8 @@ beginseg
include "build/src/code/PreRender.o" include "build/src/code/PreRender.o"
include "build/src/code/TwoHeadGfxArena.o" include "build/src/code/TwoHeadGfxArena.o"
include "build/src/code/TwoHeadArena.o" include "build/src/code/TwoHeadArena.o"
include "build/src/code/code_800C3C20.o" include "build/src/code/audio_stop_all_sfx.o"
include "build/src/code/audioMgr.o" include "build/src/code/audio_thread_manager.o"
include "build/src/code/title_setup.o" include "build/src/code/title_setup.o"
include "build/src/code/game.o" include "build/src/code/game.o"
include "build/src/code/gamealloc.o" include "build/src/code/gamealloc.o"
@ -417,22 +417,22 @@ beginseg
include "build/src/code/kanread.o" include "build/src/code/kanread.o"
include "build/src/code/ucode_disas.o" include "build/src/code/ucode_disas.o"
pad_text // audio library aligned to 32 bytes? pad_text // audio library aligned to 32 bytes?
include "build/src/code/audio_data.o" include "build/src/audio/lib/data.o"
include "build/src/code/audio_synthesis.o" include "build/src/audio/lib/synthesis.o"
include "build/src/code/audio_heap.o" include "build/src/audio/lib/heap.o"
include "build/src/code/audio_load.o" include "build/src/audio/lib/load.o"
include "build/src/code/code_800E4FE0.o" include "build/src/audio/lib/thread.o"
include "build/src/code/code_800E6840.o" include "build/src/audio/lib/dcache.o"
include "build/src/libultra/io/aisetnextbuf.o" include "build/src/audio/lib/aisetnextbuf.o"
include "build/src/code/audio_playback.o" include "build/src/audio/lib/playback.o"
include "build/src/code/audio_effects.o" include "build/src/audio/lib/effects.o"
include "build/src/code/audio_seqplayer.o" include "build/src/audio/lib/seqplayer.o"
include "build/src/code/code_800EC960.o" include "build/src/audio/general.o"
include "build/src/code/audio_sfx_params.o" include "build/src/audio/sfx_params.o"
include "build/src/code/code_800F7260.o" include "build/src/audio/sfx.o"
include "build/src/code/code_800F9280.o" include "build/src/audio/sequence.o"
include "build/src/code/audio_external_data.o" include "build/src/audio/data.o"
include "build/src/code/audio_init_params.o" include "build/src/audio/session_config.o"
include "build/src/code/logseverity.o" include "build/src/code/logseverity.o"
include "build/src/code/gfxprint.o" include "build/src/code/gfxprint.o"
include "build/src/code/rcp_utils.o" include "build/src/code/rcp_utils.o"

View file

@ -369,12 +369,12 @@ void PreRender_FetchFbufCoverage(PreRender* this, Gfx** gfxp) {
// //
// G_RM_VISCVG is the following special render mode: // G_RM_VISCVG is the following special render mode:
// IM_RD : Allow read-modify-write operations on the framebuffer // IM_RD : Allow read-modify-write operations on the framebuffer
// FORCE_BL : Apply the blender to all pixels rather than just edges // 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_0 + G_BL_CLR_BL) = G_BL_A_MEM // (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 // G_BL_A_MEM ("memory alpha") is coverage, therefore this blender configuration emits only the coverage (up to a
// and discards any pixel colors. For an RGBA16 framebuffer, each of the three color channels r,g,b will // constant factor determined by blend color) and discards any pixel colors. For an RGBA16 framebuffer, each of the
// receive the coverage value individually. // three color channels r,g,b will receive the coverage value individually.
// //
// Also disables other modes such as alpha compare and texture perspective correction // Also disables other modes such as alpha compare and texture perspective correction
gDPSetOtherMode(gfx++, gDPSetOtherMode(gfx++,

View file

@ -489,7 +489,7 @@ void* GameState_Alloc(GameState* gameState, size_t size, char* file, s32 line) {
} }
if (ret != NULL) { if (ret != NULL) {
osSyncPrintf(VT_FGCOL(GREEN)); 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); osSyncPrintf(VT_RST);
} }
return ret; return ret;

View file

@ -116,24 +116,15 @@ void Graph_InitTHGA(GraphicsContext* gfxCtx) {
GameStateOverlay* Graph_GetNextGameState(GameState* gameState) { GameStateOverlay* Graph_GetNextGameState(GameState* gameState) {
void* gameStateInitFunc = GameState_GetInit(gameState); void* gameStateInitFunc = GameState_GetInit(gameState);
if (gameStateInitFunc == Setup_Init) { // Generates code to match gameStateInitFunc to a gamestate entry and returns it if found
return &gGameStateOverlayTable[0]; #define DEFINE_GAMESTATE_INTERNAL(typeName, enumName) \
} if (gameStateInitFunc == typeName##_Init) { \
if (gameStateInitFunc == MapSelect_Init) { return &gGameStateOverlayTable[enumName]; \
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];
} }
#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); LOG_ADDRESS("game_init_func", gameStateInitFunc, "../graph.c", 696);
return NULL; return NULL;
@ -421,16 +412,14 @@ void Graph_ThreadEntry(void* arg0) {
GraphicsContext gfxCtx; GraphicsContext gfxCtx;
GameState* gameState; GameState* gameState;
u32 size; u32 size;
GameStateOverlay* nextOvl; GameStateOverlay* nextOvl = &gGameStateOverlayTable[GAMESTATE_SETUP];
GameStateOverlay* ovl; GameStateOverlay* ovl;
char faultMsg[0x50]; char faultMsg[0x50];
nextOvl = &gGameStateOverlayTable[0];
osSyncPrintf("グラフィックスレッド実行開始\n"); // "Start graphic thread execution" osSyncPrintf("グラフィックスレッド実行開始\n"); // "Start graphic thread execution"
Graph_Init(&gfxCtx); Graph_Init(&gfxCtx);
while (nextOvl) { while (nextOvl != NULL) {
ovl = nextOvl; ovl = nextOvl;
Overlay_LoadGameState(ovl); Overlay_LoadGameState(ovl);

View file

@ -1,7 +1,8 @@
#include "global.h" #include "global.h"
void* Overlay_AllocateAndLoad(uintptr_t vromStart, uintptr_t vromEnd, void* vramStart, void* vramEnd) { 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) { if (gOverlayLogSeverity >= 3) {
osSyncPrintf("OVL:SPEC(%08x-%08x) REAL(%08x-%08x) OFFSET(%08x)\n", vramStart, vramEnd, allocatedRamAddr, osSyncPrintf("OVL:SPEC(%08x-%08x) REAL(%08x-%08x) OFFSET(%08x)\n", vramStart, vramEnd, allocatedRamAddr,

View file

@ -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, gDPSetPrimColor(OVERLAY_DISP++, 0, 0, (u8)titleCtx->intensity, (u8)titleCtx->intensity, (u8)titleCtx->intensity,
(u8)titleCtx->alpha); (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, 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); 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 texture is bigger than 0x1000, display the rest
if (height > 0) { 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_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); 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; 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) && if ((play->csCtx.state == CS_STATE_IDLE) &&
(((void)0, gSaveContext.respawn[RESPAWN_MODE_TOP].entranceIndex) == (((void)0, gSaveContext.respawn[RESPAWN_MODE_TOP].entranceIndex) ==
((void)0, gSaveContext.entranceIndex)) && ((void)0, gSaveContext.entranceIndex)) &&
@ -1995,6 +1998,8 @@ void Actor_DrawFaroresWindPointer(PlayState* play) {
gSPDisplayList(POLY_XLU_DISP++, gEffFlash1DL); 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), 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.y) + yOffset,
((void)0, gSaveContext.respawn[RESPAWN_MODE_TOP].pos.z), 255, 255, 255, lightRadius); ((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); ASSERT(actorId < ACTOR_ID_MAX, "profile < ACTOR_DLF_MAX", "../z_actor.c", 6883);
name = overlayEntry->name != NULL ? overlayEntry->name : ""; 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) { if (HREG(20) != 0) {
// "Actor class addition [%d:%s]" // "Actor class addition [%d:%s]"
@ -2807,16 +2812,18 @@ Actor* Actor_Spawn(ActorContext* actorCtx, PlayState* play, s16 actorId, f32 pos
osSyncPrintf(VT_FGCOL(GREEN)); osSyncPrintf(VT_FGCOL(GREEN));
osSyncPrintf("OVL(a):Seg:%08x-%08x Ram:%08x-%08x Off:%08x %s\n", overlayEntry->vramStart, osSyncPrintf("OVL(a):Seg:%08x-%08x Ram:%08x-%08x Off:%08x %s\n", overlayEntry->vramStart,
overlayEntry->vramEnd, overlayEntry->loadedRamAddr, overlayEntry->vramEnd, overlayEntry->loadedRamAddr,
(u32)overlayEntry->loadedRamAddr + (u32)overlayEntry->vramEnd - (u32)overlayEntry->vramStart, (uintptr_t)overlayEntry->loadedRamAddr + (uintptr_t)overlayEntry->vramEnd -
(u32)overlayEntry->vramStart - (u32)overlayEntry->loadedRamAddr, name); (uintptr_t)overlayEntry->vramStart,
(uintptr_t)overlayEntry->vramStart - (uintptr_t)overlayEntry->loadedRamAddr, name);
osSyncPrintf(VT_RST); osSyncPrintf(VT_RST);
overlayEntry->numLoaded = 0; overlayEntry->numLoaded = 0;
} }
actorInit = (void*)(u32)((overlayEntry->initInfo != NULL) actorInit = (void*)(uintptr_t)((overlayEntry->initInfo != NULL)
? (void*)((u32)overlayEntry->initInfo - ? (void*)((uintptr_t)overlayEntry->initInfo -
(s32)((u32)overlayEntry->vramStart - (u32)overlayEntry->loadedRamAddr)) (intptr_t)((uintptr_t)overlayEntry->vramStart -
(uintptr_t)overlayEntry->loadedRamAddr))
: NULL); : NULL);
} }

View file

@ -76,10 +76,10 @@ void ActorOverlayTable_FaultPrint(void* arg0, void* arg1) {
FaultDrawer_Printf("No. RamStart- RamEnd cn Name\n"); FaultDrawer_Printf("No. RamStart- RamEnd cn Name\n");
for (i = 0, overlayEntry = &gActorOverlayTable[0]; i < gMaxActorId; i++, overlayEntry++) { 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) { if (overlayEntry->loadedRamAddr != NULL) {
FaultDrawer_Printf("%3d %08x-%08x %3d %s\n", i, overlayEntry->loadedRamAddr, 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 : ""); overlayEntry->name != NULL ? overlayEntry->name : "");
} }
} }

View file

@ -2880,21 +2880,25 @@ void DynaPoly_AddBgActorToLookup(PlayState* play, DynaCollisionContext* dyna, s3
if (!(dyna->bitFlag & DYNAPOLY_INVALIDATE_LOOKUP) && if (!(dyna->bitFlag & DYNAPOLY_INVALIDATE_LOOKUP) &&
(BgActor_IsTransformUnchanged(&dyna->bgActors[bgId]) == true)) { (BgActor_IsTransformUnchanged(&dyna->bgActors[bgId]) == true)) {
s32 pi; s32 pi;
for (pi = *polyStartIndex; pi < *polyStartIndex + pbgdata->numPolygons; pi++) { for (pi = *polyStartIndex; pi < *polyStartIndex + pbgdata->numPolygons; pi++) {
CollisionPoly* poly = &dyna->polyList[pi]; CollisionPoly* poly = &dyna->polyList[pi];
s16 normalY = poly->normal.y; s16 normalY = poly->normal.y;
if (normalY > COLPOLY_SNORMAL(0.5f)) { if (normalY > COLPOLY_SNORMAL(0.5f)) {
s16 polyIndex = pi; s16 polyIndex = pi;
DynaSSNodeList_SetSSListHead(&dyna->polyNodes, &dyna->bgActors[bgId].dynaLookup.floor, &polyIndex); DynaSSNodeList_SetSSListHead(&dyna->polyNodes, &dyna->bgActors[bgId].dynaLookup.floor, &polyIndex);
} else if (normalY < COLPOLY_SNORMAL(-0.8f)) { } else if (normalY < COLPOLY_SNORMAL(-0.8f)) {
if (!(dyna->bgActorFlags[bgId] & BGACTOR_CEILING_COLLISION_DISABLED)) { if (!(dyna->bgActorFlags[bgId] & BGACTOR_CEILING_COLLISION_DISABLED)) {
s16 polyIndex = pi; s16 polyIndex = pi;
DynaSSNodeList_SetSSListHead(&dyna->polyNodes, &dyna->bgActors[bgId].dynaLookup.ceiling, DynaSSNodeList_SetSSListHead(&dyna->polyNodes, &dyna->bgActors[bgId].dynaLookup.ceiling,
&polyIndex); &polyIndex);
} }
} else { } else {
s16 polyIndex = pi; s16 polyIndex = pi;
DynaSSNodeList_SetSSListHead(&dyna->polyNodes, &dyna->bgActors[bgId].dynaLookup.wall, &polyIndex); 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++) { for (i = 0; i < pbgdata->numVertices; i++) {
Vec3f vtx; Vec3f vtx;
Vec3f vtxT; // Vtx after mtx transform Vec3f vtxT; // Vtx after mtx transform
Math_Vec3s_ToVec3f(&vtx, &pbgdata->vtxList[i]); Math_Vec3s_ToVec3f(&vtx, &pbgdata->vtxList[i]);
SkinMatrix_Vec3fMtxFMultXYZ(&mtx, &vtx, &vtxT); SkinMatrix_Vec3fMtxFMultXYZ(&mtx, &vtx, &vtxT);
BgCheck_Vec3fToVec3s(&dyna->vtxList[*vtxStartIndex + i], &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.x = newCenterPoint.x;
sphere->center.y = newCenterPoint.y; sphere->center.y = newCenterPoint.y;
sphere->center.z = newCenterPoint.z; sphere->center.z = newCenterPoint.z;
newRadiusSq = -100.0f; newRadiusSq = -SQ(10.0f);
for (i = 0; i < pbgdata->numVertices; i++) { for (i = 0; i < pbgdata->numVertices; i++) {
f32 radiusSq; 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)]); newPoly->dist = -DOTXYZ(newNormal, dVtxList[(u32)COLPOLY_VTX_INDEX(newPoly->flags_vIA)]);
if (newNormal.y > 0.5f) { if (newNormal.y > 0.5f) {
s16 polyId = *polyStartIndex + i; s16 polyId = *polyStartIndex + i;
DynaSSNodeList_SetSSListHead(&dyna->polyNodes, &dyna->bgActors[bgId].dynaLookup.floor, &polyId); DynaSSNodeList_SetSSListHead(&dyna->polyNodes, &dyna->bgActors[bgId].dynaLookup.floor, &polyId);
} else if (newNormal.y < -0.8f) { } else if (newNormal.y < -0.8f) {
s16 polyId = *polyStartIndex + i; s16 polyId = *polyStartIndex + i;
DynaSSNodeList_SetSSListHead(&dyna->polyNodes, &dyna->bgActors[bgId].dynaLookup.ceiling, &polyId); DynaSSNodeList_SetSSListHead(&dyna->polyNodes, &dyna->bgActors[bgId].dynaLookup.ceiling, &polyId);
} else { } else {
s16 polyId = *polyStartIndex + i; s16 polyId = *polyStartIndex + i;
DynaSSNodeList_SetSSListHead(&dyna->polyNodes, &dyna->bgActors[bgId].dynaLookup.wall, &polyId); 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); dynaActor = DynaPoly_GetActor(&play->colCtx, i);
if (dynaActor != NULL && &dynaActor->actor == actor) { if (dynaActor != NULL && &dynaActor->actor == actor) {
DynaPolyActor_UnsetAllInteractFlags((DynaPolyActor*)actor); DynaPolyActor_UnsetAllInteractFlags((DynaPolyActor*)actor);
return; break;
} }
} }
} }

View file

@ -14,7 +14,7 @@ void SaveContext_Init(void) {
gSaveContext.forcedSeqId = NA_BGM_GENERAL_SFX; gSaveContext.forcedSeqId = NA_BGM_GENERAL_SFX;
gSaveContext.nextCutsceneIndex = 0xFFEF; gSaveContext.nextCutsceneIndex = 0xFFEF;
gSaveContext.cutsceneTrigger = 0; gSaveContext.cutsceneTrigger = 0;
gSaveContext.chamberCutsceneNum = 0; gSaveContext.chamberCutsceneNum = CHAMBER_CS_FOREST;
gSaveContext.nextDayTime = NEXT_TIME_NONE; gSaveContext.nextDayTime = NEXT_TIME_NONE;
gSaveContext.skyboxTime = 0; gSaveContext.skyboxTime = 0;
gSaveContext.dogIsLost = true; gSaveContext.dogIsLost = true;

View file

@ -790,7 +790,7 @@ void CutsceneCmd_Destination(PlayState* play, CutsceneContext* csCtx, CsCmdDesti
case CS_DEST_CHAMBER_OF_SAGES_FOREST_MEDALLION: case CS_DEST_CHAMBER_OF_SAGES_FOREST_MEDALLION:
play->nextEntranceIndex = ENTR_CHAMBER_OF_THE_SAGES_0; play->nextEntranceIndex = ENTR_CHAMBER_OF_THE_SAGES_0;
play->transitionTrigger = TRANS_TRIGGER_START; play->transitionTrigger = TRANS_TRIGGER_START;
gSaveContext.chamberCutsceneNum = 0; gSaveContext.chamberCutsceneNum = CHAMBER_CS_FOREST;
play->transitionType = TRANS_TYPE_FADE_WHITE; play->transitionType = TRANS_TYPE_FADE_WHITE;
break; break;
@ -799,14 +799,14 @@ void CutsceneCmd_Destination(PlayState* play, CutsceneContext* csCtx, CsCmdDesti
play->transitionTrigger = TRANS_TRIGGER_START; play->transitionTrigger = TRANS_TRIGGER_START;
play->transitionType = TRANS_TYPE_FADE_WHITE; play->transitionType = TRANS_TYPE_FADE_WHITE;
Item_Give(play, ITEM_MEDALLION_FIRE); Item_Give(play, ITEM_MEDALLION_FIRE);
gSaveContext.chamberCutsceneNum = 1; gSaveContext.chamberCutsceneNum = CHAMBER_CS_FIRE;
break; break;
case CS_DEST_CHAMBER_OF_SAGES_WATER_MEDALLION: case CS_DEST_CHAMBER_OF_SAGES_WATER_MEDALLION:
play->nextEntranceIndex = ENTR_CHAMBER_OF_THE_SAGES_0; play->nextEntranceIndex = ENTR_CHAMBER_OF_THE_SAGES_0;
play->transitionTrigger = TRANS_TRIGGER_START; play->transitionTrigger = TRANS_TRIGGER_START;
play->transitionType = TRANS_TYPE_FADE_WHITE; play->transitionType = TRANS_TYPE_FADE_WHITE;
gSaveContext.chamberCutsceneNum = 2; gSaveContext.chamberCutsceneNum = CHAMBER_CS_WATER;
break; break;
case CS_DEST_HYRULE_FIELD_FLASHBACK: case CS_DEST_HYRULE_FIELD_FLASHBACK:

View file

@ -11,7 +11,8 @@ void EffectSs_InitInfo(PlayState* play, s32 tableSize) {
for (i = 0; i < ARRAY_COUNT(gEffectSsOverlayTable); i++) { for (i = 0; i < ARRAY_COUNT(gEffectSsOverlayTable); i++) {
overlay = &gEffectSsOverlayTable[i]; overlay = &gEffectSsOverlayTable[i];
osSyncPrintf("effect index %3d:size=%6dbyte romsize=%6dbyte\n", 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); 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; sEffectSsInfo.searchStartIndex = index + 1;
overlaySize = (u32)overlayEntry->vramEnd - (u32)overlayEntry->vramStart; overlaySize = (uintptr_t)overlayEntry->vramEnd - (uintptr_t)overlayEntry->vramStart;
if (overlayEntry->vramStart == NULL) { if (overlayEntry->vramStart == NULL) {
// "Not an overlay" // "Not an overlay"
@ -212,9 +213,10 @@ void EffectSs_Spawn(PlayState* play, s32 type, s32 priority, void* initParams) {
osSyncPrintf(VT_RST); osSyncPrintf(VT_RST);
} }
initInfo = (void*)(u32)((overlayEntry->initInfo != NULL) initInfo = (void*)(uintptr_t)((overlayEntry->initInfo != NULL)
? (void*)((u32)overlayEntry->initInfo - ? (void*)((uintptr_t)overlayEntry->initInfo -
(s32)((u32)overlayEntry->vramStart - (u32)overlayEntry->loadedRamAddr)) (intptr_t)((uintptr_t)overlayEntry->vramStart -
(uintptr_t)overlayEntry->loadedRamAddr))
: NULL); : NULL);
} }

View file

@ -1,18 +1,35 @@
#include "global.h" #include "global.h"
#define GAMESTATE_OVERLAY(name, init, destroy, size) \ // Linker symbol declarations (used in the table below)
{ \ #define DEFINE_GAMESTATE(typeName, enumName, name) DECLARE_OVERLAY_SEGMENT(name)
NULL, (uintptr_t)_ovl_##name##SegmentRomStart, (uintptr_t)_ovl_##name##SegmentRomEnd, \ #define DEFINE_GAMESTATE_INTERNAL(typeName, enumName)
_ovl_##name##SegmentStart, _ovl_##name##SegmentEnd, NULL, init, destroy, NULL, NULL, 0, size \
} #include "tables/gamestate_table.h"
#define GAMESTATE_OVERLAY_INTERNAL(init, destroy, size) \
{ NULL, 0, 0, NULL, NULL, NULL, init, destroy, NULL, NULL, 0, size } #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[] = { GameStateOverlay gGameStateOverlayTable[] = {
GAMESTATE_OVERLAY_INTERNAL(Setup_Init, Setup_Destroy, sizeof(SetupState)), #include "tables/gamestate_table.h"
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)),
}; };
#undef DEFINE_GAMESTATE
#undef DEFINE_GAMESTATE_INTERNAL

View file

@ -102,7 +102,7 @@ void Jpeg_CopyToZbuffer(u16* src, u16* zbuffer, s32 x, s32 y) {
* unaligned values in JPEG header files. * unaligned values in JPEG header files.
*/ */
u16 Jpeg_GetUnalignedU16(u8* ptr) { 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. // Read the value normally if it's aligned to a 16-bit address.
return *(u16*)ptr; return *(u16*)ptr;
} else { } else {

View file

@ -24,18 +24,18 @@ void KaleidoManager_LoadOvl(KaleidoMgrOverlay* ovl) {
osSyncPrintf(VT_FGCOL(GREEN)); osSyncPrintf(VT_FGCOL(GREEN));
osSyncPrintf("OVL(k):Seg:%08x-%08x Ram:%08x-%08x Off:%08x %s\n", ovl->vramStart, ovl->vramEnd, ovl->loadedRamAddr, 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, (uintptr_t)ovl->loadedRamAddr + (uintptr_t)ovl->vramEnd - (uintptr_t)ovl->vramStart,
(u32)ovl->vramStart - (u32)ovl->loadedRamAddr, ovl->name); (uintptr_t)ovl->vramStart - (uintptr_t)ovl->loadedRamAddr, ovl->name);
osSyncPrintf(VT_RST); osSyncPrintf(VT_RST);
ovl->offset = (u32)ovl->loadedRamAddr - (u32)ovl->vramStart; ovl->offset = (uintptr_t)ovl->loadedRamAddr - (uintptr_t)ovl->vramStart;
gKaleidoMgrCurOvl = ovl; gKaleidoMgrCurOvl = ovl;
} }
void KaleidoManager_ClearOvl(KaleidoMgrOverlay* ovl) { void KaleidoManager_ClearOvl(KaleidoMgrOverlay* ovl) {
if (ovl->loadedRamAddr != NULL) { if (ovl->loadedRamAddr != NULL) {
ovl->offset = 0; 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; ovl->loadedRamAddr = NULL;
gKaleidoMgrCurOvl = NULL; gKaleidoMgrCurOvl = NULL;
} }
@ -47,7 +47,7 @@ void KaleidoManager_Init(PlayState* play) {
u32 i; u32 i;
for (i = 0; i < ARRAY_COUNT(gKaleidoMgrOverlayTable); 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) { if (size > largestSize) {
largestSize = size; largestSize = size;
} }
@ -61,7 +61,7 @@ void KaleidoManager_Init(PlayState* play) {
LogUtils_CheckNullPointer("KaleidoArea_allocp", sKaleidoAreaPtr, "../z_kaleido_manager.c", 151); LogUtils_CheckNullPointer("KaleidoArea_allocp", sKaleidoAreaPtr, "../z_kaleido_manager.c", 151);
osSyncPrintf(VT_FGCOL(GREEN)); 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); osSyncPrintf(VT_RST);
gKaleidoMgrCurOvl = NULL; gKaleidoMgrCurOvl = NULL;
@ -85,7 +85,7 @@ void* KaleidoManager_GetRamAddr(void* vram) {
if (ovl == NULL) { if (ovl == NULL) {
iter = &gKaleidoMgrOverlayTable[0]; iter = &gKaleidoMgrOverlayTable[0];
for (i = 0; i < ARRAY_COUNT(gKaleidoMgrOverlayTable); i++) { 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); KaleidoManager_LoadOvl(iter);
ovl = iter; ovl = iter;
goto KaleidoManager_GetRamAddr_end; goto KaleidoManager_GetRamAddr_end;
@ -98,9 +98,10 @@ void* KaleidoManager_GetRamAddr(void* vram) {
} }
KaleidoManager_GetRamAddr_end: 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 NULL;
} }
return (void*)((u32)vram + ovl->offset); return (void*)((uintptr_t)vram + ovl->offset);
} }

View file

@ -12,13 +12,14 @@ typedef enum {
} LightningBoltState; } LightningBoltState;
typedef struct { typedef struct {
/* 0x00 */ s32 mantissa; /* 0x00 */ s32 mantissaShift; // shift applied to the mantissa of the z buffer value
/* 0x04 */ s32 exponent; /* 0x04 */ s32 base; // 15.3 fixed-point base value for the exponent
} ZBufValConversionEntry; // size = 0x8 } ZBufValConversionEntry; // size = 0x8
// This table needs as many values as there are values for the 3-bit exponent
ZBufValConversionEntry sZBufValConversionTable[1 << 3] = { ZBufValConversionEntry sZBufValConversionTable[1 << 3] = {
{ 6, 0x00000 }, { 5, 0x20000 }, { 4, 0x30000 }, { 3, 0x38000 }, { 6, 0x0000 << 3 }, { 5, 0x4000 << 3 }, { 4, 0x6000 << 3 }, { 3, 0x7000 << 3 },
{ 2, 0x3C000 }, { 1, 0x3E000 }, { 0, 0x3F000 }, { 0, 0x3F800 }, { 2, 0x7800 << 3 }, { 1, 0x7C00 << 3 }, { 0, 0x7E00 << 3 }, { 0, 0x7F00 << 3 },
}; };
u8 gWeatherMode = WEATHER_MODE_CLEAR; // "E_wether_flg" u8 gWeatherMode = WEATHER_MODE_CLEAR; // "E_wether_flg"
@ -225,9 +226,9 @@ u16 sSandstormScroll;
* 4: dz value (unused) * 4: dz value (unused)
*/ */
s32 Environment_ZBufValToFixedPoint(s32 zBufferVal) { s32 Environment_ZBufValToFixedPoint(s32 zBufferVal) {
// base[exp] + mantissa << shift[exp] // base[exp] + (mantissa << shift[exp])
s32 ret = (ZBUFVAL_MANTISSA(zBufferVal) << sZBufValConversionTable[ZBUFVAL_EXPONENT(zBufferVal)].mantissa) + s32 ret = (ZBUFVAL_MANTISSA(zBufferVal) << sZBufValConversionTable[ZBUFVAL_EXPONENT(zBufferVal)].mantissaShift) +
sZBufValConversionTable[ZBUFVAL_EXPONENT(zBufferVal)].exponent; sZBufValConversionTable[ZBUFVAL_EXPONENT(zBufferVal)].base;
return ret; return ret;
} }
@ -1377,7 +1378,7 @@ void Environment_DrawSunAndMoon(PlayState* play) {
OPEN_DISPS(play->state.gfxCtx, "../z_kankyo.c", 2266); 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_SmoothStepToF(&play->envCtx.sunPos.x,
-(Math_SinS(((void)0, gSaveContext.dayTime) - CLOCK_TIME(12, 0)) * 120.0f) * 25.0f, 1.0f, -(Math_SinS(((void)0, gSaveContext.dayTime) - CLOCK_TIME(12, 0)) * 120.0f) * 25.0f, 1.0f,
0.8f, 0.8f); 0.8f, 0.8f);

View file

@ -339,11 +339,18 @@ void Lights_GlowCheck(PlayState* play) {
wY = multDest.y * cappedInvWDest; wY = multDest.y * cappedInvWDest;
if ((multDest.z > 1.0f) && (fabsf(wX) < 1.0f) && (fabsf(wY) < 1.0f)) { if ((multDest.z > 1.0f) && (fabsf(wX) < 1.0f) && (fabsf(wY) < 1.0f)) {
wZ = (s32)((multDest.z * cappedInvWDest) * 16352.0f) + 16352; // Compute screen z value assuming the viewport scale and translation both have value G_MAXZ / 2
zBuf = gZBuffer[(s32)((wY * -120.0f) + 120.0f)][(s32)((wX * 160.0f) + 160.0f)] * 4; // 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) {}
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)) { if (wZ < (Environment_ZBufValToFixedPoint(zBuf) >> 3)) {
params->drawGlow = true; params->drawGlow = true;
} }

View file

@ -55,7 +55,7 @@ static MapMarkData** sLoadedMarkDataTable;
void MapMark_Init(PlayState* play) { void MapMark_Init(PlayState* play) {
MapMarkDataOverlay* overlay = &sMapMarkDataOvl; 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); overlay->loadedRamAddr = GameState_Alloc(&play->state, overlaySize, "../z_map_mark.c", 235);
LogUtils_CheckNullPointer("dlftbl->allocp", overlay->loadedRamAddr, "../z_map_mark.c", 236); LogUtils_CheckNullPointer("dlftbl->allocp", overlay->loadedRamAddr, "../z_map_mark.c", 236);
@ -63,9 +63,10 @@ void MapMark_Init(PlayState* play) {
Overlay_Load(overlay->vromStart, overlay->vromEnd, overlay->vramStart, overlay->vramEnd, overlay->loadedRamAddr); Overlay_Load(overlay->vromStart, overlay->vromEnd, overlay->vramStart, overlay->vramEnd, overlay->loadedRamAddr);
sLoadedMarkDataTable = gMapMarkDataTable; sLoadedMarkDataTable = gMapMarkDataTable;
sLoadedMarkDataTable = (void*)(u32)( sLoadedMarkDataTable =
(overlay->vramTable != NULL) (void*)(uintptr_t)((overlay->vramTable != NULL)
? (void*)((u32)overlay->vramTable - (s32)((u32)overlay->vramStart - (u32)overlay->loadedRamAddr)) ? (void*)((uintptr_t)overlay->vramTable -
(intptr_t)((uintptr_t)overlay->vramStart - (uintptr_t)overlay->loadedRamAddr))
: NULL); : NULL);
} }

View file

@ -64,7 +64,7 @@ void Moji_DrawChar(GraphicsContext* gfxCtx, char c) {
OPEN_DISPS(gfxCtx, "../z_moji.c", 86); OPEN_DISPS(gfxCtx, "../z_moji.c", 86);
if ((u32)gMojiFontTLUTs & 0xF) { if ((uintptr_t)gMojiFontTLUTs & 0xF) {
osSyncPrintf("moji_tlut --> %X\n", gMojiFontTLUTs); 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); OPEN_DISPS(gfxCtx, "../z_moji.c", 137);
if ((u32)gMojiFontTex & 0xF) { if ((uintptr_t)gMojiFontTex & 0xF) {
osSyncPrintf("font_ff --> %X\n", gMojiFontTex); osSyncPrintf("font_ff --> %X\n", gMojiFontTex);
} }
gDPPipeSync(POLY_OPA_DISP++); gDPPipeSync(POLY_OPA_DISP++);
gDPSetPrimColor(POLY_OPA_DISP++, 0, 0, sFontColorRed, sFontColorGreen, sFontColorBlue, sFontColorAlpha); 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, 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); G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);

View file

@ -217,8 +217,8 @@ void Play_Destroy(GameState* thisx) {
void Play_Init(GameState* thisx) { void Play_Init(GameState* thisx) {
PlayState* this = (PlayState*)thisx; PlayState* this = (PlayState*)thisx;
GraphicsContext* gfxCtx = this->state.gfxCtx; GraphicsContext* gfxCtx = this->state.gfxCtx;
u32 zAlloc; uintptr_t zAlloc;
u32 zAllocAligned; uintptr_t zAllocAligned;
size_t zAllocSize; size_t zAllocSize;
Player* player; Player* player;
s32 playerStartBgCamIndex; s32 playerStartBgCamIndex;
@ -396,12 +396,11 @@ void Play_Init(GameState* thisx) {
osSyncPrintf("ZELDA ALLOC SIZE=%x\n", THA_GetRemaining(&this->state.tha)); osSyncPrintf("ZELDA ALLOC SIZE=%x\n", THA_GetRemaining(&this->state.tha));
zAllocSize = 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; zAllocAligned = (zAlloc + 8) & ~0xF;
ZeldaArena_Init((void*)zAllocAligned, zAllocSize - zAllocAligned + zAlloc); ZeldaArena_Init((void*)zAllocAligned, zAllocSize - (zAllocAligned - zAlloc));
// "Zelda Heap" // "Zelda Heap"
osSyncPrintf("ゼルダヒープ %08x-%08x\n", zAllocAligned, osSyncPrintf("ゼルダヒープ %08x-%08x\n", zAllocAligned, zAllocAligned + zAllocSize - (s32)(zAllocAligned - zAlloc));
(s32)(zAllocAligned + zAllocSize) - (s32)(zAllocAligned - zAlloc));
Fault_AddClient(&D_801614B8, ZeldaArena_Display, NULL, NULL); Fault_AddClient(&D_801614B8, ZeldaArena_Display, NULL, NULL);
Actor_InitContext(this, &this->actorCtx, this->playerEntry); Actor_InitContext(this, &this->actorCtx, this->playerEntry);
@ -1119,7 +1118,8 @@ void Play_Draw(PlayState* this) {
TransitionTile_Draw(&sTransitionTile, &sp88); TransitionTile_Draw(&sTransitionTile, &sp88);
POLY_OPA_DISP = sp88; POLY_OPA_DISP = sp88;
goto Play_Draw_DrawOverlayElements; goto Play_Draw_DrawOverlayElements;
} else { }
PreRender_SetValues(&this->pauseBgPreRender, SCREEN_WIDTH, SCREEN_HEIGHT, gfxCtx->curFrameBuffer, gZBuffer); PreRender_SetValues(&this->pauseBgPreRender, SCREEN_WIDTH, SCREEN_HEIGHT, gfxCtx->curFrameBuffer, gZBuffer);
if (R_PAUSE_BG_PRERENDER_STATE == PAUSE_BG_PRERENDER_PROCESS) { if (R_PAUSE_BG_PRERENDER_STATE == PAUSE_BG_PRERENDER_PROCESS) {
@ -1142,16 +1142,15 @@ void Play_Draw(PlayState* this) {
POLY_OPA_DISP = gfxP; POLY_OPA_DISP = gfxP;
goto Play_Draw_DrawOverlayElements; goto Play_Draw_DrawOverlayElements;
} else { }
s32 roomDrawFlags;
if ((R_HREG_MODE != HREG_MODE_PLAY) || R_PLAY_DRAW_SKYBOX) { 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 && (this->skyboxId != SKYBOX_UNSET_1D) && !this->envCtx.skyboxDisabled) {
if ((this->skyboxId == SKYBOX_NORMAL_SKY) || (this->skyboxId == SKYBOX_CUTSCENE_MAP)) { if ((this->skyboxId == SKYBOX_NORMAL_SKY) || (this->skyboxId == SKYBOX_CUTSCENE_MAP)) {
Environment_UpdateSkybox(this->skyboxId, &this->envCtx, &this->skyboxCtx); Environment_UpdateSkybox(this->skyboxId, &this->envCtx, &this->skyboxCtx);
Skybox_Draw(&this->skyboxCtx, gfxCtx, this->skyboxId, this->envCtx.skyboxBlend, Skybox_Draw(&this->skyboxCtx, gfxCtx, this->skyboxId, this->envCtx.skyboxBlend, this->view.eye.x,
this->view.eye.x, this->view.eye.y, this->view.eye.z); this->view.eye.y, this->view.eye.z);
} else if (this->skyboxCtx.unk_140 == 0) { } else if (this->skyboxCtx.drawType == SKYBOX_DRAW_128) {
Skybox_Draw(&this->skyboxCtx, gfxCtx, this->skyboxId, 0, this->view.eye.x, this->view.eye.y, Skybox_Draw(&this->skyboxCtx, gfxCtx, this->skyboxId, 0, this->view.eye.x, this->view.eye.y,
this->view.eye.z); this->view.eye.z);
} }
@ -1181,6 +1180,8 @@ void Play_Draw(PlayState* this) {
if ((R_HREG_MODE != HREG_MODE_PLAY) || (R_PLAY_DRAW_ROOM_FLAGS != 0)) { if ((R_HREG_MODE != HREG_MODE_PLAY) || (R_PLAY_DRAW_ROOM_FLAGS != 0)) {
if (VREG(94) == 0) { if (VREG(94) == 0) {
s32 roomDrawFlags;
if (R_HREG_MODE != HREG_MODE_PLAY) { if (R_HREG_MODE != HREG_MODE_PLAY) {
roomDrawFlags = ROOM_DRAW_OPA | ROOM_DRAW_XLU; roomDrawFlags = ROOM_DRAW_OPA | ROOM_DRAW_XLU;
} else { } else {
@ -1193,7 +1194,8 @@ void Play_Draw(PlayState* this) {
} }
if ((R_HREG_MODE != HREG_MODE_PLAY) || R_PLAY_DRAW_SKYBOX) { 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)) { if ((this->skyboxCtx.drawType != SKYBOX_DRAW_128) &&
(GET_ACTIVE_CAM(this)->setting != CAM_SET_PREREND_FIXED)) {
Vec3f quakeOffset; Vec3f quakeOffset;
Camera_GetQuakeOffset(&quakeOffset, GET_ACTIVE_CAM(this)); Camera_GetQuakeOffset(&quakeOffset, GET_ACTIVE_CAM(this));
@ -1232,9 +1234,9 @@ void Play_Draw(PlayState* this) {
switch (this->envCtx.fillScreen) { switch (this->envCtx.fillScreen) {
case 1: case 1:
Environment_FillScreen(gfxCtx, this->envCtx.screenFillColor[0], Environment_FillScreen(gfxCtx, this->envCtx.screenFillColor[0], this->envCtx.screenFillColor[1],
this->envCtx.screenFillColor[1], this->envCtx.screenFillColor[2], this->envCtx.screenFillColor[2], this->envCtx.screenFillColor[3],
this->envCtx.screenFillColor[3], FILL_SCREEN_OPA | FILL_SCREEN_XLU); FILL_SCREEN_OPA | FILL_SCREEN_XLU);
break; break;
default: default:
break; break;
@ -1251,8 +1253,7 @@ void Play_Draw(PlayState* this) {
DebugDisplay_DrawObjects(this); DebugDisplay_DrawObjects(this);
} }
if ((R_PAUSE_BG_PRERENDER_STATE == PAUSE_BG_PRERENDER_SETUP) || if ((R_PAUSE_BG_PRERENDER_STATE == PAUSE_BG_PRERENDER_SETUP) || (gTransitionTileState == TRANS_TILE_SETUP)) {
(gTransitionTileState == TRANS_TILE_SETUP)) {
Gfx* gfxP = OVERLAY_DISP; Gfx* gfxP = OVERLAY_DISP;
// Copy the frame buffer contents at this point in the display list to the zbuffer // Copy the frame buffer contents at this point in the display list to the zbuffer
@ -1271,15 +1272,16 @@ void Play_Draw(PlayState* this) {
OVERLAY_DISP = gfxP; OVERLAY_DISP = gfxP;
this->unk_121C7 = 2; this->unk_121C7 = 2;
R_GRAPH_TASKSET00_FLAGS |= 1; R_GRAPH_TASKSET00_FLAGS |= 1;
} else { goto Play_Draw_skip;
}
Play_Draw_DrawOverlayElements: Play_Draw_DrawOverlayElements:
if ((R_HREG_MODE != HREG_MODE_PLAY) || R_PLAY_DRAW_OVERLAY_ELEMENTS) { if ((R_HREG_MODE != HREG_MODE_PLAY) || R_PLAY_DRAW_OVERLAY_ELEMENTS) {
Play_DrawOverlayElements(this); Play_DrawOverlayElements(this);
} }
} }
}
} Play_Draw_skip:
}
if (this->view.unk_124 != 0) { if (this->view.unk_124 != 0) {
Camera_Update(GET_ACTIVE_CAM(this)); Camera_Update(GET_ACTIVE_CAM(this));

View file

@ -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; 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); 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[4] = VIRTUAL_TO_PHYSICAL(segment + PAUSE_EQUIP_BUFFER_SIZE);
gSegments[6] = gSegments[6] =

View file

@ -295,7 +295,7 @@ void Room_DrawBackground2D(Gfx** gfxP, void* tex, void* tlut, u16 width, u16 hei
Room_DecodeJpeg(SEGMENTED_TO_VIRTUAL(tex)); Room_DecodeJpeg(SEGMENTED_TO_VIRTUAL(tex));
bg = (uObjBg*)(gfx + 1); bg = (uObjBg*)(gfx + 1);
gSPBranchList(gfx, (u32)bg + sizeof(uObjBg)); gSPBranchList(gfx, (Gfx*)(bg + 1));
bg->b.imageX = 0; bg->b.imageX = 0;
bg->b.imageW = width * (1 << 2); 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.imagePal = 0;
bg->b.imageFlip = 0; bg->b.imageFlip = 0;
gfx = (Gfx*)((u32)bg + sizeof(uObjBg)); gfx = (Gfx*)(bg + 1);
if (fmt == G_IM_FMT_CI) { if (fmt == G_IM_FMT_CI) {
gDPLoadTLUT(gfx++, tlutCount, 256, tlut); 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); roomCtx->bufPtrs[0] = GameState_Alloc(&play->state, maxRoomSize, "../z_room.c", 946);
// "Room buffer initial pointer=%08x" // "Room buffer initial pointer=%08x"
osSyncPrintf("部屋バッファ開始ポインタ=%08x\n", roomCtx->bufPtrs[0]); 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" // "Room buffer end pointer=%08x"
osSyncPrintf("部屋バッファ終了ポインタ=%08x\n", roomCtx->bufPtrs[1]); osSyncPrintf("部屋バッファ終了ポインタ=%08x\n", roomCtx->bufPtrs[1]);
osSyncPrintf(VT_RST); 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); 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; 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); osCreateMesgQueue(&roomCtx->loadQueue, &roomCtx->loadMsg, 1);
DmaMgr_RequestAsync(&roomCtx->dmaRequest, roomCtx->unk_34, play->roomList[roomNum].vromStart, size, 0, DmaMgr_RequestAsync(&roomCtx->dmaRequest, roomCtx->unk_34, play->roomList[roomNum].vromStart, size, 0,

View file

@ -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("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); objectCtx->spaceEnd);
ASSERT(((objectCtx->num < OBJECT_EXCHANGE_BANK_MAX) && 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", "this->num < OBJECT_EXCHANGE_BANK_MAX && (this->status[this->num].Segment + size) < this->endSegment",
"../z_scene.c", 142); "../z_scene.c", 142);
@ -24,7 +24,7 @@ s32 Object_Spawn(ObjectContext* objectCtx, s16 objectId) {
if (objectCtx->num < OBJECT_EXCHANGE_BANK_MAX - 1) { if (objectCtx->num < OBJECT_EXCHANGE_BANK_MAX - 1) {
objectCtx->status[objectCtx->num + 1].segment = 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++; objectCtx->num++;
@ -70,7 +70,7 @@ void Object_InitBank(PlayState* play, ObjectContext* objectCtx) {
objectCtx->spaceStart = objectCtx->status[0].segment = objectCtx->spaceStart = objectCtx->status[0].segment =
GameState_Alloc(&play->state, spaceSize, "../z_scene.c", 219); 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); objectCtx->mainKeepIndex = Object_Spawn(objectCtx, OBJECT_GAMEPLAY_KEEP);
gSegments[4] = VIRTUAL_TO_PHYSICAL(objectCtx->status[objectCtx->mainKeepIndex].segment); 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; size = gObjectTable[id].vromEnd - gObjectTable[id].vromStart;
osSyncPrintf("OBJECT[%d] SIZE %fK SEG=%x\n", objectCtx->status[i].id, size / 1024.0f, osSyncPrintf("OBJECT[%d] SIZE %fK SEG=%x\n", objectCtx->status[i].id, size / 1024.0f,
objectCtx->status[i].segment); 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); objectCtx->spaceEnd);
DmaMgr_RequestSyncDebug(objectCtx->status[i].segment, gObjectTable[id].vromStart, size, "../z_scene.c", 342); 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; size = objectFile->vromEnd - objectFile->vromStart;
osSyncPrintf("OBJECT EXCHANGE NO=%2d BANK=%3d SIZE=%8.3fK\n", bankIndex, objectId, size / 1024.0f); 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); ASSERT(nextPtr < objectCtx->spaceEnd, "nextptr < this->endSegment", "../z_scene.c", 381);
// "Object exchange free size=%08x" // "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; return nextPtr;
} }

View file

@ -1073,8 +1073,8 @@ void SkelAnime_InitLink(PlayState* play, SkelAnime* skelAnime, FlexSkeletonHeade
} else { } else {
ASSERT(limbBufCount == limbCount, "joint_buff_num == joint_num", "../z_skelanime.c", 2369); ASSERT(limbBufCount == limbCount, "joint_buff_num == joint_num", "../z_skelanime.c", 2369);
skelAnime->jointTable = (Vec3s*)ALIGN16((u32)jointTable); skelAnime->jointTable = (Vec3s*)ALIGN16((uintptr_t)jointTable);
skelAnime->morphTable = (Vec3s*)ALIGN16((u32)morphTable); skelAnime->morphTable = (Vec3s*)ALIGN16((uintptr_t)morphTable);
} }
if ((skelAnime->jointTable == NULL) || (skelAnime->morphTable == NULL)) { 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); 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_SetLoadFrame(play, animation2, (s32)frame2, skelAnime->limbCount, alignedBlendTable);
AnimationContext_SetInterp(play, skelAnime->limbCount, skelAnime->jointTable, alignedBlendTable, blendWeight); 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); 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_SetLoadFrame(play, animation2, (s32)frame2, skelAnime->limbCount, alignedBlendTable);
AnimationContext_SetInterp(play, skelAnime->limbCount, skelAnime->morphTable, alignedBlendTable, blendWeight); AnimationContext_SetInterp(play, skelAnime->limbCount, skelAnime->morphTable, alignedBlendTable, blendWeight);

View file

@ -2,371 +2,452 @@
#include "terminal.h" #include "terminal.h"
#include "z64environment.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 { typedef struct {
/* 0x000 */ s32 unk_0; /* 0x000 */ s32 xStart;
/* 0x004 */ s32 unk_4; /* 0x004 */ s32 yStart;
/* 0x008 */ s32 unk_8; /* 0x008 */ s32 zStart;
/* 0x00C */ s32 unk_C; /* 0x00C */ s32 outerIncrVal;
/* 0x010 */ s32 unk_10; /* 0x010 */ s32 innerIncrVal;
} Struct_8012AF0C; // size = 0x14 } SkyboxFaceParams; // size = 0x14
Struct_8012AF0C D_8012AEBC[4] = { // Converts texture coordinate values to s10.5 fixed point
{ -0x7E, 0x7C, -0x7E, 0x3F, -0x1F }, #define TC(x) ((s16)((x)*32))
{ 0x7E, 0x7C, -0x7E, 0x3F, -0x1F },
{ 0x7E, 0x7C, 0x7E, -0x3F, -0x1F }, // Texture offsets for each face in the static segment buffer
{ -0x7E, 0x7C, 0x7E, -0x3F, -0x1F }, u32 sSkybox256TexOffsets[4] = {
256 * 256 * 0,
256 * 256 * 1,
256 * 256 * 2,
256 * 256 * 3,
}; };
Struct_8012AF0C D_8012AF0C[6] = { // Maps vertex buffer index to coordinate buffer index
{ -0x40, 0x40, -0x40, 0x20, -0x20 }, { 0x40, 0x40, 0x40, -0x20, -0x20 }, { -0x40, 0x40, 0x40, -0x20, -0x20 }, u16 sSkybox256VtxBufIndices[2][32] = {
{ 0x40, 0x40, -0x40, 0x20, -0x20 }, { -0x40, 0x40, 0x40, 0x20, -0x20 }, { -0x40, -0x40, -0x40, 0x20, 0x20 }, {
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, // S coordinates for all faces
s32 arg8, s32 arg9) { s16 sSkybox256TexSCoords[5] = {
u32 pad42C; TC(126 * 0), TC(126 * 1), TC(126 * 2), TC(126 * 3), TC(126 * 4),
s32 pad428; };
s32 sp424;
// 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 i;
s32 j; s32 j;
s32 k; s32 k;
u16 index; u16 index;
s16 phi_t1; s16 m;
s16 phi_a2_4; s16 ult;
s16 phi_a0_4; s16 uls;
s16 phi_t2_4; s16 vtxIdx;
s16 phi_ra; s16 l;
s32 sp358[9 * 5]; s32 xPoints[9 * 5];
s32 sp2A4[9 * 5]; s32 yPoints[9 * 5];
s32 sp1F0[9 * 5]; s32 zPoints[9 * 5];
s32 sp13C[9 * 5]; s32 tcS[9 * 5];
s32 sp88[9 * 5]; s32 tcT[9 * 5];
s32 pad; s32 pad;
switch (arg8) { // Collect all vertex positions for this face
case 0: switch (faceNum) {
case 0: // xy plane
case 2: 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++) { for (j = 0; j < 5; j++, k++) {
sp1F0[k] = arg5; zPoints[k] = zStart;
sp358[k] = pad42C; xPoints[k] = innerIncr;
sp2A4[k] = pad428; yPoints[k] = outerIncr;
sp13C[k] = D_8012AD20[j]; tcS[k] = sSkybox256TexSCoords[j];
sp88[k] = D_8012AD2C[i]; tcT[k] = sSkybox256TexTCoords[i];
pad42C += arg6; innerIncr += innerIncrVal;
} }
pad428 += arg7; outerIncr += outerIncrVal;
} }
break; break;
case 1: case 1: // yz plane
case 3: 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++) { for (j = 0; j < 5; j++, k++) {
sp358[k] = arg3; xPoints[k] = xStart;
sp2A4[k] = pad428; yPoints[k] = outerIncr;
sp1F0[k] = pad42C; zPoints[k] = innerIncr;
sp13C[k] = D_8012AD20[j]; tcS[k] = sSkybox256TexSCoords[j];
sp88[k] = D_8012AD2C[i]; tcT[k] = sSkybox256TexTCoords[i];
pad42C += arg6; innerIncr += innerIncrVal;
} }
pad428 += arg7; outerIncr += outerIncrVal;
} }
break; break;
case 4: case 4: // xz plane
case 5: 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++) { for (j = 0; j < 5; j++, k++) {
sp2A4[k] = arg4; yPoints[k] = yStart;
sp358[k] = pad42C; xPoints[k] = innerIncr;
sp1F0[k] = pad428; zPoints[k] = outerIncr;
sp13C[k] = D_8012AD20[j]; tcS[k] = sSkybox256TexSCoords[j];
sp88[k] = D_8012AD2C[i]; tcT[k] = sSkybox256TexTCoords[i];
pad42C += arg6; innerIncr += innerIncrVal;
} }
pad428 += arg7; outerIncr += outerIncrVal;
} }
break; break;
} }
for (phi_a2_4 = 0, sp424 = 0; sp424 < 2; sp424++) { // For a 256x256 texture with 63x31 tiles there are 32 tiles which requires at least 45 vertices,
skyboxCtx->unk_138 = skyboxCtx->dListBuf[arg9 + sp424]; // 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++) { // Select gfx buffer
index = D_8012ACA0[sp424][i]; skyboxCtx->gfx = skyboxCtx->dListBuf[dlistBufStartIndex + n];
roomVtx[arg2 + i].v.ob[0] = sp358[index]; // Generate and load Vertex structures
roomVtx[arg2 + i].v.ob[1] = sp2A4[index]; for (i = 0; i < 32; i++) {
roomVtx[arg2 + i].v.ob[2] = sp1F0[index]; index = sSkybox256VtxBufIndices[n][i];
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;
}
gSPVertex(skyboxCtx->unk_138++, &roomVtx[arg2], 32, 0);
arg2 += i;
gSPCullDisplayList(skyboxCtx->unk_138++, 0, 15);
for (phi_t2_4 = 0, phi_ra = 0; phi_ra < 4; phi_ra++, phi_a2_4 += 0x1F) { roomVtx[roomVtxStartIndex + i].v.ob[0] = xPoints[index];
for (phi_a0_4 = 0, phi_t1 = 0; phi_t1 < 4; phi_t1++, phi_a0_4 += 0x3F, phi_t2_4 += 4) { roomVtx[roomVtxStartIndex + i].v.ob[1] = yPoints[index];
gDPLoadTextureTile(skyboxCtx->unk_138++, (u32)skyboxCtx->staticSegments[0] + D_8012AC90[arg8], roomVtx[roomVtxStartIndex + i].v.ob[2] = zPoints[index];
G_IM_FMT_CI, G_IM_SIZ_8b, 256, 0, phi_a0_4, phi_a2_4, phi_a0_4 + 0x3F, roomVtx[roomVtxStartIndex + i].v.flag = 0;
phi_a2_4 + 0x1F, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD, roomVtx[roomVtxStartIndex + i].v.tc[0] = tcS[index];
G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD); roomVtx[roomVtxStartIndex + i].v.tc[1] = tcT[index];
gSP1Quadrangle(skyboxCtx->unk_138++, D_8012AD40[phi_t2_4 + 1], D_8012AD40[phi_t2_4 + 2], roomVtx[roomVtxStartIndex + i].v.cn[1] = 0;
D_8012AD40[phi_t2_4 + 3], D_8012AD40[phi_t2_4 + 0], 3); roomVtx[roomVtxStartIndex + i].v.cn[2] = 0;
roomVtx[roomVtxStartIndex + i].v.cn[0] = 255;
}
gSPVertex(skyboxCtx->gfx++, &roomVtx[roomVtxStartIndex], 32, 0);
roomVtxStartIndex += i; // += 32
// 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, // Texture offsets for each face in the static segment buffer
s32 arg8) { 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 i;
s32 j; s32 j;
s32 k; s32 k;
s16 phi_a0_4; s16 uls;
s16 phi_t1; s16 m;
s32 temp1; s32 outerIncr;
u16 index; u16 index;
s16 phi_a2_4; s16 ult;
s16 phi_ra; s16 l;
s16 phi_t2_4; s16 vtxIdx;
s32 temp2; s32 innerIncr;
s32 sp2B4[5 * 5]; s32 xPoints[5 * 5];
s32 sp250[5 * 5]; s32 yPoints[5 * 5];
s32 sp1EC[5 * 5]; s32 zPoints[5 * 5];
s32 sp188[5 * 5]; s32 tcS[5 * 5];
s32 sp124[5 * 5]; s32 tcT[5 * 5];
s32 pad; s32 pad;
switch (arg8) { // Collect all vertex positions for this face
case 0: switch (faceNum) {
case 0: // xy plane
case 1: case 1:
temp1 = arg4; outerIncr = yStart;
for (i = 0, k = 0; k < 25; i++) { for (i = 0, k = 0; k < 25; i++) {
temp2 = arg3; innerIncr = xStart;
for (j = 0; j < 5; j++, k++) { for (j = 0; j < 5; j++, k++) {
sp1EC[k] = arg5; zPoints[k] = zStart;
sp2B4[k] = temp2; xPoints[k] = innerIncr;
sp250[k] = temp1; yPoints[k] = outerIncr;
sp188[k] = D_8012AE18[j]; tcS[k] = sSkybox128TexSCoords[j];
sp124[k] = D_8012AE30[i]; tcT[k] = sSkybox128TexTCoords[i];
temp2 += arg6; innerIncr += innerIncrVal;
} }
temp1 += arg7; outerIncr += outerIncrVal;
} }
break; break;
case 2: case 2: // yz plane
case 3: case 3:
temp1 = arg4; outerIncr = yStart;
for (i = 0, k = 0; k < 25; i++) { for (i = 0, k = 0; k < 25; i++) {
temp2 = arg5; innerIncr = zStart;
for (j = 0; j < 5; j++, k++) { for (j = 0; j < 5; j++, k++) {
sp2B4[k] = arg3; xPoints[k] = xStart;
sp250[k] = temp1; yPoints[k] = outerIncr;
sp1EC[k] = temp2; zPoints[k] = innerIncr;
sp188[k] = D_8012AE18[j]; tcS[k] = sSkybox128TexSCoords[j];
sp124[k] = D_8012AE30[i]; tcT[k] = sSkybox128TexTCoords[i];
temp2 += arg6; innerIncr += innerIncrVal;
} }
temp1 += arg7; outerIncr += outerIncrVal;
} }
break; break;
case 4: case 4: // xz plane
case 5: case 5:
temp1 = arg5; outerIncr = zStart;
for (i = 0, k = 0; k < 25; i++) { for (i = 0, k = 0; k < 25; i++) {
temp2 = arg3; innerIncr = xStart;
for (j = 0; j < 5; j++, k++) { for (j = 0; j < 5; j++, k++) {
sp250[k] = arg4; yPoints[k] = yStart;
sp2B4[k] = temp2; xPoints[k] = innerIncr;
sp1EC[k] = temp1; zPoints[k] = outerIncr;
sp188[k] = D_8012AE18[j]; tcS[k] = sSkybox128TexSCoords[j];
sp124[k] = D_8012AE24[i]; tcT[k] = sSkybox128TexTCoordsXZ[i];
temp2 += arg6; innerIncr += innerIncrVal;
} }
temp1 += arg7; outerIncr += outerIncrVal;
} }
break; break;
} }
skyboxCtx->unk_138 = &skyboxCtx->dListBuf[2 * arg8][0];
for (i = 0; i < 0x20; i++) { // Select gfx buffer
index = D_8012ADD8[i]; skyboxCtx->gfx = &skyboxCtx->dListBuf[2 * faceNum][0];
roomVtx[arg2 + i].v.ob[0] = sp2B4[index]; // Generate and load Vertex structures
roomVtx[arg2 + i].v.ob[1] = sp250[index]; for (i = 0; i < 32; i++) {
roomVtx[arg2 + i].v.ob[2] = sp1EC[index]; index = sSkybox128VtxBufIndices[i];
roomVtx[arg2 + i].v.flag = 0;
roomVtx[arg2 + i].v.tc[0] = sp188[index]; roomVtx[roomVtxStartIndex + i].v.ob[0] = xPoints[index];
roomVtx[arg2 + i].v.tc[1] = sp124[index]; roomVtx[roomVtxStartIndex + i].v.ob[1] = yPoints[index];
roomVtx[arg2 + i].v.cn[1] = 0; roomVtx[roomVtxStartIndex + i].v.ob[2] = zPoints[index];
roomVtx[arg2 + i].v.cn[2] = 0; roomVtx[roomVtxStartIndex + i].v.flag = 0;
roomVtx[arg2 + i].v.cn[0] = 255; 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); gSPVertex(skyboxCtx->gfx++, &roomVtx[roomVtxStartIndex], 32, 0);
arg2 += i; roomVtxStartIndex += i;
gSPCullDisplayList(skyboxCtx->unk_138++, 0, 15);
if ((arg8 == 4) || (arg8 == 5)) { // Cull the face if not within the viewing volume
phi_a2_4 = 0; gSPCullDisplayList(skyboxCtx->gfx++, 0, 15);
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) { // Draw face, load the texture in several tiles to work around TMEM size limitations
gDPLoadMultiTile(skyboxCtx->unk_138++, (u32)skyboxCtx->staticSegments[0] + D_8012ADC0[arg8], 0, if (faceNum == 4 || faceNum == 5) {
G_TX_RENDERTILE, G_IM_FMT_CI, G_IM_SIZ_8b, 128, 0, phi_a0_4, phi_a2_4, phi_a0_4 + 0x1F, // top/bottom faces, 128x128 texture
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); ult = 0;
gDPLoadMultiTile(skyboxCtx->unk_138++, (u32)skyboxCtx->staticSegments[1] + D_8012ADC0[arg8], 0x80, 1, for (vtxIdx = 0, l = 0; l < 4; l++, ult += 31) {
G_IM_FMT_CI, G_IM_SIZ_8b, 128, 0, phi_a0_4, phi_a2_4, phi_a0_4 + 0x1F, phi_a2_4 + 0x1F, for (uls = 0, m = 0; m < 4; m++, uls += 31, vtxIdx += 4) {
0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP, 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); G_TX_NOMASK, G_TX_NOLOD);
gSP1Quadrangle(skyboxCtx->unk_138++, D_8012AE3C[phi_t2_4 + 1], D_8012AE3C[phi_t2_4 + 2], gDPLoadMultiTile(skyboxCtx->gfx++, (u8*)skyboxCtx->staticSegments[1] + sSkybox128TexOffsets[faceNum],
D_8012AE3C[phi_t2_4 + 3], D_8012AE3C[phi_t2_4 + 0], 3); 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 { } else {
phi_a2_4 = 0; // other faces, 128x64 texture
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) { ult = 0;
gDPLoadMultiTile(skyboxCtx->unk_138++, (u32)skyboxCtx->staticSegments[0] + D_8012ADC0[arg8], 0, for (vtxIdx = 0, l = 0; l < 2; l++, ult += 31) {
G_TX_RENDERTILE, G_IM_FMT_CI, G_IM_SIZ_8b, 128, 0, phi_a0_4, phi_a2_4, phi_a0_4 + 0x1F, for (uls = 0, m = 0; m < 4; m++, uls += 31, vtxIdx += 4) {
phi_a2_4 + 0x1F, 0, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD, gDPLoadMultiTile(skyboxCtx->gfx++, (u8*)skyboxCtx->staticSegments[0] + sSkybox128TexOffsets[faceNum], 0,
G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD); G_TX_RENDERTILE, G_IM_FMT_CI, G_IM_SIZ_8b, 128, 0, uls, ult, uls + 31, ult + 31, 0,
gDPLoadMultiTile(skyboxCtx->unk_138++, (u32)skyboxCtx->staticSegments[1] + D_8012ADC0[arg8], 0x80, 1, G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOMIRROR | G_TX_WRAP,
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); G_TX_NOMASK, G_TX_NOLOD);
gSP1Quadrangle(skyboxCtx->unk_138++, D_8012AE3C[phi_t2_4 + 1], D_8012AE3C[phi_t2_4 + 2], gDPLoadMultiTile(skyboxCtx->gfx++, (u8*)skyboxCtx->staticSegments[1] + sSkybox128TexOffsets[faceNum],
D_8012AE3C[phi_t2_4 + 3], D_8012AE3C[phi_t2_4 + 0], 3); 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,
}
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,
G_TX_NOMASK, G_TX_NOLOD); G_TX_NOMASK, G_TX_NOLOD);
gSP1Quadrangle(skyboxCtx->unk_138++, D_8012AE3C[phi_t2_4 + 1], D_8012AE3C[phi_t2_4 + 2], gSP1Quadrangle(skyboxCtx->gfx++, sSkybox128VtxIndices[vtxIdx + 1], sSkybox128VtxIndices[vtxIdx + 2],
D_8012AE3C[phi_t2_4 + 3], D_8012AE3C[phi_t2_4 + 0], 3); sSkybox128VtxIndices[vtxIdx + 3], sSkybox128VtxIndices[vtxIdx + 0], 3);
}
}
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);
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++); gSPEndDisplayList(skyboxCtx->gfx++);
return arg2; return roomVtxStartIndex;
} }
void func_800AEFC8(SkyboxContext* skyboxCtx, s16 skyboxId) { SkyboxFaceParams sSkybox256FaceParams[4] = {
s32 i; { -126, 124, -126, 63, -31 },
s32 j; { 126, 124, -126, 63, -31 },
s32 phi_s3 = 0; { 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)) { if (skyboxId == SKYBOX_BAZAAR || (skyboxId > SKYBOX_HOUSE_KAKARIKO && skyboxId <= SKYBOX_BOMBCHU_SHOP)) {
for (j = 0, i = 0; i < 2; i++, j += 2) { // 2 faces, one in xy plane and one in yz plane
phi_s3 = func_800ADBB0(skyboxCtx, skyboxCtx->roomVtx, phi_s3, D_8012AEBC[i].unk_0, D_8012AEBC[i].unk_4, for (dlistBufStartIndex = 0, faceNum = 0; faceNum < 2; faceNum++, dlistBufStartIndex += 2) {
D_8012AEBC[i].unk_8, D_8012AEBC[i].unk_C, D_8012AEBC[i].unk_10, i, j); 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) { } else if (skyboxCtx->drawType == SKYBOX_DRAW_256_3FACE) {
for (j = 0, i = 0; i < 3; i++, j += 2) { // 3 faces, 2 in xy plane and 1 in yz plane
phi_s3 = func_800ADBB0(skyboxCtx, skyboxCtx->roomVtx, phi_s3, D_8012AEBC[i].unk_0, D_8012AEBC[i].unk_4, for (dlistBufStartIndex = 0, faceNum = 0; faceNum < 3; faceNum++, dlistBufStartIndex += 2) {
D_8012AEBC[i].unk_8, D_8012AEBC[i].unk_C, D_8012AEBC[i].unk_10, i, j); 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 { } else {
for (j = 0, i = 0; i < 4; i++, j += 2) { // 4 faces, 2 in xy plane and 2 in yz plane
phi_s3 = func_800ADBB0(skyboxCtx, skyboxCtx->roomVtx, phi_s3, D_8012AEBC[i].unk_0, D_8012AEBC[i].unk_4, for (dlistBufStartIndex = 0, faceNum = 0; faceNum < 4; faceNum++, dlistBufStartIndex += 2) {
D_8012AEBC[i].unk_8, D_8012AEBC[i].unk_C, D_8012AEBC[i].unk_10, i, j); 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) { SkyboxFaceParams sSkybox128FaceParams[6] = {
s32 phi_s2 = 0; { -64, 64, -64, 32, -32 }, { 64, 64, 64, -32, -32 }, { -64, 64, 64, -32, -32 },
s32 i; { 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, * Computes the display list for a skybox with up to 6 faces, where the sides are 128x64 CI8 textures and the
D_8012AF0C[i].unk_8, D_8012AF0C[i].unk_C, D_8012AF0C[i].unk_10, i); * 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; s16 i;
u8 skybox1Index; u8 skybox1Index;
u8 skybox2Index; u8 skybox2Index;
u32 start; uintptr_t start;
s32 skyboxConfig; s32 skyboxConfig;
switch (skyboxId) { switch (skyboxId) {
@ -447,7 +528,7 @@ void Skybox_Setup(PlayState* play, SkyboxContext* skyboxCtx, s16 skyboxId) {
break; break;
case SKYBOX_BAZAAR: case SKYBOX_BAZAAR:
skyboxCtx->unk_140 = 1; skyboxCtx->drawType = SKYBOX_DRAW_256_4FACE;
start = (uintptr_t)_vr_SP1a_staticSegmentRomStart; start = (uintptr_t)_vr_SP1a_staticSegmentRomStart;
size = (uintptr_t)_vr_SP1a_staticSegmentRomEnd - start; 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); DmaMgr_RequestSyncDebug((u8*)skyboxCtx->palettes + size, start, size, "../z_vr_box.c", 1175);
break; break;
case SKYBOX_MARKET_ADULT: case SKYBOX_MARKET_ADULT:
skyboxCtx->unk_140 = 1; skyboxCtx->drawType = SKYBOX_DRAW_256_4FACE;
start = (uintptr_t)_vr_RUVR_staticSegmentRomStart; start = (uintptr_t)_vr_RUVR_staticSegmentRomStart;
size = (uintptr_t)_vr_RUVR_staticSegmentRomEnd - start; 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); size, "../z_vr_box.c", 1216);
break; break;
case SKYBOX_HOUSE_LINK: case SKYBOX_HOUSE_LINK:
skyboxCtx->unk_140 = 1; skyboxCtx->drawType = SKYBOX_DRAW_256_4FACE;
start = (uintptr_t)_vr_LHVR_staticSegmentRomStart; start = (uintptr_t)_vr_LHVR_staticSegmentRomStart;
size = (uintptr_t)_vr_LHVR_staticSegmentRomEnd - start; 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); DmaMgr_RequestSyncDebug(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1233);
break; break;
case SKYBOX_MARKET_CHILD_DAY: case SKYBOX_MARKET_CHILD_DAY:
skyboxCtx->unk_140 = 1; skyboxCtx->drawType = SKYBOX_DRAW_256_4FACE;
start = (uintptr_t)_vr_MDVR_staticSegmentRomStart; start = (uintptr_t)_vr_MDVR_staticSegmentRomStart;
size = (uintptr_t)_vr_MDVR_staticSegmentRomEnd - start; 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); DmaMgr_RequestSyncDebug(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1264);
break; break;
case SKYBOX_MARKET_CHILD_NIGHT: case SKYBOX_MARKET_CHILD_NIGHT:
skyboxCtx->unk_140 = 1; skyboxCtx->drawType = SKYBOX_DRAW_256_4FACE;
start = (uintptr_t)_vr_MNVR_staticSegmentRomStart; start = (uintptr_t)_vr_MNVR_staticSegmentRomStart;
size = (uintptr_t)_vr_MNVR_staticSegmentRomEnd - start; 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); DmaMgr_RequestSyncDebug(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1279);
break; break;
case SKYBOX_HAPPY_MASK_SHOP: case SKYBOX_HAPPY_MASK_SHOP:
skyboxCtx->unk_140 = 1; skyboxCtx->drawType = SKYBOX_DRAW_256_4FACE;
start = (uintptr_t)_vr_FCVR_staticSegmentRomStart; start = (uintptr_t)_vr_FCVR_staticSegmentRomStart;
size = (uintptr_t)_vr_FCVR_staticSegmentRomEnd - start; 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; skyboxCtx->rot.y = 0.8f;
break; break;
case SKYBOX_HOUSE_KNOW_IT_ALL_BROTHERS: case SKYBOX_HOUSE_KNOW_IT_ALL_BROTHERS:
skyboxCtx->unk_140 = 1; skyboxCtx->drawType = SKYBOX_DRAW_256_4FACE;
start = (uintptr_t)_vr_KHVR_staticSegmentRomStart; start = (uintptr_t)_vr_KHVR_staticSegmentRomStart;
size = (uintptr_t)_vr_KHVR_staticSegmentRomEnd - start; 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); DmaMgr_RequestSyncDebug(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1308);
break; break;
case SKYBOX_HOUSE_OF_TWINS: case SKYBOX_HOUSE_OF_TWINS:
skyboxCtx->unk_140 = 2; skyboxCtx->drawType = SKYBOX_DRAW_256_3FACE;
start = (uintptr_t)_vr_K3VR_staticSegmentRomStart; start = (uintptr_t)_vr_K3VR_staticSegmentRomStart;
size = (uintptr_t)_vr_K3VR_staticSegmentRomEnd - start; 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); DmaMgr_RequestSyncDebug(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1338);
break; break;
case SKYBOX_STABLES: case SKYBOX_STABLES:
skyboxCtx->unk_140 = 1; skyboxCtx->drawType = SKYBOX_DRAW_256_4FACE;
start = (uintptr_t)_vr_MLVR_staticSegmentRomStart; start = (uintptr_t)_vr_MLVR_staticSegmentRomStart;
size = (uintptr_t)_vr_MLVR_staticSegmentRomEnd - start; 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); DmaMgr_RequestSyncDebug(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1352);
break; break;
case SKYBOX_HOUSE_KAKARIKO: case SKYBOX_HOUSE_KAKARIKO:
skyboxCtx->unk_140 = 1; skyboxCtx->drawType = SKYBOX_DRAW_256_4FACE;
start = (uintptr_t)_vr_KKRVR_staticSegmentRomStart; start = (uintptr_t)_vr_KKRVR_staticSegmentRomStart;
size = (uintptr_t)_vr_KKRVR_staticSegmentRomEnd - start; 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); DmaMgr_RequestSyncDebug(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1366);
break; break;
case SKYBOX_KOKIRI_SHOP: case SKYBOX_KOKIRI_SHOP:
skyboxCtx->unk_140 = 1; skyboxCtx->drawType = SKYBOX_DRAW_256_4FACE;
start = (uintptr_t)_vr_KSVR_staticSegmentRomStart; start = (uintptr_t)_vr_KSVR_staticSegmentRomStart;
size = (uintptr_t)_vr_KSVR_staticSegmentRomEnd - start; 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; skyboxCtx->rot.y = 0.8f;
break; break;
case SKYBOX_GORON_SHOP: case SKYBOX_GORON_SHOP:
skyboxCtx->unk_140 = 1; skyboxCtx->drawType = SKYBOX_DRAW_256_4FACE;
start = (uintptr_t)_vr_GLVR_staticSegmentRomStart; start = (uintptr_t)_vr_GLVR_staticSegmentRomStart;
size = (uintptr_t)_vr_GLVR_staticSegmentRomEnd - start; 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; skyboxCtx->rot.y = 0.8f;
break; break;
case SKYBOX_ZORA_SHOP: case SKYBOX_ZORA_SHOP:
skyboxCtx->unk_140 = 1; skyboxCtx->drawType = SKYBOX_DRAW_256_4FACE;
start = (uintptr_t)_vr_ZRVR_staticSegmentRomStart; start = (uintptr_t)_vr_ZRVR_staticSegmentRomStart;
size = (uintptr_t)_vr_ZRVR_staticSegmentRomEnd - start; 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; skyboxCtx->rot.y = 0.8f;
break; break;
case SKYBOX_POTION_SHOP_KAKARIKO: case SKYBOX_POTION_SHOP_KAKARIKO:
skyboxCtx->unk_140 = 1; skyboxCtx->drawType = SKYBOX_DRAW_256_4FACE;
start = (uintptr_t)_vr_DGVR_staticSegmentRomStart; start = (uintptr_t)_vr_DGVR_staticSegmentRomStart;
size = (uintptr_t)_vr_DGVR_staticSegmentRomEnd - start; 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; skyboxCtx->rot.y = 0.8f;
break; break;
case SKYBOX_POTION_SHOP_MARKET: case SKYBOX_POTION_SHOP_MARKET:
skyboxCtx->unk_140 = 1; skyboxCtx->drawType = SKYBOX_DRAW_256_4FACE;
start = (uintptr_t)_vr_ALVR_staticSegmentRomStart; start = (uintptr_t)_vr_ALVR_staticSegmentRomStart;
size = (uintptr_t)_vr_ALVR_staticSegmentRomEnd - start; 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; skyboxCtx->rot.y = 0.8f;
break; break;
case SKYBOX_BOMBCHU_SHOP: case SKYBOX_BOMBCHU_SHOP:
skyboxCtx->unk_140 = 1; skyboxCtx->drawType = SKYBOX_DRAW_256_4FACE;
start = (uintptr_t)_vr_NSVR_staticSegmentRomStart; start = (uintptr_t)_vr_NSVR_staticSegmentRomStart;
size = (uintptr_t)_vr_NSVR_staticSegmentRomEnd - start; 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; skyboxCtx->rot.y = 0.8f;
break; break;
case SKYBOX_HOUSE_RICHARD: case SKYBOX_HOUSE_RICHARD:
skyboxCtx->unk_140 = 1; skyboxCtx->drawType = SKYBOX_DRAW_256_4FACE;
start = (uintptr_t)_vr_IPVR_staticSegmentRomStart; start = (uintptr_t)_vr_IPVR_staticSegmentRomStart;
size = (uintptr_t)_vr_IPVR_staticSegmentRomEnd - start; 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); DmaMgr_RequestSyncDebug(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1519);
break; break;
case SKYBOX_HOUSE_IMPA: case SKYBOX_HOUSE_IMPA:
skyboxCtx->unk_140 = 1; skyboxCtx->drawType = SKYBOX_DRAW_256_4FACE;
start = (uintptr_t)_vr_LBVR_staticSegmentRomStart; start = (uintptr_t)_vr_LBVR_staticSegmentRomStart;
size = (uintptr_t)_vr_LBVR_staticSegmentRomEnd - start; 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); DmaMgr_RequestSyncDebug(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1533);
break; break;
case SKYBOX_TENT: case SKYBOX_TENT:
skyboxCtx->unk_140 = 2; skyboxCtx->drawType = SKYBOX_DRAW_256_3FACE;
start = (uintptr_t)_vr_TTVR_staticSegmentRomStart; start = (uintptr_t)_vr_TTVR_staticSegmentRomStart;
size = (uintptr_t)_vr_TTVR_staticSegmentRomEnd - start; 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); DmaMgr_RequestSyncDebug(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1547);
break; break;
case SKYBOX_HOUSE_MIDO: case SKYBOX_HOUSE_MIDO:
skyboxCtx->unk_140 = 2; skyboxCtx->drawType = SKYBOX_DRAW_256_3FACE;
start = (uintptr_t)_vr_K4VR_staticSegmentRomStart; start = (uintptr_t)_vr_K4VR_staticSegmentRomStart;
size = (uintptr_t)_vr_K4VR_staticSegmentRomEnd - start; 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); DmaMgr_RequestSyncDebug(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1567);
break; break;
case SKYBOX_HOUSE_SARIA: case SKYBOX_HOUSE_SARIA:
skyboxCtx->unk_140 = 2; skyboxCtx->drawType = SKYBOX_DRAW_256_3FACE;
start = (uintptr_t)_vr_K5VR_staticSegmentRomStart; start = (uintptr_t)_vr_K5VR_staticSegmentRomStart;
size = (uintptr_t)_vr_K5VR_staticSegmentRomEnd - start; 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); DmaMgr_RequestSyncDebug(skyboxCtx->palettes, start, size, "../z_vr_box.c", 1581);
break; break;
case SKYBOX_HOUSE_ALLEY: case SKYBOX_HOUSE_ALLEY:
skyboxCtx->unk_140 = 2; skyboxCtx->drawType = SKYBOX_DRAW_256_3FACE;
start = (uintptr_t)_vr_KR3VR_staticSegmentRomStart; start = (uintptr_t)_vr_KR3VR_staticSegmentRomStart;
size = (uintptr_t)_vr_KR3VR_staticSegmentRomEnd - start; 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) { void Skybox_Init(GameState* state, SkyboxContext* skyboxCtx, s16 skyboxId) {
PlayState* play = (PlayState*)state; PlayState* play = (PlayState*)state;
skyboxCtx->unk_140 = 0; skyboxCtx->drawType = SKYBOX_DRAW_128;
skyboxCtx->rot.x = skyboxCtx->rot.y = skyboxCtx->rot.z = 0.0f; skyboxCtx->rot.x = skyboxCtx->rot.y = skyboxCtx->rot.z = 0.0f;
// DMA required assets based on skybox id
Skybox_Setup(play, skyboxCtx, skyboxId); Skybox_Setup(play, skyboxCtx, skyboxId);
osSyncPrintf("\n\n\n\n\n\n" osSyncPrintf("\n\n\n\n\n\n"
"%d" "%d"
"\n\n\n\n\n\n", "\n\n\n\n\n\n",
skyboxId); skyboxId);
// Precompute vertices and display lists for drawing the skybox
if (skyboxId != SKYBOX_NONE) { if (skyboxId != SKYBOX_NONE) {
osSyncPrintf(VT_FGCOL(GREEN)); 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); 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); 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); ASSERT(skyboxCtx->roomVtx != NULL, "vr_box->roomVtx != NULL", "../z_vr_box.c", 1640);
func_800AEFC8(skyboxCtx, skyboxId); Skybox_Calculate256(skyboxCtx, skyboxId);
} else { } else {
skyboxCtx->dListBuf = GameState_Alloc(state, 12 * 150 * sizeof(Gfx), "../z_vr_box.c", 1643); 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); ASSERT(skyboxCtx->dListBuf != NULL, "vr_box->dpList != NULL", "../z_vr_box.c", 1644);
if (skyboxId == SKYBOX_CUTSCENE_MAP) { 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); 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 { } 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); 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); osSyncPrintf(VT_RST);

View file

@ -23,8 +23,8 @@ void Skybox_Draw(SkyboxContext* skyboxCtx, GraphicsContext* gfxCtx, s16 skyboxId
gDPSetPrimColor(POLY_OPA_DISP++, 0x00, 0x00, 0, 0, 0, blend); gDPSetPrimColor(POLY_OPA_DISP++, 0x00, 0x00, 0, 0, 0, blend);
gSPTexture(POLY_OPA_DISP++, 0x8000, 0x8000, 0, G_TX_RENDERTILE, G_ON); gSPTexture(POLY_OPA_DISP++, 0x8000, 0x8000, 0, G_TX_RENDERTILE, G_ON);
// Prepare matrix
sSkyboxDrawMatrix = Graph_Alloc(gfxCtx, sizeof(Mtx)); sSkyboxDrawMatrix = Graph_Alloc(gfxCtx, sizeof(Mtx));
Matrix_Translate(x, y, z, MTXMODE_NEW); Matrix_Translate(x, y, z, MTXMODE_NEW);
Matrix_Scale(1.0f, 1.0f, 1.0f, MTXMODE_APPLY); Matrix_Scale(1.0f, 1.0f, 1.0f, MTXMODE_APPLY);
Matrix_RotateX(skyboxCtx->rot.x, 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); Matrix_ToMtx(sSkyboxDrawMatrix, "../z_vr_box_draw.c", 76);
gSPMatrix(POLY_OPA_DISP++, sSkyboxDrawMatrix, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); 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); gDPSetColorDither(POLY_OPA_DISP++, G_CD_MAGICSQ);
gDPSetTextureFilter(POLY_OPA_DISP++, G_TF_BILERP); gDPSetTextureFilter(POLY_OPA_DISP++, G_TF_BILERP);
// All skyboxes use CI8 textures with an RGBA16 palette
gDPLoadTLUT_pal256(POLY_OPA_DISP++, skyboxCtx->palettes[0]); gDPLoadTLUT_pal256(POLY_OPA_DISP++, skyboxCtx->palettes[0]);
gDPSetTextureLUT(POLY_OPA_DISP++, G_TT_RGBA16); gDPSetTextureLUT(POLY_OPA_DISP++, G_TT_RGBA16);
// Enable texture filtering RDP pipeline stages for bilinear filtering
gDPSetTextureConvert(POLY_OPA_DISP++, G_TC_FILT); gDPSetTextureConvert(POLY_OPA_DISP++, G_TC_FILT);
if (skyboxCtx->unk_140) { if (skyboxCtx->drawType != SKYBOX_DRAW_128) {
gSPDisplayList(POLY_OPA_DISP++, skyboxCtx->dListBuf[0]); // 256x256 textures, per-face palettes
gSPDisplayList(POLY_OPA_DISP++, skyboxCtx->dListBuf[1]); // 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++); gDPPipeSync(POLY_OPA_DISP++);
gDPLoadTLUT_pal256(POLY_OPA_DISP++, skyboxCtx->palettes[1]); gDPLoadTLUT_pal256(POLY_OPA_DISP++, skyboxCtx->palettes[1]);
gSPDisplayList(POLY_OPA_DISP++, skyboxCtx->dListBuf[2]); gSPDisplayList(POLY_OPA_DISP++, skyboxCtx->dListBuf[2]); // +x face upper
gSPDisplayList(POLY_OPA_DISP++, skyboxCtx->dListBuf[3]); gSPDisplayList(POLY_OPA_DISP++, skyboxCtx->dListBuf[3]); // +x face lower
if (skyboxId != SKYBOX_BAZAAR) { if (skyboxId != SKYBOX_BAZAAR) {
if (skyboxId <= SKYBOX_HOUSE_KAKARIKO || skyboxId > SKYBOX_BOMBCHU_SHOP) { if (skyboxId < SKYBOX_KOKIRI_SHOP || skyboxId > SKYBOX_BOMBCHU_SHOP) {
gDPPipeSync(POLY_OPA_DISP++); // Skip remaining faces for most shop skyboxes
gDPLoadTLUT_pal256(POLY_OPA_DISP++, skyboxCtx->palettes[2]);
gSPDisplayList(POLY_OPA_DISP++, skyboxCtx->dListBuf[4]);
gSPDisplayList(POLY_OPA_DISP++, skyboxCtx->dListBuf[5]);
gDPPipeSync(POLY_OPA_DISP++); 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]); gDPLoadTLUT_pal256(POLY_OPA_DISP++, skyboxCtx->palettes[3]);
gSPDisplayList(POLY_OPA_DISP++, skyboxCtx->dListBuf[6]); gSPDisplayList(POLY_OPA_DISP++, skyboxCtx->dListBuf[6]); // -x face upper
gSPDisplayList(POLY_OPA_DISP++, skyboxCtx->dListBuf[7]); gSPDisplayList(POLY_OPA_DISP++, skyboxCtx->dListBuf[7]); // -x face lower
} }
} }
} }
} else { } else {
gSPDisplayList(POLY_OPA_DISP++, skyboxCtx->dListBuf[0]); // 128x128 and 128x64 textures
gSPDisplayList(POLY_OPA_DISP++, skyboxCtx->dListBuf[2]); // 5 or 6 faces
gSPDisplayList(POLY_OPA_DISP++, skyboxCtx->dListBuf[4]);
gSPDisplayList(POLY_OPA_DISP++, skyboxCtx->dListBuf[6]); // Draw each face
gSPDisplayList(POLY_OPA_DISP++, skyboxCtx->dListBuf[8]); 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) { 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
} }
} }

View file

@ -127,7 +127,7 @@ void func_808AC908(BgSpot02Objects* this, PlayState* play) {
static Vec3f zeroVec = { 0.0f, 0.0f, 0.0f }; static Vec3f zeroVec = { 0.0f, 0.0f, 0.0f };
Vec3f pos; 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) { if (play->csCtx.actorCues[3] != NULL && play->csCtx.actorCues[3]->id == 2) {
Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_GRAVE_EXPLOSION); Actor_PlaySfx(&this->dyna.actor, NA_SE_EV_GRAVE_EXPLOSION);
SET_EVENTCHKINF(EVENTCHKINF_1D); SET_EVENTCHKINF(EVENTCHKINF_1D);
@ -199,7 +199,7 @@ void BgSpot02Objects_Draw(Actor* thisx, PlayState* play) {
} }
void func_808ACC34(BgSpot02Objects* this, 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++; this->unk_16A++;
if (this->unk_16A >= 12) { 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); 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) { if (this->unk_16A < 5) {
rate = (this->unk_16A / 5.0f); rate = (this->unk_16A / 5.0f);
redPrim = greenPrim = bluePrim = 255; redPrim = greenPrim = bluePrim = 255;
@ -265,7 +265,7 @@ void func_808ACCB8(Actor* thisx, PlayState* play) {
} }
void func_808AD3D4(BgSpot02Objects* this, 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) { if (this->timer == 2) {
Actor_PlaySfx(&this->dyna.actor, NA_SE_IT_EXPLOSION_ICE); 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); 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); u16 temp_v1 = CAM_BINANG_TO_DEG(play->csCtx.actorCues[2]->rot.z);
if (this->unk_170 != temp_v1) { if (this->unk_170 != temp_v1) {

View file

@ -404,8 +404,7 @@ void BossDodongo_IntroCutscene(BossDodongo* this, PlayState* play) {
if (this->unk_198 == 0x5A) { if (this->unk_198 == 0x5A) {
if (!GET_EVENTCHKINF(EVENTCHKINF_71)) { if (!GET_EVENTCHKINF(EVENTCHKINF_71)) {
TitleCard_InitBossName(play, &play->actorCtx.titleCtx, TitleCard_InitBossName(play, &play->actorCtx.titleCtx,
SEGMENTED_TO_VIRTUAL(&object_kingdodongo_Blob_017410), 0xA0, 0xB4, 0x80, SEGMENTED_TO_VIRTUAL(gKingDodongoTitleCardTex), 160, 180, 128, 40);
0x28);
} }
SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, 0, NA_BGM_FIRE_BOSS); 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) { void BossDodongo_UpdateDamage(BossDodongo* this, PlayState* play) {
s32 pad; s32 pad;
ColliderInfo* item1; ColliderInfo* item;
u8 swordDamage; u8 swordDamage;
s32 damage; s32 damage;
ColliderInfo* item2;
s16 i; s16 i;
if ((this->health <= 0) && (this->actionFunc != BossDodongo_DeathCutscene)) { if ((this->health <= 0) && (this->actionFunc != BossDodongo_DeathCutscene)) {
@ -1242,10 +1240,9 @@ void BossDodongo_UpdateDamage(BossDodongo* this, PlayState* play) {
if (this->actionFunc == BossDodongo_Inhale) { if (this->actionFunc == BossDodongo_Inhale) {
for (i = 0; i < 19; i++) { for (i = 0; i < 19; i++) {
if (this->collider.elements[i].info.bumperFlags & BUMP_HIT) { if (this->collider.elements[i].info.bumperFlags & BUMP_HIT) {
item1 = this->collider.elements[i].info.acHitInfo; item = this->collider.elements[i].info.acHitInfo;
item2 = item1;
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->collider.elements[i].info.bumperFlags &= ~BUMP_HIT;
this->unk_1C0 = 2; this->unk_1C0 = 2;
BossDodongo_SetupWalk(this); BossDodongo_SetupWalk(this);
@ -1258,9 +1255,9 @@ void BossDodongo_UpdateDamage(BossDodongo* this, PlayState* play) {
if (this->collider.elements->info.bumperFlags & BUMP_HIT) { if (this->collider.elements->info.bumperFlags & BUMP_HIT) {
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)) { 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) { if (damage != 0) {
Actor_PlaySfx(&this->actor, NA_SE_EN_DODO_K_DAMAGE); Actor_PlaySfx(&this->actor, NA_SE_EN_DODO_K_DAMAGE);

View file

@ -489,8 +489,8 @@ void BossFd_Fly(BossFd* this, PlayState* play) {
SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, 0, NA_BGM_FIRE_BOSS); SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, 0, NA_BGM_FIRE_BOSS);
} }
if ((this->timers[3] == 130) && !GET_EVENTCHKINF(EVENTCHKINF_73)) { if ((this->timers[3] == 130) && !GET_EVENTCHKINF(EVENTCHKINF_73)) {
TitleCard_InitBossName(play, &play->actorCtx.titleCtx, TitleCard_InitBossName(play, &play->actorCtx.titleCtx, SEGMENTED_TO_VIRTUAL(gVolvagiaTitleCardTex),
SEGMENTED_TO_VIRTUAL(gVolvagiaBossTitleCardTex), 0xA0, 0xB4, 0x80, 0x28); 160, 180, 128, 40);
} }
if (this->timers[3] <= 100) { if (this->timers[3] <= 100) {
this->subCamEyeVel.x = this->subCamEyeVel.y = this->subCamEyeVel.z = 2.0f; this->subCamEyeVel.x = this->subCamEyeVel.y = this->subCamEyeVel.z = 2.0f;

View file

@ -921,7 +921,7 @@ void BossGoma_Encounter(BossGoma* this, PlayState* play) {
if (!GET_EVENTCHKINF(EVENTCHKINF_70)) { if (!GET_EVENTCHKINF(EVENTCHKINF_70)) {
TitleCard_InitBossName(play, &play->actorCtx.titleCtx, SEGMENTED_TO_VIRTUAL(gGohmaTitleCardTex), 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); SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, 0, NA_BGM_BOSS);

View file

@ -1420,8 +1420,8 @@ void BossMo_IntroCs(BossMo* this, PlayState* play) {
SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, 0, NA_BGM_BOSS); SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, 0, NA_BGM_BOSS);
} }
if (this->timers[2] == 130) { if (this->timers[2] == 130) {
TitleCard_InitBossName(play, &play->actorCtx.titleCtx, SEGMENTED_TO_VIRTUAL(gMorphaTitleCardTex), 0xA0, TitleCard_InitBossName(play, &play->actorCtx.titleCtx, SEGMENTED_TO_VIRTUAL(gMorphaTitleCardTex), 160,
0xB4, 0x80, 0x28); 180, 128, 40);
SET_EVENTCHKINF(EVENTCHKINF_74); SET_EVENTCHKINF(EVENTCHKINF_74);
} }
break; break;

View file

@ -2214,8 +2214,8 @@ void BossTw_TwinrovaIntroCS(BossTw* this, PlayState* play) {
play->envCtx.prevLightSetting = 1; play->envCtx.prevLightSetting = 1;
play->envCtx.lightSetting = 1; play->envCtx.lightSetting = 1;
play->envCtx.lightBlend = 0.0f; play->envCtx.lightBlend = 0.0f;
TitleCard_InitBossName(play, &play->actorCtx.titleCtx, SEGMENTED_TO_VIRTUAL(gTwinrovaTitleCardTex), TitleCard_InitBossName(play, &play->actorCtx.titleCtx, SEGMENTED_TO_VIRTUAL(gTwinrovaTitleCardTex), 160,
0xA0, 0xB4, 0x80, 0x28); 180, 128, 40);
SET_EVENTCHKINF(EVENTCHKINF_75); SET_EVENTCHKINF(EVENTCHKINF_75);
SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, 0, NA_BGM_BOSS); SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 0, 0, NA_BGM_BOSS);
} }

View file

@ -974,7 +974,7 @@ void BossVa_BodyIntro(BossVa* this, PlayState* play) {
if (!GET_EVENTCHKINF(EVENTCHKINF_76)) { if (!GET_EVENTCHKINF(EVENTCHKINF_76)) {
TitleCard_InitBossName(play, &play->actorCtx.titleCtx, SEGMENTED_TO_VIRTUAL(gBarinadeTitleCardTex), TitleCard_InitBossName(play, &play->actorCtx.titleCtx, SEGMENTED_TO_VIRTUAL(gBarinadeTitleCardTex),
0xA0, 0xB4, 0x80, 0x28); 160, 180, 128, 40);
} }
if (Rand_ZeroOne() < 0.1f) { if (Rand_ZeroOne() < 0.1f) {

View file

@ -194,7 +194,7 @@ void func_80969FB4(DemoDu* this, PlayState* play) {
void DemoDu_CsFireMedallion_AdvanceTo01(DemoDu* this, PlayState* play) { void DemoDu_CsFireMedallion_AdvanceTo01(DemoDu* this, PlayState* play) {
s32 pad[2]; s32 pad[2];
if ((gSaveContext.chamberCutsceneNum == 1) && !IS_CUTSCENE_LAYER) { if ((gSaveContext.chamberCutsceneNum == CHAMBER_CS_FIRE) && !IS_CUTSCENE_LAYER) {
Player* player = GET_PLAYER(play); Player* player = GET_PLAYER(play);
this->updateIndex = CS_FIREMEDALLION_SUBSCENE(1); this->updateIndex = CS_FIREMEDALLION_SUBSCENE(1);

View file

@ -786,7 +786,7 @@ void func_8097FCE4(DemoGt* this, PlayState* play) {
Vec3f vec; Vec3f vec;
u16 csCurFrame = play->csCtx.curFrame; 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.x = this->dyna.actor.world.pos.x + 300.0f;
vec.y = this->dyna.actor.world.pos.y + 560.0f; vec.y = this->dyna.actor.world.pos.y + 560.0f;
vec.z = this->dyna.actor.world.pos.z - 377.0f; vec.z = this->dyna.actor.world.pos.z - 377.0f;

View file

@ -326,7 +326,7 @@ void func_80985430(DemoIm* this, PlayState* play) {
void func_8098544C(DemoIm* this, PlayState* play) { void func_8098544C(DemoIm* this, PlayState* play) {
s32 pad[2]; s32 pad[2];
if ((gSaveContext.chamberCutsceneNum == 4) && !IS_CUTSCENE_LAYER) { if ((gSaveContext.chamberCutsceneNum == CHAMBER_CS_SHADOW) && !IS_CUTSCENE_LAYER) {
Player* player = GET_PLAYER(play); Player* player = GET_PLAYER(play);
this->action = 1; this->action = 1;

View file

@ -253,7 +253,7 @@ void func_8098E960(DemoSa* this, PlayState* play) {
s32 pad[2]; s32 pad[2];
Player* player; Player* player;
if ((gSaveContext.chamberCutsceneNum == 0) && !IS_CUTSCENE_LAYER) { if ((gSaveContext.chamberCutsceneNum == CHAMBER_CS_FOREST) && !IS_CUTSCENE_LAYER) {
player = GET_PLAYER(play); player = GET_PLAYER(play);
this->action = 1; this->action = 1;
play->csCtx.script = D_8099010C; play->csCtx.script = D_8099010C;

View file

@ -50,7 +50,7 @@ void EfcErupc_UpdateAction(EfcErupc* this, PlayState* play) {
Vec3f accel; Vec3f accel;
s32 i; 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] != NULL) {
if (play->csCtx.actorCues[1]->id == 2) { if (play->csCtx.actorCues[1]->id == 2) {
if (this->unk_150 == 30) { 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) { if (play->csCtx.actorCues[2] != NULL) {
switch (play->csCtx.actorCues[2]->id) { switch (play->csCtx.actorCues[2]->id) {
case 2: 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), gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_efc_erupc.c", 321),
G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); 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)) { if ((play->csCtx.actorCues[1] != NULL) && (play->csCtx.actorCues[1]->id == 2)) {
gSPDisplayList(POLY_XLU_DISP++, object_efc_erupc_DL_002570); 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); Matrix_Scale(3.4f, 3.4f, 3.4f, MTXMODE_APPLY);
gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_efc_erupc.c", 333), gSPMatrix(POLY_XLU_DISP++, Matrix_NewMtx(play->state.gfxCtx, "../z_efc_erupc.c", 333),
G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_MODELVIEW); 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]; CsCmdActorCue* cue = play->csCtx.actorCues[2];
if (cue != NULL) { if (cue != NULL) {

View file

@ -742,7 +742,7 @@ void EnFish_RespawningUpdate(EnFish* this, PlayState* play) {
void EnFish_Update(Actor* thisx, PlayState* play) { void EnFish_Update(Actor* thisx, PlayState* play) {
EnFish* this = (EnFish*)thisx; 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)) { (play->csCtx.actorCues[1] != NULL)) {
EnFish_SetCutsceneData(this); EnFish_SetCutsceneData(this);
} }

View file

@ -427,7 +427,7 @@ s32 EnGo_IsCameraModified(EnGo* this, PlayState* play) {
return 0; 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) { if ((this->actor.params & 0xF0) == 0x90) {
Camera_ChangeSetting(mainCam, CAM_SET_DIRECTED_YAW); Camera_ChangeSetting(mainCam, CAM_SET_DIRECTED_YAW);
xyzDistSq *= 4.8f; xyzDistSq *= 4.8f;

View file

@ -148,10 +148,10 @@ static ColliderJntSphInit sJntSphInit = {
static CollisionCheckInfoInit D_80A65F38 = { 10, 35, 100, MASS_HEAVY }; static CollisionCheckInfoInit D_80A65F38 = { 10, 35, 100, MASS_HEAVY };
typedef struct { typedef struct {
s16 sceneId; /* 0x0 */ s16 sceneId;
Vec3s pos; /* 0x2 */ Vec3s pos;
s16 angle; /* 0x8 */ s16 angle;
} EnHorseSpawnpoint; } EnHorseSpawnpoint; // size = 0xA
static EnHorseSpawnpoint sHorseSpawns[] = { static EnHorseSpawnpoint sHorseSpawns[] = {
{ SCENE_HYRULE_FIELD, 16, 0, 1341, 0 }, { SCENE_HYRULE_FIELD, 16, 0, 1341, 0 },
@ -330,18 +330,15 @@ static EnHorseSpawnpoint sHorseSpawns[] = {
}; };
typedef struct { typedef struct {
s16 zMin; /* 0x00 */ s16 zMin;
s16 zMax; /* 0x02 */ s16 zMax;
/* 0x04 */ s16 xMin;
s16 xMin; /* 0x06 */ s16 xMax;
s16 xMax; /* 0x08 */ s16 xOffset;
s16 xOffset; /* 0x0A */ s16 angle;
/* 0x0C */ s16 angleRange;
s16 angle; /* 0x0E */ Vec3s pos;
s16 angleRange; } BridgeJumpPoint; // size = 0x14
Vec3s pos;
} BridgeJumpPoint;
static BridgeJumpPoint sBridgeJumps[] = { static BridgeJumpPoint sBridgeJumps[] = {
{ -195, -40, 225, 120, 360, -0x4000, 0x7D0, -270, -52, -117 }, { -195, -40, 225, 120, 360, -0x4000, 0x7D0, -270, -52, -117 },
@ -349,17 +346,17 @@ static BridgeJumpPoint sBridgeJumps[] = {
}; };
typedef struct { typedef struct {
s16 x; /* 0x0 */ s16 x;
s16 y; /* 0x2 */ s16 y;
s16 z; /* 0x4 */ s16 z;
s16 speedXZ; /* 0x6 */ s16 speedXZ;
s16 angle; /* 0x8 */ s16 angle;
} RaceWaypoint; } RaceWaypoint; // size = 0xA
typedef struct { typedef struct {
s32 numWaypoints; /* 0x0 */ s32 numWaypoints;
RaceWaypoint* waypoints; /* 0x4 */ RaceWaypoint* waypoints;
} RaceInfo; } RaceInfo; // size = 0x8
static RaceWaypoint sIngoRaceWaypoints[] = { static RaceWaypoint sIngoRaceWaypoints[] = {
{ 1056, 1, -1540, 11, 0x2A8D }, { 1593, 1, -985, 10, 0xFC27 }, { 1645, 1, -221, 11, 0xE891 }, { 1056, 1, -1540, 11, 0x2A8D }, { 1593, 1, -985, 10, 0xFC27 }, { 1645, 1, -221, 11, 0xE891 },
@ -407,9 +404,9 @@ static EnHorseCsFunc sCutsceneActionFuncs[] = {
}; };
typedef struct { typedef struct {
s32 cueId; /* 0x0 */ s32 cueId;
s32 csFuncIdx; /* 0x4 */ s32 csFuncIdx;
} CsActionEntry; } CsActionEntry; // size = 0x8
static CsActionEntry sCsActionTable[] = { static CsActionEntry sCsActionTable[] = {
{ 36, 1 }, { 37, 2 }, { 38, 3 }, { 64, 4 }, { 65, 5 }, { 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 }, { 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[] = { static EnHorseActionFunc sActionFuncs[] = {
EnHorse_Frozen, EnHorse_Frozen, // ENHORSE_ACT_FROZEN
EnHorse_Inactive, EnHorse_Inactive, // ENHORSE_ACT_INACTIVE
EnHorse_Idle, EnHorse_Idle, // ENHORSE_ACT_IDLE
EnHorse_FollowPlayer, EnHorse_FollowPlayer, // ENHORSE_ACT_FOLLOW_PLAYER
EnHorse_UpdateIngoRace, EnHorse_UpdateIngoRace, // ENHORSE_ACT_INGO_RACE
EnHorse_MountedIdle, EnHorse_MountedIdle, // ENHORSE_ACT_MOUNTED_IDLE
EnHorse_MountedIdleWhinneying, EnHorse_MountedIdleWhinneying, // ENHORSE_ACT_MOUNTED_IDLE_WHINNEYING
EnHorse_MountedTurn, EnHorse_MountedTurn, // ENHORSE_ACT_MOUNTED_TURN
EnHorse_MountedWalk, EnHorse_MountedWalk, // ENHORSE_ACT_MOUNTED_WALK
EnHorse_MountedTrot, EnHorse_MountedTrot, // ENHORSE_ACT_MOUNTED_TROT
EnHorse_MountedGallop, EnHorse_MountedGallop, // ENHORSE_ACT_MOUNTED_GALLOP
EnHorse_MountedRearing, EnHorse_MountedRearing, // ENHORSE_ACT_MOUNTED_REARING
EnHorse_Stopping, EnHorse_Stopping, // ENHORSE_ACT_STOPPING
EnHorse_Reverse, EnHorse_Reverse, // ENHORSE_ACT_REVERSE
EnHorse_LowJump, EnHorse_LowJump, // ENHORSE_ACT_LOW_JUMP
EnHorse_HighJump, EnHorse_HighJump, // ENHORSE_ACT_HIGH_JUMP
EnHorse_BridgeJump, EnHorse_BridgeJump, // ENHORSE_ACT_BRIDGE_JUMP
EnHorse_CutsceneUpdate, EnHorse_CutsceneUpdate, // ENHORSE_ACT_CS_UPDATE
EnHorse_UpdateHorsebackArchery, EnHorse_UpdateHorsebackArchery, // ENHORSE_ACT_HBA
EnHorse_FleePlayer, EnHorse_FleePlayer, // ENHORSE_ACT_FLEE_PLAYER
}; };
s32 EnHorse_BgCheckBridgeJumpPoint(EnHorse* this, PlayState* play) { s32 EnHorse_BgCheckBridgeJumpPoint(EnHorse* this, PlayState* play) {
@ -460,7 +457,7 @@ s32 EnHorse_BgCheckBridgeJumpPoint(EnHorse* this, PlayState* play) {
return false; return false;
} }
for (i = 0; i < 2; i++) { for (i = 0; i < ARRAY_COUNT(sBridgeJumps); i++) {
xMin = sBridgeJumps[i].xMin; xMin = sBridgeJumps[i].xMin;
xMax = (xMin + sBridgeJumps[i].xMax) + sBridgeJumps[i].xOffset; xMax = (xMin + sBridgeJumps[i].xMax) + sBridgeJumps[i].xOffset;
if (xMax < xMin) { if (xMax < xMin) {
@ -492,7 +489,7 @@ s32 EnHorse_CheckBridgeJumps(EnHorse* this, PlayState* play) {
return false; return false;
} }
for (i = 0; i != 2; i++) { for (i = 0; i < ARRAY_COUNT(sBridgeJumps); i++) {
xMin = sBridgeJumps[i].xMin; xMin = sBridgeJumps[i].xMin;
xMax = sBridgeJumps[i].xMax + xMin; xMax = sBridgeJumps[i].xMax + xMin;
@ -518,10 +515,10 @@ s32 EnHorse_CheckBridgeJumps(EnHorse* this, PlayState* play) {
return false; return false;
} }
void EnHorse_RaceWaypointPos(RaceWaypoint* waypoints, s32 idx, Vec3f* pos) { void EnHorse_RaceWaypointPos(RaceWaypoint* waypoints, s32 index, Vec3f* pos) {
pos->x = waypoints[idx].x; pos->x = waypoints[index].x;
pos->y = waypoints[idx].y; pos->y = waypoints[index].y;
pos->z = waypoints[idx].z; pos->z = waypoints[index].z;
} }
void EnHorse_RotateToPoint(EnHorse* this, PlayState* play, Vec3f* pos, s16 turnAmount) { void EnHorse_RotateToPoint(EnHorse* this, PlayState* play, Vec3f* pos, s16 turnAmount) {
@ -672,7 +669,7 @@ s32 EnHorse_Spawn(EnHorse* this, PlayState* play) {
Player* player; Player* player;
Vec3f spawnPos; Vec3f spawnPos;
for (i = 0; i < 169; i++) { for (i = 0; i < ARRAY_COUNT(sHorseSpawns); i++) {
if (sHorseSpawns[i].sceneId == play->sceneId) { if (sHorseSpawns[i].sceneId == play->sceneId) {
player = GET_PLAYER(play); player = GET_PLAYER(play);
if (play->sceneId != SCENE_LON_LON_RANCH || 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); dist = Math3D_Vec3f_DistXYZ(&player->actor.world.pos, &spawnPos);
if (play->sceneId) {} if (play->sceneId) {}
if (!(minDist < dist) && !func_80A5BBBC(play, this, &spawnPos)) { if (!((minDist < dist) || func_80A5BBBC(play, this, &spawnPos))) {
minDist = dist; minDist = dist;
this->actor.world.pos.x = sHorseSpawns[i].pos.x; this->actor.world.pos.x = sHorseSpawns[i].pos.x;
this->actor.world.pos.y = sHorseSpawns[i].pos.y; 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 || if ((player->stateFlags1 & PLAYER_STATE1_0) || func_8002DD78(GET_PLAYER(play)) == 1 ||
(player->stateFlags1 & PLAYER_STATE1_20) || ((this->stateFlags & ENHORSE_FLAG_19) && !this->inRace) || (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 false;
} }
return true; return true;
@ -945,7 +942,7 @@ void EnHorse_Frozen(EnHorse* this, PlayState* play) {
EnHorse_StartMountedIdleResetAnim(this); EnHorse_StartMountedIdleResetAnim(this);
} else if (this->actor.params == 9) { } else if (this->actor.params == 9) {
this->actor.params = 5; this->actor.params = 5;
if (play->csCtx.state != 0) { if (play->csCtx.state != CS_STATE_IDLE) {
EnHorse_StartMountedIdle(this); EnHorse_StartMountedIdle(this);
} else { } else {
this->actor.speed = 8.0f; 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) { void EnHorse_SetIngoAnimation(s32 index, f32 curFrame, s32 arg2, s16* animIdxOut, f32* curFrameOut) {
*animIdxOut = sIngoAnimations[idx]; *animIdxOut = sIngoAnimations[index];
*curFrameOut = curFrame; *curFrameOut = curFrame;
if (idx == 3 || idx == 7 || idx == 8 || idx == 4) { if ((index == 3) || (index == 7) || (index == 8) || (index == 4)) {
*curFrameOut = 0.0f; *curFrameOut = 0.0f;
} }
if (arg2 == 1) { if (arg2 == 1) {
if (idx == 5) { if (index == 5) {
*animIdxOut = 4; *animIdxOut = 4;
*curFrameOut = curFrame; *curFrameOut = curFrame;
} else if (idx == 6) { } else if (index == 6) {
*animIdxOut = 3; *animIdxOut = 3;
*curFrameOut = curFrame; *curFrameOut = curFrame;
} }

View file

@ -957,7 +957,7 @@ s32 EnKo_AdultSaved(EnKo* this, PlayState* play) {
void func_80A9877C(EnKo* this, PlayState* play) { void func_80A9877C(EnKo* this, PlayState* play) {
Player* player = GET_PLAYER(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.trackPos = play->view.eye;
this->interactInfo.yOffset = 40.0f; this->interactInfo.yOffset = 40.0f;
if (ENKO_TYPE != ENKO_TYPE_CHILD_0) { if (ENKO_TYPE != ENKO_TYPE_CHILD_0) {

View file

@ -341,7 +341,7 @@ void EnNb_SetupChamberCsImpl(EnNb* this, PlayState* play) {
s32 pad[2]; s32 pad[2];
Player* player; Player* player;
if ((gSaveContext.chamberCutsceneNum == 3) && !IS_CUTSCENE_LAYER) { if ((gSaveContext.chamberCutsceneNum == CHAMBER_CS_SPIRIT) && !IS_CUTSCENE_LAYER) {
player = GET_PLAYER(play); player = GET_PLAYER(play);
this->action = NB_CHAMBER_UNDERGROUND; this->action = NB_CHAMBER_UNDERGROUND;
play->csCtx.script = D_80AB431C; play->csCtx.script = D_80AB431C;

View file

@ -753,7 +753,7 @@ void func_80ACB748(EnOwl* this, PlayState* play) {
case 8: case 8:
case 9: case 9:
func_800F436C(&D_80ACD62C, NA_SE_EV_FLYING_AIR - SFX_FLAG, weight * 2.0f); 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); func_800F4414(&D_80ACD62C, NA_SE_EN_OWL_FLUTTER, weight * 2.0f);
} }
if (play->csCtx.curFrame == 217) { if (play->csCtx.curFrame == 217) {

View file

@ -536,7 +536,6 @@ void EnReeba_CheckDamage(EnReeba* this, PlayState* play) {
this->stunType = LEEVER_STUN_NONE; this->stunType = LEEVER_STUN_NONE;
switch (this->actor.colChkInfo.damageEffect) { switch (this->actor.colChkInfo.damageEffect) {
case LEEVER_DMGEFF_UNUSED: case LEEVER_DMGEFF_UNUSED:
case LEEVER_DMGEFF_BOOMERANG: case LEEVER_DMGEFF_BOOMERANG:
if ((this->actor.colChkInfo.health > 1) && (this->stunType != LEEVER_STUN_OTHER)) { if ((this->actor.colChkInfo.health > 1) && (this->stunType != LEEVER_STUN_OTHER)) {

View file

@ -7,6 +7,7 @@
#include "z_en_ru1.h" #include "z_en_ru1.h"
#include "assets/objects/object_ru1/object_ru1.h" #include "assets/objects/object_ru1/object_ru1.h"
#include "terminal.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) #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; Actor* actorIt = play->actorCtx.actorLists[ACTORCAT_BOSS].head;
while (actorIt != NULL) { 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; return actorIt;
} }
actorIt = actorIt->next; actorIt = actorIt->next;
@ -586,7 +587,7 @@ void func_80AEBBF4(EnRu1* this) {
void func_80AEBC30(PlayState* play) { void func_80AEBC30(PlayState* play) {
Player* player; Player* player;
if (play->csCtx.curFrame == 0xCD) { if (play->csCtx.curFrame == 205) {
player = GET_PLAYER(play); player = GET_PLAYER(play);
Audio_PlaySfxGeneral(NA_SE_EV_DIVE_INTO_WATER, &player->actor.projectedPos, 4, &gSfxDefaultFreqAndVolScale, Audio_PlaySfxGeneral(NA_SE_EV_DIVE_INTO_WATER, &player->actor.projectedPos, 4, &gSfxDefaultFreqAndVolScale,
&gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb); &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb);
@ -594,7 +595,7 @@ void func_80AEBC30(PlayState* play) {
} }
void func_80AEBC84(EnRu1* this, 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); func_80078914(&this->actor.projectedPos, NA_SE_VO_RT_LAUGH_0);
} }
} }

View file

@ -115,7 +115,7 @@ void func_80AF2608(EnRu2* this) {
s16* unk_2A6 = &this->unk_2A6; s16* unk_2A6 = &this->unk_2A6;
s16* unk_2A4 = &this->unk_2A4; s16* unk_2A4 = &this->unk_2A4;
if (!DECR(*unk_2A6)) { if (DECR(*unk_2A6) == 0) {
*unk_2A6 = Rand_S16Offset(0x3C, 0x3C); *unk_2A6 = Rand_S16Offset(0x3C, 0x3C);
} }
@ -263,7 +263,7 @@ void func_80AF2AB4(EnRu2* this, PlayState* play) {
Player* player; Player* player;
s16 temp; s16 temp;
if ((gSaveContext.chamberCutsceneNum == 2) && !IS_CUTSCENE_LAYER) { if ((gSaveContext.chamberCutsceneNum == CHAMBER_CS_WATER) && !IS_CUTSCENE_LAYER) {
player = GET_PLAYER(play); player = GET_PLAYER(play);
this->action = 1; this->action = 1;
play->csCtx.script = D_80AF411C; play->csCtx.script = D_80AF411C;

View file

@ -88,7 +88,7 @@ void EnXc_SetEyePattern(EnXc* this) {
s16* blinkTimer = &this->blinkTimer; s16* blinkTimer = &this->blinkTimer;
s16* eyePattern = &this->eyeIdx; s16* eyePattern = &this->eyeIdx;
if (!DECR(*blinkTimer)) { if (DECR(*blinkTimer) == 0) {
*blinkTimer = Rand_S16Offset(60, 60); *blinkTimer = Rand_S16Offset(60, 60);
} }
@ -120,7 +120,7 @@ s32 EnXc_AnimIsFinished(EnXc* this) {
CsCmdActorCue* EnXc_GetCue(PlayState* play, s32 cueChannel) { CsCmdActorCue* EnXc_GetCue(PlayState* play, s32 cueChannel) {
CsCmdActorCue* cue = NULL; CsCmdActorCue* cue = NULL;
if (play->csCtx.state != 0) { if (play->csCtx.state != CS_STATE_IDLE) {
cue = play->csCtx.actorCues[cueChannel]; cue = play->csCtx.actorCues[cueChannel];
} }
return cue; return cue;
@ -422,15 +422,15 @@ void EnXc_SetColossusAppearSFX(EnXc* this, PlayState* play) {
sceneId = play->sceneId; sceneId = play->sceneId;
if (sceneId == SCENE_DESERT_COLOSSUS) { if (sceneId == SCENE_DESERT_COLOSSUS) {
CutsceneContext* csCtx = &play->csCtx; CutsceneContext* csCtx = &play->csCtx;
u16 frameCount = csCtx->curFrame; u16 csCurFrame = csCtx->curFrame;
f32 wDest[2]; f32 wDest[2];
if (frameCount == 119) { if (csCurFrame == 119) {
Vec3f pos = { -611.0f, 728.0f, -2.0f }; Vec3f pos = { -611.0f, 728.0f, -2.0f };
SkinMatrix_Vec3fMtxFMultXYZW(&play->viewProjectionMtxF, &pos, &sXyzDist, wDest); SkinMatrix_Vec3fMtxFMultXYZW(&play->viewProjectionMtxF, &pos, &sXyzDist, wDest);
func_80078914(&sXyzDist, NA_SE_EV_JUMP_CONC); func_80078914(&sXyzDist, NA_SE_EV_JUMP_CONC);
} else if (frameCount == 164) { } else if (csCurFrame == 164) {
Vec3f pos = { -1069.0f, 38.0f, 0.0f }; Vec3f pos = { -1069.0f, 38.0f, 0.0f };
s32 pad; s32 pad;
@ -462,9 +462,9 @@ void EnXc_SetColossusWindSFX(PlayState* play) {
if (sceneId == SCENE_DESERT_COLOSSUS) { if (sceneId == SCENE_DESERT_COLOSSUS) {
CutsceneContext* csCtx = &play->csCtx; CutsceneContext* csCtx = &play->csCtx;
u16 frameCount = csCtx->curFrame; u16 csCurFrame = csCtx->curFrame;
if ((frameCount >= 120) && (frameCount < 164)) { if ((csCurFrame >= 120) && (csCurFrame < 164)) {
s32 pad; s32 pad;
Vec3f* eye = &play->view.eye; Vec3f* eye = &play->view.eye;
@ -723,9 +723,8 @@ void func_80B3DAF0(EnXc* this, PlayState* play) {
cueId = cue->id; cueId = cue->id;
if (cueId == 3 || cueId == 11 || cueId == 12 || cueId == 13 || cueId == 23) { 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); Animation_Change(&this->skelAnime, &gSheikPullingOutHarpAnim, 1.0f, 0.0f, frameCount, ANIMMODE_ONCE, -4.0f);
this->action = SHEIK_ACTION_7; this->action = SHEIK_ACTION_7;
this->drawMode = SHEIK_DRAW_PULLING_OUT_HARP; 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) { void func_80B3DCA8(EnXc* this, PlayState* play) {
f32 frameCount; f32 frameCount;
if (play->csCtx.state != 0) { if (play->csCtx.state != CS_STATE_IDLE) {
CsCmdActorCue* cue = play->csCtx.actorCues[4]; CsCmdActorCue* cue = play->csCtx.actorCues[4];
if (cue != NULL && cue->id == 8) { if (cue != NULL && cue->id == 8) {
@ -814,7 +813,7 @@ void func_80B3DE78(EnXc* this, s32 animFinished) {
} }
void EnXc_SetupReverseAccel(EnXc* this, PlayState* play) { 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]; CsCmdActorCue* cue = play->csCtx.actorCues[4];
if (cue != NULL && cue->id == 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) { 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]; CsCmdActorCue* cue = play->csCtx.actorCues[4];
if (cue != NULL && cue->id == 9) { if (cue != NULL && cue->id == 9) {
@ -1400,9 +1399,9 @@ void EnXc_LakeHyliaDive(PlayState* play) {
void func_80B3F534(PlayState* play) { void func_80B3F534(PlayState* play) {
CutsceneContext* csCtx = &play->csCtx; 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); Actor_Spawn(&play->actorCtx, play, ACTOR_DOOR_WARP1, -1044.0f, -1243.0f, 7458.0f, 0, 0, 0, WARP_DESTINATION);
} }
} }

View file

@ -1233,9 +1233,9 @@ void func_80B5154C(EnZl2* this, PlayState* play) {
EnZl2_UpdateEyes(this); EnZl2_UpdateEyes(this);
} else { } else {
csCtx = &play->csCtx; csCtx = &play->csCtx;
if (csCtx->curFrame < 0x5F0) { if (csCtx->curFrame < 1520) {
func_80B4EBB8(this); func_80B4EBB8(this);
} else if (csCtx->curFrame == 0x5F0) { } else if (csCtx->curFrame == 1520) {
this->unk_27C = 0.0f; this->unk_27C = 0.0f;
} else { } else {
func_80B4EC48(this); func_80B4EC48(this);

View file

@ -722,7 +722,7 @@ void ObjectKankyo_DrawSnow(Actor* thisx, PlayState* play2) {
} }
void ObjectKankyo_Lightning(ObjectKankyo* this, PlayState* play) { 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) { switch (this->effects[0].state) {
case 0: case 0:
this->effects[0].timer = 0; this->effects[0].timer = 0;
@ -797,7 +797,7 @@ void ObjectKankyo_WaitForSunGraveSparkObject(ObjectKankyo* this, PlayState* play
} }
void ObjectKankyo_SunGraveSpark(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) { if (play->csCtx.actorCues[1] != NULL && play->csCtx.actorCues[1]->id == 2) {
Actor_PlaySfx(&this->actor, NA_SE_EN_BIRI_SPARK - SFX_FLAG); Actor_PlaySfx(&this->actor, NA_SE_EN_BIRI_SPARK - SFX_FLAG);
if ((s16)this->effects[0].alpha + 20 > 255) { if ((s16)this->effects[0].alpha + 20 > 255) {
@ -818,7 +818,7 @@ void ObjectKankyo_DrawSunGraveSpark(Actor* thisx, PlayState* play2) {
f32 weight; f32 weight;
OPEN_DISPS(play->state.gfxCtx, "../z_object_kankyo.c", 1324); 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) { 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 // apparently, light waves with larger amplitudes look brighter, so the name 'amplitude' kind of works here
if (this->effects[0].state == 0) { if (this->effects[0].state == 0) {
@ -896,7 +896,7 @@ void ObjectKankyo_WaitForBeamObject(ObjectKankyo* this, PlayState* play) {
void ObjectKankyo_Beams(ObjectKankyo* this, PlayState* play) { void ObjectKankyo_Beams(ObjectKankyo* this, PlayState* play) {
u8 i; u8 i;
if (play->csCtx.state != 0) { if (play->csCtx.state != CS_STATE_IDLE) {
for (i = 0; i < 6; i++) { for (i = 0; i < 6; i++) {
if (play->csCtx.actorCues[i + 1] != NULL && play->csCtx.actorCues[i + 1]->id == 2) { if (play->csCtx.actorCues[i + 1] != NULL && play->csCtx.actorCues[i + 1]->id == 2) {
if (this->effects[i].size == 0.1f) { if (this->effects[i].size == 0.1f) {

View file

@ -11922,9 +11922,9 @@ void func_8084CBF4(Player* this, f32 arg1, f32 arg2) {
if ((this->unk_878 != 0.0f) && (arg2 <= this->skelAnime.curFrame)) { if ((this->unk_878 != 0.0f) && (arg2 <= this->skelAnime.curFrame)) {
if (arg1 < fabsf(this->unk_878)) { if (arg1 < fabsf(this->unk_878)) {
if (this->unk_878 >= 0.0f) { if (this->unk_878 >= 0.0f) {
dir = 1; dir = 1.0f;
} else { } else {
dir = -1; dir = -1.0f;
} }
temp = dir * arg1; temp = dir * arg1;
} else { } else {
@ -13052,7 +13052,7 @@ void func_8084F698(Player* this, PlayState* play) {
void func_8084F710(Player* this, PlayState* play) { void func_8084F710(Player* this, PlayState* play) {
s32 pad; 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.gravity = 0.0f;
this->actor.velocity.y = 0.0f; this->actor.velocity.y = 0.0f;
} else if (D_80853600 < 150.0f) { } else if (D_80853600 < 150.0f) {

View file

@ -1482,7 +1482,7 @@ void FileSelect_LoadGame(GameState* thisx) {
gSaveContext.nextTransitionType = TRANS_NEXT_TYPE_DEFAULT; gSaveContext.nextTransitionType = TRANS_NEXT_TYPE_DEFAULT;
gSaveContext.nextCutsceneIndex = 0xFFEF; gSaveContext.nextCutsceneIndex = 0xFFEF;
gSaveContext.cutsceneTrigger = 0; gSaveContext.cutsceneTrigger = 0;
gSaveContext.chamberCutsceneNum = 0; gSaveContext.chamberCutsceneNum = CHAMBER_CS_FOREST;
gSaveContext.nextDayTime = NEXT_TIME_NONE; gSaveContext.nextDayTime = NEXT_TIME_NONE;
gSaveContext.retainWeatherMode = false; gSaveContext.retainWeatherMode = false;

View file

@ -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` * Update function for `CM_ERASE_CONFIRM`
*/ */
void FileSelect_EraseConfirm(GameState* thisx) { void FileSelect_EraseConfirm(GameState* thisx) {

View file

@ -1,139 +1,29 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import os.path
import argparse import argparse
from pathlib import Path
parser = argparse.ArgumentParser( try:
description="Display various information about a symbol or address." import mapfile_parser
) except ImportError:
parser.add_argument( print("Missing dependency mapfile_parser, install it with `python3 -m pip install 'mapfile-parser>=1.2.1,<2.0.0'`")
"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.")
exit(1) exit(1)
def search_address(target_addr): def symInfoMain():
is_ram = target_addr & 0x80000000 parser = argparse.ArgumentParser(description="Display various information about a symbol or address.")
ram_offset = None parser.add_argument("symname", help="symbol name or VROM/VRAM address to lookup")
prev_ram = 0 parser.add_argument("-e", "--expected", dest="use_expected", action="store_true", help="use the map file in expected/build/ instead of build/")
prev_rom = 0
prev_sym = "<start of rom>"
cur_file = "<no 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
prev_line = line args = parser.parse_args()
if ( BUILTMAP = Path(f"build") / f"z64.map"
ram_offset is None
or "=" in line
or "*fill*" in line
or " 0x" not in line
):
continue
ram = int(line[16 : 16 + 18], 0) mapPath = BUILTMAP
rom = ram - ram_offset if args.use_expected:
sym = line.split()[-1] mapPath = "expected" / BUILTMAP
if sym.startswith("0x"): mapfile_parser.frontends.sym_info.doSymInfo(mapPath, args.symname)
ram_offset = None
continue
if "/" in sym:
cur_file = sym
continue
if rom == target_addr or (is_ram and ram == target_addr): if __name__ == "__main__":
return f"{sym} (RAM 0x{ram:X}, ROM 0x{rom:X}, {cur_file})" symInfoMain()
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 = "<no 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}")

View file

@ -1,11 +1,11 @@
#!/usr/bin/python3 #!/usr/bin/env python3
import argparse import argparse
from collections import OrderedDict
import os import os
import re
import pickle
import sys 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__)) script_dir = os.path.dirname(os.path.realpath(__file__))
root_dir = script_dir + "/../" root_dir = script_dir + "/../"
@ -54,8 +54,8 @@ def parse_map(fname):
if "noload" in line or "noload" in prev_line: if "noload" in line or "noload" in prev_line:
ram_offset = None ram_offset = None
continue continue
ram = int(line[16 : 16 + 18], 0) ram = int(line[16 : 16 + gAddressWidth], 0)
rom = int(line[59 : 59 + 18], 0) rom = int(line[16 + gAddressWidth + 25 : 16 + gAddressWidth + 25 + gAddressWidth], 0)
ram_offset = ram - rom ram_offset = ram - rom
continue continue
prev_line = line prev_line = line
@ -67,7 +67,7 @@ def parse_map(fname):
or " 0x" not in line or " 0x" not in line
): ):
continue continue
ram = int(line[16 : 16 + 18], 0) ram = int(line[16 : 16 + gAddressWidth], 0)
rom = ram - ram_offset rom = ram - ram_offset
fn = line.split()[-1] fn = line.split()[-1]
if "0x" in fn: if "0x" in fn:

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

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