diff --git a/Makefile b/Makefile index 07449a178..b5c32153b 100644 --- a/Makefile +++ b/Makefile @@ -1,58 +1,122 @@ -# User configurable +################################################################################ +# Options + +# ROMID - The ROM version to build. +# +# Can be set in your environment using +# $ export ROMID=... +# +# Supported values: +# * ntsc-beta +# * ntsc-1.0 +# * ntsc-final +# * pal-beta +# * pal-final +# * jpn-final ROMID ?= ntsc-final -MATCHING ?= 1 -PIRACYCHECKS ?= 1 -# In PD, some code is compiled with IDO 5.3 and some is IDO 7.1. -# The project requires the ido-static-recomp project, which deconstructs the IDO -# compiler and related binaries and recompiles them for your computer's -# architecture. These recompiled compilers and binaries are then used to compile -# the game's source. +# MATCHING - Whether to build a matching ROM (1) or a custom one (0). +# +# Build a matching ROM to prove that the decompilation is accurate. +# +# If enabled, all further options are ignored and are set automatically. -# These are paths to the recompiled compilers -CC53 ?= build/recomp/5.3/cc -CC71 ?= build/recomp/7.1/cc +MATCHING = 1 -# By default we'll compile everything using 5.3, -# as this is what most of the project uses. -CC := $(CC53) +# COMPILER - Choose which compiler to use. +# +# A matching build uses ido. For non-matching builds, use gcc for performance. +# +# gcc is currently only supported when ROMID is ntsc-1.0 or ntsc-final. +# +# Supported values: ido, gcc + +COMPILER = gcc + +# GCC_OPT_LVL - the optimisation level if building with gcc. +# +# Supported values: -O0, -O1, -O2, -Os + +GCC_OPT_LVL = -Os + +# PAL - Whether to use the PAL television standard (1) or NTSC (0). +# +# PAL runs at 50Hz while NTSC is 60Hz, and PAL uses different screen dimensions. + +PAL = 0 ################################################################################ -export ROMID +# The VERSION constant is used in the source to handle version-specific code. +ifeq ($(ROMID), ntsc-beta) + VERSION = 0 +endif +ifeq ($(ROMID), ntsc-1.0) + VERSION = 1 +endif +ifeq ($(ROMID), ntsc-final) + VERSION = 2 +endif +ifeq ($(ROMID), pal-beta) + VERSION = 3 +endif +ifeq ($(ROMID), pal-final) + VERSION = 4 +endif +ifeq ($(ROMID), jpn-final) + VERSION = 5 +endif -PAL=0 -ZIPMAGIC=0x0000 -COPYLEN=2 +# Set runtime piracy checks off. We turn this on for matching builds if needed. +PIRACYCHECKS = 0 -ifeq ($(ROMID),ntsc-beta) - VERSION=0 - PIRACYCHECKS=0 +# A magic value that's only used to produce a matching ROM. +# It's required because old-school zlib was influenced by uninitialised data. +# ZIPMAGIC is the value of the uninitialised data. We set it per version for +# matching builds, otherwise 0 is fine. +ZIPMAGIC = 0x0000 + +# This is also a value that's only used to produce a matching ROM. +# The final ROM has some duplicate bytes, and there doesn't seem to be any logic +# for determining how many bytes are duplicated. +COPYLEN = 2 + +# If a matching build has been requested, override directives as needed. +ifeq ($(MATCHING), 1) +COMPILER = ido + +ifeq ($(ROMID), ntsc-beta) + PAL = 0 + PIRACYCHECKS = 0 endif -ifeq ($(ROMID),ntsc-1.0) - VERSION=1 - ZIPMAGIC=0xffff +ifeq ($(ROMID), ntsc-1.0) + PAL = 0 + PIRACYCHECKS = 1 + ZIPMAGIC = 0xffff endif -ifeq ($(ROMID),ntsc-final) - VERSION=2 - ZIPMAGIC=0xffff +ifeq ($(ROMID), ntsc-final) + PAL = 0 + PIRACYCHECKS = 1 + ZIPMAGIC = 0xffff endif -ifeq ($(ROMID),pal-beta) - PAL=1 - VERSION=3 - ZIPMAGIC=0x0c00 - COPYLEN=6 +ifeq ($(ROMID), pal-beta) + PAL = 1 + PIRACYCHECKS = 1 + ZIPMAGIC = 0x0c00 + COPYLEN = 6 endif -ifeq ($(ROMID),pal-final) - PAL=1 - VERSION=4 - ZIPMAGIC=0xaf00 +ifeq ($(ROMID), pal-final) + PAL = 1 + PIRACYCHECKS = 1 + ZIPMAGIC = 0xaf00 +endif +ifeq ($(ROMID), jpn-final) + PAL = 0 + PIRACYCHECKS = 1 + ZIPMAGIC = 0x0002 + COPYLEN = 4 endif -ifeq ($(ROMID),jpn-final) - VERSION=5 - ZIPMAGIC=0x0002 - COPYLEN=4 endif DEFINES := VERSION=$(VERSION) MATCHING=$(MATCHING) PAL=$(PAL) PIRACYCHECKS=$(PIRACYCHECKS) _FINALROM=1 @@ -64,163 +128,20 @@ A_DIR := src/assets/$(ROMID) B_DIR := build/$(ROMID) E_DIR := extracted/$(ROMID) -ifeq ($(shell type mips-linux-gnu-ld >/dev/null 2>/dev/null; echo $$?), 0) - # Debian, Ubuntu and Arch AUR +ifneq ($(strip $(MIPS_BINUTILS_PREFIX)),) + TOOLCHAIN := $(MIPS_BINUTILS_PREFIX) +else ifneq ($(shell type mips-elf-ld),) + TOOLCHAIN := mips-elf +else ifneq ($(shell type mips-linux-gnu-ld),) TOOLCHAIN := mips-linux-gnu -else ifeq ($(shell type mips64-elf-ld >/dev/null 2>/dev/null; echo $$?), 0) - # Arch AUR +else ifneq ($(shell type mips64-elf-ld),) TOOLCHAIN := mips64-elf -else ifeq ($(shell type mips64-linux-gnu-ld >/dev/null 2>/dev/null; echo $$?), 0) +else ifneq ($(shell type mips64-linux-gnu-ld),) TOOLCHAIN := mips64-linux-gnu else - TOOLCHAIN := mips-elf + $(error You need to install a suitable MIPS binutils toolchain (eg. mips-elf-ld)) endif -AS := $(TOOLCHAIN)-as - -LOOPUNROLL_C_FILES := \ - src/lib/ultra/gu/frustum.c \ - src/lib/ultra/gu/mtxutil.c \ - src/lib/ultra/gu/ortho.c \ - src/lib/ultra/io/conteepread.c \ - src/lib/ultra/io/conteepwrite.c \ - src/lib/ultra/io/contpfs.c \ - src/lib/ultra/io/contramread.c \ - src/lib/ultra/io/contramwrite.c \ - src/lib/ultra/io/gbpakgetstatus.c \ - src/lib/ultra/io/gbpakreadid.c \ - src/lib/ultra/io/motor.c \ - src/lib/ultra/io/pfschecker.c \ - src/lib/ultra/io/pfsfreeblocks.c \ - src/lib/ultra/io/pfsgetstatus.c \ - src/lib/ultra/io/pfsinitpak2.c - -MIPS3_C_FILES := \ - src/lib/ultra/libc/ll.c \ - src/lib/ultra/libc/llcvt.c - -G_C_FILES := \ - $(shell find src/lib/ultra/audio -name '*.c') \ - $(shell find src/lib/naudio -name '*.c') \ - $(shell find src/lib/mp3 -name '*.c') \ - src/lib/lib_2fc60.c \ - src/lib/lib_317f0.c \ - src/lib/lib_39c80.c \ - src/lib/lib_3e3e0.c \ - src/lib/mp3.c \ - src/lib/speaker.c - -O1_C_FILES := \ - src/lib/lib_04f60nb.c \ - src/lib/ultra/io/ai.c \ - src/lib/ultra/io/aisetnextbuf.c \ - src/lib/ultra/io/conteeplongread.c \ - src/lib/ultra/io/contquery.c \ - src/lib/ultra/io/controller.c \ - src/lib/ultra/io/dpctr.c \ - src/lib/ultra/io/pigetcmdq.c \ - src/lib/ultra/io/pidma.c \ - src/lib/ultra/io/si.c \ - src/lib/ultra/io/sp.c \ - src/lib/ultra/io/spsetpc.c \ - src/lib/ultra/io/sptaskyielded.c \ - src/lib/ultra/io/vi.c \ - src/lib/ultra/io/viblack.c \ - src/lib/ultra/io/vigetcurrframebuf.c \ - src/lib/ultra/io/vigetnextframebuf.c \ - src/lib/ultra/io/visetevent.c \ - src/lib/ultra/io/visetmode.c \ - src/lib/ultra/io/visetxscale.c \ - src/lib/ultra/io/visetyscale.c \ - src/lib/ultra/io/viswapbuf.c \ - src/lib/ultra/libc/ll.c \ - src/lib/ultra/libc/llcvt.c \ - src/lib/ultra/os/atomic.c \ - src/lib/ultra/os/createmesgqueue.c \ - src/lib/ultra/os/destroythread.c \ - src/lib/ultra/os/gettime.c \ - src/lib/ultra/os/initialize2.c \ - src/lib/ultra/os/jammesg.c \ - src/lib/ultra/os/recvmesg.c \ - src/lib/ultra/os/resetglobalintmask.c \ - src/lib/ultra/os/sendmesg.c \ - src/lib/ultra/os/seteventmesg.c \ - src/lib/ultra/os/setglobalintmask.c \ - src/lib/ultra/os/setthreadpri.c \ - src/lib/ultra/os/settimer.c \ - src/lib/ultra/os/startthread.c \ - src/lib/ultra/os/stopthread.c \ - src/lib/ultra/os/stoptimer.c \ - src/lib/ultra/os/thread.c \ - src/lib/ultra/os/timerintr.c \ - src/lib/ultra/os/virtualtophysical.c \ - src/lib/ultra/os/yieldthread.c - -ifeq ($(ROMID), ntsc-beta) - O1_C_FILES := $(O1_C_FILES) src/lib/ultra/io/pfsisplug.c -endif - -O3_C_FILES := \ - src/lib/ultra/gu/align.c \ - src/lib/ultra/gu/frustum.c \ - src/lib/ultra/gu/ortho.c \ - src/lib/ultra/gu/scale.c \ - src/lib/ultra/libc/xprintf.c - -IDO71_C_FILES := \ - $(shell find src/lib/ultra/audio -name '*.c') \ - $(shell find src/lib/naudio -name '*.c') \ - $(shell find src/lib/mp3 -name '*.c') \ - src/lib/lib_2fc60.c \ - src/lib/lib_39c80.c - -LOOPUNROLL_O_FILES = $(patsubst src/%.c, $(B_DIR)/%.o, $(LOOPUNROLL_C_FILES)) -MIPS3_O_FILES = $(patsubst src/%.c, $(B_DIR)/%.o, $(MIPS3_C_FILES)) -G_O_FILES = $(patsubst src/%.c, $(B_DIR)/%.o, $(G_C_FILES)) -O1_O_FILES = $(patsubst src/%.c, $(B_DIR)/%.o, $(O1_C_FILES)) -O3_O_FILES = $(patsubst src/%.c, $(B_DIR)/%.o, $(O3_C_FILES)) -IDO71_O_FILES = $(patsubst src/%.c, $(B_DIR)/%.o, $(IDO71_C_FILES)) - -LOOPUNROLL := -Wo,-loopunroll,0 -MIPSISET := -mips2 -32 -OPT_LVL := -O2 - -$(LOOPUNROLL_O_FILES): LOOPUNROLL := -$(MIPS3_O_FILES): MIPSISET := -mips3 -32 -$(G_O_FILES): OPT_LVL := -g -$(O1_O_FILES): OPT_LVL := -O1 -$(O3_O_FILES): OPT_LVL := -O3 -$(IDO71_O_FILES): CC := $(CC71) - -CFLAGS = $(C_DEFINES) \ - $(LOOPUNROLL) \ - -Wab,-r4300_mul \ - -non_shared \ - -Olimit 2000 \ - -G 0 \ - -Xcpluscomm \ - -w2 \ - -Wab,-w \ - -woff 581,649,819,820,821,838,852 \ - -I include \ - -I include/PR \ - -I src/include \ - -I src/generated/$(ROMID) \ - -I src/lib/ultra/audio \ - $(OPT_LVL) \ - $(MIPSISET) - -ASFLAGS = -march=vr4300 -mabi=32 -Iinclude -Iinclude/PR -Isrc/include -Isrc/lib/ultra/audio $(AS_DEFINES) - -C_FILES := $(shell find src/lib src/game src/inflate -name '*.c') -S_FILES := $(shell find src/lib src/game src/preamble -name '*.s') - -# Files containing GLOBAL_ASM must be built with the asm_processor -GLOBALASM_C_FILES != grep -rl 'GLOBAL_ASM(' $(C_FILES) -GLOBALASM_O_FILES = $(patsubst src/%.c, $(B_DIR)/%.o, $(GLOBALASM_C_FILES)) - -$(GLOBALASM_O_FILES): CC := /usr/bin/env python3 tools/asm_processor/build.py $(CC) -- $(TOOLCHAIN)-as $(ASFLAGS) -- - # Asset files are files which are included in the "files" segment of the ROM. # This excludes animations, fonts, SFX, MIDI and textures. # And because setup files are part of the files segment they are included here, @@ -253,9 +174,15 @@ LANG_O_FILES := \ PADS_O_FILES := $(patsubst $(A_DIR)/pads/%.json, $(B_DIR)/assets/files/bgdata/bg_%_padsZ.o, $(PADS_JSON_FILES)) TILES_O_FILES := $(patsubst $(A_DIR)/tiles/%.json, $(B_DIR)/assets/files/bgdata/bg_%_tilesZ.o, $(TILES_JSON_FILES)) +C_FILES := $(shell find src/lib src/game src/inflate -name '*.c') +S_FILES := $(shell find src/lib src/game src/preamble -name '*.s') + +C_O_FILES := $(patsubst src/%.c, $(B_DIR)/%.o, $(C_FILES)) +S_O_FILES := $(patsubst src/%.s, $(B_DIR)/%.o, $(S_FILES)) + O_FILES := \ - $(patsubst src/%.c, $(B_DIR)/%.o, $(C_FILES)) \ - $(patsubst src/%.s, $(B_DIR)/%.o, $(S_FILES)) \ + $(C_O_FILES) \ + $(S_O_FILES) \ $(patsubst %, %.o, $(ASSET_FILES)) \ $(LANG_O_FILES) \ $(PADS_O_FILES) \ @@ -301,57 +228,229 @@ O_FILES := \ # ntsc-beta doesn't have this segment ifneq ($(ROMID), ntsc-beta) - O_FILES := $(O_FILES) $(B_DIR)/assets/accessingpakZ.o + O_FILES := $(O_FILES) $(B_DIR)/assets/accessingpakZ.o endif +INCLUDES = \ + -I include \ + -I include/PR \ + -I src/include \ + -I src/generated/$(ROMID) \ + -I src/lib/ultra/audio \ + +AS := $(TOOLCHAIN)-as +ASFLAGS = -march=vr4300 -mabi=32 $(INCLUDES) $(AS_DEFINES) + +ifeq ($(COMPILER), ido) + RECOMP_FILES := \ + build/recomp/5.3/as1 \ + build/recomp/5.3/cc \ + build/recomp/5.3/cfe \ + build/recomp/5.3/err.english.cc \ + build/recomp/5.3/ugen \ + build/recomp/5.3/ujoin \ + build/recomp/5.3/uld \ + build/recomp/5.3/umerge \ + build/recomp/5.3/uopt \ + build/recomp/5.3/usplit \ + build/recomp/7.1/as1 \ + build/recomp/7.1/cc \ + build/recomp/7.1/cfe \ + build/recomp/7.1/err.english.cc \ + build/recomp/7.1/ugen \ + build/recomp/7.1/uopt + + LOOPUNROLL_C_FILES := \ + src/lib/ultra/gu/frustum.c \ + src/lib/ultra/gu/mtxutil.c \ + src/lib/ultra/gu/ortho.c \ + src/lib/ultra/io/conteepread.c \ + src/lib/ultra/io/conteepwrite.c \ + src/lib/ultra/io/contpfs.c \ + src/lib/ultra/io/contramread.c \ + src/lib/ultra/io/contramwrite.c \ + src/lib/ultra/io/gbpakgetstatus.c \ + src/lib/ultra/io/gbpakreadid.c \ + src/lib/ultra/io/motor.c \ + src/lib/ultra/io/pfschecker.c \ + src/lib/ultra/io/pfsfreeblocks.c \ + src/lib/ultra/io/pfsgetstatus.c \ + src/lib/ultra/io/pfsinitpak2.c + + MIPS3_C_FILES := \ + src/lib/ultra/libc/ll.c \ + src/lib/ultra/libc/llcvt.c + + G_C_FILES := \ + $(shell find src/lib/ultra/audio -name '*.c') \ + $(shell find src/lib/naudio -name '*.c') \ + $(shell find src/lib/mp3 -name '*.c') \ + src/lib/lib_2fc60.c \ + src/lib/lib_317f0.c \ + src/lib/lib_39c80.c \ + src/lib/lib_3e3e0.c \ + src/lib/mp3.c \ + src/lib/speaker.c + + O1_C_FILES := \ + src/lib/lib_04f60nb.c \ + src/lib/ultra/io/ai.c \ + src/lib/ultra/io/aisetnextbuf.c \ + src/lib/ultra/io/conteeplongread.c \ + src/lib/ultra/io/contquery.c \ + src/lib/ultra/io/controller.c \ + src/lib/ultra/io/dpctr.c \ + src/lib/ultra/io/pigetcmdq.c \ + src/lib/ultra/io/pidma.c \ + src/lib/ultra/io/si.c \ + src/lib/ultra/io/sp.c \ + src/lib/ultra/io/spsetpc.c \ + src/lib/ultra/io/sptaskyielded.c \ + src/lib/ultra/io/vi.c \ + src/lib/ultra/io/viblack.c \ + src/lib/ultra/io/vigetcurrframebuf.c \ + src/lib/ultra/io/vigetnextframebuf.c \ + src/lib/ultra/io/visetevent.c \ + src/lib/ultra/io/visetmode.c \ + src/lib/ultra/io/visetxscale.c \ + src/lib/ultra/io/visetyscale.c \ + src/lib/ultra/io/viswapbuf.c \ + src/lib/ultra/libc/ll.c \ + src/lib/ultra/libc/llcvt.c \ + src/lib/ultra/os/atomic.c \ + src/lib/ultra/os/createmesgqueue.c \ + src/lib/ultra/os/destroythread.c \ + src/lib/ultra/os/gettime.c \ + src/lib/ultra/os/initialize2.c \ + src/lib/ultra/os/jammesg.c \ + src/lib/ultra/os/recvmesg.c \ + src/lib/ultra/os/resetglobalintmask.c \ + src/lib/ultra/os/sendmesg.c \ + src/lib/ultra/os/seteventmesg.c \ + src/lib/ultra/os/setglobalintmask.c \ + src/lib/ultra/os/setthreadpri.c \ + src/lib/ultra/os/settimer.c \ + src/lib/ultra/os/startthread.c \ + src/lib/ultra/os/stopthread.c \ + src/lib/ultra/os/stoptimer.c \ + src/lib/ultra/os/thread.c \ + src/lib/ultra/os/timerintr.c \ + src/lib/ultra/os/virtualtophysical.c \ + src/lib/ultra/os/yieldthread.c + + ifeq ($(ROMID), ntsc-beta) + O1_C_FILES := $(O1_C_FILES) src/lib/ultra/io/pfsisplug.c + endif + + O3_C_FILES := \ + src/lib/ultra/gu/align.c \ + src/lib/ultra/gu/frustum.c \ + src/lib/ultra/gu/ortho.c \ + src/lib/ultra/gu/scale.c \ + src/lib/ultra/libc/xprintf.c + + IDO71_C_FILES := \ + $(shell find src/lib/ultra/audio -name '*.c') \ + $(shell find src/lib/naudio -name '*.c') \ + $(shell find src/lib/mp3 -name '*.c') \ + src/lib/lib_2fc60.c \ + src/lib/lib_39c80.c + + LOOPUNROLL_O_FILES = $(patsubst src/%.c, $(B_DIR)/%.o, $(LOOPUNROLL_C_FILES)) + MIPS3_O_FILES = $(patsubst src/%.c, $(B_DIR)/%.o, $(MIPS3_C_FILES)) + G_O_FILES = $(patsubst src/%.c, $(B_DIR)/%.o, $(G_C_FILES)) + O1_O_FILES = $(patsubst src/%.c, $(B_DIR)/%.o, $(O1_C_FILES)) + O3_O_FILES = $(patsubst src/%.c, $(B_DIR)/%.o, $(O3_C_FILES)) + IDO71_O_FILES = $(patsubst src/%.c, $(B_DIR)/%.o, $(IDO71_C_FILES)) + + LOOPUNROLL := -Wo,-loopunroll,0 + MIPSISET := -mips2 + OPT_LVL := -O2 + CC := build/recomp/5.3/cc + + $(LOOPUNROLL_O_FILES): LOOPUNROLL := + $(MIPS3_O_FILES): MIPSISET := -mips3 + $(G_O_FILES): OPT_LVL := -g + $(O1_O_FILES): OPT_LVL := -O1 + $(O3_O_FILES): OPT_LVL := -O3 + $(IDO71_O_FILES): CC := build/recomp/7.1/cc + + CFLAGS = $(C_DEFINES) $(INCLUDES) \ + $(LOOPUNROLL) \ + -Wab,-r4300_mul \ + -non_shared \ + -Olimit 2000 \ + -G 0 \ + -Xcpluscomm \ + -w2 \ + -Wab,-w \ + -woff 581,649,819,820,821,838,852 \ + $(MIPSISET) -32 + + # Files containing GLOBAL_ASM must be built with the asm_processor + ifeq ($(MATCHING), 1) + GLOBALASM_C_FILES != grep -rl 'GLOBAL_ASM(' $(C_FILES) + GLOBALASM_O_FILES = $(patsubst src/%.c, $(B_DIR)/%.o, $(GLOBALASM_C_FILES)) + $(GLOBALASM_O_FILES): CC := /usr/bin/env python3 tools/asm_processor/build.py $(CC) -- $(TOOLCHAIN)-as $(ASFLAGS) -- + endif +else ifeq ($(COMPILER), gcc) + CC := $(TOOLCHAIN)-gcc + + $(C_O_FILES): OPT_LVL := $(GCC_OPT_LVL) + + # Turn off symbol reordering for asset files (eg. stage setups) + # but allow it for source C files. + CFLAGS := $(C_DEFINES) -DAVOID_UB=1 $(INCLUDES) \ + -EB \ + -march=vr4300 \ + -mabi=32 \ + -mfix4300 \ + -mdivide-breaks \ + -ffreestanding \ + -ffast-math \ + -fno-unsafe-math-optimizations \ + -fno-builtin \ + -fno-inline-functions \ + -fno-merge-constants \ + -fno-strict-aliasing \ + -fno-zero-initialized-in-bss \ + -fwrapv \ + -Wall \ + -Werror \ + -Wno-address \ + -Wno-aggressive-loop-optimizations \ + -Wno-array-bounds \ + -Wno-int-in-bool-context \ + -Wno-int-to-pointer-cast \ + -Wno-maybe-uninitialized \ + -Wno-misleading-indentation \ + -Wno-missing-braces \ + -Wno-multichar \ + -Wno-pointer-sign \ + -Wno-pointer-to-int-cast \ + -Wno-tautological-compare \ + -Wno-uninitialized \ + -Wno-unused-but-set-variable \ + -Wno-unused-value \ + -Wno-unused-variable \ + -G 0 +else + $(error The COMPILER option must be "ido" or "gcc") +endif + +# Make ROMID available as an environment variable to all tooling. +# (We use this a lot) +export ROMID + default: rom -################################################################################ -# ROM Finalisation Stages - -# Link all objects together with ld to make stage1.elf. In this stage, the game, -# lib and data segments are uncompressed and placed past the end of the ROM. -$(B_DIR)/stage1.elf: $(O_FILES) ld/pd.ld - cpp -DROMID=$(ROMID) -DVERSION=$(VERSION) -P ld/pd.ld -o $(B_DIR)/pd.ld - $(TOOLCHAIN)-ld --no-check-sections -z muldefs -T $(B_DIR)/pd.ld --print-map -o $@ > $(B_DIR)/pd.map - -$(B_DIR)/stage1.bin: $(B_DIR)/stage1.elf - $(TOOLCHAIN)-objcopy $< $@ -O binary - -# Build the final ROM from stage1.bin using mkrom -# mkrom handles calculating the piracy checksums, zipping segments and -# calculating the ROM checksum. -$(B_DIR)/pd.z64: $(B_DIR)/stage1.bin tools/mkrom/mkrom - tools/mkrom/mkrom $(B_DIR)/stage1.bin $(B_DIR)/pd.map $(PIRACYCHECKS) $(ZIPMAGIC) $(COPYLEN) $@ - -tools/mkrom/mkrom: - $(MAKE) -C tools/mkrom - ################################################################################ # Recomp -# --------------------- +# ------------------------------------------------------------------------------ # The ido-static-recomp project is installed as a git submodule at tools/recomp. # The IRIX binaries are taken from that project and they are recompiled to # build/recomp// -RECOMP_FILES := \ - build/recomp/5.3/as1 \ - build/recomp/5.3/cc \ - build/recomp/5.3/cfe \ - build/recomp/5.3/err.english.cc \ - build/recomp/5.3/ugen \ - build/recomp/5.3/ujoin \ - build/recomp/5.3/uld \ - build/recomp/5.3/umerge \ - build/recomp/5.3/uopt \ - build/recomp/5.3/usplit \ - build/recomp/7.1/as1 \ - build/recomp/7.1/cc \ - build/recomp/7.1/cfe \ - build/recomp/7.1/err.english.cc \ - build/recomp/7.1/ugen \ - build/recomp/7.1/uopt - tools/recomp/recomp.cpp: @echo "Please install ido-static-recomp by running:" @echo @@ -390,6 +489,28 @@ build/recomp/%/err.english.cc: @mkdir -p build/recomp/$? cp tools/err.english.cc build/recomp/$* +################################################################################ +# ROM Finalisation Stages + +# Link all objects together with ld to make stage1.elf. In this stage, the game, +# lib and data segments are uncompressed and placed past the end of the ROM. +$(B_DIR)/stage1.elf: $(O_FILES) ld/pd.ld + cpp -DROMID=$(ROMID) -DVERSION=$(VERSION) -P ld/pd.ld -o $(B_DIR)/pd.ld + $(TOOLCHAIN)-ld --no-check-sections -z muldefs -T $(B_DIR)/pd.ld --print-map -o $@ > $(B_DIR)/pd.map + +$(B_DIR)/stage1.bin: $(B_DIR)/stage1.elf + $(TOOLCHAIN)-objcopy $< $@ -O binary + +# Build the final ROM from stage1.bin using mkrom +# mkrom handles calculating the piracy checksums, zipping segments and +# calculating the ROM checksum. +$(B_DIR)/pd.z64: $(B_DIR)/stage1.bin tools/mkrom/mkrom + tools/mkrom/mkrom $(B_DIR)/stage1.bin $(B_DIR)/pd.map $(PIRACYCHECKS) $(ZIPMAGIC) $(COPYLEN) $@ + @echo -e "\033[0;32mROM written to $@\033[0m" + +tools/mkrom/mkrom: + $(MAKE) -C tools/mkrom + ################################################################################ # Testing Related # --------------------- @@ -575,7 +696,7 @@ $(B_DIR)/assets/accessingpakZ.o: $(B_DIR)/assets/accessingpakZ $(B_DIR)/assets/copyrightZ.o: $(B_DIR)/assets/copyrightZ TOOLCHAIN=$(TOOLCHAIN) ROMID=$(ROMID) tools/mkrawobject $< $@ -$(B_DIR)/rsp/%.text.bin $(B_DIR)/rsp/%.data.bin &: src/rsp/%.s +$(B_DIR)/rsp/%.text.bin $(B_DIR)/rsp/%.data.bin: src/rsp/%.s @mkdir -p $(dir $@) armips -strequ CODE_FILE $(B_DIR)/rsp/$*.text.bin -strequ DATA_FILE $(B_DIR)/rsp/$*.data.bin $< @@ -587,19 +708,21 @@ $(B_DIR)/rsp/%.bin: $(E_DIR)/rsp/%.bin $(B_DIR)/rsp/%.o: $(B_DIR)/rsp/%.bin TOOLCHAIN=$(TOOLCHAIN) ROMID=$(ROMID) tools/mkrawobject $< $@ +ifeq ($(COMPILER), ido) $(B_DIR)/lib/ultra/libc/llcvt.o: src/lib/ultra/libc/llcvt.c $(ASSETMGR_O_FILES) $(RECOMP_FILES) @mkdir -p $(dir $@) - $(CC) -c $(CFLAGS) -o $@ $< + $(CC) -c $(CFLAGS) $(OPT_LVL) -o $@ $< tools/patchmips3 $@ || rm $@ $(B_DIR)/lib/ultra/libc/ll.o: src/lib/ultra/libc/ll.c $(ASSETMGR_O_FILES) $(RECOMP_FILES) @mkdir -p $(dir $@) - $(CC) -c $(CFLAGS) $< -o $@ + $(CC) -c $(CFLAGS) $(OPT_LVL) $< -o $@ tools/patchmips3 $@ || rm $@ +endif $(B_DIR)/%.o: src/%.c $(ASSETMGR_O_FILES) $(RECOMP_FILES) @mkdir -p $(dir $@) - $(CC) -c $(CFLAGS) -o $@ $< + $(CC) -c $(CFLAGS) $(OPT_LVL) -o $@ $< $(B_DIR)/%.o: src/%.s @mkdir -p $(dir $@) diff --git a/docs/challenge7bug.md b/docs/challenge7bug.md index 3d1eea24d..524309e15 100644 --- a/docs/challenge7bug.md +++ b/docs/challenge7bug.md @@ -6,9 +6,9 @@ Thanks to the decompilation project we can easily see all the differences betwee ## The Root Cause -The root cause is in a function that the decomp project has named bgInit which can be found in [src/game/bg.c](src/game/bg.c). This function is somewhat complex so we'll just cover the important parts here. +The root cause is in a function that the decomp project has named bgReset which can be found in [src/game/bg.c](src/game/bg.c). This function is somewhat complex so we'll just cover the important parts here. -bgInit is called while the screen is black after accepting the challenge. It's responsible for loading the background (BG) file for a stage. BG files contain the stage polygon data, room information, a texture list and lighting information among other things. The exact format of the file is not important here, but you just need to know that it contains several sections and some of those sections are compressed, similar to a zip file. +bgReset is called while the screen is black after accepting the challenge. It's responsible for loading the background (BG) file for a stage. BG files contain the stage polygon data, room information, a texture list and lighting information among other things. The exact format of the file is not important here, but you just need to know that it contains several sections and some of those sections are compressed, similar to a zip file. The problem starts when loading the section 2 data, approximately half way into the function. Section 2 is a section of the BG file that is very simple; it's just a compressed list of texture IDs. Let's start by looking at the fix the developers made: @@ -102,7 +102,7 @@ A better fix would be to change the allocation size so it's just the aligned inf The one line tl;dr: When loading the background data for a stage, if the background file contained a specific section that decompressed to a smaller size than the compressed data itself, an overflow would occur due to a miscalculated buffer size. For the overflow to cause any problems the allocation had to be made from the first memory bank and be the exact same size as the remaining space in that bank. If this criteria was met, the overflow would overwrite a pointer in texture data which would cause a crash. The fix that was made increases the allocation to point where it can never be made out of the first bank, therefore avoiding the issue. -But what about the requirement of having 3 players? Why does it not happen with 4? Because each additional player causes an additional player structure to be allocated, and these are made prior to bgInit being called which means they affect the amount of free space in the first bank when bgInit is run. With 1 or 2 players there's going to be more memory available so the issue does not occur. And when playing with 4 players the expansion pak bank starts to be used sooner so the issue does not occur there either. Using 3 players on this particular stage made it total to the exact value that was needed for the onboard bank to be full at this point. In contrast, changing other settings like the number of bots or the weapon loadout would have no effect on this because those are allocated after bgInit is called. +But what about the requirement of having 3 players? Why does it not happen with 4? Because each additional player causes an additional player structure to be allocated, and these are made prior to bgReset being called which means they affect the amount of free space in the first bank when bgReset is run. With 1 or 2 players there's going to be more memory available so the issue does not occur. And when playing with 4 players the expansion pak bank starts to be used sooner so the issue does not occur there either. Using 3 players on this particular stage made it total to the exact value that was needed for the onboard bank to be full at this point. In contrast, changing other settings like the number of bots or the weapon loadout would have no effect on this because those are allocated after bgReset is called. Just to be clear, this situation was incredibly unlucky. Adding or deleting a couple of lines of code anywhere else in the game would have made this a non-issue because it would change the heap size (the heap is sized based on what's left over after code and data). And even if the memory system is in the danger territory, there's a 1 in 455 chance that any number of player structure allocations would line it up in a way that can trigger the bug (each player structure is 7280 bytes and there's a 16 byte window where the bug can occur). diff --git a/include/PR/gbi.h b/include/PR/gbi.h index f1cf71796..50b2698f4 100644 --- a/include/PR/gbi.h +++ b/include/PR/gbi.h @@ -21,6 +21,7 @@ #define _GBI_H_ #include +#include "gbiex.h" /* * To use the F3DEX ucodes, define F3DEX_GBI before include this file. diff --git a/include/PR/gu.h b/include/PR/gu.h index f7a57ac4b..7744bdf92 100644 --- a/include/PR/gu.h +++ b/include/PR/gu.h @@ -32,7 +32,7 @@ #define MIN(a,b) (((a)<(b))?(a):(b)) #endif -#define M_PI 3.14159265358979323846 +#define OS_M_PI 3.14159265358979323846 #define M_DTOR (3.14159265358979323846/180.0) #define FTOFIX32(x) (long)((x) * (float)0x00010000) @@ -69,10 +69,10 @@ typedef struct { * Function Prototypes */ -extern int guLoadTextureBlockMipMap(Gfx **glist, unsigned char *tbuf, Image *im, - unsigned char startTile, unsigned char pal, unsigned char cms, - unsigned char cmt, unsigned char masks, unsigned char maskt, - unsigned char shifts, unsigned char shiftt, unsigned char cfs, +extern int guLoadTextureBlockMipMap(Gfx **glist, unsigned char *tbuf, Image *im, + unsigned char startTile, unsigned char pal, unsigned char cms, + unsigned char cmt, unsigned char masks, unsigned char maskt, + unsigned char shifts, unsigned char shiftt, unsigned char cfs, unsigned char cft); extern int guGetDPLoadTextureTileSz (int ult, int lrt); @@ -86,7 +86,7 @@ extern void guDPLoadTextureTile (Gfx *glistp, void *timg, int shifts, int shiftt); -/* +/* * matrix operations: * * The 'F' version is floating point, in case the application wants @@ -95,19 +95,19 @@ extern void guDPLoadTextureTile (Gfx *glistp, void *timg, */ extern void guMtxIdent(Mtx *m); extern void guMtxIdentF(float mf[4][4]); -extern void guOrtho(Mtx *m, float l, float r, float b, float t, +extern void guOrtho(Mtx *m, float l, float r, float b, float t, float n, float f, float scale); -extern void guOrthoF(float mf[4][4], float l, float r, float b, float t, +extern void guOrthoF(float mf[4][4], float l, float r, float b, float t, float n, float f, float scale); -extern void guFrustum(Mtx *m, float l, float r, float b, float t, +extern void guFrustum(Mtx *m, float l, float r, float b, float t, float n, float f, float scale); -extern void guFrustumF(float mf[4][4], float l, float r, float b, float t, +extern void guFrustumF(float mf[4][4], float l, float r, float b, float t, float n, float f, float scale); -extern void guPerspective(Mtx *m, u16 *perspNorm, float fovy, +extern void guPerspective(Mtx *m, u16 *perspNorm, float fovy, float aspect, float near, float far, float scale); -extern void guPerspectiveF(float mf[4][4], u16 *perspNorm, float fovy, +extern void guPerspectiveF(float mf[4][4], u16 *perspNorm, float fovy, float aspect, float near, float far, float scale); -extern void guLookAt(Mtx *m, +extern void guLookAt(Mtx *m, float xEye, float yEye, float zEye, float xAt, float yAt, float zAt, float xUp, float yUp, float zUp); @@ -118,7 +118,7 @@ extern void guLookAtReflect(Mtx *m, LookAt *l, float xEye, float yEye, float zEye, float xAt, float yAt, float zAt, float xUp, float yUp, float zUp); -extern void guLookAtReflectF(float mf[4][4], LookAt *l, +extern void guLookAtReflectF(float mf[4][4], LookAt *l, float xEye, float yEye, float zEye, float xAt, float yAt, float zAt, float xUp, float yUp, float zUp); @@ -129,22 +129,22 @@ extern void guLookAtHilite(Mtx *m, LookAt *l, Hilite *h, float xl1, float yl1, float zl1, float xl2, float yl2, float zl2, int twidth, int theight); -extern void guLookAtHiliteF(float mf[4][4], LookAt *l, Hilite *h, +extern void guLookAtHiliteF(float mf[4][4], LookAt *l, Hilite *h, float xEye, float yEye, float zEye, float xAt, float yAt, float zAt, float xUp, float yUp, float zUp, float xl1, float yl1, float zl1, float xl2, float yl2, float zl2, int twidth, int theight); -extern void guLookAtStereo(Mtx *m, +extern void guLookAtStereo(Mtx *m, float xEye, float yEye, float zEye, float xAt, float yAt, float zAt, - float xUp, float yUp, float zUp, + float xUp, float yUp, float zUp, float eyedist); -extern void guLookAtStereoF(float mf[4][4], +extern void guLookAtStereoF(float mf[4][4], float xEye, float yEye, float zEye, float xAt, float yAt, float zAt, - float xUp, float yUp, float zUp, + float xUp, float yUp, float zUp, float eyedist); extern void guRotate(Mtx *m, float a, float x, float y, float z); extern void guRotateF(float mf[4][4], float a, float x, float y, float z); @@ -164,9 +164,9 @@ extern void guMtxF2L(float mf[4][4], Mtx *m); extern void guMtxL2F(float mf[4][4], Mtx *m); extern void guMtxCatF(float m[4][4], float n[4][4], float r[4][4]); extern void guMtxCatL(Mtx *m, Mtx *n, Mtx *res); -extern void guMtxXFMF(float mf[4][4], float x, float y, float z, +extern void guMtxXFMF(float mf[4][4], float x, float y, float z, float *ox, float *oy, float *oz); -extern void guMtxXFML(Mtx *m, float x, float y, float z, +extern void guMtxXFML(Mtx *m, float x, float y, float z, float *ox, float *oy, float *oz); /* vector utility: */ @@ -207,8 +207,8 @@ extern float sqrtf(float value); extern void guParseRdpDL(u64 *rdp_dl, u64 nbytes, u8 flags); extern void guParseString(char *StringPointer, u64 nbytes); -/* - * NO LONGER SUPPORTED, +/* + * NO LONGER SUPPORTED, * use guParseRdpDL with GU_PARSERDP_DUMPONLY flags */ /* extern void guDumpRawRdpDL(u64 *rdp_dl, u64 nbytes); */ @@ -223,7 +223,7 @@ guBlinkRdpDL(u64 *rdp_dl_in, u64 nbytes_in, u32 x, u32 y, u32 radius, u8 red, u8 green, u8 blue, u8 flags); - + /* flag values for guParseGbiDL() */ #define GU_PARSEGBI_ROWMAJOR 1 #define GU_PARSEGBI_NONEST 2 @@ -252,7 +252,7 @@ typedef struct { u32 paddr; } guDLPrintCB; -void guSprite2DInit(uSprite *SpritePointer, +void guSprite2DInit(uSprite *SpritePointer, void *SourceImagePointer, void *TlutPointer, int Stride, diff --git a/include/PR/libaudio.h b/include/PR/libaudio.h index d20a6b748..74c951c40 100644 --- a/include/PR/libaudio.h +++ b/include/PR/libaudio.h @@ -34,6 +34,7 @@ extern "C" { #endif #include +#include #include /*********************************************************************** @@ -300,10 +301,7 @@ typedef struct { ALHeap *heap; s32 outputRate; /* output sample rate */ ALFxId fxTypes[4]; - - // This should be [4], but this causes too much stack usage in sndInit. - // May have to figure out what sndInit's sp7c is before this can be fixed. - s32 *params[1]; + s32 *params[2]; } ALSynConfig; typedef struct ALPlayer_s { diff --git a/include/PR/n_libaudio.h b/include/PR/n_libaudio.h index 8840668c4..f707f00a4 100644 --- a/include/PR/n_libaudio.h +++ b/include/PR/n_libaudio.h @@ -402,6 +402,8 @@ extern long long int n_aspMainDataStart[], n_aspMainDataEnd[]; f32 func0003b9d4(s32 arg0); void func0003ba64(struct fx *fx, f32 outputrate); +s16 _getRate(f32 vol, f32 tgt, s32 count, u16 *ratel); +s16 _getVol(s16 ivol, s32 samples, s16 ratem, u16 ratel); #ifdef _LANGUAGE_C_PLUS_PLUS } diff --git a/include/PR/os_motor.h b/include/PR/os_motor.h index f8dcbd5a3..34e14fd7a 100644 --- a/include/PR/os_motor.h +++ b/include/PR/os_motor.h @@ -1,7 +1,7 @@ /*---------------------------------------------------------------------* Copyright (C) 1998 Nintendo. - + $RCSfile: os_motor.h,v $ $Revision: 1.1 $ $Date: 1998/10/09 08:01:15 $ @@ -68,6 +68,7 @@ extern s32 osMotorInit(OSMesgQueue *, OSPfs *, int); #define osMotorStart(x) __osMotorAccess((x), MOTOR_START) #define osMotorStop(x) __osMotorAccess((x), MOTOR_STOP) extern s32 __osMotorAccess(OSPfs *, s32); +s32 osMotorProbe(OSMesgQueue* ctrlrqueue, OSPfs* pfs, s32 channel); #else extern s32 osMotorStop(OSPfs *); extern s32 osMotorStart(OSPfs *); diff --git a/include/PR/os_pfs.h b/include/PR/os_pfs.h index 59f35695f..4e7d8c869 100644 --- a/include/PR/os_pfs.h +++ b/include/PR/os_pfs.h @@ -153,21 +153,21 @@ s32 osPfsInitPak(OSMesgQueue *queue, OSPfs *pfs, s32 channel, s32 *arg3); #else s32 osPfsInitPak(OSMesgQueue *queue, OSPfs *pfs, s32 channel); #endif -extern s32 osPfsRepairId(OSPfs *); -extern s32 osPfsInit(OSMesgQueue *, OSPfs *, int); -extern s32 osPfsReFormat(OSPfs *, OSMesgQueue *, int); -extern s32 osPfsChecker(OSPfs *); -extern s32 osPfsAllocateFile(OSPfs *, u16, u32, u8 *, u8 *, int, s32 *); -extern s32 osPfsFindFile(OSPfs *, u16, u32, u8 *, u8 *, s32 *); -extern s32 osPfsDeleteFile(OSPfs *, u16, u32, u8 *, u8 *); -extern s32 osPfsReadWriteFile(OSPfs *, s32, u8, int, int, u8 *); -extern s32 osPfsFileState(OSPfs *, s32, OSPfsState *); -extern s32 osPfsGetLabel(OSPfs *, u8 *, int *); -extern s32 osPfsSetLabel(OSPfs *, u8 *); -extern s32 osPfsIsPlug(OSMesgQueue *, u8 *); -extern s32 osPfsFreeBlocks(OSPfs *, s32 *); -extern s32 osPfsNumFiles(OSPfs *, s32 *, s32 *); - +s32 osPfsRepairId(OSPfs *); +s32 osPfsInit(OSMesgQueue *, OSPfs *, int); +s32 osPfsReFormat(OSPfs *, OSMesgQueue *, int); +s32 osPfsChecker(OSPfs *); +s32 osPfsAllocateFile(OSPfs *, u16, u32, u8 *, u8 *, int, s32 *); +s32 osPfsFindFile(OSPfs *, u16, u32, u8 *, u8 *, s32 *); +s32 osPfsDeleteFile(OSPfs *, u16, u32, u8 *, u8 *); +s32 osPfsReadWriteFile(OSPfs *, s32, u8, int, int, u8 *); +s32 osPfsFileState(OSPfs *, s32, OSPfsState *); +s32 osPfsGetLabel(OSPfs *, u8 *, int *); +s32 osPfsSetLabel(OSPfs *, u8 *); +s32 osPfsIsPlug(OSMesgQueue *, u8 *); +s32 osPfsFreeBlocks(OSPfs *, s32 *); +s32 osPfsNumFiles(OSPfs *, s32 *, s32 *); +s32 osPfsReSizeFile(OSPfs *pfs, u16 company_code, u32 game_code, u8 *game_name, u8 *ext_name, int length); #endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ diff --git a/ld/pd.ld b/ld/pd.ld index f9794e8d1..bad372168 100644 --- a/ld/pd.ld +++ b/ld/pd.ld @@ -38,6 +38,7 @@ BEGIN_SEG(mpstrings##lang) \ { \ build/ROMID/assets/mpstrings/mpstrings##lang.o (.data); \ + . = ALIGN(0x10); \ } \ END_SEG(mpstrings##lang) @@ -45,6 +46,7 @@ varname = __rompos; \ .file##id : AT(__rompos) { \ build/ROMID/assets/files/filename.o (.data); \ + . = ALIGN(0x10); \ } \ __rompos += SIZEOF(.file##id) @@ -52,6 +54,7 @@ BEGIN_SEG(font##name) \ { \ build/ROMID/assets/fonts/name.o (.data); \ + . = ALIGN(0x10); \ } \ END_SEG(font##name) @@ -198,10 +201,11 @@ SECTIONS __rompos = 0x02000000; __rampos = 0x70001050; - BEGIN_SEG(lib) SUBALIGN(16) + BEGIN_SEG(lib) SUBALIGN(0x10) { LIBFILES(.text) LIBFILES(.rodata) + . = ALIGN(0x10); } END_SEG(lib) @@ -231,6 +235,7 @@ SECTIONS GAMEFILES(.data) build/ROMID/rsp/gsp.data.o (.data); build/ROMID/rsp/asp.data.o (.data); + . = ALIGN(0x10); } END_SEG(data) @@ -258,6 +263,7 @@ SECTIONS { LIBFILES(.bss) GAMEFILES(.bss) + . = ALIGN(0x10); } END_SEG(bss) @@ -277,6 +283,9 @@ SECTIONS { build/ROMID/inflate/inflate.o (.text); build/ROMID/inflate/inflate.o (.data); + build/ROMID/inflate/inflate.o (.bss); + build/ROMID/inflate/inflate.o (.rodata); + . = ALIGN(0x10); } END_SEG(inflate) @@ -297,6 +306,7 @@ SECTIONS { GAMEFILES(.text) GAMEFILES(.rodata) + . = ALIGN(0x10); } END_SEG(game) @@ -345,6 +355,7 @@ SECTIONS BEGIN_SEG(mpconfigs) { build/ROMID/mpconfigs.o (.data); + . = ALIGN(0x10); } END_SEG(mpconfigs) @@ -375,6 +386,7 @@ SECTIONS BEGIN_SEG(firingrange) { build/ROMID/firingrange.o (.data); + . = ALIGN(0x10); } END_SEG(firingrange) @@ -391,6 +403,7 @@ SECTIONS BEGIN_SEG(textureconfig) { build/ROMID/textureconfig.o (.data); + . = ALIGN(0x10); } END_SEG(textureconfig) @@ -547,6 +560,7 @@ SECTIONS { build/ROMID/assets/files/list.o (.data); build/ROMID/assets/files/list.o (.rodata); + . = ALIGN(0x10); } END_SEG(filenames) diff --git a/ld/zero.ld b/ld/zero.ld index b36cf243f..96469da8e 100644 --- a/ld/zero.ld +++ b/ld/zero.ld @@ -5,10 +5,12 @@ SECTIONS { .data 0x00000000 : AT(0x0000) { __FILE__ (.data); + . = ALIGN(0x10); } .rodata : AT(SIZEOF(.data)) { __FILE__ (.rodata); + . = ALIGN(0x10); } /DISCARD/ : { diff --git a/src/game/acosasin.c b/src/game/acosasin.c index 79c5f407f..b413511f2 100644 --- a/src/game/acosasin.c +++ b/src/game/acosasin.c @@ -13,22 +13,16 @@ u16 var8006ae90[] = { 0x5555, 0x53db, 0x525c, 0x50d9, 0x4f51, 0x4dc5, 0x4c32, 0x4a9a, 0x48fc, 0x4757, 0x45ab, 0x43f7, 0x423a, 0x4075, 0x3ea5, 0x3ccb, 0x3ae5, 0x38f1, 0x36ef, 0x34dc, 0x32b7, 0x307d, 0x2e2b, 0x2bbd, - 0x292e, 0x2678, 0x2391, 0x206c, 0x1cf6, 0x0000, -}; - -u16 var8006af0c[] = { - 0x1cf6, 0x1cbb, 0x1c80, 0x1c45, 0x1c08, 0x1bcc, 0x1b8f, 0x1b51, - 0x1b13, 0x1ad4, 0x1a95, 0x1a55, 0x1a14, 0x19d3, 0x1992, 0x194f, - 0x190c, 0x18c9, 0x1884, 0x183f, 0x17f9, 0x17b3, 0x176b, 0x1723, - 0x16da, 0x1690, 0x1645, 0x15f9, 0x15ac, 0x155e, 0x150f, 0x14be, - 0x146d, 0x141a, 0x13c6, 0x1370, 0x1319, 0x12c1, 0x1267, 0x120b, - 0x11ad, 0x114e, 0x10ec, 0x1088, 0x1022, 0x0fb9, 0x0f4d, 0x0ede, - 0x0e6c, 0x0df7, 0x0d7d, 0x0d00, 0x0c7d, 0x0bf4, 0x0b66, 0x0ad0, - 0x0a31, 0x0989, 0x08d3, 0x080e, 0x0734, 0x063d, 0x0518, 0x039a, -}; - -u16 var8006af8c[] = { - 0x039a, 0x031e, 0x028c, 0x01cd, + 0x292e, 0x2678, 0x2391, 0x206c, 0x1cf6, 0x0000, 0x1cf6, 0x1cbb, + 0x1c80, 0x1c45, 0x1c08, 0x1bcc, 0x1b8f, 0x1b51, 0x1b13, 0x1ad4, + 0x1a95, 0x1a55, 0x1a14, 0x19d3, 0x1992, 0x194f, 0x190c, 0x18c9, + 0x1884, 0x183f, 0x17f9, 0x17b3, 0x176b, 0x1723, 0x16da, 0x1690, + 0x1645, 0x15f9, 0x15ac, 0x155e, 0x150f, 0x14be, 0x146d, 0x141a, + 0x13c6, 0x1370, 0x1319, 0x12c1, 0x1267, 0x120b, 0x11ad, 0x114e, + 0x10ec, 0x1088, 0x1022, 0x0fb9, 0x0f4d, 0x0ede, 0x0e6c, 0x0df7, + 0x0d7d, 0x0d00, 0x0c7d, 0x0bf4, 0x0b66, 0x0ad0, 0x0a31, 0x0989, + 0x08d3, 0x080e, 0x0734, 0x063d, 0x0518, 0x039a, 0x039a, 0x031e, + 0x028c, 0x01cd, 0x0000, }; s32 func0f096890(s32 arg0) @@ -43,17 +37,17 @@ s32 func0f096890(s32 arg0) if (arg0 >= 32736) { mask = 0x07; shiftamount = 3; - array = var8006af8c; + array = &var8006ae90[126]; arg0 -= 32736; } else if (arg0 >= 30720) { mask = 0x1f; shiftamount = 5; - array = var8006af0c; + array = &var8006ae90[62]; arg0 -= 30720; } else { mask = 0x1ff; shiftamount = 9; - array = var8006ae90; + array = &var8006ae90[0]; } index = arg0 >> shiftamount; diff --git a/src/game/acosfasinf.c b/src/game/acosfasinf.c index fa308d549..b13568869 100644 --- a/src/game/acosfasinf.c +++ b/src/game/acosfasinf.c @@ -17,7 +17,7 @@ f32 acosf(f32 value) intval = value * 32767.0f; } - return (acos(intval) * M_PI) / 65535.0f; + return acos(intval) * M_PI / 65535.0f; } f32 asinf(f32 value) @@ -29,8 +29,8 @@ f32 asinf(f32 value) } else if (value <= -1) { intval = -32767; } else { - intval = (value * 32767.0f); + intval = value * 32767.0f; } - return (asin(intval) * M_PI) / 65535.0f; + return asin(intval) * M_PI / 65535.0f; } diff --git a/src/game/activemenu.c b/src/game/activemenu.c index d94e5ffee..dce7b166e 100644 --- a/src/game/activemenu.c +++ b/src/game/activemenu.c @@ -22,6 +22,7 @@ #include "lib/main.h" #include "lib/mtx.h" #include "lib/ailist.h" +#include "lib/str.h" #include "data.h" #include "types.h" @@ -176,7 +177,7 @@ s32 amPickTargetMenuList(s32 operation, struct menuitem *item, union handlerdata } } while (numremaining >= 0); - colour = teamcolours[g_MpAllChrConfigPtrs[chrindex]->team] | renderdata->colour & 0xff; + colour = teamcolours[g_MpAllChrConfigPtrs[chrindex]->team] | (renderdata->colour & 0xff); if (renderdata->unk10) { u32 weight = menuGetSinOscFrac(40) * 255; @@ -374,7 +375,7 @@ void amApply(s32 slot) case 1: // Function if (g_Vars.currentplayer->gunctrl.weaponnum >= WEAPON_UNARMED && g_Vars.currentplayer->gunctrl.weaponnum <= WEAPON_COMBATBOOST - && g_PlayerConfigsArray[g_Vars.currentplayerstats->mpindex].gunfuncs[(g_Vars.currentplayer->gunctrl.weaponnum - 1) >> 3] & (1 << (g_Vars.currentplayer->gunctrl.weaponnum - 1 & 7))) { + && g_PlayerConfigsArray[g_Vars.currentplayerstats->mpindex].gunfuncs[(g_Vars.currentplayer->gunctrl.weaponnum - 1) >> 3] & (1 << ((g_Vars.currentplayer->gunctrl.weaponnum - 1) & 7))) { if (slot == 1) { g_AmMenus[g_AmIndex].togglefunc = true; } @@ -469,10 +470,7 @@ void amGetSlotDetails(s32 slot, u32 *flags, char *label) secfunc = weaponGetFunction(&g_Vars.currentplayer->hands[HAND_RIGHT].gset, FUNC_SECONDARY); if (slot == 1) { - if (!secfunc - || g_Vars.currentplayer->gunctrl.weaponnum < WEAPON_UNARMED - || g_Vars.currentplayer->gunctrl.weaponnum > WEAPON_COMBATBOOST - || (g_PlayerConfigsArray[g_Vars.currentplayerstats->mpindex].gunfuncs[(g_Vars.currentplayer->gunctrl.weaponnum - 1) >> 3] & (1 << (g_Vars.currentplayer->gunctrl.weaponnum - 1 & 7))) == 0) { + if (!secfunc || !FUNCISSEC()) { *flags |= AMSLOTFLAG_CURRENT; } @@ -480,10 +478,7 @@ void amGetSlotDetails(s32 slot, u32 *flags, char *label) strcpy(label, langGet(prifunc->name)); } } else { - if (!prifunc || ( - g_Vars.currentplayer->gunctrl.weaponnum >= WEAPON_UNARMED - && g_Vars.currentplayer->gunctrl.weaponnum <= WEAPON_COMBATBOOST - && g_PlayerConfigsArray[g_Vars.currentplayerstats->mpindex].gunfuncs[(g_Vars.currentplayer->gunctrl.weaponnum - 1) >> 3] & (1 << (g_Vars.currentplayer->gunctrl.weaponnum - 1 & 7)))) { + if (!prifunc || FUNCISSEC()) { *flags |= AMSLOTFLAG_CURRENT; } diff --git a/src/game/activemenutick.c b/src/game/activemenutick.c index d107483fe..d5a928cb8 100644 --- a/src/game/activemenutick.c +++ b/src/game/activemenutick.c @@ -9,6 +9,7 @@ #include "game/options.h" #include "bss.h" #include "lib/joy.h" +#include "lib/str.h" #include "data.h" #include "types.h" diff --git a/src/game/bg.c b/src/game/bg.c index 2b1e4bae6..0e286bb34 100644 --- a/src/game/bg.c +++ b/src/game/bg.c @@ -3,6 +3,7 @@ #include "game/debug.h" #include "game/dlights.h" #include "game/game_006900.h" +#include "game/portal.h" #include "game/room.h" #include "game/chr.h" #include "game/prop.h" @@ -28,6 +29,7 @@ #include "game/texdecompress.h" #include "game/wallhit.h" #include "bss.h" +#include "lib/lib_17ce0.h" #include "lib/rzip.h" #include "lib/vi.h" #include "lib/dma.h" @@ -38,6 +40,7 @@ #include "lib/mtx.h" #include "lib/lib_2f490.h" #include "data.h" +#include "gbiex.h" #include "types.h" #define BGCMD_END 0x00 @@ -266,7 +269,7 @@ Gfx *bg0f158184(Gfx *gdl, struct xraydata *xraydata) { struct gfxvtx *vertices; u32 *colours; - s32 end; + s32 numgroups; s32 i; s32 count; @@ -288,13 +291,22 @@ Gfx *bg0f158184(Gfx *gdl, struct xraydata *xraydata) count = xraydata->numvertices; gDPSetVerticeArray(gdl++, vertices, count); - end = (xraydata->numtris - 1) / 4 + 1; + numgroups = (xraydata->numtris - 1) / 4 + 1; + // @bug: The original code overflows the tris array and unintentionally writes zero + // into the xraydata->numtris property. IDO reloads the xraydata->numtris value + // on each loop iteration so it reads the 0 value and ends the loop. +#ifdef AVOID_UB + for (i = xraydata->numtris; i < numgroups * 4; i++) { + xraydata->tris[i][0] = xraydata->tris[i][1] = xraydata->tris[i][2] = 0; + } +#else for (i = xraydata->numtris; i < xraydata->numtris * 4; i++) { xraydata->tris[i][0] = xraydata->tris[i][1] = xraydata->tris[i][2] = 0; } +#endif - for (i = 0; i < end; i++) { + for (i = 0; i < numgroups; i++) { gDPTri4(gdl++, xraydata->tris[i * 4 + 0][0], xraydata->tris[i * 4 + 0][1], xraydata->tris[i * 4 + 0][2], xraydata->tris[i * 4 + 1][0], xraydata->tris[i * 4 + 1][1], xraydata->tris[i * 4 + 1][2], @@ -2619,17 +2631,17 @@ void bgReset(s32 stagenum) g_BgPrimaryData = mempAlloc(ALIGN16(inflatedsize + 0x8010), MEMPOOL_STAGE); // Set up pointer to scratch space - scratch = ((u32)g_BgPrimaryData + inflatedsize) - primcompsize; + scratch = (u32) g_BgPrimaryData + inflatedsize - primcompsize; scratch = ALIGN16(scratch + 0x8000); g_LoadType = LOADTYPE_BG; // Copy section 1 header + compressed primary to scratch space - bgLoadFile((u8 *)scratch, 0, ALIGN16(primcompsize + 15)); + bgLoadFile((u8 *) scratch, 0, ALIGN16(primcompsize + 15)); // Inflate primary data to the start of the buffer scratch += 0xc; - bgInflate((u8 *)scratch, g_BgPrimaryData, primcompsize); + bgInflate((u8 *) scratch, g_BgPrimaryData, primcompsize); // Shrink the allocation (ie. free the scratch space) mempRealloc(g_BgPrimaryData, inflatedsize, MEMPOOL_STAGE); @@ -2639,30 +2651,33 @@ void bgReset(s32 stagenum) bgLoadFile(header, section2start, 0x40); - inflatedsize = (*(u16 *)&header[0] & 0x7fff) - 1; - section2compsize = *(u16 *)&header[2]; + inflatedsize = (*(u16 *) &header[0] & 0x7fff) - 1; + section2compsize = *(u16 *) &header[2]; inflatedsize = (inflatedsize | 0xf) + 1; // Allocate space for the section 2 data (texture ID list). // This is the cause and fix for the Challenge 7 memory corruption bug in // NTSC 1.0. A full writeup about the bug and how the fix works can be found // in the docs folder of this project. -#if VERSION >= VERSION_NTSC_FINAL +#ifdef AVOID_UB + section2 = mempAlloc(inflatedsize + section2compsize, MEMPOOL_STAGE); + scratch = (u32) section2 + inflatedsize; +#elif VERSION >= VERSION_NTSC_FINAL section2 = mempAlloc(inflatedsize + 0x8000, MEMPOOL_STAGE); - scratch = (u32)section2 + 0x8000; + scratch = (u32) section2 + 0x8000; #else section2 = mempAlloc(inflatedsize + 0x800, MEMPOOL_STAGE); - scratch = (u32)section2 + 0x800; + scratch = (u32) section2 + 0x800; #endif // Load compressed data from ROM to scratch - bgLoadFile((u8 *)scratch, section2start + 4, ((section2compsize - 1) | 0xf) + 1); + bgLoadFile((u8 *) scratch, section2start + 4, ((section2compsize - 1) | 0xf) + 1); // Inflate section 2 to the start of the buffer - bgInflate((u8 *)scratch, (u8 *)section2, section2compsize); + bgInflate((u8 *) scratch, (u8 *) section2, section2compsize); // Iterate texture IDs and ensure they're loaded - inflatedsize = (*(u16 *)&header[0] & 0x7fff) >> 1; + inflatedsize = (*(u16 *) &header[0] & 0x7fff) >> 1; for (i = 0; i != inflatedsize; i++) { texLoadFromTextureNum(section2[i], NULL); diff --git a/src/game/bondgun.c b/src/game/bondgun.c index b0028c8ea..d36498245 100644 --- a/src/game/bondgun.c +++ b/src/game/bondgun.c @@ -16,6 +16,7 @@ #include "game/bondgun.h" #include "game/gunfx.h" #include "game/game_0b0fd0.h" +#include "game/modeldef.h" #include "game/modelmgr.h" #include "game/tex.h" #include "game/camera.h" @@ -39,6 +40,7 @@ #include "game/propobj.h" #include "game/objectives.h" #include "bss.h" +#include "lib/collision.h" #include "lib/vi.h" #include "lib/joy.h" #include "lib/main.h" @@ -153,12 +155,8 @@ struct fireslot g_Fireslots[NUM_FIRESLOTS]; u32 fill2[1]; #endif -u32 var80070090 = 0x96969600; -u32 var80070094 = 0x96969600; -u32 var80070098 = 0xffffff00; -u32 var8007009c = 0xffffff00; -u32 var800700a0 = 0xb24d2e00; -u32 var800700a4 = 0x00000000; +Lights1 var80070090 = gdSPDefLights1(0x96, 0x96, 0x96, 0xff, 0xff, 0xff, 0xb2, 0x4d, 0x2e); + u32 var800700a8 = 0x00025800; u32 var800700ac = 0x0001e000; @@ -2880,9 +2878,7 @@ s32 bgunTickIncIdle(struct handweaponinfo *info, s32 handnum, struct hand *hand, } // Consider switching to other gun function - usesec = g_Vars.currentplayer->gunctrl.weaponnum >= WEAPON_UNARMED - && g_Vars.currentplayer->gunctrl.weaponnum <= WEAPON_COMBATBOOST - && (g_PlayerConfigsArray[g_Vars.currentplayerstats->mpindex].gunfuncs[(g_Vars.currentplayer->gunctrl.weaponnum - 1) >> 3] & (1 << (g_Vars.currentplayer->gunctrl.weaponnum - 1 & 7))); + usesec = FUNCISSEC(); if (usesec == gunfunc) { sp30 = bgun0f098ca0(1 - hand->gset.weaponfunc, info, hand); @@ -10185,10 +10181,10 @@ glabel var7f1aca90 /* f0a747c: ad6e0004 */ sw $t6,0x4($t3) /* f0a7480: 8faf014c */ lw $t7,0x14c($sp) /* f0a7484: 3c090386 */ lui $t1,0x386 -/* f0a7488: 3c088007 */ lui $t0,%hi(var80070098) +/* f0a7488: 3c088007 */ lui $t0,%hi(var80070090+0x08) /* f0a748c: 25ec0008 */ addiu $t4,$t7,0x8 /* f0a7490: afac014c */ sw $t4,0x14c($sp) -/* f0a7494: 25080098 */ addiu $t0,$t0,%lo(var80070098) +/* f0a7494: 25080098 */ addiu $t0,$t0,%lo(var80070090+0x08) /* f0a7498: 35290010 */ ori $t1,$t1,0x10 /* f0a749c: ade90000 */ sw $t1,0x0($t7) /* f0a74a0: ade80004 */ sw $t0,0x4($t7) @@ -11026,10 +11022,10 @@ glabel var7f1aca90 /* f0a747c: ad6e0004 */ sw $t6,0x4($t3) /* f0a7480: 8faf014c */ lw $t7,0x14c($sp) /* f0a7484: 3c090386 */ lui $t1,0x386 -/* f0a7488: 3c088007 */ lui $t0,%hi(var80070098) +/* f0a7488: 3c088007 */ lui $t0,%hi(var80070090+0x08) /* f0a748c: 25ec0008 */ addiu $t4,$t7,0x8 /* f0a7490: afac014c */ sw $t4,0x14c($sp) -/* f0a7494: 25080098 */ addiu $t0,$t0,%lo(var80070098) +/* f0a7494: 25080098 */ addiu $t0,$t0,%lo(var80070090+0x08) /* f0a7498: 35290010 */ ori $t1,$t1,0x10 /* f0a749c: ade90000 */ sw $t1,0x0($t7) /* f0a74a0: ade80004 */ sw $t0,0x4($t7) @@ -12528,9 +12524,7 @@ void bgunRender(Gfx **gdlptr) gdl = beamRender(gdl, &hand->beam, 0, 0); if (weaponHasFlag(hand->gset.weaponnum, WEAPONFLAG_00008000)) { - gSPNumLights(gdl++, 1); - gSPLight(gdl++, &var80070098, 1); - gSPLight(gdl++, &var80070090, 2); + gSPSetLights1(gdl++, var80070090); gSPLookAt(gdl++, camGetLookAt()); } @@ -13242,8 +13236,6 @@ void bgunSetTriggerOn(s32 handnum, bool on) } } -#define VALIDWEAPON() (g_Vars.currentplayer->gunctrl.weaponnum >= WEAPON_UNARMED && g_Vars.currentplayer->gunctrl.weaponnum <= WEAPON_COMBATBOOST) -#define GETFUNC() (VALIDWEAPON() && (g_PlayerConfigsArray[g_Vars.currentplayerstats->mpindex].gunfuncs[(g_Vars.currentplayer->gunctrl.weaponnum - 1) >> 3] & (1 << ((g_Vars.currentplayer->gunctrl.weaponnum - 1) & 7)))) #define SETFUNCPRI() g_PlayerConfigsArray[g_Vars.currentplayerstats->mpindex].gunfuncs[(g_Vars.currentplayer->gunctrl.weaponnum - 1) >> 3] &= ~(1 << ((g_Vars.currentplayer->gunctrl.weaponnum - 1) & 7)) #define SETFUNCSEC() g_PlayerConfigsArray[g_Vars.currentplayerstats->mpindex].gunfuncs[(g_Vars.currentplayer->gunctrl.weaponnum - 1) >> 3] |= 1 << ((g_Vars.currentplayer->gunctrl.weaponnum - 1) & 7) @@ -13303,7 +13295,7 @@ s32 bgunConsiderToggleGunFunction(s32 usedowntime, bool trigpressed, bool fromac // These weapons disallow B+Z if (!trigpressed) { if (VALIDWEAPON()) { - if (1 - GETFUNC()) { + if (1 - FUNCISSEC()) { SETFUNCSEC(); } else { SETFUNCPRI(); @@ -13319,7 +13311,7 @@ s32 bgunConsiderToggleGunFunction(s32 usedowntime, bool trigpressed, bool fromac g_Vars.currentplayer->gunctrl.invertgunfunc = true; } else { if (VALIDWEAPON()) { - if (!GETFUNC()) { + if (!FUNCISSEC()) { SETFUNCSEC(); } else { SETFUNCPRI(); diff --git a/src/game/bondmove.c b/src/game/bondmove.c index f253f3e57..3a7442567 100644 --- a/src/game/bondmove.c +++ b/src/game/bondmove.c @@ -1,11 +1,13 @@ #include #include "constants.h" +#include "game/activemenu.h" #include "game/bondbike.h" #include "game/bondgrab.h" #include "game/bondmove.h" #include "game/bondwalk.h" #include "game/cheats.h" #include "game/chraction.h" +#include "game/footstep.h" #include "game/game_006900.h" #include "game/chr.h" #include "game/prop.h" @@ -26,6 +28,7 @@ #include "game/options.h" #include "game/propobj.h" #include "bss.h" +#include "lib/lib_17ce0.h" #include "lib/vi.h" #include "lib/collision.h" #include "lib/joy.h" diff --git a/src/game/bondview.c b/src/game/bondview.c index 5120e92d9..9790c68c3 100644 --- a/src/game/bondview.c +++ b/src/game/bondview.c @@ -15,6 +15,7 @@ #include "lib/joy.h" #include "lib/main.h" #include "lib/rng.h" +#include "lib/str.h" #include "lib/mtx.h" #include "data.h" #include "types.h" @@ -193,7 +194,7 @@ Gfx *bviewPrepareStaticRgba16(Gfx *gdl, u32 colour, u32 alpha) G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD); gDPSetTileSize(gdl++, G_TX_RENDERTILE, 0, 0, 0x0800, 0x0020); gDPSetTextureFilter(gdl++, G_TF_POINT); - gDPSetColor(gdl++, G_SETENVCOLOR, colour & 0xffffff00 | alpha & 0xff); + gDPSetColor(gdl++, G_SETENVCOLOR, (colour & 0xffffff00) | (alpha & 0xff)); gDPSetCombineLERP(gdl++, TEXEL0, 0, ENVIRONMENT, 0, 0, 0, 0, ENVIRONMENT, TEXEL0, 0, ENVIRONMENT, 0, 0, 0, 0, ENVIRONMENT); @@ -227,7 +228,7 @@ Gfx *bviewPrepareStaticI8(Gfx *gdl, u32 colour, u32 alpha) G_TX_NOMIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOLOD); gDPSetTileSize(gdl++, G_TX_RENDERTILE, 0, 0, 0x0800, 0x0020); gDPSetTextureFilter(gdl++, G_TF_POINT); - gDPSetColor(gdl++, G_SETENVCOLOR, colour & 0xffffff00 | alpha & 0xff); + gDPSetColor(gdl++, G_SETENVCOLOR, (colour & 0xffffff00) | (alpha & 0xff)); gDPSetCombineLERP(gdl++, TEXEL0, 0, ENVIRONMENT, 0, 0, 0, 0, ENVIRONMENT, TEXEL0, 0, ENVIRONMENT, 0, 0, 0, 0, ENVIRONMENT); @@ -298,7 +299,7 @@ Gfx *bviewDrawStatic(Gfx *gdl, u32 arg1, s32 arg2) s32 viewheight = viGetViewHeight(); s32 viewwidth = viGetViewWidth(); s32 viewleft = viGetViewLeft(); - u16 *fb2 = (u16 *) (random() & 0xfff00 | 0x80000000); + u16 *fb2 = (u16 *) PHYS_TO_K0(random() & 0xfff00); s32 y; gDPPipeSync(gdl++); diff --git a/src/game/bondwalk.c b/src/game/bondwalk.c index e9af49ab0..ab1f1550d 100644 --- a/src/game/bondwalk.c +++ b/src/game/bondwalk.c @@ -5,6 +5,7 @@ #include "game/cheats.h" #include "game/chraction.h" #include "game/debug.h" +#include "game/footstep.h" #include "game/game_006900.h" #include "game/chr.h" #include "game/prop.h" @@ -17,6 +18,7 @@ #include "game/playermgr.h" #include "game/propobj.h" #include "bss.h" +#include "lib/model.h" #include "lib/snd.h" #include "lib/rng.h" #include "lib/mtx.h" diff --git a/src/game/bot.c b/src/game/bot.c index f9e71a795..2f5915ff6 100644 --- a/src/game/bot.c +++ b/src/game/bot.c @@ -26,6 +26,7 @@ #include "game/propobj.h" #include "game/splat.h" #include "bss.h" +#include "lib/collision.h" #include "lib/model.h" #include "lib/rng.h" #include "lib/mtx.h" diff --git a/src/game/botcmd.c b/src/game/botcmd.c index f2fbd6de4..7949a32f3 100644 --- a/src/game/botcmd.c +++ b/src/game/botcmd.c @@ -1,5 +1,6 @@ #include #include "constants.h" +#include "game/activemenu.h" #include "game/chraction.h" #include "game/debug.h" #include "game/chr.h" @@ -10,6 +11,7 @@ #include "game/bot.h" #include "game/botcmd.h" #include "game/botact.h" +#include "game/botinv.h" #include "game/mplayer/mplayer.h" #include "game/propobj.h" #include "bss.h" diff --git a/src/game/botmgr.c b/src/game/botmgr.c index 503165a19..e14d0347c 100644 --- a/src/game/botmgr.c +++ b/src/game/botmgr.c @@ -5,6 +5,7 @@ #include "game/body.h" #include "game/prop.h" #include "game/botcmd.h" +#include "game/botinvinit.h" #include "game/mplayer/mplayer.h" #include "bss.h" #include "lib/memp.h" diff --git a/src/game/camdraw.c b/src/game/camdraw.c index ed3aff987..0fba471be 100644 --- a/src/game/camdraw.c +++ b/src/game/camdraw.c @@ -19,6 +19,7 @@ #include "lib/libc/ll.h" #include "data.h" #include "types.h" +#include "string.h" struct camerafile { u8 unk00[128]; @@ -3014,7 +3015,7 @@ void func0f14f700(struct var8007f8e0 *arg0, u32 arg1, u32 arg2) { u32 bit; - for (bit = 1 << (arg2 + 31); bit != 0; bit >>= 1) { + for (bit = 1 << (arg2 - 1); bit != 0; bit >>= 1) { if (bit & arg1) { s32 remainder = arg0->unk02c % 8; s32 index = arg0->unk02c / 8; @@ -3032,7 +3033,7 @@ u32 func0f14f76c(struct var8007f8e0 *arg0, u32 arg1) u32 bit; u32 bits; - for (bit = 1 << (arg1 + 31), bits = 0; bit != 0; bit >>= 1) { + for (bit = 1 << (arg1 - 1), bits = 0; bit != 0; bit >>= 1) { u32 remainder = arg0->unk02c % 8; u32 index = arg0->unk02c / 8; u8 mask = 1 << (7 - remainder); @@ -3072,7 +3073,7 @@ s32 phead0f14f7d4(struct var8007f8e0 *arg0) v0 = func0f14f76c(arg0, sp24); - if ((1 << (sp24 + 31)) & v0) { + if ((1 << (sp24 - 1)) & v0) { return v0; } diff --git a/src/game/cheats.c b/src/game/cheats.c index d38f4b913..613173646 100644 --- a/src/game/cheats.c +++ b/src/game/cheats.c @@ -1,6 +1,7 @@ #include #include "constants.h" #include "lib/sched.h" +#include "lib/str.h" #include "game/camdraw.h" #include "game/cheats.h" #include "game/inv.h" @@ -251,16 +252,16 @@ void cheatsReset(void) (1 << CHEAT_LAPTOPGUN) ); g_CheatsActiveBank1 &= ~( - (1 << CHEAT_PHOENIX - 32) | - (1 << CHEAT_PSYCHOSISGUN - 32) | - (1 << CHEAT_PP9I - 32) | - (1 << CHEAT_CC13 - 32) | - (1 << CHEAT_KL01313 - 32) | - (1 << CHEAT_KF7SPECIAL - 32) | - (1 << CHEAT_ZZT - 32) | - (1 << CHEAT_DMC - 32) | - (1 << CHEAT_AR53 - 32) | - (1 << CHEAT_RCP45 - 32) + (1 << (CHEAT_PHOENIX - 32)) | + (1 << (CHEAT_PSYCHOSISGUN - 32)) | + (1 << (CHEAT_PP9I - 32)) | + (1 << (CHEAT_CC13 - 32)) | + (1 << (CHEAT_KL01313 - 32)) | + (1 << (CHEAT_KF7SPECIAL - 32)) | + (1 << (CHEAT_ZZT - 32)) | + (1 << (CHEAT_DMC - 32)) | + (1 << (CHEAT_AR53 - 32)) | + (1 << (CHEAT_RCP45 - 32)) ); } } else { diff --git a/src/game/chr.c b/src/game/chr.c index 49b2ebd81..a40974330 100644 --- a/src/game/chr.c +++ b/src/game/chr.c @@ -6,6 +6,7 @@ #include "game/chraction.h" #include "game/debug.h" #include "game/chr.h" +#include "game/env.h" #include "game/prop.h" #include "game/propsnd.h" #include "game/objectives.h" @@ -44,6 +45,7 @@ #include "lib/anim.h" #include "lib/collision.h" #include "data.h" +#include "gbiex.h" #include "types.h" void *var8009ccc0[20]; @@ -4237,8 +4239,7 @@ glabel chr0f0260c4 #else // Mismatch: The bottom two tmp calculations should multiply by s32 0xc using // shift operations, however doing this causes it to boot gdlptr out of s8 and -// use s8 for s32 0xc. The below multiplies by 6 which is incorrect, but creates -// a diff of only one instruction to show that this is the only issue. +// use s8 for s32 0xc. void chr0f0260c4(struct model *model, s32 hitpart, struct modelnode *node, struct coord *arg3) { struct modelnode *bestnode = NULL; @@ -4460,7 +4461,7 @@ void chr0f0260c4(struct model *model, s32 hitpart, struct modelnode *node, struc tmp = ALIGN8((s32)&rodata->vertices[rodata->numvertices]); // s32 0xc } else { - tmp = ALIGN8((s32)rodata->vertices + rodata->numvertices * 6); // s32 0xc + tmp = ALIGN8((s32)&rodata->vertices[rodata->numvertices]); // s32 0xc } } diff --git a/src/game/chraction.c b/src/game/chraction.c index cc014b878..8ab121c56 100644 --- a/src/game/chraction.c +++ b/src/game/chraction.c @@ -43,6 +43,7 @@ #include "game/mpstats.h" #include "bss.h" #include "lib/joy.h" +#include "lib/lib_17ce0.h" #include "lib/main.h" #include "lib/model.h" #include "lib/snd.h" @@ -5113,16 +5114,14 @@ bool func0f03645c(struct chrdata *chr, struct coord *arg1, s16 *arg2, struct coo f32 ymax; f32 ymin; f32 radius; - u32 stack[3]; - s16 sp32; - s16 sp30; + s16 rooms[8]; struct prop *prop = chr->prop; chrGetBbox(prop, &radius, &ymax, &ymin); chrSetPerimEnabled(chr, false); - if (cdTestCylMove04(arg1, arg2, arg3, &sp30, arg5, 1, ymax - prop->pos.y, ymin - prop->pos.y) != CDRESULT_COLLISION) { - if (cdTestCylMove01(arg3, &sp30, arg4, arg5, 1, ymax - prop->pos.y, ymin - prop->pos.y) != CDRESULT_COLLISION) { + if (cdTestCylMove04(arg1, arg2, arg3, rooms, arg5, 1, ymax - prop->pos.y, ymin - prop->pos.y) != CDRESULT_COLLISION) { + if (cdTestCylMove01(arg3, rooms, arg4, arg5, 1, ymax - prop->pos.y, ymin - prop->pos.y) != CDRESULT_COLLISION) { result = true; } } diff --git a/src/game/chrai.c b/src/game/chrai.c index 0828d1ecf..43ad43095 100644 --- a/src/game/chrai.c +++ b/src/game/chrai.c @@ -6,6 +6,7 @@ #include "bss.h" #include "lib/rng.h" #include "lib/ailist.h" +#include "lib/model.h" #include "data.h" #include "types.h" diff --git a/src/game/chraicommands.c b/src/game/chraicommands.c index 2b39fd0fe..787027b44 100644 --- a/src/game/chraicommands.c +++ b/src/game/chraicommands.c @@ -9511,7 +9511,7 @@ bool aiSayQuip(void) s32 distance; // 116 - not referenced s32 row = cmd[3]; // 112 u32 playernum; // 108 - not referenced - u8 headshotted = g_Vars.chrdata->hidden2 & CHRH2FLAG_HEADSHOTTED; // 107 + u8 headshotted = (g_Vars.chrdata->hidden2 & CHRH2FLAG_HEADSHOTTED) & 0xff; // 107 struct chrdata *loopchr; // 100 // Choose bank diff --git a/src/game/credits.c b/src/game/credits.c index 1270ca421..4acfbc1fd 100644 --- a/src/game/credits.c +++ b/src/game/credits.c @@ -1,5 +1,6 @@ #include #include "constants.h" +#include "game/camera.h" #include "game/game_006900.h" #include "game/title.h" #include "game/tex.h" @@ -972,7 +973,7 @@ Gfx *creditsDrawParticles(Gfx *gdl) gDPSetVerticeArray(gdl++, osVirtualToPhysical(vertices), 4); - gDPTri2(gdl++, 0, 1, 2, 2, 3, 0) + gDPTri2(gdl++, 0, 1, 2, 2, 3, 0); } } } diff --git a/src/game/debug2.c b/src/game/debug2.c index 81f50da08..84f237739 100644 --- a/src/game/debug2.c +++ b/src/game/debug2.c @@ -1,8 +1,13 @@ #include #include "constants.h" +#include "game/challenge.h" #include "game/chraction.h" #include "game/debug.h" +#include "game/gamefile.h" +#include "lib/ailist.h" +#include "lib/debughud.h" #include "lib/rmon.h" +#include "lib/str.h" #include "lib/vi.h" #include "lib/vm.h" #include "bss.h" diff --git a/src/game/endscreen.c b/src/game/endscreen.c index 193644e73..b6e27672f 100644 --- a/src/game/endscreen.c +++ b/src/game/endscreen.c @@ -1,5 +1,6 @@ #include #include "constants.h" +#include "game/bossfile.h" #include "game/cheats.h" #include "game/game_006900.h" #include "game/title.h" @@ -25,6 +26,7 @@ #include "bss.h" #include "lib/vi.h" #include "lib/main.h" +#include "lib/str.h" #include "data.h" #include "types.h" @@ -89,7 +91,7 @@ s32 endscreenHandleRetryMission(s32 operation, struct menudialogdef *dialogdef, } } - menudialog00103608(operation, dialogdef, data); + return menudialog00103608(operation, dialogdef, data); } char *endscreenMenuTitleRetryMission(struct menudialogdef *dialogdef) diff --git a/src/game/env.c b/src/game/env.c index ddb6c941d..59513f1a5 100644 --- a/src/game/env.c +++ b/src/game/env.c @@ -25,22 +25,26 @@ u32 var800810a8 = 0; u32 var800810ac = 0; // lensflare, r, g, b, x, y, z, texture size, orb size -struct sun sun_00 = { 1, 0xff, 0xff, 0xff, -1000000, 200000, 50000, 20, 48 }; -struct sun sun_area51 = { 0, 0xff, 0xe0, 0x80, -200000, 310000, 1000000, 20, 48 }; -struct sun sun_villa = { 1, 0xff, 0xff, 0xff, -1000000, 200000, 50000, 20, 48 }; -struct sun sun_ci = { 1, 0xff, 0xff, 0xff, 400000, 600000, -1000000, 20, 48 }; -struct sun sun_skedar = { 1, 0xff, 0xff, 0xff, -400000, 600000, 1000000, 20, 48 }; -struct sun sun_05 = { 1, 0xff, 0xff, 0xff, 0, 1000000, 1000000, 25, 60 }; -struct sun sun_06 = { 1, 0xff, 0xff, 0xff, 400000, 600000, 1000000, 15, 36 }; -struct sun sun_crashsite = { 1, 0xff, 0xd7, 0xf2, 1900000, 300000, -1400000, 22, 48 }; -struct sun sun_airbase = { 1, 0xff, 0xd7, 0xf2, -1200000, 200000, 150000, 30, 60 }; +struct sun suns_00[] = { 1, 0xff, 0xff, 0xff, -1000000, 200000, 50000, 20, 48 }; +struct sun suns_area51[] = { 0, 0xff, 0xe0, 0x80, -200000, 310000, 1000000, 20, 48 }; +struct sun suns_villa[] = { 1, 0xff, 0xff, 0xff, -1000000, 200000, 50000, 20, 48 }; +struct sun suns_ci[] = { 1, 0xff, 0xff, 0xff, 400000, 600000, -1000000, 20, 48 }; + +struct sun suns_skedar[] = { + { 1, 0xff, 0xff, 0xff, -400000, 600000, 1000000, 20, 48 }, + { 1, 0xff, 0xff, 0xff, 0, 1000000, 1000000, 25, 60 }, + { 1, 0xff, 0xff, 0xff, 400000, 600000, 1000000, 15, 36 }, +}; + +struct sun suns_crashsite[] = { 1, 0xff, 0xd7, 0xf2, 1900000, 300000, -1400000, 22, 48 }; +struct sun suns_airbase[] = { 1, 0xff, 0xd7, 0xf2, -1200000, 200000, 150000, 30, 60 }; struct envtype1 g_EnvironmentsType1[] = { // |--- fog ----| |---- sky -----| |----------- clouds -----------| |--------------- water ---------------| // stage near far 06 08 0a min max r g b sun e scale 1c r g b 20 21 scale type r g b 28 - { STAGE_CRASHSITE, 15, 10000, 0, 0, 0, 0x03e2, 0x03e8, 0x9b, 0x2d, 0x1e, 1, &sun_crashsite, 1, 1500, 0x00, 0xfa, 0xfa, 0x00, 0, 0, -5000, 0, 0x00, 0x00, 0x00, 0x00 }, + { STAGE_CRASHSITE, 15, 10000, 0, 0, 0, 0x03e2, 0x03e8, 0x9b, 0x2d, 0x1e, 1, suns_crashsite, 1, 1500, 0x00, 0xfa, 0xfa, 0x00, 0, 0, -5000, 0, 0x00, 0x00, 0x00, 0x00 }, { STAGE_PELAGIC, 15, 15000, 3333, 4444, 600, 0x03e3, 0x03e8, 0x2d, 0x3e, 0x60, 0, NULL, 1, 5000, 0x00, 0xf0, 0xf0, 0xf0, 0, 0, -2000, 0, 0x14, 0x21, 0x2b, 0x00 }, - { STAGE_VILLA, 15, 20000, 0, 0, 0, 0x03d5, 0x0417, 0x46, 0xa0, 0xff, 1, &sun_villa, 1, 5000, 0x00, 0xff, 0xff, 0xff, 0, 0, -1850, 1, 0x00, 0xff, 0xff, 0x00 }, + { STAGE_VILLA, 15, 20000, 0, 0, 0, 0x03d5, 0x0417, 0x46, 0xa0, 0xff, 1, suns_villa, 1, 5000, 0x00, 0xff, 0xff, 0xff, 0, 0, -1850, 1, 0x00, 0xff, 0xff, 0x00 }, { STAGE_PELAGIC + 900, 30, 15000, 3333, 4444, 600, 0x03e3, 0x03e8, 0x10, 0x30, 0x60, 0, NULL, 1, 5000, 0x00, 0xff, 0xff, 0xff, 0, 0, -1000, 0, 0x00, 0x00, 0x00, 0x00 }, { STAGE_24, 2, 25000, 0, 0, 0, 0x03e4, 0x03e8, 0x00, 0x00, 0x00, 0, NULL, 1, 10000, 0x00, 0xff, 0xff, 0xff, 0, 0, 0, 1, 0x00, 0xff, 0xff, 0x07 }, { STAGE_2B, 2, 2000, 2500, 3055, 750, 0x03bd, 0x03e8, 0x20, 0x10, 0x10, 0, NULL, 1, 5000, 0x00, 0x3a, 0x11, 0x00, 0, 0, -1000, 1, 0x00, 0xff, 0xff, 0x14 }, @@ -61,22 +65,22 @@ struct envtype2 g_EnvironmentsType2[] = { { STAGE_RESCUE, 15, 10000, 0, 0, 0, 0x00, 0x00, 0x00, 0, NULL, 0, 0xff, 0xff, 0xff, 5000, 0, 0, 0x00, 0x00, 0x00, 0, 0, 0, 1 }, { STAGE_MAIANSOS, 15, 10000, 0, 0, 0, 0x00, 0x00, 0x00, 0, NULL, 0, 0xff, 0xff, 0xff, 5000, 0, 0, 0x00, 0x00, 0x00, 0, 0, 0, 1 }, { STAGE_ATTACKSHIP, 15, 10000, 0, 0, 0, 0x00, 0x00, 0x00, 0, NULL, 0, 0xff, 0xff, 0xff, 5000, 0, 0, 0x00, 0x00, 0x00, 0, 0, 0, 0 }, - { STAGE_INFILTRATION, 15, 12000, 0, 0, 0, 0x00, 0x00, 0x00, 1, &sun_area51, 0, 0xff, 0xff, 0xff, 5000, 0, 0, 0x00, 0x00, 0x00, 0, 0, 0, 1 }, - { STAGE_ESCAPE, 15, 10000, 0, 0, 0, 0x00, 0x00, 0x00, 1, &sun_area51, 0, 0xff, 0xff, 0xff, 5000, 0, 0, 0x00, 0x00, 0x00, 0, 0, 0, 1 }, + { STAGE_INFILTRATION, 15, 12000, 0, 0, 0, 0x00, 0x00, 0x00, 1, suns_area51, 0, 0xff, 0xff, 0xff, 5000, 0, 0, 0x00, 0x00, 0x00, 0, 0, 0, 1 }, + { STAGE_ESCAPE, 15, 10000, 0, 0, 0, 0x00, 0x00, 0x00, 1, suns_area51, 0, 0xff, 0xff, 0xff, 5000, 0, 0, 0x00, 0x00, 0x00, 0, 0, 0, 1 }, { STAGE_TEST_ARCH, 15, 10000, 0, 0, 0, 0x00, 0x00, 0x00, 0, NULL, 0, 0xff, 0xff, 0xff, 5000, 0, 0, 0x00, 0x00, 0x00, 0, 0, 0, 0 }, { STAGE_DEEPSEA, 15, 10000, 0, 0, 0, 0x05, 0x00, 0x00, 0, NULL, 0, 0x9b, 0x9b, 0x9b, 5000, 0, 0, 0x00, 0x00, 0x00, 0, 0, 0, 0 }, { STAGE_TEST_DEST, 15, 10000, 0, 0, 0, 0x10, 0x30, 0x60, 0, NULL, 1, 0xe6, 0xe6, 0xe6, 3000, 0, 1, 0xff, 0xff, 0x96, -150, 2, 0, 0 }, { STAGE_TEST_LEN, 15, 10000, 0, 0, 0, 0x30, 0x40, 0x10, 0, NULL, 0, 0xff, 0xff, 0xff, 5000, 0, 0, 0x00, 0x00, 0x00, 0, 0, 0, 0 }, { STAGE_TEST_ASH, 15, 25000, 0, 0, 0, 0x00, 0x00, 0x00, 0, NULL, 0, 0xff, 0xff, 0xff, 5000, 0, 0, 0x00, 0x00, 0x00, 0, 0, 0, 1 }, - { STAGE_DEFENSE, 15, 10000, 0, 0, 0, 0x65, 0xb2, 0xff, 1, &sun_ci, 0, 0xff, 0xff, 0xff, 5000, 0, 0, 0x00, 0x00, 0x00, 0, 0, 0, 1 }, - { STAGE_CITRAINING, 15, 10000, 0, 0, 0, 0x65, 0xb2, 0xff, 1, &sun_ci, 0, 0xff, 0xff, 0xff, 5000, 0, 0, 0x00, 0x00, 0x00, 0, 0, 0, 1 }, - { STAGE_DUEL, 10, 10000, 0, 0, 0, 0x65, 0xb2, 0xff, 1, &sun_ci, 0, 0xff, 0xff, 0xff, 5000, 0, 0, 0x00, 0x00, 0x00, 0, 0, 0, 1 }, - { STAGE_RETAKING, 15, 10000, 0, 0, 0, 0x65, 0xb2, 0xff, 1, &sun_ci, 0, 0xff, 0xff, 0xff, 5000, 0, 0, 0x00, 0x00, 0x00, 0, 0, 0, 1 }, + { STAGE_DEFENSE, 15, 10000, 0, 0, 0, 0x65, 0xb2, 0xff, 1, suns_ci, 0, 0xff, 0xff, 0xff, 5000, 0, 0, 0x00, 0x00, 0x00, 0, 0, 0, 1 }, + { STAGE_CITRAINING, 15, 10000, 0, 0, 0, 0x65, 0xb2, 0xff, 1, suns_ci, 0, 0xff, 0xff, 0xff, 5000, 0, 0, 0x00, 0x00, 0x00, 0, 0, 0, 1 }, + { STAGE_DUEL, 10, 10000, 0, 0, 0, 0x65, 0xb2, 0xff, 1, suns_ci, 0, 0xff, 0xff, 0xff, 5000, 0, 0, 0x00, 0x00, 0x00, 0, 0, 0, 1 }, + { STAGE_RETAKING, 15, 10000, 0, 0, 0, 0x65, 0xb2, 0xff, 1, suns_ci, 0, 0xff, 0xff, 0xff, 5000, 0, 0, 0x00, 0x00, 0x00, 0, 0, 0, 1 }, { STAGE_DEFECTION, 10, 10000, 0, 0, 0, 0x00, 0x00, 0x00, 0, NULL, 0, 0x3a, 0x11, 0x00, 5000, 0, 0, 0x00, 0x00, 0x00, 0, 0, 0, 1 }, { STAGE_MBR, 10, 10000, 0, 0, 0, 0x00, 0x00, 0x00, 0, NULL, 0, 0x3a, 0x11, 0x00, 5000, 0, 0, 0x00, 0x00, 0x00, 0, 0, 0, 1 }, { STAGE_EXTRACTION, 10, 10000, 0, 0, 0, 0x00, 0x00, 0x00, 0, NULL, 0, 0x3a, 0x11, 0x00, 5000, 0, 0, 0x00, 0x00, 0x00, 0, 0, 0, 1 }, - { STAGE_SKEDARRUINS, 15, 10000, 0, 0, 0, 0x65, 0x65, 0xff, 3, &sun_skedar, 0, 0xff, 0xff, 0xff, 5000, 0, 0, 0x00, 0x00, 0x00, 0, 0, 0, 1 }, - { STAGE_WAR, 15, 10000, 0, 0, 0, 0x65, 0x65, 0xff, 3, &sun_skedar, 0, 0xff, 0xff, 0xff, 5000, 0, 0, 0x00, 0x00, 0x00, 0, 0, 0, 1 }, + { STAGE_SKEDARRUINS, 15, 10000, 0, 0, 0, 0x65, 0x65, 0xff, 3, suns_skedar, 0, 0xff, 0xff, 0xff, 5000, 0, 0, 0x00, 0x00, 0x00, 0, 0, 0, 1 }, + { STAGE_WAR, 15, 10000, 0, 0, 0, 0x65, 0x65, 0xff, 3, suns_skedar, 0, 0xff, 0xff, 0xff, 5000, 0, 0, 0x00, 0x00, 0x00, 0, 0, 0, 1 }, { STAGE_TEST_RUN, 15, 10000, 0, 0, 0, 0x00, 0x00, 0x00, 0, NULL, 0, 0x3a, 0x11, 0x00, 5000, 0, 0, 0x00, 0x00, 0x00, 0, 0, 0, 1 }, { STAGE_MP_SKEDAR, 15, 10000, 0, 0, 0, 0x00, 0x00, 0x00, 0, NULL, 1, 0x3a, 0x11, 0x00, 5000, 0, 0, 0x00, 0x00, 0x00, -5000, 0, 0, 1 }, { STAGE_TEST_SILO, 15, 10000, 0, 0, 0, 0x00, 0x00, 0x00, 0, NULL, 1, 0x3a, 0x11, 0x00, 5000, 0, 0, 0x00, 0x00, 0x00, -5000, 0, 0, 1 }, @@ -84,7 +88,7 @@ struct envtype2 g_EnvironmentsType2[] = { { STAGE_G5BUILDING, 15, 10000, 0, 0, 0, 0x00, 0x00, 0x00, 0, NULL, 0, 0x50, 0x28, 0x0a, 5000, 0, 0, 0x00, 0x00, 0x00, -5000, 0, 0, 1 }, { STAGE_AIRFORCEONE, 15, 20000, 0, 0, 0, 0x00, 0x10, 0x40, 0, NULL, 1, 0xff, 0xff, 0xff, 5000, 0, 1, 0xff, 0xff, 0xff, -5000, 2, 0, 1 }, { STAGE_MP_RAVINE, 15, 10000, 0, 0, 0, 0x00, 0x00, 0x00, 0, NULL, 1, 0x50, 0x28, 0x0a, 5000, 0, 0, 0x00, 0x00, 0x00, -31000, 0, 0, 1 }, - { STAGE_AIRBASE, 15, 20000, 0, 0, 0, 0x00, 0x10, 0x40, 1, &sun_airbase, 1, 0xff, 0xff, 0xff, 5000, 0, 0, 0x00, 0x00, 0x00, -5000, 0, 0, 1 }, + { STAGE_AIRBASE, 15, 20000, 0, 0, 0, 0x00, 0x10, 0x40, 1, suns_airbase, 1, 0xff, 0xff, 0xff, 5000, 0, 0, 0x00, 0x00, 0x00, -5000, 0, 0, 1 }, { STAGE_INVESTIGATION, 15, 10000, 0, 0, 0, 0x00, 0x00, 0x00, 0, NULL, 0, 0x1e, 0x1e, 0x1e, 5000, 0, 0, 0x00, 0x00, 0x00, -5000, 0, 0, 1 }, { STAGE_MP_PIPES, 15, 10000, 0, 0, 0, 0x00, 0x00, 0x08, 0, NULL, 1, 0x46, 0xc7, 0xba, 4500, 0, 0, 0x00, 0x00, 0x00, -5000, 0, 0, 0 }, { STAGE_MP_G5BUILDING, 15, 10000, 0, 0, 0, 0x00, 0x00, 0x08, 0, NULL, 1, 0x5a, 0x90, 0xa5, 4500, 0, 0, 0x00, 0x00, 0x00, -20000, 0, 0, 0 }, @@ -424,7 +428,7 @@ struct coord *env0f1667e8(void) return var800a65e8; } -s32 env0f1667f4(struct prop *prop, f32 *arg1) +s32 env0f1667f4(struct prop *prop, f32 arg1[4]) { if (!g_FogEnabled) { return 2; diff --git a/src/game/explosions.c b/src/game/explosions.c index beac97e50..2eadeb0c0 100644 --- a/src/game/explosions.c +++ b/src/game/explosions.c @@ -19,6 +19,7 @@ #include "game/utils.h" #include "game/wallhit.h" #include "bss.h" +#include "lib/collision.h" #include "lib/vi.h" #include "lib/main.h" #include "lib/rng.h" @@ -93,19 +94,19 @@ bool explosionCreateComplex(struct prop *prop, struct coord *pos, s16 *rooms, s1 bool makescorch = true; s16 room; f32 y; - bool sp68; + struct prop *collisionprop; if (type == EXPLOSIONTYPE_NONE) { return false; } if (prop) { - room = cdFindFloorRoomYColourNormalPropAtPos(&prop->pos, prop->rooms, &y, 0, &sp88, &sp68); + room = cdFindFloorRoomYColourNormalPropAtPos(&prop->pos, prop->rooms, &y, NULL, &sp88, &collisionprop); sp100.x = prop->pos.x; sp100.y = y; sp100.z = prop->pos.z; } else { - room = cdFindFloorRoomYColourNormalPropAtPos(pos, rooms, &y, 0, &sp88, &sp68); + room = cdFindFloorRoomYColourNormalPropAtPos(pos, rooms, &y, NULL, &sp88, &collisionprop); sp100.x = pos->x; sp100.y = y; sp100.z = pos->z; @@ -113,7 +114,7 @@ bool explosionCreateComplex(struct prop *prop, struct coord *pos, s16 *rooms, s1 etype = &g_ExplosionTypes[type]; - if (sp68 || room <= 0 + if (collisionprop || room <= 0 || !(pos->y - y <= (etype->rangev + etype->changeratev * etype->duration + etype->innersize) * 0.5f || pos->y - y <= 75)) { makescorch = false; } diff --git a/src/game/file.c b/src/game/file.c index 483154b78..7bed7c732 100644 --- a/src/game/file.c +++ b/src/game/file.c @@ -4137,7 +4137,7 @@ void fileLoad(u8 *dst, u32 allocationlen, u32 *romaddrptr, struct fileinfo *info dmaExec(dst, *romaddrptr, romsize); } else { // DMA the compressed data to scratch space then inflate - u8 *scratch = (dst + allocationlen) - (romsize + 7 & 0xfffffff8); + u8 *scratch = (dst + allocationlen) - ((romsize + 7) & 0xfffffff8); if ((u32)scratch - (u32)dst < 8) { info->loadedsize = 0; diff --git a/src/game/filelist.c b/src/game/filelist.c index 64f82a017..5bc559e55 100644 --- a/src/game/filelist.c +++ b/src/game/filelist.c @@ -16,6 +16,7 @@ #include "game/utils.h" #include "bss.h" #include "lib/fault.h" +#include "lib/joy.h" #include "lib/snd.h" #include "lib/mema.h" #include "data.h" diff --git a/src/game/filemgr.c b/src/game/filemgr.c index 6097317cb..4efc96ae3 100644 --- a/src/game/filemgr.c +++ b/src/game/filemgr.c @@ -14,6 +14,7 @@ #include "game/utils.h" #include "bss.h" #include "lib/vi.h" +#include "lib/joy.h" #include "lib/mema.h" #include "lib/str.h" #include "data.h" diff --git a/src/game/footstep.c b/src/game/footstep.c index e190fb01c..1c313bf68 100644 --- a/src/game/footstep.c +++ b/src/game/footstep.c @@ -5,6 +5,7 @@ #include "game/propsnd.h" #include "game/bg.h" #include "bss.h" +#include "lib/model.h" #include "lib/rng.h" #include "lib/mtx.h" #include "data.h" @@ -162,7 +163,6 @@ void footstepCheckDefault(struct chrdata *chr) s32 soundnum; f32 prevframe = chr->oldframe; f32 frame = chr->model->anim->frame; - f32 stack; s32 i; chr->oldframe = frame; diff --git a/src/game/game_1531a0.c b/src/game/game_1531a0.c index ebc76d2a6..fb7c3e89f 100644 --- a/src/game/game_1531a0.c +++ b/src/game/game_1531a0.c @@ -110,40 +110,40 @@ u32 var8007fb30 = 0x00000000; u32 var8007fb34 = 0x00000000; u32 var8007fb38 = 0x00000000; -u32 var8007fb3c = 0xff00ff00; -u32 var8007fb40 = 0xff00ff00; -u32 var8007fb44 = 0xff00ff00; -u32 var8007fb48 = 0xff00ff00; -u32 var8007fb4c = 0xff00ff24; -u32 var8007fb50 = 0xff48ff6c; -u32 var8007fb54 = 0xff90ffb4; -u32 var8007fb58 = 0xffd8ffff; -u32 var8007fb5c = 0xff00ff58; -u32 var8007fb60 = 0xff74ff90; -u32 var8007fb64 = 0xffacffc8; -u32 var8007fb68 = 0xffe4ffff; -u32 var8007fb6c = 0xffffffff; -u32 var8007fb70 = 0xffffffff; -u32 var8007fb74 = 0xffffffff; -u32 var8007fb78 = 0xffffffff; -u32 var8007fb7c = 0xff00ff00; -u32 var8007fb80 = 0xff00ff00; -u32 var8007fb84 = 0xff00ff00; -u32 var8007fb88 = 0xff00ff00; -u32 var8007fb8c = 0xff00ff18; -u32 var8007fb90 = 0xff30ff5c; -u32 var8007fb94 = 0xff88ffb4; -u32 var8007fb98 = 0xffd8ffff; +u16 var8007fb3c[] = { + 0xff00, 0xff00, 0xff00, 0xff00, 0xff00, 0xff00, 0xff00, 0xff00, + 0xff00, 0xff24, 0xff48, 0xff6c, 0xff90, 0xffb4, 0xffd8, 0xffff, +}; + +u16 var8007fb5c[] = { + 0xff00, 0xff58, 0xff74, 0xff90, 0xffac, 0xffc8, 0xffe4, 0xffff, + 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, +}; + +u16 var8007fb7c[] = { + 0xff00, 0xff00, 0xff00, 0xff00, 0xff00, 0xff00, 0xff00, 0xff00, + 0xff00, 0xff18, 0xff30, 0xff5c, 0xff88, 0xffb4, 0xffd8, 0xffff, +}; #if VERSION == VERSION_JPN_FINAL -u32 var800801d8jf = 0xff00ff11; -u32 var800801dcjf = 0xff22ff33; -u32 var800801e0jf = 0xff44ff55; -u32 var800801e4jf = 0xff66ff77; -u32 var800801e8jf = 0xff88ff99; -u32 var800801ecjf = 0xffaaffbb; -u32 var800801f0jf = 0xffccffdd; -u32 var800801f4jf = 0xffeeffff; +u16 var800801d8jf[] = { + 0xff00, + 0xff11, + 0xff22, + 0xff33, + 0xff44, + 0xff55, + 0xff66, + 0xff77, + 0xff88, + 0xff99, + 0xffaa, + 0xffbb, + 0xffcc, + 0xffdd, + 0xffee, + 0xffff, +}; #endif bool var8007fb9c = false; @@ -873,7 +873,7 @@ u32 textApplyProjectionColour(s32 x, s32 y, u32 colour) intensity = 255 - (u32) weightf; result = intensity << 8 | intensity | intensity << 16 | intensity << 24; } else if (g_Blend.diagtimer - (f14 + f16) < f12) { - result = ((colour & 0xff) + 0xff) >> 1 | colour & 0xffffff00; + result = (((colour & 0xff) + 0xff) >> 1) | (colour & 0xffffff00); } else if ((g_Blend.diagtimer - (f14 + f18 + f16)) < f12) { u32 colour2 = (((colour & 0xff) + 0xff) / 2) | (colour & 0xffffff00); weightf = (f12 - (g_Blend.diagtimer - (f14 + f18 + f16))) / f18 * 255.0f; @@ -1925,14 +1925,14 @@ Gfx *text0f154f38(Gfx *gdl, s32 *arg1, struct fontchar *curchar, struct fontchar if (curchar->index >= 0x80) { if (!var80080104jf) { - gDPSetTextureImage(gdl++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, osVirtualToPhysical(&var800801d8jf)); + gDPSetTextureImage(gdl++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, osVirtualToPhysical(var800801d8jf)); var80080104jf = 1; gDPLoadSync(gdl++); gDPLoadTLUTCmd(gdl++, 6, 15); } } else { if (var80080104jf) { - gDPSetTextureImage(gdl++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, osVirtualToPhysical(&var8007fb3c)); + gDPSetTextureImage(gdl++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, osVirtualToPhysical(var8007fb3c)); var80080104jf = 0; gDPLoadSync(gdl++); gDPLoadTLUTCmd(gdl++, 6, 15); @@ -2044,10 +2044,10 @@ Gfx *text0f1552d4(Gfx *gdl, f32 x, f32 y, f32 widthscale, f32 heightscale, gDPSetTextureLUT(gdl++, G_TT_IA16); #if VERSION >= VERSION_JPN_FINAL - gDPSetTextureImage(gdl++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, osVirtualToPhysical(&var800801d8jf)); + gDPSetTextureImage(gdl++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, osVirtualToPhysical(var800801d8jf)); var80080104jf = true; #else - gDPSetTextureImage(gdl++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, osVirtualToPhysical(&var8007fb3c)); + gDPSetTextureImage(gdl++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, osVirtualToPhysical(var8007fb3c)); #endif gDPLoadSync(gdl++); @@ -2170,7 +2170,7 @@ Gfx *text0f15568c(Gfx *gdl, s32 *x, s32 *y, struct fontchar *curchar, struct fon if (curchar->index >= 0x80) { if (!var80080104jf) { - gDPSetTextureImage(gdl++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, osVirtualToPhysical(&var800801d8jf)); + gDPSetTextureImage(gdl++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, osVirtualToPhysical(var800801d8jf)); var80080104jf = true; @@ -2179,7 +2179,7 @@ Gfx *text0f15568c(Gfx *gdl, s32 *x, s32 *y, struct fontchar *curchar, struct fon } } else { if (var80080104jf) { - gDPSetTextureImage(gdl++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, osVirtualToPhysical(&var8007fb3c)); + gDPSetTextureImage(gdl++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, osVirtualToPhysical(var8007fb3c)); var80080104jf = false; @@ -2546,10 +2546,10 @@ Gfx *textRenderProjected(Gfx *gdl, s32 *x, s32 *y, char *text, struct fontchar * gDPSetTextureLUT(gdl++, G_TT_IA16); #if VERSION >= VERSION_JPN_FINAL - gDPSetTextureImage(gdl++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, osVirtualToPhysical(&var800801d8jf)); + gDPSetTextureImage(gdl++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, osVirtualToPhysical(var800801d8jf)); var80080104jf = 1; #else - gDPSetTextureImage(gdl++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, osVirtualToPhysical(&var8007fb3c)); + gDPSetTextureImage(gdl++, G_IM_FMT_RGBA, G_IM_SIZ_16b, 1, osVirtualToPhysical(var8007fb3c)); #endif gDPLoadSync(gdl++); diff --git a/src/game/game_176080.c b/src/game/game_176080.c index d62ef0e79..65fd99f9c 100644 --- a/src/game/game_176080.c +++ b/src/game/game_176080.c @@ -56,7 +56,7 @@ void mblurAllocate(void) } var800844f0 = mempAlloc(var800ab7c0 * var800ab7c4 * 2 + 0x40, MEMPOOL_STAGE); - var800844f0 = (void *)((u32)var800844f0 + 0x3f & ~0x3f); + var800844f0 = (void *)(((u32) var800844f0 + 0x3f) & ~0x3f); var800844f4 = var800844f0; } diff --git a/src/game/gamefile.c b/src/game/gamefile.c index 07fe54a2c..208d96c69 100644 --- a/src/game/gamefile.c +++ b/src/game/gamefile.c @@ -16,6 +16,7 @@ #include "bss.h" #include "lib/fault.h" #include "lib/snd.h" +#include "lib/str.h" #include "data.h" #include "types.h" diff --git a/src/game/gfxmemory.c b/src/game/gfxmemory.c index ce09d8082..301920841 100644 --- a/src/game/gfxmemory.c +++ b/src/game/gfxmemory.c @@ -3,10 +3,12 @@ #include "game/gfxmemory.h" #include "game/stubs/game_175f50.h" #include "bss.h" +#include "lib/args.h" #include "lib/rzip.h" #include "lib/dma.h" #include "lib/memp.h" #include "lib/rng.h" +#include "lib/str.h" #include "data.h" #include "types.h" diff --git a/src/game/gunfx.c b/src/game/gunfx.c index dfccda33a..332741ff2 100644 --- a/src/game/gunfx.c +++ b/src/game/gunfx.c @@ -11,6 +11,7 @@ #include "game/file.h" #include "bss.h" #include "lib/main.h" +#include "lib/model.h" #include "lib/rng.h" #include "lib/mtx.h" #include "data.h" diff --git a/src/game/hudmsg.c b/src/game/hudmsg.c index 4b09a0877..559a9c96e 100644 --- a/src/game/hudmsg.c +++ b/src/game/hudmsg.c @@ -16,10 +16,12 @@ #include "bss.h" #include "lib/vi.h" #include "lib/snd.h" +#include "lib/str.h" #include "lib/memp.h" #include "lib/mtx.h" #include "data.h" #include "types.h" +#include "string.h" u32 g_NextHudMessageId; diff --git a/src/game/lv.c b/src/game/lv.c index f87ff8f14..9835a5965 100644 --- a/src/game/lv.c +++ b/src/game/lv.c @@ -5,6 +5,7 @@ #include "game/activemenu.h" #include "game/atan2f.h" #include "game/bg.h" +#include "game/body.h" #include "game/bondgun.h" #include "game/bondhead.h" #include "game/bondmove.h" @@ -31,6 +32,8 @@ #include "game/game_1531a0.h" #include "game/game_176080.h" #include "game/challenge.h" +#include "game/chrmgr.h" +#include "game/env.h" #include "game/gfxmemory.h" #include "game/gunfx.h" #include "game/hudmsg.h" @@ -53,10 +56,12 @@ #include "game/propobj.h" #include "game/propobjstop.h" #include "game/propsnd.h" +#include "game/room.h" #include "game/savebuffer.h" #include "game/setup.h" #include "game/shards.h" #include "game/sky.h" +#include "game/smoke.h" #include "game/sparks.h" #include "game/splat.h" #include "game/stars.h" @@ -66,6 +71,7 @@ #include "game/stubs/game_0153f0.h" #include "game/stubs/game_015400.h" #include "game/stubs/game_015410.h" +#include "game/tex.h" #include "game/texdecompress.h" #include "game/tiles.h" #include "game/title.h" @@ -84,6 +90,7 @@ #include "lib/mtx.h" #include "lib/music.h" #include "lib/rng.h" +#include "lib/sched.h" #include "lib/snd.h" #include "lib/vars.h" #include "lib/vi.h" diff --git a/src/game/mainmenu.c b/src/game/mainmenu.c index a1d829c6c..01c1bd953 100644 --- a/src/game/mainmenu.c +++ b/src/game/mainmenu.c @@ -1,5 +1,6 @@ #include #include "constants.h" +#include "game/bossfile.h" #include "game/cheats.h" #include "game/setup.h" #include "game/title.h" @@ -24,8 +25,10 @@ #include "game/options.h" #include "bss.h" #include "lib/vi.h" +#include "lib/joy.h" #include "lib/main.h" #include "lib/snd.h" +#include "lib/str.h" #include "data.h" #include "types.h" diff --git a/src/game/menu.c b/src/game/menu.c index 2e7edb71d..32d1239f4 100644 --- a/src/game/menu.c +++ b/src/game/menu.c @@ -14,6 +14,7 @@ #include "game/menugfx.h" #include "game/menuitem.h" #include "game/menu.h" +#include "game/filelist.h" #include "game/filemgr.h" #include "game/credits.h" #include "game/game_1531a0.h" @@ -41,6 +42,7 @@ #include "lib/snd.h" #include "lib/memp.h" #include "lib/rng.h" +#include "lib/str.h" #include "lib/mtx.h" #include "lib/lib_317f0.h" #include "data.h" @@ -1713,13 +1715,7 @@ void func0f0f37a4(struct menu840 *arg0) arg0->unk554 = -1.0f; } -u32 var80071468 = 0x96969600; -u32 var8007146c = 0x96969600; - -u32 var80071470 = 0xffffff00; -u32 var80071474 = 0xffffff00; -u32 var80071478 = 0xb24d2e00; -u32 var8007147c = 0x00000000; +Lights1 var80071468 = gdSPDefLights1(0x96, 0x96, 0x96, 0xff, 0xff, 0xff, 0xb2, 0x4d, 0x2e); #if VERSION >= VERSION_NTSC_1_0 /** @@ -2310,9 +2306,7 @@ Gfx *menuRenderModels(Gfx *gdl, struct menu840 *thing, s32 arg2) } } - gSPNumLights(gdl++, 1); - gSPLight(gdl++, &var80071470, 1); - gSPLight(gdl++, &var80071468, 2); + gSPSetLights1(gdl++, var80071468); gSPLookAtX(gdl++, &camGetLookAt()->l[0]); gSPLookAtY(gdl++, &camGetLookAt()->l[1]); @@ -5635,7 +5629,7 @@ void func0f0f820c(struct menudialogdef *dialogdef, s32 root) g_MenuData.unk00c = dialogdef; } -bool menuSetBackground(s32 bg) +void menuSetBackground(s32 bg) { // Can only screenshot if there is no background already, // because we want a clean screenshot diff --git a/src/game/menugfx.c b/src/game/menugfx.c index 8b29cb5af..341cec11d 100644 --- a/src/game/menugfx.c +++ b/src/game/menugfx.c @@ -549,447 +549,447 @@ Gfx *menugfxDrawListGroupHeader(Gfx *gdl, s32 x1, s32 y1, s32 x2, s32 y2, s32 x3 } #else GLOBAL_ASM( - glabel menugfxDrawListGroupHeader - /* f0ded8c: 27bdff70 */ addiu $sp,$sp,-144 - /* f0ded90: afbf003c */ sw $ra,0x3c($sp) - /* f0ded94: afa40090 */ sw $a0,0x90($sp) - /* f0ded98: afb20038 */ sw $s2,0x38($sp) - /* f0ded9c: afb10034 */ sw $s1,0x34($sp) - /* f0deda0: afb00030 */ sw $s0,0x30($sp) - /* f0deda4: afa50094 */ sw $a1,0x94($sp) - /* f0deda8: afa60098 */ sw $a2,0x98($sp) - /* f0dedac: afa7009c */ sw $a3,0x9c($sp) - /* f0dedb0: 0fc588c3 */ jal gfxAllocateColours - /* f0dedb4: 24040007 */ addiu $a0,$zero,0x7 - /* f0dedb8: 00408825 */ or $s1,$v0,$zero - /* f0dedbc: 0fc588a9 */ jal gfxAllocateVertices - /* f0dedc0: 24040009 */ addiu $a0,$zero,0x9 - /* f0dedc4: 8fae0090 */ lw $t6,0x90($sp) - /* f0dedc8: 3c18e700 */ lui $t8,0xe700 - /* f0dedcc: 00408025 */ or $s0,$v0,$zero - /* f0dedd0: 25cf0008 */ addiu $t7,$t6,0x8 - /* f0dedd4: afaf0090 */ sw $t7,0x90($sp) - /* f0dedd8: adc00004 */ sw $zero,0x4($t6) - /* f0deddc: add80000 */ sw $t8,0x0($t6) +glabel menugfxDrawListGroupHeader +/* f0ded8c: 27bdff70 */ addiu $sp,$sp,-144 +/* f0ded90: afbf003c */ sw $ra,0x3c($sp) +/* f0ded94: afa40090 */ sw $a0,0x90($sp) +/* f0ded98: afb20038 */ sw $s2,0x38($sp) +/* f0ded9c: afb10034 */ sw $s1,0x34($sp) +/* f0deda0: afb00030 */ sw $s0,0x30($sp) +/* f0deda4: afa50094 */ sw $a1,0x94($sp) +/* f0deda8: afa60098 */ sw $a2,0x98($sp) +/* f0dedac: afa7009c */ sw $a3,0x9c($sp) +/* f0dedb0: 0fc588c3 */ jal gfxAllocateColours +/* f0dedb4: 24040007 */ addiu $a0,$zero,0x7 +/* f0dedb8: 00408825 */ or $s1,$v0,$zero +/* f0dedbc: 0fc588a9 */ jal gfxAllocateVertices +/* f0dedc0: 24040009 */ addiu $a0,$zero,0x9 +/* f0dedc4: 8fae0090 */ lw $t6,0x90($sp) +/* f0dedc8: 3c18e700 */ lui $t8,0xe700 +/* f0dedcc: 00408025 */ or $s0,$v0,$zero +/* f0dedd0: 25cf0008 */ addiu $t7,$t6,0x8 +/* f0dedd4: afaf0090 */ sw $t7,0x90($sp) +/* f0dedd8: adc00004 */ sw $zero,0x4($t6) +/* f0deddc: add80000 */ sw $t8,0x0($t6) /* f0dede0: 8fb90090 */ lw $t9,0x90($sp) - /* f0dede4: 3c0fba00 */ lui $t7,0xba00 - /* f0dede8: 35ef1402 */ ori $t7,$t7,0x1402 - /* f0dedec: 272e0008 */ addiu $t6,$t9,0x8 - /* f0dedf0: afae0090 */ sw $t6,0x90($sp) - /* f0dedf4: af200004 */ sw $zero,0x4($t9) - /* f0dedf8: af2f0000 */ sw $t7,0x0($t9) +/* f0dede4: 3c0fba00 */ lui $t7,0xba00 +/* f0dede8: 35ef1402 */ ori $t7,$t7,0x1402 +/* f0dedec: 272e0008 */ addiu $t6,$t9,0x8 +/* f0dedf0: afae0090 */ sw $t6,0x90($sp) +/* f0dedf4: af200004 */ sw $zero,0x4($t9) +/* f0dedf8: af2f0000 */ sw $t7,0x0($t9) /* f0dedfc: 8fb80090 */ lw $t8,0x90($sp) - /* f0dee00: 3c0eb900 */ lui $t6,0xb900 - /* f0dee04: 35ce0002 */ ori $t6,$t6,0x2 - /* f0dee08: 27190008 */ addiu $t9,$t8,0x8 - /* f0dee0c: afb90090 */ sw $t9,0x90($sp) - /* f0dee10: af000004 */ sw $zero,0x4($t8) - /* f0dee14: af0e0000 */ sw $t6,0x0($t8) +/* f0dee00: 3c0eb900 */ lui $t6,0xb900 +/* f0dee04: 35ce0002 */ ori $t6,$t6,0x2 +/* f0dee08: 27190008 */ addiu $t9,$t8,0x8 +/* f0dee0c: afb90090 */ sw $t9,0x90($sp) +/* f0dee10: af000004 */ sw $zero,0x4($t8) +/* f0dee14: af0e0000 */ sw $t6,0x0($t8) /* f0dee18: 8faf0090 */ lw $t7,0x90($sp) - /* f0dee1c: 3c19fc12 */ lui $t9,0xfc12 - /* f0dee20: 37397e24 */ ori $t9,$t9,0x7e24 - /* f0dee24: 25f80008 */ addiu $t8,$t7,0x8 +/* f0dee1c: 3c19fc12 */ lui $t9,0xfc12 +/* f0dee20: 37397e24 */ ori $t9,$t9,0x7e24 +/* f0dee24: 25f80008 */ addiu $t8,$t7,0x8 /* f0dee28: afb80090 */ sw $t8,0x90($sp) - /* f0dee2c: 240ef9fc */ addiu $t6,$zero,-1540 - /* f0dee30: adee0004 */ sw $t6,0x4($t7) - /* f0dee34: adf90000 */ sw $t9,0x0($t7) +/* f0dee2c: 240ef9fc */ addiu $t6,$zero,-1540 +/* f0dee30: adee0004 */ sw $t6,0x4($t7) +/* f0dee34: adf90000 */ sw $t9,0x0($t7) /* f0dee38: 8faf0090 */ lw $t7,0x90($sp) - /* f0dee3c: 3c19b600 */ lui $t9,0xb600 - /* f0dee40: 240e3000 */ addiu $t6,$zero,0x3000 - /* f0dee44: 25f80008 */ addiu $t8,$t7,0x8 - /* f0dee48: afb80090 */ sw $t8,0x90($sp) - /* f0dee4c: adee0004 */ sw $t6,0x4($t7) - /* f0dee50: adf90000 */ sw $t9,0x0($t7) +/* f0dee3c: 3c19b600 */ lui $t9,0xb600 +/* f0dee40: 240e3000 */ addiu $t6,$zero,0x3000 +/* f0dee44: 25f80008 */ addiu $t8,$t7,0x8 +/* f0dee48: afb80090 */ sw $t8,0x90($sp) +/* f0dee4c: adee0004 */ sw $t6,0x4($t7) +/* f0dee50: adf90000 */ sw $t9,0x0($t7) /* f0dee54: 8faf0090 */ lw $t7,0x90($sp) - /* f0dee58: 3c19ba00 */ lui $t9,0xba00 - /* f0dee5c: 37390c02 */ ori $t9,$t9,0xc02 - /* f0dee60: 25f80008 */ addiu $t8,$t7,0x8 +/* f0dee58: 3c19ba00 */ lui $t9,0xba00 +/* f0dee5c: 37390c02 */ ori $t9,$t9,0xc02 +/* f0dee60: 25f80008 */ addiu $t8,$t7,0x8 /* f0dee64: afb80090 */ sw $t8,0x90($sp) - /* f0dee68: 240e2000 */ addiu $t6,$zero,0x2000 - /* f0dee6c: adee0004 */ sw $t6,0x4($t7) +/* f0dee68: 240e2000 */ addiu $t6,$zero,0x2000 +/* f0dee6c: adee0004 */ sw $t6,0x4($t7) /* f0dee70: adf90000 */ sw $t9,0x0($t7) - /* f0dee74: 240f0002 */ addiu $t7,$zero,0x2 - /* f0dee78: 24180001 */ addiu $t8,$zero,0x1 - /* f0dee7c: afb80014 */ sw $t8,0x14($sp) - /* f0dee80: afaf0010 */ sw $t7,0x10($sp) +/* f0dee74: 240f0002 */ addiu $t7,$zero,0x2 +/* f0dee78: 24180001 */ addiu $t8,$zero,0x1 +/* f0dee7c: afb80014 */ sw $t8,0x14($sp) +/* f0dee80: afaf0010 */ sw $t7,0x10($sp) /* f0dee84: afa00018 */ sw $zero,0x18($sp) - /* f0dee88: 27a40090 */ addiu $a0,$sp,0x90 - /* f0dee8c: 00002825 */ or $a1,$zero,$zero - /* f0dee90: 24060002 */ addiu $a2,$zero,0x2 - /* f0dee94: 0fc2c5c8 */ jal texSelect - /* f0dee98: 00003825 */ or $a3,$zero,$zero +/* f0dee88: 27a40090 */ addiu $a0,$sp,0x90 +/* f0dee8c: 00002825 */ or $a1,$zero,$zero +/* f0dee90: 24060002 */ addiu $a2,$zero,0x2 +/* f0dee94: 0fc2c5c8 */ jal texSelect +/* f0dee98: 00003825 */ or $a3,$zero,$zero /* f0dee9c: 8fab0094 */ lw $t3,0x94($sp) - /* f0deea0: 2404000a */ addiu $a0,$zero,0xa +/* f0deea0: 2404000a */ addiu $a0,$zero,0xa /* f0deea4: 8fac0098 */ lw $t4,0x98($sp) - /* f0deea8: 01640019 */ multu $t3,$a0 - /* f0deeac: 8fad009c */ lw $t5,0x9c($sp) - /* f0deeb0: 8fb90090 */ lw $t9,0x90($sp) +/* f0deea8: 01640019 */ multu $t3,$a0 +/* f0deeac: 8fad009c */ lw $t5,0x9c($sp) +/* f0deeb0: 8fb90090 */ lw $t9,0x90($sp) /* f0deeb4: 8faa00a0 */ lw $t2,0xa0($sp) - /* f0deeb8: 3c0fb900 */ lui $t7,0xb900 - /* f0deebc: 272e0008 */ addiu $t6,$t9,0x8 +/* f0deeb8: 3c0fb900 */ lui $t7,0xb900 +/* f0deebc: 272e0008 */ addiu $t6,$t9,0x8 /* f0deec0: afae0090 */ sw $t6,0x90($sp) - /* f0deec4: 3c180050 */ lui $t8,0x50 - /* f0deec8: 37184240 */ ori $t8,$t8,0x4240 - /* f0deecc: 35ef031d */ ori $t7,$t7,0x31d - /* f0deed0: 00002812 */ mflo $a1 - /* f0deed4: af2f0000 */ sw $t7,0x0($t9) +/* f0deec4: 3c180050 */ lui $t8,0x50 +/* f0deec8: 37184240 */ ori $t8,$t8,0x4240 +/* f0deecc: 35ef031d */ ori $t7,$t7,0x31d +/* f0deed0: 00002812 */ mflo $a1 +/* f0deed4: af2f0000 */ sw $t7,0x0($t9) /* f0deed8: af380004 */ sw $t8,0x4($t9) - /* f0deedc: 01840019 */ multu $t4,$a0 - /* f0deee0: 03201825 */ or $v1,$t9,$zero - /* f0deee4: 014c9021 */ addu $s2,$t2,$t4 - /* f0deee8: 2402fff6 */ addiu $v0,$zero,-10 - /* f0deeec: a6050000 */ sh $a1,0x0($s0) - /* f0deef0: a6020004 */ sh $v0,0x4($s0) - /* f0deef4: a6020010 */ sh $v0,0x10($s0) - /* f0deef8: a6050018 */ sh $a1,0x18($s0) - /* f0deefc: a602001c */ sh $v0,0x1c($s0) +/* f0deedc: 01840019 */ multu $t4,$a0 +/* f0deee0: 03201825 */ or $v1,$t9,$zero +/* f0deee4: 014c9021 */ addu $s2,$t2,$t4 +/* f0deee8: 2402fff6 */ addiu $v0,$zero,-10 +/* f0deeec: a6050000 */ sh $a1,0x0($s0) +/* f0deef0: a6020004 */ sh $v0,0x4($s0) +/* f0deef4: a6020010 */ sh $v0,0x10($s0) +/* f0deef8: a6050018 */ sh $a1,0x18($s0) +/* f0deefc: a602001c */ sh $v0,0x1c($s0) /* f0def00: a6020028 */ sh $v0,0x28($s0) - /* f0def04: 00003012 */ mflo $a2 - /* f0def08: a6060002 */ sh $a2,0x2($s0) +/* f0def04: 00003012 */ mflo $a2 +/* f0def08: a6060002 */ sh $a2,0x2($s0) /* f0def0c: a606000e */ sh $a2,0xe($s0) - /* f0def10: 01a40019 */ multu $t5,$a0 - /* f0def14: a6050030 */ sh $a1,0x30($s0) - /* f0def18: a6020034 */ sh $v0,0x34($s0) +/* f0def10: 01a40019 */ multu $t5,$a0 +/* f0def14: a6050030 */ sh $a1,0x30($s0) +/* f0def18: a6020034 */ sh $v0,0x34($s0) /* f0def1c: a6020040 */ sh $v0,0x40($s0) - /* f0def20: 240f0018 */ addiu $t7,$zero,0x18 - /* f0def24: 24050008 */ addiu $a1,$zero,0x8 - /* f0def28: 2418000c */ addiu $t8,$zero,0xc - /* f0def2c: 00003812 */ mflo $a3 +/* f0def20: 240f0018 */ addiu $t7,$zero,0x18 +/* f0def24: 24050008 */ addiu $a1,$zero,0x8 +/* f0def28: 2418000c */ addiu $t8,$zero,0xc +/* f0def2c: 00003812 */ mflo $a3 /* f0def30: a607000c */ sh $a3,0xc($s0) - /* f0def34: 06410003 */ bgez $s2,.NB0f0def44 - /* f0def38: 0012c843 */ sra $t9,$s2,0x1 - /* f0def3c: 26410001 */ addiu $at,$s2,0x1 - /* f0def40: 0001c843 */ sra $t9,$at,0x1 - .NB0f0def44: - /* f0def44: 03240019 */ multu $t9,$a0 - /* f0def48: a6070024 */ sh $a3,0x24($s0) +/* f0def34: 06410003 */ bgez $s2,.NB0f0def44 +/* f0def38: 0012c843 */ sra $t9,$s2,0x1 +/* f0def3c: 26410001 */ addiu $at,$s2,0x1 +/* f0def40: 0001c843 */ sra $t9,$at,0x1 +.NB0f0def44: +/* f0def44: 03240019 */ multu $t9,$a0 +/* f0def48: a6070024 */ sh $a3,0x24($s0) /* f0def4c: a607003c */ sh $a3,0x3c($s0) - /* f0def50: 03209025 */ or $s2,$t9,$zero - /* f0def54: 24190010 */ addiu $t9,$zero,0x10 - /* f0def58: 00004012 */ mflo $t0 - /* f0def5c: a608001a */ sh $t0,0x1a($s0) +/* f0def50: 03209025 */ or $s2,$t9,$zero +/* f0def54: 24190010 */ addiu $t9,$zero,0x10 +/* f0def58: 00004012 */ mflo $t0 +/* f0def5c: a608001a */ sh $t0,0x1a($s0) /* f0def60: a6080026 */ sh $t0,0x26($s0) - /* f0def64: 01440019 */ multu $t2,$a0 - /* f0def68: 00001812 */ mflo $v1 - /* f0def6c: a6030032 */ sh $v1,0x32($s0) - /* f0def70: a603003e */ sh $v1,0x3e($s0) - /* f0def74: 8fae00a4 */ lw $t6,0xa4($sp) - /* f0def78: a20f0013 */ sb $t7,0x13($s0) +/* f0def64: 01440019 */ multu $t2,$a0 +/* f0def68: 00001812 */ mflo $v1 +/* f0def6c: a6030032 */ sh $v1,0x32($s0) +/* f0def70: a603003e */ sh $v1,0x3e($s0) +/* f0def74: 8fae00a4 */ lw $t6,0xa4($sp) +/* f0def78: a20f0013 */ sb $t7,0x13($s0) /* f0def7c: a606004a */ sh $a2,0x4a($s0) - /* f0def80: 01c40019 */ multu $t6,$a0 - /* f0def84: 24040004 */ addiu $a0,$zero,0x4 - /* f0def88: a204001f */ sb $a0,0x1f($s0) +/* f0def80: 01c40019 */ multu $t6,$a0 +/* f0def84: 24040004 */ addiu $a0,$zero,0x4 +/* f0def88: a204001f */ sb $a0,0x1f($s0) /* f0def8c: a204002b */ sb $a0,0x2b($s0) - /* f0def90: 016d2021 */ addu $a0,$t3,$t5 - /* f0def94: a2050037 */ sb $a1,0x37($s0) +/* f0def90: 016d2021 */ addu $a0,$t3,$t5 +/* f0def94: a2050037 */ sb $a1,0x37($s0) /* f0def98: a2050043 */ sb $a1,0x43($s0) - /* f0def9c: 240e0014 */ addiu $t6,$zero,0x14 - /* f0defa0: a602004c */ sh $v0,0x4c($s0) +/* f0def9c: 240e0014 */ addiu $t6,$zero,0x14 +/* f0defa0: a602004c */ sh $v0,0x4c($s0) /* f0defa4: a6080056 */ sh $t0,0x56($s0) - /* f0defa8: 00004812 */ mflo $t1 - /* f0defac: a6090048 */ sh $t1,0x48($s0) - /* f0defb0: a6090054 */ sh $t1,0x54($s0) - /* f0defb4: a6020058 */ sh $v0,0x58($s0) - /* f0defb8: a6090060 */ sh $t1,0x60($s0) - /* f0defbc: a6030062 */ sh $v1,0x62($s0) - /* f0defc0: a6020064 */ sh $v0,0x64($s0) - /* f0defc4: a2000007 */ sb $zero,0x7($s0) - /* f0defc8: a218004f */ sb $t8,0x4f($s0) - /* f0defcc: a219005b */ sb $t9,0x5b($s0) +/* f0defa8: 00004812 */ mflo $t1 +/* f0defac: a6090048 */ sh $t1,0x48($s0) +/* f0defb0: a6090054 */ sh $t1,0x54($s0) +/* f0defb4: a6020058 */ sh $v0,0x58($s0) +/* f0defb8: a6090060 */ sh $t1,0x60($s0) +/* f0defbc: a6030062 */ sh $v1,0x62($s0) +/* f0defc0: a6020064 */ sh $v0,0x64($s0) +/* f0defc4: a2000007 */ sb $zero,0x7($s0) +/* f0defc8: a218004f */ sb $t8,0x4f($s0) +/* f0defcc: a219005b */ sb $t9,0x5b($s0) /* f0defd0: a20e0067 */ sb $t6,0x67($s0) - /* f0defd4: 04810003 */ bgez $a0,.NB0f0defe4 - /* f0defd8: 00047843 */ sra $t7,$a0,0x1 - /* f0defdc: 24810001 */ addiu $at,$a0,0x1 - /* f0defe0: 00017843 */ sra $t7,$at,0x1 - .NB0f0defe4: - /* f0defe4: 01e02025 */ or $a0,$t7,$zero - /* f0defe8: afaf0050 */ sw $t7,0x50($sp) +/* f0defd4: 04810003 */ bgez $a0,.NB0f0defe4 +/* f0defd8: 00047843 */ sra $t7,$a0,0x1 +/* f0defdc: 24810001 */ addiu $at,$a0,0x1 +/* f0defe0: 00017843 */ sra $t7,$at,0x1 +.NB0f0defe4: +/* f0defe4: 01e02025 */ or $a0,$t7,$zero +/* f0defe8: afaf0050 */ sw $t7,0x50($sp) /* f0defec: afb20044 */ sw $s2,0x44($sp) - /* f0deff0: 02402825 */ or $a1,$s2,$zero - /* f0deff4: 0fc53a82 */ jal text0f1543ac - /* f0deff8: 2406ffff */ addiu $a2,$zero,-1 +/* f0deff0: 02402825 */ or $a1,$s2,$zero +/* f0deff4: 0fc53a82 */ jal text0f1543ac +/* f0deff8: 2406ffff */ addiu $a2,$zero,-1 /* f0deffc: 8fa40050 */ lw $a0,0x50($sp) - /* f0df000: 305200ff */ andi $s2,$v0,0xff +/* f0df000: 305200ff */ andi $s2,$v0,0xff /* f0df004: 8fa50044 */ lw $a1,0x44($sp) - /* f0df008: 0fc53a82 */ jal text0f1543ac - /* f0df00c: 2406ff7f */ addiu $a2,$zero,-129 - /* f0df010: 2406ff00 */ addiu $a2,$zero,-256 - /* f0df014: 36586f00 */ ori $t8,$s2,0x6f00 - /* f0df018: 304300ff */ andi $v1,$v0,0xff - /* f0df01c: 3c016f6f */ lui $at,0x6f6f +/* f0df008: 0fc53a82 */ jal text0f1543ac +/* f0df00c: 2406ff7f */ addiu $a2,$zero,-129 +/* f0df010: 2406ff00 */ addiu $a2,$zero,-256 +/* f0df014: 36586f00 */ ori $t8,$s2,0x6f00 +/* f0df018: 304300ff */ andi $v1,$v0,0xff +/* f0df01c: 3c016f6f */ lui $at,0x6f6f /* f0df020: ae380000 */ sw $t8,0x0($s1) - /* f0df024: 34796f00 */ ori $t9,$v1,0x6f00 - /* f0df028: 36453f00 */ ori $a1,$s2,0x3f00 - /* f0df02c: 34216f00 */ ori $at,$at,0x6f00 - /* f0df030: 03267024 */ and $t6,$t9,$a2 - /* f0df034: 00a67824 */ and $t7,$a1,$a2 - /* f0df038: 0241c025 */ or $t8,$s2,$at - /* f0df03c: ae390004 */ sw $t9,0x4($s1) - /* f0df040: ae250008 */ sw $a1,0x8($s1) - /* f0df044: ae26000c */ sw $a2,0xc($s1) - /* f0df048: ae2e0010 */ sw $t6,0x10($s1) - /* f0df04c: ae2f0014 */ sw $t7,0x14($s1) - /* f0df050: ae380018 */ sw $t8,0x18($s1) +/* f0df024: 34796f00 */ ori $t9,$v1,0x6f00 +/* f0df028: 36453f00 */ ori $a1,$s2,0x3f00 +/* f0df02c: 34216f00 */ ori $at,$at,0x6f00 +/* f0df030: 03267024 */ and $t6,$t9,$a2 +/* f0df034: 00a67824 */ and $t7,$a1,$a2 +/* f0df038: 0241c025 */ or $t8,$s2,$at +/* f0df03c: ae390004 */ sw $t9,0x4($s1) +/* f0df040: ae250008 */ sw $a1,0x8($s1) +/* f0df044: ae26000c */ sw $a2,0xc($s1) +/* f0df048: ae2e0010 */ sw $t6,0x10($s1) +/* f0df04c: ae2f0014 */ sw $t7,0x14($s1) +/* f0df050: ae380018 */ sw $t8,0x18($s1) /* f0df054: 8fb90090 */ lw $t9,0x90($sp) - /* f0df058: 3c0f0718 */ lui $t7,0x718 - /* f0df05c: 35ef001c */ ori $t7,$t7,0x1c - /* f0df060: 272e0008 */ addiu $t6,$t9,0x8 - /* f0df064: afae0090 */ sw $t6,0x90($sp) +/* f0df058: 3c0f0718 */ lui $t7,0x718 +/* f0df05c: 35ef001c */ ori $t7,$t7,0x1c +/* f0df060: 272e0008 */ addiu $t6,$t9,0x8 +/* f0df064: afae0090 */ sw $t6,0x90($sp) /* f0df068: af2f0000 */ sw $t7,0x0($t9) - /* f0df06c: 02202025 */ or $a0,$s1,$zero - /* f0df070: 0c013100 */ jal osVirtualToPhysical - /* f0df074: afb90060 */ sw $t9,0x60($sp) +/* f0df06c: 02202025 */ or $a0,$s1,$zero +/* f0df070: 0c013100 */ jal osVirtualToPhysical +/* f0df074: afb90060 */ sw $t9,0x60($sp) /* f0df078: 8fa70060 */ lw $a3,0x60($sp) - /* f0df07c: 3c0e0480 */ lui $t6,0x480 - /* f0df080: 35ce006c */ ori $t6,$t6,0x6c - /* f0df084: ace20004 */ sw $v0,0x4($a3) +/* f0df07c: 3c0e0480 */ lui $t6,0x480 +/* f0df080: 35ce006c */ ori $t6,$t6,0x6c +/* f0df084: ace20004 */ sw $v0,0x4($a3) /* f0df088: 8fb10090 */ lw $s1,0x90($sp) - /* f0df08c: 02002025 */ or $a0,$s0,$zero - /* f0df090: 26390008 */ addiu $t9,$s1,0x8 +/* f0df08c: 02002025 */ or $a0,$s0,$zero +/* f0df090: 26390008 */ addiu $t9,$s1,0x8 /* f0df094: afb90090 */ sw $t9,0x90($sp) - /* f0df098: 0c013100 */ jal osVirtualToPhysical - /* f0df09c: ae2e0000 */ sw $t6,0x0($s1) - /* f0df0a0: ae220004 */ sw $v0,0x4($s1) +/* f0df098: 0c013100 */ jal osVirtualToPhysical +/* f0df09c: ae2e0000 */ sw $t6,0x0($s1) +/* f0df0a0: ae220004 */ sw $v0,0x4($s1) /* f0df0a4: 8faf0090 */ lw $t7,0x90($sp) - /* f0df0a8: 3c19b100 */ lui $t9,0xb100 - /* f0df0ac: 3c0e3432 */ lui $t6,0x3432 - /* f0df0b0: 25f80008 */ addiu $t8,$t7,0x8 +/* f0df0a8: 3c19b100 */ lui $t9,0xb100 +/* f0df0ac: 3c0e3432 */ lui $t6,0x3432 +/* f0df0b0: 25f80008 */ addiu $t8,$t7,0x8 /* f0df0b4: afb80090 */ sw $t8,0x90($sp) - /* f0df0b8: 35ce2310 */ ori $t6,$t6,0x2310 - /* f0df0bc: 37395403 */ ori $t9,$t9,0x5403 - /* f0df0c0: adf90000 */ sw $t9,0x0($t7) - /* f0df0c4: adee0004 */ sw $t6,0x4($t7) +/* f0df0b8: 35ce2310 */ ori $t6,$t6,0x2310 +/* f0df0bc: 37395403 */ ori $t9,$t9,0x5403 +/* f0df0c0: adf90000 */ sw $t9,0x0($t7) +/* f0df0c4: adee0004 */ sw $t6,0x4($t7) /* f0df0c8: 8faf0090 */ lw $t7,0x90($sp) - /* f0df0cc: 3c0e5873 */ lui $t6,0x5873 - /* f0df0d0: 3c19b100 */ lui $t9,0xb100 - /* f0df0d4: 25f80008 */ addiu $t8,$t7,0x8 +/* f0df0cc: 3c0e5873 */ lui $t6,0x5873 +/* f0df0d0: 3c19b100 */ lui $t9,0xb100 +/* f0df0d4: 25f80008 */ addiu $t8,$t7,0x8 /* f0df0d8: afb80090 */ sw $t8,0x90($sp) - /* f0df0dc: 37393817 */ ori $t9,$t9,0x3817 - /* f0df0e0: 35ce3761 */ ori $t6,$t6,0x3761 - /* f0df0e4: adee0004 */ sw $t6,0x4($t7) - /* f0df0e8: adf90000 */ sw $t9,0x0($t7) +/* f0df0dc: 37393817 */ ori $t9,$t9,0x3817 +/* f0df0e0: 35ce3761 */ ori $t6,$t6,0x3761 +/* f0df0e4: adee0004 */ sw $t6,0x4($t7) +/* f0df0e8: adf90000 */ sw $t9,0x0($t7) /* f0df0ec: 8fa60098 */ lw $a2,0x98($sp) - /* f0df0f0: 325000ff */ andi $s0,$s2,0xff - /* f0df0f4: 0010c882 */ srl $t9,$s0,0x2 - /* f0df0f8: 240f0028 */ addiu $t7,$zero,0x28 - /* f0df0fc: 240e0001 */ addiu $t6,$zero,0x1 - /* f0df100: 24d80001 */ addiu $t8,$a2,0x1 - /* f0df104: afb80010 */ sw $t8,0x10($sp) - /* f0df108: afae0018 */ sw $t6,0x18($sp) +/* f0df0f0: 325000ff */ andi $s0,$s2,0xff +/* f0df0f4: 0010c882 */ srl $t9,$s0,0x2 +/* f0df0f8: 240f0028 */ addiu $t7,$zero,0x28 +/* f0df0fc: 240e0001 */ addiu $t6,$zero,0x1 +/* f0df100: 24d80001 */ addiu $t8,$a2,0x1 +/* f0df104: afb80010 */ sw $t8,0x10($sp) +/* f0df108: afae0018 */ sw $t6,0x18($sp) /* f0df10c: afaf001c */ sw $t7,0x1c($sp) - /* f0df110: 03208025 */ or $s0,$t9,$zero - /* f0df114: afb90014 */ sw $t9,0x14($sp) - /* f0df118: afa00020 */ sw $zero,0x20($sp) - /* f0df11c: 8fa7009c */ lw $a3,0x9c($sp) +/* f0df110: 03208025 */ or $s0,$t9,$zero +/* f0df114: afb90014 */ sw $t9,0x14($sp) +/* f0df118: afa00020 */ sw $zero,0x20($sp) +/* f0df11c: 8fa7009c */ lw $a3,0x9c($sp) /* f0df120: 8fa50094 */ lw $a1,0x94($sp) - /* f0df124: 0fc37fce */ jal menugfxDrawShimmer - /* f0df128: 8fa40090 */ lw $a0,0x90($sp) +/* f0df124: 0fc37fce */ jal menugfxDrawShimmer +/* f0df128: 8fa40090 */ lw $a0,0x90($sp) /* f0df12c: 8fa600a0 */ lw $a2,0xa0($sp) - /* f0df130: 24190028 */ addiu $t9,$zero,0x28 - /* f0df134: 240e0001 */ addiu $t6,$zero,0x1 - /* f0df138: 24d80001 */ addiu $t8,$a2,0x1 - /* f0df13c: afa20090 */ sw $v0,0x90($sp) - /* f0df140: afb80010 */ sw $t8,0x10($sp) - /* f0df144: afae0020 */ sw $t6,0x20($sp) +/* f0df130: 24190028 */ addiu $t9,$zero,0x28 +/* f0df134: 240e0001 */ addiu $t6,$zero,0x1 +/* f0df138: 24d80001 */ addiu $t8,$a2,0x1 +/* f0df13c: afa20090 */ sw $v0,0x90($sp) +/* f0df140: afb80010 */ sw $t8,0x10($sp) +/* f0df144: afae0020 */ sw $t6,0x20($sp) /* f0df148: afb9001c */ sw $t9,0x1c($sp) - /* f0df14c: 00402025 */ or $a0,$v0,$zero - /* f0df150: 8fa50094 */ lw $a1,0x94($sp) - /* f0df154: 8fa7009c */ lw $a3,0x9c($sp) +/* f0df14c: 00402025 */ or $a0,$v0,$zero +/* f0df150: 8fa50094 */ lw $a1,0x94($sp) +/* f0df154: 8fa7009c */ lw $a3,0x9c($sp) /* f0df158: afb00014 */ sw $s0,0x14($sp) - /* f0df15c: 0fc37fce */ jal menugfxDrawShimmer - /* f0df160: afa00018 */ sw $zero,0x18($sp) - /* f0df164: 8fbf003c */ lw $ra,0x3c($sp) - /* f0df168: 8fb00030 */ lw $s0,0x30($sp) - /* f0df16c: 8fb10034 */ lw $s1,0x34($sp) +/* f0df15c: 0fc37fce */ jal menugfxDrawShimmer +/* f0df160: afa00018 */ sw $zero,0x18($sp) +/* f0df164: 8fbf003c */ lw $ra,0x3c($sp) +/* f0df168: 8fb00030 */ lw $s0,0x30($sp) +/* f0df16c: 8fb10034 */ lw $s1,0x34($sp) /* f0df170: 8fb20038 */ lw $s2,0x38($sp) - /* f0df174: 03e00008 */ jr $ra - /* f0df178: 27bd0090 */ addiu $sp,$sp,0x90 - ); +/* f0df174: 03e00008 */ jr $ra +/* f0df178: 27bd0090 */ addiu $sp,$sp,0x90 +); #endif #if MATCHING - GLOBAL_ASM( - glabel menugfxRenderGradient - /* f0e1ce8: 27bdffa0 */ addiu $sp,$sp,-96 - /* f0e1cec: afbf002c */ sw $ra,0x2c($sp) - /* f0e1cf0: afa40060 */ sw $a0,0x60($sp) - /* f0e1cf4: afb10028 */ sw $s1,0x28($sp) - /* f0e1cf8: afb00024 */ sw $s0,0x24($sp) - /* f0e1cfc: afa50064 */ sw $a1,0x64($sp) - /* f0e1d00: afa60068 */ sw $a2,0x68($sp) - /* f0e1d04: afa7006c */ sw $a3,0x6c($sp) - /* f0e1d08: 0fc59e73 */ jal gfxAllocateColours - /* f0e1d0c: 24040003 */ addiu $a0,$zero,0x3 - /* f0e1d10: 00408825 */ or $s1,$v0,$zero - /* f0e1d14: 0fc59e59 */ jal gfxAllocateVertices - /* f0e1d18: 24040006 */ addiu $a0,$zero,0x6 - /* f0e1d1c: 8fae0060 */ lw $t6,0x60($sp) - /* f0e1d20: 3c18e700 */ lui $t8,0xe700 - /* f0e1d24: 00408025 */ or $s0,$v0,$zero - /* f0e1d28: 25cf0008 */ addiu $t7,$t6,0x8 - /* f0e1d2c: afaf0060 */ sw $t7,0x60($sp) - /* f0e1d30: adc00004 */ sw $zero,0x4($t6) - /* f0e1d34: add80000 */ sw $t8,0x0($t6) +GLOBAL_ASM( +glabel menugfxRenderGradient +/* f0e1ce8: 27bdffa0 */ addiu $sp,$sp,-96 +/* f0e1cec: afbf002c */ sw $ra,0x2c($sp) +/* f0e1cf0: afa40060 */ sw $a0,0x60($sp) +/* f0e1cf4: afb10028 */ sw $s1,0x28($sp) +/* f0e1cf8: afb00024 */ sw $s0,0x24($sp) +/* f0e1cfc: afa50064 */ sw $a1,0x64($sp) +/* f0e1d00: afa60068 */ sw $a2,0x68($sp) +/* f0e1d04: afa7006c */ sw $a3,0x6c($sp) +/* f0e1d08: 0fc59e73 */ jal gfxAllocateColours +/* f0e1d0c: 24040003 */ addiu $a0,$zero,0x3 +/* f0e1d10: 00408825 */ or $s1,$v0,$zero +/* f0e1d14: 0fc59e59 */ jal gfxAllocateVertices +/* f0e1d18: 24040006 */ addiu $a0,$zero,0x6 +/* f0e1d1c: 8fae0060 */ lw $t6,0x60($sp) +/* f0e1d20: 3c18e700 */ lui $t8,0xe700 +/* f0e1d24: 00408025 */ or $s0,$v0,$zero +/* f0e1d28: 25cf0008 */ addiu $t7,$t6,0x8 +/* f0e1d2c: afaf0060 */ sw $t7,0x60($sp) +/* f0e1d30: adc00004 */ sw $zero,0x4($t6) +/* f0e1d34: add80000 */ sw $t8,0x0($t6) /* f0e1d38: 8fb90060 */ lw $t9,0x60($sp) - /* f0e1d3c: 3c0eba00 */ lui $t6,0xba00 - /* f0e1d40: 35ce1402 */ ori $t6,$t6,0x1402 - /* f0e1d44: 272d0008 */ addiu $t5,$t9,0x8 - /* f0e1d48: afad0060 */ sw $t5,0x60($sp) - /* f0e1d4c: af200004 */ sw $zero,0x4($t9) - /* f0e1d50: af2e0000 */ sw $t6,0x0($t9) +/* f0e1d3c: 3c0eba00 */ lui $t6,0xba00 +/* f0e1d40: 35ce1402 */ ori $t6,$t6,0x1402 +/* f0e1d44: 272d0008 */ addiu $t5,$t9,0x8 +/* f0e1d48: afad0060 */ sw $t5,0x60($sp) +/* f0e1d4c: af200004 */ sw $zero,0x4($t9) +/* f0e1d50: af2e0000 */ sw $t6,0x0($t9) /* f0e1d54: 8faf0060 */ lw $t7,0x60($sp) - /* f0e1d58: 3c19b900 */ lui $t9,0xb900 - /* f0e1d5c: 37390002 */ ori $t9,$t9,0x2 - /* f0e1d60: 25f80008 */ addiu $t8,$t7,0x8 - /* f0e1d64: afb80060 */ sw $t8,0x60($sp) - /* f0e1d68: ade00004 */ sw $zero,0x4($t7) - /* f0e1d6c: adf90000 */ sw $t9,0x0($t7) +/* f0e1d58: 3c19b900 */ lui $t9,0xb900 +/* f0e1d5c: 37390002 */ ori $t9,$t9,0x2 +/* f0e1d60: 25f80008 */ addiu $t8,$t7,0x8 +/* f0e1d64: afb80060 */ sw $t8,0x60($sp) +/* f0e1d68: ade00004 */ sw $zero,0x4($t7) +/* f0e1d6c: adf90000 */ sw $t9,0x0($t7) /* f0e1d70: 8fad0060 */ lw $t5,0x60($sp) - /* f0e1d74: 3c0ffc12 */ lui $t7,0xfc12 - /* f0e1d78: 35ef7e24 */ ori $t7,$t7,0x7e24 - /* f0e1d7c: 25ae0008 */ addiu $t6,$t5,0x8 +/* f0e1d74: 3c0ffc12 */ lui $t7,0xfc12 +/* f0e1d78: 35ef7e24 */ ori $t7,$t7,0x7e24 +/* f0e1d7c: 25ae0008 */ addiu $t6,$t5,0x8 /* f0e1d80: afae0060 */ sw $t6,0x60($sp) - /* f0e1d84: 2418f9fc */ addiu $t8,$zero,-1540 - /* f0e1d88: adb80004 */ sw $t8,0x4($t5) - /* f0e1d8c: adaf0000 */ sw $t7,0x0($t5) +/* f0e1d84: 2418f9fc */ addiu $t8,$zero,-1540 +/* f0e1d88: adb80004 */ sw $t8,0x4($t5) +/* f0e1d8c: adaf0000 */ sw $t7,0x0($t5) /* f0e1d90: 8fb90060 */ lw $t9,0x60($sp) - /* f0e1d94: 240f3000 */ addiu $t7,$zero,0x3000 - /* f0e1d98: 3c0eb600 */ lui $t6,0xb600 - /* f0e1d9c: 272d0008 */ addiu $t5,$t9,0x8 - /* f0e1da0: afad0060 */ sw $t5,0x60($sp) - /* f0e1da4: af2f0004 */ sw $t7,0x4($t9) - /* f0e1da8: af2e0000 */ sw $t6,0x0($t9) +/* f0e1d94: 240f3000 */ addiu $t7,$zero,0x3000 +/* f0e1d98: 3c0eb600 */ lui $t6,0xb600 +/* f0e1d9c: 272d0008 */ addiu $t5,$t9,0x8 +/* f0e1da0: afad0060 */ sw $t5,0x60($sp) +/* f0e1da4: af2f0004 */ sw $t7,0x4($t9) +/* f0e1da8: af2e0000 */ sw $t6,0x0($t9) /* f0e1dac: 8fb80060 */ lw $t8,0x60($sp) - /* f0e1db0: 3c0dba00 */ lui $t5,0xba00 - /* f0e1db4: 35ad0c02 */ ori $t5,$t5,0xc02 - /* f0e1db8: 27190008 */ addiu $t9,$t8,0x8 +/* f0e1db0: 3c0dba00 */ lui $t5,0xba00 +/* f0e1db4: 35ad0c02 */ ori $t5,$t5,0xc02 +/* f0e1db8: 27190008 */ addiu $t9,$t8,0x8 /* f0e1dbc: afb90060 */ sw $t9,0x60($sp) - /* f0e1dc0: 240e2000 */ addiu $t6,$zero,0x2000 - /* f0e1dc4: af0e0004 */ sw $t6,0x4($t8) +/* f0e1dc0: 240e2000 */ addiu $t6,$zero,0x2000 +/* f0e1dc4: af0e0004 */ sw $t6,0x4($t8) /* f0e1dc8: af0d0000 */ sw $t5,0x0($t8) - /* f0e1dcc: 24180001 */ addiu $t8,$zero,0x1 - /* f0e1dd0: 240f0002 */ addiu $t7,$zero,0x2 - /* f0e1dd4: afaf0010 */ sw $t7,0x10($sp) - /* f0e1dd8: afb80014 */ sw $t8,0x14($sp) +/* f0e1dcc: 24180001 */ addiu $t8,$zero,0x1 +/* f0e1dd0: 240f0002 */ addiu $t7,$zero,0x2 +/* f0e1dd4: afaf0010 */ sw $t7,0x10($sp) +/* f0e1dd8: afb80014 */ sw $t8,0x14($sp) /* f0e1ddc: afa00018 */ sw $zero,0x18($sp) - /* f0e1de0: 27a40060 */ addiu $a0,$sp,0x60 - /* f0e1de4: 00002825 */ or $a1,$zero,$zero - /* f0e1de8: 24060002 */ addiu $a2,$zero,0x2 - /* f0e1dec: 0fc2ce70 */ jal texSelect - /* f0e1df0: 00003825 */ or $a3,$zero,$zero - /* f0e1df4: 8fb90060 */ lw $t9,0x60($sp) - /* f0e1df8: 8fab0070 */ lw $t3,0x70($sp) - /* f0e1dfc: 8fac0068 */ lw $t4,0x68($sp) - /* f0e1e00: 8fa9006c */ lw $t1,0x6c($sp) +/* f0e1de0: 27a40060 */ addiu $a0,$sp,0x60 +/* f0e1de4: 00002825 */ or $a1,$zero,$zero +/* f0e1de8: 24060002 */ addiu $a2,$zero,0x2 +/* f0e1dec: 0fc2ce70 */ jal texSelect +/* f0e1df0: 00003825 */ or $a3,$zero,$zero +/* f0e1df4: 8fb90060 */ lw $t9,0x60($sp) +/* f0e1df8: 8fab0070 */ lw $t3,0x70($sp) +/* f0e1dfc: 8fac0068 */ lw $t4,0x68($sp) +/* f0e1e00: 8fa9006c */ lw $t1,0x6c($sp) /* f0e1e04: 8faa0064 */ lw $t2,0x64($sp) - /* f0e1e08: 272d0008 */ addiu $t5,$t9,0x8 +/* f0e1e08: 272d0008 */ addiu $t5,$t9,0x8 /* f0e1e0c: afad0060 */ sw $t5,0x60($sp) - /* f0e1e10: 3c0eb900 */ lui $t6,0xb900 - /* f0e1e14: 3c0f0050 */ lui $t7,0x50 - /* f0e1e18: 018b4021 */ addu $t0,$t4,$t3 - /* f0e1e1c: 35ef4240 */ ori $t7,$t7,0x4240 - /* f0e1e20: 35ce031d */ ori $t6,$t6,0x31d - /* f0e1e24: af2e0000 */ sw $t6,0x0($t9) +/* f0e1e10: 3c0eb900 */ lui $t6,0xb900 +/* f0e1e14: 3c0f0050 */ lui $t7,0x50 +/* f0e1e18: 018b4021 */ addu $t0,$t4,$t3 +/* f0e1e1c: 35ef4240 */ ori $t7,$t7,0x4240 +/* f0e1e20: 35ce031d */ ori $t6,$t6,0x31d +/* f0e1e24: af2e0000 */ sw $t6,0x0($t9) /* f0e1e28: af2f0004 */ sw $t7,0x4($t9) - /* f0e1e2c: 03201025 */ or $v0,$t9,$zero - /* f0e1e30: 05010003 */ bgez $t0,.L0f0e1e40 - /* f0e1e34: 0008c043 */ sra $t8,$t0,0x1 - /* f0e1e38: 25010001 */ addiu $at,$t0,0x1 - /* f0e1e3c: 0001c043 */ sra $t8,$at,0x1 - .L0f0e1e40: - /* f0e1e40: 0018c840 */ sll $t9,$t8,0x1 - /* f0e1e44: 012a2023 */ subu $a0,$t1,$t2 - /* f0e1e48: 0099082a */ slt $at,$a0,$t9 - /* f0e1e4c: 10200001 */ beqz $at,.L0f0e1e54 - /* f0e1e50: 03004025 */ or $t0,$t8,$zero - .L0f0e1e54: - /* f0e1e54: 2406000a */ addiu $a2,$zero,0xa - /* f0e1e58: 01460019 */ multu $t2,$a2 - /* f0e1e5c: 2407fff6 */ addiu $a3,$zero,-10 - /* f0e1e60: a6070004 */ sh $a3,0x4($s0) - /* f0e1e64: a6070010 */ sh $a3,0x10($s0) - /* f0e1e68: a607001c */ sh $a3,0x1c($s0) - /* f0e1e6c: a6070028 */ sh $a3,0x28($s0) - /* f0e1e70: a6070034 */ sh $a3,0x34($s0) - /* f0e1e74: a6070040 */ sh $a3,0x40($s0) - /* f0e1e78: a2000007 */ sb $zero,0x7($s0) +/* f0e1e2c: 03201025 */ or $v0,$t9,$zero +/* f0e1e30: 05010003 */ bgez $t0,.L0f0e1e40 +/* f0e1e34: 0008c043 */ sra $t8,$t0,0x1 +/* f0e1e38: 25010001 */ addiu $at,$t0,0x1 +/* f0e1e3c: 0001c043 */ sra $t8,$at,0x1 +.L0f0e1e40: +/* f0e1e40: 0018c840 */ sll $t9,$t8,0x1 +/* f0e1e44: 012a2023 */ subu $a0,$t1,$t2 +/* f0e1e48: 0099082a */ slt $at,$a0,$t9 +/* f0e1e4c: 10200001 */ beqz $at,.L0f0e1e54 +/* f0e1e50: 03004025 */ or $t0,$t8,$zero +.L0f0e1e54: +/* f0e1e54: 2406000a */ addiu $a2,$zero,0xa +/* f0e1e58: 01460019 */ multu $t2,$a2 +/* f0e1e5c: 2407fff6 */ addiu $a3,$zero,-10 +/* f0e1e60: a6070004 */ sh $a3,0x4($s0) +/* f0e1e64: a6070010 */ sh $a3,0x10($s0) +/* f0e1e68: a607001c */ sh $a3,0x1c($s0) +/* f0e1e6c: a6070028 */ sh $a3,0x28($s0) +/* f0e1e70: a6070034 */ sh $a3,0x34($s0) +/* f0e1e74: a6070040 */ sh $a3,0x40($s0) +/* f0e1e78: a2000007 */ sb $zero,0x7($s0) /* f0e1e7c: a2000013 */ sb $zero,0x13($s0) - /* f0e1e80: 00001012 */ mflo $v0 - /* f0e1e84: a6020000 */ sh $v0,0x0($s0) +/* f0e1e80: 00001012 */ mflo $v0 +/* f0e1e84: a6020000 */ sh $v0,0x0($s0) /* f0e1e88: a6020024 */ sh $v0,0x24($s0) - /* f0e1e8c: 01860019 */ multu $t4,$a2 - /* f0e1e90: 00001812 */ mflo $v1 - /* f0e1e94: a6030002 */ sh $v1,0x2($s0) +/* f0e1e8c: 01860019 */ multu $t4,$a2 +/* f0e1e90: 00001812 */ mflo $v1 +/* f0e1e94: a6030002 */ sh $v1,0x2($s0) /* f0e1e98: a603000e */ sh $v1,0xe($s0) - /* f0e1e9c: 01260019 */ multu $t1,$a2 - /* f0e1ea0: 24030004 */ addiu $v1,$zero,0x4 - /* f0e1ea4: a203001f */ sb $v1,0x1f($s0) +/* f0e1e9c: 01260019 */ multu $t1,$a2 +/* f0e1ea0: 24030004 */ addiu $v1,$zero,0x4 +/* f0e1ea4: a203001f */ sb $v1,0x1f($s0) /* f0e1ea8: a203002b */ sb $v1,0x2b($s0) - /* f0e1eac: 00002012 */ mflo $a0 - /* f0e1eb0: a604000c */ sh $a0,0xc($s0) +/* f0e1eac: 00002012 */ mflo $a0 +/* f0e1eb0: a604000c */ sh $a0,0xc($s0) /* f0e1eb4: a6040018 */ sh $a0,0x18($s0) - /* f0e1eb8: 01660019 */ multu $t3,$a2 - /* f0e1ebc: 24040008 */ addiu $a0,$zero,0x8 - /* f0e1ec0: a2040037 */ sb $a0,0x37($s0) +/* f0e1eb8: 01660019 */ multu $t3,$a2 +/* f0e1ebc: 24040008 */ addiu $a0,$zero,0x8 +/* f0e1ec0: a2040037 */ sb $a0,0x37($s0) /* f0e1ec4: a2040043 */ sb $a0,0x43($s0) - /* f0e1ec8: 02202025 */ or $a0,$s1,$zero - /* f0e1ecc: 00002812 */ mflo $a1 - /* f0e1ed0: a605001a */ sh $a1,0x1a($s0) +/* f0e1ec8: 02202025 */ or $a0,$s1,$zero +/* f0e1ecc: 00002812 */ mflo $a1 +/* f0e1ed0: a605001a */ sh $a1,0x1a($s0) /* f0e1ed4: a6050026 */ sh $a1,0x26($s0) - /* f0e1ed8: 01460019 */ multu $t2,$a2 - /* f0e1edc: 00006812 */ mflo $t5 +/* f0e1ed8: 01460019 */ multu $t2,$a2 +/* f0e1edc: 00006812 */ mflo $t5 /* f0e1ee0: a60d0030 */ sh $t5,0x30($s0) - /* f0e1ee4: 00000000 */ nop - /* f0e1ee8: 01060019 */ multu $t0,$a2 - /* f0e1eec: 00001012 */ mflo $v0 - /* f0e1ef0: a6020032 */ sh $v0,0x32($s0) +/* f0e1ee4: 00000000 */ nop +/* f0e1ee8: 01060019 */ multu $t0,$a2 +/* f0e1eec: 00001012 */ mflo $v0 +/* f0e1ef0: a6020032 */ sh $v0,0x32($s0) /* f0e1ef4: a602003e */ sh $v0,0x3e($s0) - /* f0e1ef8: 01260019 */ multu $t1,$a2 - /* f0e1efc: 00007012 */ mflo $t6 - /* f0e1f00: a60e003c */ sh $t6,0x3c($s0) - /* f0e1f04: 8faf0074 */ lw $t7,0x74($sp) - /* f0e1f08: ae2f0000 */ sw $t7,0x0($s1) +/* f0e1ef8: 01260019 */ multu $t1,$a2 +/* f0e1efc: 00007012 */ mflo $t6 +/* f0e1f00: a60e003c */ sh $t6,0x3c($s0) +/* f0e1f04: 8faf0074 */ lw $t7,0x74($sp) +/* f0e1f08: ae2f0000 */ sw $t7,0x0($s1) /* f0e1f0c: 8fb80078 */ lw $t8,0x78($sp) - /* f0e1f10: 3c0f0708 */ lui $t7,0x708 - /* f0e1f14: 35ef000c */ ori $t7,$t7,0xc - /* f0e1f18: ae380008 */ sw $t8,0x8($s1) - /* f0e1f1c: 8fb9007c */ lw $t9,0x7c($sp) - /* f0e1f20: ae390004 */ sw $t9,0x4($s1) +/* f0e1f10: 3c0f0708 */ lui $t7,0x708 +/* f0e1f14: 35ef000c */ ori $t7,$t7,0xc +/* f0e1f18: ae380008 */ sw $t8,0x8($s1) +/* f0e1f1c: 8fb9007c */ lw $t9,0x7c($sp) +/* f0e1f20: ae390004 */ sw $t9,0x4($s1) /* f0e1f24: 8fad0060 */ lw $t5,0x60($sp) - /* f0e1f28: 25ae0008 */ addiu $t6,$t5,0x8 - /* f0e1f2c: afae0060 */ sw $t6,0x60($sp) +/* f0e1f28: 25ae0008 */ addiu $t6,$t5,0x8 +/* f0e1f2c: afae0060 */ sw $t6,0x60($sp) /* f0e1f30: adaf0000 */ sw $t7,0x0($t5) - /* f0e1f34: 0c012d20 */ jal osVirtualToPhysical - /* f0e1f38: afad0034 */ sw $t5,0x34($sp) +/* f0e1f34: 0c012d20 */ jal osVirtualToPhysical +/* f0e1f38: afad0034 */ sw $t5,0x34($sp) /* f0e1f3c: 8fa30034 */ lw $v1,0x34($sp) - /* f0e1f40: 3c0d0450 */ lui $t5,0x450 - /* f0e1f44: 35ad0048 */ ori $t5,$t5,0x48 - /* f0e1f48: ac620004 */ sw $v0,0x4($v1) +/* f0e1f40: 3c0d0450 */ lui $t5,0x450 +/* f0e1f44: 35ad0048 */ ori $t5,$t5,0x48 +/* f0e1f48: ac620004 */ sw $v0,0x4($v1) /* f0e1f4c: 8fb80060 */ lw $t8,0x60($sp) - /* f0e1f50: 02002025 */ or $a0,$s0,$zero - /* f0e1f54: 27190008 */ addiu $t9,$t8,0x8 - /* f0e1f58: afb90060 */ sw $t9,0x60($sp) +/* f0e1f50: 02002025 */ or $a0,$s0,$zero +/* f0e1f54: 27190008 */ addiu $t9,$t8,0x8 +/* f0e1f58: afb90060 */ sw $t9,0x60($sp) /* f0e1f5c: af0d0000 */ sw $t5,0x0($t8) - /* f0e1f60: 0c012d20 */ jal osVirtualToPhysical - /* f0e1f64: afb80030 */ sw $t8,0x30($sp) +/* f0e1f60: 0c012d20 */ jal osVirtualToPhysical +/* f0e1f64: afb80030 */ sw $t8,0x30($sp) /* f0e1f68: 8fa50030 */ lw $a1,0x30($sp) - /* f0e1f6c: 3c18b100 */ lui $t8,0xb100 - /* f0e1f70: 3c195432 */ lui $t9,0x5432 - /* f0e1f74: aca20004 */ sw $v0,0x4($a1) +/* f0e1f6c: 3c18b100 */ lui $t8,0xb100 +/* f0e1f70: 3c195432 */ lui $t9,0x5432 +/* f0e1f74: aca20004 */ sw $v0,0x4($a1) /* f0e1f78: 8fae0060 */ lw $t6,0x60($sp) - /* f0e1f7c: 37394510 */ ori $t9,$t9,0x4510 - /* f0e1f80: 37182405 */ ori $t8,$t8,0x2405 - /* f0e1f84: 25cf0008 */ addiu $t7,$t6,0x8 - /* f0e1f88: afaf0060 */ sw $t7,0x60($sp) - /* f0e1f8c: add90004 */ sw $t9,0x4($t6) - /* f0e1f90: add80000 */ sw $t8,0x0($t6) - /* f0e1f94: 8fbf002c */ lw $ra,0x2c($sp) - /* f0e1f98: 8fb10028 */ lw $s1,0x28($sp) - /* f0e1f9c: 8fb00024 */ lw $s0,0x24($sp) +/* f0e1f7c: 37394510 */ ori $t9,$t9,0x4510 +/* f0e1f80: 37182405 */ ori $t8,$t8,0x2405 +/* f0e1f84: 25cf0008 */ addiu $t7,$t6,0x8 +/* f0e1f88: afaf0060 */ sw $t7,0x60($sp) +/* f0e1f8c: add90004 */ sw $t9,0x4($t6) +/* f0e1f90: add80000 */ sw $t8,0x0($t6) +/* f0e1f94: 8fbf002c */ lw $ra,0x2c($sp) +/* f0e1f98: 8fb10028 */ lw $s1,0x28($sp) +/* f0e1f9c: 8fb00024 */ lw $s0,0x24($sp) /* f0e1fa0: 8fa20060 */ lw $v0,0x60($sp) - /* f0e1fa4: 03e00008 */ jr $ra - /* f0e1fa8: 27bd0060 */ addiu $sp,$sp,0x60 - ); +/* f0e1fa4: 03e00008 */ jr $ra +/* f0e1fa8: 27bd0060 */ addiu $sp,$sp,0x60 +); #else // Mismatch: Goal has the if statement with empty contents Gfx *menugfxRenderGradient(Gfx *gdl, s32 x1, s32 y1, s32 x2, s32 y2, u32 colourstart, u32 colourmid, u32 colourend) @@ -1165,9 +1165,9 @@ Gfx *menugfx0f0e2498(Gfx *gdl) gDPSetCycleType(gdl++, G_CYC_1CYCLE); gDPSetAlphaCompare(gdl++, G_AC_NONE); gDPSetCombineMode(gdl++, G_CC_MODULATEI, G_CC_MODULATEI); - gSPClearGeometryMode(gdl++, G_CULL_BOTH) + gSPClearGeometryMode(gdl++, G_CULL_BOTH); - texSelect(&gdl, 0, 2, 0, 2, 1, NULL); + texSelect(&gdl, 0, 2, 0, 2, 1, NULL); gDPSetRenderMode(gdl++, G_RM_XLU_SURF, G_RM_XLU_SURF2); diff --git a/src/game/menuitem.c b/src/game/menuitem.c index c38fa9820..a9a173269 100644 --- a/src/game/menuitem.c +++ b/src/game/menuitem.c @@ -19,6 +19,7 @@ #include "bss.h" #include "lib/vi.h" #include "lib/main.h" +#include "lib/str.h" #include "data.h" #include "types.h" @@ -1191,12 +1192,12 @@ Gfx *menuitemKeyboardRender(Gfx *gdl, struct menurendercontext *context) } if (context->dialog->dimmed) { - textcolour = colourBlend(textcolour, 0x00000000, 127) & 0xffffff00 | textcolour & 0xff; + textcolour = (colourBlend(textcolour, 0x00000000, 127) & 0xffffff00) | (textcolour & 0xff); } if (data->capseffective && col == 2 && row == 4) { // CAPS button - make it yellow - textcolour = textcolour & 0xff | 0xffff0000; + textcolour = (textcolour & 0xff) | 0xffff0000; } // If this button is the focused one, set highlighted colour @@ -1267,7 +1268,7 @@ Gfx *menuitemKeyboardRender(Gfx *gdl, struct menurendercontext *context) } if (context->dialog->dimmed) { - textcolour = colourBlend(textcolour, 0, 127) & 0xffffff00 | textcolour & 0xff; + textcolour = (colourBlend(textcolour, 0, 127) & 0xffffff00) | (textcolour & 0xff); } textSetWaveColours( @@ -2756,7 +2757,7 @@ Gfx *menuitemSelectableRender(Gfx *gdl, struct menurendercontext *context) } if (context->dialog->dimmed) { - leftcolour = colourBlend(leftcolour, 0, 127) & 0xffffff00 | leftcolour & 0xff; + leftcolour = (colourBlend(leftcolour, 0, 127) & 0xffffff00) | (leftcolour & 0xff); } rightcolour = leftcolour; @@ -2799,7 +2800,7 @@ Gfx *menuitemSelectableRender(Gfx *gdl, struct menurendercontext *context) } if (context->dialog->dimmed) { - leftcolour = colourBlend(leftcolour, 0x00000000, 127) & 0xffffff00 | leftcolour & 0xff; + leftcolour = (colourBlend(leftcolour, 0x00000000, 127) & 0xffffff00) | (leftcolour & 0xff); } rightcolour = leftcolour; @@ -3251,7 +3252,7 @@ Gfx *menuitemCheckboxRender(Gfx *gdl, struct menurendercontext *context) } if (context->dialog->dimmed) { - maincolour = colourBlend(maincolour, 0, 127) & 0xffffff00 | maincolour & 0xff; + maincolour = (colourBlend(maincolour, 0, 127) & 0xffffff00) | (maincolour & 0xff); } textSetWaveColours( @@ -3268,7 +3269,7 @@ Gfx *menuitemCheckboxRender(Gfx *gdl, struct menurendercontext *context) } if (context->dialog->dimmed) { - maincolour = colourBlend(maincolour, 0, 127) & 0xffffff00 | maincolour & 0xff; + maincolour = (colourBlend(maincolour, 0, 127) & 0xffffff00) | (maincolour & 0xff); } textSetWaveColours( @@ -3312,7 +3313,7 @@ Gfx *menuitemCheckboxRender(Gfx *gdl, struct menurendercontext *context) } if (context->dialog->dimmed) { - maincolour = colourBlend(maincolour, 0, 127) & 0xffffff00 | maincolour & 0xff; + maincolour = (colourBlend(maincolour, 0, 127) & 0xffffff00) | (maincolour & 0xff); } textSetWaveColours( @@ -3473,7 +3474,7 @@ Gfx *menuitemScrollableRender(Gfx *gdl, struct menurendercontext *context) } if (context->dialog->dimmed) { - colour = colourBlend(colour, 0, 0x7f) & 0xffffff00 | colour & 0xff; + colour = (colourBlend(colour, 0, 0x7f) & 0xffffff00) | (colour & 0xff); } textSetWaveColours( @@ -4007,7 +4008,7 @@ Gfx *menuitemMarqueeRender(Gfx *gdl, struct menurendercontext *context) } if (context->dialog->dimmed) { - colour = colourBlend(colour, 0, 127) & 0xffffff00 | colour & 0xff; + colour = (colourBlend(colour, 0, 127) & 0xffffff00) | (colour & 0xff); } x = context->x + context->width - data->totalmoved; @@ -4231,7 +4232,7 @@ Gfx *menuitemRankingRender(Gfx *gdl, struct menurendercontext *context) } if (context->dialog->dimmed) { - textcolour = colourBlend(textcolour, 0, 127) & 0xffffff00 | textcolour & 0xff; + textcolour = (colourBlend(textcolour, 0, 127) & 0xffffff00) | (textcolour & 0xff); } if (!team) { @@ -4263,7 +4264,7 @@ Gfx *menuitemRankingRender(Gfx *gdl, struct menurendercontext *context) } if (dialog->dimmed) { - linecolour1 = colourBlend(linecolour1, 0, 44) & 0xffffff00 | linecolour1 & 0xff; + linecolour1 = (colourBlend(linecolour1, 0, 44) & 0xffffff00) | (linecolour1 & 0xff); } if (dialog->transitionfrac < 0) { @@ -4276,11 +4277,11 @@ Gfx *menuitemRankingRender(Gfx *gdl, struct menurendercontext *context) } if (dialog->dimmed) { - linecolour2 = colourBlend(linecolour2, 0, 44) & 0xffffff00 | linecolour2 & 0xff; + linecolour2 = (colourBlend(linecolour2, 0, 44) & 0xffffff00) | (linecolour2 & 0xff); } - linecolour1 = textApplyProjectionColour(context->x, context->y + 2, -129) & 0xff | linecolour1 & 0xffffff00; - linecolour2 = textApplyProjectionColour(context->x + context->width, context->y + 2, -129) & 0xff | linecolour2 & 0xffffff00; + linecolour1 = (textApplyProjectionColour(context->x, context->y + 2, -129) & 0xff) | (linecolour1 & 0xffffff00); + linecolour2 = (textApplyProjectionColour(context->x + context->width, context->y + 2, -129) & 0xff) | (linecolour2 & 0xffffff00); // Horizontal line between header and body #if VERSION == VERSION_JPN_FINAL @@ -4501,7 +4502,7 @@ Gfx *menuitemPlayerStatsRender(Gfx *gdl, struct menurendercontext *context) } if (context->dialog->dimmed) { - maincolour = colourBlend(maincolour, 0x00000000, 127) & 0xffffff00 | maincolour & 0xff; + maincolour = (colourBlend(maincolour, 0x00000000, 127) & 0xffffff00) | (maincolour & 0xff); } textMeasure(&textheight, &textwidth, langGet(L_MPMENU_281), g_CharsHandelGothicXs, g_FontHandelGothicXs, 0); @@ -4553,7 +4554,7 @@ Gfx *menuitemPlayerStatsRender(Gfx *gdl, struct menurendercontext *context) } if (context->dialog->dimmed) { - maincolour = colourBlend(maincolour, 0, 127) & 0xffffff00 | maincolour & 0xff; + maincolour = (colourBlend(maincolour, 0, 127) & 0xffffff00) | (maincolour & 0xff); } // "Deaths" heading @@ -4736,7 +4737,7 @@ bool menuitemPlayerStatsTick(struct menuitem *item, struct menudialog *dialog, s } } - menuitemDropdownTick(item, dialog, inputs, tickflags, data); + return menuitemDropdownTick(item, dialog, inputs, tickflags, data); } Gfx *menuitemPlayerStatsOverlay(Gfx *gdl, s16 x, s16 y, s16 x2, s16 y2, struct menuitem *item, struct menudialog *dialog, union menuitemdata *data) @@ -5406,7 +5407,7 @@ Gfx *menuitemControllerRender(Gfx *gdl, struct menurendercontext *context) } if (dialog->dimmed) { - colour = colourBlend(colour, 0, 44) & 0xffffff00 | colour & 0xff; + colour = (colourBlend(colour, 0, 44) & 0xffffff00) | (colour & 0xff); } textSetWaveColours( diff --git a/src/game/menutick.c b/src/game/menutick.c index 59916d5e4..3ad6ba401 100644 --- a/src/game/menutick.c +++ b/src/game/menutick.c @@ -1,5 +1,6 @@ #include #include "constants.h" +#include "game/bossfile.h" #include "game/game_006900.h" #include "game/title.h" #include "game/pdmode.h" diff --git a/src/game/modeldef.c b/src/game/modeldef.c index a4f244b3c..565c03f72 100644 --- a/src/game/modeldef.c +++ b/src/game/modeldef.c @@ -20,6 +20,7 @@ #include "bss.h" #include "lib/vi.h" #include "lib/main.h" +#include "lib/model.h" #include "data.h" #include "types.h" @@ -105,7 +106,7 @@ struct skeleton *g_Skeletons[] = { &g_SkelBB, }; -void modeldef0f1a7560(struct modelfiledata *modeldef, u16 filenum, u32 arg2, u32 arg3, struct texpool *arg4, bool arg5) +void modeldef0f1a7560(struct modelfiledata *modeldef, u16 filenum, u32 arg2, struct modelfiledata *modeldef2, struct texpool *texpool, bool arg5) { s32 allocsize; s32 loadedsize; @@ -131,13 +132,13 @@ void modeldef0f1a7560(struct modelfiledata *modeldef, u16 filenum, u32 arg2, u32 sp84 = (s32)v1 + (s32)((s32)modeldef - ((u32)modeldef + (gdl & 0xffffff))); texCopyGdls((Gfx *)((u32)modeldef + (gdl & 0xffffff)), (Gfx *)(v1 + (u32)modeldef), loadedsize - (s32)(((u32)modeldef + (gdl & 0xffffff)) - (u32)modeldef)); - texLoadFromConfigs(modeldef->texconfigs, modeldef->numtexconfigs, arg4, arg3 - arg2); + texLoadFromConfigs(modeldef->texconfigs, modeldef->numtexconfigs, texpool, (u32)modeldef2 - arg2); while (node) { prevnode = node; s0 = gdl; - modelIterateDisplayLists(modeldef, &node, &gdl); + modelIterateDisplayLists(modeldef, &node, (Gfx **) &gdl); if (gdl) { s4 = gdl - s0; @@ -145,7 +146,7 @@ void modeldef0f1a7560(struct modelfiledata *modeldef, u16 filenum, u32 arg2, u32 s4 = loadedsize + (u32)modeldef - (u32)modeldef - (s0 & 0xffffff); } - modelNodeReplaceGdl(modeldef, prevnode, s0, s5); + modelNodeReplaceGdl(modeldef, prevnode, (Gfx *) s0, (Gfx *) s5); if (prevnode->type == MODELNODETYPE_DL) { struct modelrodata_dl *rodata = &prevnode->rodata->dl; @@ -154,7 +155,7 @@ void modeldef0f1a7560(struct modelfiledata *modeldef, u16 filenum, u32 arg2, u32 vertices = NULL; } - s5 += texLoadFromGdl((Gfx *)((u32)modeldef + (s0 & 0xffffff) + sp84), s4, (Gfx *)((u32)modeldef + (s5 & 0xffffff)), arg4, (u8 *) vertices); + s5 += texLoadFromGdl((Gfx *)((u32)modeldef + (s0 & 0xffffff) + sp84), s4, (Gfx *)((u32)modeldef + (s5 & 0xffffff)), texpool, (u8 *) vertices); } fileSetSize(filenum, modeldef, (((u32)modeldef + (s5 & 0xffffff)) - (u32)modeldef + 0xf) & ~0xf, arg5); @@ -189,7 +190,7 @@ struct modelfiledata *modeldefLoad(u16 fileid, u8 *dst, s32 size, struct texpool modelPromoteTypeToPointer(filedata); modelPromoteOffsetsToPointers(filedata, 0x5000000, (u32) filedata); - modeldef0f1a7560(filedata, fileid, 0x5000000, (u32)filedata, arg3, dst == NULL); + modeldef0f1a7560(filedata, fileid, 0x5000000, filedata, arg3, dst == NULL); return filedata; } diff --git a/src/game/mplayer/mplayer.c b/src/game/mplayer/mplayer.c index b9fc8fd1b..803b088a7 100644 --- a/src/game/mplayer/mplayer.c +++ b/src/game/mplayer/mplayer.c @@ -24,6 +24,7 @@ #include "lib/vi.h" #include "lib/main.h" #include "lib/rng.h" +#include "lib/str.h" #include "lib/lib_317f0.h" #include "data.h" #include "types.h" @@ -666,7 +667,7 @@ s32 mpGetPlayerRankings(struct ranking *rankings) scenarioCalculatePlayerScore(mpchr, i, &score, &deaths); - rankablescore = (score + 0x8000) << 16 | 0xffff - deaths; + rankablescore = (score + 0x8000) << 16 | (0xffff - deaths); dstindex = 0; found = false; @@ -693,7 +694,7 @@ s32 mpGetPlayerRankings(struct ranking *rankings) count++; // Write the new figures - rankablescores[dstindex] = (score + 0x8000) << 16 | 0xffff - deaths; + rankablescores[dstindex] = (score + 0x8000) << 16 | (0xffff - deaths); scores[dstindex] = score; mpchrs[dstindex] = mpchr; chrnums[dstindex] = i; @@ -794,7 +795,7 @@ s32 mpCalculateTeamScore(s32 teamnum, s32 *result) if (teamexists) { *result = teamscore; - return (teamscore + 0x8000) << 16 | 0xffff - teamdeaths; + return (teamscore + 0x8000) << 16 | (0xffff - teamdeaths); } return 0; @@ -2196,8 +2197,12 @@ void mpCalculateAwards(void) // @bug: playerrankings should have 12 elements. Because it's too small, // overflow occurs in mpGetPlayerRankings. The overflow writes into the // metrics array (above) which is yet to be initialised, so this bug has - // no effect. + // no effect on IDO. +#ifdef AVOID_UB + struct ranking playerrankings[MAX_MPCHRS]; +#else struct ranking playerrankings[1]; +#endif s32 numchrs; s32 numteams; diff --git a/src/game/mplayer/scenarios.c b/src/game/mplayer/scenarios.c index 90b117bc4..619c8904c 100644 --- a/src/game/mplayer/scenarios.c +++ b/src/game/mplayer/scenarios.c @@ -19,6 +19,7 @@ #include "game/mplayer/scenarios.h" #include "game/radar.h" #include "game/botcmd.h" +#include "game/botinv.h" #include "game/challenge.h" #include "game/lang.h" #include "game/mplayer/mplayer.h" diff --git a/src/game/mplayer/setup.c b/src/game/mplayer/setup.c index 18f85d137..be23492fb 100644 --- a/src/game/mplayer/setup.c +++ b/src/game/mplayer/setup.c @@ -19,7 +19,9 @@ #include "lib/snd.h" #include "lib/vi.h" #include "lib/rng.h" +#include "lib/str.h" #include "data.h" +#include "gbiex.h" #include "types.h" struct menuitem g_MpCharacterMenuItems[]; @@ -971,7 +973,7 @@ s32 mpMedalMenuHandler(s32 operation, struct menuitem *item, union handlerdata * } #if VERSION >= VERSION_NTSC_1_0 - colour = colour & 0xffffff00 | (colour & 0xff) * (renderdata->colour & 0xff) >> 8; + colour = (colour & 0xffffff00) | (colour & 0xff) * (renderdata->colour & 0xff) >> 8; #endif gDPSetEnvColorViaWord(gdl++, colour); diff --git a/src/game/mpstats.c b/src/game/mpstats.c index 1fb70e0a1..dfc66318a 100644 --- a/src/game/mpstats.c +++ b/src/game/mpstats.c @@ -9,6 +9,7 @@ #include "game/playermgr.h" #include "game/mplayer/setup.h" #include "game/botcmd.h" +#include "game/botinv.h" #include "game/lang.h" #include "game/mplayer/mplayer.h" #include "game/options.h" diff --git a/src/game/nbomb.c b/src/game/nbomb.c index eaf012da1..448d0c41c 100644 --- a/src/game/nbomb.c +++ b/src/game/nbomb.c @@ -323,7 +323,7 @@ Gfx *nbombCreateGdl(void) gdl = gdlstart = gfxAllocate(gdlsizes[index]); - texSelect(&gdl, &g_TexGeneralConfigs[0x0a], 2, 1, 2, 1, NULL); + texSelect(&gdl, &g_TexGeneralConfigs[10], 2, 1, 2, 1, NULL); gDPPipeSync(gdl++); gDPSetCycleType(gdl++, G_CYC_1CYCLE); diff --git a/src/game/objectives.c b/src/game/objectives.c index c5621e47f..9c3695d78 100644 --- a/src/game/objectives.c +++ b/src/game/objectives.c @@ -18,6 +18,7 @@ #include "lib/dma.h" #include "lib/memp.h" #include "lib/rng.h" +#include "lib/str.h" #include "lib/mtx.h" #include "data.h" #include "types.h" diff --git a/src/game/pak.c b/src/game/pak.c index f9ed826a0..d17b803c8 100644 --- a/src/game/pak.c +++ b/src/game/pak.c @@ -1,7 +1,9 @@ #include "versions.h" #include #include "constants.h" +#include "game/bossfile.h" #include "game/camdraw.h" +#include "game/filelist.h" #include "game/menu.h" #include "game/crc.h" #include "game/gamefile.h" @@ -14,8 +16,10 @@ #include "lib/main.h" #include "lib/memp.h" #include "lib/rng.h" +#include "lib/str.h" #include "data.h" #include "types.h" +#include "string.h" /** * Perfect Dark supports saving to an in-cartridge EEPROM chip, as well as to @@ -944,7 +948,7 @@ s32 _pakSaveAtGuid(s8 device, s32 fileid, s32 filetype, u8 *newdata, s32 *outfil // Find the file to be "replaced" oldoffset = pakFindFile(device, fileid, &header); - if (oldoffset && (!oldoffset || oldoffset >= pakGetPdNumBytes(device) || (pakGetBlockSize(device) - 1 & oldoffset))) { + if (oldoffset && (!oldoffset || oldoffset >= pakGetPdNumBytes(device) || ((pakGetBlockSize(device) - 1) & oldoffset))) { return 3; } @@ -1703,7 +1707,7 @@ s32 pak0f118b04(s8 device, u32 fileid) } #endif - if (offset == 0 || (offset != 0 && offset < pakGetPdNumBytes(device) && (pakGetBlockSize(device) - 1 & offset) == 0)) { + if (offset == 0 || (offset != 0 && offset < pakGetPdNumBytes(device) && ((pakGetBlockSize(device) - 1) & offset) == 0)) { if (!pakReplaceFileAtOffsetWithBlank(device, offset)) { return 4; } diff --git a/src/game/player.c b/src/game/player.c index 825f43dd0..49d568a04 100644 --- a/src/game/player.c +++ b/src/game/player.c @@ -16,6 +16,7 @@ #include "game/atan2f.h" #include "game/quaternion.h" #include "game/bondgun.h" +#include "game/env.h" #include "game/gunfx.h" #include "game/game_0b0fd0.h" #include "game/game_0b2150.h" @@ -27,6 +28,7 @@ #include "game/hudmsg.h" #include "game/menu.h" #include "game/mainmenu.h" +#include "game/file.h" #include "game/filemgr.h" #include "game/inv.h" #include "game/playermgr.h" @@ -55,6 +57,7 @@ #include "lib/ailist.h" #include "lib/collision.h" #include "lib/joy.h" +#include "lib/lib_17ce0.h" #include "lib/vi.h" #include "lib/main.h" #include "lib/snd.h" @@ -2237,7 +2240,7 @@ Gfx *player0f0baf84(Gfx *gdl) guPerspective(a, &b, g_Vars.currentplayer->zoominfovy, PAL ? 1.7316017150879f : 1.4545454978943f, 10, 300, 1); - gSPMatrix(gdl++, 0x80000000 + (u32)a, G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); + gSPMatrix(gdl++, OS_PHYSICAL_TO_K0(a), G_MTX_NOPUSH | G_MTX_LOAD | G_MTX_PROJECTION); gSPPerspNormalize(gdl++, b); } @@ -3753,7 +3756,7 @@ void playerTick(bool arg0) if (rocket->base.hidden & OBJHFLAG_PROJECTILE) { struct projectile *projectile = rocket->base.projectile; u32 mode = optionsGetControlMode(g_Vars.currentplayerstats->mpindex); - f32 fVar22; + f32 targetspeed; s8 contpad1 = optionsGetContpadNum1(g_Vars.currentplayerstats->mpindex); s8 contpad2 = optionsGetContpadNum2(g_Vars.currentplayerstats->mpindex); s8 stickx = 0; @@ -3761,14 +3764,18 @@ void playerTick(bool arg0) Mtxf sp1fc; Mtxf sp1bc; Mtxf sp17c; - f32 targetspeed; + f32 sp178; f32 sp174; f32 sp15c[6]; f32 sp14c[4]; f32 sp13c[4]; f32 sp12c[4]; f32 prevspeed; +#ifdef AVOID_UB + f32 sp11c[4]; +#else f32 sp11c[3]; +#endif bool explode = false; bool slow = false; bool pause = false; @@ -3853,7 +3860,7 @@ void playerTick(bool arg0) sp2ac.x = sp2b8[0][0]; sp2ac.z = sp2b8[0][2]; - fVar22 = sticky * LVUPDATE240FREAL() * 0.00025f; + sp178 = sticky * LVUPDATE240FREAL() * 0.00025f; sp174 = -stickx * LVUPDATE240FREAL() * 0.00025f; f20 = sqrtf(sp2ac.f[0] * sp2ac.f[0] + sp2ac.f[2] * sp2ac.f[2]); @@ -3861,9 +3868,9 @@ void playerTick(bool arg0) sp2ac.x /= f20; sp2ac.z /= f20; - f20 = sinf(fVar22); + f20 = sinf(sp178); - sp14c[0] = cosf(fVar22); + sp14c[0] = cosf(sp178); sp14c[1] = sp2ac.f[0] * f20; sp14c[2] = 0; sp14c[3] = sp2ac.f[2] * f20; diff --git a/src/game/prop.c b/src/game/prop.c index 94a22ebed..35f69649b 100644 --- a/src/game/prop.c +++ b/src/game/prop.c @@ -28,6 +28,8 @@ #include "game/wallhit.h" #include "game/mpstats.h" #include "bss.h" +#include "lib/collision.h" +#include "lib/lib_17ce0.h" #include "lib/model.h" #include "lib/snd.h" #include "lib/rng.h" @@ -588,12 +590,11 @@ struct prop *shotCalculateHits(s32 handnum, bool arg1, struct coord *arg2, struc bool done; s32 sparktype; - // This is probably supposed to have a length of 131 because the game can - // write that far into the array, but changing it causes a mismatch due to - // too much stack allocation. - // @dangerous: You'll want to change this to 131 if compiling using a - // non-matching compiler. +#ifdef AVOID_UB + s16 rooms[131]; +#else s16 rooms[124]; +#endif s16 spc8[8]; s16 spb8[8]; @@ -990,7 +991,7 @@ struct prop *func0f061d54(s32 handnum, u32 arg1, u32 arg2) mtx4TransformVec(camGetProjectionMtxF(), &sp58, &sp40); mtx4RotateVec(camGetProjectionMtxF(), &sp64, &sp4c); - shotCalculateHits(handnum, arg1, &sp58, &sp64, &sp40, &sp4c, 0, 4294836224, PLAYERCOUNT() >= 2); + return shotCalculateHits(handnum, arg1, &sp58, &sp64, &sp40, &sp4c, 0, 4294836224, PLAYERCOUNT() >= 2); } void shotCreate(s32 handnum, bool arg1, bool dorandom, s32 arg3, bool arg4) @@ -2504,7 +2505,7 @@ void farsightChooseTarget(void) struct prop *prop = g_ChrSlots[i].prop; if (prop && prop->chr) { - if (prop->type == PROPTYPE_CHR && (prop->flags & PROPFLAG_ENABLED) + if ((prop->type == PROPTYPE_CHR && (prop->flags & PROPFLAG_ENABLED)) || (prop->type == PROPTYPE_PLAYER && playermgrGetPlayerNumByProp(prop) != g_Vars.currentplayernum)) { struct chrdata *chr = prop->chr; diff --git a/src/game/propobj.c b/src/game/propobj.c index 40738fd68..cc3eb49d2 100644 --- a/src/game/propobj.c +++ b/src/game/propobj.c @@ -66,14 +66,17 @@ #include "lib/str.h" #include "lib/memp.h" #include "lib/model.h" +#include "lib/path.h" #include "lib/rng.h" #include "lib/mtx.h" #include "lib/anim.h" #include "lib/collision.h" +#include "lib/lib_17ce0.h" #include "lib/lib_317f0.h" #include "data.h" #include "textures.h" #include "types.h" +#include "string.h" struct weaponobj *g_Proxies[30]; f32 g_GasReleaseTimerMax240; @@ -1719,7 +1722,7 @@ void colourTween(u8 *col, u8 *nextcol) } } -void func0f069750(s32 *arg0, s32 arg1, f32 *arg2) +void func0f069750(s32 *arg0, s32 arg1, f32 arg2[4]) { if (arg1 == 1) { f32 tmp; @@ -2490,7 +2493,7 @@ void objFree(struct defaultobj *obj, bool freeprop, bool canregen) // flag. If the propnum was 0, all chrs would be assigned to // this one chair, and their original chairs would still have // the occupied flag. - if (g_ChrSlots[i].proppreset1 = obj->prop - g_Vars.props) { + if ((g_ChrSlots[i].proppreset1 = obj->prop - g_Vars.props)) { g_ChrSlots[i].proppreset1 = -1; } } @@ -3229,11 +3232,9 @@ s32 func0f06cd00(struct defaultobj *obj, struct coord *pos, struct coord *arg2, bool s0; s16 spcc[120]; s16 *ptr; + s16 spb8[8]; s32 i; f32 scale = 1.0f; - u32 stack2; - s32 spb8; - u32 stack3[2]; cdresult = CDRESULT_NOCOLLISION; @@ -3251,7 +3252,7 @@ s32 func0f06cd00(struct defaultobj *obj, struct coord *pos, struct coord *arg2, if ((prop->pos.x != pos->x || prop->pos.y != pos->y || prop->pos.z != pos->z) && (obj->hidden & OBJHFLAG_PROJECTILE) && (obj->projectile->flags & PROJECTILEFLAG_STICKY)) { - portal00018148(&prop->pos, &sp1c4, prop->rooms, &spb8, &spcc, 20); + portal00018148(&prop->pos, &sp1c4, prop->rooms, spb8, spcc, 20); ptr = spcc; @@ -6315,12 +6316,9 @@ s32 func0f072144(struct defaultobj *obj, struct coord *arg1, f32 arg2, bool arg3 s16 rooms[8]; struct hov prevhov; struct hov *hov = NULL; - struct hoverbikeobj *hoverbike; - struct hoverpropobj *hoverprop; - u8 stack[0x2f0]; - struct geocyl cyl; + union geounion geounion; struct prop *prop = obj->prop; - u32 stack2; + struct hoverbikeobj *hoverbike; Mtxf spa4; Mtxf sp64; f32 sp40[3][3]; @@ -6373,11 +6371,10 @@ s32 func0f072144(struct defaultobj *obj, struct coord *arg1, f32 arg2, bool arg3 setup0f09233c(obj, &pos, sp460, rooms); if (obj->type == OBJTYPE_HOVERBIKE) { - hoverbike = (struct hoverbikeobj *)obj; + hoverbike = (struct hoverbikeobj *) obj; hov = &hoverbike->hov; } else if (obj->type == OBJTYPE_HOVERPROP) { - hoverprop = (struct hoverpropobj *)obj; - hov = &hoverprop->hov; + hov = &((struct hoverpropobj *) obj)->hov; } if (hov != NULL) { @@ -6401,12 +6398,13 @@ s32 func0f072144(struct defaultobj *obj, struct coord *arg1, f32 arg2, bool arg3 } if (cdresult == CDRESULT_NOCOLLISION) { - func0f069850(obj, &pos, sp460, &cyl); + func0f069850(obj, &pos, sp460, &geounion.cyl); if (obj->flags3 & OBJFLAG3_GEOCYL) { - cdresult = cdExamCylMove01(&prop->pos, &pos, cyl.radius, rooms, CDTYPE_ALL, CHECKVERTICAL_YES, cyl.ymax - pos.y, cyl.ymin - pos.y); + cdresult = cdExamCylMove01(&prop->pos, &pos, geounion.cyl.radius, rooms, CDTYPE_ALL, + CHECKVERTICAL_YES, geounion.cyl.ymax - pos.y, geounion.cyl.ymin - pos.y); } else { - cdresult = cd0002f02c((struct geoblock *)&cyl, rooms, CDTYPE_ALL); + cdresult = cd0002f02c(&geounion.block, rooms, CDTYPE_ALL); } } @@ -6424,9 +6422,9 @@ s32 func0f072144(struct defaultobj *obj, struct coord *arg1, f32 arg2, bool arg3 if (obj->geocyl && (obj->hidden2 & OBJH2FLAG_08)) { if (obj->flags3 & OBJFLAG3_GEOCYL) { - *obj->geocyl = cyl; + *obj->geocyl = geounion.cyl; } else { - *obj->geoblock = *(struct geoblock *)&cyl; + *obj->geoblock = geounion.block; } } } else if (hov) { @@ -15600,12 +15598,9 @@ Gfx *objRenderShadow(struct defaultobj *obj, Gfx *gdl) Gfx *objRender(struct prop *prop, Gfx *gdl, bool xlupass) { - u32 stack; - u32 stack2; - struct defaultobj *obj = prop->obj; - f32 spe8; + f32 spe8[4]; s32 spe4; - s32 i; + struct defaultobj *obj = prop->obj; struct modelrenderdata renderdata = {NULL, true, 3}; struct screenbox screenbox; s32 colour[4]; @@ -15624,8 +15619,9 @@ Gfx *objRender(struct prop *prop, Gfx *gdl, bool xlupass) struct colour *oldcolours; struct colour *newcolours; f32 objdist; + s32 i; - spe4 = env0f1667f4(prop, &spe8); + spe4 = env0f1667f4(prop, spe8); if (spe4 == 0) { return gdl; @@ -15708,9 +15704,9 @@ Gfx *objRender(struct prop *prop, Gfx *gdl, bool xlupass) if (door->doortype == DOORTYPE_LASER) { node = func0f0687e4(obj->model); dldata1 = &node->rodata->dl; - dldata2 = (struct modelrwdata_dl *)modelGetNodeRwData(obj->model, node); - oldcolours = (struct colour *)(((u32)&dldata1->vertices[dldata1->numvertices] + 7 | 7) ^ 7); - newcolours = (struct colour *)gfxAllocateColours(dldata1->numcolours); + dldata2 = (struct modelrwdata_dl *) modelGetNodeRwData(obj->model, node); + oldcolours = (struct colour *) ((((u32) &dldata1->vertices[dldata1->numvertices] + 7) | 7) ^ 7); + newcolours = (struct colour *) gfxAllocateColours(dldata1->numcolours); for (i = 0; i < dldata1->numcolours; i++) { newcolours[i] = oldcolours[i]; @@ -15809,7 +15805,7 @@ Gfx *objRender(struct prop *prop, Gfx *gdl, bool xlupass) colour[3] = 0xff; } - func0f069750(colour, spe4, &spe8); + func0f069750(colour, spe4, spe8); if (USINGDEVICE(DEVICE_NIGHTVISION)) { if ((obj->flags & OBJFLAG_PATHBLOCKER) == 0) { diff --git a/src/game/raceinit.c b/src/game/raceinit.c index 6e5be2fe5..7222370b2 100644 --- a/src/game/raceinit.c +++ b/src/game/raceinit.c @@ -2,6 +2,7 @@ #include "constants.h" #include "game/race.h" #include "game/chr.h" +#include "lib/model.h" #include "bss.h" #include "data.h" #include "types.h" diff --git a/src/game/radar.c b/src/game/radar.c index 287bd12a4..3d6fa819d 100644 --- a/src/game/radar.c +++ b/src/game/radar.c @@ -14,6 +14,7 @@ #include "lib/vi.h" #include "lib/mtx.h" #include "data.h" +#include "gbiex.h" #include "types.h" u32 g_RadarX; @@ -129,7 +130,7 @@ Gfx *radarDrawDot(Gfx *gdl, struct prop *prop, struct coord *dist, u32 colour1, osSyncPrintf("RadarDrawDot : Prop=%x", prop); spcc = (atan2f(dist->x, dist->z) * 180.0f) / M_PI + g_Vars.currentplayer->vv_theta + 180.0f; - sqdist = sqrtf(dist->z * dist->z + dist->x * dist->x) * 0.004f; + sqdist = sqrtf(dist->z * dist->z + dist->x * dist->x) * (1.0f / 250.0f); if (sqdist < 16.0f) { shiftamount = 0; diff --git a/src/game/savebuffer.c b/src/game/savebuffer.c index 18705c2ef..3e8877c04 100644 --- a/src/game/savebuffer.c +++ b/src/game/savebuffer.c @@ -380,7 +380,7 @@ Gfx *menugfxDrawPlane(Gfx *gdl, s32 x1, s32 y1, s32 x2, s32 y2, u32 colour1, u32 */ void savebufferOr(struct savebuffer *buffer, u32 value, s32 numbits) { - u32 bit = 1 << (numbits + 31); + u32 bit = 1 << (numbits - 1); for (; bit; bit >>= 1) { if (bit & value) { @@ -403,7 +403,7 @@ void savebufferOr(struct savebuffer *buffer, u32 value, s32 numbits) */ void savebufferWriteBits(struct savebuffer *buffer, u32 value, s32 numbits, u8 *dst) { - u32 bit = 1 << (numbits + 31); + u32 bit = 1 << (numbits - 1); for (; bit; bit >>= 1) { s32 bitindex = buffer->bitpos % 8; @@ -429,7 +429,7 @@ void savebufferWriteBits(struct savebuffer *buffer, u32 value, s32 numbits, u8 * */ u32 savebufferReadBits(struct savebuffer *buffer, s32 numbits) { - u32 bit = 1 << (numbits + 31); + u32 bit = 1 << (numbits - 1); u32 value = 0; for (; bit; bit >>= 1) { diff --git a/src/game/setup.c b/src/game/setup.c index ae1bf9df7..415ae1150 100644 --- a/src/game/setup.c +++ b/src/game/setup.c @@ -7,6 +7,7 @@ #include "game/playerreset.h" #include "game/botmgr.h" #include "game/chr.h" +#include "game/chrmgr.h" #include "game/body.h" #include "game/prop.h" #include "game/setuputils.h" @@ -24,8 +25,10 @@ #include "game/pad.h" #include "game/propobj.h" #include "bss.h" +#include "lib/args.h" #include "lib/memp.h" #include "lib/model.h" +#include "lib/path.h" #include "lib/rng.h" #include "lib/mtx.h" #include "lib/ailist.h" @@ -781,7 +784,7 @@ void setupCreateMine(struct mineobj *mine, s32 cmdindex) setupCreateObject(&mine->base, cmdindex); if (g_Vars.coopplayernum >= 0 || g_Vars.antiplayernum >= 0) { - mine->base.hidden = mine->base.hidden & 0x0fffffff | OBJHFLAG_20000000; + mine->base.hidden = (mine->base.hidden & 0x0fffffff) | OBJHFLAG_20000000; } mine->base.prop->forcetick = true; diff --git a/src/game/setupcover.c b/src/game/setupcover.c index 51d85660f..d03a0cb44 100644 --- a/src/game/setupcover.c +++ b/src/game/setupcover.c @@ -3,6 +3,7 @@ #include "game/bg.h" #include "game/pad.h" #include "bss.h" +#include "lib/collision.h" #include "lib/memp.h" #include "lib/anim.h" #include "data.h" diff --git a/src/game/setuppads.c b/src/game/setuppads.c index 621fa4324..693f3a430 100644 --- a/src/game/setuppads.c +++ b/src/game/setuppads.c @@ -3,7 +3,9 @@ #include "game/bondhead.h" #include "game/bg.h" #include "game/pad.h" +#include "game/setup.h" #include "bss.h" +#include "lib/collision.h" #include "lib/mtx.h" #include "lib/anim.h" #include "lib/model.h" diff --git a/src/game/setuputils.c b/src/game/setuputils.c index f24b269d6..7be7c6838 100644 --- a/src/game/setuputils.c +++ b/src/game/setuputils.c @@ -6,6 +6,7 @@ #include "game/bg.h" #include "game/modeldef.h" #include "game/propobj.h" +#include "lib/model.h" #include "bss.h" #include "data.h" #include "types.h" diff --git a/src/game/shardsreset.c b/src/game/shardsreset.c index 8b4441531..bd90c8b63 100644 --- a/src/game/shardsreset.c +++ b/src/game/shardsreset.c @@ -22,7 +22,7 @@ void shardsReset(void) if (g_MaxShards == 0) { g_Shards = NULL; } else { - g_Shards = mempAlloc(g_MaxShards * sizeof(struct shard) + 0xf & ~0xf, MEMPOOL_STAGE); + g_Shards = mempAlloc((g_MaxShards * sizeof(struct shard) + 0xf) & ~0xf, MEMPOOL_STAGE); for (i = 0; i < g_MaxShards; i++) { g_Shards[i].age60 = 0; diff --git a/src/game/sky.c b/src/game/sky.c index 0e4e49798..ade24528e 100644 --- a/src/game/sky.c +++ b/src/game/sky.c @@ -7,6 +7,7 @@ #include "game/game_152fa0.h" #include "game/env.h" #include "game/pad.h" +#include "game/tex.h" #include "bss.h" #include "lib/vi.h" #include "lib/mtx.h" diff --git a/src/game/splat.c b/src/game/splat.c index 5af843c28..65ff6ce13 100644 --- a/src/game/splat.c +++ b/src/game/splat.c @@ -7,6 +7,7 @@ #include "game/utils.h" #include "game/wallhit.h" #include "bss.h" +#include "lib/lib_17ce0.h" #include "lib/model.h" #include "lib/rng.h" #include "lib/mtx.h" @@ -273,8 +274,8 @@ bool splat0f149274(f32 arg0, struct prop *chrprop, struct shotdata *shotdata, f3 endpos.f[i] = stackshotdata.gunpos.f[i] + stackshotdata.dir.f[i] * g_SplatMaxDistance; } - portal00018148(&chrprop->pos, &stackshotdata.gunpos, chrprop->rooms, &gunrooms, NULL, 0); - portal00018148(&stackshotdata.gunpos, &endpos, &gunrooms, &endrooms, rooms, ARRAYCOUNT(rooms) - 1); + portal00018148(&chrprop->pos, &stackshotdata.gunpos, chrprop->rooms, gunrooms, NULL, 0); + portal00018148(&stackshotdata.gunpos, &endpos, gunrooms, endrooms, rooms, ARRAYCOUNT(rooms) - 1); for (i = 0; rooms[i] != -1; i++) { if (bgTestHitInRoom(&stackshotdata.gunpos, &endpos, rooms[i], &hitthing) diff --git a/src/game/tex.c b/src/game/tex.c index 64b87ce50..ff84a0371 100644 --- a/src/game/tex.c +++ b/src/game/tex.c @@ -5,6 +5,7 @@ #include "game/texdecompress.h" #include "bss.h" #include "data.h" +#include "gbiex.h" #include "textures.h" #include "types.h" diff --git a/src/game/texdecompress.c b/src/game/texdecompress.c index 3df10f7f7..03584439b 100644 --- a/src/game/texdecompress.c +++ b/src/game/texdecompress.c @@ -351,10 +351,10 @@ s32 texGetAverageRed(u16 colour1, u16 colour2, u16 colour3, u16 colour4) { s32 value = 0; - value += ((colour1 >> 11) & 0x1f) << 3 | (colour1 >> 13) & 7; - value += ((colour2 >> 11) & 0x1f) << 3 | (colour2 >> 13) & 7; - value += ((colour3 >> 11) & 0x1f) << 3 | (colour3 >> 13) & 7; - value += ((colour4 >> 11) & 0x1f) << 3 | (colour4 >> 13) & 7; + value += (((colour1 >> 11) & 0x1f) << 3) | ((colour1 >> 13) & 7); + value += (((colour2 >> 11) & 0x1f) << 3) | ((colour2 >> 13) & 7); + value += (((colour3 >> 11) & 0x1f) << 3) | ((colour3 >> 13) & 7); + value += (((colour4 >> 11) & 0x1f) << 3) | ((colour4 >> 13) & 7); value = (value + 2) >> 2; @@ -373,10 +373,10 @@ s32 texGetAverageGreen(u16 colour1, u16 colour2, u16 colour3, u16 colour4) { s32 value = 0; - value += ((colour1 >> 6) & 0x1f) << 3 | (colour1 >> 8) & 7; - value += ((colour2 >> 6) & 0x1f) << 3 | (colour2 >> 8) & 7; - value += ((colour3 >> 6) & 0x1f) << 3 | (colour3 >> 8) & 7; - value += ((colour4 >> 6) & 0x1f) << 3 | (colour4 >> 8) & 7; + value += (((colour1 >> 6) & 0x1f) << 3) | ((colour1 >> 8) & 7); + value += (((colour2 >> 6) & 0x1f) << 3) | ((colour2 >> 8) & 7); + value += (((colour3 >> 6) & 0x1f) << 3) | ((colour3 >> 8) & 7); + value += (((colour4 >> 6) & 0x1f) << 3) | ((colour4 >> 8) & 7); value = (value + 2) >> 2; @@ -395,10 +395,10 @@ s32 texGetAverageBlue(u16 colour1, u16 colour2, u16 colour3, u16 colour4) { s32 value = 0; - value += ((colour1 >> 1) & 0x1f) << 3 | (colour1 >> 3) & 7; - value += ((colour2 >> 1) & 0x1f) << 3 | (colour2 >> 3) & 7; - value += ((colour3 >> 1) & 0x1f) << 3 | (colour3 >> 3) & 7; - value += ((colour4 >> 1) & 0x1f) << 3 | (colour4 >> 3) & 7; + value += (((colour1 >> 1) & 0x1f) << 3) | ((colour1 >> 3) & 7); + value += (((colour2 >> 1) & 0x1f) << 3) | ((colour2 >> 3) & 7); + value += (((colour3 >> 1) & 0x1f) << 3) | ((colour3 >> 3) & 7); + value += (((colour4 >> 1) & 0x1f) << 3) | ((colour4 >> 3) & 7); value = (value + 2) >> 2; diff --git a/src/game/texreset.c b/src/game/texreset.c index 90f920a68..a74e61408 100644 --- a/src/game/texreset.c +++ b/src/game/texreset.c @@ -28,7 +28,7 @@ s32 texReadBits(s32 arg0) var800ab548 -= arg0; - return var800ab544 >> var800ab548 & (1 << arg0) - 1; + return var800ab544 >> var800ab548 & ((1 << arg0) - 1); } extern u8 *g_TextureConfigSegment; @@ -76,7 +76,7 @@ void texReset(void) g_TexWords = mempAlloc(ALIGN16(g_TexNumConfigs * 4), MEMPOOL_STAGE); for (i = 0; i < g_TexNumConfigs; i++) { - g_TexWords[i] = 0; + g_TexWords[i] = NULL; } for (i = 0; i < ARRAYCOUNT(g_TcExplosionTexturePairs); i++) { diff --git a/src/game/texselect.c b/src/game/texselect.c index 4425ffa88..3d5197a6e 100644 --- a/src/game/texselect.c +++ b/src/game/texselect.c @@ -289,7 +289,21 @@ void texSelect(Gfx **gdlptr, struct textureconfig *tconfig, u32 arg2, s32 arg3, if (tconfig->unk0b == 1) { ptr = (u16 *)tconfig->textureptr; texturenum = ((u16 *)PHYS_TO_K0(ptr))[-4]; + + // GCC has problems with this area because it seems to think that + // registers are 64 bits wide. To do the index < g_TexNumConfigs + // comparison, it shifts index left and adds to it repeatedly, + // creating a 64-bit value, then uses a neg before the comparison. + // When a tconfig is passed that is not in the preset configs list, + // the index < g_TexNumConfigs check passes when it shouldn't, + // causing a read from g_TexWords using an invalid index. + // Casting the pointers to integers makes gcc emit different code + // which works around this issue. +#ifdef __sgi index = tconfig - g_TexWallhitConfigs; +#else + index = ((s32) tconfig - (s32) g_TexWallhitConfigs) / sizeof(struct textureconfig); +#endif if (index >= 0 && index < g_TexNumConfigs) { tex = g_TexWords[index]; diff --git a/src/game/title.c b/src/game/title.c index ab52660c9..536f2ad9c 100644 --- a/src/game/title.c +++ b/src/game/title.c @@ -29,6 +29,7 @@ #include "lib/lib_317f0.h" #include "data.h" #include "types.h" +#include "string.h" u8 *var8009cca0; u32 var8009cca4; diff --git a/src/game/titlereset.c b/src/game/titlereset.c index b2d080193..77e57ee9c 100644 --- a/src/game/titlereset.c +++ b/src/game/titlereset.c @@ -1,6 +1,6 @@ #include #include "constants.h" -#include "game/game_00b820.h" +#include "game/getitle.h" #include "game/title.h" #include "bss.h" #include "lib/memp.h" diff --git a/src/game/training.c b/src/game/training.c index c4cf74bc9..b1d576d63 100644 --- a/src/game/training.c +++ b/src/game/training.c @@ -2338,6 +2338,9 @@ u8 g_ChrBioSlot = 0; struct chrbio *ciGetChrBioByBodynum(u32 bodynum) { +#ifdef AVOID_UB + static +#endif struct chrbio bios[] = { // name, race, age, profile #if VERSION >= VERSION_PAL_BETA @@ -2432,6 +2435,9 @@ s32 ciGetChrBioBodynumBySlot(s32 slot) struct miscbio *ciGetMiscBio(s32 index) { +#ifdef AVOID_UB + static +#endif struct miscbio bios[] = { // name, description #if VERSION >= VERSION_PAL_BETA @@ -2521,6 +2527,9 @@ u8 g_HangarBioSlot = 0; struct hangarbio *ciGetHangarBio(s32 index) { +#ifdef AVOID_UB + static +#endif struct hangarbio bios[] = { // name, description #if VERSION >= VERSION_PAL_BETA diff --git a/src/game/trainingmenus.c b/src/game/trainingmenus.c index bc18a02e0..004546567 100644 --- a/src/game/trainingmenus.c +++ b/src/game/trainingmenus.c @@ -191,7 +191,7 @@ s32 frWeaponListMenuHandler(s32 operation, struct menuitem *item, union handlerd } #if VERSION >= VERSION_NTSC_1_0 - colour = colour & 0xffffff00 | ((colour & 0xff) * (renderdata->colour & 0xff)) >> 8; + colour = (colour & 0xffffff00) | (((colour & 0xff) * (renderdata->colour & 0xff)) >> 8); #endif gDPSetEnvColorViaWord(gdl++, colour); @@ -607,9 +607,9 @@ s32 frScoringMenuHandler(s32 operation, struct menuitem *item, union handlerdata static u32 y4 = 0; #if VERSION >= VERSION_NTSC_1_0 - linecolourmid = linecolourmid & 0xffffff00 | (linecolourmid & 0xff) * (renderdata->colour & 0xff) >> 8; - linecolourfig = linecolourfig & 0xffffff00 | (linecolourfig & 0xff) * (renderdata->colour & 0xff) >> 8; - linecolourtex = linecolourtex & 0xffffff00 | (linecolourtex & 0xff) * (renderdata->colour & 0xff) >> 8; + linecolourmid = (linecolourmid & 0xffffff00) | ((linecolourmid & 0xff) * (renderdata->colour & 0xff) >> 8); + linecolourfig = (linecolourfig & 0xffffff00) | ((linecolourfig & 0xff) * (renderdata->colour & 0xff) >> 8); + linecolourtex = (linecolourtex & 0xffffff00) | ((linecolourtex & 0xff) * (renderdata->colour & 0xff) >> 8); #endif mainOverrideVariable("x1", &x1); @@ -635,7 +635,7 @@ s32 frScoringMenuHandler(s32 operation, struct menuitem *item, union handlerdata gDPSetTextureFilter(gdl++, G_TF_POINT); #if VERSION >= VERSION_NTSC_1_0 - colour = (failed ? 0xff777799 : 0x55ff5588) & 0xffffff00 | ((failed ? 0xff777799 : 0x55ff5588) & 0xff) * (renderdata->colour & 0xff) >> 8; + colour = ((failed ? 0xff777799 : 0x55ff5588) & 0xffffff00) | (((failed ? 0xff777799 : 0x55ff5588) & 0xff) * (renderdata->colour & 0xff) >> 8); gDPSetEnvColorViaWord(gdl++, colour); #else gDPSetEnvColorViaWord(gdl++, failed ? 0xff777799 : 0x55ff5588); @@ -670,8 +670,8 @@ s32 frScoringMenuHandler(s32 operation, struct menuitem *item, union handlerdata G_TX_RENDERTILE, 16, 1024, -1024 / g_ScaleX, 1024); #if VERSION >= VERSION_NTSC_1_0 - gdl = textSetPrimColour(gdl, (failed ? 0xff000055 : 0x00ff0055) & 0xffffff00 | ((failed ? 0xff000055 : 0x00ff0055) & 0xff) * (renderdata->colour & 0xff) >> 8); - colour = (failed ? 0xff6969aa : renderdata->colour) & 0xffffff00 | (((failed ? 0xff6969aa : renderdata->colour) & 0xff) * (renderdata->colour & 0xff)) >> 8; + gdl = textSetPrimColour(gdl, ((failed ? 0xff000055 : 0x00ff0055) & 0xffffff00) | (((failed ? 0xff000055 : 0x00ff0055) & 0xff) * (renderdata->colour & 0xff) >> 8)); + colour = ((failed ? 0xff6969aa : renderdata->colour) & 0xffffff00) | ((((failed ? 0xff6969aa : renderdata->colour) & 0xff) * (renderdata->colour & 0xff)) >> 8); #else gdl = textSetPrimColour(gdl, failed ? 0xff000055 : 0x00ff0055); #endif diff --git a/src/game/vtxstore.c b/src/game/vtxstore.c index 6859627ee..86c5e7a90 100644 --- a/src/game/vtxstore.c +++ b/src/game/vtxstore.c @@ -6,6 +6,7 @@ #include "game/propobj.h" #include "bss.h" #include "lib/mema.h" +#include "lib/model.h" #include "lib/rng.h" #include "data.h" #include "types.h" diff --git a/src/game/weather.c b/src/game/weather.c index 7d42ff003..840564efe 100644 --- a/src/game/weather.c +++ b/src/game/weather.c @@ -23,17 +23,6 @@ struct weatherdata *g_WeatherData = NULL; -s32 var8007f0c4[4] = { - 0x000080b7, - 0x000080b6, - 0x000080b8, - -1, -}; - -u32 g_RainSpeedExtra = 20; -u32 g_SnowSpeed = 15; -u32 g_SnowSpeedExtra = 10; - Gfx *weatherRender(Gfx *gdl) { struct weatherdata *weather; @@ -267,6 +256,10 @@ void weatherSetIntensity(s32 intensity) g_WeatherData->intensity = intensity; } +u32 g_RainSpeedExtra; +u32 g_SnowSpeed; +u32 g_SnowSpeedExtra; + void weatherTickRain(struct weatherdata *weather) { \ s32 lVar6 = 0; @@ -302,7 +295,12 @@ void weatherTickRain(struct weatherdata *weather) // Rain noise for (i = 0; i != 4; i++) { - s32 sounds[4] = var8007f0c4; + s32 sounds[] = { + 0x80b7, + 0x80b6, + 0x80b8, + -1, + }; iVar10 = weather->unk58[i].unk00 * 32767.0f * weather->unk88; @@ -422,6 +420,10 @@ void weatherTickRain(struct weatherdata *weather) } } +u32 g_RainSpeedExtra = 20; +u32 g_SnowSpeed = 15; +u32 g_SnowSpeedExtra = 10; + void weatherTickSnow(struct weatherdata *weather) { \ s32 lVar7 = 0; @@ -4559,8 +4561,6 @@ u32 var8007f108 = 10; u32 var8007f10c = 0x8888aaff; u32 var8007f110 = 0xffffff7f; #else -u32 var8007f100 = 50; - Gfx *weatherRenderSnow(Gfx *gdl, struct weatherdata *weather, s32 arg2) { struct weatherparticledata *particledata; @@ -4621,6 +4621,7 @@ Gfx *weatherRenderSnow(Gfx *gdl, struct weatherdata *weather, s32 arg2) s32 index; s32 stack2[2]; + static u32 var8007f100 = 50; static u32 var8007f104 = 5; static u32 var8007f108 = 10; static u32 var8007f10c = 0x8888aaff; @@ -4686,7 +4687,7 @@ Gfx *weatherRenderSnow(Gfx *gdl, struct weatherdata *weather, s32 arg2) // x f0 = particle->pos.f[0] - particledata->boundarymin.f[0] - sp228.f[0]; - if (f0 < 0) { + if (f0 < 0.0f) { f0 += particledata->boundaryrange.f[0]; } @@ -4699,7 +4700,7 @@ Gfx *weatherRenderSnow(Gfx *gdl, struct weatherdata *weather, s32 arg2) // y f0 = particle->pos.f[1] - particledata->boundarymin.f[1] - sp228.f[1]; - if (f0 < 0) { + if (f0 < 0.0f) { f0 += particledata->boundaryrange.f[1]; } @@ -4712,7 +4713,7 @@ Gfx *weatherRenderSnow(Gfx *gdl, struct weatherdata *weather, s32 arg2) // z f0 = particle->pos.f[2] - particledata->boundarymin.f[2] - sp228.f[2]; - if (f0 < 0) { + if (f0 < 0.0f) { f0 += particledata->boundaryrange.f[2]; } @@ -4771,6 +4772,8 @@ Gfx *weatherRenderSnow(Gfx *gdl, struct weatherdata *weather, s32 arg2) if (a0 && sp1268 < 50) { sp126c[sp1268] = sp144[j2]; sp1268++; + } else { + // empty } } } @@ -4790,15 +4793,15 @@ Gfx *weatherRenderSnow(Gfx *gdl, struct weatherdata *weather, s32 arg2) if (s7 < 50) { sp1078[s7] = sp126c[i]; s7++; + } else { + // empty } } - - if (1); } // 4ea4 for (j = 0; j < s7; j++) { - if (var8007f100); + if (1); sp264[j][6] = sp264[j][0] = g_Rooms[sp1078[j]].bbmin[0] / 1 - var8007f104; sp264[j][9] = sp264[j][3] = g_Rooms[sp1078[j]].bbmax[0] / 1 + var8007f104; @@ -4832,7 +4835,7 @@ Gfx *weatherRenderSnow(Gfx *gdl, struct weatherdata *weather, s32 arg2) colours = gfxAllocateColours(16); for (j = 0; j < 16; j++) { - colours[j] = (var8007f10c & 0xffffff00) | ((0x10ef - j * 0xff) / 0x11); + colours[j] = (var8007f10c & 0xffffff00) | ((0xff * 17 - j * 0xff) / 17); } gDPSetColorArray(gdl++, osVirtualToPhysical(colours), 16); @@ -4844,12 +4847,13 @@ Gfx *weatherRenderSnow(Gfx *gdl, struct weatherdata *weather, s32 arg2) if (particledata->particles[s8].active & 3) { sp1354 = osGetCount(); - sp124.f[0] = particledata->unk3e80.f[0] + particledata->particles[s8].pos.f[0]; - sp124.f[1] = particledata->unk3e80.f[1] + particledata->particles[s8].pos.f[1]; - sp124.f[2] = particledata->unk3e80.f[2] + particledata->particles[s8].pos.f[2]; + sp124.f[0] = particledata->particles[s8].pos.f[0] + particledata->unk3e80.f[0]; + sp124.f[1] = particledata->particles[s8].pos.f[1] + particledata->unk3e80.f[1]; + sp124.f[2] = particledata->particles[s8].pos.f[2] + particledata->unk3e80.f[2]; if (cam0f0b5b9c(&sp124, 5)) { - sp137c = sp137c + osGetCount() - sp1354; + s32 count = osGetCount(); + sp137c = sp137c + count - sp1354; sp21c = particledata->particles[s8].pos.f[0]; sp220 = particledata->particles[s8].pos.f[2]; @@ -4859,17 +4863,19 @@ Gfx *weatherRenderSnow(Gfx *gdl, struct weatherdata *weather, s32 arg2) if (f20 < 0.00001f) { // empty } else { - sp260 = 0.0f; + s32 tmp2 = sp198 * 4; if (sp198 == 0) { vertices = gfxAllocateVertices(8); } + v0_2 = &vertices[tmp2]; + + sp260 = 0.0f; + sp21c /= f20; sp220 /= f20; - v0_2 = &vertices[sp198 * 4]; - for (j = 0; j < 4; j++) { v0_2[j].s = 0; v0_2[j].t = 0; @@ -4887,8 +4893,6 @@ Gfx *weatherRenderSnow(Gfx *gdl, struct weatherdata *weather, s32 arg2) for (j = 0; j < s7; j++) { // 5398 - if (var8007f100); - if (s1 && sp264[j][6] < sp118.f[0] && sp264[j][9] > sp118.f[0] @@ -4946,6 +4950,8 @@ Gfx *weatherRenderSnow(Gfx *gdl, struct weatherdata *weather, s32 arg2) // 559c if (s1) { + s32 j; + f0_3 = sqrtf(particledata->particles[s8].pos.f[0] * particledata->particles[s8].pos.f[0] + particledata->particles[s8].pos.f[1] * particledata->particles[s8].pos.f[1] + particledata->particles[s8].pos.f[2] * particledata->particles[s8].pos.f[2]); @@ -4957,21 +4963,33 @@ Gfx *weatherRenderSnow(Gfx *gdl, struct weatherdata *weather, s32 arg2) // 55fc f0_4 = sqrtf(f24 * f24 + f26 * f26); - sp1144.f[2] = sp108 * (f24 / f0_4); - sp1144.f[1] = -f0_3; sp1144.f[0] = sp108 * (f26 / f0_4); + sp1144.f[1] = -f0_4; + sp1144.f[2] = sp108 * (f24 / f0_4); - sp1144.f[6] = -sp220; - sp1144.f[7] = 1.0f; - sp1144.f[8] = sp21c; + sp115c.f[0] = -sp220; + sp115c.f[1] = 1.0f; + sp115c.f[2] = sp21c; // 5720 index = (s8 >> 2) & 7; for (j = 0; j < 4; j++) { - sp19c[j].f[0] += (var8007f104 * (f26 / f0_4)) * sp1168[index][j][0] + (var8007f104 * sp1144.f[2]) * sp1168[index][j][1]; - sp19c[j].f[1] += 0.0f + (var8007f104 * sp1144.f[1]) * sp1168[index][j][1]; - sp19c[j].f[2] += (var8007f104 * -(f24 / f0_4)) * sp1168[index][j][0] + (var8007f104 * sp1144.f[0]) * sp1168[index][j][1]; + f32 a; + f32 b; + f32 c; + + a = var8007f104 * (f26 / f0_4) * sp1168[index][j][0]; + b = 0.0f; + c = var8007f104 * -(f24 / f0_4) * sp1168[index][j][0]; + + a += var8007f104 * sp1144.f[2] * sp1168[index][j][1]; + b += var8007f104 * sp1144.f[1] * sp1168[index][j][1]; + c += var8007f104 * sp1144.f[0] * sp1168[index][j][1]; + + sp19c[j].f[1] += b; + sp19c[j].f[0] += a; + sp19c[j].f[2] += c; } // 5784 @@ -5029,44 +5047,49 @@ Gfx *weatherRenderSnow(Gfx *gdl, struct weatherdata *weather, s32 arg2) } // 5978 - v0 = &vertices[sp198 * 4]; + { + s16 a; + s16 b; - v0[0].colour = (s32)(sp260 * 16.0f) * 4; - v0[1].colour = (s32)(sp260 * 16.0f) * 4; - v0[2].colour = (s32)(sp260 * 16.0f) * 4; - v0[3].colour = (s32)(sp260 * 16.0f) * 4; + b = (s16) (((s8 & 2) >> 1) * 8); + a = (s16) ((s8 & 1) * 8); - v0[0].s = ((s32)(s8 & 1) * 8) * 32; - v0[1].s = ((s32)(s8 & 1) * 8 + 8) * 32; - v0[2].s = ((s32)(s8 & 1) * 8 + 8) * 32; - v0[3].s = ((s32)(s8 & 1) * 8) * 32; + vertices[sp198 * 4 + 0].colour = (s32) (sp260 * 16.0f) * 4; + vertices[sp198 * 4 + 1].colour = (s32) (sp260 * 16.0f) * 4; + vertices[sp198 * 4 + 2].colour = (s32) (sp260 * 16.0f) * 4; + vertices[sp198 * 4 + 3].colour = (s32) (sp260 * 16.0f) * 4; - v0[0].t = (((s8 & 2) >> 1) * 8 + 8) * 32; - v0[1].t = (((s8 & 2) >> 1) * 8 + 8) * 32; - v0[2].t = (((s8 & 2) >> 1) * 8) * 32; - v0[3].t = (((s8 & 2) >> 1) * 8) * 32; + vertices[sp198 * 4 + 0].s = (s16) (a) * 32; + vertices[sp198 * 4 + 1].s = (s16) (a + 8) * 32; + vertices[sp198 * 4 + 2].s = (s16) (a + 8) * 32; + vertices[sp198 * 4 + 3].s = (s16) (a) * 32; - v0[0].x = sp19c[0].f[0]; - v0[0].y = sp19c[0].f[1]; - v0[0].z = sp19c[0].f[2]; + vertices[sp198 * 4 + 0].t = (s16) (b + 8) * 32; + vertices[sp198 * 4 + 1].t = (s16) (b + 8) * 32; + vertices[sp198 * 4 + 2].t = (s16) (b) * 32; + vertices[sp198 * 4 + 3].t = (s16) (b) * 32; + } - v0[1].x = sp19c[1].f[0]; - v0[1].y = sp19c[1].f[1]; - v0[1].z = sp19c[1].f[2]; + vertices[sp198 * 4 + 0].x = sp19c[0].f[0]; + vertices[sp198 * 4 + 0].y = sp19c[0].f[1]; + vertices[sp198 * 4 + 0].z = sp19c[0].f[2]; - v0[2].x = sp19c[2].f[0]; - v0[2].y = sp19c[2].f[1]; - v0[2].z = sp19c[2].f[2]; + vertices[sp198 * 4 + 1].x = sp19c[1].f[0]; + vertices[sp198 * 4 + 1].y = sp19c[1].f[1]; + vertices[sp198 * 4 + 1].z = sp19c[1].f[2]; - v0[3].x = sp19c[3].f[0]; - v0[3].y = sp19c[3].f[1]; - v0[3].z = sp19c[3].f[2]; + vertices[sp198 * 4 + 2].x = sp19c[2].f[0]; + vertices[sp198 * 4 + 2].y = sp19c[2].f[1]; + vertices[sp198 * 4 + 2].z = sp19c[2].f[2]; + + vertices[sp198 * 4 + 3].x = sp19c[3].f[0]; + vertices[sp198 * 4 + 3].y = sp19c[3].f[1]; + vertices[sp198 * 4 + 3].z = sp19c[3].f[2]; if (sp198 == 1) { - sp198 = 0; - gDPSetVerticeArray(gdl++, osVirtualToPhysical(vertices), 8); gDPTri4(gdl++, 0, 1, 2, 2, 3, 0, 4, 5, 6, 6, 7, 4); + sp198 = 0; } else { sp198 = 1; } diff --git a/src/include/constants.h b/src/include/constants.h index d74fde60f..8d699d623 100644 --- a/src/include/constants.h +++ b/src/include/constants.h @@ -23,9 +23,9 @@ #define ABS(val) ((val) > 0 ? (val) : -(val)) #define ABSF(val) ((val) > 0.0f ? (val) : -(val)) #define ALIGN2(val) (((val) | 1) ^ 0x1) -#define ALIGN8(val) (((val) + 0x7 | 0x7) ^ 0x7) -#define ALIGN16(val) (((val) + 0xf | 0xf) ^ 0xf) -#define ALIGN64(val) ((((u32)(val)) + 0x3f | 0x3f) ^ 0x3f) +#define ALIGN8(val) ((((val) + 0x7) | 0x7) ^ 0x7) +#define ALIGN16(val) ((((val) + 0xf) | 0xf) ^ 0xf) +#define ALIGN64(val) (((((u32)(val)) + 0x3f) | 0x3f) ^ 0x3f) #define ARRAYCOUNT(a) (s32)(sizeof(a) / sizeof(a[0])) #define CHRRACE(chr) (chr ? chr->race : RACE_HUMAN) #define CRASH() *(u8 *)0 = 69 @@ -40,6 +40,9 @@ #define SECSTOTIME60(secs) (secs * 60) #define PFS(device) (device == SAVEDEVICE_GAMEPAK ? NULL : &g_Pfses[device]) +#define VALIDWEAPON() (g_Vars.currentplayer->gunctrl.weaponnum >= WEAPON_UNARMED && g_Vars.currentplayer->gunctrl.weaponnum <= WEAPON_COMBATBOOST) +#define FUNCISSEC() (VALIDWEAPON() && (g_PlayerConfigsArray[g_Vars.currentplayerstats->mpindex].gunfuncs[(g_Vars.currentplayer->gunctrl.weaponnum - 1) >> 3] & (1 << ((g_Vars.currentplayer->gunctrl.weaponnum - 1) & 7)))) + #define USINGDEVICE(device) (!g_Vars.currentplayer->isdead \ && !g_InCutscene \ && EYESPYINACTIVE() \ diff --git a/src/include/game/credits.h b/src/include/game/credits.h index 4fcd898c2..75ef843e8 100644 --- a/src/include/game/credits.h +++ b/src/include/game/credits.h @@ -4,9 +4,9 @@ #include "data.h" #include "types.h" - Gfx *creditsDraw(Gfx *gdl); void creditsReset(void); void creditsRequestAltTitle(void); +void credits0f13ae04(Mtxf *mtx); #endif diff --git a/src/include/game/debug.h b/src/include/game/debug.h index a8205b59e..d80e43fd1 100644 --- a/src/include/game/debug.h +++ b/src/include/game/debug.h @@ -28,6 +28,7 @@ bool debugIsChrStatsEnabled(void); bool debug0f11ef80(void); s32 dmenuGetSelectedOption(void); +void dmenuSetSelectedOption(s32 option); void dmenuSetMenu(char **labels, s32 (*positions)[2], s32 *offsets); void dmenuNavigateRight(void); void dmenuNavigateLeft(void); diff --git a/src/include/game/env.h b/src/include/game/env.h index 144567f2c..dab928f48 100644 --- a/src/include/game/env.h +++ b/src/include/game/env.h @@ -16,6 +16,6 @@ Gfx *envStartFog(Gfx *gdl, bool xlupass); Gfx *envStopFog(Gfx *gdl); bool env0f1666f8(struct coord *pos, f32 arg1); struct coord *env0f1667e8(void); -s32 env0f1667f4(struct prop *prop, f32 *arg1); +s32 env0f1667f4(struct prop *prop, f32 arg1[4]); #endif diff --git a/src/include/game/lang.h b/src/include/game/lang.h index d1f1bb630..84a849068 100644 --- a/src/include/game/lang.h +++ b/src/include/game/lang.h @@ -5,6 +5,7 @@ #include "types.h" void langInit(void); +void langReset(s32 stagenum); void langTick(void); u32 langGetLangBankIndexFromStagenum(s32 stagenum); diff --git a/src/include/game/menu.h b/src/include/game/menu.h index e87249346..ed0fa8bbf 100644 --- a/src/include/game/menu.h +++ b/src/include/game/menu.h @@ -79,7 +79,7 @@ void dialogCalculatePosition(struct menudialog *dialog); void menuClose(void); void func0f0f8120(void); void func0f0f820c(struct menudialogdef *dialogdef, s32 root); -bool menuSetBackground(s32 bg); +void menuSetBackground(s32 bg); void func0f0f8300(void); void menuPushRootDialog(struct menudialogdef *dialogdef, s32 arg1); void func0f0f85e0(struct menudialogdef *dialogdef, s32 root); diff --git a/src/include/game/modeldef.h b/src/include/game/modeldef.h index 76491e3b8..ab609e1a0 100644 --- a/src/include/game/modeldef.h +++ b/src/include/game/modeldef.h @@ -4,7 +4,7 @@ #include "data.h" #include "types.h" -void modeldef0f1a7560(struct modelfiledata *modeldef, u16 filenum, u32 arg2, u32 arg3, struct texpool *arg4, bool arg5); +void modeldef0f1a7560(struct modelfiledata *modeldef, u16 filenum, u32 arg2, struct modelfiledata *modeldef2, struct texpool *texpool, bool arg5); void modelPromoteTypeToPointer(struct modelfiledata *filedata); struct modelfiledata *modeldefLoad(u16 fileid, u8 *arg1, s32 arg2, struct texpool *arg3); struct modelfiledata *modeldefLoadToNew(u16 fileid); diff --git a/src/include/game/prop.h b/src/include/game/prop.h index 73b2b2250..47920a8cd 100644 --- a/src/include/game/prop.h +++ b/src/include/game/prop.h @@ -8,6 +8,8 @@ extern f32 g_AutoAimScale; void propsTick(void); +void propsStop(void); + void propsSort(void); void propEnable(struct prop *prop); void propDisable(struct prop *prop); diff --git a/src/include/game/propobj.h b/src/include/game/propobj.h index 33cd7e004..b53064d30 100644 --- a/src/include/game/propobj.h +++ b/src/include/game/propobj.h @@ -88,7 +88,7 @@ s32 func0f068fc8(struct prop *prop, bool arg1); void propCalculateShadeColour(struct prop *prop, u8 *nextcol, u16 floorcol); void propCalculateShadeInfo(struct prop *prop, u8 *nextcol, u16 floorcol); void colourTween(u8 *col, u8 *nextcol); -void func0f069750(s32 *arg0, s32 arg1, f32 *arg2); +void func0f069750(s32 *arg0, s32 arg1, f32 arg2[4]); void func0f069850(struct defaultobj *obj, struct coord *pos, f32 rot[3][3], struct geocyl *cyl); void func0f069b4c(struct defaultobj *obj); void func0f069c1c(struct defaultobj *obj); diff --git a/src/include/game/quaternion.h b/src/include/game/quaternion.h index d93808631..bf86a7170 100644 --- a/src/include/game/quaternion.h +++ b/src/include/game/quaternion.h @@ -5,7 +5,7 @@ #include "types.h" void quaternion0f096ca0(struct coord *arg0, f32 quat[4]); -void quaternionToMtx(f32 *arg0, Mtxf *arg1); +void quaternionToMtx(f32 arg0[4], Mtxf *arg1); void quaternion0f097044(Mtxf *matrix, f32 arg1[4]); void quaternionToTransformMtx(struct coord *pos, f32 rot[4], Mtxf *matrix); void quaternionSlerp(f32 q1[4], f32 q2[4], f32 t, f32 result[4]); diff --git a/src/include/game/tex.h b/src/include/game/tex.h index 8738c5272..5d8964147 100644 --- a/src/include/game/tex.h +++ b/src/include/game/tex.h @@ -19,7 +19,7 @@ s32 tex0f0b34d8(s32 width, s32 height, s32 lod); s32 tex0f0b3548(s32 width, s32 height, s32 lod); void texSetRenderMode(Gfx **gdlptr, s32 arg1, s32 numcycles, s32 arg3); void texLoadFromConfig(struct textureconfig *config); -void texSelect(Gfx **gdl, struct textureconfig *tconfig, u32 arg2, s32 arg3, u32 arg4, bool arg5, struct texpool *pool); +void texSelect(Gfx **gdl, struct textureconfig *tconfig, u32 arg2, s32 arg3, u32 ulst, bool arg5, struct texpool *pool); void tex0f173a08(void); bool texSetLutMode(u32 value); diff --git a/src/include/gbiex.h b/src/include/gbiex.h index 5ca5ae655..a980033f2 100644 --- a/src/include/gbiex.h +++ b/src/include/gbiex.h @@ -1,8 +1,5 @@ #ifndef _IN_GBIEX_H #define _IN_GBIEX_H -#include -#include "data.h" -#include "types.h" #define G_SETCOLOR 0x07 #define G_TRI4 -79 diff --git a/src/include/lib/debughud.h b/src/include/lib/debughud.h index 2dc05e1bf..ac2a34b8f 100644 --- a/src/include/lib/debughud.h +++ b/src/include/lib/debughud.h @@ -9,6 +9,8 @@ void dhudInit(void); void dhudReset(void); void dhudClear(void); void dhudSetPos(s32 x, s32 y); +void dhudSetFgColour(s32 r, s32 g, s32 b, s32 a); +void dhudSetBgColour(s32 r, s32 g, s32 b, s32 a); void dhudPrintChar(u8 c); void dhudPrintString(char *text); Gfx *dhudRender(Gfx *gdl); diff --git a/src/include/lib/model.h b/src/include/lib/model.h index cf1ab4738..5027ef426 100644 --- a/src/include/lib/model.h +++ b/src/include/lib/model.h @@ -105,6 +105,6 @@ void modelInit(struct model *model, struct modelfiledata *filedata, union modelr void animInit(struct anim *anim); void model00023108(struct model *model, struct modelfiledata *arg1, struct modelnode *node, struct modelfiledata *arg3); void modelIterateDisplayLists(struct modelfiledata *filedata, struct modelnode **nodeptr, Gfx **gdlptr); -void modelNodeReplaceGdl(u32 arg0, struct modelnode *node, Gfx *find, Gfx *replacement); +void modelNodeReplaceGdl(struct modelfiledata *modeldef, struct modelnode *node, Gfx *find, Gfx *replacement); #endif diff --git a/src/include/lib/profile.h b/src/include/lib/profile.h new file mode 100644 index 000000000..6d732dd37 --- /dev/null +++ b/src/include/lib/profile.h @@ -0,0 +1,14 @@ +#ifndef _IN_LIB_PROFILE_H +#define _IN_LIB_PROFILE_H +#include +#include "data.h" +#include "types.h" + +void profileInit(void); +void profileTick(void); +void profileReset(void); +void profile00009a98(void); +void profileSetMarker(u32 arg0); +Gfx *profileRender(Gfx *gdl); + +#endif diff --git a/src/include/lib/reset.h b/src/include/lib/reset.h index 4d9f23388..5de944caf 100644 --- a/src/include/lib/reset.h +++ b/src/include/lib/reset.h @@ -3,5 +3,6 @@ #include void resetproc(void *data); +void resetThreadCreate(void); #endif diff --git a/src/include/lib/sched.h b/src/include/lib/sched.h index d5da7da29..f38910a9f 100644 --- a/src/include/lib/sched.h +++ b/src/include/lib/sched.h @@ -14,6 +14,7 @@ void __scExec(OSSched *sc, OSScTask *sp, OSScTask *dp); void __scMain(void *arg); void __scYield(OSSched *sc); void schedInitArtifacts(void); +void schedResetArtifacts(void); struct artifact *schedGetWriteArtifacts(void); struct artifact *schedGetFrontArtifacts(void); void schedIncrementWriteArtifacts(void); diff --git a/src/include/lib/str.h b/src/include/lib/str.h index a47d035c1..5acd717c4 100644 --- a/src/include/lib/str.h +++ b/src/include/lib/str.h @@ -4,15 +4,15 @@ #include "data.h" #include "types.h" -char *strcpy(char *dst, char *src); -char *strncpy(char *dst, char *s2, s32 len); -char *strcat(char *dst, char *src); -s32 strcmp(char *s1, char *s2); -s32 strncmp(char *s1, char *s2, s32 len); +char *strcpy(char *dst, const char *src); +char *strncpy(char *dst, const char *src, s32 len); +char *strcat(char *dst, const char *src); +s32 strcmp(const char *s1, const char *s2); +s32 strncmp(const char *s1, const char *s2, s32 len); char toupper(char c); s32 isdigit(char c); s32 isalpha(char c); s32 isspace(char c); -s32 strtol(char *arg0, char **arg1, s32 arg2); +s32 strtol(const char *src, const char **endptr, s32 base); #endif diff --git a/src/include/lib/vi.h b/src/include/lib/vi.h index ea2327dc5..2b5372e76 100644 --- a/src/include/lib/vi.h +++ b/src/include/lib/vi.h @@ -4,12 +4,6 @@ #include "data.h" #include "types.h" -void profileInit(void); -void profileTick(void); -void profileReset(void); -void profile00009a98(void); -void profileSetMarker(u32 arg0); -Gfx *profileRender(Gfx *gdl); void viConfigureForLogos(void); void viConfigureForCopyright(u16 *fb); void viConfigureForLegal(void); @@ -19,6 +13,7 @@ void vi00009ed4(void); void viUpdateMode(void); void viShake(f32 intensity); void viSetMode(s32 mode); +void viSet16Bit(void); u16 *viGetBackBuffer(void); u16 *viGetFrontBuffer(void); Vp *viGetCurrentPlayerViewport(void); @@ -54,5 +49,7 @@ f32 viGetFovY(void); void viSetZRange(f32 arg0, f32 arg1); void viGetZRange(struct zrange *zrange); Gfx *viSetFillColour(Gfx *gdl, s32 r, s32 g, s32 b); +void viGrabJpg32(void); +void viGrabRgb32(void); #endif diff --git a/src/include/types.h b/src/include/types.h index 768725d7e..c313500ac 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -4,10 +4,10 @@ #include #include "n_libaudio.h" #include "constants.h" -#include "gbiex.h" #include "lang.h" #include "pads.h" #include "tiles.h" +#include "gbi.h" #define bool s32 #define ubool u32 @@ -895,6 +895,13 @@ struct geocyl { /*0x14*/ f32 radius; }; +union geounion { + struct geotilei tilei; + struct geotilef tilef; + struct geoblock block; + struct geocyl cyl; +}; + struct act_stand { /*0x2c*/ s32 prestand; /*0x30*/ s32 flags; @@ -3431,7 +3438,7 @@ union soundnumhack { }; struct { - u16 hasconfig : 1; + u16 hasconfig2 : 1; u16 unk02 : 2; u16 mp3priority : 2; u16 id : 11; @@ -4232,8 +4239,7 @@ struct mpplayerconfig { /*0x94*/ u8 medals; /*0x95*/ u8 title; /*0x96*/ u8 newtitle; - /*0x97*/ u8 gunfuncs[5]; - /*0x9c*/ u8 unk9c; + /*0x97*/ u8 gunfuncs[6]; /*0x9d*/ u8 handicap; }; diff --git a/src/lib/anim.c b/src/lib/anim.c index b821912ac..a49ee0a2f 100644 --- a/src/lib/anim.c +++ b/src/lib/anim.c @@ -400,8 +400,8 @@ s32 anim00023fe0(u8 *arg0, u8 arg1, s32 arg2) { u16 result = anim00023f50(arg0, arg1, arg2); - if (arg1 < 16 && (result & 1 << (arg1 + 31))) { - result |= (1 << (16 - arg1)) - 1 << arg1; + if (arg1 < 16 && (result & (1 << (arg1 - 1)))) { + result |= ((1 << (16 - arg1)) - 1) << arg1; } return result; @@ -689,7 +689,7 @@ f32 anim00024b64(u32 arg0, u32 arg1, struct skeleton *arg2, s16 animnum, u32 arg coord->y = sp30[1]; coord->z = sp30[2]; - return (value * M_BADTAU) / 65536.0f; + return value * M_BADTAU / 65536.0f; } f32 anim00024c14(s32 arg0, s16 animnum, u8 arg2) diff --git a/src/lib/args.c b/src/lib/args.c index e95d11d2b..bf4a48001 100644 --- a/src/lib/args.c +++ b/src/lib/args.c @@ -2,7 +2,9 @@ #include "constants.h" #include "bss.h" #include "lib/args.h" +#include "lib/str.h" #include "lib/rmon.h" +#include "string.h" #include "data.h" #include "types.h" @@ -56,7 +58,7 @@ char *argParseString(char *str) void argSetString(char *string) { - strcpy(g_ArgBuffer, string); + strcpy((char *) g_ArgBuffer, string); argParseString((char *) g_ArgBuffer); } diff --git a/src/lib/audiomgr.c b/src/lib/audiomgr.c index a663c8fef..d0409744a 100644 --- a/src/lib/audiomgr.c +++ b/src/lib/audiomgr.c @@ -5,6 +5,7 @@ #include "bss.h" #include "lib/audiodma.h" #include "lib/lib_2fc60.h" +#include "lib/profile.h" #include "lib/libc/ll.h" #include "data.h" #include "types.h" diff --git a/src/lib/boot.c b/src/lib/boot.c index a1a9e69aa..361f43827 100644 --- a/src/lib/boot.c +++ b/src/lib/boot.c @@ -41,7 +41,7 @@ u32 var8005ce08 = 0; u32 var8005ce0c = 0; u8 *g_StackLeftAddrs[7] = {0}; u8 *g_StackRightAddrs[7] = {0}; -u8 *g_StackAllocatedPos = (u8 *)0x80400000; +u8 *g_StackAllocatedPos = (u8 *) K0BASE + 4 * 1024 * 1024; u32 var8005ce4c = 0x00000002; u32 var8005ce50 = 0x10000000; @@ -149,10 +149,11 @@ void bootPhase1(void) osWritebackDCacheAll(); // Invalidate all instruction cache - osInvalICache((void *) 0x80000000, ICACHE_SIZE); + osInvalICache((void *) K0BASE, ICACHE_SIZE); // Configure the floating point unit flags = __osGetFpcCsr(); + flags |= FPCSR_EI; // enable inexact operation flags |= FPCSR_EO; // enable overflow flags |= FPCSR_EZ; // enable division by zero diff --git a/src/lib/collision.c b/src/lib/collision.c index 1838cae12..af14113ae 100644 --- a/src/lib/collision.c +++ b/src/lib/collision.c @@ -1802,6 +1802,8 @@ void cd0002901c(struct coord *pos, struct coord *dist, f32 width, struct collisi cdSetObstacleVtxPropFlt(&vtx1, &vtx2, collisions[bestindex].prop, bestvalue); } +f32 cdFindGroundFromList(struct collision *collisions, struct coord *pos, struct collision **collisionptr, f32 width); + #if VERSION >= VERSION_NTSC_1_0 // NTSC beta mismatches due to swapped s5/s6 registers // collision should be s6; next should be s5 @@ -2735,7 +2737,7 @@ glabel cdFindGroundFromList #endif /** - * Test if the given cylindar is intersecting a tile with the given geoflags. + * Test if the given cylinder is intersecting a tile with the given geoflags. * If so, populate the laddernormal argument and return true. * * There is nothing specific to ladders in this function, but it's only used diff --git a/src/lib/crash.c b/src/lib/crash.c index 6cbd851c6..8ca79a17b 100644 --- a/src/lib/crash.c +++ b/src/lib/crash.c @@ -6,6 +6,7 @@ #include "lib/crash.h" #include "lib/dma.h" #include "lib/rmon.h" +#include "lib/vi.h" #include "data.h" #include "types.h" @@ -593,7 +594,7 @@ u32 crashGetStackEnd(u32 sp, s32 tid) start = (u32)g_StackLeftAddrs[tid]; end = (u32)g_StackRightAddrs[tid]; - if (sp >= 0x80000000) { + if (sp >= K0BASE) { return end; } @@ -611,7 +612,7 @@ u32 crashGetStackStart(u32 sp, s32 tid) start = (u32)g_StackLeftAddrs[tid]; - if (sp >= 0x80000000) { + if (sp >= K0BASE) { return start; } diff --git a/src/lib/joy.c b/src/lib/joy.c index e7f7baa18..5ee6f52a5 100644 --- a/src/lib/joy.c +++ b/src/lib/joy.c @@ -9,7 +9,7 @@ /** * PD polls the controllers from the scheduler's thread. The scheduler polls the - * controllers on each retrace and stores teh results inside g_JoyData->samples. + * controllers on each retrace and stores the results inside g_JoyData->samples. * This allows the main thread to access a history of controller states since * the last rendered frame. For example, under laggy conditions the player might * press and release a button between two frames and the main thread can tell diff --git a/src/lib/lib_034d0.c b/src/lib/lib_034d0.c index 24ef6a347..c94105945 100644 --- a/src/lib/lib_034d0.c +++ b/src/lib/lib_034d0.c @@ -10,7 +10,7 @@ void func000034d8(void) // empty } -Gfx *func000034e0(Gfx *gdl) +void func000034e0(Gfx **gdl) { // empty } diff --git a/src/lib/main.c b/src/lib/main.c index 97d22b5fa..a9e2700a6 100644 --- a/src/lib/main.c +++ b/src/lib/main.c @@ -6,6 +6,7 @@ #include "game/camdraw.h" #include "game/cheats.h" #include "game/debug.h" +#include "game/file.h" #include "game/lang.h" #include "game/race.h" #include "game/body.h" @@ -29,6 +30,7 @@ #include "game/playermgr.h" #include "game/game_1531a0.h" #include "game/gfxmemory.h" +#include "game/lang.h" #include "game/lv.h" #include "game/timing.h" #include "game/music.h" @@ -55,12 +57,16 @@ #include "lib/snd.h" #include "lib/memp.h" #include "lib/mema.h" +#include "lib/profile.h" #include "lib/videbug.h" #include "lib/debughud.h" #include "lib/anim.h" #include "lib/rdp.h" +#include "lib/lib_34d0.h" #include "lib/lib_2f490.h" #include "lib/rmon.h" +#include "lib/rng.h" +#include "lib/str.h" #include "data.h" #include "types.h" @@ -391,7 +397,7 @@ void mainInit(void) // but before the thread stacks and VM system. // In 8MB mode, put it at the end of the expansion pak. if (bootGetMemSize() <= 4 * 1024 * 1024) { - addr = 0x80400000; + addr = K0BASE + 4 * 1024 * 1024; addr -= STACKSIZE_MAIN; addr -= STACKSIZE_IDLE; addr -= STACKSIZE_RMON; @@ -403,7 +409,7 @@ void mainInit(void) addr -= addr % 0x2000; // align down to a multiple of 0x2000 addr -= 0x1c80; // buffer for single biggest game zip } else { - addr = 0x80800000; + addr = K0BASE + 8 * 1024 * 1024; } addr -= 640 * 480 * 2; // the framebuffer itself diff --git a/src/lib/memp.c b/src/lib/memp.c index 00eee9a2a..ed8fe9428 100644 --- a/src/lib/memp.c +++ b/src/lib/memp.c @@ -1,6 +1,7 @@ #include #include "constants.h" #include "bss.h" +#include "lib/boot.h" #include "lib/memp.h" #include "data.h" #include "types.h" @@ -89,9 +90,9 @@ void mempSetHeap(u8 *heapstart, u32 heaplen) // If 8MB, reserve the entire expansion pak for the stage pool #if VERSION >= VERSION_NTSC_1_0 - extraend = (u8 *)(0x80000000 + bootGetMemSize()); + extraend = (u8 *) K0BASE + bootGetMemSize(); #else - extraend = (u8 *)(0x80000000 + osGetMemSize()); + extraend = (u8 *) K0BASE + osGetMemSize(); #endif #if VERSION >= VERSION_NTSC_1_0 @@ -100,7 +101,7 @@ void mempSetHeap(u8 *heapstart, u32 heaplen) if (osGetMemSize() > 4 * 1024 * 1024) #endif { - g_MempExpansionPools[MEMPOOL_STAGE].start = (u8 *)0x80400000; + g_MempExpansionPools[MEMPOOL_STAGE].start = (u8 *) K0BASE + 4 * 1024 * 1024; g_MempExpansionPools[MEMPOOL_STAGE].rightpos = extraend; } diff --git a/src/lib/model.c b/src/lib/model.c index 2bc7a5e0b..cf1b06092 100644 --- a/src/lib/model.c +++ b/src/lib/model.c @@ -683,8 +683,7 @@ void model0001b400(struct modelrenderdata *arg0, struct model *model, struct mod struct coord sp10c; f32 spfc[4]; f32 spec[4]; - u8 stack4[0xc]; - f32 spdc; + f32 spdc[4]; struct coord spd0; struct coord spc4; struct coord spb8; @@ -735,8 +734,8 @@ void model0001b400(struct modelrenderdata *arg0, struct model *model, struct mod quaternion0f096ca0(&sp230, spfc); quaternion0f0976c0(spfc, spec); - quaternionSlerp(spfc, spec, anim->fracmerge, &spdc); - quaternionToMtx(&spdc, &sp1d8); + quaternionSlerp(spfc, spec, anim->fracmerge, spdc); + quaternionToMtx(spdc, &sp1d8); } else { mtx4LoadRotation(&sp230, &sp1d8); } @@ -4277,7 +4276,7 @@ void modelIterateDisplayLists(struct modelfiledata *filedata, struct modelnode * *nodeptr = node; } -void modelNodeReplaceGdl(u32 arg0, struct modelnode *node, Gfx *find, Gfx *replacement) +void modelNodeReplaceGdl(struct modelfiledata *modeldef, struct modelnode *node, Gfx *find, Gfx *replacement) { union modelrodata *rodata; u32 type = node->type & 0xff; diff --git a/src/lib/modelasm.s b/src/lib/modelasm.s index 4360287ae..e29a08e7a 100644 --- a/src/lib/modelasm.s +++ b/src/lib/modelasm.s @@ -2152,8 +2152,8 @@ glabel model0001a2dc slti $at, $t3, 0x7fe0 bnez $at, .L0001a348 nop - lui $t4, %hi(var8006af8c) - addiu $t4, $t4, %lo(var8006af8c) + lui $t4, %hi(var8006ae90+252) + addiu $t4, $t4, %lo(var8006ae90+252) addi $t3, $t3, -32736 addiu $t5, $zero, 0x3 b .L0001a37c @@ -2162,8 +2162,8 @@ glabel model0001a2dc slti $at, $t3, 0x7800 bnez $at, .L0001a36c nop - lui $t4, %hi(var8006af0c) - addiu $t4, $t4, %lo(var8006af0c) + lui $t4, %hi(var8006ae90+124) + addiu $t4, $t4, %lo(var8006ae90+124) addi $t3, $t3, -30720 addiu $t5, $zero, 0x5 b .L0001a37c diff --git a/src/lib/mp3.c b/src/lib/mp3.c index c8b472067..e53864127 100644 --- a/src/lib/mp3.c +++ b/src/lib/mp3.c @@ -26,7 +26,6 @@ struct mp3vars g_Mp3Vars; struct asistream *g_AsiStream; -s16 _getRate(f32 vol, f32 tgt, s32 count, u16 *ratel); s32 func00038ba8(s32 arg0, u8 *arg1, s32 arg2, s32 arg3); extern f32 *var8009c6d8; @@ -241,7 +240,7 @@ s32 func00037fc0(s32 arg0, Acmd **cmd) sp58++; } - g_Mp3Vars.var8009c3d8 = g_Mp3Vars.var8009c3d8 - 0x24 & 0x1e; + g_Mp3Vars.var8009c3d8 = (g_Mp3Vars.var8009c3d8 - 0x24) & 0x1e; g_Mp3Vars.var8009c3cc = 0x240; g_Mp3Vars.var8009c3f1 = sp5c == 2; } else { diff --git a/src/lib/mp3/decoder.c b/src/lib/mp3/decoder.c index fd0094c98..81f62eb01 100644 --- a/src/lib/mp3/decoder.c +++ b/src/lib/mp3/decoder.c @@ -2173,7 +2173,7 @@ bool mp3decInit(void) sp25c = sp28[sp22c]; if (sp230 <= sp254->unk02) { - sp258 = &sp250[sp25c].bytes[sp254->unk04 & 1 << (sp230 + 31) ? 1 : 0]; + sp258 = &sp250[sp25c].bytes[sp254->unk04 & 1 << (sp230 - 1) ? 1 : 0]; if (*sp258) { sp25c = sp28[sp22c] + *sp258; diff --git a/src/lib/mp3/lib_47d20.c b/src/lib/mp3/lib_47d20.c index 85ad79e6f..818e87c2c 100644 --- a/src/lib/mp3/lib_47d20.c +++ b/src/lib/mp3/lib_47d20.c @@ -3,7 +3,11 @@ f32 fabsf(f32 value); +#ifdef __sgi #pragma intrinsic (fabsf) +#else +#define fabsf(f) __builtin_fabsf((f32)(f)) +#endif f32 func00047d20(f32 arg0) { diff --git a/src/lib/mtx.c b/src/lib/mtx.c index 45022982e..ec99dad30 100644 --- a/src/lib/mtx.c +++ b/src/lib/mtx.c @@ -286,8 +286,8 @@ void mtx00016798(Mtxf *src, Mtxf *dst) u32 word1 = srcwords[i + 0]; u32 word2 = srcwords[i + 8]; - dstfloats[(i << 1) + 0] = (s32) (word1 & 0xffff0000 | word2 >> 16) / var8005ef10[0]; - dstfloats[(i << 1) + 1] = (s32) (word1 << 16 | word2 & 0xffff) / var8005ef10[i & 1]; + dstfloats[(i << 1) + 0] = (s32) ((word1 & 0xffff0000) | (word2 >> 16)) / var8005ef10[0]; + dstfloats[(i << 1) + 1] = (s32) ((word1 << 16) | (word2 & 0xffff)) / var8005ef10[i & 1]; } } @@ -301,8 +301,8 @@ void mtx00016820(Mtx *src, Mtx *dst) u32 word1 = srcwords[i + 0]; u32 word2 = srcwords[i + 8]; - dstwords[(i << 1) + 0] = word1 & 0xffff0000 | word2 >> 16; - dstwords[(i << 1) + 1] = word1 << 16 | word2 & 0xffff; + dstwords[(i << 1) + 0] = (word1 & 0xffff0000) | (word2 >> 16); + dstwords[(i << 1) + 1] = (word1 << 16) | (word2 & 0xffff); } } diff --git a/src/lib/music.c b/src/lib/music.c index c3d14a49f..5033d9701 100644 --- a/src/lib/music.c +++ b/src/lib/music.c @@ -3,6 +3,7 @@ #include "constants.h" #include "game/music.h" #include "game/game_176080.h" +#include "game/stagemusic.h" #include "bss.h" #include "lib/snd.h" #include "lib/music.h" diff --git a/src/lib/naudio/n_csplayer.c b/src/lib/naudio/n_csplayer.c index 25363e196..9eaf4c694 100644 --- a/src/lib/naudio/n_csplayer.c +++ b/src/lib/naudio/n_csplayer.c @@ -1,5 +1,6 @@ #include "versions.h" #include +#include #include #include #include "n_libaudio.h" @@ -65,6 +66,7 @@ f32 var8005f34c[100] = { u32 var8005f4dc = 0x00000000; +void func00039cd0(N_ALCSPlayer *seqp); ALMicroTime __n_CSPVoiceHandler(void *node); void n_alCSPNew(N_ALCSPlayer *seqp, ALSeqpConfig *c) @@ -271,8 +273,9 @@ ALMicroTime __n_CSPVoiceHandler(void *node) ALFxRef fx = func0003e540(seqp->nextEvent.msg.evt19.unk00); if (fx) { - n_alSynSetFXParam(fx, seqp->nextEvent.msg.evt19.unk02 << 3 | - seqp->nextEvent.msg.evt19.unk01 & 7, &seqp->nextEvent.msg.evt19.param); + n_alSynSetFXParam(fx, + (seqp->nextEvent.msg.evt19.unk02 << 3) | (seqp->nextEvent.msg.evt19.unk01 & 7), + &seqp->nextEvent.msg.evt19.param); } } else { ALFxRef fx = func0003e5b8(seqp->nextEvent.msg.evt19.unk00); @@ -724,7 +727,7 @@ void __n_CSPHandleMIDIMsg(N_ALCSPlayer *seqp, N_ALEvent *event) } if ((chanstate->unk10 & 1) && seqp->queue) { - osSendMesg(seqp->queue, (OSMesg)(var8009c350[chan] & 0xffffff00 | chanstate->unk10 >> 2), OS_MESG_NOBLOCK); + osSendMesg(seqp->queue, (OSMesg)((var8009c350[chan] & 0xffffff00) | (chanstate->unk10 >> 2)), OS_MESG_NOBLOCK); } break; @@ -895,7 +898,7 @@ void __n_CSPHandleMIDIMsg(N_ALCSPlayer *seqp, N_ALEvent *event) break; case (0x1e): if (seqp->queue) { - osSendMesg(seqp->queue, (OSMesg)(byte2 & 7 | 0x10 | (seqp->node.samplesLeft << 5) & 0xffffff00), OS_MESG_NOBLOCK); + osSendMesg(seqp->queue, (OSMesg)((byte2 & 7) | 0x10 | ((seqp->node.samplesLeft << 5) & 0xffffff00)), OS_MESG_NOBLOCK); } break; case (AL_MIDI_VOLUME_CTRL): @@ -933,6 +936,7 @@ void __n_CSPHandleMIDIMsg(N_ALCSPlayer *seqp, N_ALEvent *event) } else if (vs->phase == AL_PHASE_SUSTREL) { vs->phase = AL_PHASE_RELEASE; + // @bug: chanstate is uninitialised if (chanstate->unk24) { __n_seqpReleaseVoice((N_ALSeqPlayer*)seqp, &vs->voice, diff --git a/src/lib/naudio/n_drvrNew.c b/src/lib/naudio/n_drvrNew.c index 2adab2ac9..89b497d59 100644 --- a/src/lib/naudio/n_drvrNew.c +++ b/src/lib/naudio/n_drvrNew.c @@ -13,6 +13,10 @@ */ #define ms *(((s32)((f32)44.1))&~0x7) +#ifdef AVOID_UB +f32 atan2f(f32 x, f32 z); +#endif + s32 SMALLROOM_PARAMS_N[26] = { /* sections length */ 3, 55 ms, @@ -40,6 +44,12 @@ void func0003b710(f32 outputrate, f32 arg1, f32 arg2, f32 *arg3, f32 *arg4) arg1 = outputrate - 200; } + // @bug: the declaration for atan2f is missing, so an implicit declaration + // is used by the compiler. The implicit declaration uses integer arguments, + // so these floats are being converted to ints here. atan2f then interprets + // the integer bits as a float. Similar story with the return value: atan2f + // returns a float in $f0, but the implicit declaration uses an integer so + // it's reading from $v0, which is a garbage value. sp24 = atan2f(arg1 * M_PI, outputrate); sp20 = sp24 * sp24; sp1c = (sp24 * 1.4142136573792f) / arg2; diff --git a/src/lib/naudio/n_env.c b/src/lib/naudio/n_env.c index 814692696..ba4ec80cb 100644 --- a/src/lib/naudio/n_env.c +++ b/src/lib/naudio/n_env.c @@ -23,8 +23,6 @@ s16 n_eqpower[] = { 0x0b11, 0x097d, 0x07e9, 0x0654, 0x04c0, 0x032a, 0x0195, 0x0000, }; -s16 _getRate(f32 vol, f32 tgt, s32 count, u16 *ratel); -s16 _getVol(s16 ivol, s32 samples, s16 ratem, u16 ratel); Acmd *_pullSubFrame(N_PVoice *filter, s16 *inp, s16 *outp, s32 outCount, Acmd *p); Acmd *n_alEnvmixerPull(N_PVoice *filter, s32 sampleOffset, Acmd *p) @@ -80,7 +78,7 @@ Acmd *n_alEnvmixerPull(N_PVoice *filter, s32 sampleOffset, Acmd *p) e->em_volume = tmp; e->em_pan = param->pan; - e->em_dryamt = n_eqpower[param->fxMix & 0x7f] & 0xfffe | param->fxMix >> 7; + e->em_dryamt = (n_eqpower[param->fxMix & 0x7f] & 0xfffe) | (param->fxMix >> 7); if (!var8009c340.surround) { e->em_dryamt &= 0xfffe; @@ -191,8 +189,8 @@ Acmd *n_alEnvmixerPull(N_PVoice *filter, s32 sampleOffset, Acmd *p) } } - e->em_dryamt = n_eqpower[e->em_ctrlList->data.i & 0x7f] & 0xfffe | e->em_dryamt & 1; - e->em_wetamt = n_eqpower[N_EQPOWER_LENGTH - (e->em_ctrlList->data.i & 0x7f) - 1] & 0xfffe | e->em_wetamt & 1; + e->em_dryamt = (n_eqpower[e->em_ctrlList->data.i & 0x7f] & 0xfffe) | (e->em_dryamt & 1); + e->em_wetamt = (n_eqpower[N_EQPOWER_LENGTH - (e->em_ctrlList->data.i & 0x7f) - 1] & 0xfffe) | (e->em_wetamt & 1); } /* diff --git a/src/lib/naudio/n_mainbus.c b/src/lib/naudio/n_mainbus.c index ca655834d..bba347bbe 100644 --- a/src/lib/naudio/n_mainbus.c +++ b/src/lib/naudio/n_mainbus.c @@ -1,5 +1,7 @@ +#include #include "n_synthInternals.h" +s32 func00037fc0(s32 arg0, Acmd **cmd); void func0003ba64(struct fx *fx, f32 outputrate); Acmd *n_alMainBusPull(s32 sampleOffset, Acmd *p) diff --git a/src/lib/path.c b/src/lib/path.c index 1553446df..6e1e64e3c 100644 --- a/src/lib/path.c +++ b/src/lib/path.c @@ -2,6 +2,7 @@ #include "constants.h" #include "bss.h" #include "data.h" +#include "game/padhalllv.h" #include "types.h" void objSetBlockedPathUnblocked(struct defaultobj *blocker, bool unblocked) diff --git a/src/lib/rdp.c b/src/lib/rdp.c index 99b261500..a46241e49 100644 --- a/src/lib/rdp.c +++ b/src/lib/rdp.c @@ -4,6 +4,7 @@ #include "data.h" #include "bss.h" #include "lib/memp.h" +#include "lib/sched.h" u8 g_RdpDramStack[SP_DRAM_STACK_SIZE8]; diff --git a/src/lib/reset.c b/src/lib/reset.c index c105f0730..7a520125a 100644 --- a/src/lib/reset.c +++ b/src/lib/reset.c @@ -1,5 +1,7 @@ #include #include "constants.h" +#include "lib/audiomgr.h" +#include "lib/joy.h" #include "lib/reset.h" #include "bss.h" #include "data.h" diff --git a/src/lib/rzip.s b/src/lib/rzip.s index 6d9c78f63..5e7dd4c07 100644 --- a/src/lib/rzip.s +++ b/src/lib/rzip.s @@ -22,6 +22,7 @@ .set gp=64 .bss +.balign 4 glabel var80090b10 .space 2504 diff --git a/src/lib/sched.c b/src/lib/sched.c index e6e8e27ac..dc813e789 100644 --- a/src/lib/sched.c +++ b/src/lib/sched.c @@ -6,13 +6,17 @@ #include "bss.h" #include "lib/args.h" #include "lib/audiomgr.h" +#include "lib/reset.h" #include "lib/rzip.h" #include "lib/crash.h" #include "lib/main.h" #include "lib/snd.h" #include "lib/pimgr.h" +#include "lib/profile.h" #include "lib/rmon.h" #include "lib/lib_48150.h" +#include "lib/vi.h" +#include "lib/joy.h" #include "data.h" #include "types.h" @@ -763,10 +767,6 @@ s32 __scSchedule(OSSched *sc, OSScTask **sp, OSScTask **dp, s32 availRCP) if (gfx->state & OS_SC_DP) { *dp = gfx; avail &= ~OS_SC_DP; - - if (avail & OS_SC_DP == 0) { - assert(sc->curRDPTask == gfx); - } } sc->gfxListHead = sc->gfxListHead->next; diff --git a/src/lib/snd.c b/src/lib/snd.c index 8f9aa0dba..4a31d4d08 100644 --- a/src/lib/snd.c +++ b/src/lib/snd.c @@ -7,14 +7,17 @@ #include "bss.h" #include "lib/rzip.h" #include "lib/args.h" +#include "lib/audiomgr.h" #include "lib/dma.h" #include "lib/snd.h" #include "lib/memp.h" #include "lib/rng.h" +#include "lib/str.h" #include "lib/lib_2fc60.h" #include "lib/lib_317f0.h" #include "lib/mp3.h" #include "lib/lib_39c80.h" +#include "lib/speaker.h" #include "data.h" #include "types.h" @@ -146,7 +149,6 @@ enum audioconfig_e { #endif }; -// 3e04 struct audiorussmapping g_AudioRussMappings[] = { /*0x0000*/ { 0x85ba, AUDIOCONFIG_59 }, /*0x0001*/ { 0x85a5, AUDIOCONFIG_15 }, @@ -836,8 +838,7 @@ s16 var8005ecf8[] = { 0x6665, 0x4ccc, 0x6ccb, - 0xffff, - 0x0000, + -1, }; extern u8 _sfxctlSegmentRomStart; @@ -1667,6 +1668,10 @@ void sndRemoveRef(ALSound *sound) void sndInit(void) { ALSndpConfig sndpconfig; + ALSynConfig synconfig; +#if VERSION >= VERSION_PAL_BETA + u32 settings[3]; +#endif #if VERSION >= VERSION_JPN_FINAL u32 heaplen = 1024 * 441; @@ -1701,14 +1706,9 @@ void sndInit(void) if (!g_SndDisabled) { // Allocate memory for the audio heap, // clear it and give it to the audio library - ALSynConfig synconfig; -#if VERSION >= VERSION_PAL_BETA - u32 settings[3]; -#endif - u8 *ptr = mempAlloc(heaplen, MEMPOOL_PERMANENT); u32 len = &_seqctlSegmentRomEnd - &_seqctlSegmentRomStart; + u8 *ptr = mempAlloc(heaplen, MEMPOOL_PERMANENT); s32 i; - u32 seqromaddr = (u32) &_sequencesSegmentRomStart; u8 *heapstart = ptr; u8 *end = heapstart + heaplen; ALBankFile *bankfile; @@ -1741,15 +1741,15 @@ void sndInit(void) // enough space for the table and load it. var80095204 = bankfile->bankArray[0]; g_SeqTable = alHeapDBAlloc(0, 0, &g_SndHeap, 1, 0x10); - dmaExec(g_SeqTable, seqromaddr, 0x10); + dmaExec(g_SeqTable, (u32) &_sequencesSegmentRomStart, 0x10); len = g_SeqTable->count * sizeof(struct seqtableentry) + 4; g_SeqTable = alHeapDBAlloc(0, 0, &g_SndHeap, 1, len); - dmaExec(g_SeqTable, seqromaddr, len + 0xf & 0xfffffff0); + dmaExec(g_SeqTable, (u32) &_sequencesSegmentRomStart, (len + 0xf) & 0xfffffff0); // Promote segment-relative offsets to ROM addresses for (i = 0; i < g_SeqTable->count; i++) { - g_SeqTable->entries[i].romaddr += seqromaddr; + g_SeqTable->entries[i].romaddr += (u32) &_sequencesSegmentRomStart; } synconfig.maxVVoices = 44; @@ -2031,7 +2031,7 @@ u16 seqGetVolume(struct seqinstance *seq) void seqSetVolume(struct seqinstance *seq, u16 volume) { if (!g_SndDisabled) { - u32 tmp = (var8005ecf8[seq->tracknum] * volume); + u32 tmp = var8005ecf8[seq->tracknum] * volume; tmp >>= 15; seq->volume = volume; @@ -2106,8 +2106,7 @@ void sndTick(void) if ((state->flags & SNDSTATEFLAG_02) == 0 && stateptrs[i]->state == AL_PLAYING && stateptrs[i]->unk48 > 0 - && stateptrs[i]->unk48 < curtime - ) { + && stateptrs[i]->unk48 < curtime) { state->unk48 = 0; func00033db0(); break; @@ -2148,7 +2147,7 @@ void sndTick(void) } if (g_SndGuardStringPtr != NULL) { - if (strcmp(g_SndGuardStringPtr, &g_SndGuardString) != 0) { + if (strcmp(g_SndGuardStringPtr, g_SndGuardString) != 0) { #if VERSION < VERSION_NTSC_1_0 crashSetMessage("Snd Heap Check FAILED"); CRASH(); @@ -2480,14 +2479,12 @@ struct sndstate *sndStart(s32 arg0, s16 sound, struct sndstate **handle, s32 arg #if VERSION >= VERSION_NTSC_1_0 if (sp40.id < (u32)g_NumSounds) { - return func00033820(arg0, sp40.id, sp3a, sp3d & 0x7f, - sp34, sp3f, IS4MB() ? 0 : sp3e, handle); + return func00033820(arg0, sp40.id, sp3a, sp3d & 0x7f, sp34, sp3f, IS4MB() ? 0 : sp3e, handle); } return NULL; #else - return func00033820(arg0, sp40.id, sp3a, sp3d & 0x7f, - sp34, sp3f, IS4MB() ? 0 : sp3e, handle); + return func00033820(arg0, sp40.id, sp3a, sp3d & 0x7f, sp34, sp3f, IS4MB() ? 0 : sp3e, handle); #endif } diff --git a/src/lib/str.c b/src/lib/str.c index 6bd516662..3491ba41f 100644 --- a/src/lib/str.c +++ b/src/lib/str.c @@ -1,7 +1,7 @@ #include #include "lib/fault.h" -char *strcpy(char *dst, char *src) +char *strcpy(char *dst, const char *src) { char *ptr = dst; char c; @@ -27,7 +27,7 @@ char *strcpy(char *dst, char *src) return dst; } -char *strncpy(char *dst, char *src, s32 len) +char *strncpy(char *dst, const char *src, s32 len) { char *ptr = dst; char c; @@ -56,7 +56,7 @@ char *strncpy(char *dst, char *src, s32 len) return dst; } -char *strcat(char *dst, char *src) +char *strcat(char *dst, const char *src) { char *ptr = dst; char c; @@ -78,7 +78,7 @@ char *strcat(char *dst, char *src) return dst; } -s32 strcmp(char *s1, char *s2) +s32 strcmp(const char *s1, const char *s2) { if (*s1 != *s2) { if (*s1 < *s2) { @@ -95,7 +95,7 @@ s32 strcmp(char *s1, char *s2) return strcmp(s1 + 1, s2 + 1); } -s32 strncmp(char *s1, char *s2, s32 len) +s32 strncmp(const char *s1, const char *s2, s32 len) { if (len == 0) { return 0; @@ -142,15 +142,15 @@ s32 isspace(char c) return c == ' ' || c == '\t' || c == '\n' || c == '\f' || c == '\v'; } -s32 strtol(char *src, char **endptr, s32 base) +s32 strtol(const char *src, const char **endptr, s32 base) { bool negative; u32 cutoff; u32 cutlim; u32 value; - char *ptr; + const char *ptr; char c; - char *save; + const char *save; bool overflow; if (base < 0 || base == 1 || base > 36) { diff --git a/src/lib/tlb.s b/src/lib/tlb.s index ebb0581ed..25467e8bc 100644 --- a/src/lib/tlb.s +++ b/src/lib/tlb.s @@ -6,20 +6,21 @@ .set noreorder .bss +.balign 4 glabel var8008ae20 .space 4 -glabel g_VmStateTable; +glabel g_VmStateTable .space 4 -glabel g_VmInitialised; +glabel g_VmInitialised .space 4 -glabel g_VmZipBuffer; +glabel g_VmZipBuffer .space 4 -glabel g_VmZipTable; +glabel g_VmZipTable .space 8 glabel var8008ae38 diff --git a/src/lib/ultra/gu/coss.c b/src/lib/ultra/gu/coss.c index 4bef02674..f6c805f1c 100644 --- a/src/lib/ultra/gu/coss.c +++ b/src/lib/ultra/gu/coss.c @@ -2,5 +2,5 @@ signed short coss(unsigned short x) { - return sins ((unsigned short) (x + 0x4000)); + return sins((unsigned short) (x + 0x4000)); } diff --git a/src/lib/ultra/io/devmgr.c b/src/lib/ultra/io/devmgr.c index 4427ce838..a5f27f785 100644 --- a/src/lib/ultra/io/devmgr.c +++ b/src/lib/ultra/io/devmgr.c @@ -41,7 +41,7 @@ void __osDevMgrMain(void *args) osRecvMesg(dm->acsQueue, &dummy, OS_MESG_BLOCK); __osResetGlobalIntMask(OS_IM_PI); - osEPiRawWriteIo(mb->piHandle, LEO_BM_CTL, (info->bmCtlShadow | 0x80000000)); + osEPiRawWriteIo(mb->piHandle, LEO_BM_CTL, PHYS_TO_K0(info->bmCtlShadow)); while (TRUE) { osRecvMesg(dm->evtQueue, &em, OS_MESG_BLOCK); diff --git a/src/lib/ultra/io/pfsallocatefile.c b/src/lib/ultra/io/pfsallocatefile.c index 0d436c6ec..cc5225a0e 100644 --- a/src/lib/ultra/io/pfsallocatefile.c +++ b/src/lib/ultra/io/pfsallocatefile.c @@ -3,7 +3,7 @@ s32 __osPfsDeclearPage(OSPfs *pfs, __OSInode *inode, int fileSizeInPages, int *startPage, u8 bank, int *decleared, int *finalPage); -s32 osPfsAllocateFile(OSPfs *pfs, u16 company_code, u32 game_code, char *game_name, char *ext_name, int num_bytes, s32 *file_no) +s32 osPfsAllocateFile(OSPfs *pfs, u16 company_code, u32 game_code, u8 *game_name, u8 *ext_name, int num_bytes, s32 *file_no) { int startPage; int decleared; diff --git a/src/lib/ultra/io/pfsdeletefile.c b/src/lib/ultra/io/pfsdeletefile.c index d2ecc0d7e..58a2523d5 100644 --- a/src/lib/ultra/io/pfsdeletefile.c +++ b/src/lib/ultra/io/pfsdeletefile.c @@ -1,7 +1,7 @@ #include #include "controller.h" -s32 osPfsDeleteFile(OSPfs *pfs, u16 company_code, u32 game_code, char *game_name, char *ext_name) +s32 osPfsDeleteFile(OSPfs *pfs, u16 company_code, u32 game_code, u8 *game_name, u8 *ext_name) { s32 file_no; s32 ret; diff --git a/src/lib/ultra/io/piint.h b/src/lib/ultra/io/piint.h index 71a38edc6..7da923ff7 100755 --- a/src/lib/ultra/io/piint.h +++ b/src/lib/ultra/io/piint.h @@ -104,6 +104,9 @@ void __osDevMgrMain(void *); void __osPiCreateAccessQueue(void); void __osPiRelAccess(void); void __osPiGetAccess(void); +s32 osPiRawReadIo(u32 devAddr, u32 *data); +s32 osEPiRawReadIo(OSPiHandle *handle, u32 devAddr, u32 *data); +s32 osEPiRawWriteIo(OSPiHandle *handle, u32 devAddr, u32 data); OSMesgQueue *osPiGetCmdQueue(void); #define OS_RAMROM_STACKSIZE 1024 diff --git a/src/lib/ultra/libc/ll.c b/src/lib/ultra/libc/ll.c index 7363283e7..daf4003b1 100644 --- a/src/lib/ultra/libc/ll.c +++ b/src/lib/ultra/libc/ll.c @@ -1,3 +1,5 @@ +#ifdef __sgi + unsigned long long __ull_rshift(unsigned long long a0, unsigned long long a1) { return a0 >> a1; @@ -54,3 +56,143 @@ long long __ll_rshift(long long a0, long long a1) { return a0 >> a1; } + +#else +// gcc + +/** + * IDO's __ull_rem is gcc's __umoddi3 + * IDO's __ull_div is gcc's __udivdi3 + * IDO's __ll_rem is gcc's __moddi3 + * IDO's __ll_div is gcc's __divdi3 + * + * The other IDO functions are not needed as gcc inlines them. + */ + +__asm__(" \n\ + .set push \n\ + .set noat \n\ + .set noreorder \n\ + .set gp=64 \n\ + \n\ + .global __umoddi3 \n\ + __umoddi3: \n\ + .type __umoddi3, @function \n\ + .ent __umoddi3 \n\ + sw $a0, ($sp) \n\ + sw $a1, 4($sp) \n\ + sw $a2, 8($sp) \n\ + sw $a3, 0xc($sp) \n\ + ld $t7, 8($sp) \n\ + ld $t6, ($sp) \n\ + ddivu $zero, $t6, $t7 \n\ + bnez $t7, 1f \n\ + nop \n\ + break 7 \n\ + 1: \n\ + mfhi $v0 \n\ + dsll32 $v1, $v0, 0 \n\ + dsra32 $v1, $v1, 0 \n\ + jr $ra \n\ + dsra32 $v0, $v0, 0 \n\ + .end __umoddi3 \n\ + .size __umoddi3, . - __umoddi3 \n\ + \n\ + .global __udivdi3 \n\ + __udivdi3: \n\ + .type __udivdi3, @function \n\ + .ent __udivdi3 \n\ + sw $a0, ($sp) \n\ + sw $a1, 4($sp) \n\ + sw $a2, 8($sp) \n\ + sw $a3, 0xc($sp) \n\ + ld $t7, 8($sp) \n\ + ld $t6, ($sp) \n\ + ddivu $zero, $t6, $t7 \n\ + bnez $t7, 1f \n\ + nop \n\ + break 7 \n\ + 1: \n\ + mflo $v0 \n\ + dsll32 $v1, $v0, 0 \n\ + dsra32 $v1, $v1, 0 \n\ + jr $ra \n\ + dsra32 $v0, $v0, 0 \n\ + .end __udivdi3 \n\ + .size __udivdi3, . - __udivdi3 \n\ + \n\ + .global __moddi3 \n\ + __moddi3: \n\ + .type __moddi3, @function \n\ + .ent __moddi3 \n\ + sw $a0, ($sp) \n\ + sw $a1, 4($sp) \n\ + sw $a2, 8($sp) \n\ + sw $a3, 0xc($sp) \n\ + ld $t7, 8($sp) \n\ + ld $t6, ($sp) \n\ + ddivu $zero, $t6, $t7 \n\ + bnez $t7, 1f \n\ + nop \n\ + break 7 \n\ + 1: \n\ + mfhi $v0 \n\ + dsll32 $v1, $v0, 0 \n\ + dsra32 $v1, $v1, 0 \n\ + jr $ra \n\ + dsra32 $v0, $v0, 0 \n\ + .end __moddi3 \n\ + .size __moddi3, . - __moddi3 \n\ + \n\ + .global __divdi3 \n\ + __divdi3: \n\ + .type __divdi3, @function \n\ + .ent __divdi3 \n\ + sw $a0, ($sp) \n\ + sw $a1, 4($sp) \n\ + sw $a2, 8($sp) \n\ + sw $a3, 0xc($sp) \n\ + ld $t7, 8($sp) \n\ + ld $t6, ($sp) \n\ + ddiv $zero, $t6, $t7 \n\ + nop \n\ + bnez $t7, 1f \n\ + nop \n\ + break 7 \n\ + 1: \n\ + daddiu $at, $zero, -1 \n\ + bne $t7, $at, 2f \n\ + daddiu $at, $zero, 1 \n\ + dsll32 $at, $at, 0x1f \n\ + bne $t6, $at, 2f \n\ + nop \n\ + break 6 \n\ + 2: \n\ + mflo $v0 \n\ + dsll32 $v1, $v0, 0 \n\ + dsra32 $v1, $v1, 0 \n\ + jr $ra \n\ + dsra32 $v0, $v0, 0 \n\ + .end __divdi3 \n\ + .size __divdi3, . - __divdi3 \n\ + \n\ + .global __ashldi3 \n\ + __ashldi3: \n\ + .type __ashldi3, @function \n\ + .ent __ashldi3 \n\ + sw $a0, 0($sp) \n\ + sw $a1, 4($sp) \n\ + ld $t6, 0($sp) \n\ + move $t7, $a2 \n\ + dsllv $v0, $t6, $t7 \n\ + dsll32 $v1, $v0, 0 \n\ + dsra32 $v1, $v1, 0 \n\ + jr $ra \n\ + dsra32 $v0, $v0, 0 \n\ + .end __ashldi3 \n\ + .size __ashldi3, . - __ashldi3 \n\ + \n\ + .set pop \n\ + \n"); + +#endif diff --git a/src/lib/ultra/libc/llcvt.c b/src/lib/ultra/libc/llcvt.c index 0881bc84a..ce6797516 100644 --- a/src/lib/ultra/libc/llcvt.c +++ b/src/lib/ultra/libc/llcvt.c @@ -1,5 +1,7 @@ #include "constants.h" +#ifdef __sgi + #if VERSION < VERSION_NTSC_1_0 long long __d_to_ll(double f) { @@ -160,3 +162,120 @@ float __ull_to_f(unsigned long long u) { return u; } + +#else +// gcc + +/** + * IDO's __f_to_ll is gcc's __fixsfdi + * IDO's __f_to_ull is gcc's __fixunssfdi + * IDO's __ll_to_d is gcc's __floatdidf + * IDO's __ull_to_f is gcc's __floatundisf + */ + +__asm__(" \n\ + .set push \n\ + .set noat \n\ + .set noreorder \n\ + .set gp=64 \n\ + \n\ + .global __fixsfdi \n\ + __fixsfdi: \n\ + .type __fixsfdi, @function \n\ + .ent __fixsfdi \n\ + trunc.l.s $f4, $f12 \n\ + dmfc1 $v0, $f4 \n\ + nop \n\ + dsll32 $v1, $v0, 0 \n\ + dsra32 $v1, $v1, 0 \n\ + jr $ra \n\ + dsra32 $v0, $v0, 0 \n\ + .end __fixsfdi \n\ + .size __fixsfdi, . - __fixsfdi \n\ + \n\ + .global __fixunssfdi \n\ + __fixunssfdi: \n\ + .type __fixunssfdi, @function \n\ + .ent __fixunssfdi \n\ + cfc1 $t6, $31 \n\ + addiu $v0, $zero, 1 \n\ + ctc1 $v0, $31 \n\ + nop \n\ + cvt.l.s $f4, $f12 \n\ + cfc1 $v0, $31 \n\ + nop \n\ + andi $at, $v0, 4 \n\ + andi $v0, $v0, 0x78 \n\ + beqz $v0, 2f \n\ + lui $at, 0x5f00 \n\ + mtc1 $at, $f4 \n\ + addiu $v0, $zero, 1 \n\ + sub.s $f4, $f12, $f4 \n\ + ctc1 $v0, $31 \n\ + nop \n\ + cvt.l.s $f4, $f4 \n\ + cfc1 $v0, $31 \n\ + nop \n\ + andi $at, $v0, 4 \n\ + andi $v0, $v0, 0x78 \n\ + bnez $v0, 1f \n\ + nop \n\ + lui $t7, 0x8000 \n\ + dsll32 $t7, $t7, 0 \n\ + dmfc1 $v0, $f4 \n\ + b 3f \n\ + or $v0, $v0, $t7 \n\ + 1: \n\ + b 3f \n\ + addiu $v0, $zero, -1 \n\ + 2: \n\ + dmfc1 $v0, $f4 \n\ + nop \n\ + bltz $v0, 1b \n\ + nop \n\ + 3: \n\ + ctc1 $t6, $31 \n\ + dsll32 $v1, $v0, 0 \n\ + dsra32 $v1, $v1, 0 \n\ + jr $ra \n\ + dsra32 $v0, $v0, 0 \n\ + .end __fixunssfdi \n\ + .size __fixunssfdi, . - __fixunssfdi \n\ + \n\ + .global __floatdidf \n\ + __floatdidf: \n\ + .type __floatdidf, @function \n\ + .ent __floatdidf \n\ + sw $a0, 0($sp) \n\ + sw $a1, 4($sp) \n\ + ld $t6, 0($sp) \n\ + dmtc1 $t6, $f4 \n\ + jr $ra \n\ + cvt.d.l $f0, $f4 \n\ + .end __floatdidf \n\ + .size __floatdidf, . - __floatdidf \n\ + \n\ + .global __floatundisf \n\ + __floatundisf: \n\ + .type __floatundisf, @function \n\ + .ent __floatundisf \n\ + sw $a0, 0($sp) \n\ + sw $a1, 4($sp) \n\ + ld $t6, 0($sp) \n\ + dmtc1 $t6, $f4 \n\ + bgez $t6, 1f \n\ + cvt.s.l $f0, $f4 \n\ + lui $at, 0x4f80 \n\ + mtc1 $at, $f6 \n\ + nop \n\ + add.s $f0, $f0, $f6 \n\ + 1: \n\ + jr $ra \n\ + nop \n\ + .end __floatundisf \n\ + .size __floatundisf, . - __floatundisf \n\ + \n\ + .set pop \n\ + \n"); + +#endif diff --git a/src/lib/ultra/libc/sprintf.c b/src/lib/ultra/libc/sprintf.c index 1ac640312..ba6c8111a 100644 --- a/src/lib/ultra/libc/sprintf.c +++ b/src/lib/ultra/libc/sprintf.c @@ -1,5 +1,6 @@ #include #include "stdarg.h" +#include "string.h" char _Printf(char *(*prout)(char *, const char *, size_t), char *dst, const char *fmt, va_list args); @@ -19,7 +20,11 @@ char *proutSprintf(char *dst, const char *src, size_t count) * Also note this file is using an incorrect declaration for _Printf. * _Printf returns an int, not a char. */ +#ifdef AVOID_UB +int sprintf(char *dst, const char *fmt, ...) +#else void sprintf(char *dst, const char *fmt, ...) +#endif { int ans; va_list ap; @@ -34,4 +39,8 @@ void sprintf(char *dst, const char *fmt, ...) va_end(ap); if ((ans && ans) != 0); + +#ifdef AVOID_UB + return ans; +#endif } diff --git a/src/lib/ultra/libc/string.c b/src/lib/ultra/libc/string.c index 517abab0e..d000daf03 100644 --- a/src/lib/ultra/libc/string.c +++ b/src/lib/ultra/libc/string.c @@ -38,3 +38,21 @@ char *strchr(const char *s, int c) return (char *)s; } + +#ifdef __GNUC__ +/** + * When compiling with gcc it replaces some loops with a call to memset, + * which means memset must be included in the project. + */ +void *memset(void *str, s32 c, size_t n) +{ + u8* m1 = (u8*) str; + u32 i; + + for (i = 0; i < n; i++) { + m1[i] = c; + } + + return str; +} +#endif diff --git a/src/lib/ultra/libc/xldtob.c b/src/lib/ultra/libc/xldtob.c index ddb5ef2b8..ee9d0f92c 100644 --- a/src/lib/ultra/libc/xldtob.c +++ b/src/lib/ultra/libc/xldtob.c @@ -35,7 +35,7 @@ const double pows[] = {10e0L, 10e1L, 10e3L, 10e7L, 10e15L, 10e31L, 10e63L, 10e12 #define _D2 2 #define _D3 3 -void _Ldtob(printf_struct *args, u8 type) +void _Ldtob(printf_struct *args, char type) { u8 buff[0x20]; u8 *p = buff; @@ -201,32 +201,35 @@ short _Ldunscale(short *pex, printf_struct *px) void _Genld(printf_struct *px, char code, char *p, short nsig, short xexp) { - const char point = 0x2e; + const char point = '.'; if (nsig <= 0) { - nsig = 1, p = (char *)"0"; + p = (char *) "0"; + nsig = 1; } - if (code == 0x66 || ((code == 0x67 || code == 0x47) && (-4 <= xexp) && (xexp < px->precision))) { - /* 0x66 format */ - ++xexp; /* change to leading digit count */ + if (code == 'f' || ((code == 'g' || code == 'G') && xexp >= -4 && xexp < px->precision)) { + /* 'f' format */ + xexp++; /* change to leading digit count */ - if (code != 0x66) { - /* fixup for 0x67 */ + if (code != 'f') { + /* fixup for 'g' */ if (!(px->flags & FLAGS_HASH) && nsig < px->precision) { px->precision = nsig; } - if ((px->precision -= xexp) < 0) { + px->precision -= xexp; + + if (px->precision < 0) { px->precision = 0; } } if (xexp <= 0) { /* digits only to right of point */ - px->buff[px->part2_len++] = 0x30; + px->buff[px->part2_len++] = '0'; - if (0 < px->precision || px->flags & FLAGS_HASH) { + if (px->precision > 0 || px->flags & FLAGS_HASH) { px->buff[px->part2_len++] = point; } @@ -241,7 +244,9 @@ void _Genld(printf_struct *px, char code, char *p, short nsig, short xexp) nsig = px->precision; } - memcpy(&px->buff[px->part2_len], p, px->part3_len = nsig); + px->part3_len = nsig; + + memcpy(&px->buff[px->part2_len], p, nsig); px->num_trailing_zeros = px->precision - nsig; } else if (nsig < xexp) { @@ -251,8 +256,9 @@ void _Genld(printf_struct *px, char code, char *p, short nsig, short xexp) px->part2_len += nsig; px->num_mid_zeros = xexp - nsig; - if (0 < px->precision || px->flags & FLAGS_HASH) { - px->buff[px->part2_len] = point, ++px->part3_len; + if (px->precision > 0 || px->flags & FLAGS_HASH) { + px->buff[px->part2_len] = point; + px->part3_len++; } px->num_trailing_zeros = px->precision; @@ -263,7 +269,7 @@ void _Genld(printf_struct *px, char code, char *p, short nsig, short xexp) px->part2_len += xexp; nsig -= xexp; - if (0 < px->precision || px->flags & FLAGS_HASH) { + if (px->precision > 0 || px->flags & FLAGS_HASH) { px->buff[px->part2_len++] = point; } @@ -277,29 +283,36 @@ void _Genld(printf_struct *px, char code, char *p, short nsig, short xexp) px->num_mid_zeros = px->precision - nsig; } } else { - /* 0x65 format */ - if (code == 0x67 || code == 0x47) { - /* fixup for 0x67 */ + /* 'e' format */ + if (code == 'g' || code == 'G') { + /* fixup for 'g' */ if (nsig < px->precision) { px->precision = nsig; } - if (--px->precision < 0) { + px->precision--; + + if (px->precision < 0) { px->precision = 0; } - code = code == 0x67 ? 0x65 : 0x45; + code = code == 'g' ? 'e' : 'E'; } - px->buff[px->part2_len++] = *p++; + px->buff[px->part2_len] = *p; + px->part2_len++; + p++; - if (0 < px->precision || px->flags & FLAGS_HASH) { - px->buff[px->part2_len++] = point; + if (px->precision > 0 || px->flags & FLAGS_HASH) { + px->buff[px->part2_len] = point; + px->part2_len++; } - if (0 < px->precision) { + if (px->precision > 0) { /* put fraction digits */ - if (px->precision < --nsig) { + nsig--; + + if (px->precision < nsig) { nsig = px->precision; } @@ -309,30 +322,35 @@ void _Genld(printf_struct *px, char code, char *p, short nsig, short xexp) px->num_mid_zeros = px->precision - nsig; } - p = (char *)&px->buff[px->part2_len]; /* put exponent */ - *p++ = code; + p = (char *) &px->buff[px->part2_len]; /* put exponent */ + *p = code; + p++; - if (0 <= xexp) { - *p++ = 0x2b; + if (xexp >= 0) { + *p++ = '+'; } else { /* negative exponent */ - *p++ = 0x2d; + *p++ = '-'; xexp = -xexp; } - if (100 <= xexp) { + if (xexp >= 100) { /* put oversize exponent */ - if (1000 <= xexp) { - *p++ = xexp / 1000 + 0x30, xexp %= 1000; + if (xexp >= 1000) { + *p = xexp / 1000 + 0x30, xexp %= 1000; + p++; } - *p++ = xexp / 100 + 0x30, xexp %= 100; + *p = xexp / 100 + 0x30, xexp %= 100; + p++; } - *p++ = xexp / 10 + 0x30, xexp %= 10; - *p++ = xexp + 0x30; + *p = xexp / 10 + 0x30, xexp %= 10; + p++; + *p = xexp + 0x30; + p++; - px->part3_len = p - (char *)&px->buff[px->part2_len]; + px->part3_len = p - (char *) &px->buff[px->part2_len]; } if ((px->flags & (FLAGS_ZERO | FLAGS_MINUS)) == FLAGS_ZERO) { diff --git a/src/lib/ultra/libc/xlitob.c b/src/lib/ultra/libc/xlitob.c index d90dcd5c1..c8468eabe 100644 --- a/src/lib/ultra/libc/xlitob.c +++ b/src/lib/ultra/libc/xlitob.c @@ -1,5 +1,6 @@ #include #include "xstdio.h" +#include #define BUFF_LEN 0x18 diff --git a/src/lib/ultra/os/createthread.c b/src/lib/ultra/os/createthread.c index b723fcac9..472bc26f0 100644 --- a/src/lib/ultra/os/createthread.c +++ b/src/lib/ultra/os/createthread.c @@ -7,24 +7,26 @@ void __osCleanupThread(void); void osCreateThread(OSThread *t, OSId id, void (*entry)(void *), void *arg, void *sp, OSPri p) { register u32 saveMask; - OSIntMask mask; + t->id = id; t->priority = p; t->next = NULL; t->queue = NULL; - t->context.pc = (u32)entry; - t->context.a0 = (u64)arg; - t->context.sp = (u64)sp - 16; - t->context.ra = (u64)__osCleanupThread; - mask = OS_IM_ALL; + t->context.pc = (u32) entry; + t->context.a0 = (u64) arg; + t->context.sp = (u64) sp - 16; + t->context.ra = (u64) __osCleanupThread; t->context.sr = SR_FR | SR_IMASK | SR_EXL | SR_IE; - t->context.rcp = (mask & RCP_IMASK) >> RCP_IMASKSHIFT; - t->context.fpcsr = (u32)(FPCSR_FS | FPCSR_EV); + t->context.rcp = (OS_IM_ALL & RCP_IMASK) >> RCP_IMASKSHIFT; + t->context.fpcsr = (u32) (FPCSR_FS | FPCSR_EV); t->fp = 0; t->state = OS_STATE_STOPPED; t->flags = 0; + saveMask = __osDisableInt(); + t->tlnext = __osActiveQueue; __osActiveQueue = t; + __osRestoreInt(saveMask); } diff --git a/src/lib/ultra/os/initialize.c b/src/lib/ultra/os/initialize.c index cb26aaec5..6219a83b4 100644 --- a/src/lib/ultra/os/initialize.c +++ b/src/lib/ultra/os/initialize.c @@ -112,4 +112,8 @@ OSPiHandle *osCartRomInit(void) LeoDiskHandle.pulse = IO_READ(0xa4600028); LeoDiskHandle.pageSize = IO_READ(0xa460002c); LeoDiskHandle.relDuration = IO_READ(0xa4600030); + +#ifdef AVOID_UB + return &CartRomHandle; +#endif } diff --git a/src/lib/ultra/os/initialize2.c b/src/lib/ultra/os/initialize2.c index 0e036b494..69bfb1d78 100644 --- a/src/lib/ultra/os/initialize2.c +++ b/src/lib/ultra/os/initialize2.c @@ -95,4 +95,8 @@ OSPiHandle *osCartRomInit2(void) LeoDiskHandle.pulse = IO_READ(0xa4600028); LeoDiskHandle.pageSize = IO_READ(0xa460002c); LeoDiskHandle.relDuration = IO_READ(0xa4600030); + +#ifdef AVOID_UB + return &CartRomHandle; +#endif } diff --git a/src/lib/vi.c b/src/lib/vi.c index 57e40b974..fdd79b828 100644 --- a/src/lib/vi.c +++ b/src/lib/vi.c @@ -15,11 +15,11 @@ #include "types.h" #define TO_U16_A(x) ((u16)(x)) -#define TO_U16_B(x) (x & 0xffff) -#define TO_U16_C(x) ((u16)(x & 0xffff)) +#define TO_U16_B(x) ((x) & 0xffff) +#define TO_U16_C(x) ((u16)((x) & 0xffff)) #define ADD_LOW_AND_HI_16_TRUNCATE(reg, add) ((TO_U16_B(TO_U16_A((reg) >> 16) + (add)) << 16) | TO_U16_B(TO_U16_A(reg) + (add))) -#define ADD_LOW_AND_HI_16_MOD(reg, add) ((((((reg >> 16) & 0xffff) + add) % 0xffff) << 16) | (((((reg >> 0) & 0xffff) + add) % 0xffff) << 0)) +#define ADD_LOW_AND_HI_16_MOD(reg, add) ((((((reg >> 16) & 0xffff) + (add)) % 0xffff) << 16) | (((((reg >> 0) & 0xffff) + (add)) % 0xffff) << 0)) Mtxf var80092830; Mtx *var80092870; diff --git a/src/lib/vm.c b/src/lib/vm.c index 436f0a0de..f5f64ffb3 100644 --- a/src/lib/vm.c +++ b/src/lib/vm.c @@ -2,6 +2,7 @@ #include "lib/tlb.h" #include "constants.h" #include "bss.h" +#include "lib/boot.h" #include "lib/rzip.h" #include "lib/dma.h" #include "lib/lib_48150.h" diff --git a/src/setups/mp_setupame.c b/src/setups/mp_setupame.c index f334b4780..5b4e86f0e 100644 --- a/src/setups/mp_setupame.c +++ b/src/setups/mp_setupame.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/mp_setuparch.c b/src/setups/mp_setuparch.c index 3f4e1faaf..2478e6ed1 100644 --- a/src/setups/mp_setuparch.c +++ b/src/setups/mp_setuparch.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/mp_setuparec.c b/src/setups/mp_setuparec.c index f676b3642..42a668fff 100644 --- a/src/setups/mp_setuparec.c +++ b/src/setups/mp_setuparec.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/mp_setupark.c b/src/setups/mp_setupark.c index 56401c7a2..84ad2af2d 100644 --- a/src/setups/mp_setupark.c +++ b/src/setups/mp_setupark.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/mp_setupash.c b/src/setups/mp_setupash.c index e70826dc5..db9d59704 100644 --- a/src/setups/mp_setupash.c +++ b/src/setups/mp_setupash.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/mp_setupate.c b/src/setups/mp_setupate.c index a670ead32..62c256ce5 100644 --- a/src/setups/mp_setupate.c +++ b/src/setups/mp_setupate.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/mp_setupazt.c b/src/setups/mp_setupazt.c index 28a80be79..a6e6379dc 100644 --- a/src/setups/mp_setupazt.c +++ b/src/setups/mp_setupazt.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/mp_setupcat.c b/src/setups/mp_setupcat.c index e53ebfed4..d4be4efe4 100644 --- a/src/setups/mp_setupcat.c +++ b/src/setups/mp_setupcat.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/mp_setupcave.c b/src/setups/mp_setupcave.c index 1a610b576..55509d349 100644 --- a/src/setups/mp_setupcave.c +++ b/src/setups/mp_setupcave.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/mp_setupcrad.c b/src/setups/mp_setupcrad.c index 704884fc4..c91bca4ff 100644 --- a/src/setups/mp_setupcrad.c +++ b/src/setups/mp_setupcrad.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/mp_setupcryp.c b/src/setups/mp_setupcryp.c index 2afab87db..2f0cde66f 100644 --- a/src/setups/mp_setupcryp.c +++ b/src/setups/mp_setupcryp.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/mp_setupdam.c b/src/setups/mp_setupdam.c index de123df46..355b8faa2 100644 --- a/src/setups/mp_setupdam.c +++ b/src/setups/mp_setupdam.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/mp_setupdepo.c b/src/setups/mp_setupdepo.c index 67c1911dc..1648f80f0 100644 --- a/src/setups/mp_setupdepo.c +++ b/src/setups/mp_setupdepo.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/mp_setupdest.c b/src/setups/mp_setupdest.c index b178616eb..4c403f233 100644 --- a/src/setups/mp_setupdest.c +++ b/src/setups/mp_setupdest.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/mp_setupdish.c b/src/setups/mp_setupdish.c index 55d612cd8..0f397dbc8 100644 --- a/src/setups/mp_setupdish.c +++ b/src/setups/mp_setupdish.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/mp_setupear.c b/src/setups/mp_setupear.c index 58bb752e4..1a6da36d0 100644 --- a/src/setups/mp_setupear.c +++ b/src/setups/mp_setupear.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/mp_setupeld.c b/src/setups/mp_setupeld.c index 91e0c206f..09acb1b31 100644 --- a/src/setups/mp_setupeld.c +++ b/src/setups/mp_setupeld.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/mp_setupimp.c b/src/setups/mp_setupimp.c index 5a5d10c89..ed405a95b 100644 --- a/src/setups/mp_setupimp.c +++ b/src/setups/mp_setupimp.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/mp_setupjun.c b/src/setups/mp_setupjun.c index 5b9bf89f2..81d72e78d 100644 --- a/src/setups/mp_setupjun.c +++ b/src/setups/mp_setupjun.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/mp_setuplam.c b/src/setups/mp_setuplam.c index 142dd48a8..d5624157a 100644 --- a/src/setups/mp_setuplam.c +++ b/src/setups/mp_setuplam.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/mp_setuplee.c b/src/setups/mp_setuplee.c index 364e9f79b..69fb20617 100644 --- a/src/setups/mp_setuplee.c +++ b/src/setups/mp_setuplee.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/mp_setuplen.c b/src/setups/mp_setuplen.c index 9f183eaa7..66b44ceda 100644 --- a/src/setups/mp_setuplen.c +++ b/src/setups/mp_setuplen.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/mp_setuplip.c b/src/setups/mp_setuplip.c index ad0094ffb..6fe213064 100644 --- a/src/setups/mp_setuplip.c +++ b/src/setups/mp_setuplip.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/mp_setuplue.c b/src/setups/mp_setuplue.c index 8b96d7049..12b495cee 100644 --- a/src/setups/mp_setuplue.c +++ b/src/setups/mp_setuplue.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/mp_setupmp1.c b/src/setups/mp_setupmp1.c index b34aa6ec8..3a2cf25b2 100644 --- a/src/setups/mp_setupmp1.c +++ b/src/setups/mp_setupmp1.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/mp_setupmp10.c b/src/setups/mp_setupmp10.c index 1fcdc0f7b..a8363ee98 100644 --- a/src/setups/mp_setupmp10.c +++ b/src/setups/mp_setupmp10.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/mp_setupmp11.c b/src/setups/mp_setupmp11.c index 3f9a2448a..da1c2cd2e 100644 --- a/src/setups/mp_setupmp11.c +++ b/src/setups/mp_setupmp11.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/mp_setupmp12.c b/src/setups/mp_setupmp12.c index dce9fc1e4..09c91e65e 100644 --- a/src/setups/mp_setupmp12.c +++ b/src/setups/mp_setupmp12.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/mp_setupmp13.c b/src/setups/mp_setupmp13.c index 7e43c994a..ae04dcb2c 100644 --- a/src/setups/mp_setupmp13.c +++ b/src/setups/mp_setupmp13.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/mp_setupmp14.c b/src/setups/mp_setupmp14.c index 91e00c852..4ed802a11 100644 --- a/src/setups/mp_setupmp14.c +++ b/src/setups/mp_setupmp14.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/mp_setupmp15.c b/src/setups/mp_setupmp15.c index 805c153c4..3bf4ae759 100644 --- a/src/setups/mp_setupmp15.c +++ b/src/setups/mp_setupmp15.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/mp_setupmp16.c b/src/setups/mp_setupmp16.c index c37632f6d..deb474881 100644 --- a/src/setups/mp_setupmp16.c +++ b/src/setups/mp_setupmp16.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/mp_setupmp17.c b/src/setups/mp_setupmp17.c index 5cd14d043..b5a35afd9 100644 --- a/src/setups/mp_setupmp17.c +++ b/src/setups/mp_setupmp17.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/mp_setupmp18.c b/src/setups/mp_setupmp18.c index 49b857d94..4ee06e743 100644 --- a/src/setups/mp_setupmp18.c +++ b/src/setups/mp_setupmp18.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/mp_setupmp19.c b/src/setups/mp_setupmp19.c index 70f285cbd..aaa6b4b2f 100644 --- a/src/setups/mp_setupmp19.c +++ b/src/setups/mp_setupmp19.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/mp_setupmp2.c b/src/setups/mp_setupmp2.c index 93dd3392c..bf2e43ea0 100644 --- a/src/setups/mp_setupmp2.c +++ b/src/setups/mp_setupmp2.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/mp_setupmp20.c b/src/setups/mp_setupmp20.c index 8a1b8da8a..a806de67b 100644 --- a/src/setups/mp_setupmp20.c +++ b/src/setups/mp_setupmp20.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/mp_setupmp3.c b/src/setups/mp_setupmp3.c index c15c11d83..1cd892079 100644 --- a/src/setups/mp_setupmp3.c +++ b/src/setups/mp_setupmp3.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/mp_setupmp4.c b/src/setups/mp_setupmp4.c index d9199eaff..78d9999ed 100644 --- a/src/setups/mp_setupmp4.c +++ b/src/setups/mp_setupmp4.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/mp_setupmp5.c b/src/setups/mp_setupmp5.c index 853343caa..6d2a63fa1 100644 --- a/src/setups/mp_setupmp5.c +++ b/src/setups/mp_setupmp5.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/mp_setupmp6.c b/src/setups/mp_setupmp6.c index 126f5a234..b5c2fcd14 100644 --- a/src/setups/mp_setupmp6.c +++ b/src/setups/mp_setupmp6.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/mp_setupmp7.c b/src/setups/mp_setupmp7.c index 57745a900..d71ac84fd 100644 --- a/src/setups/mp_setupmp7.c +++ b/src/setups/mp_setupmp7.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/mp_setupmp8.c b/src/setups/mp_setupmp8.c index 3454c5f11..eef5783b9 100644 --- a/src/setups/mp_setupmp8.c +++ b/src/setups/mp_setupmp8.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/mp_setupmp9.c b/src/setups/mp_setupmp9.c index 6da22b114..bfc5dc238 100644 --- a/src/setups/mp_setupmp9.c +++ b/src/setups/mp_setupmp9.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/mp_setupoat.c b/src/setups/mp_setupoat.c index 85612c249..b47e7e5df 100644 --- a/src/setups/mp_setupoat.c +++ b/src/setups/mp_setupoat.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/mp_setupold.c b/src/setups/mp_setupold.c index 2083b8a43..6e18b3f0c 100644 --- a/src/setups/mp_setupold.c +++ b/src/setups/mp_setupold.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/mp_setuppam.c b/src/setups/mp_setuppam.c index cf70b2188..0b3cc37fa 100644 --- a/src/setups/mp_setuppam.c +++ b/src/setups/mp_setuppam.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/mp_setuppete.c b/src/setups/mp_setuppete.c index b223023ab..885549b69 100644 --- a/src/setups/mp_setuppete.c +++ b/src/setups/mp_setuppete.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/mp_setupref.c b/src/setups/mp_setupref.c index d2fcdb8a4..7ea6ba73b 100644 --- a/src/setups/mp_setupref.c +++ b/src/setups/mp_setupref.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/mp_setuprit.c b/src/setups/mp_setuprit.c index 7b569d0b4..5c6cc4738 100644 --- a/src/setups/mp_setuprit.c +++ b/src/setups/mp_setuprit.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/mp_setuprun.c b/src/setups/mp_setuprun.c index 63cce749f..82431fc23 100644 --- a/src/setups/mp_setuprun.c +++ b/src/setups/mp_setuprun.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/mp_setupsev.c b/src/setups/mp_setupsev.c index 7a8d261ba..6a6701faf 100644 --- a/src/setups/mp_setupsev.c +++ b/src/setups/mp_setupsev.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/mp_setupsevb.c b/src/setups/mp_setupsevb.c index 70912c7cf..ec826f8f5 100644 --- a/src/setups/mp_setupsevb.c +++ b/src/setups/mp_setupsevb.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/mp_setupsevx.c b/src/setups/mp_setupsevx.c index e0b6743ff..50770203a 100644 --- a/src/setups/mp_setupsevx.c +++ b/src/setups/mp_setupsevx.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/mp_setupsho.c b/src/setups/mp_setupsho.c index 84f279a59..d8b24c236 100644 --- a/src/setups/mp_setupsho.c +++ b/src/setups/mp_setupsho.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/mp_setupsilo.c b/src/setups/mp_setupsilo.c index 6593c3664..56837031d 100644 --- a/src/setups/mp_setupsilo.c +++ b/src/setups/mp_setupsilo.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/mp_setupstat.c b/src/setups/mp_setupstat.c index 5258b2ccf..011df9f00 100644 --- a/src/setups/mp_setupstat.c +++ b/src/setups/mp_setupstat.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/mp_setuptra.c b/src/setups/mp_setuptra.c index fe8041864..dea66e525 100644 --- a/src/setups/mp_setuptra.c +++ b/src/setups/mp_setuptra.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/mp_setupuff.c b/src/setups/mp_setupuff.c index f89fdc016..1c17ef24d 100644 --- a/src/setups/mp_setupuff.c +++ b/src/setups/mp_setupuff.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/mp_setupwax.c b/src/setups/mp_setupwax.c index 9dfd12a50..d9b039d75 100644 --- a/src/setups/mp_setupwax.c +++ b/src/setups/mp_setupwax.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/setupame.c b/src/setups/setupame.c index 6610892c3..3987417c7 100644 --- a/src/setups/setupame.c +++ b/src/setups/setupame.c @@ -133,10 +133,10 @@ #define AILIST_SURRENDERING_GUARD 0x042f #define AILIST_INIT_FALCON_GUARD 0x0430 -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/setuparch.c b/src/setups/setuparch.c index 5003aa6cd..57c09f01c 100644 --- a/src/setups/setuparch.c +++ b/src/setups/setuparch.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/setuparec.c b/src/setups/setuparec.c index 8b7fb0a3b..ac6775a81 100644 --- a/src/setups/setuparec.c +++ b/src/setups/setuparec.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/setupark.c b/src/setups/setupark.c index 8b7e4bdf9..af7d84974 100644 --- a/src/setups/setupark.c +++ b/src/setups/setupark.c @@ -77,10 +77,10 @@ #define AILIST_DEFEND_PAD 0x0413 #define AILIST_INIT_SHOCK 0x0414 -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/setupash.c b/src/setups/setupash.c index e70826dc5..db9d59704 100644 --- a/src/setups/setupash.c +++ b/src/setups/setupash.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/setupate.c b/src/setups/setupate.c index 715cace58..e38bf29ab 100644 --- a/src/setups/setupate.c +++ b/src/setups/setupate.c @@ -25,10 +25,10 @@ #define AILIST_JON_INIT 0x0406 #define AILIST_TRENT_INIT 0x0407 -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/setupazt.c b/src/setups/setupazt.c index 0bca63c66..f157fd0d6 100644 --- a/src/setups/setupazt.c +++ b/src/setups/setupazt.c @@ -106,10 +106,10 @@ enum chrnum { #define AILIST_STARTING_AREA_GUARD 0x0421 #define AILIST_HIDE 0x0422 -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/setupcat.c b/src/setups/setupcat.c index e53ebfed4..d4be4efe4 100644 --- a/src/setups/setupcat.c +++ b/src/setups/setupcat.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/setupcave.c b/src/setups/setupcave.c index 6f6b585bd..5e9602583 100644 --- a/src/setups/setupcave.c +++ b/src/setups/setupcave.c @@ -78,10 +78,10 @@ #define AILIST_INIT_FOYER_CLONE 0x042b #define AILIST_FOYER_CLONE 0x042c -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/setupcrad.c b/src/setups/setupcrad.c index 4ae0bf14a..f15755b4d 100644 --- a/src/setups/setupcrad.c +++ b/src/setups/setupcrad.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/setupcryp.c b/src/setups/setupcryp.c index 0c07d72fd..60716c6ce 100644 --- a/src/setups/setupcryp.c +++ b/src/setups/setupcryp.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/setupdam.c b/src/setups/setupdam.c index 70c681cfe..e23103bff 100644 --- a/src/setups/setupdam.c +++ b/src/setups/setupdam.c @@ -86,10 +86,10 @@ #define AILIST_ELVIS_PREPARE_LEADING 0x0417 #define AILIST_ELVIS_AT_MOONPOOL 0x0418 -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/setupdepo.c b/src/setups/setupdepo.c index f4999a656..d6f50b192 100644 --- a/src/setups/setupdepo.c +++ b/src/setups/setupdepo.c @@ -98,10 +98,10 @@ #define AILIST_CLOAK_GUARD 0x0412 #define AILIST_CLOAK2_GUARD 0x0414 -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/setupdest.c b/src/setups/setupdest.c index 53307ebd3..8d98f48a9 100644 --- a/src/setups/setupdest.c +++ b/src/setups/setupdest.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/setupdish.c b/src/setups/setupdish.c index 140ef755f..69cb44831 100644 --- a/src/setups/setupdish.c +++ b/src/setups/setupdish.c @@ -94,10 +94,10 @@ #define PAD_DEVICEROOM 0x0121 #define PAD_HOLOROOM 0x0273 -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/setupear.c b/src/setups/setupear.c index 87d277046..2473c6796 100644 --- a/src/setups/setupear.c +++ b/src/setups/setupear.c @@ -89,10 +89,10 @@ #define AILIST_RADIOACTIVITY 0x0415 #define AILIST_OUTRO 0x0417 -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/setupeld.c b/src/setups/setupeld.c index 5edb9b385..3635b3c28 100644 --- a/src/setups/setupeld.c +++ b/src/setups/setupeld.c @@ -85,10 +85,10 @@ #define AILIST_CARRINGTON 0x0410 #define AILIST_CISOLIDER 0x0411 -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/setupimp.c b/src/setups/setupimp.c index b140eed0c..1f9ad1c03 100644 --- a/src/setups/setupimp.c +++ b/src/setups/setupimp.c @@ -141,10 +141,10 @@ #define AILIST_INIT_CISOLDIER 0x043c #define AILIST_CARRINGTON 0x043e -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, @@ -3352,7 +3352,7 @@ u8 func043a_unused[] = { }; u8 unregistered_function1[] = { - // All of these objects have been removed :\ + // All of these objects have been removed... // Wait for all 4 objects destroyed beginloop(0x04) if_object_in_good_condition(0x1f, /*goto*/ 0x08) diff --git a/src/setups/setupjun.c b/src/setups/setupjun.c index a698a0b7e..74fc0662c 100644 --- a/src/setups/setupjun.c +++ b/src/setups/setupjun.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/setuplam.c b/src/setups/setuplam.c index 142dd48a8..d5624157a 100644 --- a/src/setups/setuplam.c +++ b/src/setups/setuplam.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/setuplee.c b/src/setups/setuplee.c index a5fe67065..3e0f19dc1 100644 --- a/src/setups/setuplee.c +++ b/src/setups/setuplee.c @@ -230,10 +230,10 @@ enum labelnum { #define LABEL_6C LABEL_6D #endif -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/setuplen.c b/src/setups/setuplen.c index 42467c0f8..f5c9423fb 100644 --- a/src/setups/setuplen.c +++ b/src/setups/setuplen.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/setuplip.c b/src/setups/setuplip.c index 97c705e1c..ce1143b0c 100644 --- a/src/setups/setuplip.c +++ b/src/setups/setuplip.c @@ -321,10 +321,10 @@ enum labelnum { LABEL_F6 }; -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/setuplue.c b/src/setups/setuplue.c index 8a9950fdb..aa3b529c7 100644 --- a/src/setups/setuplue.c +++ b/src/setups/setuplue.c @@ -76,10 +76,10 @@ #define AILIST_ACTIVATE_AUTOGUN 0x0421 #define AILIST_ACTIVATE_LASERS 0x0424 -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/setupmp1.c b/src/setups/setupmp1.c index 99200f1d2..092d2fe5b 100644 --- a/src/setups/setupmp1.c +++ b/src/setups/setupmp1.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/setupmp10.c b/src/setups/setupmp10.c index a6d31c535..27cce04c9 100644 --- a/src/setups/setupmp10.c +++ b/src/setups/setupmp10.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/setupmp11.c b/src/setups/setupmp11.c index 64128cfe3..3ec4ab3f1 100644 --- a/src/setups/setupmp11.c +++ b/src/setups/setupmp11.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/setupmp12.c b/src/setups/setupmp12.c index db64588f9..3d788c4f5 100644 --- a/src/setups/setupmp12.c +++ b/src/setups/setupmp12.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/setupmp13.c b/src/setups/setupmp13.c index 258780e5e..c9262b6c3 100644 --- a/src/setups/setupmp13.c +++ b/src/setups/setupmp13.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/setupmp14.c b/src/setups/setupmp14.c index bcffcfd12..547203cee 100644 --- a/src/setups/setupmp14.c +++ b/src/setups/setupmp14.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/setupmp15.c b/src/setups/setupmp15.c index a51f15b5c..b90535aaa 100644 --- a/src/setups/setupmp15.c +++ b/src/setups/setupmp15.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/setupmp16.c b/src/setups/setupmp16.c index fcee2f1e2..26f90428f 100644 --- a/src/setups/setupmp16.c +++ b/src/setups/setupmp16.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/setupmp17.c b/src/setups/setupmp17.c index 983f56bf8..c69278d4c 100644 --- a/src/setups/setupmp17.c +++ b/src/setups/setupmp17.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/setupmp18.c b/src/setups/setupmp18.c index 4307deb00..95157b40c 100644 --- a/src/setups/setupmp18.c +++ b/src/setups/setupmp18.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/setupmp19.c b/src/setups/setupmp19.c index 943b38f1e..d19432449 100644 --- a/src/setups/setupmp19.c +++ b/src/setups/setupmp19.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/setupmp2.c b/src/setups/setupmp2.c index 116d356be..d9387668e 100644 --- a/src/setups/setupmp2.c +++ b/src/setups/setupmp2.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/setupmp20.c b/src/setups/setupmp20.c index 2ac9a8116..bd11e999a 100644 --- a/src/setups/setupmp20.c +++ b/src/setups/setupmp20.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/setupmp3.c b/src/setups/setupmp3.c index 37b539a0e..ebf3c8015 100644 --- a/src/setups/setupmp3.c +++ b/src/setups/setupmp3.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/setupmp4.c b/src/setups/setupmp4.c index b71ba3fb3..454744af0 100644 --- a/src/setups/setupmp4.c +++ b/src/setups/setupmp4.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/setupmp5.c b/src/setups/setupmp5.c index 83c241501..3e0e5a028 100644 --- a/src/setups/setupmp5.c +++ b/src/setups/setupmp5.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/setupmp6.c b/src/setups/setupmp6.c index c105e35a1..50cbbb3d8 100644 --- a/src/setups/setupmp6.c +++ b/src/setups/setupmp6.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/setupmp7.c b/src/setups/setupmp7.c index f1adff3bc..5cbad2c77 100644 --- a/src/setups/setupmp7.c +++ b/src/setups/setupmp7.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/setupmp8.c b/src/setups/setupmp8.c index 27cb8e98d..763f6511b 100644 --- a/src/setups/setupmp8.c +++ b/src/setups/setupmp8.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/setupmp9.c b/src/setups/setupmp9.c index fc964703f..dd8883fcf 100644 --- a/src/setups/setupmp9.c +++ b/src/setups/setupmp9.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/setupoat.c b/src/setups/setupoat.c index 21840431f..b0d3e967c 100644 --- a/src/setups/setupoat.c +++ b/src/setups/setupoat.c @@ -8,10 +8,10 @@ #define AILIST_INIT_ENEMY 0x0401 #define AILIST_INIT_MAIAN 0x0402 -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/setupold.c b/src/setups/setupold.c index bfdbd53df..c02bad2ac 100644 --- a/src/setups/setupold.c +++ b/src/setups/setupold.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/setuppam.c b/src/setups/setuppam.c index bad488d95..182ed45c3 100644 --- a/src/setups/setuppam.c +++ b/src/setups/setuppam.c @@ -95,10 +95,10 @@ #define PAD_PAAREA_TELEPORT 0x0200 #define PAD_DRCAROLLROOM_ENTRY 0x01cb -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, @@ -3877,7 +3877,7 @@ u8 func101b_pa_door4[] = { u8 func101c_pa_door5[] = { // @bug: One of the PA door glasses is checked twice, and one is not - // checked at all, hence why this doesn't use the pa_cylindar macro. + // checked at all, hence why this doesn't use the pa_cylinder macro. // Wait until any object destroyed beginloop(0x04) diff --git a/src/setups/setuppete.c b/src/setups/setuppete.c index e71c7311d..7fac66cdc 100644 --- a/src/setups/setuppete.c +++ b/src/setups/setuppete.c @@ -93,10 +93,10 @@ // Other #define GROUP_ALARM_RESPONDER 0x09 -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/setupref.c b/src/setups/setupref.c index 85f5c85f8..9b81b8e73 100644 --- a/src/setups/setupref.c +++ b/src/setups/setupref.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/setuprit.c b/src/setups/setuprit.c index fa0381706..d6d0b6c31 100644 --- a/src/setups/setuprit.c +++ b/src/setups/setuprit.c @@ -113,10 +113,10 @@ #define AILIST_REINIT_STRIPES 0x042b #define AILIST_REMOVE_IF_OFFSCREEN 0x042c -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/setuprun.c b/src/setups/setuprun.c index 7f7443089..11ceafdf9 100644 --- a/src/setups/setuprun.c +++ b/src/setups/setuprun.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/setupsev.c b/src/setups/setupsev.c index 028294e9c..86ad94b4d 100644 --- a/src/setups/setupsev.c +++ b/src/setups/setupsev.c @@ -40,10 +40,10 @@ #define AILIST_OUTRO 0x041b #define AILIST_INIT_LABTECH 0x041c -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/setupsevb.c b/src/setups/setupsevb.c index 70912c7cf..ec826f8f5 100644 --- a/src/setups/setupsevb.c +++ b/src/setups/setupsevb.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/setupsevx.c b/src/setups/setupsevx.c index f36f8cee3..566a3b6e4 100644 --- a/src/setups/setupsevx.c +++ b/src/setups/setupsevx.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/setupsevxb.c b/src/setups/setupsevxb.c index 541d58d9d..750cd3354 100644 --- a/src/setups/setupsevxb.c +++ b/src/setups/setupsevxb.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/setupsho.c b/src/setups/setupsho.c index dc12bfa86..57b67d9cb 100644 --- a/src/setups/setupsho.c +++ b/src/setups/setupsho.c @@ -101,10 +101,10 @@ #define AILIST_HIDE 0x0413 #define AILIST_OUTRO 0x0414 -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/setupsilo.c b/src/setups/setupsilo.c index 6593c3664..56837031d 100644 --- a/src/setups/setupsilo.c +++ b/src/setups/setupsilo.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/setupstat.c b/src/setups/setupstat.c index d98f28f25..ddb22723b 100644 --- a/src/setups/setupstat.c +++ b/src/setups/setupstat.c @@ -54,10 +54,10 @@ #define GROUP_KING2_SKEDAR 3 #define GROUP_KING3_SKEDAR 4 -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/setuptra.c b/src/setups/setuptra.c index 2e9e00497..e1b6035e9 100644 --- a/src/setups/setuptra.c +++ b/src/setups/setuptra.c @@ -93,10 +93,10 @@ #define SPAWNGROUP3 0x0b #define SPAWNGROUP4 0x0d -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/setupuff.c b/src/setups/setupuff.c index 8afcadac1..843b097b5 100644 --- a/src/setups/setupuff.c +++ b/src/setups/setupuff.c @@ -4,10 +4,10 @@ #include "stagesetup.h" -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL, diff --git a/src/setups/setupwax.c b/src/setups/setupwax.c index e579ce5f2..413d55af4 100644 --- a/src/setups/setupwax.c +++ b/src/setups/setupwax.c @@ -43,10 +43,10 @@ #define AILIST_CHIEF 0x0415 #define AILIST_OUTRO 0x0417 -s32 intro[]; -u32 props[]; -struct path paths[]; -struct ailist ailists[]; +extern s32 intro[]; +extern u32 props[]; +extern struct path paths[]; +extern struct ailist ailists[]; struct stagesetup setup = { NULL,